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" | |
12 | |
13 #include "GrAtlasTextBlob.h" | 11 #include "GrAtlasTextBlob.h" |
14 #include "GrDistanceFieldAdjustTable.h" | 12 #include "GrDistanceFieldAdjustTable.h" |
15 #include "GrGeometryProcessor.h" | 13 #include "GrGeometryProcessor.h" |
16 #include "SkTextBlobRunIterator.h" | 14 #include "SkTextBlobRunIterator.h" |
17 | 15 |
18 #ifdef GR_TEST_UTILS | 16 #ifdef GR_TEST_UTILS |
19 #include "GrBatchTest.h" | 17 #include "GrBatchTest.h" |
20 #endif | 18 #endif |
21 | 19 |
22 class GrDrawBatch; | 20 class GrDrawBatch; |
23 class GrDrawContext; | 21 class GrDrawContext; |
24 class GrDrawTarget; | 22 class GrDrawTarget; |
25 class GrPipelineBuilder; | 23 class GrPipelineBuilder; |
26 class GrTextBlobCache; | 24 class GrTextBlobCache; |
27 class SkGlyph; | 25 class SkGlyph; |
28 | 26 |
29 /* | 27 /* |
30 * This class implements GrTextContext using standard bitmap fonts, and can also
process textblobs. | 28 * Renders text using some kind of an atlas, ie BitmapText or DistanceField text |
31 */ | 29 */ |
32 class GrAtlasTextContext : public GrTextContext { | 30 class GrAtlasTextContext { |
33 public: | 31 public: |
34 static GrAtlasTextContext* Create(); | 32 static GrAtlasTextContext* Create(); |
35 | 33 |
36 bool canDraw(const SkPaint&, const SkMatrix& viewMatrix, const SkSurfaceProp
s&, | 34 bool canDraw(const SkPaint&, const SkMatrix& viewMatrix, const SkSurfaceProp
s&, |
37 const GrShaderCaps&); | 35 const GrShaderCaps&); |
38 void drawText(GrContext*, GrDrawContext*, const GrClip&, const GrPaint&, con
st SkPaint&, | 36 void drawText(GrContext*, GrDrawContext*, const GrClip&, const GrPaint&, con
st SkPaint&, |
39 const SkMatrix& viewMatrix, const SkSurfaceProps&, const char
text[], | 37 const SkMatrix& viewMatrix, const SkSurfaceProps&, const char
text[], |
40 size_t byteLength, SkScalar x, SkScalar y, | 38 size_t byteLength, SkScalar x, SkScalar y, |
41 const SkIRect& regionClipBounds) override; | 39 const SkIRect& regionClipBounds); |
42 void drawPosText(GrContext*, GrDrawContext*, const GrClip&, const GrPaint&, | 40 void drawPosText(GrContext*, GrDrawContext*, const GrClip&, const GrPaint&, |
43 const SkPaint&, const SkMatrix& viewMatrix, const SkSurface
Props&, | 41 const SkPaint&, const SkMatrix& viewMatrix, const SkSurface
Props&, |
44 const char text[], size_t byteLength, | 42 const char text[], size_t byteLength, |
45 const SkScalar pos[], int scalarsPerPosition, | 43 const SkScalar pos[], int scalarsPerPosition, |
46 const SkPoint& offset, const SkIRect& regionClipBounds) ove
rride; | 44 const SkPoint& offset, const SkIRect& regionClipBounds); |
47 void drawTextBlob(GrContext*, GrDrawContext*, const GrClip&, const SkPaint&, | 45 void drawTextBlob(GrContext*, GrDrawContext*, const GrClip&, const SkPaint&, |
48 const SkMatrix& viewMatrix, const SkSurfaceProps&, const S
kTextBlob*, | 46 const SkMatrix& viewMatrix, const SkSurfaceProps&, const S
kTextBlob*, |
49 SkScalar x, SkScalar y, | 47 SkScalar x, SkScalar y, |
50 SkDrawFilter*, const SkIRect& clipBounds) override; | 48 SkDrawFilter*, const SkIRect& clipBounds); |
51 | 49 |
52 private: | 50 private: |
53 GrAtlasTextContext(); | 51 GrAtlasTextContext(); |
54 | 52 |
55 // sets up the descriptor on the blob and returns a detached cache. Client
must attach | 53 // sets up the descriptor on the blob and returns a detached cache. Client
must attach |
56 inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd); | 54 inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd); |
57 static void RegenerateTextBlob(GrAtlasTextBlob* bmp, | 55 static void RegenerateTextBlob(GrAtlasTextBlob* bmp, |
58 GrBatchFontCache*, | 56 GrBatchFontCache*, |
59 const GrShaderCaps&, | 57 const GrShaderCaps&, |
60 const SkPaint& skPaint, GrColor, | 58 const SkPaint& skPaint, GrColor, |
(...skipping 19 matching lines...) Expand all Loading... |
80 const SkScalar pos[], | 78 const SkScalar pos[], |
81 int scalarsPerPosition, | 79 int scalarsPerPosition, |
82 const SkPoint& offset); | 80 const SkPoint& offset); |
83 const GrDistanceFieldAdjustTable* dfAdjustTable() const { return fDistanceAd
justTable; } | 81 const GrDistanceFieldAdjustTable* dfAdjustTable() const { return fDistanceAd
justTable; } |
84 | 82 |
85 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; | 83 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; |
86 | 84 |
87 #ifdef GR_TEST_UTILS | 85 #ifdef GR_TEST_UTILS |
88 DRAW_BATCH_TEST_FRIEND(TextBlobBatch); | 86 DRAW_BATCH_TEST_FRIEND(TextBlobBatch); |
89 #endif | 87 #endif |
90 | |
91 typedef GrTextContext INHERITED; | |
92 }; | 88 }; |
93 | 89 |
94 #endif | 90 #endif |
OLD | NEW |