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 |
11 #include "GrTextContext.h" | 11 #include "GrTextContext.h" |
12 | 12 |
13 #include "GrBatchAtlas.h" | 13 #include "GrBatchAtlas.h" |
14 #include "GrBatchFontCache.h" | 14 #include "GrBatchFontCache.h" |
15 #include "GrGeometryProcessor.h" | 15 #include "GrGeometryProcessor.h" |
16 #include "SkDescriptor.h" | 16 #include "SkDescriptor.h" |
17 #include "GrMemoryPool.h" | 17 #include "GrMemoryPool.h" |
18 #include "SkMaskFilter.h" | 18 #include "SkMaskFilter.h" |
19 #include "SkTextBlob.h" | 19 #include "SkTextBlob.h" |
20 #include "SkTInternalLList.h" | 20 #include "SkTInternalLList.h" |
21 | 21 |
22 #ifdef GR_TEST_UTILS | 22 #ifdef GR_TEST_UTILS |
23 #include "GrBatchTest.h" | 23 #include "GrBatchTest.h" |
24 #endif | 24 #endif |
25 | 25 |
26 class BitmapTextBatch; | 26 class BitmapTextBatch; |
27 class GrDrawContext; | 27 class GrDrawContext; |
28 class GrDrawTarget; | |
29 class GrPipelineBuilder; | 28 class GrPipelineBuilder; |
30 class GrTextBlobCache; | 29 class GrTextBlobCache; |
31 | 30 |
32 /* | 31 /* |
33 * This class implements GrTextContext using standard bitmap fonts, and can also
process textblobs. | 32 * This class implements GrTextContext using standard bitmap fonts, and can also
process textblobs. |
34 * TODO replace GrBitmapTextContext | 33 * TODO replace GrBitmapTextContext |
35 */ | 34 */ |
36 class GrAtlasTextContext : public GrTextContext { | 35 class GrAtlasTextContext : public GrTextContext { |
37 public: | 36 public: |
38 static GrAtlasTextContext* Create(GrContext*, GrDrawContext*, | 37 static GrAtlasTextContext* Create(GrContext*, const SkDeviceProperties&, |
39 const SkDeviceProperties&, bool enableDist
anceFields); | 38 bool enableDistanceFields); |
40 | 39 |
41 private: | 40 private: |
42 GrAtlasTextContext(GrContext*, GrDrawContext*, const SkDeviceProperties&, bo
ol useDFT); | 41 GrAtlasTextContext(GrContext*, const SkDeviceProperties&, bool enableDistanc
eFields); |
43 ~GrAtlasTextContext() override {} | 42 ~GrAtlasTextContext() override {} |
44 | 43 |
45 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, | 44 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, |
46 const SkPaint&, const SkMatrix& viewMatrix) override; | 45 const SkPaint&, const SkMatrix& viewMatrix) override; |
47 | 46 |
48 void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPain
t&, | 47 void onDrawText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrPain
t&, const SkPaint&, |
49 const SkMatrix& viewMatrix, const char text[], size_t byteLe
ngth, | 48 const SkMatrix& viewMatrix, const char text[], size_t byteLe
ngth, |
50 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; | 49 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; |
51 void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, | 50 void onDrawPosText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrP
aint&, |
52 const SkPaint&, const SkMatrix& viewMatrix, | 51 const SkPaint&, const SkMatrix& viewMatrix, |
53 const char text[], size_t byteLength, | 52 const char text[], size_t byteLength, |
54 const SkScalar pos[], int scalarsPerPosition, | 53 const SkScalar pos[], int scalarsPerPosition, |
55 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; | 54 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; |
56 void drawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&, | 55 void drawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&, |
57 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x,
SkScalar y, | 56 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x,
SkScalar y, |
58 SkDrawFilter*, const SkIRect& clipBounds) override; | 57 SkDrawFilter*, const SkIRect& clipBounds) override; |
59 | 58 |
60 /* | 59 /* |
61 * A BitmapTextBlob contains a fully processed SkTextBlob, suitable for near
ly immediate drawing | 60 * A BitmapTextBlob contains a fully processed SkTextBlob, suitable for near
ly immediate drawing |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 bool dfAppendGlyph(BitmapTextBlob*, int runIndex, GrGlyph::PackedID, SkScala
r sx, SkScalar sy, | 264 bool dfAppendGlyph(BitmapTextBlob*, int runIndex, GrGlyph::PackedID, SkScala
r sx, SkScalar sy, |
266 GrColor color, GrFontScaler*, const SkIRect& clipRect, Sk
Scalar textRatio, | 265 GrColor color, GrFontScaler*, const SkIRect& clipRect, Sk
Scalar textRatio, |
267 const SkMatrix& viewMatrix); | 266 const SkMatrix& viewMatrix); |
268 inline void appendGlyphPath(BitmapTextBlob* blob, GrGlyph* glyph, | 267 inline void appendGlyphPath(BitmapTextBlob* blob, GrGlyph* glyph, |
269 GrFontScaler* scaler, SkScalar x, SkScalar y); | 268 GrFontScaler* scaler, SkScalar x, SkScalar y); |
270 inline void appendGlyphCommon(BitmapTextBlob*, Run*, Run::SubRunInfo*, | 269 inline void appendGlyphCommon(BitmapTextBlob*, Run*, Run::SubRunInfo*, |
271 const SkRect& positions, GrColor color, | 270 const SkRect& positions, GrColor color, |
272 size_t vertexStride, bool useVertexColor, | 271 size_t vertexStride, bool useVertexColor, |
273 GrGlyph*); | 272 GrGlyph*); |
274 | 273 |
275 inline void flushRunAsPaths(GrRenderTarget*, | 274 inline void flushRunAsPaths(GrDrawContext*, GrRenderTarget*, |
276 const SkTextBlob::RunIterator&, const GrClip& cl
ip, | 275 const SkTextBlob::RunIterator&, const GrClip& cl
ip, |
277 const SkPaint&, SkDrawFilter*, | 276 const SkPaint&, SkDrawFilter*, |
278 const SkMatrix& viewMatrix, const SkIRect& clipB
ounds, SkScalar x, | 277 const SkMatrix& viewMatrix, const SkIRect& clipB
ounds, SkScalar x, |
279 SkScalar y); | 278 SkScalar y); |
280 inline BitmapTextBatch* createBatch(BitmapTextBlob*, const PerSubRunInfo&, | 279 inline BitmapTextBatch* createBatch(BitmapTextBlob*, const PerSubRunInfo&, |
281 int glyphCount, int run, int subRun, | 280 int glyphCount, int run, int subRun, |
282 GrColor, SkScalar transX, SkScalar trans
Y, | 281 GrColor, SkScalar transX, SkScalar trans
Y, |
283 const SkPaint&); | 282 const SkPaint&); |
284 inline void flushRun(GrPipelineBuilder*, BitmapTextBlob*, int run, GrColor, | 283 inline void flushRun(GrDrawContext*, GrPipelineBuilder*, BitmapTextBlob*, in
t run, GrColor, |
285 SkScalar transX, SkScalar transY, const SkPaint&); | 284 SkScalar transX, SkScalar transY, const SkPaint&); |
286 inline void flushBigGlyphs(BitmapTextBlob* cacheBlob, GrRenderTarget*, | 285 inline void flushBigGlyphs(BitmapTextBlob* cacheBlob, GrDrawContext*, GrRend
erTarget*, |
287 const GrClip& clip, const SkPaint& skPaint, | 286 const GrClip& clip, const SkPaint& skPaint, |
288 SkScalar transX, SkScalar transY, const SkIRect&
clipBounds); | 287 SkScalar transX, SkScalar transY, const SkIRect&
clipBounds); |
289 | 288 |
290 // We have to flush SkTextBlobs differently from drawText / drawPosText | 289 // We have to flush SkTextBlobs differently from drawText / drawPosText |
291 void flush(const SkTextBlob*, BitmapTextBlob*, GrRenderTarget*, | 290 void flush(GrDrawContext*, const SkTextBlob*, BitmapTextBlob*, GrRenderTarge
t*, |
292 const SkPaint&, const GrPaint&, SkDrawFilter*, const GrClip&, | 291 const SkPaint&, const GrPaint&, SkDrawFilter*, const GrClip&, |
293 const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x
, SkScalar y, | 292 const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x
, SkScalar y, |
294 SkScalar transX, SkScalar transY); | 293 SkScalar transX, SkScalar transY); |
295 void flush(BitmapTextBlob*, GrRenderTarget*, const SkPaint&, | 294 void flush(GrDrawContext*, BitmapTextBlob*, GrRenderTarget*, const SkPaint&, |
296 const GrPaint&, const GrClip&, const SkIRect& clipBounds); | 295 const GrPaint&, const GrClip&, const SkIRect& clipBounds); |
297 | 296 |
298 // A helper for drawing BitmapText in a run of distance fields | 297 // A helper for drawing BitmapText in a run of distance fields |
299 inline void fallbackDrawPosText(BitmapTextBlob*, int runIndex, | 298 inline void fallbackDrawPosText(BitmapTextBlob*, int runIndex, |
300 GrRenderTarget*, const GrClip&, | 299 GrRenderTarget*, const GrClip&, |
301 const GrPaint&, | 300 const GrPaint&, |
302 const SkPaint&, const SkMatrix& viewMatrix, | 301 const SkPaint&, const SkMatrix& viewMatrix, |
303 const SkTDArray<char>& fallbackTxt, | 302 const SkTDArray<char>& fallbackTxt, |
304 const SkTDArray<SkScalar>& fallbackPos, | 303 const SkTDArray<SkScalar>& fallbackPos, |
305 int scalarsPerPosition, | 304 int scalarsPerPosition, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 friend class BitmapTextBatch; | 391 friend class BitmapTextBatch; |
393 | 392 |
394 #ifdef GR_TEST_UTILS | 393 #ifdef GR_TEST_UTILS |
395 BATCH_TEST_FRIEND(TextBlobBatch); | 394 BATCH_TEST_FRIEND(TextBlobBatch); |
396 #endif | 395 #endif |
397 | 396 |
398 typedef GrTextContext INHERITED; | 397 typedef GrTextContext INHERITED; |
399 }; | 398 }; |
400 | 399 |
401 #endif | 400 #endif |
OLD | NEW |