summaryrefslogtreecommitdiff
path: root/src/lib/render_text.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-09-23 23:54:13 +0200
committerCarl Hetherington <cth@carlh.net>2021-09-27 13:41:46 +0200
commit6e1ceb315f01a233e8c449e649fa44551aa30491 (patch)
treeb1991a8829f12da5eab5680be6c41cb21ac15923 /src/lib/render_text.cc
parent67ff55886b1ee86d99c2ea27d10c73b85b0504b7 (diff)
Check that the image used to make a Cairo::ImageSurface is the right alignment and pixel format.
Diffstat (limited to 'src/lib/render_text.cc')
-rw-r--r--src/lib/render_text.cc9
1 files changed, 8 insertions, 1 deletions
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<Cairo::Context> context, dcp::Colour colour, floa
static shared_ptr<Image>
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<Image>(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<Cairo::ImageSurface>
create_surface (shared_ptr<Image> 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,