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: |
jvanverth | 8c27a18 | 2014-10-14 08:45:50 -0700 | [diff] [blame] | 21 | static GrBitmapTextContext* Create(GrContext*, const SkDeviceProperties&); |
| 22 | |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 23 | virtual ~GrBitmapTextContext() {} |
commit-bot@chromium.org | 9f94b91 | 2014-01-30 15:22:54 +0000 | [diff] [blame] | 24 | |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 25 | private: |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 26 | GrTextStrike* fStrike; |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 27 | void* fVertices; |
jvanverth | 294c326 | 2014-10-10 11:36:12 -0700 | [diff] [blame] | 28 | int fCurrVertex; |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 29 | int fAllocVertexCount; |
| 30 | int fTotalVertexCount; |
jvanverth | 294c326 | 2014-10-10 11:36:12 -0700 | [diff] [blame] | 31 | SkRect fVertexBounds; |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 32 | GrTexture* fCurrTexture; |
jvanverth | 294c326 | 2014-10-10 11:36:12 -0700 | [diff] [blame] | 33 | GrMaskFormat fCurrMaskFormat; |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 34 | SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor; |
bsalomon | 1c63bf6 | 2014-07-22 13:09:46 -0700 | [diff] [blame] | 35 | // Used to check whether fCachedEffect is still valid. |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 36 | uint32_t fEffectTextureUniqueID; |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 37 | |
jvanverth | 8c27a18 | 2014-10-14 08:45:50 -0700 | [diff] [blame] | 38 | GrBitmapTextContext(GrContext*, const SkDeviceProperties&); |
| 39 | |
| 40 | virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE; |
| 41 | |
jvanverth | aab626c | 2014-10-16 08:04:39 -0700 | [diff] [blame] | 42 | virtual void onDrawText(const GrPaint&, const SkPaint&, const char text[], size_t byteLength, |
| 43 | SkScalar x, SkScalar y) SK_OVERRIDE; |
jvanverth | 8c27a18 | 2014-10-14 08:45:50 -0700 | [diff] [blame] | 44 | virtual void onDrawPosText(const GrPaint&, const SkPaint&, |
| 45 | const char text[], size_t byteLength, |
| 46 | const SkScalar pos[], int scalarsPerPosition, |
| 47 | const SkPoint& offset) SK_OVERRIDE; |
| 48 | |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 49 | void init(const GrPaint&, const SkPaint&); |
| 50 | void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*); |
| 51 | void flush(); // automatically called by destructor |
| 52 | void finish(); |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | #endif |