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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 SkDebugf("Could not invert matrix\n"); | 234 SkDebugf("Could not invert matrix\n"); |
235 return; | 235 return; |
236 } | 236 } |
237 | 237 |
238 AutoCheckFlush acf(fDrawingManager); | 238 AutoCheckFlush acf(fDrawingManager); |
239 | 239 |
240 SkAutoTUnref<GrDrawBatch> batch( | 240 SkAutoTUnref<GrDrawBatch> batch( |
241 GrRectBatchFactory::CreateNonAAFill(paint->getColor(), SkMatrix:
:I(), r, nullptr, | 241 GrRectBatchFactory::CreateNonAAFill(paint->getColor(), SkMatrix:
:I(), r, nullptr, |
242 &localMatrix)); | 242 &localMatrix)); |
243 GrPipelineBuilder pipelineBuilder(*paint, this->isUnifiedMultisampled())
; | 243 GrPipelineBuilder pipelineBuilder(*paint, this->isUnifiedMultisampled())
; |
244 pipelineBuilder.setRenderTarget(fRenderTarget.get()); | |
245 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 244 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
246 } | 245 } |
247 } | 246 } |
248 | 247 |
249 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) { |
250 return point.fX >= rect.fLeft && point.fX <= rect.fRight && | 249 return point.fX >= rect.fLeft && point.fX <= rect.fRight && |
251 point.fY >= rect.fTop && point.fY <= rect.fBottom; | 250 point.fY >= rect.fTop && point.fY <= rect.fBottom; |
252 } | 251 } |
253 | 252 |
254 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... |
350 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix,
rect, | 349 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix,
rect, |
351 width, snapToPixel
Centers)); | 350 width, snapToPixel
Centers)); |
352 | 351 |
353 // 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 |
354 // 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 |
355 // when MSAA is enabled because it can cause ugly artifacts. | 354 // when MSAA is enabled because it can cause ugly artifacts. |
356 } | 355 } |
357 } | 356 } |
358 | 357 |
359 if (batch) { | 358 if (batch) { |
360 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled())
; | 359 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); |
361 pipelineBuilder.setRenderTarget(fRenderTarget.get()); | |
362 | 360 |
363 if (snapToPixelCenters) { | 361 if (snapToPixelCenters) { |
364 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCent
ers_Flag, | 362 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCent
ers_Flag, |
365 snapToPixelCenters); | 363 snapToPixelCenters); |
366 } | 364 } |
367 | 365 |
368 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 366 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
369 return; | 367 return; |
370 } | 368 } |
371 | 369 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 AutoCheckFlush acf(fDrawContext->fDrawingManager); | 406 AutoCheckFlush acf(fDrawContext->fDrawingManager); |
409 | 407 |
410 GrPaint paint; | 408 GrPaint paint; |
411 paint.setAntiAlias(doAA); | 409 paint.setAntiAlias(doAA); |
412 SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create())); | 410 SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create())); |
413 | 411 |
414 SkAutoTUnref<GrDrawBatch> batch(fDrawContext->getFillRectBatch(paint, viewMa
trix, rect)); | 412 SkAutoTUnref<GrDrawBatch> batch(fDrawContext->getFillRectBatch(paint, viewMa
trix, rect)); |
415 SkASSERT(batch); | 413 SkASSERT(batch); |
416 | 414 |
417 GrPipelineBuilder pipelineBuilder(paint, fDrawContext->isUnifiedMultisampled
()); | 415 GrPipelineBuilder pipelineBuilder(paint, fDrawContext->isUnifiedMultisampled
()); |
418 pipelineBuilder.setRenderTarget(fDrawContext->accessRenderTarget()); | |
419 pipelineBuilder.setUserStencil(ss); | 416 pipelineBuilder.setUserStencil(ss); |
420 | 417 |
421 fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, fDrawContext, clip
, batch); | 418 fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, fDrawContext, clip
, batch); |
422 } | 419 } |
423 | 420 |
424 bool GrDrawContextPriv::drawAndStencilRect(const GrFixedClip& clip, | 421 bool GrDrawContextPriv::drawAndStencilRect(const GrFixedClip& clip, |
425 const GrUserStencilSettings* ss, | 422 const GrUserStencilSettings* ss, |
426 SkRegion::Op op, | 423 SkRegion::Op op, |
427 bool invert, | 424 bool invert, |
428 bool doAA, | 425 bool doAA, |
429 const SkMatrix& viewMatrix, | 426 const SkMatrix& viewMatrix, |
430 const SkRect& rect) { | 427 const SkRect& rect) { |
431 ASSERT_SINGLE_OWNER_PRIV | 428 ASSERT_SINGLE_OWNER_PRIV |
432 RETURN_FALSE_IF_ABANDONED_PRIV | 429 RETURN_FALSE_IF_ABANDONED_PRIV |
433 SkDEBUGCODE(fDrawContext->validate();) | 430 SkDEBUGCODE(fDrawContext->validate();) |
434 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil
Rect"); | 431 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawAnd
StencilRect"); |
435 | 432 |
436 AutoCheckFlush acf(fDrawContext->fDrawingManager); | 433 AutoCheckFlush acf(fDrawContext->fDrawingManager); |
437 | 434 |
438 GrPaint paint; | 435 GrPaint paint; |
439 paint.setAntiAlias(doAA); | 436 paint.setAntiAlias(doAA); |
440 paint.setCoverageSetOpXPFactory(op, invert); | 437 paint.setCoverageSetOpXPFactory(op, invert); |
441 | 438 |
442 SkAutoTUnref<GrDrawBatch> batch(fDrawContext->getFillRectBatch(paint, viewMa
trix, rect)); | 439 SkAutoTUnref<GrDrawBatch> batch(fDrawContext->getFillRectBatch(paint, viewMa
trix, rect)); |
443 if (batch) { | 440 if (batch) { |
444 GrPipelineBuilder pipelineBuilder(paint, fDrawContext->isUnifiedMultisam
pled()); | 441 GrPipelineBuilder pipelineBuilder(paint, fDrawContext->isUnifiedMultisam
pled()); |
445 pipelineBuilder.setRenderTarget(fDrawContext->accessRenderTarget()); | |
446 pipelineBuilder.setUserStencil(ss); | 442 pipelineBuilder.setUserStencil(ss); |
447 | 443 |
448 fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, fDrawContext,
clip, batch); | 444 fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, fDrawContext,
clip, batch); |
449 return true; | 445 return true; |
450 } | 446 } |
451 | 447 |
452 SkPath path; | 448 SkPath path; |
453 path.setIsVolatile(true); | 449 path.setIsVolatile(true); |
454 path.addRect(rect); | 450 path.addRect(rect); |
455 return this->drawAndStencilPath(clip, ss, op, invert, doAA, viewMatrix, path
); | 451 return this->drawAndStencilPath(clip, ss, op, invert, doAA, viewMatrix, path
); |
(...skipping 16 matching lines...) Expand all Loading... |
472 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 468 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
473 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie
wMatrix, rectToDraw, | 469 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie
wMatrix, rectToDraw, |
474 localRect)); | 470 localRect)); |
475 } else { | 471 } else { |
476 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa
trix, rectToDraw, | 472 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa
trix, rectToDraw, |
477 &localRect, nullptr)); | 473 &localRect, nullptr)); |
478 } | 474 } |
479 | 475 |
480 if (batch) { | 476 if (batch) { |
481 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); | 477 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); |
482 pipelineBuilder.setRenderTarget(fRenderTarget.get()); | |
483 this->drawBatch(pipelineBuilder, clip, batch); | 478 this->drawBatch(pipelineBuilder, clip, batch); |
484 } | 479 } |
485 } | 480 } |
486 | 481 |
487 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, | 482 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, |
488 const GrPaint& paint, | 483 const GrPaint& paint, |
489 const SkMatrix& viewMatrix, | 484 const SkMatrix& viewMatrix, |
490 const SkRect& rectToDraw, | 485 const SkRect& rectToDraw, |
491 const SkMatrix& localMatrix) { | 486 const SkMatrix& localMatrix) { |
492 ASSERT_SINGLE_OWNER | 487 ASSERT_SINGLE_OWNER |
493 RETURN_IF_ABANDONED | 488 RETURN_IF_ABANDONED |
494 SkDEBUGCODE(this->validate();) | 489 SkDEBUGCODE(this->validate();) |
495 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectWithLocalMatr
ix"); | 490 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectWithLocalMatr
ix"); |
496 | 491 |
497 AutoCheckFlush acf(fDrawingManager); | 492 AutoCheckFlush acf(fDrawingManager); |
498 | 493 |
499 SkAutoTUnref<GrDrawBatch> batch; | 494 SkAutoTUnref<GrDrawBatch> batch; |
500 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && | 495 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && |
501 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 496 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
502 batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, loca
lMatrix, | 497 batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, loca
lMatrix, |
503 rectToDraw)); | 498 rectToDraw)); |
504 } else { | 499 } else { |
505 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa
trix, rectToDraw, | 500 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa
trix, rectToDraw, |
506 nullptr, &localMatrix)); | 501 nullptr, &localMatrix)); |
507 } | 502 } |
508 | 503 |
509 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); | 504 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); |
510 pipelineBuilder.setRenderTarget(fRenderTarget.get()); | |
511 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 505 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
512 } | 506 } |
513 | 507 |
514 void GrDrawContext::drawVertices(const GrClip& clip, | 508 void GrDrawContext::drawVertices(const GrClip& clip, |
515 const GrPaint& paint, | 509 const GrPaint& paint, |
516 const SkMatrix& viewMatrix, | 510 const SkMatrix& viewMatrix, |
517 GrPrimitiveType primitiveType, | 511 GrPrimitiveType primitiveType, |
518 int vertexCount, | 512 int vertexCount, |
519 const SkPoint positions[], | 513 const SkPoint positions[], |
520 const SkPoint texCoords[], | 514 const SkPoint texCoords[], |
(...skipping 24 matching lines...) Expand all Loading... |
545 bounds.outset(0.5f, 0.5f); | 539 bounds.outset(0.5f, 0.5f); |
546 } | 540 } |
547 | 541 |
548 GrDrawVerticesBatch::Geometry geometry; | 542 GrDrawVerticesBatch::Geometry geometry; |
549 geometry.fColor = paint.getColor(); | 543 geometry.fColor = paint.getColor(); |
550 SkAutoTUnref<GrDrawBatch> batch(GrDrawVerticesBatch::Create(geometry, primit
iveType, viewMatrix, | 544 SkAutoTUnref<GrDrawBatch> batch(GrDrawVerticesBatch::Create(geometry, primit
iveType, viewMatrix, |
551 positions, verte
xCount, indices, | 545 positions, verte
xCount, indices, |
552 indexCount, colo
rs, texCoords, | 546 indexCount, colo
rs, texCoords, |
553 bounds)); | 547 bounds)); |
554 | 548 |
555 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); | 549 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); |
556 pipelineBuilder.setRenderTarget(fRenderTarget.get()); | |
557 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 550 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
558 } | 551 } |
559 | 552 |
560 /////////////////////////////////////////////////////////////////////////////// | 553 /////////////////////////////////////////////////////////////////////////////// |
561 | 554 |
562 void GrDrawContext::drawAtlas(const GrClip& clip, | 555 void GrDrawContext::drawAtlas(const GrClip& clip, |
563 const GrPaint& paint, | 556 const GrPaint& paint, |
564 const SkMatrix& viewMatrix, | 557 const SkMatrix& viewMatrix, |
565 int spriteCount, | 558 int spriteCount, |
566 const SkRSXform xform[], | 559 const SkRSXform xform[], |
567 const SkRect texRect[], | 560 const SkRect texRect[], |
568 const SkColor colors[]) { | 561 const SkColor colors[]) { |
569 ASSERT_SINGLE_OWNER | 562 ASSERT_SINGLE_OWNER |
570 RETURN_IF_ABANDONED | 563 RETURN_IF_ABANDONED |
571 SkDEBUGCODE(this->validate();) | 564 SkDEBUGCODE(this->validate();) |
572 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawAtlas"); | 565 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawAtlas"); |
573 | 566 |
574 AutoCheckFlush acf(fDrawingManager); | 567 AutoCheckFlush acf(fDrawingManager); |
575 | 568 |
576 GrDrawAtlasBatch::Geometry geometry; | 569 GrDrawAtlasBatch::Geometry geometry; |
577 geometry.fColor = paint.getColor(); | 570 geometry.fColor = paint.getColor(); |
578 SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatri
x, spriteCount, | 571 SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatri
x, spriteCount, |
579 xform, texRect, col
ors)); | 572 xform, texRect, col
ors)); |
580 | 573 |
581 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); | 574 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); |
582 pipelineBuilder.setRenderTarget(fRenderTarget.get()); | |
583 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 575 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
584 } | 576 } |
585 | 577 |
586 /////////////////////////////////////////////////////////////////////////////// | 578 /////////////////////////////////////////////////////////////////////////////// |
587 | 579 |
588 void GrDrawContext::drawRRect(const GrClip& clip, | 580 void GrDrawContext::drawRRect(const GrClip& clip, |
589 const GrPaint& paint, | 581 const GrPaint& paint, |
590 const SkMatrix& viewMatrix, | 582 const SkMatrix& viewMatrix, |
591 const SkRRect& rrect, | 583 const SkRRect& rrect, |
592 const GrStyle& style) { | 584 const GrStyle& style) { |
(...skipping 12 matching lines...) Expand all Loading... |
605 | 597 |
606 if (should_apply_coverage_aa(paint, fRenderTarget.get())) { | 598 if (should_apply_coverage_aa(paint, fRenderTarget.get())) { |
607 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); | 599 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); |
608 | 600 |
609 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(paint.g
etColor(), | 601 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(paint.g
etColor(), |
610 viewMat
rix, | 602 viewMat
rix, |
611 rrect, | 603 rrect, |
612 stroke, | 604 stroke, |
613 shaderC
aps)); | 605 shaderC
aps)); |
614 if (batch) { | 606 if (batch) { |
615 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisample
d()); | 607 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled
()); |
616 pipelineBuilder.setRenderTarget(fRenderTarget.get()); | |
617 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch)
; | 608 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch)
; |
618 return; | 609 return; |
619 } | 610 } |
620 } | 611 } |
621 | 612 |
622 SkPath path; | 613 SkPath path; |
623 path.setIsVolatile(true); | 614 path.setIsVolatile(true); |
624 path.addRRect(rrect); | 615 path.addRRect(rrect); |
625 this->internalDrawPath(clip, paint, viewMatrix, path, style); | 616 this->internalDrawPath(clip, paint, viewMatrix, path, style); |
626 } | 617 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 AutoCheckFlush acf(fDrawingManager); | 722 AutoCheckFlush acf(fDrawingManager); |
732 const SkStrokeRec& stroke = style.strokeRec(); | 723 const SkStrokeRec& stroke = style.strokeRec(); |
733 if (should_apply_coverage_aa(paint, fRenderTarget.get())) { | 724 if (should_apply_coverage_aa(paint, fRenderTarget.get())) { |
734 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); | 725 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); |
735 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.ge
tColor(), | 726 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.ge
tColor(), |
736 viewMatr
ix, | 727 viewMatr
ix, |
737 oval, | 728 oval, |
738 stroke, | 729 stroke, |
739 shaderCa
ps)); | 730 shaderCa
ps)); |
740 if (batch) { | 731 if (batch) { |
741 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisample
d()); | 732 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled
()); |
742 pipelineBuilder.setRenderTarget(fRenderTarget.get()); | |
743 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch)
; | 733 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch)
; |
744 return; | 734 return; |
745 } | 735 } |
746 } | 736 } |
747 | 737 |
748 SkPath path; | 738 SkPath path; |
749 path.setIsVolatile(true); | 739 path.setIsVolatile(true); |
750 path.addOval(oval); | 740 path.addOval(oval); |
751 this->internalDrawPath(clip, paint, viewMatrix, path, style); | 741 this->internalDrawPath(clip, paint, viewMatrix, path, style); |
752 } | 742 } |
753 | 743 |
754 void GrDrawContext::drawImageNine(const GrClip& clip, | 744 void GrDrawContext::drawImageNine(const GrClip& clip, |
755 const GrPaint& paint, | 745 const GrPaint& paint, |
756 const SkMatrix& viewMatrix, | 746 const SkMatrix& viewMatrix, |
757 int imageWidth, | 747 int imageWidth, |
758 int imageHeight, | 748 int imageHeight, |
759 const SkIRect& center, | 749 const SkIRect& center, |
760 const SkRect& dst) { | 750 const SkRect& dst) { |
761 ASSERT_SINGLE_OWNER | 751 ASSERT_SINGLE_OWNER |
762 RETURN_IF_ABANDONED | 752 RETURN_IF_ABANDONED |
763 SkDEBUGCODE(this->validate();) | 753 SkDEBUGCODE(this->validate();) |
764 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawImageNine"); | 754 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawImageNine"); |
765 | 755 |
766 AutoCheckFlush acf(fDrawingManager); | 756 AutoCheckFlush acf(fDrawingManager); |
767 | 757 |
768 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v
iewMatrix, | 758 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v
iewMatrix, |
769 imageWidth, imageHe
ight, | 759 imageWidth, imageHe
ight, |
770 center, dst)); | 760 center, dst)); |
771 | 761 |
772 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); | 762 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); |
773 pipelineBuilder.setRenderTarget(fRenderTarget.get()); | |
774 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 763 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
775 } | 764 } |
776 | 765 |
777 | 766 |
778 // Can 'path' be drawn as a pair of filled nested rectangles? | 767 // Can 'path' be drawn as a pair of filled nested rectangles? |
779 static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path
, SkRect rects[2]) { | 768 static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path
, SkRect rects[2]) { |
780 | 769 |
781 if (path.isInverseFillType()) { | 770 if (path.isInverseFillType()) { |
782 return false; | 771 return false; |
783 } | 772 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 | 812 |
824 void GrDrawContext::drawBatch(const GrClip& clip, | 813 void GrDrawContext::drawBatch(const GrClip& clip, |
825 const GrPaint& paint, GrDrawBatch* batch) { | 814 const GrPaint& paint, GrDrawBatch* batch) { |
826 ASSERT_SINGLE_OWNER | 815 ASSERT_SINGLE_OWNER |
827 RETURN_IF_ABANDONED | 816 RETURN_IF_ABANDONED |
828 SkDEBUGCODE(this->validate();) | 817 SkDEBUGCODE(this->validate();) |
829 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 818 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
830 | 819 |
831 AutoCheckFlush acf(fDrawingManager); | 820 AutoCheckFlush acf(fDrawingManager); |
832 | 821 |
833 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); | 822 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled()); |
834 pipelineBuilder.setRenderTarget(fRenderTarget.get()); | |
835 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 823 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
836 } | 824 } |
837 | 825 |
838 void GrDrawContext::drawPath(const GrClip& clip, | 826 void GrDrawContext::drawPath(const GrClip& clip, |
839 const GrPaint& paint, | 827 const GrPaint& paint, |
840 const SkMatrix& viewMatrix, | 828 const SkMatrix& viewMatrix, |
841 const SkPath& path, | 829 const SkPath& path, |
842 const GrStyle& style) { | 830 const GrStyle& style) { |
843 ASSERT_SINGLE_OWNER | 831 ASSERT_SINGLE_OWNER |
844 RETURN_IF_ABANDONED | 832 RETURN_IF_ABANDONED |
(...skipping 11 matching lines...) Expand all Loading... |
856 | 844 |
857 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && !style.pathEffec
t()) { | 845 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && !style.pathEffec
t()) { |
858 if (style.isSimpleFill() && !path.isConvex()) { | 846 if (style.isSimpleFill() && !path.isConvex()) { |
859 // Concave AA paths are expensive - try to avoid them for special ca
ses | 847 // Concave AA paths are expensive - try to avoid them for special ca
ses |
860 SkRect rects[2]; | 848 SkRect rects[2]; |
861 | 849 |
862 if (fills_as_nested_rects(viewMatrix, path, rects)) { | 850 if (fills_as_nested_rects(viewMatrix, path, rects)) { |
863 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill
NestedRects( | 851 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill
NestedRects( |
864 paint.getColor(), viewMatrix, rects)); | 852 paint.getColor(), viewMatrix, rects)); |
865 if (batch) { | 853 if (batch) { |
866 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMul
tisampled()); | 854 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMult
isampled()); |
867 pipelineBuilder.setRenderTarget(fRenderTarget.get()); | |
868 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip
, batch); | 855 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip
, batch); |
869 } | 856 } |
870 return; | 857 return; |
871 } | 858 } |
872 } | 859 } |
873 SkRect ovalRect; | 860 SkRect ovalRect; |
874 bool isOval = path.isOval(&ovalRect); | 861 bool isOval = path.isOval(&ovalRect); |
875 | 862 |
876 if (isOval && !path.isInverseFillType()) { | 863 if (isOval && !path.isInverseFillType()) { |
877 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); | 864 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); |
878 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(pain
t.getColor(), | 865 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(pain
t.getColor(), |
879 view
Matrix, | 866 view
Matrix, |
880 oval
Rect, | 867 oval
Rect, |
881 styl
e.strokeRec(), | 868 styl
e.strokeRec(), |
882 shad
erCaps)); | 869 shad
erCaps)); |
883 if (batch) { | 870 if (batch) { |
884 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisa
mpled()); | 871 GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisam
pled()); |
885 pipelineBuilder.setRenderTarget(fRenderTarget.get()); | |
886 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, ba
tch); | 872 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, ba
tch); |
887 return; | 873 return; |
888 } | 874 } |
889 } | 875 } |
890 } | 876 } |
891 | 877 |
892 // Note that internalDrawPath may sw-rasterize the path into a scratch textu
re. | 878 // Note that internalDrawPath may sw-rasterize the path into a scratch textu
re. |
893 // Scratch textures can be recycled after they are returned to the texture | 879 // Scratch textures can be recycled after they are returned to the texture |
894 // cache. This presents a potential hazard for buffered drawing. However, | 880 // cache. This presents a potential hazard for buffered drawing. However, |
895 // the writePixels that uploads to the scratch will perform a flush so we're | 881 // the writePixels that uploads to the scratch will perform a flush so we're |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 | 1055 |
1070 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr
Clip& clip, | 1056 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr
Clip& clip, |
1071 GrDrawBatch* batch) { | 1057 GrDrawBatch* batch) { |
1072 ASSERT_SINGLE_OWNER | 1058 ASSERT_SINGLE_OWNER |
1073 RETURN_IF_ABANDONED | 1059 RETURN_IF_ABANDONED |
1074 SkDEBUGCODE(this->validate();) | 1060 SkDEBUGCODE(this->validate();) |
1075 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 1061 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
1076 | 1062 |
1077 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 1063 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
1078 } | 1064 } |
OLD | NEW |