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 GrGeometryProcessor; | 13 class GrGeometryProcessor; |
14 class GrTextStrike; | 14 class GrTextStrike; |
15 | 15 |
16 /* | 16 /* |
17 * This class implements GrTextContext using distance field fonts | 17 * This class implements GrTextContext using distance field fonts |
18 */ | 18 */ |
19 class GrDistanceFieldTextContext : public GrTextContext { | 19 class GrDistanceFieldTextContext : public GrTextContext { |
20 public: | 20 public: |
21 static GrDistanceFieldTextContext* Create(GrContext*, const SkDeviceProperti
es&, bool enable); | 21 static GrDistanceFieldTextContext* Create(GrContext*, SkGpuDevice*, const Sk
DeviceProperties&, |
| 22 bool enable); |
22 | 23 |
23 virtual ~GrDistanceFieldTextContext(); | 24 virtual ~GrDistanceFieldTextContext(); |
24 | 25 |
25 private: | 26 private: |
26 enum { | 27 enum { |
27 kMinRequestedGlyphs = 1, | 28 kMinRequestedGlyphs = 1, |
28 kDefaultRequestedGlyphs = 64, | 29 kDefaultRequestedGlyphs = 64, |
29 kMinRequestedVerts = kMinRequestedGlyphs * 4, | 30 kMinRequestedVerts = kMinRequestedGlyphs * 4, |
30 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, | 31 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, |
31 }; | 32 }; |
32 | 33 |
33 GrTextStrike* fStrike; | 34 GrTextStrike* fStrike; |
34 SkScalar fTextRatio; | 35 SkScalar fTextRatio; |
35 bool fUseLCDText; | 36 bool fUseLCDText; |
36 bool fEnableDFRendering; | 37 bool fEnableDFRendering; |
37 SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor; | 38 SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor; |
38 // Used to check whether fCachedEffect is still valid. | 39 // Used to check whether fCachedEffect is still valid. |
39 uint32_t fEffectTextureUniqueID; | 40 uint32_t fEffectTextureUniqueID; |
40 SkColor fEffectColor; | 41 SkColor fEffectColor; |
41 uint32_t fEffectFlags; | 42 uint32_t fEffectFlags; |
42 GrTexture* fGammaTexture; | 43 GrTexture* fGammaTexture; |
43 void* fVertices; | 44 void* fVertices; |
44 int fCurrVertex; | 45 int fCurrVertex; |
45 int fAllocVertexCount; | 46 int fAllocVertexCount; |
46 int fTotalVertexCount; | 47 int fTotalVertexCount; |
47 GrTexture* fCurrTexture; | 48 GrTexture* fCurrTexture; |
48 SkRect fVertexBounds; | 49 SkRect fVertexBounds; |
49 SkMatrix fViewMatrix; | 50 SkMatrix fViewMatrix; |
50 | 51 |
51 GrDistanceFieldTextContext(GrContext*, const SkDeviceProperties&, bool enabl
e); | 52 GrDistanceFieldTextContext(GrContext*, SkGpuDevice*, const SkDevicePropertie
s&, bool enable); |
52 | 53 |
53 bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) SK_OVERRIDE; | 54 bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) SK_OVERRIDE; |
54 | 55 |
55 virtual void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, cons
t SkPaint&, | 56 virtual void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, cons
t SkPaint&, |
56 const SkMatrix& viewMatrix, | 57 const SkMatrix& viewMatrix, |
57 const char text[], size_t byteLength, | 58 const char text[], size_t byteLength, |
58 SkScalar x, SkScalar y) SK_OVERRIDE; | 59 SkScalar x, SkScalar y, const SkIRect& regionClipBou
nds) SK_OVERRIDE; |
59 virtual void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, c
onst SkPaint&, | 60 virtual void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, c
onst SkPaint&, |
60 const SkMatrix& viewMatrix, | 61 const SkMatrix& viewMatrix, |
61 const char text[], size_t byteLength, | 62 const char text[], size_t byteLength, |
62 const SkScalar pos[], int scalarsPerPosition, | 63 const SkScalar pos[], int scalarsPerPosition, |
63 const SkPoint& offset) SK_OVERRIDE; | 64 const SkPoint& offset, const SkIRect& regionClipB
ounds) SK_OVERRIDE; |
64 | 65 |
65 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&); | 66 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, |
| 67 const SkIRect& regionClipBounds); |
66 bool appendGlyph(GrGlyph::PackedID, SkScalar left, SkScalar top, GrFontScale
r*); | 68 bool appendGlyph(GrGlyph::PackedID, SkScalar left, SkScalar top, GrFontScale
r*); |
67 bool uploadGlyph(GrGlyph*, GrFontScaler*); | 69 bool uploadGlyph(GrGlyph*, GrFontScaler*); |
68 void setupCoverageEffect(const SkColor& filteredColor); | 70 void setupCoverageEffect(const SkColor& filteredColor); |
69 void flush(); // automatically called by destructor | 71 void flush(); // automatically called by destructor |
70 void finish(); | 72 void finish(); |
71 }; | 73 }; |
72 | 74 |
73 #endif | 75 #endif |
OLD | NEW |