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

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

Issue 1750533003: Move drawDRRect back to GrDrawContext (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 | « src/gpu/GrDrawContext.cpp ('k') | no next file » | 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 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "GrBlurUtils.h" 10 #include "GrBlurUtils.h"
(...skipping 26 matching lines...) Expand all
37 #include "SkStroke.h" 37 #include "SkStroke.h"
38 #include "SkSurface.h" 38 #include "SkSurface.h"
39 #include "SkSurface_Gpu.h" 39 #include "SkSurface_Gpu.h"
40 #include "SkTLazy.h" 40 #include "SkTLazy.h"
41 #include "SkUtils.h" 41 #include "SkUtils.h"
42 #include "SkVertState.h" 42 #include "SkVertState.h"
43 #include "SkXfermode.h" 43 #include "SkXfermode.h"
44 #include "batches/GrRectBatchFactory.h" 44 #include "batches/GrRectBatchFactory.h"
45 #include "effects/GrBicubicEffect.h" 45 #include "effects/GrBicubicEffect.h"
46 #include "effects/GrDashingEffect.h" 46 #include "effects/GrDashingEffect.h"
47 #include "effects/GrRRectEffect.h"
48 #include "effects/GrSimpleTextureEffect.h" 47 #include "effects/GrSimpleTextureEffect.h"
49 #include "effects/GrTextureDomain.h" 48 #include "effects/GrTextureDomain.h"
50 #include "text/GrTextUtils.h" 49 #include "text/GrTextUtils.h"
51 50
52 #if SK_SUPPORT_GPU 51 #if SK_SUPPORT_GPU
53 52
54 #define ASSERT_SINGLE_OWNER \ 53 #define ASSERT_SINGLE_OWNER \
55 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fContext->debugSing leOwner());) 54 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fContext->debugSing leOwner());)
56 55
57 enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 }; 56 enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 };
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 *draw.fMatrix, nullptr, 553 *draw.fMatrix, nullptr,
555 draw.fClip->getBounds(), true); 554 draw.fClip->getBounds(), true);
556 return; 555 return;
557 } 556 }
558 557
559 SkASSERT(!strokeInfo.isDashed()); 558 SkASSERT(!strokeInfo.isDashed());
560 559
561 fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rect, strokeInfo); 560 fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rect, strokeInfo);
562 } 561 }
563 562
564 bool SkGpuDevice::drawFilledDRRect(const SkMatrix& viewMatrix, const SkRRect& or igOuter,
565 const SkRRect& origInner, const SkPaint& pain t) {
566 SkASSERT(!origInner.isEmpty());
567 SkASSERT(!origOuter.isEmpty());
568
569 bool applyAA = paint.isAntiAlias() && !fRenderTarget->isUnifiedMultisampled( );
570
571 GrPrimitiveEdgeType innerEdgeType = applyAA ? kInverseFillAA_GrProcessorEdge Type :
572 kInverseFillBW_GrProcessorEdge Type;
573 GrPrimitiveEdgeType outerEdgeType = applyAA ? kFillAA_GrProcessorEdgeType :
574 kFillBW_GrProcessorEdgeType;
575
576 SkTCopyOnFirstWrite<SkRRect> inner(origInner), outer(origOuter);
577 SkMatrix inverseVM;
578 if (!viewMatrix.isIdentity()) {
579 if (!origInner.transform(viewMatrix, inner.writable())) {
580 return false;
581 }
582 if (!origOuter.transform(viewMatrix, outer.writable())) {
583 return false;
584 }
585 if (!viewMatrix.invert(&inverseVM)) {
586 return false;
587 }
588 } else {
589 inverseVM.reset();
590 }
591
592 GrPaint grPaint;
593
594 if (!SkPaintToGrPaint(this->context(), paint, viewMatrix, &grPaint)) {
595 return false;
596 }
597
598 grPaint.setAntiAlias(false);
599
600 // TODO these need to be a geometry processors
601 SkAutoTUnref<GrFragmentProcessor> innerEffect(GrRRectEffect::Create(innerEdg eType, *inner));
602 if (!innerEffect) {
603 return false;
604 }
605
606 SkAutoTUnref<GrFragmentProcessor> outerEffect(GrRRectEffect::Create(outerEdg eType, *outer));
607 if (!outerEffect) {
608 return false;
609 }
610
611 grPaint.addCoverageFragmentProcessor(innerEffect);
612 grPaint.addCoverageFragmentProcessor(outerEffect);
613
614 SkRect bounds = outer->getBounds();
615 if (applyAA) {
616 bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
617 }
618
619 fDrawContext->fillRectWithLocalMatrix(fClip, grPaint, SkMatrix::I(), bounds, inverseVM);
620 return true;
621 }
622
623 563
624 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, 564 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
625 const SkRRect& inner, const SkPaint& paint) { 565 const SkRRect& inner, const SkPaint& paint) {
626 ASSERT_SINGLE_OWNER 566 ASSERT_SINGLE_OWNER
627 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDRRect", fContext); 567 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDRRect", fContext);
628 CHECK_FOR_ANNOTATION(paint); 568 CHECK_FOR_ANNOTATION(paint);
629 CHECK_SHOULD_DRAW(draw); 569 CHECK_SHOULD_DRAW(draw);
630 570
631 if (outer.isEmpty()) { 571 if (outer.isEmpty()) {
632 return; 572 return;
633 } 573 }
634 574
635 if (inner.isEmpty()) { 575 if (inner.isEmpty()) {
636 return this->drawRRect(draw, outer, paint); 576 return this->drawRRect(draw, outer, paint);
637 } 577 }
638 578
639 SkStrokeRec stroke(paint); 579 SkStrokeRec stroke(paint);
640 580
641 if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect() ) { 581 if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect() ) {
642 if (this->drawFilledDRRect(*draw.fMatrix, outer, inner, paint)) { 582 GrPaint grPaint;
583 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) {
643 return; 584 return;
644 } 585 }
586
587 fDrawContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner);
588 return;
645 } 589 }
646 590
647 SkPath path; 591 SkPath path;
648 path.setIsVolatile(true); 592 path.setIsVolatile(true);
649 path.addRRect(outer); 593 path.addRRect(outer);
650 path.addRRect(inner); 594 path.addRRect(inner);
651 path.setFillType(SkPath::kEvenOdd_FillType); 595 path.setFillType(SkPath::kEvenOdd_FillType);
652 596
653 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, 597 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext,
654 fClip, path, paint, 598 fClip, path, paint,
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1946 } 1890 }
1947 1891
1948 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1892 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1949 ASSERT_SINGLE_OWNER 1893 ASSERT_SINGLE_OWNER
1950 // We always return a transient cache, so it is freed after each 1894 // We always return a transient cache, so it is freed after each
1951 // filter traversal. 1895 // filter traversal.
1952 return SkGpuDevice::NewImageFilterCache(); 1896 return SkGpuDevice::NewImageFilterCache();
1953 } 1897 }
1954 1898
1955 #endif 1899 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698