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

Unified Diff: include/gpu/GrClip.h

Issue 2132073002: Pre-crop filled rects to avoid scissor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nearest filtering for the gm Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/croppedrects.cpp ('k') | src/gpu/GrClip.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrClip.h
diff --git a/include/gpu/GrClip.h b/include/gpu/GrClip.h
index e58528114e873f2caa78f807337cdbb30d46b7e1..b63f2130dac8e13fdf80c87df6491a0f5290f62f 100644
--- a/include/gpu/GrClip.h
+++ b/include/gpu/GrClip.h
@@ -109,6 +109,26 @@ public:
const SkRect* devBounds, GrAppliedClip*) const = 0;
virtual ~GrClip() {}
+
+protected:
+ /**
+ * Returns true if a clip can safely disable its scissor test for a particular draw.
+ */
+ static bool CanIgnoreScissor(const SkIRect& scissorRect, const SkRect& drawBounds) {
+ // This is the maximum distance that a draw may extend beyond a clip's scissor and still
+ // count as inside. We use a sloppy compare because the draw may have chosen its bounds in a
+ // different coord system. The rationale for 1e-3 is that in the coverage case (and barring
+ // unexpected rounding), as long as coverage stays below 0.5 * 1/256 we ought to be OK.
+ constexpr SkScalar fuzz = 1e-3f;
+ SkASSERT(!scissorRect.isEmpty());
+ SkASSERT(!drawBounds.isEmpty());
+ return scissorRect.fLeft <= drawBounds.fLeft + fuzz &&
+ scissorRect.fTop <= drawBounds.fTop + fuzz &&
+ scissorRect.fRight >= drawBounds.fRight - fuzz &&
+ scissorRect.fBottom >= drawBounds.fBottom - fuzz;
+ }
+
+ friend class GrClipMaskManager;
};
/**
« no previous file with comments | « gm/croppedrects.cpp ('k') | src/gpu/GrClip.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698