| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrBitmapTextContext_DEFINED | 8 #ifndef GrBitmapTextContext_DEFINED |
| 9 #define GrBitmapTextContext_DEFINED | 9 #define GrBitmapTextContext_DEFINED |
| 10 | 10 |
| 11 #include "GrTextContext.h" | 11 #include "GrTextContext.h" |
| 12 | 12 |
| 13 class GrGeometryProcessor; | 13 class GrGeometryProcessor; |
| 14 class GrTextStrike; | 14 class GrTextStrike; |
| 15 | 15 |
| 16 /* | 16 /* |
| 17 * This class implements GrTextContext using standard bitmap fonts | 17 * This class implements GrTextContext using standard bitmap fonts |
| 18 */ | 18 */ |
| 19 class GrBitmapTextContext : public GrTextContext { | 19 class GrBitmapTextContext : public GrTextContext { |
| 20 public: | 20 public: |
| 21 GrBitmapTextContext(GrContext*, const SkDeviceProperties&); | 21 static GrBitmapTextContext* Create(GrContext*, const SkDeviceProperties&); |
| 22 |
| 22 virtual ~GrBitmapTextContext(); | 23 virtual ~GrBitmapTextContext(); |
| 23 | 24 |
| 24 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE; | |
| 25 | |
| 26 virtual void drawText(const GrPaint&, const SkPaint&, const char text[], siz
e_t byteLength, | |
| 27 SkScalar x, SkScalar y) SK_OVERRIDE; | |
| 28 virtual void drawPosText(const GrPaint&, const SkPaint&, | |
| 29 const char text[], size_t byteLength, | |
| 30 const SkScalar pos[], int scalarsPerPosition, | |
| 31 const SkPoint& offset) SK_OVERRIDE; | |
| 32 | |
| 33 private: | 25 private: |
| 34 enum { | 26 enum { |
| 35 kMinRequestedGlyphs = 1, | 27 kMinRequestedGlyphs = 1, |
| 36 kDefaultRequestedGlyphs = 64, | 28 kDefaultRequestedGlyphs = 64, |
| 37 kMinRequestedVerts = kMinRequestedGlyphs * 4, | 29 kMinRequestedVerts = kMinRequestedGlyphs * 4, |
| 38 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, | 30 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, |
| 39 }; | 31 }; |
| 40 | 32 |
| 41 GrTextStrike* fStrike; | 33 GrTextStrike* fStrike; |
| 42 void* fVertices; | 34 void* fVertices; |
| 43 int fCurrVertex; | 35 int fCurrVertex; |
| 44 int fMaxVertices; | 36 int fMaxVertices; |
| 45 SkRect fVertexBounds; | 37 SkRect fVertexBounds; |
| 46 GrTexture* fCurrTexture; | 38 GrTexture* fCurrTexture; |
| 47 GrMaskFormat fCurrMaskFormat; | 39 GrMaskFormat fCurrMaskFormat; |
| 48 SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor; | 40 SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor; |
| 49 // Used to check whether fCachedEffect is still valid. | 41 // Used to check whether fCachedEffect is still valid. |
| 50 uint32_t fEffectTextureUniqueID; | 42 uint32_t fEffectTextureUniqueID; |
| 51 | 43 |
| 44 GrBitmapTextContext(GrContext*, const SkDeviceProperties&); |
| 45 |
| 46 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE; |
| 47 |
| 48 virtual void onDrawText(const GrPaint&, const SkPaint&, const char text[], s
ize_t byteLength, |
| 49 SkScalar x, SkScalar y) SK_OVERRIDE; |
| 50 virtual void onDrawPosText(const GrPaint&, const SkPaint&, |
| 51 const char text[], size_t byteLength, |
| 52 const SkScalar pos[], int scalarsPerPosition, |
| 53 const SkPoint& offset) SK_OVERRIDE; |
| 54 |
| 52 void init(const GrPaint&, const SkPaint&); | 55 void init(const GrPaint&, const SkPaint&); |
| 53 void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*
); | 56 void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*
); |
| 54 void flush(); // automatically called by destructor | 57 void flush(); // automatically called by destructor |
| 55 void finish(); | 58 void finish(); |
| 56 | 59 |
| 57 }; | 60 }; |
| 58 | 61 |
| 59 #endif | 62 #endif |
| OLD | NEW |