OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkDraw_DEFINED | 10 #ifndef SkDraw_DEFINED |
(...skipping 25 matching lines...) Expand all Loading... |
36 void drawRect(const SkRect&, const SkPaint&) const; | 36 void drawRect(const SkRect&, const SkPaint&) const; |
37 /** | 37 /** |
38 * To save on mallocs, we allow a flag that tells us that srcPath is | 38 * To save on mallocs, we allow a flag that tells us that srcPath is |
39 * mutable, so that we don't have to make copies of it as we transform it. | 39 * mutable, so that we don't have to make copies of it as we transform it. |
40 * | 40 * |
41 * If prePathMatrix is not null, it should logically be applied before any | 41 * If prePathMatrix is not null, it should logically be applied before any |
42 * stroking or other effects. If there are no effects on the paint that | 42 * stroking or other effects. If there are no effects on the paint that |
43 * affect the geometry/rasterization, then the pre matrix can just be | 43 * affect the geometry/rasterization, then the pre matrix can just be |
44 * pre-concated with the current matrix. | 44 * pre-concated with the current matrix. |
45 */ | 45 */ |
46 void drawPath(const SkPath& srcPath, const SkPaint&, | 46 void drawPath(const SkPath& path, const SkPaint& paint, |
47 const SkMatrix* prePathMatrix, bool pathIsMutable) const; | 47 const SkMatrix* prePathMatrix, bool pathIsMutable) const { |
| 48 this->drawPath(path, paint, prePathMatrix, pathIsMutable, false); |
| 49 } |
| 50 |
| 51 void drawPath(const SkPath& path, const SkPaint& paint) const { |
| 52 this->drawPath(path, paint, NULL, false, false); |
| 53 } |
| 54 |
48 void drawBitmap(const SkBitmap&, const SkMatrix&, const SkPaint&) const; | 55 void drawBitmap(const SkBitmap&, const SkMatrix&, const SkPaint&) const; |
49 void drawSprite(const SkBitmap&, int x, int y, const SkPaint&) const; | 56 void drawSprite(const SkBitmap&, int x, int y, const SkPaint&) const; |
50 void drawText(const char text[], size_t byteLength, SkScalar x, | 57 void drawText(const char text[], size_t byteLength, SkScalar x, |
51 SkScalar y, const SkPaint& paint) const; | 58 SkScalar y, const SkPaint& paint) const; |
52 void drawPosText(const char text[], size_t byteLength, | 59 void drawPosText(const char text[], size_t byteLength, |
53 const SkScalar pos[], SkScalar constY, | 60 const SkScalar pos[], SkScalar constY, |
54 int scalarsPerPosition, const SkPaint& paint) const; | 61 int scalarsPerPosition, const SkPaint& paint) const; |
55 void drawTextOnPath(const char text[], size_t byteLength, | 62 void drawTextOnPath(const char text[], size_t byteLength, |
56 const SkPath&, const SkMatrix*, const SkPaint&) const; | 63 const SkPath&, const SkMatrix*, const SkPaint&) const; |
57 #ifdef SK_BUILD_FOR_ANDROID | 64 #ifdef SK_BUILD_FOR_ANDROID |
58 void drawPosTextOnPath(const char text[], size_t byteLength, | 65 void drawPosTextOnPath(const char text[], size_t byteLength, |
59 const SkPoint pos[], const SkPaint& paint, | 66 const SkPoint pos[], const SkPaint& paint, |
60 const SkPath& path, const SkMatrix* matrix) const; | 67 const SkPath& path, const SkMatrix* matrix) const; |
61 #endif | 68 #endif |
62 void drawVertices(SkCanvas::VertexMode mode, int count, | 69 void drawVertices(SkCanvas::VertexMode mode, int count, |
63 const SkPoint vertices[], const SkPoint textures[], | 70 const SkPoint vertices[], const SkPoint textures[], |
64 const SkColor colors[], SkXfermode* xmode, | 71 const SkColor colors[], SkXfermode* xmode, |
65 const uint16_t indices[], int ptCount, | 72 const uint16_t indices[], int ptCount, |
66 const SkPaint& paint) const; | 73 const SkPaint& paint) const; |
67 | 74 |
68 void drawPath(const SkPath& src, const SkPaint& paint) const { | 75 /** |
69 this->drawPath(src, paint, NULL, false); | 76 * Overwrite the target with the path's coverage (i.e. its mask). |
| 77 * Will overwrite the entire device, so it need not be zero'd first. |
| 78 * |
| 79 * Only device A8 is supported right now. |
| 80 */ |
| 81 void drawPathCoverage(const SkPath& src, const SkPaint& paint) const { |
| 82 this->drawPath(src, paint, NULL, false, true); |
70 } | 83 } |
71 | 84 |
72 /** Helper function that creates a mask from a path and an optional maskfilt
er. | 85 /** Helper function that creates a mask from a path and an optional maskfilt
er. |
73 Note however, that the resulting mask will not have been actually filter
ed, | 86 Note however, that the resulting mask will not have been actually filter
ed, |
74 that must be done afterwards (by calling filterMask). The maskfilter is
provided | 87 that must be done afterwards (by calling filterMask). The maskfilter is
provided |
75 solely to assist in computing the mask's bounds (if the mode requests th
at). | 88 solely to assist in computing the mask's bounds (if the mode requests th
at). |
76 */ | 89 */ |
77 static bool DrawToMask(const SkPath& devPath, const SkIRect* clipBounds, | 90 static bool DrawToMask(const SkPath& devPath, const SkIRect* clipBounds, |
78 const SkMaskFilter*, const SkMatrix* filterMatrix, | 91 const SkMaskFilter*, const SkMatrix* filterMatrix, |
79 SkMask* mask, SkMask::CreateMode mode, | 92 SkMask* mask, SkMask::CreateMode mode, |
(...skipping 20 matching lines...) Expand all Loading... |
100 void drawText_asPaths(const char text[], size_t byteLength, | 113 void drawText_asPaths(const char text[], size_t byteLength, |
101 SkScalar x, SkScalar y, const SkPaint&) const; | 114 SkScalar x, SkScalar y, const SkPaint&) const; |
102 void drawPosText_asPaths(const char text[], size_t byteLength, | 115 void drawPosText_asPaths(const char text[], size_t byteLength, |
103 const SkScalar pos[], SkScalar constY, | 116 const SkScalar pos[], SkScalar constY, |
104 int scalarsPerPosition, const SkPaint&) const; | 117 int scalarsPerPosition, const SkPaint&) const; |
105 | 118 |
106 private: | 119 private: |
107 void drawDevMask(const SkMask& mask, const SkPaint&) const; | 120 void drawDevMask(const SkMask& mask, const SkPaint&) const; |
108 void drawBitmapAsMask(const SkBitmap&, const SkPaint&) const; | 121 void drawBitmapAsMask(const SkBitmap&, const SkPaint&) const; |
109 | 122 |
| 123 void drawPath(const SkPath&, const SkPaint&, const SkMatrix* preMatrix, |
| 124 bool pathIsMutable, bool drawCoverage) const; |
| 125 |
110 /** | 126 /** |
111 * Return the current clip bounds, in local coordinates, with slop to accou
nt | 127 * Return the current clip bounds, in local coordinates, with slop to accou
nt |
112 * for antialiasing or hairlines (i.e. device-bounds outset by 1, and then | 128 * for antialiasing or hairlines (i.e. device-bounds outset by 1, and then |
113 * run through the inverse of the matrix). | 129 * run through the inverse of the matrix). |
114 * | 130 * |
115 * If the matrix cannot be inverted, or the current clip is empty, return | 131 * If the matrix cannot be inverted, or the current clip is empty, return |
116 * false and ignore bounds parameter. | 132 * false and ignore bounds parameter. |
117 */ | 133 */ |
118 bool SK_WARN_UNUSED_RESULT | 134 bool SK_WARN_UNUSED_RESULT |
119 computeConservativeLocalClipBounds(SkRect* bounds) const; | 135 computeConservativeLocalClipBounds(SkRect* bounds) const; |
(...skipping 12 matching lines...) Expand all Loading... |
132 SkDrawProcs* fProcs; // optional | 148 SkDrawProcs* fProcs; // optional |
133 | 149 |
134 #ifdef SK_DEBUG | 150 #ifdef SK_DEBUG |
135 void validate() const; | 151 void validate() const; |
136 #else | 152 #else |
137 void validate() const {} | 153 void validate() const {} |
138 #endif | 154 #endif |
139 }; | 155 }; |
140 | 156 |
141 #endif | 157 #endif |
OLD | NEW |