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

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

Issue 1726223008: Hide GrPipelineBuilder from GrOvalRenderer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | src/gpu/GrOvalRenderer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrBatchTest.h" 9 #include "GrBatchTest.h"
10 #include "GrColor.h" 10 #include "GrColor.h"
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 return; 487 return;
488 } 488 }
489 489
490 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path in SkGpuDevice 490 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path in SkGpuDevice
491 491
492 AutoCheckFlush acf(fDrawingManager); 492 AutoCheckFlush acf(fDrawingManager);
493 493
494 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 494 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
495 GrColor color = paint.getColor(); 495 GrColor color = paint.getColor();
496 496
497 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); 497 if (should_apply_coverage_aa(paint, fRenderTarget)) {
498 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(pipelineBui lder, 498 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
499 color, 499
500 viewMatrix, 500 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(color,
501 paint.isAnt iAlias(), 501 viewMat rix,
502 rrect, 502 rrect,
503 strokeInfo, 503 strokeI nfo,
504 shaderCaps) ); 504 shaderC aps));
505 if (batch) { 505 if (batch) {
506 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 506 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
507 } else { 507 return;
508 SkPath path; 508 }
509 path.setIsVolatile(true);
510 path.addRRect(rrect);
511 this->internalDrawPath(&pipelineBuilder, viewMatrix, color,
512 paint.isAntiAlias(), path, strokeInfo);
513 } 509 }
510
511 SkPath path;
512 path.setIsVolatile(true);
513 path.addRRect(rrect);
514 this->internalDrawPath(&pipelineBuilder, viewMatrix, color,
515 paint.isAntiAlias(), path, strokeInfo);
514 } 516 }
515 517
516 /////////////////////////////////////////////////////////////////////////////// 518 ///////////////////////////////////////////////////////////////////////////////
517 519
518 void GrDrawContext::drawOval(const GrClip& clip, 520 void GrDrawContext::drawOval(const GrClip& clip,
519 const GrPaint& paint, 521 const GrPaint& paint,
520 const SkMatrix& viewMatrix, 522 const SkMatrix& viewMatrix,
521 const SkRect& oval, 523 const SkRect& oval,
522 const GrStrokeInfo& strokeInfo) { 524 const GrStrokeInfo& strokeInfo) {
523 ASSERT_SINGLE_OWNER 525 ASSERT_SINGLE_OWNER
524 RETURN_IF_ABANDONED 526 RETURN_IF_ABANDONED
525 SkDEBUGCODE(this->validate();) 527 SkDEBUGCODE(this->validate();)
526 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawOval"); 528 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawOval");
527 529
528 if (oval.isEmpty()) { 530 if (oval.isEmpty()) {
529 return; 531 return;
530 } 532 }
531 533
532 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path in SkGpuDevice 534 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path in SkGpuDevice
533 535
534 AutoCheckFlush acf(fDrawingManager); 536 AutoCheckFlush acf(fDrawingManager);
535 537
536 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 538 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
537 GrColor color = paint.getColor(); 539 GrColor color = paint.getColor();
540
541 if (should_apply_coverage_aa(paint, fRenderTarget)) {
542 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
543 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(color,
544 viewMatr ix,
545 oval,
546 strokeIn fo,
547 shaderCa ps));
548 if (batch) {
549 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
550 return;
551 }
552 }
538 553
539 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); 554 SkPath path;
540 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(pipelineBuil der, 555 path.setIsVolatile(true);
541 color, 556 path.addOval(oval);
542 viewMatrix, 557 this->internalDrawPath(&pipelineBuilder, viewMatrix, color,
543 paint.isAnti Alias(), 558 paint.isAntiAlias(), path, strokeInfo);
544 oval,
545 strokeInfo,
546 shaderCaps)) ;
547 if (batch) {
548 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
549 } else {
550 SkPath path;
551 path.setIsVolatile(true);
552 path.addOval(oval);
553 this->internalDrawPath(&pipelineBuilder, viewMatrix, color,
554 paint.isAntiAlias(), path, strokeInfo);
555 }
556 } 559 }
557 560
558 void GrDrawContext::drawImageNine(const GrClip& clip, 561 void GrDrawContext::drawImageNine(const GrClip& clip,
559 const GrPaint& paint, 562 const GrPaint& paint,
560 const SkMatrix& viewMatrix, 563 const SkMatrix& viewMatrix,
561 int imageWidth, 564 int imageWidth,
562 int imageHeight, 565 int imageHeight,
563 const SkIRect& center, 566 const SkIRect& center,
564 const SkRect& dst) { 567 const SkRect& dst) {
565 ASSERT_SINGLE_OWNER 568 ASSERT_SINGLE_OWNER
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 GrColor color = paint.getColor(); 676 GrColor color = paint.getColor();
674 677
675 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re. 678 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re.
676 // Scratch textures can be recycled after they are returned to the texture 679 // Scratch textures can be recycled after they are returned to the texture
677 // cache. This presents a potential hazard for buffered drawing. However, 680 // cache. This presents a potential hazard for buffered drawing. However,
678 // the writePixels that uploads to the scratch will perform a flush so we're 681 // the writePixels that uploads to the scratch will perform a flush so we're
679 // OK. 682 // OK.
680 AutoCheckFlush acf(fDrawingManager); 683 AutoCheckFlush acf(fDrawingManager);
681 684
682 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 685 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
683 if (!strokeInfo.isDashed()) { 686 if (should_apply_coverage_aa(paint, fRenderTarget) && !strokeInfo.isDashed() ) {
684 bool useCoverageAA = should_apply_coverage_aa(paint, pipelineBuilder.get RenderTarget()); 687 if (strokeInfo.getWidth() < 0 && !path.isConvex()) {
685
686 if (useCoverageAA && strokeInfo.getWidth() < 0 && !path.isConvex()) {
687 // Concave AA paths are expensive - try to avoid them for special ca ses 688 // Concave AA paths are expensive - try to avoid them for special ca ses
688 SkRect rects[2]; 689 SkRect rects[2];
689 690
690 if (is_nested_rects(viewMatrix, path, strokeInfo, rects)) { 691 if (is_nested_rects(viewMatrix, path, strokeInfo, rects)) {
691 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill NestedRects( 692 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill NestedRects(
692 color, viewMatrix, rects)); 693 color, viewMatrix, rects));
693 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 694 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
694 return; 695 return;
695 } 696 }
696 } 697 }
697 SkRect ovalRect; 698 SkRect ovalRect;
698 bool isOval = path.isOval(&ovalRect); 699 bool isOval = path.isOval(&ovalRect);
699 700
700 if (isOval && !path.isInverseFillType()) { 701 if (isOval && !path.isInverseFillType()) {
701 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); 702 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
702 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(pipe lineBuilder, 703 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(colo r,
703 colo r,
704 view Matrix, 704 view Matrix,
705 pain t.isAntiAlias(),
706 oval Rect, 705 oval Rect,
707 stro keInfo, 706 stro keInfo,
708 shad erCaps)); 707 shad erCaps));
709 if (batch) { 708 if (batch) {
710 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 709 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
711 return; 710 return;
712 } 711 }
713 } 712 }
714 } 713 }
715 this->internalDrawPath(&pipelineBuilder, viewMatrix, color, 714 this->internalDrawPath(&pipelineBuilder, viewMatrix, color,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 } 818 }
820 819
821 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) { 820 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) {
822 ASSERT_SINGLE_OWNER 821 ASSERT_SINGLE_OWNER
823 RETURN_IF_ABANDONED 822 RETURN_IF_ABANDONED
824 SkDEBUGCODE(this->validate();) 823 SkDEBUGCODE(this->validate();)
825 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); 824 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch");
826 825
827 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); 826 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch);
828 } 827 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrOvalRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698