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 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 } | 1383 } |
1384 | 1384 |
1385 bool GrOvalRenderer::DrawDRRect(GrDrawTarget* target, | 1385 bool GrOvalRenderer::DrawDRRect(GrDrawTarget* target, |
1386 const GrPipelineBuilder& pipelineBuilder, | 1386 const GrPipelineBuilder& pipelineBuilder, |
1387 GrColor color, | 1387 GrColor color, |
1388 const SkMatrix& viewMatrix, | 1388 const SkMatrix& viewMatrix, |
1389 bool useAA, | 1389 bool useAA, |
1390 const SkRRect& origOuter, | 1390 const SkRRect& origOuter, |
1391 const SkRRect& origInner) { | 1391 const SkRRect& origInner) { |
1392 bool applyAA = useAA && !pipelineBuilder.getRenderTarget()->isUnifiedMultisa
mpled(); | 1392 bool applyAA = useAA && !pipelineBuilder.getRenderTarget()->isUnifiedMultisa
mpled(); |
1393 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp; | 1393 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
1394 if (!origInner.isEmpty()) { | 1394 if (!origInner.isEmpty()) { |
1395 SkTCopyOnFirstWrite<SkRRect> inner(origInner); | 1395 SkTCopyOnFirstWrite<SkRRect> inner(origInner); |
1396 if (!viewMatrix.isIdentity()) { | 1396 if (!viewMatrix.isIdentity()) { |
1397 if (!origInner.transform(viewMatrix, inner.writable())) { | 1397 if (!origInner.transform(viewMatrix, inner.writable())) { |
1398 return false; | 1398 return false; |
1399 } | 1399 } |
1400 } | 1400 } |
1401 GrPrimitiveEdgeType edgeType = applyAA ? | 1401 GrPrimitiveEdgeType edgeType = applyAA ? |
1402 kInverseFillAA_GrProcessorEdgeType : | 1402 kInverseFillAA_GrProcessorEdgeType : |
1403 kInverseFillBW_GrProcessorEdgeType; | 1403 kInverseFillBW_GrProcessorEdgeType; |
1404 // TODO this needs to be a geometry processor | 1404 // TODO this needs to be a geometry processor |
1405 GrFragmentProcessor* fp = GrRRectEffect::Create(edgeType, *inner); | 1405 GrFragmentProcessor* fp = GrRRectEffect::Create(edgeType, *inner); |
1406 if (NULL == fp) { | 1406 if (NULL == fp) { |
1407 return false; | 1407 return false; |
1408 } | 1408 } |
1409 arfp.set(&pipelineBuilder); | 1409 arfps.set(&pipelineBuilder); |
1410 arfp.addCoverageProcessor(fp)->unref(); | 1410 arfps.addCoverageProcessor(fp)->unref(); |
1411 } | 1411 } |
1412 | 1412 |
1413 SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle); | 1413 SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle); |
1414 if (DrawRRect(target, pipelineBuilder, color, viewMatrix, useAA, origOuter,
fillRec)) { | 1414 if (DrawRRect(target, pipelineBuilder, color, viewMatrix, useAA, origOuter,
fillRec)) { |
1415 return true; | 1415 return true; |
1416 } | 1416 } |
1417 | 1417 |
1418 SkASSERT(!origOuter.isEmpty()); | 1418 SkASSERT(!origOuter.isEmpty()); |
1419 SkTCopyOnFirstWrite<SkRRect> outer(origOuter); | 1419 SkTCopyOnFirstWrite<SkRRect> outer(origOuter); |
1420 if (!viewMatrix.isIdentity()) { | 1420 if (!viewMatrix.isIdentity()) { |
1421 if (!origOuter.transform(viewMatrix, outer.writable())) { | 1421 if (!origOuter.transform(viewMatrix, outer.writable())) { |
1422 return false; | 1422 return false; |
1423 } | 1423 } |
1424 } | 1424 } |
1425 GrPrimitiveEdgeType edgeType = applyAA ? kFillAA_GrProcessorEdgeType : | 1425 GrPrimitiveEdgeType edgeType = applyAA ? kFillAA_GrProcessorEdgeType : |
1426 kFillBW_GrProcessorEdgeType; | 1426 kFillBW_GrProcessorEdgeType; |
1427 GrFragmentProcessor* effect = GrRRectEffect::Create(edgeType, *outer); | 1427 GrFragmentProcessor* effect = GrRRectEffect::Create(edgeType, *outer); |
1428 if (NULL == effect) { | 1428 if (NULL == effect) { |
1429 return false; | 1429 return false; |
1430 } | 1430 } |
1431 if (!arfp.isSet()) { | 1431 if (!arfps.isSet()) { |
1432 arfp.set(&pipelineBuilder); | 1432 arfps.set(&pipelineBuilder); |
1433 } | 1433 } |
1434 | 1434 |
1435 SkMatrix invert; | 1435 SkMatrix invert; |
1436 if (!viewMatrix.invert(&invert)) { | 1436 if (!viewMatrix.invert(&invert)) { |
1437 return false; | 1437 return false; |
1438 } | 1438 } |
1439 | 1439 |
1440 arfp.addCoverageProcessor(effect)->unref(); | 1440 arfps.addCoverageProcessor(effect)->unref(); |
1441 SkRect bounds = outer->getBounds(); | 1441 SkRect bounds = outer->getBounds(); |
1442 if (applyAA) { | 1442 if (applyAA) { |
1443 bounds.outset(SK_ScalarHalf, SK_ScalarHalf); | 1443 bounds.outset(SK_ScalarHalf, SK_ScalarHalf); |
1444 } | 1444 } |
1445 target->drawBWRect(pipelineBuilder, color, SkMatrix::I(), bounds, NULL, &inv
ert); | 1445 target->drawBWRect(pipelineBuilder, color, SkMatrix::I(), bounds, NULL, &inv
ert); |
1446 return true; | 1446 return true; |
1447 } | 1447 } |
1448 | 1448 |
1449 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 1449 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
1450 | 1450 |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2012 } | 2012 } |
2013 | 2013 |
2014 BATCH_TEST_DEFINE(RRectBatch) { | 2014 BATCH_TEST_DEFINE(RRectBatch) { |
2015 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); | 2015 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); |
2016 GrColor color = GrRandomColor(random); | 2016 GrColor color = GrRandomColor(random); |
2017 const SkRRect& rrect = GrTest::TestRRectSimple(random); | 2017 const SkRRect& rrect = GrTest::TestRRectSimple(random); |
2018 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); | 2018 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); |
2019 } | 2019 } |
2020 | 2020 |
2021 #endif | 2021 #endif |
OLD | NEW |