Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrBatchTest.h" | 8 #include "GrBatchTest.h" |
| 9 #include "GrColor.h" | 9 #include "GrColor.h" |
| 10 #include "GrDrawContext.h" | 10 #include "GrDrawContext.h" |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 609 SkDEBUGCODE(this->validate();) | 609 SkDEBUGCODE(this->validate();) |
| 610 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectToRect"); | 610 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectToRect"); |
| 611 | 611 |
| 612 SkRect croppedRect = rectToDraw; | 612 SkRect croppedRect = rectToDraw; |
| 613 SkRect croppedLocalRect = localRect; | 613 SkRect croppedLocalRect = localRect; |
| 614 if (!crop_filled_rect(fRenderTarget.get(), clip, viewMatrix, &croppedRect, & croppedLocalRect)) { | 614 if (!crop_filled_rect(fRenderTarget.get(), clip, viewMatrix, &croppedRect, & croppedLocalRect)) { |
| 615 return; | 615 return; |
| 616 } | 616 } |
| 617 | 617 |
| 618 AutoCheckFlush acf(fDrawingManager); | 618 AutoCheckFlush acf(fDrawingManager); |
| 619 SkAutoTUnref<GrDrawBatch> batch; | |
| 620 bool useHWAA; | 619 bool useHWAA; |
| 621 | 620 |
| 622 if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) { | 621 if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) { |
| 623 batch.reset(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), cr oppedLocalRect, | 622 SkAutoTUnref<GrDrawBatch> batch(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), |
| 624 paint.isAntiAlias(), fInstancedPipelineInfo, &useHWAA)); | 623 croppedLocalRect, paint.i sAntiAlias(), |
| 624 fInstancedPipelineInfo, & useHWAA)); | |
| 625 if (batch) { | 625 if (batch) { |
| 626 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | 626 GrPipelineBuilder pipelineBuilder(paint, useHWAA); |
| 627 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch) ; | 627 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch) ; |
| 628 return; | 628 return; |
| 629 } | 629 } |
| 630 } | 630 } |
| 631 | 631 |
| 632 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) && | 632 if (!should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) { |
| 633 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | |
| 634 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie wMatrix, | |
| 635 croppedRect, croppedL ocalRect)); | |
| 636 if (batch) { | |
| 637 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | |
| 638 this->drawBatch(pipelineBuilder, clip, batch); | |
| 639 return; | |
| 640 } | |
| 641 } else { | |
| 642 this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, &cropped LocalRect, | 633 this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, &cropped LocalRect, |
| 643 nullptr, nullptr); | 634 nullptr, nullptr); |
| 635 return; | |
| 644 } | 636 } |
| 645 | 637 |
| 638 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | |
| 639 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::CreateWithLocalRect(p aint.getColor(), | |
| 640 v iewMatrix, | |
| 641 c roppedRect, | |
| 642 c roppedLocalRect)); | |
| 643 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | |
| 644 this->drawBatch(pipelineBuilder, clip, batch); | |
| 645 return; | |
| 646 } | |
| 647 | |
| 648 SkMatrix viewAndUnLocalMatrix; | |
| 649 if (!viewAndUnLocalMatrix.setRectToRect(localRect, rectToDraw, SkMatrix::kFi ll_ScaleToFit)) { | |
| 650 SkFAIL("Bogus local rect."); // I'm hoping this is illegal and we can ju st bail? | |
|
csmartdalton
2016/07/26 20:28:28
Is an empty local rect legal?
bsalomon
2016/07/26 20:33:03
I don't think so. Seems ok to bail to me.
| |
| 651 return; | |
| 652 } | |
| 653 viewAndUnLocalMatrix.postConcat(viewMatrix); | |
| 654 | |
| 655 SkPath path; | |
| 656 path.setIsVolatile(true); | |
| 657 path.addRect(localRect); | |
| 658 this->internalDrawPath(clip, paint, viewAndUnLocalMatrix, path, GrStyle()); | |
| 646 } | 659 } |
| 647 | 660 |
| 648 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, | 661 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, |
| 649 const GrPaint& paint, | 662 const GrPaint& paint, |
| 650 const SkMatrix& viewMatrix, | 663 const SkMatrix& viewMatrix, |
| 651 const SkRect& rectToDraw, | 664 const SkRect& rectToDraw, |
| 652 const SkMatrix& localMatrix) { | 665 const SkMatrix& localMatrix) { |
| 653 ASSERT_SINGLE_OWNER | 666 ASSERT_SINGLE_OWNER |
| 654 RETURN_IF_ABANDONED | 667 RETURN_IF_ABANDONED |
| 655 SkDEBUGCODE(this->validate();) | 668 SkDEBUGCODE(this->validate();) |
| 656 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectWithLocalMatr ix"); | 669 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectWithLocalMatr ix"); |
| 657 | 670 |
| 658 SkRect croppedRect = rectToDraw; | 671 SkRect croppedRect = rectToDraw; |
| 659 if (!crop_filled_rect(fRenderTarget.get(), clip, viewMatrix, &croppedRect)) { | 672 if (!crop_filled_rect(fRenderTarget.get(), clip, viewMatrix, &croppedRect)) { |
| 660 return; | 673 return; |
| 661 } | 674 } |
| 662 | 675 |
| 663 AutoCheckFlush acf(fDrawingManager); | 676 AutoCheckFlush acf(fDrawingManager); |
| 664 SkAutoTUnref<GrDrawBatch> batch; | |
| 665 bool useHWAA; | 677 bool useHWAA; |
| 666 | 678 |
| 667 if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) { | 679 if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) { |
| 668 batch.reset(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), lo calMatrix, | 680 SkAutoTUnref<GrDrawBatch> batch(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), |
| 669 paint.isAntiAlias(), fInstancedPipelineInfo, &useHWAA)); | 681 localMatrix, paint.isAnti Alias(), |
| 682 fInstancedPipelineInfo, & useHWAA)); | |
| 670 if (batch) { | 683 if (batch) { |
| 671 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | 684 GrPipelineBuilder pipelineBuilder(paint, useHWAA); |
| 672 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch) ; | 685 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch) ; |
| 673 return; | 686 return; |
| 674 } | 687 } |
| 675 } | 688 } |
| 676 | 689 |
| 677 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) && | 690 if (!should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) { |
| 678 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 691 this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, nullptr, |
| 679 batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, loca lMatrix, | 692 &localMatrix, nullptr); |
| 680 croppedRect)); | 693 return; |
| 694 } | |
| 695 | |
| 696 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | |
| 697 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::Create(paint.getColor (), viewMatrix, | |
| 698 localMatrix, c roppedRect)); | |
| 681 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | 699 GrPipelineBuilder pipelineBuilder(paint, useHWAA); |
| 682 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 700 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
| 683 } else { | 701 return; |
| 684 this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, nullptr, | |
| 685 &localMatrix, nullptr); | |
| 686 } | 702 } |
| 687 | 703 |
| 704 SkMatrix viewAndUnLocalMatrix; | |
| 705 if (!localMatrix.invert(&viewAndUnLocalMatrix)) { | |
| 706 SkFAIL("Bogus local matrix."); // I'm hoping this is illegal and we can just bail? | |
|
csmartdalton
2016/07/26 20:28:28
Is a degenerate local matrix legal?
bsalomon
2016/07/26 20:33:03
I think it's ok to bail.
| |
| 707 return; | |
| 708 } | |
| 709 viewAndUnLocalMatrix.postConcat(viewMatrix); | |
| 710 | |
| 711 SkPath path; | |
| 712 path.setIsVolatile(true); | |
| 713 path.addRect(rectToDraw); | |
| 714 path.transform(localMatrix); | |
| 715 this->internalDrawPath(clip, paint, viewAndUnLocalMatrix, path, GrStyle()); | |
| 688 } | 716 } |
| 689 | 717 |
| 690 void GrDrawContext::drawVertices(const GrClip& clip, | 718 void GrDrawContext::drawVertices(const GrClip& clip, |
| 691 const GrPaint& paint, | 719 const GrPaint& paint, |
| 692 const SkMatrix& viewMatrix, | 720 const SkMatrix& viewMatrix, |
| 693 GrPrimitiveType primitiveType, | 721 GrPrimitiveType primitiveType, |
| 694 int vertexCount, | 722 int vertexCount, |
| 695 const SkPoint positions[], | 723 const SkPoint positions[], |
| 696 const SkPoint texCoords[], | 724 const SkPoint texCoords[], |
| 697 const GrColor colors[], | 725 const GrColor colors[], |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1244 | 1272 |
| 1245 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr Clip& clip, | 1273 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr Clip& clip, |
| 1246 GrDrawBatch* batch) { | 1274 GrDrawBatch* batch) { |
| 1247 ASSERT_SINGLE_OWNER | 1275 ASSERT_SINGLE_OWNER |
| 1248 RETURN_IF_ABANDONED | 1276 RETURN_IF_ABANDONED |
| 1249 SkDEBUGCODE(this->validate();) | 1277 SkDEBUGCODE(this->validate();) |
| 1250 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 1278 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
| 1251 | 1279 |
| 1252 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 1280 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
| 1253 } | 1281 } |
| OLD | NEW |