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 | |
23 virtual void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, | 20 virtual void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, |
24 GrFontScaler*) SK_OVERRIDE; | 21 GrFontScaler*) SK_OVERRIDE; |
25 | 22 |
26 void drawText(const char text[], size_t byteLength, | 23 void drawText(const char text[], size_t byteLength, |
27 SkScalar x, SkScalar y, SkGlyphCache*, GrFontScaler*); | 24 SkScalar x, SkScalar y, SkGlyphCache*, GrFontScaler*); |
28 void drawPosText(const char text[], size_t byteLength, | 25 void drawPosText(const char text[], size_t byteLength, |
29 const SkScalar pos[], SkScalar constY, | 26 const SkScalar pos[], SkScalar constY, |
30 int scalarsPerPosition, | 27 int scalarsPerPosition, |
31 SkGlyphCache* cache, GrFontScaler* fontScaler); | 28 SkGlyphCache* cache, GrFontScaler* fontScaler); |
32 | 29 |
33 const SkPaint& getSkPaint() { return fSkPaint; } | 30 const SkPaint& getSkPaint() { return fSkPaint; } |
34 | 31 |
35 private: | 32 private: |
| 33 GrDistanceFieldTextContext(GrContext*, const GrPaint&, const SkPaint&); |
| 34 virtual ~GrDistanceFieldTextContext(); |
| 35 friend class GrTTextContextFactory<GrDistanceFieldTextContext>; |
| 36 |
36 GrTextStrike* fStrike; | 37 GrTextStrike* fStrike; |
37 SkScalar fTextRatio; | 38 SkScalar fTextRatio; |
38 | 39 |
39 void flushGlyphs(); // automatically called by destructor | 40 void flushGlyphs(); // automatically called by destructor |
40 | 41 |
41 enum { | 42 enum { |
42 kMinRequestedGlyphs = 1, | 43 kMinRequestedGlyphs = 1, |
43 kDefaultRequestedGlyphs = 64, | 44 kDefaultRequestedGlyphs = 64, |
44 kMinRequestedVerts = kMinRequestedGlyphs * 4, | 45 kMinRequestedVerts = kMinRequestedGlyphs * 4, |
45 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, | 46 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, |
46 }; | 47 }; |
47 | 48 |
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 |