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 "GrDrawTarget.h" | 12 #include "GrDrawTarget.h" |
13 #include "GrStrokeInfo.h" | 13 #include "GrStrokeInfo.h" |
14 | 14 |
15 class GrTextStrike; | 15 class GrTextStrike; |
16 class GrPath; | 16 class GrPath; |
17 class GrPathRange; | 17 class GrPathRange; |
18 class GrPathRangeDraw; | |
19 class SkSurfaceProps; | 18 class SkSurfaceProps; |
20 | 19 |
21 /* | 20 /* |
22 * This class implements text rendering using stencil and cover path rendering | 21 * This class implements text rendering using stencil and cover path rendering |
23 * (by the means of GrDrawTarget::drawPath). | 22 * (by the means of GrDrawTarget::drawPath). |
24 * This class exposes the functionality through GrTextContext interface. | 23 * This class exposes the functionality through GrTextContext interface. |
25 */ | 24 */ |
26 class GrStencilAndCoverTextContext : public GrTextContext { | 25 class GrStencilAndCoverTextContext : public GrTextContext { |
27 public: | 26 public: |
28 static GrStencilAndCoverTextContext* Create(GrContext*, const SkSurfaceProps
&); | 27 static GrStencilAndCoverTextContext* Create(GrContext*, const SkSurfaceProps
&); |
29 | 28 |
30 virtual ~GrStencilAndCoverTextContext(); | 29 virtual ~GrStencilAndCoverTextContext(); |
31 | 30 |
32 private: | 31 private: |
33 SkScalar fTextRatio; | |
34 float fTextInverseRatio; | |
35 SkGlyphCache* fGlyphCache; | |
36 | |
37 GrPathRange* fGlyphs; | |
38 GrPathRangeDraw* fDraw; | |
39 GrStrokeInfo fStroke; | |
40 SkSTArray<32, uint16_t, true> fFallbackIndices; | |
41 SkSTArray<32, SkPoint, true> fFallbackPositions; | |
42 | |
43 SkMatrix fViewMatrix; | |
44 SkMatrix fLocalMatrix; | |
45 SkAutoTUnref<GrRenderTarget> fRenderTarget; | |
46 GrClip fClip; | |
47 SkIRect fClipRect; | |
48 SkIRect fRegionClipBounds; | |
49 GrPaint fPaint; | |
50 SkPaint fSkPaint; | |
51 | |
52 GrStencilAndCoverTextContext(GrContext*, const SkSurfaceProps&); | 32 GrStencilAndCoverTextContext(GrContext*, const SkSurfaceProps&); |
53 | 33 |
54 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, | 34 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, |
55 const SkPaint&, const SkMatrix& viewMatrix) override; | 35 const SkPaint&, const SkMatrix& viewMatrix) override; |
56 | 36 |
57 void onDrawText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrPain
t&, const SkPaint&, | 37 void onDrawText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrPain
t&, const SkPaint&, |
58 const SkMatrix& viewMatrix, | 38 const SkMatrix& viewMatrix, |
59 const char text[], size_t byteLength, | 39 const char text[], size_t byteLength, |
60 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; | 40 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; |
61 void onDrawPosText(GrDrawContext*, GrRenderTarget*, | 41 void onDrawPosText(GrDrawContext*, GrRenderTarget*, |
62 const GrClip&, const GrPaint&, const SkPaint&, | 42 const GrClip&, const GrPaint&, const SkPaint&, |
63 const SkMatrix& viewMatrix, | 43 const SkMatrix& viewMatrix, |
64 const char text[], size_t byteLength, | 44 const char text[], size_t byteLength, |
65 const SkScalar pos[], int scalarsPerPosition, | 45 const SkScalar pos[], int scalarsPerPosition, |
66 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; | 46 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; |
67 | 47 |
68 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, si
ze_t textByteLength, | 48 class TextRun { |
69 const SkMatrix& viewMatrix, const SkIRect& regionClipBounds); | 49 public: |
70 void appendGlyph(const SkGlyph&, const SkPoint&); | 50 TextRun(const SkPaint& fontAndStroke); |
71 void flush(GrDrawContext* dc); | 51 ~TextRun(); |
72 void finish(GrDrawContext* dc); | 52 |
| 53 void setText(const char text[], size_t byteLength, SkScalar x, SkScalar
y, |
| 54 GrContext*, const SkSurfaceProps*); |
| 55 |
| 56 void setPosText(const char text[], size_t byteLength, |
| 57 const SkScalar pos[], int scalarsPerPosition, const SkPo
int& offset, |
| 58 GrContext*, const SkSurfaceProps*); |
| 59 |
| 60 void draw(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrPaint&
, const SkMatrix&, |
| 61 const SkIRect& regionClipBounds, GrTextContext* fallbackTextCo
ntext, |
| 62 const SkPaint& originalSkPaint) const; |
| 63 |
| 64 private: |
| 65 GrPathRange* createGlyphs(GrContext*, SkGlyphCache*); |
| 66 |
| 67 void appendGlyph(const SkGlyph&, const SkPoint&); |
| 68 |
| 69 GrStrokeInfo fStroke; |
| 70 SkPaint fFont; |
| 71 SkScalar fTextRatio; |
| 72 float fTextInverseRatio; |
| 73 SkMatrix fLocalMatrix; |
| 74 bool fUsingRawGlyphPaths; |
| 75 SkAutoTUnref<GrPathRangeDraw> fDraw; |
| 76 SkSTArray<32, uint16_t, true> fFallbackIndices; |
| 77 SkSTArray<32, SkPoint, true> fFallbackPositions; |
| 78 }; |
73 | 79 |
74 typedef GrTextContext INHERITED; | 80 typedef GrTextContext INHERITED; |
75 }; | 81 }; |
76 | 82 |
77 #endif | 83 #endif |
OLD | NEW |