| 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 "GrProcessor.h" | 10 #include "GrProcessor.h" |
| 11 #include "GrDrawState.h" | |
| 12 #include "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
| 13 #include "GrGeometryProcessor.h" | 12 #include "GrGeometryProcessor.h" |
| 14 #include "GrGpu.h" | 13 #include "GrGpu.h" |
| 15 #include "GrInvariantOutput.h" | 14 #include "GrInvariantOutput.h" |
| 15 #include "GrPipelineBuilder.h" |
| 16 #include "SkRRect.h" | 16 #include "SkRRect.h" |
| 17 #include "SkStrokeRec.h" | 17 #include "SkStrokeRec.h" |
| 18 #include "SkTLazy.h" | 18 #include "SkTLazy.h" |
| 19 #include "effects/GrRRectEffect.h" | 19 #include "effects/GrRRectEffect.h" |
| 20 #include "gl/GrGLProcessor.h" | 20 #include "gl/GrGLProcessor.h" |
| 21 #include "gl/GrGLSL.h" | 21 #include "gl/GrGLSL.h" |
| 22 #include "gl/GrGLGeometryProcessor.h" | 22 #include "gl/GrGLGeometryProcessor.h" |
| 23 #include "gl/builders/GrGLProgramBuilder.h" | 23 #include "gl/builders/GrGLProgramBuilder.h" |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 } | 650 } |
| 651 | 651 |
| 652 /////////////////////////////////////////////////////////////////////////////// | 652 /////////////////////////////////////////////////////////////////////////////// |
| 653 | 653 |
| 654 void GrOvalRenderer::reset() { | 654 void GrOvalRenderer::reset() { |
| 655 SkSafeSetNull(fRRectIndexBuffer); | 655 SkSafeSetNull(fRRectIndexBuffer); |
| 656 SkSafeSetNull(fStrokeRRectIndexBuffer); | 656 SkSafeSetNull(fStrokeRRectIndexBuffer); |
| 657 } | 657 } |
| 658 | 658 |
| 659 bool GrOvalRenderer::drawOval(GrDrawTarget* target, | 659 bool GrOvalRenderer::drawOval(GrDrawTarget* target, |
| 660 GrDrawState* drawState, | 660 GrPipelineBuilder* pipelineBuilder, |
| 661 GrColor color, | 661 GrColor color, |
| 662 const SkMatrix& viewMatrix, | 662 const SkMatrix& viewMatrix, |
| 663 bool useAA, | 663 bool useAA, |
| 664 const SkRect& oval, | 664 const SkRect& oval, |
| 665 const SkStrokeRec& stroke) | 665 const SkStrokeRec& stroke) |
| 666 { | 666 { |
| 667 bool useCoverageAA = useAA && | 667 bool useCoverageAA = useAA && |
| 668 !drawState->getRenderTarget()->isMultisampled() && | 668 !pipelineBuilder->getRenderTarget()->isMultisampled() && |
| 669 drawState->canUseFracCoveragePrimProc(color, *target->caps()); | 669 pipelineBuilder->canUseFracCoveragePrimProc(color, *target->caps()); |
| 670 | 670 |
| 671 if (!useCoverageAA) { | 671 if (!useCoverageAA) { |
| 672 return false; | 672 return false; |
| 673 } | 673 } |
| 674 | 674 |
| 675 // we can draw circles | 675 // we can draw circles |
| 676 if (SkScalarNearlyEqual(oval.width(), oval.height()) && circle_stays_circle(
viewMatrix)) { | 676 if (SkScalarNearlyEqual(oval.width(), oval.height()) && circle_stays_circle(
viewMatrix)) { |
| 677 this->drawCircle(target, drawState, color, viewMatrix, useCoverageAA, ov
al, stroke); | 677 this->drawCircle(target, pipelineBuilder, color, viewMatrix, useCoverage
AA, oval, stroke); |
| 678 // if we have shader derivative support, render as device-independent | 678 // if we have shader derivative support, render as device-independent |
| 679 } else if (target->caps()->shaderDerivativeSupport()) { | 679 } else if (target->caps()->shaderDerivativeSupport()) { |
| 680 return this->drawDIEllipse(target, drawState, color, viewMatrix, useCove
rageAA, oval, | 680 return this->drawDIEllipse(target, pipelineBuilder, color, viewMatrix, u
seCoverageAA, oval, |
| 681 stroke); | 681 stroke); |
| 682 // otherwise axis-aligned ellipses only | 682 // otherwise axis-aligned ellipses only |
| 683 } else if (viewMatrix.rectStaysRect()) { | 683 } else if (viewMatrix.rectStaysRect()) { |
| 684 return this->drawEllipse(target, drawState, color, viewMatrix, useCovera
geAA, oval, stroke); | 684 return this->drawEllipse(target, pipelineBuilder, color, viewMatrix, use
CoverageAA, oval, |
| 685 stroke); |
| 685 } else { | 686 } else { |
| 686 return false; | 687 return false; |
| 687 } | 688 } |
| 688 | 689 |
| 689 return true; | 690 return true; |
| 690 } | 691 } |
| 691 | 692 |
| 692 /////////////////////////////////////////////////////////////////////////////// | 693 /////////////////////////////////////////////////////////////////////////////// |
| 693 | 694 |
| 694 void GrOvalRenderer::drawCircle(GrDrawTarget* target, | 695 void GrOvalRenderer::drawCircle(GrDrawTarget* target, |
| 695 GrDrawState* drawState, | 696 GrPipelineBuilder* pipelineBuilder, |
| 696 GrColor color, | 697 GrColor color, |
| 697 const SkMatrix& viewMatrix, | 698 const SkMatrix& viewMatrix, |
| 698 bool useCoverageAA, | 699 bool useCoverageAA, |
| 699 const SkRect& circle, | 700 const SkRect& circle, |
| 700 const SkStrokeRec& stroke) { | 701 const SkStrokeRec& stroke) { |
| 701 SkPoint center = SkPoint::Make(circle.centerX(), circle.centerY()); | 702 SkPoint center = SkPoint::Make(circle.centerX(), circle.centerY()); |
| 702 viewMatrix.mapPoints(¢er, 1); | 703 viewMatrix.mapPoints(¢er, 1); |
| 703 SkScalar radius = viewMatrix.mapRadius(SkScalarHalf(circle.width())); | 704 SkScalar radius = viewMatrix.mapRadius(SkScalarHalf(circle.width())); |
| 704 SkScalar strokeWidth = viewMatrix.mapRadius(stroke.getWidth()); | 705 SkScalar strokeWidth = viewMatrix.mapRadius(stroke.getWidth()); |
| 705 | 706 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 verts[2].fOffset = SkPoint::Make(1, 1); | 772 verts[2].fOffset = SkPoint::Make(1, 1); |
| 772 verts[2].fOuterRadius = outerRadius; | 773 verts[2].fOuterRadius = outerRadius; |
| 773 verts[2].fInnerRadius = innerRadius; | 774 verts[2].fInnerRadius = innerRadius; |
| 774 | 775 |
| 775 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); | 776 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); |
| 776 verts[3].fOffset = SkPoint::Make(1, -1); | 777 verts[3].fOffset = SkPoint::Make(1, -1); |
| 777 verts[3].fOuterRadius = outerRadius; | 778 verts[3].fOuterRadius = outerRadius; |
| 778 verts[3].fInnerRadius = innerRadius; | 779 verts[3].fInnerRadius = innerRadius; |
| 779 | 780 |
| 780 target->setIndexSourceToBuffer(fGpu->getQuadIndexBuffer()); | 781 target->setIndexSourceToBuffer(fGpu->getQuadIndexBuffer()); |
| 781 target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, 1, 4
, 6, &bounds); | 782 target->drawIndexedInstances(pipelineBuilder, gp, kTriangles_GrPrimitiveType
, 1, 4, 6, &bounds); |
| 782 target->resetIndexSource(); | 783 target->resetIndexSource(); |
| 783 } | 784 } |
| 784 | 785 |
| 785 /////////////////////////////////////////////////////////////////////////////// | 786 /////////////////////////////////////////////////////////////////////////////// |
| 786 | 787 |
| 787 bool GrOvalRenderer::drawEllipse(GrDrawTarget* target, | 788 bool GrOvalRenderer::drawEllipse(GrDrawTarget* target, |
| 788 GrDrawState* drawState, | 789 GrPipelineBuilder* pipelineBuilder, |
| 789 GrColor color, | 790 GrColor color, |
| 790 const SkMatrix& viewMatrix, | 791 const SkMatrix& viewMatrix, |
| 791 bool useCoverageAA, | 792 bool useCoverageAA, |
| 792 const SkRect& ellipse, | 793 const SkRect& ellipse, |
| 793 const SkStrokeRec& stroke) { | 794 const SkStrokeRec& stroke) { |
| 794 #ifdef SK_DEBUG | 795 #ifdef SK_DEBUG |
| 795 { | 796 { |
| 796 // we should have checked for this previously | 797 // we should have checked for this previously |
| 797 bool isAxisAlignedEllipse = viewMatrix.rectStaysRect(); | 798 bool isAxisAlignedEllipse = viewMatrix.rectStaysRect(); |
| 798 SkASSERT(useCoverageAA && isAxisAlignedEllipse); | 799 SkASSERT(useCoverageAA && isAxisAlignedEllipse); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 verts[2].fOffset = SkPoint::Make(xRadius, yRadius); | 906 verts[2].fOffset = SkPoint::Make(xRadius, yRadius); |
| 906 verts[2].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); | 907 verts[2].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); |
| 907 verts[2].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); | 908 verts[2].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); |
| 908 | 909 |
| 909 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); | 910 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); |
| 910 verts[3].fOffset = SkPoint::Make(xRadius, -yRadius); | 911 verts[3].fOffset = SkPoint::Make(xRadius, -yRadius); |
| 911 verts[3].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); | 912 verts[3].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); |
| 912 verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); | 913 verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); |
| 913 | 914 |
| 914 target->setIndexSourceToBuffer(fGpu->getQuadIndexBuffer()); | 915 target->setIndexSourceToBuffer(fGpu->getQuadIndexBuffer()); |
| 915 target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, 1, 4
, 6, &bounds); | 916 target->drawIndexedInstances(pipelineBuilder, gp, kTriangles_GrPrimitiveType
, 1, 4, 6, &bounds); |
| 916 target->resetIndexSource(); | 917 target->resetIndexSource(); |
| 917 | 918 |
| 918 return true; | 919 return true; |
| 919 } | 920 } |
| 920 | 921 |
| 921 bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target, | 922 bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target, |
| 922 GrDrawState* drawState, | 923 GrPipelineBuilder* pipelineBuilder, |
| 923 GrColor color, | 924 GrColor color, |
| 924 const SkMatrix& viewMatrix, | 925 const SkMatrix& viewMatrix, |
| 925 bool useCoverageAA, | 926 bool useCoverageAA, |
| 926 const SkRect& ellipse, | 927 const SkRect& ellipse, |
| 927 const SkStrokeRec& stroke) { | 928 const SkStrokeRec& stroke) { |
| 928 SkPoint center = SkPoint::Make(ellipse.centerX(), ellipse.centerY()); | 929 SkPoint center = SkPoint::Make(ellipse.centerX(), ellipse.centerY()); |
| 929 SkScalar xRadius = SkScalarHalf(ellipse.width()); | 930 SkScalar xRadius = SkScalarHalf(ellipse.width()); |
| 930 SkScalar yRadius = SkScalarHalf(ellipse.height()); | 931 SkScalar yRadius = SkScalarHalf(ellipse.height()); |
| 931 | 932 |
| 932 SkStrokeRec::Style style = stroke.getStyle(); | 933 SkStrokeRec::Style style = stroke.getStyle(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 | 1014 |
| 1014 verts[2].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom); | 1015 verts[2].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom); |
| 1015 verts[2].fOuterOffset = SkPoint::Make(1.0f + offsetDx, 1.0f + offsetDy); | 1016 verts[2].fOuterOffset = SkPoint::Make(1.0f + offsetDx, 1.0f + offsetDy); |
| 1016 verts[2].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, innerRatioY +
offsetDy); | 1017 verts[2].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, innerRatioY +
offsetDy); |
| 1017 | 1018 |
| 1018 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); | 1019 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); |
| 1019 verts[3].fOuterOffset = SkPoint::Make(1.0f + offsetDx, -1.0f - offsetDy); | 1020 verts[3].fOuterOffset = SkPoint::Make(1.0f + offsetDx, -1.0f - offsetDy); |
| 1020 verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -innerRatioY -
offsetDy); | 1021 verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -innerRatioY -
offsetDy); |
| 1021 | 1022 |
| 1022 target->setIndexSourceToBuffer(fGpu->getQuadIndexBuffer()); | 1023 target->setIndexSourceToBuffer(fGpu->getQuadIndexBuffer()); |
| 1023 target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, 1, 4
, 6, &bounds); | 1024 target->drawIndexedInstances(pipelineBuilder, gp, kTriangles_GrPrimitiveType
, 1, 4, 6, &bounds); |
| 1024 target->resetIndexSource(); | 1025 target->resetIndexSource(); |
| 1025 | 1026 |
| 1026 return true; | 1027 return true; |
| 1027 } | 1028 } |
| 1028 | 1029 |
| 1029 /////////////////////////////////////////////////////////////////////////////// | 1030 /////////////////////////////////////////////////////////////////////////////// |
| 1030 | 1031 |
| 1031 static const uint16_t gRRectIndices[] = { | 1032 static const uint16_t gRRectIndices[] = { |
| 1032 // corners | 1033 // corners |
| 1033 0, 1, 5, 0, 5, 4, | 1034 0, 1, 5, 0, 5, 4, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 fRRectIndexBuffer = fGpu->createInstancedIndexBuffer(gRRectIndices, | 1066 fRRectIndexBuffer = fGpu->createInstancedIndexBuffer(gRRectIndices, |
| 1066 kIndicesPerRRec
t, | 1067 kIndicesPerRRec
t, |
| 1067 kNumRRectsInInd
exBuffer, | 1068 kNumRRectsInInd
exBuffer, |
| 1068 kVertsPerRRect)
; | 1069 kVertsPerRRect)
; |
| 1069 } | 1070 } |
| 1070 return fRRectIndexBuffer; | 1071 return fRRectIndexBuffer; |
| 1071 } | 1072 } |
| 1072 } | 1073 } |
| 1073 | 1074 |
| 1074 bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, | 1075 bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, |
| 1075 GrDrawState* drawState, | 1076 GrPipelineBuilder* pipelineBuilder, |
| 1076 GrColor color, | 1077 GrColor color, |
| 1077 const SkMatrix& viewMatrix, | 1078 const SkMatrix& viewMatrix, |
| 1078 bool useAA, | 1079 bool useAA, |
| 1079 const SkRRect& origOuter, | 1080 const SkRRect& origOuter, |
| 1080 const SkRRect& origInner) { | 1081 const SkRRect& origInner) { |
| 1081 bool applyAA = useAA && | 1082 bool applyAA = useAA && |
| 1082 !drawState->getRenderTarget()->isMultisampled() && | 1083 !pipelineBuilder->getRenderTarget()->isMultisampled() && |
| 1083 drawState->canUseFracCoveragePrimProc(color, *target->caps())
; | 1084 pipelineBuilder->canUseFracCoveragePrimProc(color, *target->c
aps()); |
| 1084 GrDrawState::AutoRestoreEffects are; | 1085 GrPipelineBuilder::AutoRestoreEffects are; |
| 1085 if (!origInner.isEmpty()) { | 1086 if (!origInner.isEmpty()) { |
| 1086 SkTCopyOnFirstWrite<SkRRect> inner(origInner); | 1087 SkTCopyOnFirstWrite<SkRRect> inner(origInner); |
| 1087 if (!viewMatrix.isIdentity()) { | 1088 if (!viewMatrix.isIdentity()) { |
| 1088 if (!origInner.transform(viewMatrix, inner.writable())) { | 1089 if (!origInner.transform(viewMatrix, inner.writable())) { |
| 1089 return false; | 1090 return false; |
| 1090 } | 1091 } |
| 1091 } | 1092 } |
| 1092 GrPrimitiveEdgeType edgeType = applyAA ? | 1093 GrPrimitiveEdgeType edgeType = applyAA ? |
| 1093 kInverseFillAA_GrProcessorEdgeType : | 1094 kInverseFillAA_GrProcessorEdgeType : |
| 1094 kInverseFillBW_GrProcessorEdgeType; | 1095 kInverseFillBW_GrProcessorEdgeType; |
| 1095 // TODO this needs to be a geometry processor | 1096 // TODO this needs to be a geometry processor |
| 1096 GrFragmentProcessor* fp = GrRRectEffect::Create(edgeType, *inner); | 1097 GrFragmentProcessor* fp = GrRRectEffect::Create(edgeType, *inner); |
| 1097 if (NULL == fp) { | 1098 if (NULL == fp) { |
| 1098 return false; | 1099 return false; |
| 1099 } | 1100 } |
| 1100 are.set(drawState); | 1101 are.set(pipelineBuilder); |
| 1101 drawState->addCoverageProcessor(fp)->unref(); | 1102 pipelineBuilder->addCoverageProcessor(fp)->unref(); |
| 1102 } | 1103 } |
| 1103 | 1104 |
| 1104 SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle); | 1105 SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle); |
| 1105 if (this->drawRRect(target, drawState, color, viewMatrix, useAA, origOuter,
fillRec)) { | 1106 if (this->drawRRect(target, pipelineBuilder, color, viewMatrix, useAA, origO
uter, fillRec)) { |
| 1106 return true; | 1107 return true; |
| 1107 } | 1108 } |
| 1108 | 1109 |
| 1109 SkASSERT(!origOuter.isEmpty()); | 1110 SkASSERT(!origOuter.isEmpty()); |
| 1110 SkTCopyOnFirstWrite<SkRRect> outer(origOuter); | 1111 SkTCopyOnFirstWrite<SkRRect> outer(origOuter); |
| 1111 if (!viewMatrix.isIdentity()) { | 1112 if (!viewMatrix.isIdentity()) { |
| 1112 if (!origOuter.transform(viewMatrix, outer.writable())) { | 1113 if (!origOuter.transform(viewMatrix, outer.writable())) { |
| 1113 return false; | 1114 return false; |
| 1114 } | 1115 } |
| 1115 } | 1116 } |
| 1116 GrPrimitiveEdgeType edgeType = applyAA ? kFillAA_GrProcessorEdgeType : | 1117 GrPrimitiveEdgeType edgeType = applyAA ? kFillAA_GrProcessorEdgeType : |
| 1117 kFillBW_GrProcessorEdgeType; | 1118 kFillBW_GrProcessorEdgeType; |
| 1118 GrFragmentProcessor* effect = GrRRectEffect::Create(edgeType, *outer); | 1119 GrFragmentProcessor* effect = GrRRectEffect::Create(edgeType, *outer); |
| 1119 if (NULL == effect) { | 1120 if (NULL == effect) { |
| 1120 return false; | 1121 return false; |
| 1121 } | 1122 } |
| 1122 if (!are.isSet()) { | 1123 if (!are.isSet()) { |
| 1123 are.set(drawState); | 1124 are.set(pipelineBuilder); |
| 1124 } | 1125 } |
| 1125 | 1126 |
| 1126 SkMatrix invert; | 1127 SkMatrix invert; |
| 1127 if (!viewMatrix.invert(&invert)) { | 1128 if (!viewMatrix.invert(&invert)) { |
| 1128 return false; | 1129 return false; |
| 1129 } | 1130 } |
| 1130 | 1131 |
| 1131 drawState->addCoverageProcessor(effect)->unref(); | 1132 pipelineBuilder->addCoverageProcessor(effect)->unref(); |
| 1132 SkRect bounds = outer->getBounds(); | 1133 SkRect bounds = outer->getBounds(); |
| 1133 if (applyAA) { | 1134 if (applyAA) { |
| 1134 bounds.outset(SK_ScalarHalf, SK_ScalarHalf); | 1135 bounds.outset(SK_ScalarHalf, SK_ScalarHalf); |
| 1135 } | 1136 } |
| 1136 target->drawRect(drawState, color, SkMatrix::I(), bounds, NULL, &invert); | 1137 target->drawRect(pipelineBuilder, color, SkMatrix::I(), bounds, NULL, &inver
t); |
| 1137 return true; | 1138 return true; |
| 1138 } | 1139 } |
| 1139 | 1140 |
| 1140 bool GrOvalRenderer::drawRRect(GrDrawTarget* target, | 1141 bool GrOvalRenderer::drawRRect(GrDrawTarget* target, |
| 1141 GrDrawState* drawState, | 1142 GrPipelineBuilder* pipelineBuilder, |
| 1142 GrColor color, | 1143 GrColor color, |
| 1143 const SkMatrix& viewMatrix, | 1144 const SkMatrix& viewMatrix, |
| 1144 bool useAA, | 1145 bool useAA, |
| 1145 const SkRRect& rrect, | 1146 const SkRRect& rrect, |
| 1146 const SkStrokeRec& stroke) { | 1147 const SkStrokeRec& stroke) { |
| 1147 if (rrect.isOval()) { | 1148 if (rrect.isOval()) { |
| 1148 return this->drawOval(target, drawState, color, viewMatrix, useAA, rrect
.getBounds(), | 1149 return this->drawOval(target, pipelineBuilder, color, viewMatrix, useAA,
rrect.getBounds(), |
| 1149 stroke); | 1150 stroke); |
| 1150 } | 1151 } |
| 1151 | 1152 |
| 1152 bool useCoverageAA = useAA && | 1153 bool useCoverageAA = useAA && |
| 1153 !drawState->getRenderTarget()->isMultisampled() && | 1154 !pipelineBuilder->getRenderTarget()->isMultisampled() && |
| 1154 drawState->canUseFracCoveragePrimProc(color, *target->caps()); | 1155 pipelineBuilder->canUseFracCoveragePrimProc(color, *target->caps()); |
| 1155 | 1156 |
| 1156 // only anti-aliased rrects for now | 1157 // only anti-aliased rrects for now |
| 1157 if (!useCoverageAA) { | 1158 if (!useCoverageAA) { |
| 1158 return false; | 1159 return false; |
| 1159 } | 1160 } |
| 1160 | 1161 |
| 1161 if (!viewMatrix.rectStaysRect() || !rrect.isSimple()) { | 1162 if (!viewMatrix.rectStaysRect() || !rrect.isSimple()) { |
| 1162 return false; | 1163 return false; |
| 1163 } | 1164 } |
| 1164 | 1165 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 verts->fOffset = SkPoint::Make(1, yOuterRadii[i]); | 1298 verts->fOffset = SkPoint::Make(1, yOuterRadii[i]); |
| 1298 verts->fOuterRadius = outerRadius; | 1299 verts->fOuterRadius = outerRadius; |
| 1299 verts->fInnerRadius = innerRadius; | 1300 verts->fInnerRadius = innerRadius; |
| 1300 verts++; | 1301 verts++; |
| 1301 } | 1302 } |
| 1302 | 1303 |
| 1303 // drop out the middle quad if we're stroked | 1304 // drop out the middle quad if we're stroked |
| 1304 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : | 1305 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : |
| 1305 SK_ARRAY_COUNT(gRRectIndices); | 1306 SK_ARRAY_COUNT(gRRectIndices); |
| 1306 target->setIndexSourceToBuffer(indexBuffer); | 1307 target->setIndexSourceToBuffer(indexBuffer); |
| 1307 target->drawIndexedInstances(drawState, effect, kTriangles_GrPrimitiveTy
pe, 1, 16, indexCnt, | 1308 target->drawIndexedInstances(pipelineBuilder, effect, kTriangles_GrPrimi
tiveType, 1, 16, |
| 1308 &bounds); | 1309 indexCnt, &bounds); |
| 1309 | 1310 |
| 1310 // otherwise we use the ellipse renderer | 1311 // otherwise we use the ellipse renderer |
| 1311 } else { | 1312 } else { |
| 1312 SkScalar innerXRadius = 0.0f; | 1313 SkScalar innerXRadius = 0.0f; |
| 1313 SkScalar innerYRadius = 0.0f; | 1314 SkScalar innerYRadius = 0.0f; |
| 1314 if (hasStroke) { | 1315 if (hasStroke) { |
| 1315 if (SkScalarNearlyZero(scaledStroke.length())) { | 1316 if (SkScalarNearlyZero(scaledStroke.length())) { |
| 1316 scaledStroke.set(SK_ScalarHalf, SK_ScalarHalf); | 1317 scaledStroke.set(SK_ScalarHalf, SK_ScalarHalf); |
| 1317 } else { | 1318 } else { |
| 1318 scaledStroke.scale(SK_ScalarHalf); | 1319 scaledStroke.scale(SK_ScalarHalf); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 verts->fOffset = SkPoint::Make(xOuterRadius, yOuterOffsets[i]); | 1406 verts->fOffset = SkPoint::Make(xOuterRadius, yOuterOffsets[i]); |
| 1406 verts->fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); | 1407 verts->fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); |
| 1407 verts->fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); | 1408 verts->fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); |
| 1408 verts++; | 1409 verts++; |
| 1409 } | 1410 } |
| 1410 | 1411 |
| 1411 // drop out the middle quad if we're stroked | 1412 // drop out the middle quad if we're stroked |
| 1412 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : | 1413 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : |
| 1413 SK_ARRAY_COUNT(gRRectIndices); | 1414 SK_ARRAY_COUNT(gRRectIndices); |
| 1414 target->setIndexSourceToBuffer(indexBuffer); | 1415 target->setIndexSourceToBuffer(indexBuffer); |
| 1415 target->drawIndexedInstances(drawState, effect, kTriangles_GrPrimitiveTy
pe, 1, 16, indexCnt, | 1416 target->drawIndexedInstances(pipelineBuilder, effect, kTriangles_GrPrimi
tiveType, 1, 16, |
| 1416 &bounds); | 1417 indexCnt, &bounds); |
| 1417 } | 1418 } |
| 1418 | 1419 |
| 1419 target->resetIndexSource(); | 1420 target->resetIndexSource(); |
| 1420 return true; | 1421 return true; |
| 1421 } | 1422 } |
| OLD | NEW |