• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright 2010 Google Inc.
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 
9 
10 
11 #ifndef GrTextContext_DEFINED
12 #define GrTextContext_DEFINED
13 
14 #include "GrContext.h"
15 #include "GrGlyph.h"
16 #include "GrPaint.h"
17 
18 struct GrGpuTextVertex;
19 class GrContext;
20 class GrTextStrike;
21 class GrFontScaler;
22 class GrDrawTarget;
23 
24 class GrTextContext {
25 public:
26     GrTextContext(GrContext*, const GrPaint&);
27     ~GrTextContext();
28 
29     void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top,
30                          GrFontScaler*);
31 
32     void flush();   // optional; automatically called by destructor
33 
34 private:
35     GrPaint         fPaint;
36     GrVertexLayout  fVertexLayout;
37     GrContext*      fContext;
38     GrDrawTarget*   fDrawTarget;
39 
40     GrFontScaler*   fScaler;
41     GrTextStrike*   fStrike;
42 
43     inline void flushGlyphs();
44     void setupDrawTarget();
45 
46     enum {
47         kMinRequestedGlyphs      = 1,
48         kDefaultRequestedGlyphs  = 64,
49         kMinRequestedVerts       = kMinRequestedGlyphs * 4,
50         kDefaultRequestedVerts   = kDefaultRequestedGlyphs * 4,
51     };
52 
53     GrGpuTextVertex*        fVertices;
54 
55     int32_t                 fMaxVertices;
56     GrTexture*              fCurrTexture;
57     int                     fCurrVertex;
58 
59     GrIRect                 fClipRect;
60     GrContext::AutoMatrix   fAutoMatrix;
61 };
62 
63 #endif
64