From 35e2be6cf1d5ce6ecefdfb57317ebf3889bc122fd6e811853fac3193409b5f3d Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger Date: Sat, 6 Apr 2013 15:14:46 +0000 Subject: [PATCH] Accepting request 162152 from home:pgajdos:libpng16 - call png_set_read_user_transform_fn() before png_read_update_info() [bnc#810701] * libpng16-v2.patch OBS-URL: https://build.opensuse.org/request/show/162152 OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/cairo?expand=0&rev=68 --- cairo-libpng16-v2.patch | 52 +++++++++++++++++++++++++++++++++++++++++ cairo.changes | 7 ++++++ cairo.spec | 3 +++ 3 files changed, 62 insertions(+) create mode 100644 cairo-libpng16-v2.patch diff --git a/cairo-libpng16-v2.patch b/cairo-libpng16-v2.patch new file mode 100644 index 0000000..63eabd4 --- /dev/null +++ b/cairo-libpng16-v2.patch @@ -0,0 +1,52 @@ +http://lists.cairographics.org/archives/cairo/2013-March/024195.html +--- src/cairo-png.c 2012-03-29 12:05:32.000000000 +0200 ++++ src/cairo-png.c 2013-03-30 09:13:50.817181600 +0100 +@@ -497,6 +497,20 @@ + } + } + ++/* branches into premultiply_data or convert_bytes_to_data depending on color type */ ++static void read_user_transform_func (png_structp png, png_row_infop row_info, png_bytep data) ++{ ++ switch ((cairo_format_t) png_get_user_transform_ptr (png)) { ++ case CAIRO_FORMAT_ARGB32: ++ premultiply_data (png, row_info, data); ++ break; ++ ++ case CAIRO_FORMAT_RGB24: ++ convert_bytes_to_data (png, row_info, data); ++ break; ++ } ++} ++ + static cairo_status_t + stdio_read_func (void *closure, unsigned char *data, unsigned int size) + { +@@ -623,6 +637,9 @@ + + png_set_filler (png, 0xff, PNG_FILLER_AFTER); + ++ /* this must be stored before calling png_read_update_info */ ++ png_set_read_user_transform_fn (png, read_user_transform_func); ++ + /* recheck header after setting EXPAND options */ + png_read_update_info (png, info); + png_get_IHDR (png, info, +@@ -643,15 +660,15 @@ + + case PNG_COLOR_TYPE_RGB_ALPHA: + format = CAIRO_FORMAT_ARGB32; +- png_set_read_user_transform_fn (png, premultiply_data); + break; + + case PNG_COLOR_TYPE_RGB: + format = CAIRO_FORMAT_RGB24; +- png_set_read_user_transform_fn (png, convert_bytes_to_data); + break; + } + ++ png_set_user_transform_info (png, (void*) format, 0, 0); ++ + stride = cairo_format_stride_for_width (format, png_width); + if (stride < 0) { + surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE)); diff --git a/cairo.changes b/cairo.changes index b17bb6e..7d9faae 100644 --- a/cairo.changes +++ b/cairo.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Apr 2 11:57:02 UTC 2013 - pgajdos@suse.com + +- call png_set_read_user_transform_fn() before png_read_update_info() + [bnc#810701] + * libpng16-v2.patch + ------------------------------------------------------------------- Thu Feb 14 17:42:09 UTC 2013 - zaitor@opensuse.org diff --git a/cairo.spec b/cairo.spec index 03cddac..62ecbe1 100644 --- a/cairo.spec +++ b/cairo.spec @@ -30,6 +30,8 @@ Source: http://cairographics.org/releases/%{name}-%{version}.tar.xz Source99: baselibs.conf # PATCH-FIX-UPSTREAM cairo-modules-no-version.patch fdo#29319 dimstar@opensuse.org -- Build modules with -module -avoid-version. Patch0: cairo-modules-no-version.patch +# PATCH-FIX-UPSTREAM cairo-modules-no-version.patch bnc#810701 pgajdos@suse.com -- call png_set_read_user_transform_fn() before png_read_update_info() +Patch1: cairo-libpng16-v2.patch # These libraries are needed only for tests. # Do not enable tests in build systems, it causes build loop! #BuildRequires: librsvg-devel poppler-devel @@ -148,6 +150,7 @@ cairo. %prep %setup -q %patch0 -p1 +%patch1 %build # Needed by patch0