OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 #include "GrGLPath.h" | 9 #include "GrGLPath.h" |
10 #include "GrGLPathRendering.h" | 10 #include "GrGLPathRendering.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 SkDEBUGCODE(numCoords += num_coords(verb)); | 172 SkDEBUGCODE(numCoords += num_coords(verb)); |
173 pathCoords.push_back_n(coordsForVerb, coords); | 173 pathCoords.push_back_n(coordsForVerb, coords); |
174 } | 174 } |
175 SkASSERT(verbCnt == pathCommands.count()); | 175 SkASSERT(verbCnt == pathCommands.count()); |
176 SkASSERT(numCoords == pathCoords.count()); | 176 SkASSERT(numCoords == pathCoords.count()); |
177 | 177 |
178 GR_GL_CALL(gpu->glInterface(), PathCommands(pathID, pathCommands.count(), &p
athCommands[0], | 178 GR_GL_CALL(gpu->glInterface(), PathCommands(pathID, pathCommands.count(), &p
athCommands[0], |
179 pathCoords.count(), GR_GL_FLOAT,
&pathCoords[0])); | 179 pathCoords.count(), GR_GL_FLOAT,
&pathCoords[0])); |
180 return true; | 180 return true; |
181 } | 181 } |
| 182 |
| 183 /* |
| 184 * For now paths only natively support winding and even odd fill types |
| 185 */ |
| 186 static GrPathRendering::FillType convert_skpath_filltype(SkPath::FillType fill)
{ |
| 187 switch (fill) { |
| 188 default: |
| 189 SkFAIL("Incomplete Switch\n"); |
| 190 case SkPath::kWinding_FillType: |
| 191 case SkPath::kInverseWinding_FillType: |
| 192 return GrPathRendering::kWinding_FillType; |
| 193 case SkPath::kEvenOdd_FillType: |
| 194 case SkPath::kInverseEvenOdd_FillType: |
| 195 return GrPathRendering::kEvenOdd_FillType; |
| 196 } |
| 197 } |
| 198 |
182 } // namespace | 199 } // namespace |
183 | 200 |
184 bool GrGLPath::InitPathObjectPathDataCheckingDegenerates(GrGLGpu* gpu, GrGLuint
pathID, | 201 bool GrGLPath::InitPathObjectPathDataCheckingDegenerates(GrGLGpu* gpu, GrGLuint
pathID, |
185 const SkPath& skPath) { | 202 const SkPath& skPath) { |
186 return init_path_object_for_general_path<true>(gpu, pathID, skPath); | 203 return init_path_object_for_general_path<true>(gpu, pathID, skPath); |
187 } | 204 } |
188 | 205 |
189 void GrGLPath::InitPathObjectPathData(GrGLGpu* gpu, | 206 void GrGLPath::InitPathObjectPathData(GrGLGpu* gpu, |
190 GrGLuint pathID, | 207 GrGLuint pathID, |
191 const SkPath& skPath) { | 208 const SkPath& skPath) { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } | 302 } |
286 | 303 |
287 if (!didInit) { | 304 if (!didInit) { |
288 InitPathObjectPathData(gpu, fPathID, *skPath); | 305 InitPathObjectPathData(gpu, fPathID, *skPath); |
289 } | 306 } |
290 | 307 |
291 fShouldStroke = stroke->needToApply(); | 308 fShouldStroke = stroke->needToApply(); |
292 fShouldFill = stroke->isFillStyle() || | 309 fShouldFill = stroke->isFillStyle() || |
293 stroke->getStyle() == SkStrokeRec::kStrokeAndFill_Style; | 310 stroke->getStyle() == SkStrokeRec::kStrokeAndFill_Style; |
294 | 311 |
| 312 fFillType = convert_skpath_filltype(skPath->getFillType()); |
| 313 fBounds = skPath->getBounds(); |
| 314 |
295 if (fShouldStroke) { | 315 if (fShouldStroke) { |
296 InitPathObjectStroke(gpu, fPathID, *stroke); | 316 InitPathObjectStroke(gpu, fPathID, *stroke); |
297 | 317 |
298 // FIXME: try to account for stroking, without rasterizing the strok
e. | 318 // FIXME: try to account for stroking, without rasterizing the strok
e. |
299 fBounds.outset(stroke->getWidth(), stroke->getWidth()); | 319 fBounds.outset(stroke->getWidth(), stroke->getWidth()); |
300 } | 320 } |
301 } | 321 } |
302 | 322 |
303 this->registerWithCache(); | 323 this->registerWithCache(); |
304 } | 324 } |
305 | 325 |
306 void GrGLPath::onRelease() { | 326 void GrGLPath::onRelease() { |
307 if (0 != fPathID && this->shouldFreeResources()) { | 327 if (0 != fPathID && this->shouldFreeResources()) { |
308 static_cast<GrGLGpu*>(this->getGpu())->glPathRendering()->deletePaths(fP
athID, 1); | 328 static_cast<GrGLGpu*>(this->getGpu())->glPathRendering()->deletePaths(fP
athID, 1); |
309 fPathID = 0; | 329 fPathID = 0; |
310 } | 330 } |
311 | 331 |
312 INHERITED::onRelease(); | 332 INHERITED::onRelease(); |
313 } | 333 } |
314 | 334 |
315 void GrGLPath::onAbandon() { | 335 void GrGLPath::onAbandon() { |
316 fPathID = 0; | 336 fPathID = 0; |
317 | 337 |
318 INHERITED::onAbandon(); | 338 INHERITED::onAbandon(); |
319 } | 339 } |
OLD | NEW |