mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-07 16:38:33 +02:00
libweston: change div by 0 behaviour in coordinate conversion
Let's simplify this code by asserting, and letting it explode naturally (return Inf, possibly SIGFPE depending on external factors) if compiled NDEBUG, instead of a contained explosion (safely returning 0). If this actually happens it's Really Bad, so we'd like to catch is ASAP, especially in CI. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
parent
8bf90010dd
commit
d347e37be4
1 changed files with 2 additions and 16 deletions
|
|
@ -655,14 +655,7 @@ weston_view_to_global_float(struct weston_view *view,
|
|||
|
||||
weston_matrix_transform(&view->transform.matrix, &v);
|
||||
|
||||
if (fabsf(v.f[3]) < 1e-6) {
|
||||
weston_log("warning: numerical instability in "
|
||||
"%s(), divisor = %g\n", __func__,
|
||||
v.f[3]);
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
return;
|
||||
}
|
||||
assert(fabs(v.f[3]) > 1e-6);
|
||||
|
||||
*x = v.f[0] / v.f[3];
|
||||
*y = v.f[1] / v.f[3];
|
||||
|
|
@ -1468,14 +1461,7 @@ weston_view_from_global_float(struct weston_view *view,
|
|||
|
||||
weston_matrix_transform(&view->transform.inverse, &v);
|
||||
|
||||
if (fabsf(v.f[3]) < 1e-6) {
|
||||
weston_log("warning: numerical instability in "
|
||||
"weston_view_from_global(), divisor = %g\n",
|
||||
v.f[3]);
|
||||
*vx = 0;
|
||||
*vy = 0;
|
||||
return;
|
||||
}
|
||||
assert(fabs(v.f[3]) > 1e-6);
|
||||
|
||||
*vx = v.f[0] / v.f[3];
|
||||
*vy = v.f[1] / v.f[3];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue