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