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 GrClip; |
19 class GrContext; | 19 class GrContext; |
20 class GrDrawTarget; | 20 class GrDrawTarget; |
21 class GrFontScaler; | 21 class GrFontScaler; |
| 22 class SkDrawFilter; |
22 class SkGpuDevice; | 23 class SkGpuDevice; |
| 24 class SkTextBlob; |
23 | 25 |
24 /* | 26 /* |
25 * This class wraps the state for a single text render | 27 * This class wraps the state for a single text render |
26 */ | 28 */ |
27 class GrTextContext { | 29 class GrTextContext { |
28 public: | 30 public: |
29 virtual ~GrTextContext(); | 31 virtual ~GrTextContext(); |
30 | 32 |
31 void drawText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const SkPa
int&, | 33 void drawText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const SkPa
int&, |
32 const SkMatrix& viewMatrix, const char text[], size_t byteLeng
th, SkScalar x, | 34 const SkMatrix& viewMatrix, const char text[], size_t byteLeng
th, SkScalar x, |
33 SkScalar y, const SkIRect& clipBounds); | 35 SkScalar y, const SkIRect& clipBounds); |
34 void drawPosText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const Sk
Paint&, | 36 void drawPosText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const Sk
Paint&, |
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); |
| 41 void drawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&, |
| 42 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x,
SkScalar y, |
| 43 SkDrawFilter*, const SkIRect& clipBounds); |
39 | 44 |
40 protected: | 45 protected: |
41 GrTextContext* fFallbackTextContext; | 46 GrTextContext* fFallbackTextContext; |
42 GrContext* fContext; | 47 GrContext* fContext; |
43 // TODO we probably don't really need to store a back pointer to the owning
SkGpuDevice, except | 48 // TODO we probably don't really need to store a back pointer to the owning
SkGpuDevice, except |
44 // we need to be able to call drawPath on it in the event no other text cont
ext can draw the | 49 // we need to be able to call drawPath on it in the event no other text cont
ext can draw the |
45 // text. We might be able to move this logic to context though. This is un
reffed because | 50 // text. We might be able to move this logic to context though. This is un
reffed because |
46 // GrTextContext is completely owned by SkGpuDevice | 51 // GrTextContext is completely owned by SkGpuDevice |
47 SkGpuDevice* fGpuDevice; | 52 SkGpuDevice* fGpuDevice; |
48 SkDeviceProperties fDeviceProperties; | 53 SkDeviceProperties fDeviceProperties; |
(...skipping 11 matching lines...) Expand all Loading... |
60 virtual bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) = 0; | 65 virtual bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) = 0; |
61 | 66 |
62 virtual void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, cons
t SkPaint&, | 67 virtual void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, cons
t SkPaint&, |
63 const SkMatrix& viewMatrix, const char text[], size_
t byteLength, | 68 const SkMatrix& viewMatrix, const char text[], size_
t byteLength, |
64 SkScalar x, SkScalar y, const SkIRect& clipBounds) =
0; | 69 SkScalar x, SkScalar y, const SkIRect& clipBounds) =
0; |
65 virtual void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, c
onst SkPaint&, | 70 virtual void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, c
onst SkPaint&, |
66 const SkMatrix& viewMatrix, | 71 const SkMatrix& viewMatrix, |
67 const char text[], size_t byteLength, | 72 const char text[], size_t byteLength, |
68 const SkScalar pos[], int scalarsPerPosition, | 73 const SkScalar pos[], int scalarsPerPosition, |
69 const SkPoint& offset, const SkIRect& clipBounds)
= 0; | 74 const SkPoint& offset, const SkIRect& clipBounds)
= 0; |
| 75 virtual void onDrawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&, |
| 76 const SkMatrix& viewMatrix, const SkTextBlob*, |
| 77 SkScalar x, SkScalar y, SkDrawFilter*, const SkI
Rect& clipBounds); |
70 | 78 |
71 void drawTextAsPath(const SkPaint& origPaint, const SkMatrix& viewMatrix, | 79 void drawTextAsPath(const SkPaint& origPaint, const SkMatrix& viewMatrix, |
72 const char text[], size_t byteLength, SkScalar x, SkScal
ar y, | 80 const char text[], size_t byteLength, SkScalar x, SkScal
ar y, |
73 const SkIRect& clipBounds); | 81 const SkIRect& clipBounds); |
74 void drawPosTextAsPath(const SkPaint& origPaint, const SkMatrix& viewMatrix, | 82 void drawPosTextAsPath(const SkPaint& origPaint, const SkMatrix& viewMatrix, |
75 const char text[], size_t byteLength, | 83 const char text[], size_t byteLength, |
76 const SkScalar pos[], int scalarsPerPosition, | 84 const SkScalar pos[], int scalarsPerPosition, |
77 const SkPoint& offset, const SkIRect& clipBounds); | 85 const SkPoint& offset, const SkIRect& clipBounds); |
78 | 86 |
79 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, | 87 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, |
80 const SkIRect& regionClipBounds); | 88 const SkIRect& regionClipBounds); |
81 void finish() { fDrawTarget = NULL; } | 89 void finish() { fDrawTarget = NULL; } |
82 | 90 |
83 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); | 91 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); |
84 // sets extent in stopVector and returns glyph count | 92 // sets extent in stopVector and returns glyph count |
85 static int MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, | 93 static int MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, |
86 const char text[], size_t byteLength, SkVector* stopV
ector); | 94 const char text[], size_t byteLength, SkVector* stopV
ector); |
87 }; | 95 }; |
88 | 96 |
89 #endif | 97 #endif |
OLD | NEW |