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 SkDrawFilter; |
23 class SkGpuDevice; | 23 class SkGpuDevice; |
24 class SkTextBlob; | 24 class SkTextBlob; |
25 | 25 |
26 // For testing textblobs on GPU. | |
27 //#define USE_BITMAP_TEXTBLOBS | |
28 | |
29 /* | 26 /* |
30 * This class wraps the state for a single text render | 27 * This class wraps the state for a single text render |
31 */ | 28 */ |
32 class GrTextContext { | 29 class GrTextContext { |
33 public: | 30 public: |
34 virtual ~GrTextContext(); | 31 virtual ~GrTextContext(); |
35 | 32 |
36 void drawText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const SkPa
int&, | 33 void drawText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const SkPa
int&, |
37 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, |
38 SkScalar y, const SkIRect& clipBounds); | 35 SkScalar y, const SkIRect& clipBounds); |
39 void drawPosText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const Sk
Paint&, | 36 void drawPosText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const Sk
Paint&, |
40 const SkMatrix& viewMatrix, | 37 const SkMatrix& viewMatrix, |
41 const char text[], size_t byteLength, | 38 const char text[], size_t byteLength, |
42 const SkScalar pos[], int scalarsPerPosition, | 39 const SkScalar pos[], int scalarsPerPosition, |
43 const SkPoint& offset, const SkIRect& clipBounds); | 40 const SkPoint& offset, const SkIRect& clipBounds); |
44 virtual void drawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&, | 41 void drawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&, |
45 const SkMatrix& viewMatrix, const SkTextBlob*, SkS
calar x, SkScalar y, | 42 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x,
SkScalar y, |
46 SkDrawFilter*, const SkIRect& clipBounds); | 43 SkDrawFilter*, const SkIRect& clipBounds); |
47 | 44 |
48 protected: | 45 protected: |
49 GrTextContext* fFallbackTextContext; | 46 GrTextContext* fFallbackTextContext; |
50 GrContext* fContext; | 47 GrContext* fContext; |
51 // 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 |
52 // 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 |
53 // 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 |
54 // GrTextContext is completely owned by SkGpuDevice | 51 // GrTextContext is completely owned by SkGpuDevice |
55 SkGpuDevice* fGpuDevice; | 52 SkGpuDevice* fGpuDevice; |
56 SkDeviceProperties fDeviceProperties; | 53 SkDeviceProperties fDeviceProperties; |
(...skipping 29 matching lines...) Expand all Loading... |
86 const SkPoint& offset, const SkIRect& clipBounds); | 83 const SkPoint& offset, const SkIRect& clipBounds); |
87 | 84 |
88 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, | 85 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, |
89 const SkIRect& regionClipBounds); | 86 const SkIRect& regionClipBounds); |
90 void finish() { fDrawTarget = NULL; } | 87 void finish() { fDrawTarget = NULL; } |
91 | 88 |
92 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); | 89 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); |
93 // sets extent in stopVector and returns glyph count | 90 // sets extent in stopVector and returns glyph count |
94 static int MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, | 91 static int MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, |
95 const char text[], size_t byteLength, SkVector* stopV
ector); | 92 const char text[], size_t byteLength, SkVector* stopV
ector); |
96 | |
97 friend class BitmapTextBatch; | |
98 }; | 93 }; |
99 | 94 |
100 #endif | 95 #endif |
OLD | NEW |