OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrOvalRenderer.h" | 8 #include "GrOvalRenderer.h" |
9 | 9 |
10 #include "GrEffect.h" | 10 #include "GrEffect.h" |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 GrPrintf("Failed to get space for vertices!\n"); | 684 GrPrintf("Failed to get space for vertices!\n"); |
685 return false; | 685 return false; |
686 } | 686 } |
687 | 687 |
688 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices()); | 688 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices()); |
689 | 689 |
690 GrEffectRef* effect = EllipseEdgeEffect::Create(isStroked && | 690 GrEffectRef* effect = EllipseEdgeEffect::Create(isStroked && |
691 innerXRadius > 0 && innerYRa
dius > 0); | 691 innerXRadius > 0 && innerYRa
dius > 0); |
692 | 692 |
693 static const int kEllipseCenterAttrIndex = 1; | 693 static const int kEllipseCenterAttrIndex = 1; |
694 drawState->addCoverageEffect(effect, kEllipseCenterAttrIndex)->unref(); | 694 static const int kEllipseEdgeAttrIndex = 2; |
| 695 drawState->addCoverageEffect(effect, kEllipseCenterAttrIndex, kEllipseEdgeAt
trIndex)->unref(); |
695 | 696 |
696 // Compute the reciprocals of the radii here to save time in the shader | 697 // Compute the reciprocals of the radii here to save time in the shader |
697 SkScalar xRadRecip = SkScalarInvert(xRadius); | 698 SkScalar xRadRecip = SkScalarInvert(xRadius); |
698 SkScalar yRadRecip = SkScalarInvert(yRadius); | 699 SkScalar yRadRecip = SkScalarInvert(yRadius); |
699 SkScalar xInnerRadRecip = SkScalarInvert(innerXRadius); | 700 SkScalar xInnerRadRecip = SkScalarInvert(innerXRadius); |
700 SkScalar yInnerRadRecip = SkScalarInvert(innerYRadius); | 701 SkScalar yInnerRadRecip = SkScalarInvert(innerYRadius); |
701 | 702 |
702 // We've extended the outer x radius out half a pixel to antialias. | 703 // We've extended the outer x radius out half a pixel to antialias. |
703 // This will also expand the rect so all the pixels will be captured. | 704 // This will also expand the rect so all the pixels will be captured. |
704 // TODO: Consider if we should use sqrt(2)/2 instead | 705 // TODO: Consider if we should use sqrt(2)/2 instead |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 } | 1142 } |
1142 | 1143 |
1143 // drop out the middle quad if we're stroked | 1144 // drop out the middle quad if we're stroked |
1144 int indexCnt = isStroked ? GR_ARRAY_COUNT(gRRectIndices)-6 : GR_ARRAY_CO
UNT(gRRectIndices); | 1145 int indexCnt = isStroked ? GR_ARRAY_COUNT(gRRectIndices)-6 : GR_ARRAY_CO
UNT(gRRectIndices); |
1145 target->setIndexSourceToBuffer(indexBuffer); | 1146 target->setIndexSourceToBuffer(indexBuffer); |
1146 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou
nds); | 1147 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou
nds); |
1147 } | 1148 } |
1148 | 1149 |
1149 return true; | 1150 return true; |
1150 } | 1151 } |
OLD | NEW |