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