| 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 GrDrawTarget; | 24 class GrDrawTarget; |
| 25 class GrPipelineBuilder; | 25 class GrPipelineBuilder; |
| 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*); | 34 static GrAtlasTextContext* Create(); |
| 35 | 35 |
| 36 bool canDraw(const SkPaint&, const SkMatrix& viewMatrix, const SkSurfaceProp
s&); | 36 bool canDraw(const SkPaint&, const SkMatrix& viewMatrix, const SkSurfaceProp
s&, |
| 37 void drawText(GrDrawContext*, const GrClip&, const GrPaint&, const SkPaint&, | 37 const GrShaderCaps&); |
| 38 void drawText(GrContext*, GrDrawContext*, const GrClip&, const GrPaint&, con
st SkPaint&, |
| 38 const SkMatrix& viewMatrix, const SkSurfaceProps&, const char
text[], | 39 const SkMatrix& viewMatrix, const SkSurfaceProps&, const char
text[], |
| 39 size_t byteLength, SkScalar x, SkScalar y, | 40 size_t byteLength, SkScalar x, SkScalar y, |
| 40 const SkIRect& regionClipBounds) override; | 41 const SkIRect& regionClipBounds) override; |
| 41 void drawPosText(GrDrawContext*, const GrClip&, const GrPaint&, | 42 void drawPosText(GrContext*, GrDrawContext*, const GrClip&, const GrPaint&, |
| 42 const SkPaint&, const SkMatrix& viewMatrix, const SkSurface
Props&, | 43 const SkPaint&, const SkMatrix& viewMatrix, const SkSurface
Props&, |
| 43 const char text[], size_t byteLength, | 44 const char text[], size_t byteLength, |
| 44 const SkScalar pos[], int scalarsPerPosition, | 45 const SkScalar pos[], int scalarsPerPosition, |
| 45 const SkPoint& offset, const SkIRect& regionClipBounds) ove
rride; | 46 const SkPoint& offset, const SkIRect& regionClipBounds) ove
rride; |
| 46 void drawTextBlob(GrDrawContext*, const GrClip&, const SkPaint&, | 47 void drawTextBlob(GrContext*, GrDrawContext*, const GrClip&, const SkPaint&, |
| 47 const SkMatrix& viewMatrix, const SkSurfaceProps&, const S
kTextBlob*, | 48 const SkMatrix& viewMatrix, const SkSurfaceProps&, const S
kTextBlob*, |
| 48 SkScalar x, SkScalar y, | 49 SkScalar x, SkScalar y, |
| 49 SkDrawFilter*, const SkIRect& clipBounds) override; | 50 SkDrawFilter*, const SkIRect& clipBounds) override; |
| 50 | 51 |
| 51 private: | 52 private: |
| 52 GrAtlasTextContext(GrContext*); | 53 GrAtlasTextContext(); |
| 53 | 54 |
| 54 // sets up the descriptor on the blob and returns a detached cache. Client
must attach | 55 // sets up the descriptor on the blob and returns a detached cache. Client
must attach |
| 55 inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd); | 56 inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd); |
| 56 void regenerateTextBlob(GrAtlasTextBlob* bmp, const SkPaint& skPaint, GrColo
r, | 57 static void RegenerateTextBlob(GrAtlasTextBlob* bmp, |
| 57 const SkMatrix& viewMatrix, | 58 GrBatchFontCache*, |
| 58 const SkSurfaceProps&, | 59 const GrShaderCaps&, |
| 59 const SkTextBlob* blob, SkScalar x, SkScalar y, | 60 const SkPaint& skPaint, GrColor, |
| 60 SkDrawFilter* drawFilter); | 61 const SkMatrix& viewMatrix, |
| 62 const SkSurfaceProps&, |
| 63 const SkTextBlob* blob, SkScalar x, SkScalar
y, |
| 64 SkDrawFilter* drawFilter); |
| 61 inline static bool HasLCD(const SkTextBlob*); | 65 inline static bool HasLCD(const SkTextBlob*); |
| 62 | 66 |
| 63 // Test methods | 67 static inline GrAtlasTextBlob* CreateDrawTextBlob(GrTextBlobCache*, |
| 64 inline GrAtlasTextBlob* createDrawTextBlob(const GrPaint&, | 68 GrBatchFontCache*, const G
rShaderCaps&, |
| 65 const SkPaint&, const SkMatrix& v
iewMatrix, | 69 const GrPaint&, |
| 66 const SkSurfaceProps&, | 70 const SkPaint&, const SkMa
trix& viewMatrix, |
| 67 const char text[], size_t byteLen
gth, | 71 const SkSurfaceProps&, |
| 68 SkScalar x, SkScalar y); | 72 const char text[], size_t
byteLength, |
| 69 inline GrAtlasTextBlob* createDrawPosTextBlob(const GrPaint&, | 73 SkScalar x, SkScalar y); |
| 70 const SkPaint&, const SkMatrix
& viewMatrix, | 74 static inline GrAtlasTextBlob* CreateDrawPosTextBlob(GrTextBlobCache*, GrBat
chFontCache*, |
| 71 const SkSurfaceProps&, | 75 const GrShaderCaps&, |
| 72 const char text[], size_t byte
Length, | 76 const GrPaint&, |
| 73 const SkScalar pos[], int scal
arsPerPosition, | 77 const SkPaint&, const S
kMatrix& viewMatrix, |
| 74 const SkPoint& offset); | 78 const SkSurfaceProps&, |
| 79 const char text[], size
_t byteLength, |
| 80 const SkScalar pos[], |
| 81 int scalarsPerPosition, |
| 82 const SkPoint& offset); |
| 75 const GrDistanceFieldAdjustTable* dfAdjustTable() const { return fDistanceAd
justTable; } | 83 const GrDistanceFieldAdjustTable* dfAdjustTable() const { return fDistanceAd
justTable; } |
| 76 | 84 |
| 77 GrTextBlobCache* fCache; | |
| 78 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; | 85 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; |
| 79 | 86 |
| 80 #ifdef GR_TEST_UTILS | 87 #ifdef GR_TEST_UTILS |
| 81 DRAW_BATCH_TEST_FRIEND(TextBlobBatch); | 88 DRAW_BATCH_TEST_FRIEND(TextBlobBatch); |
| 82 #endif | 89 #endif |
| 83 | 90 |
| 84 typedef GrTextContext INHERITED; | 91 typedef GrTextContext INHERITED; |
| 85 }; | 92 }; |
| 86 | 93 |
| 87 #endif | 94 #endif |
| OLD | NEW |