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 "GrAAConvexPathRenderer.h" | 9 #include "GrAAConvexPathRenderer.h" |
10 | 10 |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 }; | 478 }; |
479 SkSTArray<kPreallocSegmentCnt, Segment, true> segments; | 479 SkSTArray<kPreallocSegmentCnt, Segment, true> segments; |
480 SkPoint fanPt; | 480 SkPoint fanPt; |
481 | 481 |
482 if (!get_segments(*path, *vm, &segments, &fanPt, &vCount, &iCount)) { | 482 if (!get_segments(*path, *vm, &segments, &fanPt, &vCount, &iCount)) { |
483 return false; | 483 return false; |
484 } | 484 } |
485 | 485 |
486 // position + edge | 486 // position + edge |
487 static const GrVertexAttrib kAttribs[] = { | 487 static const GrVertexAttrib kAttribs[] = { |
488 {kVec2f_GrVertexAttribType, 0}, | 488 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBin
ding}, |
489 {kVec4f_GrVertexAttribType, sizeof(GrPoint)} | 489 {kVec4f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBindi
ng} |
490 }; | 490 }; |
491 | |
492 drawState->setVertexAttribs(kAttribs, SK_ARRAY_COUNT(kAttribs)); | 491 drawState->setVertexAttribs(kAttribs, SK_ARRAY_COUNT(kAttribs)); |
493 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0); | |
494 drawState->setAttribBindings(GrDrawState::kDefault_AttribBindings); | |
495 | 492 |
496 enum { | 493 enum { |
497 // the edge effects share this stage with glyph rendering | 494 // the edge effects share this stage with glyph rendering |
498 // (kGlyphMaskStage in GrTextContext) && SW path rendering | 495 // (kGlyphMaskStage in GrTextContext) && SW path rendering |
499 // (kPathMaskStage in GrSWMaskHelper) | 496 // (kPathMaskStage in GrSWMaskHelper) |
500 kEdgeEffectStage = GrPaint::kTotalStages, | 497 kEdgeEffectStage = GrPaint::kTotalStages, |
501 }; | 498 }; |
502 static const int kEdgeAttrIndex = 1; | 499 static const int kEdgeAttrIndex = 1; |
503 GrEffectRef* quadEffect = GrEdgeEffect::Create(GrEdgeEffect::kQuad_EdgeType)
; | 500 GrEffectRef* quadEffect = GrEdgeEffect::Create(GrEdgeEffect::kQuad_EdgeType)
; |
504 drawState->setEffect(kEdgeEffectStage, quadEffect, kEdgeAttrIndex)->unref(); | 501 drawState->setEffect(kEdgeEffectStage, quadEffect, kEdgeAttrIndex)->unref(); |
505 | 502 |
506 GrDrawTarget::AutoReleaseGeometry arg(target, vCount, iCount); | 503 GrDrawTarget::AutoReleaseGeometry arg(target, vCount, iCount); |
507 if (!arg.succeeded()) { | 504 if (!arg.succeeded()) { |
508 return false; | 505 return false; |
509 } | 506 } |
510 GrAssert(sizeof(QuadVertex) == drawState->getVertexSize()); | 507 GrAssert(sizeof(QuadVertex) == drawState->getVertexSize()); |
511 verts = reinterpret_cast<QuadVertex*>(arg.vertices()); | 508 verts = reinterpret_cast<QuadVertex*>(arg.vertices()); |
512 idxs = reinterpret_cast<uint16_t*>(arg.indices()); | 509 idxs = reinterpret_cast<uint16_t*>(arg.indices()); |
513 | 510 |
514 create_vertices(segments, fanPt, verts, idxs); | 511 create_vertices(segments, fanPt, verts, idxs); |
515 | 512 |
516 target->drawIndexed(kTriangles_GrPrimitiveType, | 513 target->drawIndexed(kTriangles_GrPrimitiveType, |
517 0, // start vertex | 514 0, // start vertex |
518 0, // start index | 515 0, // start index |
519 vCount, | 516 vCount, |
520 iCount); | 517 iCount); |
521 | 518 |
522 return true; | 519 return true; |
523 } | 520 } |
OLD | NEW |