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 |
(...skipping 12 matching lines...) Expand all Loading... |
23 * (by the means of GrDrawTarget::drawPath). | 23 * (by the means of GrDrawTarget::drawPath). |
24 * This class exposes the functionality through GrTextContext interface. | 24 * This class exposes the functionality through GrTextContext interface. |
25 */ | 25 */ |
26 class GrStencilAndCoverTextContext : public GrTextContext { | 26 class GrStencilAndCoverTextContext : public GrTextContext { |
27 public: | 27 public: |
28 static GrStencilAndCoverTextContext* Create(GrContext*, const SkSurfaceProps
&); | 28 static GrStencilAndCoverTextContext* Create(GrContext*, const SkSurfaceProps
&); |
29 | 29 |
30 virtual ~GrStencilAndCoverTextContext(); | 30 virtual ~GrStencilAndCoverTextContext(); |
31 | 31 |
32 private: | 32 private: |
33 enum RenderMode { | |
34 /** | |
35 * This is the render mode used by drawText(), which is mainly used by | |
36 * the Skia unit tests. It tries match the other text backends exactly, | |
37 * with the exception of not implementing LCD text, and doing anti- | |
38 * aliasing with the built-in MSAA. | |
39 */ | |
40 kMaxAccuracy_RenderMode, | |
41 | |
42 /** | |
43 * This is the render mode used by drawPosText(). It ignores hinting and | |
44 * LCD text, even if the client provided positions for hinted glyphs, | |
45 * and renders from a canonically-sized, generic set of paths for the | |
46 * given typeface. In the future we should work out a system for the | |
47 * client to know it should not provide hinted glyph positions. This | |
48 * render mode also tries to use GPU stroking for fake bold, even when | |
49 * SK_USE_FREETYPE_EMBOLDEN is set. | |
50 */ | |
51 kMaxPerformance_RenderMode, | |
52 }; | |
53 | |
54 SkScalar fTextRatio; | 33 SkScalar fTextRatio; |
55 float fTextInverseRatio; | 34 float fTextInverseRatio; |
56 SkGlyphCache* fGlyphCache; | 35 SkGlyphCache* fGlyphCache; |
57 | 36 |
58 GrPathRange* fGlyphs; | 37 GrPathRange* fGlyphs; |
59 GrPathRangeDraw* fDraw; | 38 GrPathRangeDraw* fDraw; |
60 GrStrokeInfo fStroke; | 39 GrStrokeInfo fStroke; |
61 SkSTArray<32, uint16_t, true> fFallbackIndices; | 40 SkSTArray<32, uint16_t, true> fFallbackIndices; |
62 SkSTArray<32, SkPoint, true> fFallbackPositions; | 41 SkSTArray<32, SkPoint, true> fFallbackPositions; |
63 | 42 |
64 SkMatrix fContextInitialMatrix; | |
65 SkMatrix fViewMatrix; | 43 SkMatrix fViewMatrix; |
66 SkMatrix fLocalMatrix; | 44 SkMatrix fLocalMatrix; |
67 bool fUsingDeviceSpaceGlyphs; | |
68 SkAutoTUnref<GrRenderTarget> fRenderTarget; | 45 SkAutoTUnref<GrRenderTarget> fRenderTarget; |
69 GrClip fClip; | 46 GrClip fClip; |
70 SkIRect fClipRect; | 47 SkIRect fClipRect; |
71 SkIRect fRegionClipBounds; | 48 SkIRect fRegionClipBounds; |
72 GrPaint fPaint; | 49 GrPaint fPaint; |
73 SkPaint fSkPaint; | 50 SkPaint fSkPaint; |
74 | 51 |
75 GrStencilAndCoverTextContext(GrContext*, const SkSurfaceProps&); | 52 GrStencilAndCoverTextContext(GrContext*, const SkSurfaceProps&); |
76 | 53 |
77 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, | 54 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, |
78 const SkPaint&, const SkMatrix& viewMatrix) override; | 55 const SkPaint&, const SkMatrix& viewMatrix) override; |
79 | 56 |
80 void onDrawText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrPain
t&, const SkPaint&, | 57 void onDrawText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrPain
t&, const SkPaint&, |
81 const SkMatrix& viewMatrix, | 58 const SkMatrix& viewMatrix, |
82 const char text[], size_t byteLength, | 59 const char text[], size_t byteLength, |
83 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; | 60 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; |
84 void onDrawPosText(GrDrawContext*, GrRenderTarget*, | 61 void onDrawPosText(GrDrawContext*, GrRenderTarget*, |
85 const GrClip&, const GrPaint&, const SkPaint&, | 62 const GrClip&, const GrPaint&, const SkPaint&, |
86 const SkMatrix& viewMatrix, | 63 const SkMatrix& viewMatrix, |
87 const char text[], size_t byteLength, | 64 const char text[], size_t byteLength, |
88 const SkScalar pos[], int scalarsPerPosition, | 65 const SkScalar pos[], int scalarsPerPosition, |
89 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; | 66 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; |
90 | 67 |
91 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, | 68 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, si
ze_t textByteLength, |
92 size_t textByteLength, RenderMode, const SkMatrix& viewMatrix, | 69 const SkMatrix& viewMatrix, const SkIRect& regionClipBounds); |
93 const SkIRect& regionClipBounds); | |
94 bool mapToFallbackContext(SkMatrix* inverse); | |
95 void appendGlyph(const SkGlyph&, const SkPoint&); | 70 void appendGlyph(const SkGlyph&, const SkPoint&); |
96 void flush(GrDrawContext* dc); | 71 void flush(GrDrawContext* dc); |
97 void finish(GrDrawContext* dc); | 72 void finish(GrDrawContext* dc); |
98 | 73 |
99 typedef GrTextContext INHERITED; | 74 typedef GrTextContext INHERITED; |
100 }; | 75 }; |
101 | 76 |
102 #endif | 77 #endif |
OLD | NEW |