Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: src/gpu/GrDrawContext.cpp

Issue 1966903004: Remove clip from GrPipelineBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@fix2_nvpr
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 if (!viewMatrix.invert(&localMatrix)) { 228 if (!viewMatrix.invert(&localMatrix)) {
229 SkDebugf("Could not invert matrix\n"); 229 SkDebugf("Could not invert matrix\n");
230 return; 230 return;
231 } 231 }
232 232
233 AutoCheckFlush acf(fDrawingManager); 233 AutoCheckFlush acf(fDrawingManager);
234 234
235 SkAutoTUnref<GrDrawBatch> batch( 235 SkAutoTUnref<GrDrawBatch> batch(
236 GrRectBatchFactory::CreateNonAAFill(paint->getColor(), SkMatrix: :I(), r, nullptr, 236 GrRectBatchFactory::CreateNonAAFill(paint->getColor(), SkMatrix: :I(), r, nullptr,
237 &localMatrix)); 237 &localMatrix));
238 GrPipelineBuilder pipelineBuilder(*paint, fRenderTarget.get(), clip); 238 GrPipelineBuilder pipelineBuilder(*paint, fRenderTarget.get());
239 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 239 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch);
240 } 240 }
241 } 241 }
242 242
243 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po int) { 243 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po int) {
244 return point.fX >= rect.fLeft && point.fX <= rect.fRight && 244 return point.fX >= rect.fLeft && point.fX <= rect.fRight &&
245 point.fY >= rect.fTop && point.fY <= rect.fBottom; 245 point.fY >= rect.fTop && point.fY <= rect.fBottom;
246 } 246 }
247 247
248 static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) { 248 static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) {
249 return viewMatrix.preservesRightAngles(); 249 return viewMatrix.preservesRightAngles();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix, rect, 350 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix, rect,
351 width, snapToPixel Centers)); 351 width, snapToPixel Centers));
352 352
353 // Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of 353 // 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 354 // 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. 355 // when MSAA is enabled because it can cause ugly artifacts.
356 } 356 }
357 } 357 }
358 358
359 if (batch) { 359 if (batch) {
360 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); 360 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get());
361 361
362 if (snapToPixelCenters) { 362 if (snapToPixelCenters) {
363 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCent ers_Flag, 363 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCent ers_Flag,
364 snapToPixelCenters); 364 snapToPixelCenters);
365 } 365 }
366 366
367 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 367 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch);
368 return; 368 return;
369 } 369 }
370 370
371 SkPath path; 371 SkPath path;
372 path.setIsVolatile(true); 372 path.setIsVolatile(true);
373 path.addRect(rect); 373 path.addRect(rect);
374 this->internalDrawPath(clip, paint, viewMatrix, path, *style); 374 this->internalDrawPath(clip, paint, viewMatrix, path, *style);
375 } 375 }
376 376
377 bool GrDrawContextPriv::drawAndStencilRect(const SkIRect* scissorRect, 377 bool GrDrawContextPriv::drawAndStencilRect(const GrClip& clip,
378 const GrUserStencilSettings* ss, 378 const GrUserStencilSettings* ss,
379 SkRegion::Op op, 379 SkRegion::Op op,
380 bool invert, 380 bool invert,
381 bool doAA, 381 bool doAA,
382 const SkMatrix& viewMatrix, 382 const SkMatrix& viewMatrix,
383 const SkRect& rect) { 383 const SkRect& rect) {
384 ASSERT_SINGLE_OWNER_PRIV 384 ASSERT_SINGLE_OWNER_PRIV
385 RETURN_FALSE_IF_ABANDONED_PRIV 385 RETURN_FALSE_IF_ABANDONED_PRIV
386 SkDEBUGCODE(fDrawContext->validate();) 386 SkDEBUGCODE(fDrawContext->validate();)
387 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil Rect"); 387 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil Rect");
388 388
389 AutoCheckFlush acf(fDrawContext->fDrawingManager); 389 AutoCheckFlush acf(fDrawContext->fDrawingManager);
390 390
391 GrPaint paint; 391 GrPaint paint;
392 paint.setAntiAlias(doAA); 392 paint.setAntiAlias(doAA);
393 paint.setCoverageSetOpXPFactory(op, invert); 393 paint.setCoverageSetOpXPFactory(op, invert);
394 394
395 SkAutoTUnref<GrDrawBatch> batch(fDrawContext->getFillRectBatch(paint, viewMa trix, rect)); 395 SkAutoTUnref<GrDrawBatch> batch(fDrawContext->getFillRectBatch(paint, viewMa trix, rect));
396 if (batch) { 396 if (batch) {
397 GrPipelineBuilder pipelineBuilder(paint, 397 GrPipelineBuilder pipelineBuilder(paint, fDrawContext->accessRenderTarge t());
398 fDrawContext->accessRenderTarget(),
399 GrClip::WideOpen());
400 pipelineBuilder.setUserStencil(ss); 398 pipelineBuilder.setUserStencil(ss);
401 399
402 fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, batch, scissor Rect); 400 fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch);
403 return true; 401 return true;
404 } 402 }
405 403
406 SkPath path; 404 SkPath path;
407 path.setIsVolatile(true); 405 path.setIsVolatile(true);
408 path.addRect(rect); 406 path.addRect(rect);
409 return this->drawAndStencilPath(scissorRect, ss, op, invert, doAA, viewMatri x, path); 407 return this->drawAndStencilPath(clip, ss, op, invert, doAA, viewMatrix, path );
410 } 408 }
411 409
412 void GrDrawContext::fillRectToRect(const GrClip& clip, 410 void GrDrawContext::fillRectToRect(const GrClip& clip,
413 const GrPaint& paint, 411 const GrPaint& paint,
414 const SkMatrix& viewMatrix, 412 const SkMatrix& viewMatrix,
415 const SkRect& rectToDraw, 413 const SkRect& rectToDraw,
416 const SkRect& localRect) { 414 const SkRect& localRect) {
417 ASSERT_SINGLE_OWNER 415 ASSERT_SINGLE_OWNER
418 RETURN_IF_ABANDONED 416 RETURN_IF_ABANDONED
419 SkDEBUGCODE(this->validate();) 417 SkDEBUGCODE(this->validate();)
420 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectToRect"); 418 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectToRect");
421 419
422 AutoCheckFlush acf(fDrawingManager); 420 AutoCheckFlush acf(fDrawingManager);
423 421
424 SkAutoTUnref<GrDrawBatch> batch; 422 SkAutoTUnref<GrDrawBatch> batch;
425 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && 423 if (should_apply_coverage_aa(paint, fRenderTarget.get()) &&
426 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { 424 view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
427 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie wMatrix, rectToDraw, 425 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie wMatrix, rectToDraw,
428 localRect)); 426 localRect));
429 } else { 427 } else {
430 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa trix, rectToDraw, 428 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa trix, rectToDraw,
431 &localRect, nullptr)); 429 &localRect, nullptr));
432 } 430 }
433 431
434 if (batch) { 432 if (batch) {
435 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); 433 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get());
436 this->drawBatch(&pipelineBuilder, batch); 434 this->drawBatch(&pipelineBuilder, clip, batch);
437 } 435 }
438 } 436 }
439 437
440 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, 438 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip,
441 const GrPaint& paint, 439 const GrPaint& paint,
442 const SkMatrix& viewMatrix, 440 const SkMatrix& viewMatrix,
443 const SkRect& rectToDraw, 441 const SkRect& rectToDraw,
444 const SkMatrix& localMatrix) { 442 const SkMatrix& localMatrix) {
445 ASSERT_SINGLE_OWNER 443 ASSERT_SINGLE_OWNER
446 RETURN_IF_ABANDONED 444 RETURN_IF_ABANDONED
447 SkDEBUGCODE(this->validate();) 445 SkDEBUGCODE(this->validate();)
448 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectWithLocalMatr ix"); 446 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectWithLocalMatr ix");
449 447
450 AutoCheckFlush acf(fDrawingManager); 448 AutoCheckFlush acf(fDrawingManager);
451 449
452 SkAutoTUnref<GrDrawBatch> batch; 450 SkAutoTUnref<GrDrawBatch> batch;
453 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && 451 if (should_apply_coverage_aa(paint, fRenderTarget.get()) &&
454 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { 452 view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
455 batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, loca lMatrix, 453 batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, loca lMatrix,
456 rectToDraw)); 454 rectToDraw));
457 } else { 455 } else {
458 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa trix, rectToDraw, 456 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa trix, rectToDraw,
459 nullptr, &localMatrix)); 457 nullptr, &localMatrix));
460 } 458 }
461 459
462 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); 460 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get());
463 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 461 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch);
464 } 462 }
465 463
466 void GrDrawContext::drawVertices(const GrClip& clip, 464 void GrDrawContext::drawVertices(const GrClip& clip,
467 const GrPaint& paint, 465 const GrPaint& paint,
468 const SkMatrix& viewMatrix, 466 const SkMatrix& viewMatrix,
469 GrPrimitiveType primitiveType, 467 GrPrimitiveType primitiveType,
470 int vertexCount, 468 int vertexCount,
471 const SkPoint positions[], 469 const SkPoint positions[],
472 const SkPoint texCoords[], 470 const SkPoint texCoords[],
473 const GrColor colors[], 471 const GrColor colors[],
(...skipping 23 matching lines...) Expand all
497 bounds.outset(0.5f, 0.5f); 495 bounds.outset(0.5f, 0.5f);
498 } 496 }
499 497
500 GrDrawVerticesBatch::Geometry geometry; 498 GrDrawVerticesBatch::Geometry geometry;
501 geometry.fColor = paint.getColor(); 499 geometry.fColor = paint.getColor();
502 SkAutoTUnref<GrDrawBatch> batch(GrDrawVerticesBatch::Create(geometry, primit iveType, viewMatrix, 500 SkAutoTUnref<GrDrawBatch> batch(GrDrawVerticesBatch::Create(geometry, primit iveType, viewMatrix,
503 positions, verte xCount, indices, 501 positions, verte xCount, indices,
504 indexCount, colo rs, texCoords, 502 indexCount, colo rs, texCoords,
505 bounds)); 503 bounds));
506 504
507 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); 505 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get());
508 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 506 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch);
509 } 507 }
510 508
511 /////////////////////////////////////////////////////////////////////////////// 509 ///////////////////////////////////////////////////////////////////////////////
512 510
513 void GrDrawContext::drawAtlas(const GrClip& clip, 511 void GrDrawContext::drawAtlas(const GrClip& clip,
514 const GrPaint& paint, 512 const GrPaint& paint,
515 const SkMatrix& viewMatrix, 513 const SkMatrix& viewMatrix,
516 int spriteCount, 514 int spriteCount,
517 const SkRSXform xform[], 515 const SkRSXform xform[],
518 const SkRect texRect[], 516 const SkRect texRect[],
519 const SkColor colors[]) { 517 const SkColor colors[]) {
520 ASSERT_SINGLE_OWNER 518 ASSERT_SINGLE_OWNER
521 RETURN_IF_ABANDONED 519 RETURN_IF_ABANDONED
522 SkDEBUGCODE(this->validate();) 520 SkDEBUGCODE(this->validate();)
523 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawAtlas"); 521 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawAtlas");
524 522
525 AutoCheckFlush acf(fDrawingManager); 523 AutoCheckFlush acf(fDrawingManager);
526 524
527 GrDrawAtlasBatch::Geometry geometry; 525 GrDrawAtlasBatch::Geometry geometry;
528 geometry.fColor = paint.getColor(); 526 geometry.fColor = paint.getColor();
529 SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatri x, spriteCount, 527 SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatri x, spriteCount,
530 xform, texRect, col ors)); 528 xform, texRect, col ors));
531 529
532 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); 530 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get());
533 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 531 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch);
534 } 532 }
535 533
536 /////////////////////////////////////////////////////////////////////////////// 534 ///////////////////////////////////////////////////////////////////////////////
537 535
538 void GrDrawContext::drawRRect(const GrClip& clip, 536 void GrDrawContext::drawRRect(const GrClip& clip,
539 const GrPaint& paint, 537 const GrPaint& paint,
540 const SkMatrix& viewMatrix, 538 const SkMatrix& viewMatrix,
541 const SkRRect& rrect, 539 const SkRRect& rrect,
542 const GrStyle& style) { 540 const GrStyle& style) {
543 ASSERT_SINGLE_OWNER 541 ASSERT_SINGLE_OWNER
(...skipping 11 matching lines...) Expand all
555 553
556 if (should_apply_coverage_aa(paint, fRenderTarget.get())) { 554 if (should_apply_coverage_aa(paint, fRenderTarget.get())) {
557 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); 555 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
558 556
559 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(paint.g etColor(), 557 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(paint.g etColor(),
560 viewMat rix, 558 viewMat rix,
561 rrect, 559 rrect,
562 stroke, 560 stroke,
563 shaderC aps)); 561 shaderC aps));
564 if (batch) { 562 if (batch) {
565 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); 563 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get());
566 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 564 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch);
567 return; 565 return;
568 } 566 }
569 } 567 }
570 568
571 SkPath path; 569 SkPath path;
572 path.setIsVolatile(true); 570 path.setIsVolatile(true);
573 path.addRRect(rrect); 571 path.addRRect(rrect);
574 this->internalDrawPath(clip, paint, viewMatrix, path, style); 572 this->internalDrawPath(clip, paint, viewMatrix, path, style);
575 } 573 }
576 574
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 if (this->drawFilledDRRect(clip, paint, viewMatrix, outer, inner)) { 647 if (this->drawFilledDRRect(clip, paint, viewMatrix, outer, inner)) {
650 return; 648 return;
651 } 649 }
652 650
653 SkPath path; 651 SkPath path;
654 path.setIsVolatile(true); 652 path.setIsVolatile(true);
655 path.addRRect(inner); 653 path.addRRect(inner);
656 path.addRRect(outer); 654 path.addRRect(outer);
657 path.setFillType(SkPath::kEvenOdd_FillType); 655 path.setFillType(SkPath::kEvenOdd_FillType);
658 656
659 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip);
660 this->internalDrawPath(clip, paint, viewMatrix, path, GrStyle::SimpleFill()) ; 657 this->internalDrawPath(clip, paint, viewMatrix, path, GrStyle::SimpleFill()) ;
661 } 658 }
662 659
663 /////////////////////////////////////////////////////////////////////////////// 660 ///////////////////////////////////////////////////////////////////////////////
664 661
665 void GrDrawContext::drawOval(const GrClip& clip, 662 void GrDrawContext::drawOval(const GrClip& clip,
666 const GrPaint& paint, 663 const GrPaint& paint,
667 const SkMatrix& viewMatrix, 664 const SkMatrix& viewMatrix,
668 const SkRect& oval, 665 const SkRect& oval,
669 const GrStyle& style) { 666 const GrStyle& style) {
(...skipping 11 matching lines...) Expand all
681 AutoCheckFlush acf(fDrawingManager); 678 AutoCheckFlush acf(fDrawingManager);
682 const SkStrokeRec& stroke = style.strokeRec(); 679 const SkStrokeRec& stroke = style.strokeRec();
683 if (should_apply_coverage_aa(paint, fRenderTarget.get())) { 680 if (should_apply_coverage_aa(paint, fRenderTarget.get())) {
684 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); 681 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
685 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.ge tColor(), 682 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.ge tColor(),
686 viewMatr ix, 683 viewMatr ix,
687 oval, 684 oval,
688 stroke, 685 stroke,
689 shaderCa ps)); 686 shaderCa ps));
690 if (batch) { 687 if (batch) {
691 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); 688 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get());
692 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 689 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch);
693 return; 690 return;
694 } 691 }
695 } 692 }
696 693
697 SkPath path; 694 SkPath path;
698 path.setIsVolatile(true); 695 path.setIsVolatile(true);
699 path.addOval(oval); 696 path.addOval(oval);
700 this->internalDrawPath(clip, paint, viewMatrix, path, style); 697 this->internalDrawPath(clip, paint, viewMatrix, path, style);
701 } 698 }
702 699
703 void GrDrawContext::drawImageNine(const GrClip& clip, 700 void GrDrawContext::drawImageNine(const GrClip& clip,
704 const GrPaint& paint, 701 const GrPaint& paint,
705 const SkMatrix& viewMatrix, 702 const SkMatrix& viewMatrix,
706 int imageWidth, 703 int imageWidth,
707 int imageHeight, 704 int imageHeight,
708 const SkIRect& center, 705 const SkIRect& center,
709 const SkRect& dst) { 706 const SkRect& dst) {
710 ASSERT_SINGLE_OWNER 707 ASSERT_SINGLE_OWNER
711 RETURN_IF_ABANDONED 708 RETURN_IF_ABANDONED
712 SkDEBUGCODE(this->validate();) 709 SkDEBUGCODE(this->validate();)
713 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawImageNine"); 710 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawImageNine");
714 711
715 AutoCheckFlush acf(fDrawingManager); 712 AutoCheckFlush acf(fDrawingManager);
716 713
717 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v iewMatrix, 714 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v iewMatrix,
718 imageWidth, imageHe ight, 715 imageWidth, imageHe ight,
719 center, dst)); 716 center, dst));
720 717
721 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); 718 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get());
722 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 719 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch);
723 } 720 }
724 721
725 722
726 // Can 'path' be drawn as a pair of filled nested rectangles? 723 // Can 'path' be drawn as a pair of filled nested rectangles?
727 static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path , SkRect rects[2]) { 724 static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path , SkRect rects[2]) {
728 725
729 if (path.isInverseFillType()) { 726 if (path.isInverseFillType()) {
730 return false; 727 return false;
731 } 728 }
732 729
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 768
772 void GrDrawContext::drawBatch(const GrClip& clip, 769 void GrDrawContext::drawBatch(const GrClip& clip,
773 const GrPaint& paint, GrDrawBatch* batch) { 770 const GrPaint& paint, GrDrawBatch* batch) {
774 ASSERT_SINGLE_OWNER 771 ASSERT_SINGLE_OWNER
775 RETURN_IF_ABANDONED 772 RETURN_IF_ABANDONED
776 SkDEBUGCODE(this->validate();) 773 SkDEBUGCODE(this->validate();)
777 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); 774 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch");
778 775
779 AutoCheckFlush acf(fDrawingManager); 776 AutoCheckFlush acf(fDrawingManager);
780 777
781 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); 778 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get());
782 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 779 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch);
783 } 780 }
784 781
785 void GrDrawContext::drawPath(const GrClip& clip, 782 void GrDrawContext::drawPath(const GrClip& clip,
786 const GrPaint& paint, 783 const GrPaint& paint,
787 const SkMatrix& viewMatrix, 784 const SkMatrix& viewMatrix,
788 const SkPath& path, 785 const SkPath& path,
789 const GrStyle& style) { 786 const GrStyle& style) {
790 ASSERT_SINGLE_OWNER 787 ASSERT_SINGLE_OWNER
791 RETURN_IF_ABANDONED 788 RETURN_IF_ABANDONED
792 SkDEBUGCODE(this->validate();) 789 SkDEBUGCODE(this->validate();)
(...skipping 10 matching lines...) Expand all
803 800
804 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && !style.pathEffec t()) { 801 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && !style.pathEffec t()) {
805 if (style.isSimpleFill() && !path.isConvex()) { 802 if (style.isSimpleFill() && !path.isConvex()) {
806 // Concave AA paths are expensive - try to avoid them for special ca ses 803 // Concave AA paths are expensive - try to avoid them for special ca ses
807 SkRect rects[2]; 804 SkRect rects[2];
808 805
809 if (fills_as_nested_rects(viewMatrix, path, rects)) { 806 if (fills_as_nested_rects(viewMatrix, path, rects)) {
810 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill NestedRects( 807 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill NestedRects(
811 paint.getColor(), viewMatrix, rects)); 808 paint.getColor(), viewMatrix, rects));
812 if (batch) { 809 if (batch) {
813 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get() , clip); 810 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get() );
814 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 811 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batc h);
815 } 812 }
816 return; 813 return;
817 } 814 }
818 } 815 }
819 SkRect ovalRect; 816 SkRect ovalRect;
820 bool isOval = path.isOval(&ovalRect); 817 bool isOval = path.isOval(&ovalRect);
821 818
822 if (isOval && !path.isInverseFillType()) { 819 if (isOval && !path.isInverseFillType()) {
823 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); 820 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
824 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(pain t.getColor(), 821 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(pain t.getColor(),
825 view Matrix, 822 view Matrix,
826 oval Rect, 823 oval Rect,
827 styl e.strokeRec(), 824 styl e.strokeRec(),
828 shad erCaps)); 825 shad erCaps));
829 if (batch) { 826 if (batch) {
830 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), cl ip); 827 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get());
831 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 828 this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch);
832 return; 829 return;
833 } 830 }
834 } 831 }
835 } 832 }
836 833
837 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re. 834 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re.
838 // Scratch textures can be recycled after they are returned to the texture 835 // Scratch textures can be recycled after they are returned to the texture
839 // cache. This presents a potential hazard for buffered drawing. However, 836 // cache. This presents a potential hazard for buffered drawing. However,
840 // the writePixels that uploads to the scratch will perform a flush so we're 837 // the writePixels that uploads to the scratch will perform a flush so we're
841 // OK. 838 // OK.
842 this->internalDrawPath(clip, paint, viewMatrix, path, style); 839 this->internalDrawPath(clip, paint, viewMatrix, path, style);
843 } 840 }
844 841
845 bool GrDrawContextPriv::drawAndStencilPath(const SkIRect* scissorRect, 842 bool GrDrawContextPriv::drawAndStencilPath(const GrClip& clip,
846 const GrUserStencilSettings* ss, 843 const GrUserStencilSettings* ss,
847 SkRegion::Op op, 844 SkRegion::Op op,
848 bool invert, 845 bool invert,
849 bool doAA, 846 bool doAA,
850 const SkMatrix& viewMatrix, 847 const SkMatrix& viewMatrix,
851 const SkPath& path) { 848 const SkPath& path) {
852 ASSERT_SINGLE_OWNER_PRIV 849 ASSERT_SINGLE_OWNER_PRIV
853 RETURN_FALSE_IF_ABANDONED_PRIV 850 RETURN_FALSE_IF_ABANDONED_PRIV
854 SkDEBUGCODE(fDrawContext->validate();) 851 SkDEBUGCODE(fDrawContext->validate();)
855 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawPat h"); 852 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawPat h");
856 853
857 if (path.isEmpty() && path.isInverseFillType()) { 854 if (path.isEmpty() && path.isInverseFillType()) {
858 this->drawAndStencilRect(scissorRect, ss, op, invert, false, SkMatrix::I (), 855 this->drawAndStencilRect(clip, ss, op, invert, false, SkMatrix::I(),
859 SkRect::MakeIWH(fDrawContext->width(), 856 SkRect::MakeIWH(fDrawContext->width(),
860 fDrawContext->height())); 857 fDrawContext->height()));
861 return true; 858 return true;
862 } 859 }
863 860
864 AutoCheckFlush acf(fDrawContext->fDrawingManager); 861 AutoCheckFlush acf(fDrawContext->fDrawingManager);
865 862
866 // An Assumption here is that path renderer would use some form of tweaking 863 // An Assumption here is that path renderer would use some form of tweaking
867 // the src color (either the input alpha or in the frag shader) to implement 864 // the src color (either the input alpha or in the frag shader) to implement
868 // aa. If we have some future driver-mojo path AA that can do the right 865 // aa. If we have some future driver-mojo path AA that can do the right
(...skipping 17 matching lines...) Expand all
886 883
887 // Don't allow the SW renderer 884 // Don't allow the SW renderer
888 GrPathRenderer* pr = fDrawContext->fDrawingManager->getPathRenderer(canDrawA rgs, false, type); 885 GrPathRenderer* pr = fDrawContext->fDrawingManager->getPathRenderer(canDrawA rgs, false, type);
889 if (!pr) { 886 if (!pr) {
890 return false; 887 return false;
891 } 888 }
892 889
893 GrPaint paint; 890 GrPaint paint;
894 paint.setCoverageSetOpXPFactory(op, invert); 891 paint.setCoverageSetOpXPFactory(op, invert);
895 892
896 // TODO: it is unfortunate that we have to convert this to a GrClip to 893 GrPipelineBuilder pipelineBuilder(paint, fDrawContext->accessRenderTarget()) ;
897 // call drawPath.
898 GrClip clip;
899 if (scissorRect) {
900 clip.setIRect(*scissorRect);
901 }
902
903 GrPipelineBuilder pipelineBuilder(paint, fDrawContext->accessRenderTarget(), clip);
904 pipelineBuilder.setUserStencil(ss); 894 pipelineBuilder.setUserStencil(ss);
905 895
906 GrPathRenderer::DrawPathArgs args; 896 GrPathRenderer::DrawPathArgs args;
907 args.fTarget = fDrawContext->getDrawTarget(); 897 args.fTarget = fDrawContext->getDrawTarget();
908 args.fResourceProvider = fDrawContext->fDrawingManager->getContext()->resour ceProvider(); 898 args.fResourceProvider = fDrawContext->fDrawingManager->getContext()->resour ceProvider();
909 args.fPipelineBuilder = &pipelineBuilder; 899 args.fPipelineBuilder = &pipelineBuilder;
900 args.fClip = &clip;
910 args.fColor = GrColor_WHITE; 901 args.fColor = GrColor_WHITE;
911 args.fViewMatrix = &viewMatrix; 902 args.fViewMatrix = &viewMatrix;
912 args.fPath = &path; 903 args.fPath = &path;
913 args.fStyle = &GrStyle::SimpleFill(); 904 args.fStyle = &GrStyle::SimpleFill();
914 args.fAntiAlias = useCoverageAA; 905 args.fAntiAlias = useCoverageAA;
915 args.fGammaCorrect = fDrawContext->isGammaCorrect(); 906 args.fGammaCorrect = fDrawContext->isGammaCorrect();
916 pr->drawPath(args); 907 pr->drawPath(args);
917 return true; 908 return true;
918 } 909 }
919 910
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 pr = fDrawingManager->getPathRenderer(canDrawArgs, true, type); 989 pr = fDrawingManager->getPathRenderer(canDrawArgs, true, type);
999 } 990 }
1000 991
1001 if (nullptr == pr) { 992 if (nullptr == pr) {
1002 #ifdef SK_DEBUG 993 #ifdef SK_DEBUG
1003 SkDebugf("Unable to find path renderer compatible with path.\n"); 994 SkDebugf("Unable to find path renderer compatible with path.\n");
1004 #endif 995 #endif
1005 return; 996 return;
1006 } 997 }
1007 998
1008 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); 999 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get());
1009 1000
1010 GrPathRenderer::DrawPathArgs args; 1001 GrPathRenderer::DrawPathArgs args;
1011 args.fTarget = this->getDrawTarget(); 1002 args.fTarget = this->getDrawTarget();
1012 args.fResourceProvider = fDrawingManager->getContext()->resourceProvider(); 1003 args.fResourceProvider = fDrawingManager->getContext()->resourceProvider();
1013 args.fPipelineBuilder = &pipelineBuilder; 1004 args.fPipelineBuilder = &pipelineBuilder;
1005 args.fClip = &clip;
1014 args.fColor = paint.getColor(); 1006 args.fColor = paint.getColor();
1015 args.fViewMatrix = &viewMatrix; 1007 args.fViewMatrix = &viewMatrix;
1016 args.fPath = canDrawArgs.fPath; 1008 args.fPath = canDrawArgs.fPath;
1017 args.fStyle = canDrawArgs.fStyle; 1009 args.fStyle = canDrawArgs.fStyle;
1018 args.fAntiAlias = useCoverageAA; 1010 args.fAntiAlias = useCoverageAA;
1019 args.fGammaCorrect = this->isGammaCorrect(); 1011 args.fGammaCorrect = this->isGammaCorrect();
1020 pr->drawPath(args); 1012 pr->drawPath(args);
1021 } 1013 }
1022 1014
1023 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) { 1015 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, const GrClip& clip,
1016 GrDrawBatch* batch) {
1024 ASSERT_SINGLE_OWNER 1017 ASSERT_SINGLE_OWNER
1025 RETURN_IF_ABANDONED 1018 RETURN_IF_ABANDONED
1026 SkDEBUGCODE(this->validate();) 1019 SkDEBUGCODE(this->validate();)
1027 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); 1020 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch");
1028 1021
1029 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); 1022 this->getDrawTarget()->drawBatch(*pipelineBuilder, clip, batch);
1030 } 1023 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698