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 | |
| 13 | class GrTextStrike; |
| 14 | |
| 15 | /* |
| 16 | * This class implements GrTextContext using distance field fonts |
| 17 | */ |
| 18 | class GrDistanceFieldTextContext : public GrTextContext { |
| 19 | public: |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 20 | GrDistanceFieldTextContext(GrContext*, const SkDeviceProperties&); |
| 21 | virtual ~GrDistanceFieldTextContext(); |
| 22 | |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 23 | 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] | 24 | SkScalar x, SkScalar y) SK_OVERRIDE; |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 25 | virtual void drawPosText(const GrPaint&, const SkPaint&, |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 26 | const char text[], size_t byteLength, |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 27 | const SkScalar pos[], SkScalar constY, |
| 28 | int scalarsPerPosition) SK_OVERRIDE; |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 29 | |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 30 | virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE; |
commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 31 | |
jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 32 | private: |
| 33 | GrTextStrike* fStrike; |
| 34 | SkScalar fTextRatio; |
commit-bot@chromium.org | 609ced4 | 2014-04-03 18:25:48 +0000 | [diff] [blame^] | 35 | bool fUseLCDText; |
jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 36 | |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 37 | void init(const GrPaint&, const SkPaint&); |
commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 38 | void drawPackedGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*); |
jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 39 | void flushGlyphs(); // automatically called by destructor |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 40 | void finish(); |
jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 41 | |
| 42 | enum { |
| 43 | kMinRequestedGlyphs = 1, |
| 44 | kDefaultRequestedGlyphs = 64, |
| 45 | kMinRequestedVerts = kMinRequestedGlyphs * 4, |
| 46 | kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, |
| 47 | }; |
| 48 | |
jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 49 | SkPoint* fVertices; |
| 50 | int32_t fMaxVertices; |
| 51 | GrTexture* fCurrTexture; |
| 52 | int fCurrVertex; |
| 53 | }; |
| 54 | |
| 55 | #endif |