| 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 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1548 | 1548 |
| 1549 bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, | 1549 bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, |
| 1550 GrPipelineBuilder* pipelineBuilder, | 1550 GrPipelineBuilder* pipelineBuilder, |
| 1551 GrColor color, | 1551 GrColor color, |
| 1552 const SkMatrix& viewMatrix, | 1552 const SkMatrix& viewMatrix, |
| 1553 bool useAA, | 1553 bool useAA, |
| 1554 const SkRRect& origOuter, | 1554 const SkRRect& origOuter, |
| 1555 const SkRRect& origInner) { | 1555 const SkRRect& origInner) { |
| 1556 bool applyAA = useAA && | 1556 bool applyAA = useAA && |
| 1557 !pipelineBuilder->getRenderTarget()->isMultisampled(); | 1557 !pipelineBuilder->getRenderTarget()->isMultisampled(); |
| 1558 GrPipelineBuilder::AutoRestoreEffects are; | 1558 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp; |
| 1559 if (!origInner.isEmpty()) { | 1559 if (!origInner.isEmpty()) { |
| 1560 SkTCopyOnFirstWrite<SkRRect> inner(origInner); | 1560 SkTCopyOnFirstWrite<SkRRect> inner(origInner); |
| 1561 if (!viewMatrix.isIdentity()) { | 1561 if (!viewMatrix.isIdentity()) { |
| 1562 if (!origInner.transform(viewMatrix, inner.writable())) { | 1562 if (!origInner.transform(viewMatrix, inner.writable())) { |
| 1563 return false; | 1563 return false; |
| 1564 } | 1564 } |
| 1565 } | 1565 } |
| 1566 GrPrimitiveEdgeType edgeType = applyAA ? | 1566 GrPrimitiveEdgeType edgeType = applyAA ? |
| 1567 kInverseFillAA_GrProcessorEdgeType : | 1567 kInverseFillAA_GrProcessorEdgeType : |
| 1568 kInverseFillBW_GrProcessorEdgeType; | 1568 kInverseFillBW_GrProcessorEdgeType; |
| 1569 // TODO this needs to be a geometry processor | 1569 // TODO this needs to be a geometry processor |
| 1570 GrFragmentProcessor* fp = GrRRectEffect::Create(edgeType, *inner); | 1570 GrFragmentProcessor* fp = GrRRectEffect::Create(edgeType, *inner); |
| 1571 if (NULL == fp) { | 1571 if (NULL == fp) { |
| 1572 return false; | 1572 return false; |
| 1573 } | 1573 } |
| 1574 are.set(pipelineBuilder); | 1574 arfp.set(pipelineBuilder); |
| 1575 pipelineBuilder->addCoverageProcessor(fp)->unref(); | 1575 pipelineBuilder->addCoverageProcessor(fp)->unref(); |
| 1576 } | 1576 } |
| 1577 | 1577 |
| 1578 SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle); | 1578 SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle); |
| 1579 if (this->drawRRect(target, pipelineBuilder, color, viewMatrix, useAA, origO
uter, fillRec)) { | 1579 if (this->drawRRect(target, pipelineBuilder, color, viewMatrix, useAA, origO
uter, fillRec)) { |
| 1580 return true; | 1580 return true; |
| 1581 } | 1581 } |
| 1582 | 1582 |
| 1583 SkASSERT(!origOuter.isEmpty()); | 1583 SkASSERT(!origOuter.isEmpty()); |
| 1584 SkTCopyOnFirstWrite<SkRRect> outer(origOuter); | 1584 SkTCopyOnFirstWrite<SkRRect> outer(origOuter); |
| 1585 if (!viewMatrix.isIdentity()) { | 1585 if (!viewMatrix.isIdentity()) { |
| 1586 if (!origOuter.transform(viewMatrix, outer.writable())) { | 1586 if (!origOuter.transform(viewMatrix, outer.writable())) { |
| 1587 return false; | 1587 return false; |
| 1588 } | 1588 } |
| 1589 } | 1589 } |
| 1590 GrPrimitiveEdgeType edgeType = applyAA ? kFillAA_GrProcessorEdgeType : | 1590 GrPrimitiveEdgeType edgeType = applyAA ? kFillAA_GrProcessorEdgeType : |
| 1591 kFillBW_GrProcessorEdgeType; | 1591 kFillBW_GrProcessorEdgeType; |
| 1592 GrFragmentProcessor* effect = GrRRectEffect::Create(edgeType, *outer); | 1592 GrFragmentProcessor* effect = GrRRectEffect::Create(edgeType, *outer); |
| 1593 if (NULL == effect) { | 1593 if (NULL == effect) { |
| 1594 return false; | 1594 return false; |
| 1595 } | 1595 } |
| 1596 if (!are.isSet()) { | 1596 if (!arfp.isSet()) { |
| 1597 are.set(pipelineBuilder); | 1597 arfp.set(pipelineBuilder); |
| 1598 } | 1598 } |
| 1599 | 1599 |
| 1600 SkMatrix invert; | 1600 SkMatrix invert; |
| 1601 if (!viewMatrix.invert(&invert)) { | 1601 if (!viewMatrix.invert(&invert)) { |
| 1602 return false; | 1602 return false; |
| 1603 } | 1603 } |
| 1604 | 1604 |
| 1605 pipelineBuilder->addCoverageProcessor(effect)->unref(); | 1605 pipelineBuilder->addCoverageProcessor(effect)->unref(); |
| 1606 SkRect bounds = outer->getBounds(); | 1606 SkRect bounds = outer->getBounds(); |
| 1607 if (applyAA) { | 1607 if (applyAA) { |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2195 geometry.fInnerXRadius = innerXRadius; | 2195 geometry.fInnerXRadius = innerXRadius; |
| 2196 geometry.fInnerYRadius = innerYRadius; | 2196 geometry.fInnerYRadius = innerYRadius; |
| 2197 geometry.fStroke = isStrokeOnly; | 2197 geometry.fStroke = isStrokeOnly; |
| 2198 geometry.fDevBounds = bounds; | 2198 geometry.fDevBounds = bounds; |
| 2199 | 2199 |
| 2200 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry,
indexBuffer)); | 2200 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry,
indexBuffer)); |
| 2201 target->drawBatch(pipelineBuilder, batch, &bounds); | 2201 target->drawBatch(pipelineBuilder, batch, &bounds); |
| 2202 } | 2202 } |
| 2203 return true; | 2203 return true; |
| 2204 } | 2204 } |
| OLD | NEW |