aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2017-06-05 13:15:37 -0600
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-05 19:53:06 +0000
commit348060fa820e1ee7a4fd246afe517a80a9ef311d (patch)
tree04e6e87d8b141f562116f107d42dcb77edda6341 /src
parent70898afe073c49d8151b25cc5bf234f61c76ffae (diff)
Fix GrReducedClip.cpp: assertion failure surrounding tiny query bounds
Some assertions cannot be relied upon due to FP error. Bug: skia:5990 Change-Id: I32445b320b9100ae2f80d2f762707d823da77805 Reviewed-on: https://skia-review.googlesource.com/18602 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrClip.h16
-rw-r--r--src/gpu/GrReducedClip.cpp12
2 files changed, 19 insertions, 9 deletions
diff --git a/src/gpu/GrClip.h b/src/gpu/GrClip.h
index c44653baad..2e247c82f2 100644
--- a/src/gpu/GrClip.h
+++ b/src/gpu/GrClip.h
@@ -90,12 +90,16 @@ public:
*/
template <typename TRect>
constexpr static bool IsOutsideClip(const TRect& outerClipBounds, const SkRect& queryBounds) {
- return outerClipBounds.fRight - outerClipBounds.fLeft <= kBoundsTolerance ||
- outerClipBounds.fBottom - outerClipBounds.fTop <= kBoundsTolerance ||
- outerClipBounds.fLeft >= queryBounds.fRight - kBoundsTolerance ||
- outerClipBounds.fTop >= queryBounds.fBottom - kBoundsTolerance ||
- outerClipBounds.fRight <= queryBounds.fLeft + kBoundsTolerance ||
- outerClipBounds.fBottom <= queryBounds.fTop + kBoundsTolerance;
+ return
+ // Is the clip so small that it is effectively empty?
+ outerClipBounds.fRight - outerClipBounds.fLeft <= kBoundsTolerance ||
+ outerClipBounds.fBottom - outerClipBounds.fTop <= kBoundsTolerance ||
+
+ // Are the query bounds effectively outside the clip?
+ outerClipBounds.fLeft >= queryBounds.fRight - kBoundsTolerance ||
+ outerClipBounds.fTop >= queryBounds.fBottom - kBoundsTolerance ||
+ outerClipBounds.fRight <= queryBounds.fLeft + kBoundsTolerance ||
+ outerClipBounds.fBottom <= queryBounds.fTop + kBoundsTolerance;
}
/**
diff --git a/src/gpu/GrReducedClip.cpp b/src/gpu/GrReducedClip.cpp
index b7ffa7b26f..8c98ac1c71 100644
--- a/src/gpu/GrReducedClip.cpp
+++ b/src/gpu/GrReducedClip.cpp
@@ -45,7 +45,7 @@ GrReducedClip::GrReducedClip(const SkClipStack& stack, const SkRect& queryBounds
bool iior;
stack.getBounds(&stackBounds, &stackBoundsType, &iior);
- if (stackBounds.isEmpty() || GrClip::IsOutsideClip(stackBounds, queryBounds)) {
+ if (GrClip::IsOutsideClip(stackBounds, queryBounds)) {
bool insideOut = SkClipStack::kInsideOut_BoundsType == stackBoundsType;
fInitialState = insideOut ? InitialState::kAllIn : InitialState::kAllOut;
return;
@@ -72,7 +72,10 @@ GrReducedClip::GrReducedClip(const SkClipStack& stack, const SkRect& queryBounds
SkRect tightBounds;
SkAssertResult(tightBounds.intersect(stackBounds, queryBounds));
fIBounds = GrClip::GetPixelIBounds(tightBounds);
- SkASSERT(!fIBounds.isEmpty()); // Empty should have been blocked by IsOutsideClip above.
+ if (fIBounds.isEmpty()) {
+ fInitialState = InitialState::kAllOut;
+ return;
+ }
fHasIBounds = true;
// Implement the clip with an AA rect element.
@@ -92,7 +95,10 @@ GrReducedClip::GrReducedClip(const SkClipStack& stack, const SkRect& queryBounds
}
fIBounds = GrClip::GetPixelIBounds(tighterQuery);
- SkASSERT(!fIBounds.isEmpty()); // Empty should have been blocked by IsOutsideClip above.
+ if (fIBounds.isEmpty()) {
+ fInitialState = InitialState::kAllOut;
+ return;
+ }
fHasIBounds = true;
// Now that we have determined the bounds to use and filtered out the trivial cases, call the