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 "SkSurfaceProps.h" | 14 #include "SkSurfaceProps.h" |
15 #include "SkPostConfig.h" | 15 #include "SkPostConfig.h" |
16 | 16 |
17 class GrClip; | 17 class GrClip; |
18 class GrContext; | 18 class GrContext; |
19 class GrDrawContext; | 19 class GrDrawContext; |
20 class GrFontScaler; | 20 class GrFontScaler; |
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(GrDrawContext* dc, | 31 virtual void drawText(GrDrawContext* dc, |
32 const GrClip&, const GrPaint&, const SkPaint&, | 32 const GrClip&, const GrPaint&, const SkPaint&, |
33 const SkMatrix& viewMatrix, const char text[], size_t byteLeng
th, SkScalar x, | 33 const SkMatrix& viewMatrix, const char text[], size_t
byteLength, |
34 SkScalar y, const SkIRect& clipBounds); | 34 SkScalar x, SkScalar y, const SkIRect& clipBounds) = 0
; |
35 void drawPosText(GrDrawContext* dc, | 35 virtual void drawPosText(GrDrawContext* dc, |
36 const GrClip&, const GrPaint&, const SkPaint&, | 36 const GrClip&, const GrPaint&, const SkPaint&, |
37 const SkMatrix& viewMatrix, | 37 const SkMatrix& viewMatrix, |
38 const char text[], size_t byteLength, | 38 const char text[], size_t byteLength, |
39 const SkScalar pos[], int scalarsPerPosition, | 39 const SkScalar pos[], int scalarsPerPosition, |
40 const SkPoint& offset, const SkIRect& clipBounds); | 40 const SkPoint& offset, const SkIRect& clipBounds) =
0; |
41 virtual void drawTextBlob(GrDrawContext* dc, const GrClip&, const SkPaint&, | 41 virtual void drawTextBlob(GrDrawContext* dc, const GrClip&, const SkPaint&, |
42 const SkMatrix& viewMatrix, const SkTextBlob*, | 42 const SkMatrix& viewMatrix, const SkTextBlob*, |
43 SkScalar x, SkScalar y, | 43 SkScalar x, SkScalar y, |
44 SkDrawFilter*, const SkIRect& clipBounds); | 44 SkDrawFilter*, const SkIRect& clipBounds) = 0; |
45 | 45 |
46 static bool ShouldDisableLCD(const SkPaint& paint); | 46 static bool ShouldDisableLCD(const SkPaint& paint); |
47 | 47 |
48 protected: | 48 protected: |
49 GrTextContext* fFallbackTextContext; | |
50 GrContext* fContext; | 49 GrContext* fContext; |
51 SkSurfaceProps fSurfaceProps; | 50 SkSurfaceProps fSurfaceProps; |
52 | 51 |
53 GrTextContext(GrContext*, const SkSurfaceProps&); | 52 GrTextContext(GrContext*, const SkSurfaceProps&); |
54 | 53 |
55 virtual bool canDraw(const SkPaint&, const SkMatrix& viewMatrix) = 0; | |
56 | |
57 virtual void onDrawText(GrDrawContext*, const GrClip&, | |
58 const GrPaint&, const SkPaint&, | |
59 const SkMatrix& viewMatrix, const char text[], size_
t byteLength, | |
60 SkScalar x, SkScalar y, const SkIRect& clipBounds) =
0; | |
61 virtual void onDrawPosText(GrDrawContext*, const GrClip&, | |
62 const GrPaint&, const SkPaint&, | |
63 const SkMatrix& viewMatrix, | |
64 const char text[], size_t byteLength, | |
65 const SkScalar pos[], int scalarsPerPosition, | |
66 const SkPoint& offset, const SkIRect& clipBounds)
= 0; | |
67 | |
68 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); | 54 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); |
69 static uint32_t FilterTextFlags(const SkSurfaceProps& surfaceProps, const Sk
Paint& paint); | 55 static uint32_t FilterTextFlags(const SkSurfaceProps& surfaceProps, const Sk
Paint& paint); |
70 | 56 |
71 friend class GrAtlasTextBatch; | 57 friend class GrAtlasTextBatch; |
72 friend class GrAtlasTextBlob; // for FilterTextFlags | 58 friend class GrAtlasTextBlob; // for FilterTextFlags |
73 friend class GrTextUtils; // for some static functions | 59 friend class GrTextUtils; // for some static functions |
74 }; | 60 }; |
75 | 61 |
76 #endif | 62 #endif |
OLD | NEW |