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 15 matching lines...) Expand all Loading... |
26 class GrTextBlobCache; | 26 class GrTextBlobCache; |
27 class SkGlyph; | 27 class SkGlyph; |
28 | 28 |
29 /* | 29 /* |
30 * This class implements GrTextContext using standard bitmap fonts, and can also
process textblobs. | 30 * This class implements GrTextContext using standard bitmap fonts, and can also
process textblobs. |
31 */ | 31 */ |
32 class GrAtlasTextContext : public GrTextContext { | 32 class GrAtlasTextContext : public GrTextContext { |
33 public: | 33 public: |
34 static GrAtlasTextContext* Create(GrContext*, const SkSurfaceProps&); | 34 static GrAtlasTextContext* Create(GrContext*, const SkSurfaceProps&); |
35 | 35 |
36 private: | 36 bool canDraw(const SkPaint&, const SkMatrix& viewMatrix); |
37 GrAtlasTextContext(GrContext*, const SkSurfaceProps&); | 37 void drawText(GrDrawContext*, const GrClip&, const GrPaint&, const SkPaint&, |
38 ~GrAtlasTextContext() override {} | 38 const SkMatrix& viewMatrix, const char text[], size_t byteLeng
th, |
39 | 39 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) overr
ide; |
40 bool canDraw(const SkPaint&, const SkMatrix& viewMatrix) override; | 40 void drawPosText(GrDrawContext*, const GrClip&, const GrPaint&, |
41 | 41 const SkPaint&, const SkMatrix& viewMatrix, |
42 void onDrawText(GrDrawContext*, const GrClip&, const GrPaint&, const SkPaint
&, | 42 const char text[], size_t byteLength, |
43 const SkMatrix& viewMatrix, const char text[], size_t byteLe
ngth, | 43 const SkScalar pos[], int scalarsPerPosition, |
44 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; | 44 const SkPoint& offset, const SkIRect& regionClipBounds) ove
rride; |
45 void onDrawPosText(GrDrawContext*, const GrClip&, const GrPaint&, | |
46 const SkPaint&, const SkMatrix& viewMatrix, | |
47 const char text[], size_t byteLength, | |
48 const SkScalar pos[], int scalarsPerPosition, | |
49 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; | |
50 void drawTextBlob(GrDrawContext*, const GrClip&, const SkPaint&, | 45 void drawTextBlob(GrDrawContext*, const GrClip&, const SkPaint&, |
51 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x,
SkScalar y, | 46 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x,
SkScalar y, |
52 SkDrawFilter*, const SkIRect& clipBounds) override; | 47 SkDrawFilter*, const SkIRect& clipBounds) override; |
53 | 48 |
| 49 private: |
| 50 GrAtlasTextContext(GrContext*, const SkSurfaceProps&); |
| 51 |
54 // sets up the descriptor on the blob and returns a detached cache. Client
must attach | 52 // sets up the descriptor on the blob and returns a detached cache. Client
must attach |
55 inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd); | 53 inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd); |
56 void regenerateTextBlob(GrAtlasTextBlob* bmp, const SkPaint& skPaint, GrColo
r, | 54 void regenerateTextBlob(GrAtlasTextBlob* bmp, const SkPaint& skPaint, GrColo
r, |
57 const SkMatrix& viewMatrix, | 55 const SkMatrix& viewMatrix, |
58 const SkTextBlob* blob, SkScalar x, SkScalar y, | 56 const SkTextBlob* blob, SkScalar x, SkScalar y, |
59 SkDrawFilter* drawFilter); | 57 SkDrawFilter* drawFilter); |
60 inline static bool HasLCD(const SkTextBlob*); | 58 inline static bool HasLCD(const SkTextBlob*); |
61 | 59 |
62 // Test methods | 60 // Test methods |
63 // TODO this is really ugly. It'd be much nicer if positioning could be mov
ed to batch | |
64 inline GrAtlasTextBlob* createDrawTextBlob(const GrPaint&, | 61 inline GrAtlasTextBlob* createDrawTextBlob(const GrPaint&, |
65 const SkPaint&, const SkMatrix& v
iewMatrix, | 62 const SkPaint&, const SkMatrix& v
iewMatrix, |
66 const char text[], size_t byteLen
gth, | 63 const char text[], size_t byteLen
gth, |
67 SkScalar x, SkScalar y); | 64 SkScalar x, SkScalar y); |
68 inline GrAtlasTextBlob* createDrawPosTextBlob(const GrPaint&, | 65 inline GrAtlasTextBlob* createDrawPosTextBlob(const GrPaint&, |
69 const SkPaint&, const SkMatrix
& viewMatrix, | 66 const SkPaint&, const SkMatrix
& viewMatrix, |
70 const char text[], size_t byte
Length, | 67 const char text[], size_t byte
Length, |
71 const SkScalar pos[], int scal
arsPerPosition, | 68 const SkScalar pos[], int scal
arsPerPosition, |
72 const SkPoint& offset); | 69 const SkPoint& offset); |
73 const GrDistanceFieldAdjustTable* dfAdjustTable() const { return fDistanceAd
justTable; } | 70 const GrDistanceFieldAdjustTable* dfAdjustTable() const { return fDistanceAd
justTable; } |
74 | 71 |
75 GrBatchTextStrike* fCurrStrike; | |
76 GrTextBlobCache* fCache; | 72 GrTextBlobCache* fCache; |
77 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; | 73 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; |
78 | 74 |
79 #ifdef GR_TEST_UTILS | 75 #ifdef GR_TEST_UTILS |
80 DRAW_BATCH_TEST_FRIEND(TextBlobBatch); | 76 DRAW_BATCH_TEST_FRIEND(TextBlobBatch); |
81 #endif | 77 #endif |
82 | 78 |
83 typedef GrTextContext INHERITED; | 79 typedef GrTextContext INHERITED; |
84 }; | 80 }; |
85 | 81 |
86 #endif | 82 #endif |
OLD | NEW |