OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 GrTextUtils_DEFINED | 8 #ifndef GrTextUtils_DEFINED |
9 #define GrTextUtils_DEFINED | 9 #define GrTextUtils_DEFINED |
10 | 10 |
11 #include "GrColor.h" | 11 #include "GrColor.h" |
| 12 #include "SkPaint.h" |
12 #include "SkScalar.h" | 13 #include "SkScalar.h" |
13 | 14 |
14 class GrAtlasTextBlob; | 15 class GrAtlasTextBlob; |
15 class GrBatchFontCache; | 16 class GrBatchFontCache; |
16 class GrBatchTextStrike; | 17 class GrBatchTextStrike; |
17 class GrClip; | 18 class GrClip; |
18 class GrContext; | 19 class GrContext; |
19 class GrDrawContext; | 20 class GrDrawContext; |
20 class GrFontScaler; | 21 class GrFontScaler; |
21 class GrShaderCaps; | 22 class GrShaderCaps; |
22 class SkGlyph; | 23 class SkGlyph; |
23 class SkMatrix; | 24 class SkMatrix; |
24 struct SkIRect; | 25 struct SkIRect; |
25 class SkPaint; | |
26 struct SkPoint; | 26 struct SkPoint; |
27 class SkGlyphCache; | 27 class SkGlyphCache; |
28 class SkSurfaceProps; | 28 class SkSurfaceProps; |
29 | 29 |
30 /* | 30 /* |
31 * A class to house a bunch of common text utilities. This class should *ONLY*
have static | 31 * A class to house a bunch of common text utilities. This class should *ONLY*
have static |
32 * functions. It is not a namespace only because we wish to friend SkPaint | 32 * functions. It is not a namespace only because we wish to friend SkPaint |
33 * | 33 * |
34 */ | 34 */ |
35 class GrTextUtils { | 35 class GrTextUtils { |
36 public: | 36 public: |
37 // Functions for appending BMP text to GrAtlasTextBlob | 37 // Functions for appending BMP text to GrAtlasTextBlob |
38 static void DrawBmpText(GrAtlasTextBlob*, int runIndex, | 38 static void DrawBmpText(GrAtlasTextBlob*, int runIndex, |
39 GrBatchFontCache*, const SkSurfaceProps&, | 39 GrBatchFontCache*, const SkSurfaceProps&, |
40 const SkPaint&, | 40 const SkPaint&, |
41 GrColor, const SkMatrix& viewMatrix, | 41 GrColor, SkPaint::FakeGamma, const SkMatrix& viewMat
rix, |
42 const char text[], size_t byteLength, | 42 const char text[], size_t byteLength, |
43 SkScalar x, SkScalar y); | 43 SkScalar x, SkScalar y); |
44 | 44 |
45 static void DrawBmpPosText(GrAtlasTextBlob*, int runIndex, | 45 static void DrawBmpPosText(GrAtlasTextBlob*, int runIndex, |
46 GrBatchFontCache*, const SkSurfaceProps&, const S
kPaint&, | 46 GrBatchFontCache*, const SkSurfaceProps&, const S
kPaint&, |
47 GrColor, const SkMatrix& viewMatrix, | 47 GrColor, SkPaint::FakeGamma, const SkMatrix& view
Matrix, |
48 const char text[], size_t byteLength, | 48 const char text[], size_t byteLength, |
49 const SkScalar pos[], int scalarsPerPosition, | 49 const SkScalar pos[], int scalarsPerPosition, |
50 const SkPoint& offset); | 50 const SkPoint& offset); |
51 | 51 |
52 // functions for appending distance field text | 52 // functions for appending distance field text |
53 static bool CanDrawAsDistanceFields(const SkPaint& skPaint, const SkMatrix&
viewMatrix, | 53 static bool CanDrawAsDistanceFields(const SkPaint& skPaint, const SkMatrix&
viewMatrix, |
54 const SkSurfaceProps& props, const GrSha
derCaps& caps); | 54 const SkSurfaceProps& props, const GrSha
derCaps& caps); |
55 | 55 |
56 static void DrawDFText(GrAtlasTextBlob* blob, int runIndex, | 56 static void DrawDFText(GrAtlasTextBlob* blob, int runIndex, |
57 GrBatchFontCache*, const SkSurfaceProps&, | 57 GrBatchFontCache*, const SkSurfaceProps&, |
58 const SkPaint& skPaint, GrColor color, | 58 const SkPaint& skPaint, GrColor color, SkPaint::FakeG
amma, |
59 const SkMatrix& viewMatrix, | 59 const SkMatrix& viewMatrix, |
60 const char text[], size_t byteLength, | 60 const char text[], size_t byteLength, |
61 SkScalar x, SkScalar y); | 61 SkScalar x, SkScalar y); |
62 | 62 |
63 static void DrawDFPosText(GrAtlasTextBlob* blob, int runIndex, | 63 static void DrawDFPosText(GrAtlasTextBlob* blob, int runIndex, |
64 GrBatchFontCache*, const SkSurfaceProps&, const Sk
Paint&, | 64 GrBatchFontCache*, const SkSurfaceProps&, const Sk
Paint&, |
65 GrColor color, const SkMatrix& viewMatrix, | 65 GrColor color, SkPaint::FakeGamma, const SkMatrix&
viewMatrix, |
66 const char text[], size_t byteLength, | 66 const char text[], size_t byteLength, |
67 const SkScalar pos[], int scalarsPerPosition, | 67 const SkScalar pos[], int scalarsPerPosition, |
68 const SkPoint& offset); | 68 const SkPoint& offset); |
69 | 69 |
70 // Functions for drawing text as paths | 70 // Functions for drawing text as paths |
71 static void DrawTextAsPath(GrContext*, GrDrawContext*, const GrClip& clip, | 71 static void DrawTextAsPath(GrContext*, GrDrawContext*, const GrClip& clip, |
72 const SkPaint& origPaint, const SkMatrix& viewMat
rix, | 72 const SkPaint& origPaint, const SkMatrix& viewMat
rix, |
73 const char text[], size_t byteLength, SkScalar x,
SkScalar y, | 73 const char text[], size_t byteLength, SkScalar x,
SkScalar y, |
74 const SkIRect& clipBounds); | 74 const SkIRect& clipBounds); |
75 | 75 |
(...skipping 22 matching lines...) Expand all Loading... |
98 GrColor color, GrFontScaler*); | 98 GrColor color, GrFontScaler*); |
99 | 99 |
100 static bool DfAppendGlyph(GrAtlasTextBlob*, int runIndex, GrBatchFontCache*, | 100 static bool DfAppendGlyph(GrAtlasTextBlob*, int runIndex, GrBatchFontCache*, |
101 GrBatchTextStrike**, const SkGlyph&, | 101 GrBatchTextStrike**, const SkGlyph&, |
102 SkScalar sx, SkScalar sy, GrColor color, | 102 SkScalar sx, SkScalar sy, GrColor color, |
103 GrFontScaler* scaler, | 103 GrFontScaler* scaler, |
104 SkScalar textRatio, const SkMatrix& viewMatrix); | 104 SkScalar textRatio, const SkMatrix& viewMatrix); |
105 }; | 105 }; |
106 | 106 |
107 #endif | 107 #endif |
OLD | NEW |