OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 GrStencilAndCoverTextContext_DEFINED | 8 #ifndef GrStencilAndCoverTextContext_DEFINED |
9 #define GrStencilAndCoverTextContext_DEFINED | 9 #define GrStencilAndCoverTextContext_DEFINED |
10 | 10 |
11 #include "GrTextContext.h" | 11 #include "GrTextContext.h" |
12 #include "GrDrawState.h" | 12 #include "GrDrawState.h" |
13 #include "GrDrawTarget.h" | 13 #include "GrDrawTarget.h" |
14 #include "SkStrokeRec.h" | 14 #include "SkStrokeRec.h" |
15 | 15 |
16 class GrTextStrike; | 16 class GrTextStrike; |
17 class GrPath; | 17 class GrPath; |
18 class GrPathRange; | 18 class GrPathRange; |
19 | 19 |
20 /* | 20 /* |
21 * This class implements text rendering using stencil and cover path rendering | 21 * This class implements text rendering using stencil and cover path rendering |
22 * (by the means of GrDrawTarget::drawPath). | 22 * (by the means of GrDrawTarget::drawPath). |
23 * This class exposes the functionality through GrTextContext interface. | 23 * This class exposes the functionality through GrTextContext interface. |
24 */ | 24 */ |
25 class GrStencilAndCoverTextContext : public GrTextContext { | 25 class GrStencilAndCoverTextContext : public GrTextContext { |
26 public: | 26 public: |
27 GrStencilAndCoverTextContext(GrContext*, const SkDeviceProperties&); | 27 static GrStencilAndCoverTextContext* Create(GrContext*, const SkDeviceProper
ties&); |
| 28 |
28 virtual ~GrStencilAndCoverTextContext(); | 29 virtual ~GrStencilAndCoverTextContext(); |
29 | 30 |
30 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE; | |
31 | |
32 virtual void drawText(const GrPaint&, const SkPaint&, const char text[], | |
33 size_t byteLength, | |
34 SkScalar x, SkScalar y) SK_OVERRIDE; | |
35 virtual void drawPosText(const GrPaint&, const SkPaint&, | |
36 const char text[], size_t byteLength, | |
37 const SkScalar pos[], int scalarsPerPosition, | |
38 const SkPoint& offset) SK_OVERRIDE; | |
39 | |
40 private: | 31 private: |
41 static const int kGlyphBufferSize = 1024; | 32 static const int kGlyphBufferSize = 1024; |
42 | 33 |
43 enum RenderMode { | 34 enum RenderMode { |
44 /** | 35 /** |
45 * This is the render mode used by drawText(), which is mainly used by | 36 * This is the render mode used by drawText(), which is mainly used by |
46 * the Skia unit tests. It tries match the other text backends exactly, | 37 * the Skia unit tests. It tries match the other text backends exactly, |
47 * with the exception of not implementing LCD text, and doing anti- | 38 * with the exception of not implementing LCD text, and doing anti- |
48 * aliasing with the built-in MSAA. | 39 * aliasing with the built-in MSAA. |
49 */ | 40 */ |
(...skipping 16 matching lines...) Expand all Loading... |
66 float fTextInverseRatio; | 57 float fTextInverseRatio; |
67 SkGlyphCache* fGlyphCache; | 58 SkGlyphCache* fGlyphCache; |
68 GrPathRange* fGlyphs; | 59 GrPathRange* fGlyphs; |
69 uint32_t fIndexBuffer[kGlyphBufferSize]; | 60 uint32_t fIndexBuffer[kGlyphBufferSize]; |
70 float fTransformBuffer[2 * kGlyphBufferSize]; | 61 float fTransformBuffer[2 * kGlyphBufferSize]; |
71 GrDrawTarget::PathTransformType fTransformType; | 62 GrDrawTarget::PathTransformType fTransformType; |
72 int fPendingGlyphCount; | 63 int fPendingGlyphCount; |
73 SkMatrix fContextInitialMatrix; | 64 SkMatrix fContextInitialMatrix; |
74 bool fNeedsDeviceSpaceGlyphs; | 65 bool fNeedsDeviceSpaceGlyphs; |
75 | 66 |
| 67 GrStencilAndCoverTextContext(GrContext*, const SkDeviceProperties&); |
| 68 |
| 69 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE; |
| 70 |
| 71 virtual void onDrawText(const GrPaint&, const SkPaint&, const char text[], |
| 72 size_t byteLength, |
| 73 SkScalar x, SkScalar y) SK_OVERRIDE; |
| 74 virtual void onDrawPosText(const GrPaint&, const SkPaint&, |
| 75 const char text[], size_t byteLength, |
| 76 const SkScalar pos[], int scalarsPerPosition, |
| 77 const SkPoint& offset) SK_OVERRIDE; |
| 78 |
76 void init(const GrPaint&, const SkPaint&, size_t textByteLength, | 79 void init(const GrPaint&, const SkPaint&, size_t textByteLength, |
77 RenderMode, const SkPoint& textTranslate); | 80 RenderMode, const SkPoint& textTranslate); |
78 void initGlyphs(SkGlyphCache* cache); | 81 void initGlyphs(SkGlyphCache* cache); |
79 void appendGlyph(uint16_t glyphID, float x); | 82 void appendGlyph(uint16_t glyphID, float x); |
80 void appendGlyph(uint16_t glyphID, float x, float y); | 83 void appendGlyph(uint16_t glyphID, float x, float y); |
81 void flush(); | 84 void flush(); |
82 void finish(); | 85 void finish(); |
83 | 86 |
84 }; | 87 }; |
85 | 88 |
86 #endif | 89 #endif |
OLD | NEW |