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 |
(...skipping 10 matching lines...) Expand all Loading... |
21 class SkDrawFilter; | 21 class SkDrawFilter; |
22 class SkTextBlob; | 22 class SkTextBlob; |
23 | 23 |
24 /* | 24 /* |
25 * This class wraps the state for a single text render | 25 * This class wraps the state for a single text render |
26 */ | 26 */ |
27 class GrTextContext { | 27 class GrTextContext { |
28 public: | 28 public: |
29 virtual ~GrTextContext(); | 29 virtual ~GrTextContext(); |
30 | 30 |
31 void drawText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const SkPa
int&, | 31 void drawText(GrDrawContext* dc, GrRenderTarget* rt, |
| 32 const GrClip&, const GrPaint&, const SkPaint&, |
32 const SkMatrix& viewMatrix, const char text[], size_t byteLeng
th, SkScalar x, | 33 const SkMatrix& viewMatrix, const char text[], size_t byteLeng
th, SkScalar x, |
33 SkScalar y, const SkIRect& clipBounds); | 34 SkScalar y, const SkIRect& clipBounds); |
34 void drawPosText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const Sk
Paint&, | 35 void drawPosText(GrDrawContext* dc, GrRenderTarget* rt, |
| 36 const GrClip&, const GrPaint&, const SkPaint&, |
35 const SkMatrix& viewMatrix, | 37 const SkMatrix& viewMatrix, |
36 const char text[], size_t byteLength, | 38 const char text[], size_t byteLength, |
37 const SkScalar pos[], int scalarsPerPosition, | 39 const SkScalar pos[], int scalarsPerPosition, |
38 const SkPoint& offset, const SkIRect& clipBounds); | 40 const SkPoint& offset, const SkIRect& clipBounds); |
39 virtual void drawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&, | 41 virtual void drawTextBlob(GrDrawContext* dc, GrRenderTarget*, const GrClip&,
const SkPaint&, |
40 const SkMatrix& viewMatrix, const SkTextBlob*, | 42 const SkMatrix& viewMatrix, const SkTextBlob*, |
41 SkScalar x, SkScalar y, | 43 SkScalar x, SkScalar y, |
42 SkDrawFilter*, const SkIRect& clipBounds); | 44 SkDrawFilter*, const SkIRect& clipBounds); |
43 | 45 |
44 static bool ShouldDisableLCD(const SkPaint& paint); | 46 static bool ShouldDisableLCD(const SkPaint& paint); |
45 | 47 |
46 protected: | 48 protected: |
47 GrTextContext* fFallbackTextContext; | 49 GrTextContext* fFallbackTextContext; |
48 GrContext* fContext; | 50 GrContext* fContext; |
49 SkSurfaceProps fSurfaceProps; | 51 SkSurfaceProps fSurfaceProps; |
50 | 52 |
51 GrDrawContext* fDrawContext; // owning drawContext | 53 GrTextContext(GrContext*, const SkSurfaceProps&); |
52 | |
53 GrTextContext(GrContext*, GrDrawContext*, const SkSurfaceProps&); | |
54 | 54 |
55 virtual bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, | 55 virtual bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, |
56 const SkPaint&, const SkMatrix& viewMatrix) = 0; | 56 const SkPaint&, const SkMatrix& viewMatrix) = 0; |
57 | 57 |
58 virtual void onDrawText(GrRenderTarget*, const GrClip&, | 58 virtual void onDrawText(GrDrawContext*, GrRenderTarget*, const GrClip&, |
59 const GrPaint&, const SkPaint&, | 59 const GrPaint&, const SkPaint&, |
60 const SkMatrix& viewMatrix, const char text[], size_
t byteLength, | 60 const SkMatrix& viewMatrix, const char text[], size_
t byteLength, |
61 SkScalar x, SkScalar y, const SkIRect& clipBounds) =
0; | 61 SkScalar x, SkScalar y, const SkIRect& clipBounds) =
0; |
62 virtual void onDrawPosText(GrRenderTarget*, const GrClip&, | 62 virtual void onDrawPosText(GrDrawContext*, GrRenderTarget*, const GrClip&, |
63 const GrPaint&, const SkPaint&, | 63 const GrPaint&, const SkPaint&, |
64 const SkMatrix& viewMatrix, | 64 const SkMatrix& viewMatrix, |
65 const char text[], size_t byteLength, | 65 const char text[], size_t byteLength, |
66 const SkScalar pos[], int scalarsPerPosition, | 66 const SkScalar pos[], int scalarsPerPosition, |
67 const SkPoint& offset, const SkIRect& clipBounds)
= 0; | 67 const SkPoint& offset, const SkIRect& clipBounds)
= 0; |
68 | 68 |
69 void drawTextAsPath(GrRenderTarget*, const GrClip& clip, | 69 void drawTextAsPath(GrDrawContext*, GrRenderTarget*, const GrClip& clip, |
70 const SkPaint& origPaint, const SkMatrix& viewMatrix, | 70 const SkPaint& origPaint, const SkMatrix& viewMatrix, |
71 const char text[], size_t byteLength, SkScalar x, SkScal
ar y, | 71 const char text[], size_t byteLength, SkScalar x, SkScal
ar y, |
72 const SkIRect& clipBounds); | 72 const SkIRect& clipBounds); |
73 void drawPosTextAsPath(GrRenderTarget*, const GrClip& clip, | 73 void drawPosTextAsPath(GrDrawContext*, GrRenderTarget*, const GrClip& clip, |
74 const SkPaint& origPaint, const SkMatrix& viewMatrix, | 74 const SkPaint& origPaint, const SkMatrix& viewMatrix, |
75 const char text[], size_t byteLength, | 75 const char text[], size_t byteLength, |
76 const SkScalar pos[], int scalarsPerPosition, | 76 const SkScalar pos[], int scalarsPerPosition, |
77 const SkPoint& offset, const SkIRect& clipBounds); | 77 const SkPoint& offset, const SkIRect& clipBounds); |
78 | 78 |
79 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); | 79 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); |
80 // sets extent in stopVector and returns glyph count | 80 // sets extent in stopVector and returns glyph count |
81 static int MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, | 81 static int MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, |
82 const char text[], size_t byteLength, SkVector* stopV
ector); | 82 const char text[], size_t byteLength, SkVector* stopV
ector); |
83 static uint32_t FilterTextFlags(const SkSurfaceProps& surfaceProps, const Sk
Paint& paint); | 83 static uint32_t FilterTextFlags(const SkSurfaceProps& surfaceProps, const Sk
Paint& paint); |
84 | 84 |
85 friend class TextBatch; | 85 friend class TextBatch; |
86 }; | 86 }; |
87 | 87 |
88 #endif | 88 #endif |
OLD | NEW |