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