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 "GrBatch.h" | 10 #include "GrBatch.h" |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 | 651 |
652 bool GrOvalRenderer::drawOval(GrDrawTarget* target, | 652 bool GrOvalRenderer::drawOval(GrDrawTarget* target, |
653 GrPipelineBuilder* pipelineBuilder, | 653 GrPipelineBuilder* pipelineBuilder, |
654 GrColor color, | 654 GrColor color, |
655 const SkMatrix& viewMatrix, | 655 const SkMatrix& viewMatrix, |
656 bool useAA, | 656 bool useAA, |
657 const SkRect& oval, | 657 const SkRect& oval, |
658 const SkStrokeRec& stroke) | 658 const SkStrokeRec& stroke) |
659 { | 659 { |
660 bool useCoverageAA = useAA && | 660 bool useCoverageAA = useAA && |
661 !pipelineBuilder->getRenderTarget()->isMultisampled() && | 661 !pipelineBuilder->getRenderTarget()->isMultisampled(); |
662 pipelineBuilder->canUseFracCoveragePrimProc(color, *target->caps()); | |
663 | 662 |
664 if (!useCoverageAA) { | 663 if (!useCoverageAA) { |
665 return false; | 664 return false; |
666 } | 665 } |
667 | 666 |
668 // we can draw circles | 667 // we can draw circles |
669 if (SkScalarNearlyEqual(oval.width(), oval.height()) && circle_stays_circle(
viewMatrix)) { | 668 if (SkScalarNearlyEqual(oval.width(), oval.height()) && circle_stays_circle(
viewMatrix)) { |
670 this->drawCircle(target, pipelineBuilder, color, viewMatrix, useCoverage
AA, oval, stroke); | 669 this->drawCircle(target, pipelineBuilder, color, viewMatrix, useCoverage
AA, oval, stroke); |
671 // if we have shader derivative support, render as device-independent | 670 // if we have shader derivative support, render as device-independent |
672 } else if (target->caps()->shaderDerivativeSupport()) { | 671 } else if (target->caps()->shaderDerivativeSupport()) { |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 } | 1547 } |
1549 | 1548 |
1550 bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, | 1549 bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, |
1551 GrPipelineBuilder* pipelineBuilder, | 1550 GrPipelineBuilder* pipelineBuilder, |
1552 GrColor color, | 1551 GrColor color, |
1553 const SkMatrix& viewMatrix, | 1552 const SkMatrix& viewMatrix, |
1554 bool useAA, | 1553 bool useAA, |
1555 const SkRRect& origOuter, | 1554 const SkRRect& origOuter, |
1556 const SkRRect& origInner) { | 1555 const SkRRect& origInner) { |
1557 bool applyAA = useAA && | 1556 bool applyAA = useAA && |
1558 !pipelineBuilder->getRenderTarget()->isMultisampled() && | 1557 !pipelineBuilder->getRenderTarget()->isMultisampled(); |
1559 pipelineBuilder->canUseFracCoveragePrimProc(color, *target->c
aps()); | |
1560 GrPipelineBuilder::AutoRestoreEffects are; | 1558 GrPipelineBuilder::AutoRestoreEffects are; |
1561 if (!origInner.isEmpty()) { | 1559 if (!origInner.isEmpty()) { |
1562 SkTCopyOnFirstWrite<SkRRect> inner(origInner); | 1560 SkTCopyOnFirstWrite<SkRRect> inner(origInner); |
1563 if (!viewMatrix.isIdentity()) { | 1561 if (!viewMatrix.isIdentity()) { |
1564 if (!origInner.transform(viewMatrix, inner.writable())) { | 1562 if (!origInner.transform(viewMatrix, inner.writable())) { |
1565 return false; | 1563 return false; |
1566 } | 1564 } |
1567 } | 1565 } |
1568 GrPrimitiveEdgeType edgeType = applyAA ? | 1566 GrPrimitiveEdgeType edgeType = applyAA ? |
1569 kInverseFillAA_GrProcessorEdgeType : | 1567 kInverseFillAA_GrProcessorEdgeType : |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2037 const SkMatrix& viewMatrix, | 2035 const SkMatrix& viewMatrix, |
2038 bool useAA, | 2036 bool useAA, |
2039 const SkRRect& rrect, | 2037 const SkRRect& rrect, |
2040 const SkStrokeRec& stroke) { | 2038 const SkStrokeRec& stroke) { |
2041 if (rrect.isOval()) { | 2039 if (rrect.isOval()) { |
2042 return this->drawOval(target, pipelineBuilder, color, viewMatrix, useAA,
rrect.getBounds(), | 2040 return this->drawOval(target, pipelineBuilder, color, viewMatrix, useAA,
rrect.getBounds(), |
2043 stroke); | 2041 stroke); |
2044 } | 2042 } |
2045 | 2043 |
2046 bool useCoverageAA = useAA && | 2044 bool useCoverageAA = useAA && |
2047 !pipelineBuilder->getRenderTarget()->isMultisampled() && | 2045 !pipelineBuilder->getRenderTarget()->isMultisampled(); |
2048 pipelineBuilder->canUseFracCoveragePrimProc(color, *target->caps()); | |
2049 | 2046 |
2050 // only anti-aliased rrects for now | 2047 // only anti-aliased rrects for now |
2051 if (!useCoverageAA) { | 2048 if (!useCoverageAA) { |
2052 return false; | 2049 return false; |
2053 } | 2050 } |
2054 | 2051 |
2055 if (!viewMatrix.rectStaysRect() || !rrect.isSimple()) { | 2052 if (!viewMatrix.rectStaysRect() || !rrect.isSimple()) { |
2056 return false; | 2053 return false; |
2057 } | 2054 } |
2058 | 2055 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2198 geometry.fInnerXRadius = innerXRadius; | 2195 geometry.fInnerXRadius = innerXRadius; |
2199 geometry.fInnerYRadius = innerYRadius; | 2196 geometry.fInnerYRadius = innerYRadius; |
2200 geometry.fStroke = isStrokeOnly; | 2197 geometry.fStroke = isStrokeOnly; |
2201 geometry.fDevBounds = bounds; | 2198 geometry.fDevBounds = bounds; |
2202 | 2199 |
2203 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry,
indexBuffer)); | 2200 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry,
indexBuffer)); |
2204 target->drawBatch(pipelineBuilder, batch, &bounds); | 2201 target->drawBatch(pipelineBuilder, batch, &bounds); |
2205 } | 2202 } |
2206 return true; | 2203 return true; |
2207 } | 2204 } |
OLD | NEW |