| 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" |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 | 658 |
| 659 bool GrOvalRenderer::drawOval(GrDrawTarget* target, | 659 bool GrOvalRenderer::drawOval(GrDrawTarget* target, |
| 660 GrPipelineBuilder* pipelineBuilder, | 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 !pipelineBuilder->getRenderTarget()->isMultisampled() && | 668 !pipelineBuilder->getRenderTarget()->isMultisampled(); |
| 669 pipelineBuilder->canUseFracCoveragePrimProc(color, *target->caps()); | |
| 670 | 669 |
| 671 if (!useCoverageAA) { | 670 if (!useCoverageAA) { |
| 672 return false; | 671 return false; |
| 673 } | 672 } |
| 674 | 673 |
| 675 // we can draw circles | 674 // we can draw circles |
| 676 if (SkScalarNearlyEqual(oval.width(), oval.height()) && circle_stays_circle(
viewMatrix)) { | 675 if (SkScalarNearlyEqual(oval.width(), oval.height()) && circle_stays_circle(
viewMatrix)) { |
| 677 this->drawCircle(target, pipelineBuilder, color, viewMatrix, useCoverage
AA, oval, stroke); | 676 this->drawCircle(target, pipelineBuilder, color, viewMatrix, useCoverage
AA, oval, stroke); |
| 678 // if we have shader derivative support, render as device-independent | 677 // if we have shader derivative support, render as device-independent |
| 679 } else if (target->caps()->shaderDerivativeSupport()) { | 678 } else if (target->caps()->shaderDerivativeSupport()) { |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 } | 1072 } |
| 1074 | 1073 |
| 1075 bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, | 1074 bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, |
| 1076 GrPipelineBuilder* pipelineBuilder, | 1075 GrPipelineBuilder* pipelineBuilder, |
| 1077 GrColor color, | 1076 GrColor color, |
| 1078 const SkMatrix& viewMatrix, | 1077 const SkMatrix& viewMatrix, |
| 1079 bool useAA, | 1078 bool useAA, |
| 1080 const SkRRect& origOuter, | 1079 const SkRRect& origOuter, |
| 1081 const SkRRect& origInner) { | 1080 const SkRRect& origInner) { |
| 1082 bool applyAA = useAA && | 1081 bool applyAA = useAA && |
| 1083 !pipelineBuilder->getRenderTarget()->isMultisampled() && | 1082 !pipelineBuilder->getRenderTarget()->isMultisampled(); |
| 1084 pipelineBuilder->canUseFracCoveragePrimProc(color, *target->c
aps()); | |
| 1085 GrPipelineBuilder::AutoRestoreEffects are; | 1083 GrPipelineBuilder::AutoRestoreEffects are; |
| 1086 if (!origInner.isEmpty()) { | 1084 if (!origInner.isEmpty()) { |
| 1087 SkTCopyOnFirstWrite<SkRRect> inner(origInner); | 1085 SkTCopyOnFirstWrite<SkRRect> inner(origInner); |
| 1088 if (!viewMatrix.isIdentity()) { | 1086 if (!viewMatrix.isIdentity()) { |
| 1089 if (!origInner.transform(viewMatrix, inner.writable())) { | 1087 if (!origInner.transform(viewMatrix, inner.writable())) { |
| 1090 return false; | 1088 return false; |
| 1091 } | 1089 } |
| 1092 } | 1090 } |
| 1093 GrPrimitiveEdgeType edgeType = applyAA ? | 1091 GrPrimitiveEdgeType edgeType = applyAA ? |
| 1094 kInverseFillAA_GrProcessorEdgeType : | 1092 kInverseFillAA_GrProcessorEdgeType : |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 const SkMatrix& viewMatrix, | 1142 const SkMatrix& viewMatrix, |
| 1145 bool useAA, | 1143 bool useAA, |
| 1146 const SkRRect& rrect, | 1144 const SkRRect& rrect, |
| 1147 const SkStrokeRec& stroke) { | 1145 const SkStrokeRec& stroke) { |
| 1148 if (rrect.isOval()) { | 1146 if (rrect.isOval()) { |
| 1149 return this->drawOval(target, pipelineBuilder, color, viewMatrix, useAA,
rrect.getBounds(), | 1147 return this->drawOval(target, pipelineBuilder, color, viewMatrix, useAA,
rrect.getBounds(), |
| 1150 stroke); | 1148 stroke); |
| 1151 } | 1149 } |
| 1152 | 1150 |
| 1153 bool useCoverageAA = useAA && | 1151 bool useCoverageAA = useAA && |
| 1154 !pipelineBuilder->getRenderTarget()->isMultisampled() && | 1152 !pipelineBuilder->getRenderTarget()->isMultisampled(); |
| 1155 pipelineBuilder->canUseFracCoveragePrimProc(color, *target->caps()); | |
| 1156 | 1153 |
| 1157 // only anti-aliased rrects for now | 1154 // only anti-aliased rrects for now |
| 1158 if (!useCoverageAA) { | 1155 if (!useCoverageAA) { |
| 1159 return false; | 1156 return false; |
| 1160 } | 1157 } |
| 1161 | 1158 |
| 1162 if (!viewMatrix.rectStaysRect() || !rrect.isSimple()) { | 1159 if (!viewMatrix.rectStaysRect() || !rrect.isSimple()) { |
| 1163 return false; | 1160 return false; |
| 1164 } | 1161 } |
| 1165 | 1162 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : | 1410 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : |
| 1414 SK_ARRAY_COUNT(gRRectIndices); | 1411 SK_ARRAY_COUNT(gRRectIndices); |
| 1415 target->setIndexSourceToBuffer(indexBuffer); | 1412 target->setIndexSourceToBuffer(indexBuffer); |
| 1416 target->drawIndexedInstances(pipelineBuilder, effect, kTriangles_GrPrimi
tiveType, 1, 16, | 1413 target->drawIndexedInstances(pipelineBuilder, effect, kTriangles_GrPrimi
tiveType, 1, 16, |
| 1417 indexCnt, &bounds); | 1414 indexCnt, &bounds); |
| 1418 } | 1415 } |
| 1419 | 1416 |
| 1420 target->resetIndexSource(); | 1417 target->resetIndexSource(); |
| 1421 return true; | 1418 return true; |
| 1422 } | 1419 } |
| OLD | NEW |