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 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 | 774 |
775 SkAutoTUnref<GrDrawBatch> batch(new GrDrawAtlasBatch(paint.getColor(), viewM
atrix, spriteCount, | 775 SkAutoTUnref<GrDrawBatch> batch(new GrDrawAtlasBatch(paint.getColor(), viewM
atrix, spriteCount, |
776 xform, texRect, colors)
); | 776 xform, texRect, colors)
); |
777 | 777 |
778 GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint)); | 778 GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint)); |
779 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 779 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
780 } | 780 } |
781 | 781 |
782 /////////////////////////////////////////////////////////////////////////////// | 782 /////////////////////////////////////////////////////////////////////////////// |
783 | 783 |
784 void GrDrawContext::drawRRect(const GrClip& clip, | 784 void GrDrawContext::drawRRect(const GrClip& origClip, |
785 const GrPaint& paint, | 785 const GrPaint& paint, |
786 const SkMatrix& viewMatrix, | 786 const SkMatrix& viewMatrix, |
787 const SkRRect& rrect, | 787 const SkRRect& rrect, |
788 const GrStyle& style) { | 788 const GrStyle& style) { |
789 ASSERT_SINGLE_OWNER | 789 ASSERT_SINGLE_OWNER |
790 RETURN_IF_ABANDONED | 790 RETURN_IF_ABANDONED |
791 SkDEBUGCODE(this->validate();) | 791 SkDEBUGCODE(this->validate();) |
792 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRRect"); | 792 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRRect"); |
793 | |
794 if (rrect.isEmpty()) { | 793 if (rrect.isEmpty()) { |
795 return; | 794 return; |
796 } | 795 } |
797 | 796 |
| 797 GrNoClip noclip; |
| 798 const GrClip* clip = &origClip; |
| 799 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 800 // The Android framework frequently clips rrects to themselves where the cli
p is non-aa and the |
| 801 // draw is aa. Since our lower level clip code works from batch bounds, whic
h are SkRects, it |
| 802 // doesn't detect that the clip can be ignored (modulo antialiasing). The fo
llowing test |
| 803 // attempts to mitigate the stencil clip cost but will only help when the en
tire clip stack |
| 804 // can be ignored. We'd prefer to fix this in the framework by removing the
clips calls. |
| 805 SkRRect devRRect; |
| 806 if (rrect.transform(viewMatrix, &devRRect) && clip->quickContains(devRRect))
{ |
| 807 clip = &noclip; |
| 808 } |
| 809 #endif |
798 SkASSERT(!style.pathEffect()); // this should've been devolved to a path in
SkGpuDevice | 810 SkASSERT(!style.pathEffect()); // this should've been devolved to a path in
SkGpuDevice |
799 | 811 |
800 AutoCheckFlush acf(fDrawingManager); | 812 AutoCheckFlush acf(fDrawingManager); |
801 const SkStrokeRec stroke = style.strokeRec(); | 813 const SkStrokeRec stroke = style.strokeRec(); |
802 bool useHWAA; | 814 bool useHWAA; |
803 | 815 |
804 if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()
&& | 816 if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()
&& |
805 stroke.isFillStyle()) { | 817 stroke.isFillStyle()) { |
806 InstancedRendering* ir = this->getDrawTarget()->instancedRendering(); | 818 InstancedRendering* ir = this->getDrawTarget()->instancedRendering(); |
807 SkAutoTUnref<GrDrawBatch> batch(ir->recordRRect(rrect, viewMatrix, paint
.getColor(), | 819 SkAutoTUnref<GrDrawBatch> batch(ir->recordRRect(rrect, viewMatrix, paint
.getColor(), |
808 paint.isAntiAlias(), fIn
stancedPipelineInfo, | 820 paint.isAntiAlias(), fIn
stancedPipelineInfo, |
809 &useHWAA)); | 821 &useHWAA)); |
810 if (batch) { | 822 if (batch) { |
811 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | 823 GrPipelineBuilder pipelineBuilder(paint, useHWAA); |
812 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch)
; | 824 this->getDrawTarget()->drawBatch(pipelineBuilder, this, *clip, batch
); |
813 return; | 825 return; |
814 } | 826 } |
815 } | 827 } |
816 | 828 |
817 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) { | 829 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) { |
818 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); | 830 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); |
819 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(paint.g
etColor(), | 831 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(paint.g
etColor(), |
820 viewMat
rix, | 832 viewMat
rix, |
821 rrect, | 833 rrect, |
822 stroke, | 834 stroke, |
823 shaderC
aps)); | 835 shaderC
aps)); |
824 if (batch) { | 836 if (batch) { |
825 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | 837 GrPipelineBuilder pipelineBuilder(paint, useHWAA); |
826 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch)
; | 838 this->getDrawTarget()->drawBatch(pipelineBuilder, this, *clip, batch
); |
827 return; | 839 return; |
828 } | 840 } |
829 } | 841 } |
830 | 842 |
831 SkPath path; | 843 SkPath path; |
832 path.setIsVolatile(true); | 844 path.setIsVolatile(true); |
833 path.addRRect(rrect); | 845 path.addRRect(rrect); |
834 this->internalDrawPath(clip, paint, viewMatrix, path, style); | 846 this->internalDrawPath(*clip, paint, viewMatrix, path, style); |
835 } | 847 } |
836 | 848 |
837 bool GrDrawContext::drawFilledDRRect(const GrClip& clip, | 849 bool GrDrawContext::drawFilledDRRect(const GrClip& clip, |
838 const GrPaint& paintIn, | 850 const GrPaint& paintIn, |
839 const SkMatrix& viewMatrix, | 851 const SkMatrix& viewMatrix, |
840 const SkRRect& origOuter, | 852 const SkRRect& origOuter, |
841 const SkRRect& origInner) { | 853 const SkRRect& origInner) { |
842 SkASSERT(!origInner.isEmpty()); | 854 SkASSERT(!origInner.isEmpty()); |
843 SkASSERT(!origOuter.isEmpty()); | 855 SkASSERT(!origOuter.isEmpty()); |
844 | 856 |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 | 1309 |
1298 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr
Clip& clip, | 1310 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr
Clip& clip, |
1299 GrDrawBatch* batch) { | 1311 GrDrawBatch* batch) { |
1300 ASSERT_SINGLE_OWNER | 1312 ASSERT_SINGLE_OWNER |
1301 RETURN_IF_ABANDONED | 1313 RETURN_IF_ABANDONED |
1302 SkDEBUGCODE(this->validate();) | 1314 SkDEBUGCODE(this->validate();) |
1303 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 1315 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
1304 | 1316 |
1305 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 1317 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
1306 } | 1318 } |
OLD | NEW |