OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrDistanceFieldTextContext_DEFINED | 8 #ifndef GrDistanceFieldTextContext_DEFINED |
9 #define GrDistanceFieldTextContext_DEFINED | 9 #define GrDistanceFieldTextContext_DEFINED |
10 | 10 |
11 #include "GrTextContext.h" | 11 #include "GrTextContext.h" |
12 | 12 |
13 class GrTextStrike; | 13 class GrTextStrike; |
14 | 14 |
15 /* | 15 /* |
16 * This class implements GrTextContext using distance field fonts | 16 * This class implements GrTextContext using distance field fonts |
17 */ | 17 */ |
18 class GrDistanceFieldTextContext : public GrTextContext { | 18 class GrDistanceFieldTextContext : public GrTextContext { |
19 public: | 19 public: |
| 20 GrDistanceFieldTextContext(GrContext*, const GrPaint&, const SkPaint&); |
| 21 virtual ~GrDistanceFieldTextContext(); |
| 22 |
20 virtual void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, | 23 virtual void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, |
21 GrFontScaler*) SK_OVERRIDE; | 24 GrFontScaler*) SK_OVERRIDE; |
22 | 25 |
23 void drawText(const char text[], size_t byteLength, | 26 void drawText(const char text[], size_t byteLength, |
24 SkScalar x, SkScalar y, SkGlyphCache*, GrFontScaler*); | 27 SkScalar x, SkScalar y, SkGlyphCache*, GrFontScaler*); |
25 void drawPosText(const char text[], size_t byteLength, | 28 void drawPosText(const char text[], size_t byteLength, |
26 const SkScalar pos[], SkScalar constY, | 29 const SkScalar pos[], SkScalar constY, |
27 int scalarsPerPosition, | 30 int scalarsPerPosition, |
28 SkGlyphCache* cache, GrFontScaler* fontScaler); | 31 SkGlyphCache* cache, GrFontScaler* fontScaler); |
29 | 32 |
30 const SkPaint& getSkPaint() { return fSkPaint; } | 33 const SkPaint& getSkPaint() { return fSkPaint; } |
31 | 34 |
32 private: | 35 private: |
33 GrDistanceFieldTextContext(GrContext*, const GrPaint&, const SkPaint&); | |
34 virtual ~GrDistanceFieldTextContext(); | |
35 friend class GrTTextContextManager<GrDistanceFieldTextContext>; | |
36 | |
37 GrTextStrike* fStrike; | 36 GrTextStrike* fStrike; |
38 SkScalar fTextRatio; | 37 SkScalar fTextRatio; |
39 | 38 |
40 void flushGlyphs(); // automatically called by destructor | 39 void flushGlyphs(); // automatically called by destructor |
41 | 40 |
42 enum { | 41 enum { |
43 kMinRequestedGlyphs = 1, | 42 kMinRequestedGlyphs = 1, |
44 kDefaultRequestedGlyphs = 64, | 43 kDefaultRequestedGlyphs = 64, |
45 kMinRequestedVerts = kMinRequestedGlyphs * 4, | 44 kMinRequestedVerts = kMinRequestedGlyphs * 4, |
46 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, | 45 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, |
47 }; | 46 }; |
48 | 47 |
| 48 SkPaint fSkPaint; |
49 SkPoint* fVertices; | 49 SkPoint* fVertices; |
50 int32_t fMaxVertices; | 50 int32_t fMaxVertices; |
51 GrTexture* fCurrTexture; | 51 GrTexture* fCurrTexture; |
52 int fCurrVertex; | 52 int fCurrVertex; |
53 }; | 53 }; |
54 | 54 |
55 #endif | 55 #endif |
OLD | NEW |