Skip to content

Commit

Permalink
Remove troublesome DCHECK() in homogenousLimitNearZero.
Browse files Browse the repository at this point in the history
This DCHECK() has become more trouble than it's worth, given that there
are enough edge cases that can cause it to fail in various ways.  So
just turn it into a code comment.

Fixed: 1230937
Bug: 1224066
Change-Id: Ia66eb51771b993c760e84f204c1f2e006b633441
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3046409
Commit-Queue: David Baron <dbaron@chromium.org>
Commit-Queue: Robert Flack <flackr@chromium.org>
Auto-Submit: David Baron <dbaron@chromium.org>
Reviewed-by: Robert Flack <flackr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#904586}
  • Loading branch information
dbaron authored and Chromium LUCI CQ committed Jul 23, 2021
1 parent 0a41f34 commit feae95a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cc/base/math_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ static void homogenousLimitNearZero(SkScalar a1,
if (std::abs(a1 * w2 / w1 / a2 - 1.0f) > kStationaryPointEpsilon) {
// t has been computed so that w is near but not at zero.
*limit = ((1.0f - t) * a1 + t * a2) / ((1.0f - t) * w1 + t * w2);
DCHECK(t == 0.0f || t == 1.0f ||
std::abs(*limit) * 0.998f <
HomogeneousCoordinate::kInfiniteCoordinate);
// std::abs(*limit) should now be somewhere near
// HomogeneousCoordinate::kInfiniteCoordinate, preferably smaller than it,
// but there are edge cases where it will be larger (for example, if the
// point where a crosses 0 is very close to the point where w crosses 0),
// so it's hard to DCHECK() that this is the case.
} else {
*limit = a1 / w1; // (== a2 / w2) && == (1.0f - t) * a1 / w1 + t * a2 / w2
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE HTML>
<title>CSS Test (Transforms): Transform with w crossing zero</title>
<link rel="author" title="L. David Baron" href="https://dbaron.org/">
<link rel="author" title="Google" href="http://www.google.com/">
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1230937">
<link rel="help" href="https://drafts.csswg.org/css-transforms-2/#processing-of-perspective-transformed-boxes">
<meta name="assert" content="This should not crash.">

<style>
#outer {
transform-style: preserve-3d;
}
#inner {
transform: matrix3d(4,947066.75,3,-57.374,1860.6956175,97,2291.191,-8.1785,9,46.047,5.02880,7.198084,2,8,2009,3.2);
border: medium solid;
}
</style>
<div id="outer">
<div id="inner">
</div>
</div>

0 comments on commit feae95a

Please sign in to comment.