| 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" | |
| 12 #include "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
| 13 #include "GrStrokeInfo.h" | 12 #include "GrStrokeInfo.h" |
| 13 #include "SkDrawFilter.h" |
| 14 #include "SkTextBlob.h" |
| 14 #include "SkTHash.h" | 15 #include "SkTHash.h" |
| 15 #include "SkTInternalLList.h" | 16 #include "SkTInternalLList.h" |
| 16 #include "SkTLList.h" | 17 #include "SkTLList.h" |
| 17 #include "batches/GrDrawPathBatch.h" | 18 #include "batches/GrDrawPathBatch.h" |
| 18 | 19 |
| 19 class GrAtlasTextContext; | 20 class GrAtlasTextContext; |
| 20 class GrTextStrike; | 21 class GrTextStrike; |
| 21 class GrPath; | 22 class GrPath; |
| 22 class SkSurfaceProps; | 23 class SkSurfaceProps; |
| 23 | 24 |
| 24 /* | 25 /* |
| 25 * This class implements text rendering using stencil and cover path rendering | 26 * This class implements text rendering using stencil and cover path rendering |
| 26 * (by the means of GrDrawTarget::drawPath). | 27 * (by the means of GrDrawTarget::drawPath). |
| 27 * This class exposes the functionality through GrTextContext interface. | |
| 28 */ | 28 */ |
| 29 class GrStencilAndCoverTextContext : public GrTextContext { | 29 class GrStencilAndCoverTextContext { |
| 30 public: | 30 public: |
| 31 static GrStencilAndCoverTextContext* Create(); | 31 static GrStencilAndCoverTextContext* Create(); |
| 32 | 32 |
| 33 void drawText(GrContext*, GrDrawContext* dc, | 33 void drawText(GrContext*, GrDrawContext* dc, |
| 34 const GrClip&, const GrPaint&, const SkPaint&, | 34 const GrClip&, const GrPaint&, const SkPaint&, |
| 35 const SkMatrix& viewMatrix, const SkSurfaceProps&, const char
text[], | 35 const SkMatrix& viewMatrix, const SkSurfaceProps&, const char
text[], |
| 36 size_t byteLength, SkScalar x, | 36 size_t byteLength, SkScalar x, |
| 37 SkScalar y, const SkIRect& clipBounds) override; | 37 SkScalar y, const SkIRect& clipBounds); |
| 38 void drawPosText(GrContext*, GrDrawContext*, | 38 void drawPosText(GrContext*, GrDrawContext*, |
| 39 const GrClip&, const GrPaint&, const SkPaint&, | 39 const GrClip&, const GrPaint&, const SkPaint&, |
| 40 const SkMatrix& viewMatrix, const SkSurfaceProps&, | 40 const SkMatrix& viewMatrix, const SkSurfaceProps&, |
| 41 const char text[], size_t byteLength, | 41 const char text[], size_t byteLength, |
| 42 const SkScalar pos[], int scalarsPerPosition, | 42 const SkScalar pos[], int scalarsPerPosition, |
| 43 const SkPoint& offset, const SkIRect& clipBounds) override; | 43 const SkPoint& offset, const SkIRect& clipBounds); |
| 44 void drawTextBlob(GrContext*, GrDrawContext*, const GrClip&, const SkPaint&, | 44 void drawTextBlob(GrContext*, GrDrawContext*, const GrClip&, const SkPaint&, |
| 45 const SkMatrix& viewMatrix, const SkSurfaceProps&, const S
kTextBlob*, | 45 const SkMatrix& viewMatrix, const SkSurfaceProps&, const S
kTextBlob*, |
| 46 SkScalar x, SkScalar y, | 46 SkScalar x, SkScalar y, |
| 47 SkDrawFilter*, const SkIRect& clipBounds) override; | 47 SkDrawFilter*, const SkIRect& clipBounds); |
| 48 | 48 |
| 49 virtual ~GrStencilAndCoverTextContext(); | 49 virtual ~GrStencilAndCoverTextContext(); |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 GrStencilAndCoverTextContext(); | 52 GrStencilAndCoverTextContext(); |
| 53 | 53 |
| 54 bool canDraw(const SkPaint& skPaint, const SkMatrix&) { | 54 bool canDraw(const SkPaint& skPaint, const SkMatrix&) { |
| 55 return this->internalCanDraw(skPaint); | 55 return this->internalCanDraw(skPaint); |
| 56 } | 56 } |
| 57 | 57 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 74 ~TextRun(); | 74 ~TextRun(); |
| 75 | 75 |
| 76 void setText(const char text[], size_t byteLength, SkScalar x, SkScalar
y); | 76 void setText(const char text[], size_t byteLength, SkScalar x, SkScalar
y); |
| 77 | 77 |
| 78 void setPosText(const char text[], size_t byteLength, const SkScalar pos
[], | 78 void setPosText(const char text[], size_t byteLength, const SkScalar pos
[], |
| 79 int scalarsPerPosition, const SkPoint& offset); | 79 int scalarsPerPosition, const SkPoint& offset); |
| 80 | 80 |
| 81 void draw(GrContext*, GrDrawContext*, GrPipelineBuilder*, GrColor, const
SkMatrix&, | 81 void draw(GrContext*, GrDrawContext*, GrPipelineBuilder*, GrColor, const
SkMatrix&, |
| 82 const SkSurfaceProps&, | 82 const SkSurfaceProps&, |
| 83 SkScalar x, SkScalar y, const SkIRect& clipBounds, | 83 SkScalar x, SkScalar y, const SkIRect& clipBounds, |
| 84 GrTextContext* fallbackTextContext, const SkPaint& originalSkP
aint) const; | 84 GrAtlasTextContext* fallbackTextContext, const SkPaint& origin
alSkPaint) const; |
| 85 | 85 |
| 86 void releaseGlyphCache() const; | 86 void releaseGlyphCache() const; |
| 87 | 87 |
| 88 size_t computeSizeInCache() const; | 88 size_t computeSizeInCache() const; |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 typedef GrDrawPathRangeBatch::InstanceData InstanceData; | 91 typedef GrDrawPathRangeBatch::InstanceData InstanceData; |
| 92 | 92 |
| 93 SkGlyphCache* getGlyphCache() const; | 93 SkGlyphCache* getGlyphCache() const; |
| 94 GrPathRange* createGlyphs(GrContext*) const; | 94 GrPathRange* createGlyphs(GrContext*) const; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 const TextBlob& findOrCreateTextBlob(const SkTextBlob*, const SkPaint&); | 147 const TextBlob& findOrCreateTextBlob(const SkTextBlob*, const SkPaint&); |
| 148 void purgeToFit(const TextBlob&); | 148 void purgeToFit(const TextBlob&); |
| 149 | 149 |
| 150 GrAtlasTextContext* fFallbackTextConte
xt; | 150 GrAtlasTextContext* fFallbackTextConte
xt; |
| 151 SkTHashMap<uint32_t, TextBlob*> fBlobIdCache; | 151 SkTHashMap<uint32_t, TextBlob*> fBlobIdCache; |
| 152 SkTHashTable<TextBlob*, const TextBlob::Key&, TextBlob> fBlobKeyCache; | 152 SkTHashTable<TextBlob*, const TextBlob::Key&, TextBlob> fBlobKeyCache; |
| 153 SkTInternalLList<TextBlob> fLRUList; | 153 SkTInternalLList<TextBlob> fLRUList; |
| 154 size_t fCacheSize; | 154 size_t fCacheSize; |
| 155 | |
| 156 typedef GrTextContext INHERITED; | |
| 157 }; | 155 }; |
| 158 | 156 |
| 159 #endif | 157 #endif |
| OLD | NEW |