mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 06:28:01 +02:00
subsurface: Don't crash when the device transform isn't integer
Apply the transform before rounding to integer coordinates, so we can handle doubles easily.
This commit is contained in:
parent
e19b213e84
commit
40459dacb5
1 changed files with 4 additions and 6 deletions
|
|
@ -492,7 +492,6 @@ cairo_surface_create_for_rectangle (cairo_surface_t *target,
|
|||
cairo_surface_subsurface_t *surface;
|
||||
cairo_rectangle_int_t target_extents;
|
||||
cairo_bool_t ret;
|
||||
int tx, ty;
|
||||
|
||||
if (unlikely (target->status))
|
||||
return _cairo_surface_create_in_error (target->status);
|
||||
|
|
@ -503,6 +502,10 @@ cairo_surface_create_for_rectangle (cairo_surface_t *target,
|
|||
if (unlikely (surface == NULL))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
assert (_cairo_matrix_is_translation (&target->device_transform));
|
||||
x += target->device_transform.x0;
|
||||
y += target->device_transform.y0;
|
||||
|
||||
_cairo_surface_init (&surface->base,
|
||||
&_cairo_surface_subsurface_backend,
|
||||
NULL, /* device */
|
||||
|
|
@ -514,11 +517,6 @@ cairo_surface_create_for_rectangle (cairo_surface_t *target,
|
|||
surface->extents.width = floor (x + width) - surface->extents.x;
|
||||
surface->extents.height = floor (y + height) - surface->extents.y;
|
||||
|
||||
ret = _cairo_matrix_is_integer_translation (&target->device_transform, &tx, &ty);
|
||||
assert (ret);
|
||||
surface->extents.x += tx;
|
||||
surface->extents.y += ty;
|
||||
|
||||
if (_cairo_surface_get_extents (target, &target_extents))
|
||||
ret = _cairo_rectangle_intersect (&surface->extents, &target_extents);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue