blob: d813c0935d39fdb3ef8cb3c44b6b65610f96a42d [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
2 Copyright 2010 Google Inc.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17
18#ifndef GrTextContext_DEFINED
19#define GrTextContext_DEFINED
20
21#include "GrGlyph.h"
22#include "GrGpuVertex.h"
23
24class GrContext;
25class GrTextStrike;
26class GrFontScaler;
27
28class GrTextContext {
29public:
bsalomon@google.com5782d712011-01-21 21:03:59 +000030 GrTextContext(GrContext*,
31 const GrPaint& paint,
32 const GrMatrix* extMatrix = NULL);
reed@google.comac10a2d2010-12-22 21:39:39 +000033 ~GrTextContext();
34
35 void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top,
36 GrFontScaler*);
37
38 void flush(); // optional; automatically called by destructor
39
40private:
bsalomon@google.com5782d712011-01-21 21:03:59 +000041 const GrPaint& fPaint;
reed@google.comac10a2d2010-12-22 21:39:39 +000042 GrContext* fContext;
43 GrDrawTarget* fDrawTarget;
44
45 GrMatrix fExtMatrix;
46 GrFontScaler* fScaler;
47 GrTextStrike* fStrike;
48
49 inline void flushGlyphs();
50
51 enum {
52 kMinRequestedGlyphs = 1,
53 kDefaultRequestedGlyphs = 64,
54 kMinRequestedVerts = kMinRequestedGlyphs * 4,
55 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
56 };
57
58 GrGpuTextVertex* fVertices;
bsalomon@google.com5782d712011-01-21 21:03:59 +000059
reed@google.comac10a2d2010-12-22 21:39:39 +000060 int32_t fMaxVertices;
61 GrTexture* fCurrTexture;
62 int fCurrVertex;
63
64 GrIRect fClipRect;
65 GrMatrix fOrigViewMatrix; // restore previous viewmatrix
66};
67
68#endif
69
70