jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrDistanceFieldTextContext_DEFINED |
| 9 | #define GrDistanceFieldTextContext_DEFINED |
| 10 | |
| 11 | #include "GrTextContext.h" |
| 12 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 13 | class GrGeometryProcessor; |
jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 14 | class GrTextStrike; |
| 15 | |
| 16 | /* |
| 17 | * This class implements GrTextContext using distance field fonts |
| 18 | */ |
| 19 | class GrDistanceFieldTextContext : public GrTextContext { |
| 20 | public: |
commit-bot@chromium.org | 6fcd1ef | 2014-05-02 12:39:41 +0000 | [diff] [blame] | 21 | GrDistanceFieldTextContext(GrContext*, const SkDeviceProperties&, bool enable); |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 22 | virtual ~GrDistanceFieldTextContext(); |
| 23 | |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 24 | virtual void drawText(const GrPaint&, const SkPaint&, const char text[], size_t byteLength, |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 25 | SkScalar x, SkScalar y) SK_OVERRIDE; |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 26 | virtual void drawPosText(const GrPaint&, const SkPaint&, |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 27 | const char text[], size_t byteLength, |
fmalita | 05c4a43 | 2014-09-29 06:29:53 -0700 | [diff] [blame] | 28 | const SkScalar pos[], int scalarsPerPosition, |
| 29 | const SkPoint& offset) SK_OVERRIDE; |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 30 | |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 31 | virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE; |
commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 32 | |
jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 33 | private: |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 34 | GrTextStrike* fStrike; |
| 35 | SkScalar fTextRatio; |
| 36 | bool fUseLCDText; |
| 37 | bool fEnableDFRendering; |
| 38 | SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor; |
Mike Klein | 6a25bd0 | 2014-08-29 10:03:59 -0400 | [diff] [blame] | 39 | // Used to check whether fCachedEffect is still valid. |
| 40 | uint32_t fEffectTextureUniqueID; |
| 41 | SkColor fEffectColor; |
| 42 | uint32_t fEffectFlags; |
| 43 | GrTexture* fGammaTexture; |
| 44 | |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 45 | void init(const GrPaint&, const SkPaint&); |
commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 46 | void drawPackedGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*); |
jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 47 | void flushGlyphs(); // automatically called by destructor |
jvanverth | 78f0718 | 2014-07-30 06:17:59 -0700 | [diff] [blame] | 48 | void setupCoverageEffect(const SkColor& filteredColor); |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 49 | void finish(); |
jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 50 | |
| 51 | enum { |
| 52 | kMinRequestedGlyphs = 1, |
| 53 | kDefaultRequestedGlyphs = 64, |
| 54 | kMinRequestedVerts = kMinRequestedGlyphs * 4, |
| 55 | kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, |
| 56 | }; |
| 57 | |
jvanverth | f17bc6c | 2014-07-25 16:46:53 -0700 | [diff] [blame] | 58 | void* fVertices; |
Mike Klein | 6a25bd0 | 2014-08-29 10:03:59 -0400 | [diff] [blame] | 59 | int32_t fMaxVertices; |
| 60 | GrTexture* fCurrTexture; |
jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 61 | int fCurrVertex; |
jvanverth | 1723bfc | 2014-07-30 09:16:33 -0700 | [diff] [blame] | 62 | SkRect fVertexBounds; |
jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | #endif |