| 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;
|
| };
|
|
|
| /**
|
|
|