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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 QuadEdgeEffect(GrColor color) : INHERITED(color) { | 589 QuadEdgeEffect(GrColor color) : INHERITED(color) { |
590 this->initClassID<QuadEdgeEffect>(); | 590 this->initClassID<QuadEdgeEffect>(); |
591 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr
VertexAttribType)); | 591 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr
VertexAttribType)); |
592 fInQuadEdge = &this->addVertexAttrib(GrAttribute("inQuadEdge", kVec4f_Gr
VertexAttribType)); | 592 fInQuadEdge = &this->addVertexAttrib(GrAttribute("inQuadEdge", kVec4f_Gr
VertexAttribType)); |
593 } | 593 } |
594 | 594 |
595 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { | 595 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { |
596 return true; | 596 return true; |
597 } | 597 } |
598 | 598 |
599 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE { | 599 virtual void onComputeOutputCoverage(GrInitInvariantOutput* out) const SK_OV
ERRIDE { |
600 inout->mulByUnknownAlpha(); | 600 out->setIsUnknownSingleComponent(); |
601 } | 601 } |
602 | 602 |
603 const GrAttribute* fInPosition; | 603 const GrAttribute* fInPosition; |
604 const GrAttribute* fInQuadEdge; | 604 const GrAttribute* fInQuadEdge; |
605 | 605 |
606 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 606 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
607 | 607 |
608 typedef GrGeometryProcessor INHERITED; | 608 typedef GrGeometryProcessor INHERITED; |
609 }; | 609 }; |
610 | 610 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 // We can't simply use the path bounds because we may degenerate cubics to q
uads which produces | 672 // We can't simply use the path bounds because we may degenerate cubics to q
uads which produces |
673 // new control points outside the original convex hull. | 673 // new control points outside the original convex hull. |
674 SkRect devBounds; | 674 SkRect devBounds; |
675 if (!get_segments(*path, viewMatrix, &segments, &fanPt, &vCount, &iCount, &d
evBounds)) { | 675 if (!get_segments(*path, viewMatrix, &segments, &fanPt, &vCount, &iCount, &d
evBounds)) { |
676 return false; | 676 return false; |
677 } | 677 } |
678 | 678 |
679 // Our computed verts should all be within one pixel of the segment control
points. | 679 // Our computed verts should all be within one pixel of the segment control
points. |
680 devBounds.outset(SK_Scalar1, SK_Scalar1); | 680 devBounds.outset(SK_Scalar1, SK_Scalar1); |
681 | 681 |
682 GrGeometryProcessor* quadProcessor = QuadEdgeEffect::Create(color); | 682 SkAutoTUnref<GrGeometryProcessor> quadProcessor(QuadEdgeEffect::Create(color
)); |
683 drawState->setGeometryProcessor(quadProcessor)->unref(); | |
684 | 683 |
685 GrDrawTarget::AutoReleaseGeometry arg(target, vCount, quadProcessor->getVert
exStride(), iCount); | 684 GrDrawTarget::AutoReleaseGeometry arg(target, vCount, quadProcessor->getVert
exStride(), iCount); |
686 SkASSERT(quadProcessor->getVertexStride() == sizeof(QuadVertex)); | 685 SkASSERT(quadProcessor->getVertexStride() == sizeof(QuadVertex)); |
687 if (!arg.succeeded()) { | 686 if (!arg.succeeded()) { |
688 return false; | 687 return false; |
689 } | 688 } |
690 verts = reinterpret_cast<QuadVertex*>(arg.vertices()); | 689 verts = reinterpret_cast<QuadVertex*>(arg.vertices()); |
691 idxs = reinterpret_cast<uint16_t*>(arg.indices()); | 690 idxs = reinterpret_cast<uint16_t*>(arg.indices()); |
692 | 691 |
693 SkSTArray<kPreallocDrawCnt, Draw, true> draws; | 692 SkSTArray<kPreallocDrawCnt, Draw, true> draws; |
694 create_vertices(segments, fanPt, &draws, verts, idxs); | 693 create_vertices(segments, fanPt, &draws, verts, idxs); |
695 | 694 |
696 // Check devBounds | 695 // Check devBounds |
697 #ifdef SK_DEBUG | 696 #ifdef SK_DEBUG |
698 SkRect tolDevBounds = devBounds; | 697 SkRect tolDevBounds = devBounds; |
699 tolDevBounds.outset(SK_Scalar1 / 10000, SK_Scalar1 / 10000); | 698 tolDevBounds.outset(SK_Scalar1 / 10000, SK_Scalar1 / 10000); |
700 SkRect actualBounds; | 699 SkRect actualBounds; |
701 actualBounds.set(verts[0].fPos, verts[1].fPos); | 700 actualBounds.set(verts[0].fPos, verts[1].fPos); |
702 for (int i = 2; i < vCount; ++i) { | 701 for (int i = 2; i < vCount; ++i) { |
703 actualBounds.growToInclude(verts[i].fPos.fX, verts[i].fPos.fY); | 702 actualBounds.growToInclude(verts[i].fPos.fX, verts[i].fPos.fY); |
704 } | 703 } |
705 SkASSERT(tolDevBounds.contains(actualBounds)); | 704 SkASSERT(tolDevBounds.contains(actualBounds)); |
706 #endif | 705 #endif |
707 | 706 |
708 int vOffset = 0; | 707 int vOffset = 0; |
709 for (int i = 0; i < draws.count(); ++i) { | 708 for (int i = 0; i < draws.count(); ++i) { |
710 const Draw& draw = draws[i]; | 709 const Draw& draw = draws[i]; |
711 target->drawIndexed(drawState, | 710 target->drawIndexed(drawState, |
| 711 quadProcessor, |
712 kTriangles_GrPrimitiveType, | 712 kTriangles_GrPrimitiveType, |
713 vOffset, // start vertex | 713 vOffset, // start vertex |
714 0, // start index | 714 0, // start index |
715 draw.fVertexCnt, | 715 draw.fVertexCnt, |
716 draw.fIndexCnt, | 716 draw.fIndexCnt, |
717 &devBounds); | 717 &devBounds); |
718 vOffset += draw.fVertexCnt; | 718 vOffset += draw.fVertexCnt; |
719 } | 719 } |
720 | 720 |
721 return true; | 721 return true; |
722 } | 722 } |
OLD | NEW |