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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 290 |
291 static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt, | 291 static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt, |
292 bool* useHWAA = nullptr) { | 292 bool* useHWAA = nullptr) { |
293 if (!paint.isAntiAlias()) { | 293 if (!paint.isAntiAlias()) { |
294 if (useHWAA) { | 294 if (useHWAA) { |
295 *useHWAA = false; | 295 *useHWAA = false; |
296 } | 296 } |
297 return false; | 297 return false; |
298 } else { | 298 } else { |
299 if (useHWAA) { | 299 if (useHWAA) { |
300 *useHWAA = rt->isUnifiedMultisampled() || rt->hasMixedSamples(); | 300 *useHWAA = rt->isUnifiedMultisampled(); |
301 } | 301 } |
302 return !rt->isUnifiedMultisampled() && !rt->hasMixedSamples(); | 302 return !rt->isUnifiedMultisampled(); |
303 } | 303 } |
304 } | 304 } |
305 | 305 |
306 // Attempts to crop a rect and optional local rect to the clip boundaries. | 306 // Attempts to crop a rect and optional local rect to the clip boundaries. |
307 // Returns false if the draw can be skipped entirely. | 307 // Returns false if the draw can be skipped entirely. |
308 static bool crop_filled_rect(const GrRenderTarget* rt, const GrClip& clip, | 308 static bool crop_filled_rect(const GrRenderTarget* rt, const GrClip& clip, |
309 const SkMatrix& viewMatrix, SkRect* rect, | 309 const SkMatrix& viewMatrix, SkRect* rect, |
310 SkRect* localRect = nullptr) { | 310 SkRect* localRect = nullptr) { |
311 if (!viewMatrix.rectStaysRect()) { | 311 if (!viewMatrix.rectStaysRect()) { |
312 return true; | 312 return true; |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 } | 614 } |
615 | 615 |
616 AutoCheckFlush acf(fDrawingManager); | 616 AutoCheckFlush acf(fDrawingManager); |
617 SkAutoTUnref<GrDrawBatch> batch; | 617 SkAutoTUnref<GrDrawBatch> batch; |
618 bool useHWAA; | 618 bool useHWAA; |
619 | 619 |
620 if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) { | 620 if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) { |
621 batch.reset(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), cr
oppedLocalRect, | 621 batch.reset(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), cr
oppedLocalRect, |
622 paint.isAntiAlias(), fInstancedPipelineInfo,
&useHWAA)); | 622 paint.isAntiAlias(), fInstancedPipelineInfo,
&useHWAA)); |
623 if (batch) { | 623 if (batch) { |
624 SkASSERT(useHWAA == this->mustUseHWAA(paint)); | 624 GrPipelineBuilder pipelineBuilder(paint, useHWAA); |
625 this->drawBatch(paint, clip, GrUserStencilSettings::kUnused, batch); | 625 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch)
; |
626 return; | 626 return; |
627 } | 627 } |
628 } | 628 } |
629 | 629 |
630 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) && | 630 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) && |
631 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 631 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
632 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie
wMatrix, | 632 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie
wMatrix, |
633 croppedRect, croppedL
ocalRect)); | 633 croppedRect, croppedL
ocalRect)); |
634 if (batch) { | 634 if (batch) { |
635 SkASSERT(useHWAA == this->mustUseHWAA(paint)); | 635 GrPipelineBuilder pipelineBuilder(paint, useHWAA); |
636 this->drawBatch(paint, clip, GrUserStencilSettings::kUnused, batch); | 636 this->drawBatch(pipelineBuilder, clip, batch); |
| 637 return; |
637 } | 638 } |
638 } else { | 639 } else { |
639 this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, &cropped
LocalRect, | 640 this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, &cropped
LocalRect, |
640 nullptr, nullptr); | 641 nullptr, nullptr); |
641 } | 642 } |
| 643 |
642 } | 644 } |
643 | 645 |
644 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, | 646 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, |
645 const GrPaint& paint, | 647 const GrPaint& paint, |
646 const SkMatrix& viewMatrix, | 648 const SkMatrix& viewMatrix, |
647 const SkRect& rectToDraw, | 649 const SkRect& rectToDraw, |
648 const SkMatrix& localMatrix) { | 650 const SkMatrix& localMatrix) { |
649 ASSERT_SINGLE_OWNER | 651 ASSERT_SINGLE_OWNER |
650 RETURN_IF_ABANDONED | 652 RETURN_IF_ABANDONED |
651 SkDEBUGCODE(this->validate();) | 653 SkDEBUGCODE(this->validate();) |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 args.fUserStencilSettings = &GrUserStencilSettings::kUnused; | 1233 args.fUserStencilSettings = &GrUserStencilSettings::kUnused; |
1232 args.fDrawContext = this; | 1234 args.fDrawContext = this; |
1233 args.fClip = &clip; | 1235 args.fClip = &clip; |
1234 args.fViewMatrix = &viewMatrix; | 1236 args.fViewMatrix = &viewMatrix; |
1235 args.fShape = canDrawArgs.fShape; | 1237 args.fShape = canDrawArgs.fShape; |
1236 args.fAntiAlias = useCoverageAA; | 1238 args.fAntiAlias = useCoverageAA; |
1237 args.fGammaCorrect = this->isGammaCorrect(); | 1239 args.fGammaCorrect = this->isGammaCorrect(); |
1238 pr->drawPath(args); | 1240 pr->drawPath(args); |
1239 } | 1241 } |
1240 | 1242 |
1241 void GrDrawContext::drawBatch(const GrPaint& paint, | 1243 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr
Clip& clip, |
1242 const GrClip& clip, | 1244 GrDrawBatch* batch) { |
1243 const GrUserStencilSettings& userStencilSettings, | |
1244 GrDrawBatch* batch, | |
1245 GrDrawFace drawFace) { | |
1246 ASSERT_SINGLE_OWNER | 1245 ASSERT_SINGLE_OWNER |
1247 RETURN_IF_ABANDONED | 1246 RETURN_IF_ABANDONED |
1248 SkDEBUGCODE(this->validate();) | 1247 SkDEBUGCODE(this->validate();) |
1249 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 1248 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
1250 | 1249 |
1251 GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint)); | |
1252 pipelineBuilder.setUserStencil(&userStencilSettings); | |
1253 pipelineBuilder.setDrawFace(drawFace); | |
1254 | |
1255 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 1250 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
1256 } | 1251 } |
OLD | NEW |