| 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 SkGpuDevice; |
| 22 | 23 |
| 23 /* | 24 /* |
| 24 * This class wraps the state for a single text render | 25 * This class wraps the state for a single text render |
| 25 */ | 26 */ |
| 26 class GrTextContext { | 27 class GrTextContext { |
| 27 public: | 28 public: |
| 28 virtual ~GrTextContext(); | 29 virtual ~GrTextContext(); |
| 29 | 30 |
| 30 bool drawText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const SkPa
int&, | 31 void drawText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const SkPa
int&, |
| 31 const SkMatrix& viewMatrix, const char text[], size_t byteLeng
th, SkScalar x, | 32 const SkMatrix& viewMatrix, const char text[], size_t byteLeng
th, SkScalar x, |
| 32 SkScalar y); | 33 SkScalar y, const SkIRect& clipBounds); |
| 33 bool drawPosText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const Sk
Paint&, | 34 void drawPosText(GrRenderTarget* rt, const GrClip&, const GrPaint&, const Sk
Paint&, |
| 34 const SkMatrix& viewMatrix, | 35 const SkMatrix& viewMatrix, |
| 35 const char text[], size_t byteLength, | 36 const char text[], size_t byteLength, |
| 36 const SkScalar pos[], int scalarsPerPosition, | 37 const SkScalar pos[], int scalarsPerPosition, |
| 37 const SkPoint& offset); | 38 const SkPoint& offset, const SkIRect& clipBounds); |
| 38 | 39 |
| 39 protected: | 40 protected: |
| 40 GrTextContext* fFallbackTextContext; | 41 GrTextContext* fFallbackTextContext; |
| 41 GrContext* fContext; | 42 GrContext* fContext; |
| 43 // 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 |
| 45 // text. We might be able to move this logic to context though. This is un
reffed because |
| 46 // GrTextContext is completely owned by SkGpuDevice |
| 47 SkGpuDevice* fGpuDevice; |
| 42 SkDeviceProperties fDeviceProperties; | 48 SkDeviceProperties fDeviceProperties; |
| 43 | 49 |
| 44 SkAutoTUnref<GrRenderTarget> fRenderTarget; | 50 SkAutoTUnref<GrRenderTarget> fRenderTarget; |
| 45 GrClip fClip; | 51 GrClip fClip; |
| 46 GrDrawTarget* fDrawTarget; | 52 GrDrawTarget* fDrawTarget; |
| 47 SkIRect fClipRect; | 53 SkIRect fClipRect; |
| 48 GrPaint fPaint; | 54 GrPaint fPaint; |
| 49 SkPaint fSkPaint; | 55 SkPaint fSkPaint; |
| 50 | 56 |
| 51 GrTextContext(GrContext*, const SkDeviceProperties&); | 57 GrTextContext(GrContext*, SkGpuDevice*, const SkDeviceProperties&); |
| 52 | 58 |
| 53 virtual bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) = 0; | 59 virtual bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) = 0; |
| 54 | 60 |
| 55 virtual void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, cons
t SkPaint&, | 61 virtual void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, cons
t SkPaint&, |
| 56 const SkMatrix& viewMatrix, const char text[], size_
t byteLength, | 62 const SkMatrix& viewMatrix, const char text[], size_
t byteLength, |
| 57 SkScalar x, SkScalar y) = 0; | 63 SkScalar x, SkScalar y) = 0; |
| 58 virtual void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, c
onst SkPaint&, | 64 virtual void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, c
onst SkPaint&, |
| 59 const SkMatrix& viewMatrix, | 65 const SkMatrix& viewMatrix, |
| 60 const char text[], size_t byteLength, | 66 const char text[], size_t byteLength, |
| 61 const SkScalar pos[], int scalarsPerPosition, | 67 const SkScalar pos[], int scalarsPerPosition, |
| 62 const SkPoint& offset) = 0; | 68 const SkPoint& offset) = 0; |
| 63 | 69 |
| 70 void drawTextAsPath(const SkPaint& origPaint, const SkMatrix& viewMatrix, |
| 71 const char text[], size_t byteLength, SkScalar x, SkScal
ar y, |
| 72 const SkIRect& clipBounds); |
| 73 void drawPosTextAsPath(const SkPaint& origPaint, const SkMatrix& viewMatrix, |
| 74 const char text[], size_t byteLength, |
| 75 const SkScalar pos[], int scalarsPerPosition, |
| 76 const SkPoint& offset, const SkIRect& clipBounds); |
| 77 |
| 64 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&); | 78 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&); |
| 65 void finish() { fDrawTarget = NULL; } | 79 void finish() { fDrawTarget = NULL; } |
| 66 | 80 |
| 67 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); | 81 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); |
| 68 // sets extent in stopVector and returns glyph count | 82 // sets extent in stopVector and returns glyph count |
| 69 static int MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, | 83 static int MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, |
| 70 const char text[], size_t byteLength, SkVector* stopV
ector); | 84 const char text[], size_t byteLength, SkVector* stopV
ector); |
| 85 |
| 86 friend class GrDistanceFieldTextContext; |
| 87 friend class GrStencilAndCoverTextContext; |
| 71 }; | 88 }; |
| 72 | 89 |
| 73 #endif | 90 #endif |
| OLD | NEW |