| 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 GrBitmapTextContext(GrContext*, const SkDeviceProperties&); |
| 22 virtual ~GrBitmapTextContext(); | 22 virtual ~GrBitmapTextContext(); |
| 23 | 23 |
| 24 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE; |
| 25 |
| 24 virtual void drawText(const GrPaint&, const SkPaint&, const char text[], siz
e_t byteLength, | 26 virtual void drawText(const GrPaint&, const SkPaint&, const char text[], siz
e_t byteLength, |
| 25 SkScalar x, SkScalar y) SK_OVERRIDE; | 27 SkScalar x, SkScalar y) SK_OVERRIDE; |
| 26 virtual void drawPosText(const GrPaint&, const SkPaint&, | 28 virtual void drawPosText(const GrPaint&, const SkPaint&, |
| 27 const char text[], size_t byteLength, | 29 const char text[], size_t byteLength, |
| 28 const SkScalar pos[], int scalarsPerPosition, | 30 const SkScalar pos[], int scalarsPerPosition, |
| 29 const SkPoint& offset) SK_OVERRIDE; | 31 const SkPoint& offset) SK_OVERRIDE; |
| 30 | 32 |
| 31 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE; | |
| 32 | |
| 33 private: | 33 private: |
| 34 GrTextStrike* fStrike; | |
| 35 | |
| 36 void init(const GrPaint&, const SkPaint&); | |
| 37 void drawPackedGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontSca
ler*); | |
| 38 void flushGlyphs(); // automatically called by destructor | |
| 39 void finish(); | |
| 40 | |
| 41 enum { | 34 enum { |
| 42 kMinRequestedGlyphs = 1, | 35 kMinRequestedGlyphs = 1, |
| 43 kDefaultRequestedGlyphs = 64, | 36 kDefaultRequestedGlyphs = 64, |
| 44 kMinRequestedVerts = kMinRequestedGlyphs * 4, | 37 kMinRequestedVerts = kMinRequestedGlyphs * 4, |
| 45 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, | 38 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, |
| 46 }; | 39 }; |
| 47 | 40 |
| 41 GrTextStrike* fStrike; |
| 48 void* fVertices; | 42 void* fVertices; |
| 49 int32_t fMaxVertices; | 43 int32_t fMaxVertices; |
| 50 GrTexture* fCurrTexture; | 44 GrTexture* fCurrTexture; |
| 51 SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor; | 45 SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor; |
| 52 // Used to check whether fCachedEffect is still valid. | 46 // Used to check whether fCachedEffect is still valid. |
| 53 uint32_t fEffectTextureUniqueID; | 47 uint32_t fEffectTextureUniqueID; |
| 54 int fCurrVertex; | 48 int fCurrVertex; |
| 55 SkRect fVertexBounds; | 49 SkRect fVertexBounds; |
| 50 |
| 51 void init(const GrPaint&, const SkPaint&); |
| 52 void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*
); |
| 53 void flush(); // automatically called by destructor |
| 54 void finish(); |
| 55 |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 #endif | 58 #endif |
| OLD | NEW |