| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "GrBatchTest.h" | 9 #include "GrBatchTest.h" |
| 10 #include "GrColor.h" | 10 #include "GrColor.h" |
| 11 #include "GrDrawContext.h" | 11 #include "GrDrawContext.h" |
| 12 #include "GrDrawingManager.h" | 12 #include "GrDrawingManager.h" |
| 13 #include "GrOvalRenderer.h" | 13 #include "GrOvalRenderer.h" |
| 14 #include "GrPathRenderer.h" | 14 #include "GrPathRenderer.h" |
| 15 #include "GrRenderTarget.h" | 15 #include "GrRenderTarget.h" |
| 16 #include "GrRenderTargetPriv.h" | 16 #include "GrRenderTargetPriv.h" |
| 17 #include "GrResourceProvider.h" | 17 #include "GrResourceProvider.h" |
| 18 #include "SkSurfacePriv.h" | 18 #include "SkSurfacePriv.h" |
| 19 | 19 |
| 20 #include "batches/GrBatch.h" | 20 #include "batches/GrBatch.h" |
| 21 #include "batches/GrDrawAtlasBatch.h" | 21 #include "batches/GrDrawAtlasBatch.h" |
| 22 #include "batches/GrDrawVerticesBatch.h" | 22 #include "batches/GrDrawVerticesBatch.h" |
| 23 #include "batches/GrRectBatchFactory.h" | 23 #include "batches/GrRectBatchFactory.h" |
| 24 #include "batches/GrNinePatch.h" // TODO Factory | 24 #include "batches/GrNinePatch.h" // TODO Factory |
| 25 | 25 |
| 26 #include "effects/GrRRectEffect.h" |
| 27 |
| 26 #include "text/GrAtlasTextContext.h" | 28 #include "text/GrAtlasTextContext.h" |
| 27 #include "text/GrStencilAndCoverTextContext.h" | 29 #include "text/GrStencilAndCoverTextContext.h" |
| 28 | 30 |
| 29 #include "../private/GrAuditTrail.h" | 31 #include "../private/GrAuditTrail.h" |
| 30 | 32 |
| 31 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM
anager->getContext()) | 33 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM
anager->getContext()) |
| 32 #define ASSERT_SINGLE_OWNER \ | 34 #define ASSERT_SINGLE_OWNER \ |
| 33 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);) | 35 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);) |
| 34 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } | 36 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } |
| 35 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fa
lse; } | 37 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fa
lse; } |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 } | 510 } |
| 509 } | 511 } |
| 510 | 512 |
| 511 SkPath path; | 513 SkPath path; |
| 512 path.setIsVolatile(true); | 514 path.setIsVolatile(true); |
| 513 path.addRRect(rrect); | 515 path.addRRect(rrect); |
| 514 this->internalDrawPath(&pipelineBuilder, viewMatrix, color, | 516 this->internalDrawPath(&pipelineBuilder, viewMatrix, color, |
| 515 paint.isAntiAlias(), path, strokeInfo); | 517 paint.isAntiAlias(), path, strokeInfo); |
| 516 } | 518 } |
| 517 | 519 |
| 520 bool GrDrawContext::drawFilledDRRect(const GrClip& clip, |
| 521 const GrPaint& paintIn, |
| 522 const SkMatrix& viewMatrix, |
| 523 const SkRRect& origOuter, |
| 524 const SkRRect& origInner) { |
| 525 SkASSERT(!origInner.isEmpty()); |
| 526 SkASSERT(!origOuter.isEmpty()); |
| 527 |
| 528 bool applyAA = paintIn.isAntiAlias() && !fRenderTarget->isUnifiedMultisample
d(); |
| 529 |
| 530 GrPrimitiveEdgeType innerEdgeType = applyAA ? kInverseFillAA_GrProcessorEdge
Type : |
| 531 kInverseFillBW_GrProcessorEdge
Type; |
| 532 GrPrimitiveEdgeType outerEdgeType = applyAA ? kFillAA_GrProcessorEdgeType : |
| 533 kFillBW_GrProcessorEdgeType; |
| 534 |
| 535 SkTCopyOnFirstWrite<SkRRect> inner(origInner), outer(origOuter); |
| 536 SkMatrix inverseVM; |
| 537 if (!viewMatrix.isIdentity()) { |
| 538 if (!origInner.transform(viewMatrix, inner.writable())) { |
| 539 return false; |
| 540 } |
| 541 if (!origOuter.transform(viewMatrix, outer.writable())) { |
| 542 return false; |
| 543 } |
| 544 if (!viewMatrix.invert(&inverseVM)) { |
| 545 return false; |
| 546 } |
| 547 } else { |
| 548 inverseVM.reset(); |
| 549 } |
| 550 |
| 551 GrPaint grPaint(paintIn); |
| 552 grPaint.setAntiAlias(false); |
| 553 |
| 554 // TODO these need to be a geometry processors |
| 555 SkAutoTUnref<GrFragmentProcessor> innerEffect(GrRRectEffect::Create(innerEdg
eType, *inner)); |
| 556 if (!innerEffect) { |
| 557 return false; |
| 558 } |
| 559 |
| 560 SkAutoTUnref<GrFragmentProcessor> outerEffect(GrRRectEffect::Create(outerEdg
eType, *outer)); |
| 561 if (!outerEffect) { |
| 562 return false; |
| 563 } |
| 564 |
| 565 grPaint.addCoverageFragmentProcessor(innerEffect); |
| 566 grPaint.addCoverageFragmentProcessor(outerEffect); |
| 567 |
| 568 SkRect bounds = outer->getBounds(); |
| 569 if (applyAA) { |
| 570 bounds.outset(SK_ScalarHalf, SK_ScalarHalf); |
| 571 } |
| 572 |
| 573 this->fillRectWithLocalMatrix(clip, grPaint, SkMatrix::I(), bounds, inverseV
M); |
| 574 return true; |
| 575 } |
| 576 |
| 577 void GrDrawContext::drawDRRect(const GrClip& clip, |
| 578 const GrPaint& paint, |
| 579 const SkMatrix& viewMatrix, |
| 580 const SkRRect& outer, |
| 581 const SkRRect& inner) { |
| 582 ASSERT_SINGLE_OWNER |
| 583 RETURN_IF_ABANDONED |
| 584 SkDEBUGCODE(this->validate();) |
| 585 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawDRRect"); |
| 586 |
| 587 SkASSERT(!outer.isEmpty()); |
| 588 SkASSERT(!inner.isEmpty()); |
| 589 |
| 590 AutoCheckFlush acf(fDrawingManager); |
| 591 |
| 592 if (this->drawFilledDRRect(clip, paint, viewMatrix, outer, inner)) { |
| 593 return; |
| 594 } |
| 595 |
| 596 SkPath path; |
| 597 path.setIsVolatile(true); |
| 598 path.addRRect(inner); |
| 599 path.addRRect(outer); |
| 600 path.setFillType(SkPath::kEvenOdd_FillType); |
| 601 |
| 602 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); |
| 603 this->internalDrawPath(&pipelineBuilder, viewMatrix, paint.getColor(), |
| 604 paint.isAntiAlias(), path, GrStrokeInfo::FillInfo())
; |
| 605 } |
| 606 |
| 518 /////////////////////////////////////////////////////////////////////////////// | 607 /////////////////////////////////////////////////////////////////////////////// |
| 519 | 608 |
| 520 void GrDrawContext::drawOval(const GrClip& clip, | 609 void GrDrawContext::drawOval(const GrClip& clip, |
| 521 const GrPaint& paint, | 610 const GrPaint& paint, |
| 522 const SkMatrix& viewMatrix, | 611 const SkMatrix& viewMatrix, |
| 523 const SkRect& oval, | 612 const SkRect& oval, |
| 524 const GrStrokeInfo& strokeInfo) { | 613 const GrStrokeInfo& strokeInfo) { |
| 525 ASSERT_SINGLE_OWNER | 614 ASSERT_SINGLE_OWNER |
| 526 RETURN_IF_ABANDONED | 615 RETURN_IF_ABANDONED |
| 527 SkDEBUGCODE(this->validate();) | 616 SkDEBUGCODE(this->validate();) |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 } | 907 } |
| 819 | 908 |
| 820 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { | 909 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { |
| 821 ASSERT_SINGLE_OWNER | 910 ASSERT_SINGLE_OWNER |
| 822 RETURN_IF_ABANDONED | 911 RETURN_IF_ABANDONED |
| 823 SkDEBUGCODE(this->validate();) | 912 SkDEBUGCODE(this->validate();) |
| 824 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 913 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
| 825 | 914 |
| 826 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); | 915 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); |
| 827 } | 916 } |
| OLD | NEW |