blob: 6b7446b4be46c19c32fcc0e79034b01152e0c996 [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:
30 GrTextContext(GrContext*, const GrMatrix* extMatrix = NULL);
31 ~GrTextContext();
32
33 void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top,
34 GrFontScaler*);
35
36 void flush(); // optional; automatically called by destructor
37
38private:
39 GrContext* fContext;
40 GrDrawTarget* fDrawTarget;
41
42 GrMatrix fExtMatrix;
43 GrFontScaler* fScaler;
44 GrTextStrike* fStrike;
45
46 inline void flushGlyphs();
47
48 enum {
49 kMinRequestedGlyphs = 1,
50 kDefaultRequestedGlyphs = 64,
51 kMinRequestedVerts = kMinRequestedGlyphs * 4,
52 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
53 };
54
55 GrGpuTextVertex* fVertices;
56
57 int32_t fMaxVertices;
58 GrTexture* fCurrTexture;
59 int fCurrVertex;
60
61 GrIRect fClipRect;
62 GrMatrix fOrigViewMatrix; // restore previous viewmatrix
63};
64
65#endif
66
67