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 | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame^] | 20 | virtual void drawText(const char text[], size_t byteLength, SkScalar x, SkScalar y) SK_OVERRIDE; |
| 21 | virtual void drawPosText(const char text[], size_t byteLength, |
| 22 | const SkScalar pos[], SkScalar constY, |
| 23 | int scalarsPerPosition) SK_OVERRIDE; |
commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 24 | |
jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 25 | private: |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame^] | 26 | GrDistanceFieldTextContext(GrContext*, const GrPaint&, const SkPaint&, |
| 27 | const SkDeviceProperties&); |
commit-bot@chromium.org | cc40f06 | 2014-01-24 14:38:27 +0000 | [diff] [blame] | 28 | virtual ~GrDistanceFieldTextContext(); |
| 29 | friend class GrTTextContextManager<GrDistanceFieldTextContext>; |
| 30 | |
jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 31 | GrTextStrike* fStrike; |
| 32 | SkScalar fTextRatio; |
| 33 | |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame^] | 34 | void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, GrFontScaler*); |
jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 35 | void flushGlyphs(); // automatically called by destructor |
| 36 | |
| 37 | enum { |
| 38 | kMinRequestedGlyphs = 1, |
| 39 | kDefaultRequestedGlyphs = 64, |
| 40 | kMinRequestedVerts = kMinRequestedGlyphs * 4, |
| 41 | kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, |
| 42 | }; |
| 43 | |
jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 44 | SkPoint* fVertices; |
| 45 | int32_t fMaxVertices; |
| 46 | GrTexture* fCurrTexture; |
| 47 | int fCurrVertex; |
| 48 | }; |
| 49 | |
| 50 | #endif |