OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "GrDefaultPathRenderer.h" | 8 #include "GrDefaultPathRenderer.h" |
9 | 9 |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 226 } |
227 } else { | 227 } else { |
228 if (indexed) { | 228 if (indexed) { |
229 maxIdxs = 3 * maxPts; | 229 maxIdxs = 3 * maxPts; |
230 *primType = kTriangles_GrPrimitiveType; | 230 *primType = kTriangles_GrPrimitiveType; |
231 } else { | 231 } else { |
232 *primType = kTriangleFan_GrPrimitiveType; | 232 *primType = kTriangleFan_GrPrimitiveType; |
233 } | 233 } |
234 } | 234 } |
235 | 235 |
236 drawState->setDefaultVertexAttribs(); | 236 // TODO this is really wierd, I just need default vertex stride, can I think
of a better way? |
237 if (!arg->set(target, maxPts, drawState->getVertexStride(), maxIdxs)) { | 237 SkAutoTUnref<const GrGeometryProcessor> gp(GrDefaultGeoProcFactory::Create()
); |
| 238 if (!arg->set(target, maxPts, gp->getVertexStride(), maxIdxs)) { |
238 return false; | 239 return false; |
239 } | 240 } |
| 241 SkASSERT(gp->getVertexStride() == sizeof(SkPoint)); |
240 | 242 |
241 uint16_t* idxBase = reinterpret_cast<uint16_t*>(arg->indices()); | 243 uint16_t* idxBase = reinterpret_cast<uint16_t*>(arg->indices()); |
242 uint16_t* idx = idxBase; | 244 uint16_t* idx = idxBase; |
243 uint16_t subpathIdxStart = 0; | 245 uint16_t subpathIdxStart = 0; |
244 | 246 |
245 SkPoint* base = reinterpret_cast<SkPoint*>(arg->vertices()); | 247 SkPoint* base = reinterpret_cast<SkPoint*>(arg->vertices()); |
246 SkASSERT(base); | 248 SkASSERT(base); |
247 SkPoint* vert = base; | 249 SkPoint* vert = base; |
248 | 250 |
249 SkPoint pts[4]; | 251 SkPoint pts[4]; |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 } else { | 492 } else { |
491 bounds = path.getBounds(); | 493 bounds = path.getBounds(); |
492 } | 494 } |
493 GrDrawTarget::AutoGeometryPush agp(target); | 495 GrDrawTarget::AutoGeometryPush agp(target); |
494 target->drawSimpleRect(drawState, bounds); | 496 target->drawSimpleRect(drawState, bounds); |
495 } else { | 497 } else { |
496 if (passCount > 1) { | 498 if (passCount > 1) { |
497 drawState->enableState(GrDrawState::kNoColorWrites_StateBit); | 499 drawState->enableState(GrDrawState::kNoColorWrites_StateBit); |
498 } | 500 } |
499 GrDrawState::AutoRestoreEffects are(drawState); | 501 GrDrawState::AutoRestoreEffects are(drawState); |
500 drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create(fals
e))->unref(); | 502 drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create())->
unref(); |
501 if (indexCnt) { | 503 if (indexCnt) { |
502 target->drawIndexed(drawState, | 504 target->drawIndexed(drawState, |
503 primType, | 505 primType, |
504 0, | 506 0, |
505 0, | 507 0, |
506 vertexCnt, | 508 vertexCnt, |
507 indexCnt, | 509 indexCnt, |
508 &devBounds); | 510 &devBounds); |
509 } else { | 511 } else { |
510 target->drawNonIndexed(drawState, primType, 0, vertexCnt, &devBo
unds); | 512 target->drawNonIndexed(drawState, primType, 0, vertexCnt, &devBo
unds); |
(...skipping 28 matching lines...) Expand all Loading... |
539 } | 541 } |
540 | 542 |
541 void GrDefaultPathRenderer::onStencilPath(GrDrawTarget* target, | 543 void GrDefaultPathRenderer::onStencilPath(GrDrawTarget* target, |
542 GrDrawState* drawState, | 544 GrDrawState* drawState, |
543 const SkPath& path, | 545 const SkPath& path, |
544 const SkStrokeRec& stroke) { | 546 const SkStrokeRec& stroke) { |
545 SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType()); | 547 SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType()); |
546 SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType()); | 548 SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType()); |
547 this->internalDrawPath(target, drawState, path, stroke, true); | 549 this->internalDrawPath(target, drawState, path, stroke, true); |
548 } | 550 } |
OLD | NEW |