Update To 11.40.268.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 GrGeometryProcessor;
14 class GrTextStrike;
15
16 /*
17  * This class implements GrTextContext using standard bitmap fonts
18  */
19 class GrBitmapTextContext : public GrTextContext {
20 public:
21     static GrBitmapTextContext* Create(GrContext*, const SkDeviceProperties&);
22
23     virtual ~GrBitmapTextContext();
24
25 private:
26     GrTextStrike*                     fStrike;
27     void*                             fVertices;
28     int                               fCurrVertex;
29     int                               fAllocVertexCount;
30     int                               fTotalVertexCount;
31     SkRect                            fVertexBounds;
32     GrTexture*                        fCurrTexture;
33     GrMaskFormat                      fCurrMaskFormat;
34     SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor;
35     // Used to check whether fCachedEffect is still valid.
36     uint32_t                          fEffectTextureUniqueID;
37
38     GrBitmapTextContext(GrContext*, const SkDeviceProperties&);
39
40     virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;
41
42     virtual void onDrawText(const GrPaint&, const SkPaint&, const char text[], size_t byteLength,
43                             SkScalar x, SkScalar y) SK_OVERRIDE;
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
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();
53
54 };
55
56 #endif