OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 GrTextContext_DEFINED | 8 #ifndef GrTextContext_DEFINED |
9 #define GrTextContext_DEFINED | 9 #define GrTextContext_DEFINED |
10 | 10 |
11 #include "GrGlyph.h" | 11 #include "GrGlyph.h" |
12 #include "GrPaint.h" | 12 #include "GrPaint.h" |
13 #include "SkDeviceProperties.h" | 13 #include "SkDeviceProperties.h" |
14 | 14 |
15 #include "SkPostConfig.h" | 15 #include "SkPostConfig.h" |
16 | 16 |
17 class GrContext; | 17 class GrContext; |
18 class GrDrawTarget; | 18 class GrDrawTarget; |
19 class GrFontScaler; | 19 class GrFontScaler; |
20 | 20 |
21 /* | 21 /* |
22 * This class wraps the state for a single text render | 22 * This class wraps the state for a single text render |
23 */ | 23 */ |
24 class GrTextContext { | 24 class GrTextContext { |
25 public: | 25 public: |
26 virtual ~GrTextContext() {} | 26 virtual ~GrTextContext(); |
27 | 27 |
28 virtual bool canDraw(const SkPaint& paint) = 0; | 28 virtual bool canDraw(const SkPaint& paint) = 0; |
29 | 29 |
30 virtual void drawText(const GrPaint&, const SkPaint&, const char text[], siz
e_t byteLength, | 30 virtual void drawText(const GrPaint&, const SkPaint&, const char text[], siz
e_t byteLength, |
31 SkScalar x, SkScalar y) = 0; | 31 SkScalar x, SkScalar y) = 0; |
32 virtual void drawPosText(const GrPaint&, const SkPaint&, | 32 virtual void drawPosText(const GrPaint&, const SkPaint&, |
33 const char text[], size_t byteLength, | 33 const char text[], size_t byteLength, |
34 const SkScalar pos[], int scalarsPerPosition, | 34 const SkScalar pos[], int scalarsPerPosition, |
35 const SkPoint& offset) = 0; | 35 const SkPoint& offset) = 0; |
36 | 36 |
| 37 void setFallbackTextContext(GrTextContext* textContext) { fFallbackTextConte
xt = textContext; } |
| 38 GrTextContext* getFallbackTextContext() { return fFallbackTe
xtContext; } |
| 39 |
37 protected: | 40 protected: |
| 41 GrTextContext* fFallbackTextContext; |
38 GrContext* fContext; | 42 GrContext* fContext; |
39 SkDeviceProperties fDeviceProperties; | 43 SkDeviceProperties fDeviceProperties; |
40 | 44 |
41 GrDrawTarget* fDrawTarget; | 45 GrDrawTarget* fDrawTarget; |
42 SkIRect fClipRect; | 46 SkIRect fClipRect; |
43 GrPaint fPaint; | 47 GrPaint fPaint; |
44 SkPaint fSkPaint; | 48 SkPaint fSkPaint; |
45 | 49 |
46 GrTextContext(GrContext*, const SkDeviceProperties&); | 50 GrTextContext(GrContext*, const SkDeviceProperties&); |
47 | 51 |
48 void init(const GrPaint&, const SkPaint&); | 52 void init(const GrPaint&, const SkPaint&); |
49 void finish() { fDrawTarget = NULL; } | 53 void finish() { fDrawTarget = NULL; } |
50 | 54 |
51 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); | 55 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); |
52 static void MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, | 56 static void MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, |
53 const char text[], size_t byteLength, SkVector* stop
Vector); | 57 const char text[], size_t byteLength, SkVector* stop
Vector); |
54 }; | 58 }; |
55 | 59 |
56 #endif | 60 #endif |
OLD | NEW |