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 "SkStrokeRec.h" | 14 #include "SkStrokeRec.h" |
14 | 15 |
15 class GrTextStrike; | 16 class GrTextStrike; |
16 class GrPath; | 17 class GrPath; |
17 | 18 |
18 /* | 19 /* |
19 * This class implements text rendering using stencil and cover path rendering | 20 * This class implements text rendering using stencil and cover path rendering |
20 * (by the means of GrDrawTarget::drawPath). | 21 * (by the means of GrDrawTarget::drawPath). |
21 * This class exposes the functionality through GrTextContext interface. | 22 * This class exposes the functionality through GrTextContext interface. |
22 */ | 23 */ |
23 class GrStencilAndCoverTextContext : public GrTextContext { | 24 class GrStencilAndCoverTextContext : public GrTextContext { |
24 public: | 25 public: |
25 GrStencilAndCoverTextContext(GrContext*, const SkDeviceProperties&); | 26 GrStencilAndCoverTextContext(GrContext*, const SkDeviceProperties&); |
26 virtual ~GrStencilAndCoverTextContext(); | 27 virtual ~GrStencilAndCoverTextContext(); |
27 | 28 |
28 virtual void drawText(const GrPaint&, const SkPaint&, const char text[], | 29 virtual void drawText(const GrPaint&, const SkPaint&, const char text[], |
29 size_t byteLength, | 30 size_t byteLength, |
30 SkScalar x, SkScalar y) SK_OVERRIDE; | 31 SkScalar x, SkScalar y) SK_OVERRIDE; |
31 virtual void drawPosText(const GrPaint&, const SkPaint&, | 32 virtual void drawPosText(const GrPaint&, const SkPaint&, |
32 const char text[], size_t byteLength, | 33 const char text[], size_t byteLength, |
33 const SkScalar pos[], SkScalar constY, | 34 const SkScalar pos[], SkScalar constY, |
34 int scalarsPerPosition) SK_OVERRIDE; | 35 int scalarsPerPosition) SK_OVERRIDE; |
35 | 36 |
36 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE; | 37 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE; |
37 | 38 |
38 private: | 39 private: |
39 class GlyphPathRange; | 40 class GlyphPathRange; |
40 static const int kGlyphBufferSize = 1024; | 41 static const int kGlyphBufferSize = 1024; |
41 | 42 |
42 void init(const GrPaint&, const SkPaint&, size_t textByteLength); | 43 enum DeviceSpaceGlyphsBehavior { |
| 44 kUseIfNeeded_DeviceSpaceGlyphsBehavior, |
| 45 kDoNotUse_DeviceSpaceGlyphsBehavior, |
| 46 }; |
| 47 void init(const GrPaint&, const SkPaint&, size_t textByteLength, |
| 48 DeviceSpaceGlyphsBehavior, SkScalar textTranslateY = 0); |
43 void initGlyphs(SkGlyphCache* cache); | 49 void initGlyphs(SkGlyphCache* cache); |
| 50 void appendGlyph(uint16_t glyphID, float x); |
44 void appendGlyph(uint16_t glyphID, float x, float y); | 51 void appendGlyph(uint16_t glyphID, float x, float y); |
45 void flush(); | 52 void flush(); |
46 void finish(); | 53 void finish(); |
47 | 54 |
48 GrDrawState::AutoRestoreEffects fStateRestore; | 55 GrDrawState::AutoRestoreEffects fStateRestore; |
49 SkScalar fTextRatio; | 56 SkScalar fTextRatio; |
| 57 float fTextInverseRatio; |
50 SkStrokeRec fStroke; | 58 SkStrokeRec fStroke; |
51 SkGlyphCache* fGlyphCache; | 59 SkGlyphCache* fGlyphCache; |
52 GlyphPathRange* fGlyphs; | 60 GlyphPathRange* fGlyphs; |
53 uint32_t fIndexBuffer[kGlyphBufferSize]; | 61 uint32_t fIndexBuffer[kGlyphBufferSize]; |
54 float fTransformBuffer[6 * kGlyphBufferSize]; | 62 float fTransformBuffer[2 * kGlyphBufferSize]; |
| 63 GrDrawTarget::PathTransformType fTransformType; |
55 int fPendingGlyphCount; | 64 int fPendingGlyphCount; |
56 SkMatrix fGlyphTransform; | 65 SkMatrix fContextInitialMatrix; |
57 bool fNeedsDeviceSpaceGlyphs; | 66 bool fNeedsDeviceSpaceGlyphs; |
58 }; | 67 }; |
59 | 68 |
60 #endif | 69 #endif |
OLD | NEW |