blob: 727358ec42d0fb811805952860bb7437985e7bc7 [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.com7d34d2e2011-01-24 17:41:47 +000041 GrPaint fPaint;
42 GrVertexLayout fVertexLayout;
reed@google.comac10a2d2010-12-22 21:39:39 +000043 GrContext* fContext;
44 GrDrawTarget* fDrawTarget;
45
46 GrMatrix fExtMatrix;
47 GrFontScaler* fScaler;
48 GrTextStrike* fStrike;
49
50 inline void flushGlyphs();
51
52 enum {
53 kMinRequestedGlyphs = 1,
54 kDefaultRequestedGlyphs = 64,
55 kMinRequestedVerts = kMinRequestedGlyphs * 4,
56 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
57 };
58
59 GrGpuTextVertex* fVertices;
bsalomon@google.com5782d712011-01-21 21:03:59 +000060
reed@google.comac10a2d2010-12-22 21:39:39 +000061 int32_t fMaxVertices;
62 GrTexture* fCurrTexture;
63 int fCurrVertex;
64
65 GrIRect fClipRect;
66 GrMatrix fOrigViewMatrix; // restore previous viewmatrix
67};
68
69#endif
70
71