| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 if (!viewMatrix.invert(&localMatrix)) { | 232 if (!viewMatrix.invert(&localMatrix)) { |
| 233 SkDebugf("Could not invert matrix\n"); | 233 SkDebugf("Could not invert matrix\n"); |
| 234 return; | 234 return; |
| 235 } | 235 } |
| 236 | 236 |
| 237 AutoCheckFlush acf(fDrawingManager); | 237 AutoCheckFlush acf(fDrawingManager); |
| 238 | 238 |
| 239 SkAutoTUnref<GrDrawBatch> batch( | 239 SkAutoTUnref<GrDrawBatch> batch( |
| 240 GrRectBatchFactory::CreateNonAAFill(paint->getColor(), SkMatrix:
:I(), r, nullptr, | 240 GrRectBatchFactory::CreateNonAAFill(paint->getColor(), SkMatrix:
:I(), r, nullptr, |
| 241 &localMatrix)); | 241 &localMatrix)); |
| 242 GrPipelineBuilder pipelineBuilder(*paint, fRenderTarget.get()); | 242 GrPipelineBuilder pipelineBuilder(*paint, this->isUnifiedMultisampled())
; |
| 243 pipelineBuilder.setRenderTarget(fRenderTarget.get()); |
| 243 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); | 244 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
| 244 } | 245 } |
| 245 } | 246 } |
| 246 | 247 |
| 247 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
int) { | 248 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
int) { |
| 248 return point.fX >= rect.fLeft && point.fX <= rect.fRight && | 249 return point.fX >= rect.fLeft && point.fX <= rect.fRight && |
| 249 point.fY >= rect.fTop && point.fY <= rect.fBottom; | 250 point.fY >= rect.fTop && point.fY <= rect.fBottom; |
| 250 } | 251 } |
| 251 | 252 |
| 252 static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) { | 253 static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix,
rect, | 349 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix,
rect, |
| 349 width, snapToPixel
Centers)); | 350 width, snapToPixel
Centers)); |
| 350 | 351 |
| 351 // Depending on sub-pixel coordinates and the particular GPU, we may
lose a corner of | 352 // Depending on sub-pixel coordinates and the particular GPU, we may
lose a corner of |
| 352 // hairline rects. We jam all the vertices to pixel centers to avoid
this, but not | 353 // hairline rects. We jam all the vertices to pixel centers to avoid
this, but not |
| 353 // when MSAA is enabled because it can cause ugly artifacts. | 354 // when MSAA is enabled because it can cause ugly artifacts. |
| 354 } | 355 } |
| 355 } | 356 } |
| 356 | 357 |
| 357 if (batch) { | 358 if (batch) { |
| 358 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); | 359 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled())
; |
| 360 pipelineBuilder.setRenderTarget(fRenderTarget.get()); |
| 359 | 361 |
| 360 if (snapToPixelCenters) { | 362 if (snapToPixelCenters) { |
| 361 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCent
ers_Flag, | 363 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCent
ers_Flag, |
| 362 snapToPixelCenters); | 364 snapToPixelCenters); |
| 363 } | 365 } |
| 364 | 366 |
| 365 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); | 367 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
| 366 return; | 368 return; |
| 367 } | 369 } |
| 368 | 370 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 385 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil
Rect"); | 387 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil
Rect"); |
| 386 | 388 |
| 387 AutoCheckFlush acf(fDrawContext->fDrawingManager); | 389 AutoCheckFlush acf(fDrawContext->fDrawingManager); |
| 388 | 390 |
| 389 GrPaint paint; | 391 GrPaint paint; |
| 390 paint.setAntiAlias(doAA); | 392 paint.setAntiAlias(doAA); |
| 391 paint.setCoverageSetOpXPFactory(op, invert); | 393 paint.setCoverageSetOpXPFactory(op, invert); |
| 392 | 394 |
| 393 SkAutoTUnref<GrDrawBatch> batch(fDrawContext->getFillRectBatch(paint, viewMa
trix, rect)); | 395 SkAutoTUnref<GrDrawBatch> batch(fDrawContext->getFillRectBatch(paint, viewMa
trix, rect)); |
| 394 if (batch) { | 396 if (batch) { |
| 395 GrPipelineBuilder pipelineBuilder(paint, fDrawContext->accessRenderTarge
t()); | 397 GrPipelineBuilder pipelineBuilder(paint, fDrawContext->isUnifiedMultisam
pled()); |
| 398 pipelineBuilder.setRenderTarget(fDrawContext->accessRenderTarget()); |
| 396 pipelineBuilder.setUserStencil(ss); | 399 pipelineBuilder.setUserStencil(ss); |
| 397 | 400 |
| 398 fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); | 401 fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
| 399 return true; | 402 return true; |
| 400 } | 403 } |
| 401 | 404 |
| 402 SkPath path; | 405 SkPath path; |
| 403 path.setIsVolatile(true); | 406 path.setIsVolatile(true); |
| 404 path.addRect(rect); | 407 path.addRect(rect); |
| 405 return this->drawAndStencilPath(clip, ss, op, invert, doAA, viewMatrix, path
); | 408 return this->drawAndStencilPath(clip, ss, op, invert, doAA, viewMatrix, path
); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 421 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && | 424 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && |
| 422 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 425 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
| 423 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie
wMatrix, rectToDraw, | 426 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie
wMatrix, rectToDraw, |
| 424 localRect)); | 427 localRect)); |
| 425 } else { | 428 } else { |
| 426 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa
trix, rectToDraw, | 429 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa
trix, rectToDraw, |
| 427 &localRect, nullptr)); | 430 &localRect, nullptr)); |
| 428 } | 431 } |
| 429 | 432 |
| 430 if (batch) { | 433 if (batch) { |
| 431 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); | 434 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); |
| 435 pipelineBuilder.setRenderTarget(fRenderTarget.get()); |
| 432 this->drawBatch(&pipelineBuilder, clip, batch); | 436 this->drawBatch(&pipelineBuilder, clip, batch); |
| 433 } | 437 } |
| 434 } | 438 } |
| 435 | 439 |
| 436 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, | 440 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, |
| 437 const GrPaint& paint, | 441 const GrPaint& paint, |
| 438 const SkMatrix& viewMatrix, | 442 const SkMatrix& viewMatrix, |
| 439 const SkRect& rectToDraw, | 443 const SkRect& rectToDraw, |
| 440 const SkMatrix& localMatrix) { | 444 const SkMatrix& localMatrix) { |
| 441 ASSERT_SINGLE_OWNER | 445 ASSERT_SINGLE_OWNER |
| 442 RETURN_IF_ABANDONED | 446 RETURN_IF_ABANDONED |
| 443 SkDEBUGCODE(this->validate();) | 447 SkDEBUGCODE(this->validate();) |
| 444 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectWithLocalMatr
ix"); | 448 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectWithLocalMatr
ix"); |
| 445 | 449 |
| 446 AutoCheckFlush acf(fDrawingManager); | 450 AutoCheckFlush acf(fDrawingManager); |
| 447 | 451 |
| 448 SkAutoTUnref<GrDrawBatch> batch; | 452 SkAutoTUnref<GrDrawBatch> batch; |
| 449 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && | 453 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && |
| 450 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 454 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
| 451 batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, loca
lMatrix, | 455 batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, loca
lMatrix, |
| 452 rectToDraw)); | 456 rectToDraw)); |
| 453 } else { | 457 } else { |
| 454 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa
trix, rectToDraw, | 458 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa
trix, rectToDraw, |
| 455 nullptr, &localMatrix)); | 459 nullptr, &localMatrix)); |
| 456 } | 460 } |
| 457 | 461 |
| 458 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); | 462 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); |
| 463 pipelineBuilder.setRenderTarget(fRenderTarget.get()); |
| 459 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); | 464 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
| 460 } | 465 } |
| 461 | 466 |
| 462 void GrDrawContext::drawVertices(const GrClip& clip, | 467 void GrDrawContext::drawVertices(const GrClip& clip, |
| 463 const GrPaint& paint, | 468 const GrPaint& paint, |
| 464 const SkMatrix& viewMatrix, | 469 const SkMatrix& viewMatrix, |
| 465 GrPrimitiveType primitiveType, | 470 GrPrimitiveType primitiveType, |
| 466 int vertexCount, | 471 int vertexCount, |
| 467 const SkPoint positions[], | 472 const SkPoint positions[], |
| 468 const SkPoint texCoords[], | 473 const SkPoint texCoords[], |
| (...skipping 24 matching lines...) Expand all Loading... |
| 493 bounds.outset(0.5f, 0.5f); | 498 bounds.outset(0.5f, 0.5f); |
| 494 } | 499 } |
| 495 | 500 |
| 496 GrDrawVerticesBatch::Geometry geometry; | 501 GrDrawVerticesBatch::Geometry geometry; |
| 497 geometry.fColor = paint.getColor(); | 502 geometry.fColor = paint.getColor(); |
| 498 SkAutoTUnref<GrDrawBatch> batch(GrDrawVerticesBatch::Create(geometry, primit
iveType, viewMatrix, | 503 SkAutoTUnref<GrDrawBatch> batch(GrDrawVerticesBatch::Create(geometry, primit
iveType, viewMatrix, |
| 499 positions, verte
xCount, indices, | 504 positions, verte
xCount, indices, |
| 500 indexCount, colo
rs, texCoords, | 505 indexCount, colo
rs, texCoords, |
| 501 bounds)); | 506 bounds)); |
| 502 | 507 |
| 503 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); | 508 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); |
| 509 pipelineBuilder.setRenderTarget(fRenderTarget.get()); |
| 504 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); | 510 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
| 505 } | 511 } |
| 506 | 512 |
| 507 /////////////////////////////////////////////////////////////////////////////// | 513 /////////////////////////////////////////////////////////////////////////////// |
| 508 | 514 |
| 509 void GrDrawContext::drawAtlas(const GrClip& clip, | 515 void GrDrawContext::drawAtlas(const GrClip& clip, |
| 510 const GrPaint& paint, | 516 const GrPaint& paint, |
| 511 const SkMatrix& viewMatrix, | 517 const SkMatrix& viewMatrix, |
| 512 int spriteCount, | 518 int spriteCount, |
| 513 const SkRSXform xform[], | 519 const SkRSXform xform[], |
| 514 const SkRect texRect[], | 520 const SkRect texRect[], |
| 515 const SkColor colors[]) { | 521 const SkColor colors[]) { |
| 516 ASSERT_SINGLE_OWNER | 522 ASSERT_SINGLE_OWNER |
| 517 RETURN_IF_ABANDONED | 523 RETURN_IF_ABANDONED |
| 518 SkDEBUGCODE(this->validate();) | 524 SkDEBUGCODE(this->validate();) |
| 519 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawAtlas"); | 525 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawAtlas"); |
| 520 | 526 |
| 521 AutoCheckFlush acf(fDrawingManager); | 527 AutoCheckFlush acf(fDrawingManager); |
| 522 | 528 |
| 523 GrDrawAtlasBatch::Geometry geometry; | 529 GrDrawAtlasBatch::Geometry geometry; |
| 524 geometry.fColor = paint.getColor(); | 530 geometry.fColor = paint.getColor(); |
| 525 SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatri
x, spriteCount, | 531 SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatri
x, spriteCount, |
| 526 xform, texRect, col
ors)); | 532 xform, texRect, col
ors)); |
| 527 | 533 |
| 528 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); | 534 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); |
| 535 pipelineBuilder.setRenderTarget(fRenderTarget.get()); |
| 529 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); | 536 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
| 530 } | 537 } |
| 531 | 538 |
| 532 /////////////////////////////////////////////////////////////////////////////// | 539 /////////////////////////////////////////////////////////////////////////////// |
| 533 | 540 |
| 534 void GrDrawContext::drawRRect(const GrClip& clip, | 541 void GrDrawContext::drawRRect(const GrClip& clip, |
| 535 const GrPaint& paint, | 542 const GrPaint& paint, |
| 536 const SkMatrix& viewMatrix, | 543 const SkMatrix& viewMatrix, |
| 537 const SkRRect& rrect, | 544 const SkRRect& rrect, |
| 538 const GrStyle& style) { | 545 const GrStyle& style) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 551 | 558 |
| 552 if (should_apply_coverage_aa(paint, fRenderTarget.get())) { | 559 if (should_apply_coverage_aa(paint, fRenderTarget.get())) { |
| 553 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); | 560 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); |
| 554 | 561 |
| 555 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(paint.g
etColor(), | 562 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(paint.g
etColor(), |
| 556 viewMat
rix, | 563 viewMat
rix, |
| 557 rrect, | 564 rrect, |
| 558 stroke, | 565 stroke, |
| 559 shaderC
aps)); | 566 shaderC
aps)); |
| 560 if (batch) { | 567 if (batch) { |
| 561 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); | 568 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisample
d()); |
| 569 pipelineBuilder.setRenderTarget(fRenderTarget.get()); |
| 562 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); | 570 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
| 563 return; | 571 return; |
| 564 } | 572 } |
| 565 } | 573 } |
| 566 | 574 |
| 567 SkPath path; | 575 SkPath path; |
| 568 path.setIsVolatile(true); | 576 path.setIsVolatile(true); |
| 569 path.addRRect(rrect); | 577 path.addRRect(rrect); |
| 570 this->internalDrawPath(clip, paint, viewMatrix, path, style); | 578 this->internalDrawPath(clip, paint, viewMatrix, path, style); |
| 571 } | 579 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 AutoCheckFlush acf(fDrawingManager); | 684 AutoCheckFlush acf(fDrawingManager); |
| 677 const SkStrokeRec& stroke = style.strokeRec(); | 685 const SkStrokeRec& stroke = style.strokeRec(); |
| 678 if (should_apply_coverage_aa(paint, fRenderTarget.get())) { | 686 if (should_apply_coverage_aa(paint, fRenderTarget.get())) { |
| 679 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); | 687 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); |
| 680 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.ge
tColor(), | 688 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.ge
tColor(), |
| 681 viewMatr
ix, | 689 viewMatr
ix, |
| 682 oval, | 690 oval, |
| 683 stroke, | 691 stroke, |
| 684 shaderCa
ps)); | 692 shaderCa
ps)); |
| 685 if (batch) { | 693 if (batch) { |
| 686 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); | 694 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisample
d()); |
| 695 pipelineBuilder.setRenderTarget(fRenderTarget.get()); |
| 687 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); | 696 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
| 688 return; | 697 return; |
| 689 } | 698 } |
| 690 } | 699 } |
| 691 | 700 |
| 692 SkPath path; | 701 SkPath path; |
| 693 path.setIsVolatile(true); | 702 path.setIsVolatile(true); |
| 694 path.addOval(oval); | 703 path.addOval(oval); |
| 695 this->internalDrawPath(clip, paint, viewMatrix, path, style); | 704 this->internalDrawPath(clip, paint, viewMatrix, path, style); |
| 696 } | 705 } |
| 697 | 706 |
| 698 void GrDrawContext::drawImageNine(const GrClip& clip, | 707 void GrDrawContext::drawImageNine(const GrClip& clip, |
| 699 const GrPaint& paint, | 708 const GrPaint& paint, |
| 700 const SkMatrix& viewMatrix, | 709 const SkMatrix& viewMatrix, |
| 701 int imageWidth, | 710 int imageWidth, |
| 702 int imageHeight, | 711 int imageHeight, |
| 703 const SkIRect& center, | 712 const SkIRect& center, |
| 704 const SkRect& dst) { | 713 const SkRect& dst) { |
| 705 ASSERT_SINGLE_OWNER | 714 ASSERT_SINGLE_OWNER |
| 706 RETURN_IF_ABANDONED | 715 RETURN_IF_ABANDONED |
| 707 SkDEBUGCODE(this->validate();) | 716 SkDEBUGCODE(this->validate();) |
| 708 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawImageNine"); | 717 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawImageNine"); |
| 709 | 718 |
| 710 AutoCheckFlush acf(fDrawingManager); | 719 AutoCheckFlush acf(fDrawingManager); |
| 711 | 720 |
| 712 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v
iewMatrix, | 721 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v
iewMatrix, |
| 713 imageWidth, imageHe
ight, | 722 imageWidth, imageHe
ight, |
| 714 center, dst)); | 723 center, dst)); |
| 715 | 724 |
| 716 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); | 725 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); |
| 726 pipelineBuilder.setRenderTarget(fRenderTarget.get()); |
| 717 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); | 727 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
| 718 } | 728 } |
| 719 | 729 |
| 720 | 730 |
| 721 // Can 'path' be drawn as a pair of filled nested rectangles? | 731 // Can 'path' be drawn as a pair of filled nested rectangles? |
| 722 static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path
, SkRect rects[2]) { | 732 static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path
, SkRect rects[2]) { |
| 723 | 733 |
| 724 if (path.isInverseFillType()) { | 734 if (path.isInverseFillType()) { |
| 725 return false; | 735 return false; |
| 726 } | 736 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 | 776 |
| 767 void GrDrawContext::drawBatch(const GrClip& clip, | 777 void GrDrawContext::drawBatch(const GrClip& clip, |
| 768 const GrPaint& paint, GrDrawBatch* batch) { | 778 const GrPaint& paint, GrDrawBatch* batch) { |
| 769 ASSERT_SINGLE_OWNER | 779 ASSERT_SINGLE_OWNER |
| 770 RETURN_IF_ABANDONED | 780 RETURN_IF_ABANDONED |
| 771 SkDEBUGCODE(this->validate();) | 781 SkDEBUGCODE(this->validate();) |
| 772 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 782 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
| 773 | 783 |
| 774 AutoCheckFlush acf(fDrawingManager); | 784 AutoCheckFlush acf(fDrawingManager); |
| 775 | 785 |
| 776 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); | 786 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); |
| 787 pipelineBuilder.setRenderTarget(fRenderTarget.get()); |
| 777 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); | 788 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
| 778 } | 789 } |
| 779 | 790 |
| 780 void GrDrawContext::drawPath(const GrClip& clip, | 791 void GrDrawContext::drawPath(const GrClip& clip, |
| 781 const GrPaint& paint, | 792 const GrPaint& paint, |
| 782 const SkMatrix& viewMatrix, | 793 const SkMatrix& viewMatrix, |
| 783 const SkPath& path, | 794 const SkPath& path, |
| 784 const GrStyle& style) { | 795 const GrStyle& style) { |
| 785 ASSERT_SINGLE_OWNER | 796 ASSERT_SINGLE_OWNER |
| 786 RETURN_IF_ABANDONED | 797 RETURN_IF_ABANDONED |
| (...skipping 11 matching lines...) Expand all Loading... |
| 798 | 809 |
| 799 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && !style.pathEffec
t()) { | 810 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && !style.pathEffec
t()) { |
| 800 if (style.isSimpleFill() && !path.isConvex()) { | 811 if (style.isSimpleFill() && !path.isConvex()) { |
| 801 // Concave AA paths are expensive - try to avoid them for special ca
ses | 812 // Concave AA paths are expensive - try to avoid them for special ca
ses |
| 802 SkRect rects[2]; | 813 SkRect rects[2]; |
| 803 | 814 |
| 804 if (fills_as_nested_rects(viewMatrix, path, rects)) { | 815 if (fills_as_nested_rects(viewMatrix, path, rects)) { |
| 805 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill
NestedRects( | 816 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill
NestedRects( |
| 806 paint.getColor(), viewMatrix, rects)); | 817 paint.getColor(), viewMatrix, rects)); |
| 807 if (batch) { | 818 if (batch) { |
| 808 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()
); | 819 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMul
tisampled()); |
| 820 pipelineBuilder.setRenderTarget(fRenderTarget.get()); |
| 809 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batc
h); | 821 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batc
h); |
| 810 } | 822 } |
| 811 return; | 823 return; |
| 812 } | 824 } |
| 813 } | 825 } |
| 814 SkRect ovalRect; | 826 SkRect ovalRect; |
| 815 bool isOval = path.isOval(&ovalRect); | 827 bool isOval = path.isOval(&ovalRect); |
| 816 | 828 |
| 817 if (isOval && !path.isInverseFillType()) { | 829 if (isOval && !path.isInverseFillType()) { |
| 818 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); | 830 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); |
| 819 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(pain
t.getColor(), | 831 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(pain
t.getColor(), |
| 820 view
Matrix, | 832 view
Matrix, |
| 821 oval
Rect, | 833 oval
Rect, |
| 822 styl
e.strokeRec(), | 834 styl
e.strokeRec(), |
| 823 shad
erCaps)); | 835 shad
erCaps)); |
| 824 if (batch) { | 836 if (batch) { |
| 825 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); | 837 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisa
mpled()); |
| 838 pipelineBuilder.setRenderTarget(fRenderTarget.get()); |
| 826 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); | 839 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
| 827 return; | 840 return; |
| 828 } | 841 } |
| 829 } | 842 } |
| 830 } | 843 } |
| 831 | 844 |
| 832 // Note that internalDrawPath may sw-rasterize the path into a scratch textu
re. | 845 // Note that internalDrawPath may sw-rasterize the path into a scratch textu
re. |
| 833 // Scratch textures can be recycled after they are returned to the texture | 846 // Scratch textures can be recycled after they are returned to the texture |
| 834 // cache. This presents a potential hazard for buffered drawing. However, | 847 // cache. This presents a potential hazard for buffered drawing. However, |
| 835 // the writePixels that uploads to the scratch will perform a flush so we're | 848 // the writePixels that uploads to the scratch will perform a flush so we're |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 | 894 |
| 882 // Don't allow the SW renderer | 895 // Don't allow the SW renderer |
| 883 GrPathRenderer* pr = fDrawContext->fDrawingManager->getPathRenderer(canDrawA
rgs, false, type); | 896 GrPathRenderer* pr = fDrawContext->fDrawingManager->getPathRenderer(canDrawA
rgs, false, type); |
| 884 if (!pr) { | 897 if (!pr) { |
| 885 return false; | 898 return false; |
| 886 } | 899 } |
| 887 | 900 |
| 888 GrPaint paint; | 901 GrPaint paint; |
| 889 paint.setCoverageSetOpXPFactory(op, invert); | 902 paint.setCoverageSetOpXPFactory(op, invert); |
| 890 | 903 |
| 891 GrPipelineBuilder pipelineBuilder(paint, fDrawContext->accessRenderTarget())
; | 904 GrPipelineBuilder pipelineBuilder(paint, fDrawContext->isUnifiedMultisample
d()); |
| 905 pipelineBuilder.setRenderTarget(fDrawContext->accessRenderTarget()); |
| 892 pipelineBuilder.setUserStencil(ss); | 906 pipelineBuilder.setUserStencil(ss); |
| 893 | 907 |
| 894 GrPathRenderer::DrawPathArgs args; | 908 GrPathRenderer::DrawPathArgs args; |
| 895 args.fTarget = fDrawContext->getDrawTarget(); | 909 args.fTarget = fDrawContext->getDrawTarget(); |
| 896 args.fResourceProvider = fDrawContext->fDrawingManager->getContext()->resour
ceProvider(); | 910 args.fResourceProvider = fDrawContext->fDrawingManager->getContext()->resour
ceProvider(); |
| 897 args.fPipelineBuilder = &pipelineBuilder; | 911 args.fPipelineBuilder = &pipelineBuilder; |
| 898 args.fClip = &clip; | 912 args.fClip = &clip; |
| 899 args.fColor = GrColor_WHITE; | 913 args.fColor = GrColor_WHITE; |
| 900 args.fViewMatrix = &viewMatrix; | 914 args.fViewMatrix = &viewMatrix; |
| 901 args.fPath = &path; | 915 args.fPath = &path; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 pr = fDrawingManager->getPathRenderer(canDrawArgs, true, type); | 1001 pr = fDrawingManager->getPathRenderer(canDrawArgs, true, type); |
| 988 } | 1002 } |
| 989 | 1003 |
| 990 if (nullptr == pr) { | 1004 if (nullptr == pr) { |
| 991 #ifdef SK_DEBUG | 1005 #ifdef SK_DEBUG |
| 992 SkDebugf("Unable to find path renderer compatible with path.\n"); | 1006 SkDebugf("Unable to find path renderer compatible with path.\n"); |
| 993 #endif | 1007 #endif |
| 994 return; | 1008 return; |
| 995 } | 1009 } |
| 996 | 1010 |
| 997 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); | 1011 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); |
| 1012 pipelineBuilder.setRenderTarget(fRenderTarget.get()); |
| 998 | 1013 |
| 999 GrPathRenderer::DrawPathArgs args; | 1014 GrPathRenderer::DrawPathArgs args; |
| 1000 args.fTarget = this->getDrawTarget(); | 1015 args.fTarget = this->getDrawTarget(); |
| 1001 args.fResourceProvider = fDrawingManager->getContext()->resourceProvider(); | 1016 args.fResourceProvider = fDrawingManager->getContext()->resourceProvider(); |
| 1002 args.fPipelineBuilder = &pipelineBuilder; | 1017 args.fPipelineBuilder = &pipelineBuilder; |
| 1003 args.fClip = &clip; | 1018 args.fClip = &clip; |
| 1004 args.fColor = paint.getColor(); | 1019 args.fColor = paint.getColor(); |
| 1005 args.fViewMatrix = &viewMatrix; | 1020 args.fViewMatrix = &viewMatrix; |
| 1006 args.fPath = canDrawArgs.fPath; | 1021 args.fPath = canDrawArgs.fPath; |
| 1007 args.fStyle = canDrawArgs.fStyle; | 1022 args.fStyle = canDrawArgs.fStyle; |
| 1008 args.fAntiAlias = useCoverageAA; | 1023 args.fAntiAlias = useCoverageAA; |
| 1009 args.fGammaCorrect = this->isGammaCorrect(); | 1024 args.fGammaCorrect = this->isGammaCorrect(); |
| 1010 pr->drawPath(args); | 1025 pr->drawPath(args); |
| 1011 } | 1026 } |
| 1012 | 1027 |
| 1013 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, const GrClip&
clip, | 1028 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, const GrClip&
clip, |
| 1014 GrDrawBatch* batch) { | 1029 GrDrawBatch* batch) { |
| 1015 ASSERT_SINGLE_OWNER | 1030 ASSERT_SINGLE_OWNER |
| 1016 RETURN_IF_ABANDONED | 1031 RETURN_IF_ABANDONED |
| 1017 SkDEBUGCODE(this->validate();) | 1032 SkDEBUGCODE(this->validate();) |
| 1018 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 1033 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
| 1019 | 1034 |
| 1020 this->getDrawTarget()->drawBatch(*pipelineBuilder, clip, batch); | 1035 this->getDrawTarget()->drawBatch(*pipelineBuilder, clip, batch); |
| 1021 } | 1036 } |
| OLD | NEW |