| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 GrStencilAndCoverTextContext_DEFINED | 8 #ifndef GrStencilAndCoverTextContext_DEFINED |
| 9 #define GrStencilAndCoverTextContext_DEFINED | 9 #define GrStencilAndCoverTextContext_DEFINED |
| 10 | 10 |
| 11 #include "GrTextContext.h" | 11 #include "GrTextContext.h" |
| 12 #include "GrDrawTarget.h" | 12 #include "GrDrawTarget.h" |
| 13 #include "GrStrokeInfo.h" | 13 #include "GrStrokeInfo.h" |
| 14 #include "SkTHash.h" | 14 #include "SkTHash.h" |
| 15 #include "SkTInternalLList.h" | 15 #include "SkTInternalLList.h" |
| 16 #include "SkTLList.h" | 16 #include "SkTLList.h" |
| 17 #include "batches/GrDrawPathBatch.h" | 17 #include "batches/GrDrawPathBatch.h" |
| 18 | 18 |
| 19 class GrAtlasTextContext; |
| 19 class GrTextStrike; | 20 class GrTextStrike; |
| 20 class GrPath; | 21 class GrPath; |
| 21 class SkSurfaceProps; | 22 class SkSurfaceProps; |
| 22 | 23 |
| 23 /* | 24 /* |
| 24 * This class implements text rendering using stencil and cover path rendering | 25 * This class implements text rendering using stencil and cover path rendering |
| 25 * (by the means of GrDrawTarget::drawPath). | 26 * (by the means of GrDrawTarget::drawPath). |
| 26 * This class exposes the functionality through GrTextContext interface. | 27 * This class exposes the functionality through GrTextContext interface. |
| 27 */ | 28 */ |
| 28 class GrStencilAndCoverTextContext : public GrTextContext { | 29 class GrStencilAndCoverTextContext : public GrTextContext { |
| 29 public: | 30 public: |
| 30 static GrStencilAndCoverTextContext* Create(GrContext*, const SkSurfaceProps
&); | 31 static GrStencilAndCoverTextContext* Create(GrContext*, const SkSurfaceProps
&); |
| 31 | 32 |
| 33 void drawText(GrDrawContext* dc, |
| 34 const GrClip&, const GrPaint&, const SkPaint&, |
| 35 const SkMatrix& viewMatrix, const char text[], size_t byteLeng
th, SkScalar x, |
| 36 SkScalar y, const SkIRect& clipBounds) override; |
| 37 void drawPosText(GrDrawContext*, |
| 38 const GrClip&, const GrPaint&, const SkPaint&, |
| 39 const SkMatrix& viewMatrix, |
| 40 const char text[], size_t byteLength, |
| 41 const SkScalar pos[], int scalarsPerPosition, |
| 42 const SkPoint& offset, const SkIRect& clipBounds) override; |
| 43 void drawTextBlob(GrDrawContext*, const GrClip&, const SkPaint&, |
| 44 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x,
SkScalar y, |
| 45 SkDrawFilter*, const SkIRect& clipBounds) override; |
| 46 |
| 32 virtual ~GrStencilAndCoverTextContext(); | 47 virtual ~GrStencilAndCoverTextContext(); |
| 33 | 48 |
| 34 private: | 49 private: |
| 35 GrStencilAndCoverTextContext(GrContext*, const SkSurfaceProps&); | 50 GrStencilAndCoverTextContext(GrContext*, const SkSurfaceProps&); |
| 36 | 51 |
| 37 bool canDraw(const SkPaint& skPaint, const SkMatrix&) override { | 52 bool canDraw(const SkPaint& skPaint, const SkMatrix&) { |
| 38 return this->internalCanDraw(skPaint); | 53 return this->internalCanDraw(skPaint); |
| 39 } | 54 } |
| 40 | 55 |
| 41 bool internalCanDraw(const SkPaint&); | 56 bool internalCanDraw(const SkPaint&); |
| 42 | 57 |
| 43 void onDrawText(GrDrawContext*, const GrClip&, const GrPaint&, const SkPaint
&, | 58 void uncachedDrawTextBlob(GrDrawContext* dc, |
| 44 const SkMatrix& viewMatrix, | 59 const GrClip& clip, const SkPaint& skPaint, |
| 45 const char text[], size_t byteLength, | 60 const SkMatrix& viewMatrix, |
| 46 SkScalar x, SkScalar y, const SkIRect& clipBounds) override; | 61 const SkTextBlob* blob, |
| 47 void onDrawPosText(GrDrawContext*, | 62 SkScalar x, SkScalar y, |
| 48 const GrClip&, const GrPaint&, const SkPaint&, | 63 SkDrawFilter* drawFilter, |
| 49 const SkMatrix& viewMatrix, | 64 const SkIRect& clipBounds); |
| 50 const char text[], size_t byteLength, | |
| 51 const SkScalar pos[], int scalarsPerPosition, | |
| 52 const SkPoint& offset, const SkIRect& clipBounds) overrid
e; | |
| 53 void drawTextBlob(GrDrawContext*, const GrClip&, const SkPaint&, | |
| 54 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x,
SkScalar y, | |
| 55 SkDrawFilter*, const SkIRect& clipBounds) override; | |
| 56 | 65 |
| 57 class FallbackBlobBuilder; | 66 class FallbackBlobBuilder; |
| 58 | 67 |
| 59 class TextRun { | 68 class TextRun { |
| 60 public: | 69 public: |
| 61 TextRun(const SkPaint& fontAndStroke); | 70 TextRun(const SkPaint& fontAndStroke); |
| 62 ~TextRun(); | 71 ~TextRun(); |
| 63 | 72 |
| 64 void setText(const char text[], size_t byteLength, SkScalar x, SkScalar
y); | 73 void setText(const char text[], size_t byteLength, SkScalar x, SkScalar
y); |
| 65 | 74 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 136 |
| 128 const SkSTArray<1, uint32_t, true> fKey; | 137 const SkSTArray<1, uint32_t, true> fKey; |
| 129 size_t fCpuMemorySize; | 138 size_t fCpuMemorySize; |
| 130 | 139 |
| 131 SK_DECLARE_INTERNAL_LLIST_INTERFACE(TextBlob); | 140 SK_DECLARE_INTERNAL_LLIST_INTERFACE(TextBlob); |
| 132 }; | 141 }; |
| 133 | 142 |
| 134 const TextBlob& findOrCreateTextBlob(const SkTextBlob*, const SkPaint&); | 143 const TextBlob& findOrCreateTextBlob(const SkTextBlob*, const SkPaint&); |
| 135 void purgeToFit(const TextBlob&); | 144 void purgeToFit(const TextBlob&); |
| 136 | 145 |
| 146 GrAtlasTextContext* fFallbackTextConte
xt; |
| 137 SkTHashMap<uint32_t, TextBlob*> fBlobIdCache; | 147 SkTHashMap<uint32_t, TextBlob*> fBlobIdCache; |
| 138 SkTHashTable<TextBlob*, const TextBlob::Key&, TextBlob> fBlobKeyCache; | 148 SkTHashTable<TextBlob*, const TextBlob::Key&, TextBlob> fBlobKeyCache; |
| 139 SkTInternalLList<TextBlob> fLRUList; | 149 SkTInternalLList<TextBlob> fLRUList; |
| 140 size_t fCacheSize; | 150 size_t fCacheSize; |
| 141 | 151 |
| 142 typedef GrTextContext INHERITED; | 152 typedef GrTextContext INHERITED; |
| 143 }; | 153 }; |
| 144 | 154 |
| 145 #endif | 155 #endif |
| OLD | NEW |