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 onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { | 599 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE { |
600 out->setUnknownSingleComponent(); | 600 inout->mulByUnknownAlpha(); |
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 SkAutoTUnref<GrGeometryProcessor> quadProcessor(QuadEdgeEffect::Create(color
)); | 682 GrGeometryProcessor* quadProcessor = QuadEdgeEffect::Create(color); |
| 683 drawState->setGeometryProcessor(quadProcessor)->unref(); |
683 | 684 |
684 GrDrawTarget::AutoReleaseGeometry arg(target, vCount, quadProcessor->getVert
exStride(), iCount); | 685 GrDrawTarget::AutoReleaseGeometry arg(target, vCount, quadProcessor->getVert
exStride(), iCount); |
685 SkASSERT(quadProcessor->getVertexStride() == sizeof(QuadVertex)); | 686 SkASSERT(quadProcessor->getVertexStride() == sizeof(QuadVertex)); |
686 if (!arg.succeeded()) { | 687 if (!arg.succeeded()) { |
687 return false; | 688 return false; |
688 } | 689 } |
689 verts = reinterpret_cast<QuadVertex*>(arg.vertices()); | 690 verts = reinterpret_cast<QuadVertex*>(arg.vertices()); |
690 idxs = reinterpret_cast<uint16_t*>(arg.indices()); | 691 idxs = reinterpret_cast<uint16_t*>(arg.indices()); |
691 | 692 |
692 SkSTArray<kPreallocDrawCnt, Draw, true> draws; | 693 SkSTArray<kPreallocDrawCnt, Draw, true> draws; |
693 create_vertices(segments, fanPt, &draws, verts, idxs); | 694 create_vertices(segments, fanPt, &draws, verts, idxs); |
694 | 695 |
695 // Check devBounds | 696 // Check devBounds |
696 #ifdef SK_DEBUG | 697 #ifdef SK_DEBUG |
697 SkRect tolDevBounds = devBounds; | 698 SkRect tolDevBounds = devBounds; |
698 tolDevBounds.outset(SK_Scalar1 / 10000, SK_Scalar1 / 10000); | 699 tolDevBounds.outset(SK_Scalar1 / 10000, SK_Scalar1 / 10000); |
699 SkRect actualBounds; | 700 SkRect actualBounds; |
700 actualBounds.set(verts[0].fPos, verts[1].fPos); | 701 actualBounds.set(verts[0].fPos, verts[1].fPos); |
701 for (int i = 2; i < vCount; ++i) { | 702 for (int i = 2; i < vCount; ++i) { |
702 actualBounds.growToInclude(verts[i].fPos.fX, verts[i].fPos.fY); | 703 actualBounds.growToInclude(verts[i].fPos.fX, verts[i].fPos.fY); |
703 } | 704 } |
704 SkASSERT(tolDevBounds.contains(actualBounds)); | 705 SkASSERT(tolDevBounds.contains(actualBounds)); |
705 #endif | 706 #endif |
706 | 707 |
707 int vOffset = 0; | 708 int vOffset = 0; |
708 for (int i = 0; i < draws.count(); ++i) { | 709 for (int i = 0; i < draws.count(); ++i) { |
709 const Draw& draw = draws[i]; | 710 const Draw& draw = draws[i]; |
710 target->drawIndexed(drawState, | 711 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 |