Chromium Code Reviews| 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. | |
|
robertphillips
2015/03/18 19:52:13
// Note: this is unreffed ?
| |
| 46 SkGpuDevice* fGpuDevice; | |
| 42 SkDeviceProperties fDeviceProperties; | 47 SkDeviceProperties fDeviceProperties; |
| 43 | 48 |
| 44 SkAutoTUnref<GrRenderTarget> fRenderTarget; | 49 SkAutoTUnref<GrRenderTarget> fRenderTarget; |
| 45 GrClip fClip; | 50 GrClip fClip; |
| 46 GrDrawTarget* fDrawTarget; | 51 GrDrawTarget* fDrawTarget; |
| 47 SkIRect fClipRect; | 52 SkIRect fClipRect; |
| 48 GrPaint fPaint; | 53 GrPaint fPaint; |
| 49 SkPaint fSkPaint; | 54 SkPaint fSkPaint; |
| 50 | 55 |
| 51 GrTextContext(GrContext*, const SkDeviceProperties&); | 56 GrTextContext(GrContext*, SkGpuDevice*, const SkDeviceProperties&); |
| 52 | 57 |
| 53 virtual bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) = 0; | 58 virtual bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) = 0; |
| 54 | 59 |
| 55 virtual void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, cons t SkPaint&, | 60 virtual void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, cons t SkPaint&, |
| 56 const SkMatrix& viewMatrix, const char text[], size_ t byteLength, | 61 const SkMatrix& viewMatrix, const char text[], size_ t byteLength, |
| 57 SkScalar x, SkScalar y) = 0; | 62 SkScalar x, SkScalar y) = 0; |
| 58 virtual void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, c onst SkPaint&, | 63 virtual void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, c onst SkPaint&, |
| 59 const SkMatrix& viewMatrix, | 64 const SkMatrix& viewMatrix, |
| 60 const char text[], size_t byteLength, | 65 const char text[], size_t byteLength, |
| 61 const SkScalar pos[], int scalarsPerPosition, | 66 const SkScalar pos[], int scalarsPerPosition, |
| 62 const SkPoint& offset) = 0; | 67 const SkPoint& offset) = 0; |
| 63 | 68 |
|
robertphillips
2015/03/18 19:52:13
skPaint -> origPaint ?
| |
| 69 void drawTextAsPath(const SkPaint& skPaint, const SkMatrix& viewMatrix, | |
| 70 const char text[], size_t byteLength, SkScalar x, SkScal ar y, | |
| 71 const SkIRect& clipBounds); | |
| 72 void drawPosTextAsPath(const SkPaint& origPaint, const SkMatrix& viewMatrix, | |
| 73 const char text[], size_t byteLength, | |
| 74 const SkScalar pos[], int scalarsPerPosition, | |
| 75 const SkPoint& offset, const SkIRect& clipBounds); | |
| 76 | |
| 64 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&); | 77 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&); |
| 65 void finish() { fDrawTarget = NULL; } | 78 void finish() { fDrawTarget = NULL; } |
| 66 | 79 |
| 67 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); | 80 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); |
| 68 // sets extent in stopVector and returns glyph count | 81 // sets extent in stopVector and returns glyph count |
| 69 static int MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, | 82 static int MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, |
| 70 const char text[], size_t byteLength, SkVector* stopV ector); | 83 const char text[], size_t byteLength, SkVector* stopV ector); |
| 84 | |
| 85 friend class GrDistanceFieldTextContext; | |
| 86 friend class GrStencilAndCoverTextContext; | |
| 71 }; | 87 }; |
| 72 | 88 |
| 73 #endif | 89 #endif |
| OLD | NEW |