| 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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 class SkDrawFilter; | 21 class SkDrawFilter; |
| 22 class SkTextBlob; | 22 class SkTextBlob; |
| 23 | 23 |
| 24 /* | 24 /* |
| 25 * This class wraps the state for a single text render | 25 * This class wraps the state for a single text render |
| 26 */ | 26 */ |
| 27 class GrTextContext { | 27 class GrTextContext { |
| 28 public: | 28 public: |
| 29 virtual ~GrTextContext(); | 29 virtual ~GrTextContext(); |
| 30 | 30 |
| 31 void drawText(GrDrawContext* dc, GrRenderTarget* rt, | 31 void drawText(GrDrawContext* dc, |
| 32 const GrClip&, const GrPaint&, const SkPaint&, | 32 const GrClip&, const GrPaint&, const SkPaint&, |
| 33 const SkMatrix& viewMatrix, const char text[], size_t byteLeng
th, SkScalar x, | 33 const SkMatrix& viewMatrix, const char text[], size_t byteLeng
th, SkScalar x, |
| 34 SkScalar y, const SkIRect& clipBounds); | 34 SkScalar y, const SkIRect& clipBounds); |
| 35 void drawPosText(GrDrawContext* dc, GrRenderTarget* rt, | 35 void drawPosText(GrDrawContext* dc, |
| 36 const GrClip&, const GrPaint&, const SkPaint&, | 36 const GrClip&, const GrPaint&, const SkPaint&, |
| 37 const SkMatrix& viewMatrix, | 37 const SkMatrix& viewMatrix, |
| 38 const char text[], size_t byteLength, | 38 const char text[], size_t byteLength, |
| 39 const SkScalar pos[], int scalarsPerPosition, | 39 const SkScalar pos[], int scalarsPerPosition, |
| 40 const SkPoint& offset, const SkIRect& clipBounds); | 40 const SkPoint& offset, const SkIRect& clipBounds); |
| 41 virtual void drawTextBlob(GrDrawContext* dc, GrRenderTarget*, const GrClip&,
const SkPaint&, | 41 virtual void drawTextBlob(GrDrawContext* dc, const GrClip&, const SkPaint&, |
| 42 const SkMatrix& viewMatrix, const SkTextBlob*, | 42 const SkMatrix& viewMatrix, const SkTextBlob*, |
| 43 SkScalar x, SkScalar y, | 43 SkScalar x, SkScalar y, |
| 44 SkDrawFilter*, const SkIRect& clipBounds); | 44 SkDrawFilter*, const SkIRect& clipBounds); |
| 45 | 45 |
| 46 static bool ShouldDisableLCD(const SkPaint& paint); | 46 static bool ShouldDisableLCD(const SkPaint& paint); |
| 47 | 47 |
| 48 protected: | 48 protected: |
| 49 GrTextContext* fFallbackTextContext; | 49 GrTextContext* fFallbackTextContext; |
| 50 GrContext* fContext; | 50 GrContext* fContext; |
| 51 SkSurfaceProps fSurfaceProps; | 51 SkSurfaceProps fSurfaceProps; |
| 52 | 52 |
| 53 GrTextContext(GrContext*, const SkSurfaceProps&); | 53 GrTextContext(GrContext*, const SkSurfaceProps&); |
| 54 | 54 |
| 55 virtual bool canDraw(const SkPaint&, const SkMatrix& viewMatrix) = 0; | 55 virtual bool canDraw(const SkPaint&, const SkMatrix& viewMatrix) = 0; |
| 56 | 56 |
| 57 virtual void onDrawText(GrDrawContext*, GrRenderTarget*, const GrClip&, | 57 virtual void onDrawText(GrDrawContext*, const GrClip&, |
| 58 const GrPaint&, const SkPaint&, | 58 const GrPaint&, const SkPaint&, |
| 59 const SkMatrix& viewMatrix, const char text[], size_
t byteLength, | 59 const SkMatrix& viewMatrix, const char text[], size_
t byteLength, |
| 60 SkScalar x, SkScalar y, const SkIRect& clipBounds) =
0; | 60 SkScalar x, SkScalar y, const SkIRect& clipBounds) =
0; |
| 61 virtual void onDrawPosText(GrDrawContext*, GrRenderTarget*, const GrClip&, | 61 virtual void onDrawPosText(GrDrawContext*, const GrClip&, |
| 62 const GrPaint&, const SkPaint&, | 62 const GrPaint&, const SkPaint&, |
| 63 const SkMatrix& viewMatrix, | 63 const SkMatrix& viewMatrix, |
| 64 const char text[], size_t byteLength, | 64 const char text[], size_t byteLength, |
| 65 const SkScalar pos[], int scalarsPerPosition, | 65 const SkScalar pos[], int scalarsPerPosition, |
| 66 const SkPoint& offset, const SkIRect& clipBounds)
= 0; | 66 const SkPoint& offset, const SkIRect& clipBounds)
= 0; |
| 67 | 67 |
| 68 void drawTextAsPath(GrDrawContext*, const GrClip& clip, | 68 void drawTextAsPath(GrDrawContext*, const GrClip& clip, |
| 69 const SkPaint& origPaint, const SkMatrix& viewMatrix, | 69 const SkPaint& origPaint, const SkMatrix& viewMatrix, |
| 70 const char text[], size_t byteLength, SkScalar x, SkScal
ar y, | 70 const char text[], size_t byteLength, SkScalar x, SkScal
ar y, |
| 71 const SkIRect& clipBounds); | 71 const SkIRect& clipBounds); |
| 72 void drawPosTextAsPath(GrDrawContext*, const GrClip& clip, | 72 void drawPosTextAsPath(GrDrawContext*, const GrClip& clip, |
| 73 const SkPaint& origPaint, const SkMatrix& viewMatrix, | 73 const SkPaint& origPaint, const SkMatrix& viewMatrix, |
| 74 const char text[], size_t byteLength, | 74 const char text[], size_t byteLength, |
| 75 const SkScalar pos[], int scalarsPerPosition, | 75 const SkScalar pos[], int scalarsPerPosition, |
| 76 const SkPoint& offset, const SkIRect& clipBounds); | 76 const SkPoint& offset, const SkIRect& clipBounds); |
| 77 | 77 |
| 78 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); | 78 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); |
| 79 // sets extent in stopVector and returns glyph count | 79 // sets extent in stopVector and returns glyph count |
| 80 static int MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, | 80 static int MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, |
| 81 const char text[], size_t byteLength, SkVector* stopV
ector); | 81 const char text[], size_t byteLength, SkVector* stopV
ector); |
| 82 static uint32_t FilterTextFlags(const SkSurfaceProps& surfaceProps, const Sk
Paint& paint); | 82 static uint32_t FilterTextFlags(const SkSurfaceProps& surfaceProps, const Sk
Paint& paint); |
| 83 | 83 |
| 84 friend class GrAtlasTextBatch; | 84 friend class GrAtlasTextBatch; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 #endif | 87 #endif |
| OLD | NEW |