OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
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 #ifndef GrPathRenderer_DEFINED | 9 #ifndef GrPathRenderer_DEFINED |
10 #define GrPathRenderer_DEFINED | 10 #define GrPathRenderer_DEFINED |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 * Draws the path into the draw target. If getStencilSupport() would return
kNoRestriction then | 110 * Draws the path into the draw target. If getStencilSupport() would return
kNoRestriction then |
111 * the subclass must respect the stencil settings of the target's draw state
. | 111 * the subclass must respect the stencil settings of the target's draw state
. |
112 * | 112 * |
113 * @param path the path to draw. | 113 * @param path the path to draw. |
114 * @param stroke the stroke information (width, join, cap) | 114 * @param stroke the stroke information (width, join, cap) |
115 * @param target target that the path will be rendered to | 115 * @param target target that the path will be rendered to |
116 * @param antiAlias true if anti-aliasing is required. | 116 * @param antiAlias true if anti-aliasing is required. |
117 */ | 117 */ |
118 bool drawPath(GrDrawTarget* target, | 118 bool drawPath(GrDrawTarget* target, |
119 GrDrawState* ds, | 119 GrDrawState* ds, |
| 120 GrColor color, |
120 const SkPath& path, | 121 const SkPath& path, |
121 const SkStrokeRec& stroke, | 122 const SkStrokeRec& stroke, |
122 bool antiAlias) { | 123 bool antiAlias) { |
123 SkASSERT(!path.isEmpty()); | 124 SkASSERT(!path.isEmpty()); |
124 SkASSERT(this->canDrawPath(target, ds, path, stroke, antiAlias)); | 125 SkASSERT(this->canDrawPath(target, ds, path, stroke, antiAlias)); |
125 SkASSERT(ds->getStencil().isDisabled() || | 126 SkASSERT(ds->getStencil().isDisabled() || |
126 kNoRestriction_StencilSupport == this->getStencilSupport(target
, ds, path, | 127 kNoRestriction_StencilSupport == this->getStencilSupport(target
, ds, path, |
127 stroke
)); | 128 stroke
)); |
128 return this->onDrawPath(target, ds, path, stroke, antiAlias); | 129 return this->onDrawPath(target, ds, color, path, stroke, antiAlias); |
129 } | 130 } |
130 | 131 |
131 /** | 132 /** |
132 * Draws the path to the stencil buffer. Assume the writable stencil bits ar
e already | 133 * Draws the path to the stencil buffer. Assume the writable stencil bits ar
e already |
133 * initialized to zero. The pixels inside the path will have non-zero stenci
l values afterwards. | 134 * initialized to zero. The pixels inside the path will have non-zero stenci
l values afterwards. |
134 * | 135 * |
135 * @param path the path to draw. | 136 * @param path the path to draw. |
136 * @param stroke the stroke information (width, join, cap) | 137 * @param stroke the stroke information (width, join, cap) |
137 * @param target target that the path will be rendered to | 138 * @param target target that the path will be rendered to |
138 */ | 139 */ |
(...skipping 29 matching lines...) Expand all Loading... |
168 const SkPath&, | 169 const SkPath&, |
169 const SkStrokeRec&) const { | 170 const SkStrokeRec&) const { |
170 return kNoRestriction_StencilSupport; | 171 return kNoRestriction_StencilSupport; |
171 } | 172 } |
172 | 173 |
173 /** | 174 /** |
174 * Subclass implementation of drawPath() | 175 * Subclass implementation of drawPath() |
175 */ | 176 */ |
176 virtual bool onDrawPath(GrDrawTarget*, | 177 virtual bool onDrawPath(GrDrawTarget*, |
177 GrDrawState*, | 178 GrDrawState*, |
| 179 GrColor, |
178 const SkPath&, | 180 const SkPath&, |
179 const SkStrokeRec&, | 181 const SkStrokeRec&, |
180 bool antiAlias) = 0; | 182 bool antiAlias) = 0; |
181 | 183 |
182 /** | 184 /** |
183 * Subclass implementation of stencilPath(). Subclass must override iff it e
ver returns | 185 * Subclass implementation of stencilPath(). Subclass must override iff it e
ver returns |
184 * kStencilOnly in onGetStencilSupport(). | 186 * kStencilOnly in onGetStencilSupport(). |
185 */ | 187 */ |
186 virtual void onStencilPath(GrDrawTarget* target, | 188 virtual void onStencilPath(GrDrawTarget* target, |
187 GrDrawState* drawState, | 189 GrDrawState* drawState, |
188 const SkPath& path, | 190 const SkPath& path, |
189 const SkStrokeRec& stroke) { | 191 const SkStrokeRec& stroke) { |
190 GR_STATIC_CONST_SAME_STENCIL(kIncrementStencil, | 192 GR_STATIC_CONST_SAME_STENCIL(kIncrementStencil, |
191 kReplace_StencilOp, | 193 kReplace_StencilOp, |
192 kReplace_StencilOp, | 194 kReplace_StencilOp, |
193 kAlways_StencilFunc, | 195 kAlways_StencilFunc, |
194 0xffff, | 196 0xffff, |
195 0xffff, | 197 0xffff, |
196 0xffff); | 198 0xffff); |
197 drawState->setStencil(kIncrementStencil); | 199 drawState->setStencil(kIncrementStencil); |
198 drawState->enableState(GrDrawState::kNoColorWrites_StateBit); | 200 drawState->enableState(GrDrawState::kNoColorWrites_StateBit); |
199 this->drawPath(target, drawState, path, stroke, false); | 201 this->drawPath(target, drawState, GrColor_WHITE, path, stroke, false); |
200 } | 202 } |
201 | 203 |
202 // Helper for getting the device bounds of a path. Inverse filled paths will
have bounds set | 204 // Helper for getting the device bounds of a path. Inverse filled paths will
have bounds set |
203 // by devSize. Non-inverse path bounds will not necessarily be clipped to de
vSize. | 205 // by devSize. Non-inverse path bounds will not necessarily be clipped to de
vSize. |
204 static void GetPathDevBounds(const SkPath& path, | 206 static void GetPathDevBounds(const SkPath& path, |
205 int devW, | 207 int devW, |
206 int devH, | 208 int devH, |
207 const SkMatrix& matrix, | 209 const SkMatrix& matrix, |
208 SkRect* bounds); | 210 SkRect* bounds); |
209 | 211 |
210 // Helper version that gets the dev width and height from a GrSurface. | 212 // Helper version that gets the dev width and height from a GrSurface. |
211 static void GetPathDevBounds(const SkPath& path, | 213 static void GetPathDevBounds(const SkPath& path, |
212 const GrSurface* device, | 214 const GrSurface* device, |
213 const SkMatrix& matrix, | 215 const SkMatrix& matrix, |
214 SkRect* bounds) { | 216 SkRect* bounds) { |
215 GetPathDevBounds(path, device->width(), device->height(), matrix, bounds
); | 217 GetPathDevBounds(path, device->width(), device->height(), matrix, bounds
); |
216 } | 218 } |
217 | 219 |
218 private: | 220 private: |
219 | 221 |
220 typedef SkRefCnt INHERITED; | 222 typedef SkRefCnt INHERITED; |
221 }; | 223 }; |
222 | 224 |
223 #endif | 225 #endif |
OLD | NEW |