| 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 | 14 |
| 15 class GrTextStrike; | 15 class GrTextStrike; |
| 16 class GrPath; | 16 class GrPath; |
| 17 class GrPathRange; | 17 class GrPathRange; |
| 18 | 18 |
| 19 /* | 19 /* |
| 20 * This class implements text rendering using stencil and cover path rendering | 20 * This class implements text rendering using stencil and cover path rendering |
| 21 * (by the means of GrDrawTarget::drawPath). | 21 * (by the means of GrDrawTarget::drawPath). |
| 22 * This class exposes the functionality through GrTextContext interface. | 22 * This class exposes the functionality through GrTextContext interface. |
| 23 */ | 23 */ |
| 24 class GrStencilAndCoverTextContext : public GrTextContext { | 24 class GrStencilAndCoverTextContext : public GrTextContext { |
| 25 public: | 25 public: |
| 26 static GrStencilAndCoverTextContext* Create(GrContext*, const SkDeviceProper
ties&); | 26 static GrStencilAndCoverTextContext* Create(GrContext*, GrDrawContext*, |
| 27 const SkDeviceProperties&, bool
fallbackUsesDFT); |
| 27 | 28 |
| 28 virtual ~GrStencilAndCoverTextContext(); | 29 virtual ~GrStencilAndCoverTextContext(); |
| 29 | 30 |
| 30 private: | 31 private: |
| 31 static const int kGlyphBufferSize = 1024; | 32 static const int kGlyphBufferSize = 1024; |
| 32 | 33 |
| 33 enum RenderMode { | 34 enum RenderMode { |
| 34 /** | 35 /** |
| 35 * This is the render mode used by drawText(), which is mainly used by | 36 * This is the render mode used by drawText(), which is mainly used by |
| 36 * the Skia unit tests. It tries match the other text backends exactly, | 37 * the Skia unit tests. It tries match the other text backends exactly, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 60 GrStrokeInfo fStroke; | 61 GrStrokeInfo fStroke; |
| 61 uint16_t fGlyphIndices[kGlyphBuff
erSize]; | 62 uint16_t fGlyphIndices[kGlyphBuff
erSize]; |
| 62 SkPoint fGlyphPositions[kGlyphBu
fferSize]; | 63 SkPoint fGlyphPositions[kGlyphBu
fferSize]; |
| 63 int fQueuedGlyphCount; | 64 int fQueuedGlyphCount; |
| 64 int fFallbackGlyphsIdx; | 65 int fFallbackGlyphsIdx; |
| 65 SkMatrix fContextInitialMatrix; | 66 SkMatrix fContextInitialMatrix; |
| 66 SkMatrix fViewMatrix; | 67 SkMatrix fViewMatrix; |
| 67 SkMatrix fLocalMatrix; | 68 SkMatrix fLocalMatrix; |
| 68 bool fUsingDeviceSpaceGlyphs; | 69 bool fUsingDeviceSpaceGlyphs; |
| 69 | 70 |
| 70 GrStencilAndCoverTextContext(GrContext*, const SkDeviceProperties&); | 71 GrStencilAndCoverTextContext(GrContext*, GrDrawContext*, const SkDevicePrope
rties&); |
| 71 | 72 |
| 72 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, | 73 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, |
| 73 const SkPaint&, const SkMatrix& viewMatrix) override; | 74 const SkPaint&, const SkMatrix& viewMatrix) override; |
| 74 | 75 |
| 75 void onDrawText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrPain
t&, const SkPaint&, | 76 void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPain
t&, |
| 76 const SkMatrix& viewMatrix, | 77 const SkMatrix& viewMatrix, |
| 77 const char text[], size_t byteLength, | 78 const char text[], size_t byteLength, |
| 78 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; | 79 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; |
| 79 void onDrawPosText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrP
aint&, const SkPaint&, | 80 void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkP
aint&, |
| 80 const SkMatrix& viewMatrix, | 81 const SkMatrix& viewMatrix, |
| 81 const char text[], size_t byteLength, | 82 const char text[], size_t byteLength, |
| 82 const SkScalar pos[], int scalarsPerPosition, | 83 const SkScalar pos[], int scalarsPerPosition, |
| 83 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; | 84 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; |
| 84 | 85 |
| 85 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, | 86 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, |
| 86 size_t textByteLength, RenderMode, const SkMatrix& viewMatrix, | 87 size_t textByteLength, RenderMode, const SkMatrix& viewMatrix, |
| 87 const SkIRect& regionClipBounds); | 88 const SkIRect& regionClipBounds); |
| 88 bool mapToFallbackContext(SkMatrix* inverse); | 89 bool mapToFallbackContext(SkMatrix* inverse); |
| 89 void appendGlyph(GrDrawContext*, const SkGlyph&, const SkPoint&); | 90 void appendGlyph(const SkGlyph&, const SkPoint&); |
| 90 void flush(GrDrawContext*); | 91 void flush(); |
| 91 void finish(GrDrawContext*); | 92 void finish(); |
| 92 | 93 |
| 93 }; | 94 }; |
| 94 | 95 |
| 95 #endif | 96 #endif |
| OLD | NEW |