OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 GrAtlasTextContext_DEFINED | 8 #ifndef GrAtlasTextContext_DEFINED |
9 #define GrAtlasTextContext_DEFINED | 9 #define GrAtlasTextContext_DEFINED |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 class GrPipelineBuilder; | 24 class GrPipelineBuilder; |
25 class GrTextBlobCache; | 25 class GrTextBlobCache; |
26 class SkGlyph; | 26 class SkGlyph; |
27 | 27 |
28 /* | 28 /* |
29 * This class implements GrTextContext using standard bitmap fonts, and can also
process textblobs. | 29 * This class implements GrTextContext using standard bitmap fonts, and can also
process textblobs. |
30 * TODO replace GrBitmapTextContext | 30 * TODO replace GrBitmapTextContext |
31 */ | 31 */ |
32 class GrAtlasTextContext : public GrTextContext { | 32 class GrAtlasTextContext : public GrTextContext { |
33 public: | 33 public: |
34 static GrAtlasTextContext* Create(GrContext*, GrDrawContext*, const SkSurfac
eProps&); | 34 static GrAtlasTextContext* Create(GrContext*, const SkSurfaceProps&); |
35 | 35 |
36 private: | 36 private: |
37 GrAtlasTextContext(GrContext*, GrDrawContext*, const SkSurfaceProps&); | 37 GrAtlasTextContext(GrContext*, const SkSurfaceProps&); |
38 ~GrAtlasTextContext() override {} | 38 ~GrAtlasTextContext() override {} |
39 | 39 |
40 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, | 40 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, |
41 const SkPaint&, const SkMatrix& viewMatrix) override; | 41 const SkPaint&, const SkMatrix& viewMatrix) override; |
42 | 42 |
43 void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPain
t&, | 43 void onDrawText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrPain
t&, const SkPaint&, |
44 const SkMatrix& viewMatrix, const char text[], size_t byteLe
ngth, | 44 const SkMatrix& viewMatrix, const char text[], size_t byteLe
ngth, |
45 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; | 45 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; |
46 void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, | 46 void onDrawPosText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrP
aint&, |
47 const SkPaint&, const SkMatrix& viewMatrix, | 47 const SkPaint&, const SkMatrix& viewMatrix, |
48 const char text[], size_t byteLength, | 48 const char text[], size_t byteLength, |
49 const SkScalar pos[], int scalarsPerPosition, | 49 const SkScalar pos[], int scalarsPerPosition, |
50 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; | 50 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; |
51 void drawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&, | 51 void drawTextBlob(GrDrawContext*, GrRenderTarget*, const GrClip&, const SkPa
int&, |
52 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x,
SkScalar y, | 52 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x,
SkScalar y, |
53 SkDrawFilter*, const SkIRect& clipBounds) override; | 53 SkDrawFilter*, const SkIRect& clipBounds) override; |
54 | 54 |
55 typedef GrAtlasTextBlob::Run Run; | 55 typedef GrAtlasTextBlob::Run Run; |
56 typedef Run::SubRunInfo PerSubRunInfo; | 56 typedef Run::SubRunInfo PerSubRunInfo; |
57 | 57 |
58 inline bool canDrawAsDistanceFields(const SkPaint&, const SkMatrix& viewMatr
ix); | 58 inline bool canDrawAsDistanceFields(const SkPaint&, const SkMatrix& viewMatr
ix); |
59 GrAtlasTextBlob* setupDFBlob(int glyphCount, const SkPaint& origPaint, | 59 GrAtlasTextBlob* setupDFBlob(int glyphCount, const SkPaint& origPaint, |
60 const SkMatrix& viewMatrix, SkGlyphCache** cache
, | 60 const SkMatrix& viewMatrix, SkGlyphCache** cache
, |
61 SkPaint* dfPaint, SkScalar* textRatio); | 61 SkPaint* dfPaint, SkScalar* textRatio); |
62 void bmpAppendGlyph(GrAtlasTextBlob*, int runIndex, const SkGlyph&, int left
, int top, | 62 void bmpAppendGlyph(GrAtlasTextBlob*, int runIndex, const SkGlyph&, int left
, int top, |
63 GrColor color, GrFontScaler*, const SkIRect& clipRect); | 63 GrColor color, GrFontScaler*, const SkIRect& clipRect); |
64 bool dfAppendGlyph(GrAtlasTextBlob*, int runIndex, const SkGlyph&, SkScalar
sx, SkScalar sy, | 64 bool dfAppendGlyph(GrAtlasTextBlob*, int runIndex, const SkGlyph&, SkScalar
sx, SkScalar sy, |
65 GrColor color, GrFontScaler*, const SkIRect& clipRect, Sk
Scalar textRatio, | 65 GrColor color, GrFontScaler*, const SkIRect& clipRect, Sk
Scalar textRatio, |
66 const SkMatrix& viewMatrix); | 66 const SkMatrix& viewMatrix); |
67 inline void appendGlyphPath(GrAtlasTextBlob*, GrGlyph*, GrFontScaler*, const
SkGlyph&, | 67 inline void appendGlyphPath(GrAtlasTextBlob*, GrGlyph*, GrFontScaler*, const
SkGlyph&, |
68 SkScalar x, SkScalar y, SkScalar scale = 1.0f, | 68 SkScalar x, SkScalar y, SkScalar scale = 1.0f, |
69 bool applyVM = false); | 69 bool applyVM = false); |
70 inline void appendGlyphCommon(GrAtlasTextBlob*, Run*, Run::SubRunInfo*, | 70 inline void appendGlyphCommon(GrAtlasTextBlob*, Run*, Run::SubRunInfo*, |
71 const SkRect& positions, GrColor color, | 71 const SkRect& positions, GrColor color, |
72 size_t vertexStride, bool useVertexColor, | 72 size_t vertexStride, bool useVertexColor, |
73 GrGlyph*); | 73 GrGlyph*); |
74 | 74 |
75 inline void flushRunAsPaths(GrRenderTarget*, | 75 inline void flushRunAsPaths(GrDrawContext*, GrRenderTarget*, |
76 const SkTextBlob::RunIterator&, const GrClip& cl
ip, | 76 const SkTextBlob::RunIterator&, const GrClip& cl
ip, |
77 const SkPaint&, SkDrawFilter*, | 77 const SkPaint&, SkDrawFilter*, |
78 const SkMatrix& viewMatrix, const SkIRect& clipB
ounds, SkScalar x, | 78 const SkMatrix& viewMatrix, const SkIRect& clipB
ounds, SkScalar x, |
79 SkScalar y); | 79 SkScalar y); |
80 inline GrDrawBatch* createBatch(GrAtlasTextBlob*, const PerSubRunInfo&, | 80 inline GrDrawBatch* createBatch(GrAtlasTextBlob*, const PerSubRunInfo&, |
81 int glyphCount, int run, int subRun, | 81 int glyphCount, int run, int subRun, |
82 GrColor, SkScalar transX, SkScalar transY, | 82 GrColor, SkScalar transX, SkScalar transY, |
83 const SkPaint&); | 83 const SkPaint&); |
84 inline void flushRun(GrPipelineBuilder*, GrAtlasTextBlob*, int run, GrColor, | 84 inline void flushRun(GrDrawContext*, GrPipelineBuilder*, GrAtlasTextBlob*, i
nt run, GrColor, |
85 SkScalar transX, SkScalar transY, const SkPaint&); | 85 SkScalar transX, SkScalar transY, const SkPaint&); |
86 inline void flushBigGlyphs(GrAtlasTextBlob* cacheBlob, GrRenderTarget*, | 86 inline void flushBigGlyphs(GrAtlasTextBlob* cacheBlob, GrDrawContext*, GrRen
derTarget*, |
87 const GrClip& clip, const SkPaint& skPaint, | 87 const GrClip& clip, const SkPaint& skPaint, |
88 SkScalar transX, SkScalar transY, const SkIRect&
clipBounds); | 88 SkScalar transX, SkScalar transY, const SkIRect&
clipBounds); |
89 | 89 |
90 // We have to flush SkTextBlobs differently from drawText / drawPosText | 90 // We have to flush SkTextBlobs differently from drawText / drawPosText |
91 void flush(const SkTextBlob*, GrAtlasTextBlob*, GrRenderTarget*, | 91 void flush(const SkTextBlob*, GrAtlasTextBlob*, GrDrawContext*, GrRenderTarg
et*, |
92 const SkPaint&, const GrPaint&, SkDrawFilter*, const GrClip&, | 92 const SkPaint&, const GrPaint&, SkDrawFilter*, const GrClip&, |
93 const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x
, SkScalar y, | 93 const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x
, SkScalar y, |
94 SkScalar transX, SkScalar transY); | 94 SkScalar transX, SkScalar transY); |
95 void flush(GrAtlasTextBlob*, GrRenderTarget*, const SkPaint&, | 95 void flush(GrAtlasTextBlob*, GrDrawContext*, GrRenderTarget*, const SkPaint&
, |
96 const GrPaint&, const GrClip&, const SkIRect& clipBounds); | 96 const GrPaint&, const GrClip&, const SkIRect& clipBounds); |
97 | 97 |
98 // A helper for drawing BitmapText in a run of distance fields | 98 // A helper for drawing BitmapText in a run of distance fields |
99 inline void fallbackDrawPosText(GrAtlasTextBlob*, int runIndex, | 99 inline void fallbackDrawPosText(GrAtlasTextBlob*, int runIndex, |
100 GrRenderTarget*, const GrClip&, GrColor colo
r, | 100 GrRenderTarget*, const GrClip&, GrColor colo
r, |
101 const SkPaint&, const SkMatrix& viewMatrix, | 101 const SkPaint&, const SkMatrix& viewMatrix, |
102 const SkTDArray<char>& fallbackTxt, | 102 const SkTDArray<char>& fallbackTxt, |
103 const SkTDArray<SkScalar>& fallbackPos, | 103 const SkTDArray<SkScalar>& fallbackPos, |
104 int scalarsPerPosition, | 104 int scalarsPerPosition, |
105 const SkPoint& offset, | 105 const SkPoint& offset, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } | 174 } |
175 | 175 |
176 private: | 176 private: |
177 void buildDistanceAdjustTable(); | 177 void buildDistanceAdjustTable(); |
178 | 178 |
179 SkScalar* fTable; | 179 SkScalar* fTable; |
180 }; | 180 }; |
181 | 181 |
182 GrBatchTextStrike* fCurrStrike; | 182 GrBatchTextStrike* fCurrStrike; |
183 GrTextBlobCache* fCache; | 183 GrTextBlobCache* fCache; |
184 SkAutoTUnref<DistanceAdjustTable> fDistanceAdjustTable; | 184 SkAutoTUnref<const DistanceAdjustTable> fDistanceAdjustTable; |
185 | 185 |
186 friend class GrTextBlobCache; | 186 friend class GrTextBlobCache; |
187 friend class TextBatch; | 187 friend class TextBatch; |
188 | 188 |
189 #ifdef GR_TEST_UTILS | 189 #ifdef GR_TEST_UTILS |
190 DRAW_BATCH_TEST_FRIEND(TextBlobBatch); | 190 DRAW_BATCH_TEST_FRIEND(TextBlobBatch); |
191 #endif | 191 #endif |
192 | 192 |
193 typedef GrTextContext INHERITED; | 193 typedef GrTextContext INHERITED; |
194 }; | 194 }; |
195 | 195 |
196 #endif | 196 #endif |
OLD | NEW |