From: Carl Hetherington Date: Thu, 23 Sep 2021 21:54:13 +0000 (+0200) Subject: Check that the image used to make a Cairo::ImageSurface is the right alignment and... X-Git-Tag: v2.15.163~1^2~2 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;ds=sidebyside;h=6e1ceb315f01a233e8c449e649fa44551aa30491;p=dcpomatic.git Check that the image used to make a Cairo::ImageSurface is the right alignment and pixel format. --- diff --git a/src/lib/render_text.cc b/src/lib/render_text.cc index 76c0fb79d..94b412856 100644 --- a/src/lib/render_text.cc +++ b/src/lib/render_text.cc @@ -93,7 +93,9 @@ set_source_rgba (Cairo::RefPtr context, dcp::Colour colour, floa static shared_ptr create_image (dcp::Size size) { - /* FFmpeg BGRA means first byte blue, second byte green, third byte red, fourth byte alpha */ + /* FFmpeg BGRA means first byte blue, second byte green, third byte red, fourth byte alpha. + * This must be COMPACT as we're using it with Cairo::ImageSurface::create + */ auto image = make_shared(AV_PIX_FMT_BGRA, size, Image::Alignment::COMPACT); image->make_black (); return image; @@ -103,6 +105,11 @@ create_image (dcp::Size size) static Cairo::RefPtr create_surface (shared_ptr image) { + /* XXX: I don't think it's guaranteed that format_stride_for_width will return a stride without any padding, + * so it's lucky that this works. + */ + DCPOMATIC_ASSERT (image->alignment() == Image::Alignment::COMPACT); + DCPOMATIC_ASSERT (image->pixel_format() == AV_PIX_FMT_BGRA); return Cairo::ImageSurface::create ( image->data()[0], Cairo::FORMAT_ARGB32,