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 "gl/builders/GrGLProgramBuilder.h" | 9 #include "gl/builders/GrGLProgramBuilder.h" |
10 #include "GrAAConvexPathRenderer.h" | 10 #include "GrAAConvexPathRenderer.h" |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 // We can't simply use the path bounds because we may degenerate cubics to q
uads which produces | 667 // We can't simply use the path bounds because we may degenerate cubics to q
uads which produces |
668 // new control points outside the original convex hull. | 668 // new control points outside the original convex hull. |
669 SkRect devBounds; | 669 SkRect devBounds; |
670 if (!get_segments(*path, viewMatrix, &segments, &fanPt, &vCount, &iCount, &d
evBounds)) { | 670 if (!get_segments(*path, viewMatrix, &segments, &fanPt, &vCount, &iCount, &d
evBounds)) { |
671 return false; | 671 return false; |
672 } | 672 } |
673 | 673 |
674 // Our computed verts should all be within one pixel of the segment control
points. | 674 // Our computed verts should all be within one pixel of the segment control
points. |
675 devBounds.outset(SK_Scalar1, SK_Scalar1); | 675 devBounds.outset(SK_Scalar1, SK_Scalar1); |
676 | 676 |
677 drawState->setVertexAttribs<gPathAttribs>(SK_ARRAY_COUNT(gPathAttribs), size
of(QuadVertex)); | 677 drawState->setVertexAttribs<gPathAttribs>(SK_ARRAY_COUNT(gPathAttribs)); |
678 | 678 |
679 static const int kEdgeAttrIndex = 1; | 679 static const int kEdgeAttrIndex = 1; |
680 GrEffect* quadEffect = QuadEdgeEffect::Create(); | 680 GrEffect* quadEffect = QuadEdgeEffect::Create(); |
681 drawState->addCoverageEffect(quadEffect, kEdgeAttrIndex)->unref(); | 681 drawState->addCoverageEffect(quadEffect, kEdgeAttrIndex)->unref(); |
682 | 682 |
683 GrDrawTarget::AutoReleaseGeometry arg(target, vCount, iCount); | 683 GrDrawTarget::AutoReleaseGeometry arg(target, vCount, iCount); |
684 if (!arg.succeeded()) { | 684 if (!arg.succeeded()) { |
685 return false; | 685 return false; |
686 } | 686 } |
| 687 SkASSERT(sizeof(QuadVertex) == drawState->getVertexSize()); |
687 verts = reinterpret_cast<QuadVertex*>(arg.vertices()); | 688 verts = reinterpret_cast<QuadVertex*>(arg.vertices()); |
688 idxs = reinterpret_cast<uint16_t*>(arg.indices()); | 689 idxs = reinterpret_cast<uint16_t*>(arg.indices()); |
689 | 690 |
690 SkSTArray<kPreallocDrawCnt, Draw, true> draws; | 691 SkSTArray<kPreallocDrawCnt, Draw, true> draws; |
691 create_vertices(segments, fanPt, &draws, verts, idxs); | 692 create_vertices(segments, fanPt, &draws, verts, idxs); |
692 | 693 |
693 // Check devBounds | 694 // Check devBounds |
694 #ifdef SK_DEBUG | 695 #ifdef SK_DEBUG |
695 SkRect tolDevBounds = devBounds; | 696 SkRect tolDevBounds = devBounds; |
696 tolDevBounds.outset(SK_Scalar1 / 10000, SK_Scalar1 / 10000); | 697 tolDevBounds.outset(SK_Scalar1 / 10000, SK_Scalar1 / 10000); |
(...skipping 12 matching lines...) Expand all Loading... |
709 vOffset, // start vertex | 710 vOffset, // start vertex |
710 0, // start index | 711 0, // start index |
711 draw.fVertexCnt, | 712 draw.fVertexCnt, |
712 draw.fIndexCnt, | 713 draw.fIndexCnt, |
713 &devBounds); | 714 &devBounds); |
714 vOffset += draw.fVertexCnt; | 715 vOffset += draw.fVertexCnt; |
715 } | 716 } |
716 | 717 |
717 return true; | 718 return true; |
718 } | 719 } |
OLD | NEW |