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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 this->drawRect(clip, *paint, viewMatrix, r); | 270 this->drawRect(clip, *paint, viewMatrix, r); |
271 } else { | 271 } else { |
272 SkMatrix localMatrix; | 272 SkMatrix localMatrix; |
273 if (!viewMatrix.invert(&localMatrix)) { | 273 if (!viewMatrix.invert(&localMatrix)) { |
274 SkDebugf("Could not invert matrix\n"); | 274 SkDebugf("Could not invert matrix\n"); |
275 return; | 275 return; |
276 } | 276 } |
277 | 277 |
278 AutoCheckFlush acf(fDrawingManager); | 278 AutoCheckFlush acf(fDrawingManager); |
279 | 279 |
280 this->drawNonAAFilledRect(clip, *paint, SkMatrix::I(), r, nullptr, &loca
lMatrix, nullptr); | 280 this->drawNonAAFilledRect(clip, *paint, SkMatrix::I(), r, nullptr, &loca
lMatrix, nullptr, |
| 281 false /* useHWAA */); |
281 } | 282 } |
282 } | 283 } |
283 | 284 |
284 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
int) { | 285 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
int) { |
285 return point.fX >= rect.fLeft && point.fX <= rect.fRight && | 286 return point.fX >= rect.fLeft && point.fX <= rect.fRight && |
286 point.fY >= rect.fTop && point.fY <= rect.fBottom; | 287 point.fY >= rect.fTop && point.fY <= rect.fBottom; |
287 } | 288 } |
288 | 289 |
289 static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) { | 290 static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) { |
290 return viewMatrix.preservesRightAngles(); | 291 return viewMatrix.preservesRightAngles(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 if (batch) { | 393 if (batch) { |
393 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | 394 GrPipelineBuilder pipelineBuilder(paint, useHWAA); |
394 if (ss) { | 395 if (ss) { |
395 pipelineBuilder.setUserStencil(ss); | 396 pipelineBuilder.setUserStencil(ss); |
396 } | 397 } |
397 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, ba
tch); | 398 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, ba
tch); |
398 return true; | 399 return true; |
399 } | 400 } |
400 } | 401 } |
401 } else { | 402 } else { |
402 this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, nullptr,
nullptr, ss); | 403 this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, nullptr,
nullptr, ss, |
| 404 useHWAA); |
403 return true; | 405 return true; |
404 } | 406 } |
405 | 407 |
406 return false; | 408 return false; |
407 } | 409 } |
408 | 410 |
409 void GrDrawContext::drawRect(const GrClip& clip, | 411 void GrDrawContext::drawRect(const GrClip& clip, |
410 const GrPaint& paint, | 412 const GrPaint& paint, |
411 const SkMatrix& viewMatrix, | 413 const SkMatrix& viewMatrix, |
412 const SkRect& rect, | 414 const SkRect& rect, |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 RETURN_IF_ABANDONED_PRIV | 561 RETURN_IF_ABANDONED_PRIV |
560 SkDEBUGCODE(fDrawContext->validate();) | 562 SkDEBUGCODE(fDrawContext->validate();) |
561 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil
Rect"); | 563 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil
Rect"); |
562 | 564 |
563 AutoCheckFlush acf(fDrawContext->fDrawingManager); | 565 AutoCheckFlush acf(fDrawContext->fDrawingManager); |
564 | 566 |
565 GrPaint paint; | 567 GrPaint paint; |
566 paint.setAntiAlias(useHWAA); | 568 paint.setAntiAlias(useHWAA); |
567 paint.setXPFactory(GrDisableColorXPFactory::Make()); | 569 paint.setXPFactory(GrDisableColorXPFactory::Make()); |
568 | 570 |
569 SkASSERT(!useHWAA || fDrawContext->isStencilBufferMultisampled()); | 571 fDrawContext->drawNonAAFilledRect(clip, paint, viewMatrix, rect, nullptr, nu
llptr, ss, useHWAA); |
570 | |
571 fDrawContext->drawFilledRect(clip, paint, viewMatrix, rect, ss); | |
572 } | 572 } |
573 | 573 |
574 bool GrDrawContextPriv::drawAndStencilRect(const GrFixedClip& clip, | 574 bool GrDrawContextPriv::drawAndStencilRect(const GrFixedClip& clip, |
575 const GrUserStencilSettings* ss, | 575 const GrUserStencilSettings* ss, |
576 SkRegion::Op op, | 576 SkRegion::Op op, |
577 bool invert, | 577 bool invert, |
578 bool doAA, | 578 bool doAA, |
579 const SkMatrix& viewMatrix, | 579 const SkMatrix& viewMatrix, |
580 const SkRect& rect) { | 580 const SkRect& rect) { |
581 ASSERT_SINGLE_OWNER_PRIV | 581 ASSERT_SINGLE_OWNER_PRIV |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 fInstancedPipelineInfo, &
useHWAA)); | 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 this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, &cropped
LocalRect, | 633 this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, &cropped
LocalRect, |
634 nullptr, nullptr); | 634 nullptr, nullptr, useHWAA); |
635 return; | 635 return; |
636 } | 636 } |
637 | 637 |
638 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 638 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
639 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::CreateWithLocalRect(p
aint.getColor(), | 639 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::CreateWithLocalRect(p
aint.getColor(), |
640 v
iewMatrix, | 640 v
iewMatrix, |
641 c
roppedRect, | 641 c
roppedRect, |
642 c
roppedLocalRect)); | 642 c
roppedLocalRect)); |
643 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | 643 GrPipelineBuilder pipelineBuilder(paint, useHWAA); |
644 this->drawBatch(pipelineBuilder, clip, batch); | 644 this->drawBatch(pipelineBuilder, clip, batch); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 fInstancedPipelineInfo, &
useHWAA)); | 682 fInstancedPipelineInfo, &
useHWAA)); |
683 if (batch) { | 683 if (batch) { |
684 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | 684 GrPipelineBuilder pipelineBuilder(paint, useHWAA); |
685 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch)
; | 685 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch)
; |
686 return; | 686 return; |
687 } | 687 } |
688 } | 688 } |
689 | 689 |
690 if (!should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) { | 690 if (!should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) { |
691 this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, nullptr, | 691 this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, nullptr, |
692 &localMatrix, nullptr); | 692 &localMatrix, nullptr, useHWAA); |
693 return; | 693 return; |
694 } | 694 } |
695 | 695 |
696 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 696 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
697 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::Create(paint.getColor
(), viewMatrix, | 697 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::Create(paint.getColor
(), viewMatrix, |
698 localMatrix, c
roppedRect)); | 698 localMatrix, c
roppedRect)); |
699 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | 699 GrPipelineBuilder pipelineBuilder(paint, useHWAA); |
700 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 700 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
701 return; | 701 return; |
702 } | 702 } |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 | 1018 |
1019 fDrawingManager->getContext()->prepareSurfaceForExternalIO(fRenderTarget.get
()); | 1019 fDrawingManager->getContext()->prepareSurfaceForExternalIO(fRenderTarget.get
()); |
1020 } | 1020 } |
1021 | 1021 |
1022 void GrDrawContext::drawNonAAFilledRect(const GrClip& clip, | 1022 void GrDrawContext::drawNonAAFilledRect(const GrClip& clip, |
1023 const GrPaint& paint, | 1023 const GrPaint& paint, |
1024 const SkMatrix& viewMatrix, | 1024 const SkMatrix& viewMatrix, |
1025 const SkRect& rect, | 1025 const SkRect& rect, |
1026 const SkRect* localRect, | 1026 const SkRect* localRect, |
1027 const SkMatrix* localMatrix, | 1027 const SkMatrix* localMatrix, |
1028 const GrUserStencilSettings* ss) { | 1028 const GrUserStencilSettings* ss, |
| 1029 bool useHWAA) { |
| 1030 SkASSERT(!useHWAA || this->isStencilBufferMultisampled()); |
1029 SkAutoTUnref<GrDrawBatch> batch( | 1031 SkAutoTUnref<GrDrawBatch> batch( |
1030 GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, re
ct, localRect, | 1032 GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, re
ct, localRect, |
1031 localMatrix)); | 1033 localMatrix)); |
1032 GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint)); | 1034 GrPipelineBuilder pipelineBuilder(paint, useHWAA); |
1033 if (ss) { | 1035 if (ss) { |
1034 pipelineBuilder.setUserStencil(ss); | 1036 pipelineBuilder.setUserStencil(ss); |
1035 } | 1037 } |
1036 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 1038 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
1037 } | 1039 } |
1038 | 1040 |
1039 // Can 'path' be drawn as a pair of filled nested rectangles? | 1041 // Can 'path' be drawn as a pair of filled nested rectangles? |
1040 static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path
, SkRect rects[2]) { | 1042 static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path
, SkRect rects[2]) { |
1041 | 1043 |
1042 if (path.isInverseFillType()) { | 1044 if (path.isInverseFillType()) { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 | 1284 |
1283 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr
Clip& clip, | 1285 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr
Clip& clip, |
1284 GrDrawBatch* batch) { | 1286 GrDrawBatch* batch) { |
1285 ASSERT_SINGLE_OWNER | 1287 ASSERT_SINGLE_OWNER |
1286 RETURN_IF_ABANDONED | 1288 RETURN_IF_ABANDONED |
1287 SkDEBUGCODE(this->validate();) | 1289 SkDEBUGCODE(this->validate();) |
1288 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 1290 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
1289 | 1291 |
1290 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 1292 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
1291 } | 1293 } |
OLD | NEW |