Home | History | Annotate | Download | only in gpu
      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 
     13 class GrGeometryProcessor;
     14 class GrTextStrike;
     15 
     16 /*
     17  * This class implements GrTextContext using standard bitmap fonts
     18  */
     19 class GrBitmapTextContext : public GrTextContext {
     20 public:
     21     GrBitmapTextContext(GrContext*, const SkDeviceProperties&);
     22     virtual ~GrBitmapTextContext();
     23 
     24     virtual void drawText(const GrPaint&, const SkPaint&, const char text[], size_t byteLength,
     25                           SkScalar x, SkScalar y) SK_OVERRIDE;
     26     virtual void drawPosText(const GrPaint&, const SkPaint&,
     27                              const char text[], size_t byteLength,
     28                              const SkScalar pos[], SkScalar constY,
     29                              int scalarsPerPosition) SK_OVERRIDE;
     30 
     31     virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;
     32 
     33 private:
     34     GrTextStrike*          fStrike;
     35 
     36     void init(const GrPaint&, const SkPaint&);
     37     void drawPackedGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*);
     38     void flushGlyphs();                 // automatically called by destructor
     39     void finish();
     40 
     41     enum {
     42         kMinRequestedGlyphs      = 1,
     43         kDefaultRequestedGlyphs  = 64,
     44         kMinRequestedVerts       = kMinRequestedGlyphs * 4,
     45         kDefaultRequestedVerts   = kDefaultRequestedGlyphs * 4,
     46     };
     47 
     48     void*                             fVertices;
     49     int32_t                           fMaxVertices;
     50     GrTexture*                        fCurrTexture;
     51     SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor;
     52     // Used to check whether fCachedEffect is still valid.
     53     uint32_t                          fEffectTextureUniqueID;
     54     int                               fCurrVertex;
     55     SkRect                            fVertexBounds;
     56 };
     57 
     58 #endif
     59