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