jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +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 GrBitmapTextContext_DEFINED |
| 9 | #define GrBitmapTextContext_DEFINED |
| 10 | |
| 11 | #include "GrTextContext.h" |
| 12 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 13 | class GrGeometryProcessor; |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 14 | class GrTextStrike; |
| 15 | |
| 16 | /* |
| 17 | * This class implements GrTextContext using standard bitmap fonts |
| 18 | */ |
| 19 | class GrBitmapTextContext : public GrTextContext { |
| 20 | public: |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 21 | GrBitmapTextContext(GrContext*, const SkDeviceProperties&); |
commit-bot@chromium.org | 9f94b91 | 2014-01-30 15:22:54 +0000 | [diff] [blame] | 22 | virtual ~GrBitmapTextContext(); |
| 23 | |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 24 | virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE; |
| 25 | |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 26 | 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] | 27 | SkScalar x, SkScalar y) SK_OVERRIDE; |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 28 | virtual void drawPosText(const GrPaint&, const SkPaint&, |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 29 | const char text[], size_t byteLength, |
fmalita | 05c4a43 | 2014-09-29 06:29:53 -0700 | [diff] [blame] | 30 | const SkScalar pos[], int scalarsPerPosition, |
| 31 | const SkPoint& offset) SK_OVERRIDE; |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 32 | |
| 33 | private: |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 34 | enum { |
| 35 | kMinRequestedGlyphs = 1, |
| 36 | kDefaultRequestedGlyphs = 64, |
| 37 | kMinRequestedVerts = kMinRequestedGlyphs * 4, |
| 38 | kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, |
| 39 | }; |
| 40 | |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 41 | GrTextStrike* fStrike; |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 42 | void* fVertices; |
jvanverth | 294c326 | 2014-10-10 11:36:12 -0700 | [diff] [blame^] | 43 | int fCurrVertex; |
| 44 | int fMaxVertices; |
| 45 | SkRect fVertexBounds; |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 46 | GrTexture* fCurrTexture; |
jvanverth | 294c326 | 2014-10-10 11:36:12 -0700 | [diff] [blame^] | 47 | GrMaskFormat fCurrMaskFormat; |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 48 | SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor; |
bsalomon | 1c63bf6 | 2014-07-22 13:09:46 -0700 | [diff] [blame] | 49 | // Used to check whether fCachedEffect is still valid. |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 50 | uint32_t fEffectTextureUniqueID; |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 51 | |
| 52 | void init(const GrPaint&, const SkPaint&); |
| 53 | void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*); |
| 54 | void flush(); // automatically called by destructor |
| 55 | void finish(); |
| 56 | |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | #endif |