Bug 1624366. Support image surfaces with a last row with < stride bytes. r=lsalzman

We create sub images from larger images by using a stride that matches
the original and adjusting the offset. This creates a situation where
the last row will only have stride - offset bytes. This stops us
from lying to CGDataProvider.

Differential Revision: https://phabricator.services.mozilla.com/D77476
This commit is contained in:
Jeff Muizelaar 2020-05-29 15:17:35 +00:00
parent 365c5302e9
commit f8a0df6679

View file

@ -232,9 +232,15 @@ _cairo_quartz_create_cgimage (cairo_format_t format,
return NULL;
}
// We don't use height * stride because we may have < stride bytes
// in the last row. CGDataProviderCreateWithData checks that the last
// byte is accessible with newer SDKs and it seems like PDF contexts
// will also read the entire buffer. Instead compute the minimum required
// bytes for the last row using cairo_format_stride_for_width.
size_t size = (height - 1) * stride + cairo_format_stride_for_width (format, width);
dataProvider = CGDataProviderCreateWithData (releaseInfo,
data,
height * stride,
size,
releaseCallback);
if (!dataProvider) {