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 "GrClip.h" | 11 #include "GrClip.h" |
12 #include "GrGlyph.h" | 12 #include "GrGlyph.h" |
13 #include "GrPaint.h" | 13 #include "GrPaint.h" |
14 #include "SkDeviceProperties.h" | 14 #include "SkDeviceProperties.h" |
15 | 15 |
16 #include "SkPostConfig.h" | 16 #include "SkPostConfig.h" |
17 | 17 |
| 18 class GrClip; |
18 class GrContext; | 19 class GrContext; |
19 class GrDrawTarget; | 20 class GrDrawTarget; |
20 class GrFontScaler; | 21 class GrFontScaler; |
21 | 22 |
22 /* | 23 /* |
23 * This class wraps the state for a single text render | 24 * This class wraps the state for a single text render |
24 */ | 25 */ |
25 class GrTextContext { | 26 class GrTextContext { |
26 public: | 27 public: |
27 virtual ~GrTextContext(); | 28 virtual ~GrTextContext(); |
28 | 29 |
29 bool drawText(GrRenderTarget* rt, const GrPaint&, const SkPaint&, const SkMa
trix& viewMatrix, | 30 bool drawText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const SkPa
int&, |
30 const char text[], size_t byteLength, SkScalar x, SkScalar y); | 31 const SkMatrix& viewMatrix, const char text[], size_t byteLeng
th, SkScalar x, |
31 bool drawPosText(GrRenderTarget* rt, const GrPaint&, const SkPaint&, const S
kMatrix& viewMatrix, | 32 SkScalar y); |
| 33 bool drawPosText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const Sk
Paint&, |
| 34 const SkMatrix& viewMatrix, |
32 const char text[], size_t byteLength, | 35 const char text[], size_t byteLength, |
33 const SkScalar pos[], int scalarsPerPosition, | 36 const SkScalar pos[], int scalarsPerPosition, |
34 const SkPoint& offset); | 37 const SkPoint& offset); |
35 | 38 |
36 protected: | 39 protected: |
37 GrTextContext* fFallbackTextContext; | 40 GrTextContext* fFallbackTextContext; |
38 GrContext* fContext; | 41 GrContext* fContext; |
39 SkDeviceProperties fDeviceProperties; | 42 SkDeviceProperties fDeviceProperties; |
40 | 43 |
41 SkAutoTUnref<GrRenderTarget> fRenderTarget; | 44 SkAutoTUnref<GrRenderTarget> fRenderTarget; |
42 const GrClip* fClip; | 45 GrClip fClip; |
43 GrDrawTarget* fDrawTarget; | 46 GrDrawTarget* fDrawTarget; |
44 SkIRect fClipRect; | 47 SkIRect fClipRect; |
45 GrPaint fPaint; | 48 GrPaint fPaint; |
46 SkPaint fSkPaint; | 49 SkPaint fSkPaint; |
47 | 50 |
48 GrTextContext(GrContext*, const SkDeviceProperties&); | 51 GrTextContext(GrContext*, const SkDeviceProperties&); |
49 | 52 |
50 virtual bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) = 0; | 53 virtual bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) = 0; |
51 | 54 |
52 virtual void onDrawText(GrRenderTarget*, const GrPaint&, const SkPaint&, | 55 virtual void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, cons
t SkPaint&, |
53 const SkMatrix& viewMatrix, const char text[], size_
t byteLength, | 56 const SkMatrix& viewMatrix, const char text[], size_
t byteLength, |
54 SkScalar x, SkScalar y) = 0; | 57 SkScalar x, SkScalar y) = 0; |
55 virtual void onDrawPosText(GrRenderTarget*, const GrPaint&, const SkPaint&, | 58 virtual void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, c
onst SkPaint&, |
56 const SkMatrix& viewMatrix, | 59 const SkMatrix& viewMatrix, |
57 const char text[], size_t byteLength, | 60 const char text[], size_t byteLength, |
58 const SkScalar pos[], int scalarsPerPosition, | 61 const SkScalar pos[], int scalarsPerPosition, |
59 const SkPoint& offset) = 0; | 62 const SkPoint& offset) = 0; |
60 | 63 |
61 void init(GrRenderTarget*, const GrPaint&, const SkPaint&); | 64 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&); |
62 void finish() { fDrawTarget = NULL; } | 65 void finish() { fDrawTarget = NULL; } |
63 | 66 |
64 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); | 67 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); |
65 // sets extent in stopVector and returns glyph count | 68 // sets extent in stopVector and returns glyph count |
66 static int MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, | 69 static int MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, |
67 const char text[], size_t byteLength, SkVector* stopV
ector); | 70 const char text[], size_t byteLength, SkVector* stopV
ector); |
68 }; | 71 }; |
69 | 72 |
70 #endif | 73 #endif |
OLD | NEW |