| 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 class SkSurfaceProps; |
| 19 | 19 |
| 20 /* | 20 /* |
| 21 * This class implements text rendering using stencil and cover path rendering | 21 * This class implements text rendering using stencil and cover path rendering |
| 22 * (by the means of GrDrawTarget::drawPath). | 22 * (by the means of GrDrawTarget::drawPath). |
| 23 * This class exposes the functionality through GrTextContext interface. | 23 * This class exposes the functionality through GrTextContext interface. |
| 24 */ | 24 */ |
| 25 class GrStencilAndCoverTextContext : public GrTextContext { | 25 class GrStencilAndCoverTextContext : public GrTextContext { |
| 26 public: | 26 public: |
| 27 static GrStencilAndCoverTextContext* Create(GrContext*, GrDrawContext*, | 27 static GrStencilAndCoverTextContext* Create(GrContext*, const SkSurfaceProps
&); |
| 28 const SkSurfaceProps&); | |
| 29 | 28 |
| 30 virtual ~GrStencilAndCoverTextContext(); | 29 virtual ~GrStencilAndCoverTextContext(); |
| 31 | 30 |
| 32 private: | 31 private: |
| 33 static const int kGlyphBufferSize = 1024; | 32 static const int kGlyphBufferSize = 1024; |
| 34 | 33 |
| 35 enum RenderMode { | 34 enum RenderMode { |
| 36 /** | 35 /** |
| 37 * 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 |
| 38 * 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 27 matching lines...) Expand all Loading... |
| 66 SkMatrix fViewMatrix; | 65 SkMatrix fViewMatrix; |
| 67 SkMatrix fLocalMatrix; | 66 SkMatrix fLocalMatrix; |
| 68 bool fUsingDeviceSpaceGlyphs; | 67 bool fUsingDeviceSpaceGlyphs; |
| 69 SkAutoTUnref<GrRenderTarget> fRenderTarget; | 68 SkAutoTUnref<GrRenderTarget> fRenderTarget; |
| 70 GrClip fClip; | 69 GrClip fClip; |
| 71 SkIRect fClipRect; | 70 SkIRect fClipRect; |
| 72 SkIRect fRegionClipBounds; | 71 SkIRect fRegionClipBounds; |
| 73 GrPaint fPaint; | 72 GrPaint fPaint; |
| 74 SkPaint fSkPaint; | 73 SkPaint fSkPaint; |
| 75 | 74 |
| 76 GrStencilAndCoverTextContext(GrContext*, GrDrawContext*, const SkSurfaceProp
s&); | 75 GrStencilAndCoverTextContext(GrContext*, const SkSurfaceProps&); |
| 77 | 76 |
| 78 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, | 77 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, |
| 79 const SkPaint&, const SkMatrix& viewMatrix) override; | 78 const SkPaint&, const SkMatrix& viewMatrix) override; |
| 80 | 79 |
| 81 void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPain
t&, | 80 void onDrawText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrPain
t&, const SkPaint&, |
| 82 const SkMatrix& viewMatrix, | 81 const SkMatrix& viewMatrix, |
| 83 const char text[], size_t byteLength, | 82 const char text[], size_t byteLength, |
| 84 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; | 83 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; |
| 85 void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkP
aint&, | 84 void onDrawPosText(GrDrawContext*, GrRenderTarget*, |
| 85 const GrClip&, const GrPaint&, const SkPaint&, |
| 86 const SkMatrix& viewMatrix, | 86 const SkMatrix& viewMatrix, |
| 87 const char text[], size_t byteLength, | 87 const char text[], size_t byteLength, |
| 88 const SkScalar pos[], int scalarsPerPosition, | 88 const SkScalar pos[], int scalarsPerPosition, |
| 89 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; | 89 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; |
| 90 | 90 |
| 91 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, | 91 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, |
| 92 size_t textByteLength, RenderMode, const SkMatrix& viewMatrix, | 92 size_t textByteLength, RenderMode, const SkMatrix& viewMatrix, |
| 93 const SkIRect& regionClipBounds); | 93 const SkIRect& regionClipBounds); |
| 94 bool mapToFallbackContext(SkMatrix* inverse); | 94 bool mapToFallbackContext(SkMatrix* inverse); |
| 95 void appendGlyph(const SkGlyph&, const SkPoint&); | 95 void appendGlyph(GrDrawContext* dc, const SkGlyph&, const SkPoint&); |
| 96 void flush(); | 96 void flush(GrDrawContext* dc); |
| 97 void finish(); | 97 void finish(GrDrawContext* dc); |
| 98 | 98 |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 #endif | 101 #endif |
| OLD | NEW |