[mingw-cairo] - Fix corrupted drawing, cherry-picked from upstream (fdo#61876) - Add a few windows related fixes

Marc-André Lureau elmarco at fedoraproject.org
Tue Apr 2 23:00:03 UTC 2013


commit 602fd779ff72e25af2fdf28aaec8b8d71da75aad
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Wed Apr 3 00:51:33 2013 +0200

    - Fix corrupted drawing, cherry-picked from upstream (fdo#61876)
    - Add a few windows related fixes

 ...o-not-try-to-build-util-sphinx-on-Windows.patch |   37 +++++++++++++++
 0001-win32-Free-the-fallback-upon-finish.patch     |   41 +++++++++++++++++
 0002-win32-fix-corrupted-drawing.patch             |   48 ++++++++++++++++++++
 ...o-not-try-to-build-util-sphinx-on-Windows.patch |   37 +++++++++++++++
 mingw-cairo.spec                                   |   17 +++++++-
 5 files changed, 179 insertions(+), 1 deletions(-)
---
diff --git a/0001-build-sys-do-not-try-to-build-util-sphinx-on-Windows.patch b/0001-build-sys-do-not-try-to-build-util-sphinx-on-Windows.patch
new file mode 100644
index 0000000..c29a835
--- /dev/null
+++ b/0001-build-sys-do-not-try-to-build-util-sphinx-on-Windows.patch
@@ -0,0 +1,37 @@
+From 4b69464dde07f2d5c23664499cb61ac984344e66 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau at gmail.com>
+Date: Tue, 2 Apr 2013 21:00:20 +0200
+Subject: [PATCH] build-sys: do not try to build util/sphinx on Windows
+
+glib and dlfcn exist on windows, but sphinx code uses a lot of
+Unix-only API
+
+Fixes the following build error on mingw-fedora
+
+  CC     cairo-boilerplate-system.lo
+../../../util/cairo-sphinx/sphinx.c:8:22: fatal error: sys/mman.h: No such file or directory
+compilation terminated.
+
+https://bugs.freedesktop.org/show_bug.cgi?id=63043
+
+https://bugs.freedesktop.org/show_bug.cgi?id=63044
+---
+ configure.ac | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index 928a169..9a9be60 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -797,7 +797,7 @@ CAIRO_ENABLE(symbol_lookup, symbol-lookup, auto, [
+ PKG_CHECK_MODULES(glib, glib-2.0, have_glib=yes, have_glib=no)
+ AC_SUBST(glib_CFLAGS)
+ AC_SUBST(glib_LIBS)
+-AM_CONDITIONAL(BUILD_SPHINX, test "x$have_glib" = "xyes")
++AM_CONDITIONAL(BUILD_SPHINX, test "x$have_glib" = "xyes" -a "x$have_windows" = "xno")
+ 
+ save_LIBS="$LIBS"
+ AC_CHECK_LIB(rt, shm_open, shm_LIBS="-lrt")
+-- 
+1.8.1.1.439.g50a6b54
+
diff --git a/0001-win32-Free-the-fallback-upon-finish.patch b/0001-win32-Free-the-fallback-upon-finish.patch
new file mode 100644
index 0000000..e170367
--- /dev/null
+++ b/0001-win32-Free-the-fallback-upon-finish.patch
@@ -0,0 +1,41 @@
+From 3fcaddfefa2024e04217e302e72e15dd22014df0 Mon Sep 17 00:00:00 2001
+From: Chris Wilson <chris at chris-wilson.co.uk>
+Date: Fri, 15 Feb 2013 14:04:21 +0000
+Subject: [PATCH 1/3] win32: Free the fallback upon finish
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Zozó Teki pointed out that we leak the fallback surface upon finish in
+case it was active at the time as the preceding flush would only clear
+the damage and not decouple the fallback surface.
+
+Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
+---
+ src/win32/cairo-win32-display-surface.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/win32/cairo-win32-display-surface.c b/src/win32/cairo-win32-display-surface.c
+index ccd285d..0390625 100644
+--- a/src/win32/cairo-win32-display-surface.c
++++ b/src/win32/cairo-win32-display-surface.c
+@@ -429,6 +429,8 @@ _cairo_win32_display_surface_finish (void *abstract_surface)
+ 	DeleteDC (surface->win32.dc);
+     }
+ 
++    _cairo_win32_display_surface_discard_fallback (surface);
++
+     if (surface->initial_clip_rgn)
+ 	DeleteObject (surface->initial_clip_rgn);
+ 
+@@ -758,6 +760,7 @@ _cairo_win32_display_surface_discard_fallback (cairo_win32_display_surface_t *su
+ 	TRACE ((stderr, "%s (surface=%d)\n",
+ 		__FUNCTION__, surface->win32.base.unique_id));
+ 
++	cairo_surface_finish (surface->fallback);
+ 	cairo_surface_destroy (surface->fallback);
+ 	surface->fallback = NULL;
+     }
+-- 
+1.8.1.1.439.g50a6b54
+
diff --git a/0002-win32-fix-corrupted-drawing.patch b/0002-win32-fix-corrupted-drawing.patch
new file mode 100644
index 0000000..75e1b26
--- /dev/null
+++ b/0002-win32-fix-corrupted-drawing.patch
@@ -0,0 +1,48 @@
+From 9f65974bdaafe700930c6cd7de85915a5450b431 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau at gmail.com>
+Date: Tue, 2 Apr 2013 00:32:56 +0200
+Subject: [PATCH 2/3] win32: fix corrupted drawing
+
+Fix src bitmap coordinates, which origin is bottom-left. This is
+apparently a bug in StretchDIBits(), according to some comments on
+MSDN API documentation.
+
+The backend used to have this coordinate change in the past:
+
+            if (!StretchDIBits (dst->dc,
+                                /* dst x,y,w,h */
+                                dst_r.x, dst_r.y + dst_r.height - 1,
+                                dst_r.width, - (int) dst_r.height,
+                                /* src x,y,w,h */
+                                src_r.x, src_extents.height - src_r.y + 1,
+                                src_r.width, - (int) src_r.height,
+                                src_image->data,
+                                &bi,
+                                DIB_RGB_COLORS,
+                                SRCCOPY))
+
+https://bugs.freedesktop.org/show_bug.cgi?id=61876
+---
+ src/win32/cairo-win32-gdi-compositor.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/win32/cairo-win32-gdi-compositor.c b/src/win32/cairo-win32-gdi-compositor.c
+index c70b0f9..073e889 100644
+--- a/src/win32/cairo-win32-gdi-compositor.c
++++ b/src/win32/cairo-win32-gdi-compositor.c
+@@ -151,10 +151,11 @@ static cairo_bool_t upload_box (cairo_box_t *box, void *closure)
+     int y = _cairo_fixed_integer_part (box->p1.y);
+     int width  = _cairo_fixed_integer_part (box->p2.x - box->p1.x);
+     int height = _cairo_fixed_integer_part (box->p2.y - box->p1.y);
++    int src_height = -cb->bi.bmiHeader.biHeight;
+ 
+     TRACE ((stderr, "%s\n", __FUNCTION__));
+     return StretchDIBits (cb->dst, x, y + height - 1, width, -height,
+-			  x + cb->tx,  height - (y + cb->ty - 1),
++			  x + cb->tx,  src_height - (y + cb->ty - 1),
+ 			  width, -height,
+ 			  cb->data, &cb->bi,
+ 			  DIB_RGB_COLORS, SRCCOPY);
+-- 
+1.8.1.1.439.g50a6b54
+
diff --git a/0003-build-sys-do-not-try-to-build-util-sphinx-on-Windows.patch b/0003-build-sys-do-not-try-to-build-util-sphinx-on-Windows.patch
new file mode 100644
index 0000000..738f0dc
--- /dev/null
+++ b/0003-build-sys-do-not-try-to-build-util-sphinx-on-Windows.patch
@@ -0,0 +1,37 @@
+From 332bce6142b313f336e5a714543cc9ea202912e0 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau at gmail.com>
+Date: Tue, 2 Apr 2013 21:00:20 +0200
+Subject: [PATCH 3/3] build-sys: do not try to build util/sphinx on Windows
+
+glib and dlfcn exist on windows, but sphinx code uses a lot of
+Unix-only API
+
+Fixes the following build error on mingw-fedora
+
+  CC     cairo-boilerplate-system.lo
+../../../util/cairo-sphinx/sphinx.c:8:22: fatal error: sys/mman.h: No such file or directory
+compilation terminated.
+
+https://bugs.freedesktop.org/show_bug.cgi?id=63043
+
+https://bugs.freedesktop.org/show_bug.cgi?id=63044
+---
+ configure.ac | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index 928a169..9a9be60 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -797,7 +797,7 @@ CAIRO_ENABLE(symbol_lookup, symbol-lookup, auto, [
+ PKG_CHECK_MODULES(glib, glib-2.0, have_glib=yes, have_glib=no)
+ AC_SUBST(glib_CFLAGS)
+ AC_SUBST(glib_LIBS)
+-AM_CONDITIONAL(BUILD_SPHINX, test "x$have_glib" = "xyes")
++AM_CONDITIONAL(BUILD_SPHINX, test "x$have_glib" = "xyes" -a "x$have_windows" = "xno")
+ 
+ save_LIBS="$LIBS"
+ AC_CHECK_LIB(rt, shm_open, shm_LIBS="-lrt")
+-- 
+1.8.1.1.439.g50a6b54
+
diff --git a/mingw-cairo.spec b/mingw-cairo.spec
index 053ccf7..5e84bc4 100644
--- a/mingw-cairo.spec
+++ b/mingw-cairo.spec
@@ -2,7 +2,7 @@
 
 Name:           mingw-cairo
 Version:        1.12.14
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        MinGW Windows Cairo library
 
 License:        LGPLv2 or MPLv1.1
@@ -37,8 +37,14 @@ BuildRequires:  mingw64-zlib
 BuildRequires:  mingw64-glib2
 
 BuildRequires:  mingw-w64-tools
+BuildRequires:  autoconf automake libtool
 BuildRequires:  pkgconfig
 
+# cherry-picked from upcoming 1.12.15
+Patch1: 0001-win32-Free-the-fallback-upon-finish.patch
+Patch2: 0002-win32-fix-corrupted-drawing.patch
+# https://bugs.freedesktop.org/show_bug.cgi?id=63043
+Patch3: 0003-build-sys-do-not-try-to-build-util-sphinx-on-Windows.patch
 
 %description
 MinGW Windows Cairo library.
@@ -87,6 +93,11 @@ Static version of the MinGW Windows Cairo library.
 %prep
 %setup -q -n cairo-%{version}
 
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+
+autoreconf -vfi
 
 %build
 # Function to generate an import library for delay-loading
@@ -209,6 +220,10 @@ find $RPM_BUILD_ROOT -name "*.la" -delete
 
 
 %changelog
+* Tue Apr  2 2013 Marc-André Lureau <marcandre.lureau at redhat.com> - 1.12.14-2
+- Fix corrupted drawing, cherry-picked from upstream (fdo#61876)
+- Add a few windows related fixes
+
 * Fri Mar 29 2013 Kalev Lember <kalevlember at gmail.com> - 1.12.14-1
 - Update to 1.12.14
 


More information about the scm-commits mailing list