From 3d3a707f5aeed0ba2ce7c0e981c3a41e321b179c Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Mon, 8 Mar 2010 18:14:56 +0900 Subject: [PATCH 1/7] Bug 550772 - fallback pref font handling for CJK fonts is broken r=jdaggett --- gfx/thebes/public/gfxPlatform.h | 1 + gfx/thebes/src/gfxPlatform.cpp | 15 ++++++--- gfx/thebes/src/nsUnicodeRange.h | 54 +++++++++++++++++---------------- 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/gfx/thebes/public/gfxPlatform.h b/gfx/thebes/public/gfxPlatform.h index 0b62c398229..198aa6d4fdb 100644 --- a/gfx/thebes/public/gfxPlatform.h +++ b/gfx/thebes/public/gfxPlatform.h @@ -67,6 +67,7 @@ class nsIAtom; // pref lang id's for font prefs // !!! needs to match the list of pref font.default.xx entries listed in all.js !!! +// !!! don't use as bit mask, this may grow larger !!! enum eFontPrefLang { eFontPrefLang_Western = 0, diff --git a/gfx/thebes/src/gfxPlatform.cpp b/gfx/thebes/src/gfxPlatform.cpp index 49f414e7f24..32219154367 100644 --- a/gfx/thebes/src/gfxPlatform.cpp +++ b/gfx/thebes/src/gfxPlatform.cpp @@ -549,13 +549,20 @@ gfxPlatform::GetFontPrefLangFor(PRUint8 aUnicodeRange) } } -const PRUint32 kFontPrefLangCJKMask = (1 << (PRUint32) eFontPrefLang_Japanese) | (1 << (PRUint32) eFontPrefLang_ChineseTW) - | (1 << (PRUint32) eFontPrefLang_ChineseCN) | (1 << (PRUint32) eFontPrefLang_ChineseHK) - | (1 << (PRUint32) eFontPrefLang_Korean) | (1 << (PRUint32) eFontPrefLang_CJKSet); PRBool gfxPlatform::IsLangCJK(eFontPrefLang aLang) { - return kFontPrefLangCJKMask & (1 << (PRUint32) aLang); + switch (aLang) { + case eFontPrefLang_Japanese: + case eFontPrefLang_ChineseTW: + case eFontPrefLang_ChineseCN: + case eFontPrefLang_ChineseHK: + case eFontPrefLang_Korean: + case eFontPrefLang_CJKSet: + return PR_TRUE; + default: + return PR_FALSE; + } } void diff --git a/gfx/thebes/src/nsUnicodeRange.h b/gfx/thebes/src/nsUnicodeRange.h index 3cc9e6c16e6..46b424c50f0 100644 --- a/gfx/thebes/src/nsUnicodeRange.h +++ b/gfx/thebes/src/nsUnicodeRange.h @@ -76,35 +76,37 @@ const PRUint8 kRangeTibetan = 26; const PRUint8 kRangeSpecificItemNum = 27; -//range/rangeSet grow to this place 27-30 +//range/rangeSet grow to this place 27-29 -const PRUint8 kRangeSetStart = 31; // range set definition starts from here -const PRUint8 kRangeSetLatin = 31; -const PRUint8 kRangeSetCJK = 32; -const PRUint8 kRangeSetEnd = 32; // range set definition ends here +const PRUint8 kRangeSetStart = 30; // range set definition starts from here +const PRUint8 kRangeSetLatin = 30; +const PRUint8 kRangeSetCJK = 31; +const PRUint8 kRangeSetEnd = 31; // range set definition ends here, this + // and smaller ranges are used as bit + // mask, don't increase this value. // less frequently used range definition -const PRUint8 kRangeSurrogate = 33; -const PRUint8 kRangePrivate = 34; -const PRUint8 kRangeMisc = 35; -const PRUint8 kRangeUnassigned = 36; -const PRUint8 kRangeSyriac = 37; -const PRUint8 kRangeThaana = 38; -const PRUint8 kRangeLao = 39; -const PRUint8 kRangeMyanmar = 40; -const PRUint8 kRangeCherokee = 41; -const PRUint8 kRangeOghamRunic = 42; -const PRUint8 kRangeMongolian = 43; -const PRUint8 kRangeMathOperators = 44; -const PRUint8 kRangeMiscTechnical = 45; -const PRUint8 kRangeControlOpticalEnclose = 46; -const PRUint8 kRangeBoxBlockGeometrics = 47; -const PRUint8 kRangeMiscSymbols = 48; -const PRUint8 kRangeDingbats = 49; -const PRUint8 kRangeBraillePattern = 50; -const PRUint8 kRangeYi = 51; -const PRUint8 kRangeCombiningDiacriticalMarks = 52; -const PRUint8 kRangeSpecials = 53; +const PRUint8 kRangeSurrogate = 32; +const PRUint8 kRangePrivate = 33; +const PRUint8 kRangeMisc = 34; +const PRUint8 kRangeUnassigned = 35; +const PRUint8 kRangeSyriac = 36; +const PRUint8 kRangeThaana = 37; +const PRUint8 kRangeLao = 38; +const PRUint8 kRangeMyanmar = 39; +const PRUint8 kRangeCherokee = 40; +const PRUint8 kRangeOghamRunic = 41; +const PRUint8 kRangeMongolian = 42; +const PRUint8 kRangeMathOperators = 43; +const PRUint8 kRangeMiscTechnical = 44; +const PRUint8 kRangeControlOpticalEnclose = 45; +const PRUint8 kRangeBoxBlockGeometrics = 46; +const PRUint8 kRangeMiscSymbols = 47; +const PRUint8 kRangeDingbats = 48; +const PRUint8 kRangeBraillePattern = 49; +const PRUint8 kRangeYi = 50; +const PRUint8 kRangeCombiningDiacriticalMarks = 51; +const PRUint8 kRangeSpecials = 52; const PRUint8 kRangeTableBase = 128; //values over 127 are reserved for internal use only const PRUint8 kRangeTertiaryTable = 145; // leave room for 16 subtable From c31fc239f4e4901cb4987535478033bb4c2c2a85 Mon Sep 17 00:00:00 2001 From: Ginn Chen Date: Mon, 8 Mar 2010 17:30:40 +0800 Subject: [PATCH 2/7] Bug 538723: run_for_effect is not portable for Bourne shell r=ted.mielczarek --- build/Makefile.in | 4 ++-- build/pymake/tests/include-dynamic.mk | 2 +- extensions/java/xpcom/package/Makefile.in | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/Makefile.in b/build/Makefile.in index e6270fc0e27..d8463af3f8f 100644 --- a/build/Makefile.in +++ b/build/Makefile.in @@ -117,7 +117,7 @@ check:: echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to produce a universal binary!"; \ false; \ fi - @if ! test -f ./unify-test-universal; then \ + @if test ! -f ./unify-test-universal; then \ echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to produce a universal binary!"; \ false; \ fi @@ -136,7 +136,7 @@ check:: echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to unify a Java class file!"; \ false; \ fi - @if ! test -f ./unifytestc.class; then \ + @if test ! -f ./unifytestc.class; then \ echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to unify a Java class file!"; \ false; \ fi diff --git a/build/pymake/tests/include-dynamic.mk b/build/pymake/tests/include-dynamic.mk index 571895dc3c6..5789380e8a0 100644 --- a/build/pymake/tests/include-dynamic.mk +++ b/build/pymake/tests/include-dynamic.mk @@ -1,5 +1,5 @@ $(shell \ -if ! test -f include-dynamic.inc; then \ +if test ! -f include-dynamic.inc; then \ echo "TESTVAR = oldval" > include-dynamic.inc; \ sleep 2; \ echo "TESTVAR = newval" > include-dynamic.inc.in; \ diff --git a/extensions/java/xpcom/package/Makefile.in b/extensions/java/xpcom/package/Makefile.in index ad6806deae0..f2be450516e 100644 --- a/extensions/java/xpcom/package/Makefile.in +++ b/extensions/java/xpcom/package/Makefile.in @@ -73,7 +73,7 @@ stage/javaconnect/.done: javaconnect.js: stage/javaconnect/.done @echo Creating $@... rm -f javaconnect.js - @if ! test -e "javaconnect.jst"; then \ + @if test ! -e "javaconnect.jst"; then \ $(INSTALL) -m 644 $(srcdir)/javaconnect.jst .; \ fi $(PERL) $(topsrcdir)/toolkit/mozapps/installer/makejs.pl javaconnect.jst \ From 51b8057cbc659a9be3e257523dc236031c8701f5 Mon Sep 17 00:00:00 2001 From: Ginn Chen Date: Mon, 8 Mar 2010 17:33:14 +0800 Subject: [PATCH 3/7] Bug 550386: content/base/src/nsFileDataProtocolHandler.cpp failed to compile with SS12 r=bzbarsky --- content/base/src/nsFileDataProtocolHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/base/src/nsFileDataProtocolHandler.cpp b/content/base/src/nsFileDataProtocolHandler.cpp index 513658b310f..314c987fd4b 100644 --- a/content/base/src/nsFileDataProtocolHandler.cpp +++ b/content/base/src/nsFileDataProtocolHandler.cpp @@ -381,7 +381,7 @@ nsFileDataProtocolHandler::NewURI(const nsACString& aSpec, NS_ENSURE_SUCCESS(rv, rv); nsRefPtr uri = - new nsFileDataURI(info ? info->mPrincipal : nsnull, inner); + new nsFileDataURI(info ? info->mPrincipal.get() : nsnull, inner); NS_TryToSetImmutable(uri); *aResult = uri.forget().get(); From b8ef46d2402191e2790532b00e205468e39c40dd Mon Sep 17 00:00:00 2001 From: Ginn Chen Date: Mon, 8 Mar 2010 17:34:55 +0800 Subject: [PATCH 4/7] Bug 550405: [Sun Studio] Mangled name mismatch for LoadInlineStyle and LoadStyleLink (release build only) r=bzbarsky --- layout/style/nsCSSLoader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/layout/style/nsCSSLoader.cpp b/layout/style/nsCSSLoader.cpp index 8a95f85318d..ff21529bc91 100644 --- a/layout/style/nsCSSLoader.cpp +++ b/layout/style/nsCSSLoader.cpp @@ -1819,8 +1819,8 @@ nsresult Loader::LoadInlineStyle(nsIContent* aElement, nsIUnicharInputStream* aStream, PRUint32 aLineNumber, - const nsSubstring& aTitle, - const nsSubstring& aMedia, + const nsAString& aTitle, + const nsAString& aMedia, nsICSSLoaderObserver* aObserver, PRBool* aCompleted, PRBool* aIsAlternate) @@ -1889,8 +1889,8 @@ Loader::LoadInlineStyle(nsIContent* aElement, nsresult Loader::LoadStyleLink(nsIContent* aElement, nsIURI* aURL, - const nsSubstring& aTitle, - const nsSubstring& aMedia, + const nsAString& aTitle, + const nsAString& aMedia, PRBool aHasAlternateRel, nsICSSLoaderObserver* aObserver, PRBool* aIsAlternate) From 42dacb38cb6ba16635b263397a135d2c1a418b3b Mon Sep 17 00:00:00 2001 From: Ginn Chen Date: Mon, 8 Mar 2010 17:35:41 +0800 Subject: [PATCH 5/7] Bug 550154: PGO build issue on Solaris SPARC r=ted.mielczarek --- configure.in | 9 ++------- js/src/configure.in | 9 ++------- xpcom/reflect/xptcall/src/md/unix/Makefile.in | 12 ++++++++---- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/configure.in b/configure.in index b6ed352a269..d041eff7d72 100644 --- a/configure.in +++ b/configure.in @@ -7390,13 +7390,8 @@ dnl Sun Studio on Solaris if test "$SOLARIS_SUNPRO_CC"; then PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application" PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application" - if test "$CPU_ARCH" != "sparc"; then - PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application" - PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application" - else - PROFILE_USE_CFLAGS="-xlinkopt=2 -xprofile=use:$_objdir/$enable_application" - PROFILE_USE_LDFLAGS="-xlinkopt=2 -xprofile=use:$_objdir/$enable_application" - fi + PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application" + PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application" fi AC_SUBST(PROFILE_GEN_CFLAGS) diff --git a/js/src/configure.in b/js/src/configure.in index ceef221347b..1b797b968d8 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -4531,13 +4531,8 @@ dnl Sun Studio on Solaris if test "$SOLARIS_SUNPRO_CC"; then PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application" PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application" - if test "$CPU_ARCH" != "sparc"; then - PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application" - PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application" - else - PROFILE_USE_CFLAGS="-xlinkopt=2 -xprofile=use:$_objdir/$enable_application" - PROFILE_USE_LDFLAGS="-xlinkopt=2 -xprofile=use:$_objdir/$enable_application" - fi + PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application" + PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application" fi AC_SUBST(PROFILE_GEN_CFLAGS) diff --git a/xpcom/reflect/xptcall/src/md/unix/Makefile.in b/xpcom/reflect/xptcall/src/md/unix/Makefile.in index 05237cfd4f0..5f3b7f5c460 100644 --- a/xpcom/reflect/xptcall/src/md/unix/Makefile.in +++ b/xpcom/reflect/xptcall/src/md/unix/Makefile.in @@ -55,6 +55,14 @@ CPPSRCS = $(error XPTCall not implemented on this platform!) # Force use of PIC FORCE_USE_PIC = 1 +ifeq ($(OS_ARCH),SunOS) +ifneq (86,$(findstring 86,$(OS_TEST))) +# disable PGO for this directory with Sun Studio on SPARC because +# compiling with xprofile=collect will insert code into nsXPTCStubBase::Stub##n +NO_PROFILE_GUIDED_OPTIMIZE = 1 +endif +endif + include $(topsrcdir)/config/config.mk ###################################################################### @@ -435,10 +443,6 @@ ASFILES := xptcinvoke_asm_sparc_solaris_GCC.s xptcstubs_asm_sparc_solaris.s endif else -# disable PGO for this directory with Sun Studio on SPARC -# because compiling with xprofile=collect will insert code into nsXPTCStubBase::Stub##n -NO_PROFILE_GUIDED_OPTIMIZE = 1 - ifdef HAVE_64BIT_OS ASFILES := xptcinvoke_asm_sparcv9_solaris_SUNW.s xptcstubs_asm_sparcv9_solaris.s else From e771c422aeea7fad577951205f73538c2c31b9f1 Mon Sep 17 00:00:00 2001 From: Ginn Chen Date: Mon, 8 Mar 2010 17:36:19 +0800 Subject: [PATCH 6/7] Bug 548218: Reference to static function in function templates not allowed with Sun Studio compiler r=bsmedberg --- configure.in | 2 +- js/src/configure.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index d041eff7d72..6b7c4f71b0a 100644 --- a/configure.in +++ b/configure.in @@ -2640,7 +2640,7 @@ alpha*-*-osf*) MOZ_FIX_LINK_PATHS= AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES) CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all" - CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife -norunpath" + CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic -norunpath" LDFLAGS="-xildoff -z lazyload -z combreloc $LDFLAGS" if test -z "$CROSS_COMPILE" && test -f /usr/lib/ld/map.noexstk; then _SAVE_LDFLAGS=$LDFLAGS diff --git a/js/src/configure.in b/js/src/configure.in index 1b797b968d8..254e3e9079f 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -2321,7 +2321,7 @@ alpha*-*-osf*) MOZ_FIX_LINK_PATHS= AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES) CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all" - CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife -norunpath" + CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic -norunpath" LDFLAGS="-xildoff -z lazyload -z combreloc $LDFLAGS" if test -z "$CROSS_COMPILE" && test -f /usr/lib/ld/map.noexstk; then _SAVE_LDFLAGS=$LDFLAGS From f7cd5098d6f59393be28eaca59072fb35fc856bd Mon Sep 17 00:00:00 2001 From: Ginn Chen Date: Mon, 8 Mar 2010 17:37:58 +0800 Subject: [PATCH 7/7] Bug 526976: SIGFPE [@ _moz_cairo_format_stride_for_width] on BGR frame buffer r=jrmuizel --- gfx/cairo/cairo/src/cairo-surface.c | 58 ++++++++++++--------- gfx/cairo/wrap-source_image.patch | 80 ++++++++++++++++------------- 2 files changed, 77 insertions(+), 61 deletions(-) diff --git a/gfx/cairo/cairo/src/cairo-surface.c b/gfx/cairo/cairo/src/cairo-surface.c index ce75a23df01..ed71351b07f 100644 --- a/gfx/cairo/cairo/src/cairo-surface.c +++ b/gfx/cairo/cairo/src/cairo-surface.c @@ -1541,7 +1541,9 @@ static void _wrap_release_source_image (void *data) { struct acquire_source_image_data *acquire_data = data; - _cairo_surface_release_source_image (acquire_data->src, acquire_data->image, acquire_data->image_extra); + _cairo_surface_release_source_image (acquire_data->src, + acquire_data->image, + acquire_data->image_extra); free(data); } @@ -1555,37 +1557,43 @@ _wrap_image (cairo_surface_t *src, cairo_image_surface_t *surface; cairo_status_t status; - struct acquire_source_image_data *data = malloc(sizeof(*data)); + struct acquire_source_image_data *data = malloc (sizeof (*data)); + if (unlikely (data == NULL)) + return _cairo_error (CAIRO_STATUS_NO_MEMORY); data->src = src; data->image = image; data->image_extra = image_extra; - surface = (cairo_image_surface_t*)cairo_image_surface_create_for_data (image->data, - image->format, - image->width, - image->height, - image->stride); + surface = (cairo_image_surface_t*) + _cairo_image_surface_create_with_pixman_format (image->data, + image->pixman_format, + image->width, + image->height, + image->stride); status = surface->base.status; - if (status) - return status; - - status = _cairo_user_data_array_set_data (&surface->base.user_data, - &wrap_image_key, - data, - _wrap_release_source_image); if (status) { - cairo_surface_destroy (&surface->base); + free (data); return status; } - pixman_image_set_component_alpha (surface->pixman_image, - pixman_image_get_component_alpha (image->pixman_image)); + status = _cairo_user_data_array_set_data (&surface->base.user_data, + &wrap_image_key, + data, + _wrap_release_source_image); + if (status) { + cairo_surface_destroy (&surface->base); + free (data); + return status; + } + + pixman_image_set_component_alpha ( + surface->pixman_image, + pixman_image_get_component_alpha (image->pixman_image)); *out = surface; return CAIRO_STATUS_SUCCESS; } - /** * _cairo_surface_clone_similar: * @surface: a #cairo_surface_t @@ -1661,13 +1669,13 @@ _cairo_surface_clone_similar (cairo_surface_t *surface, _cairo_surface_release_source_image (src, image, image_extra); } else { status = - surface->backend->clone_similar (surface, &image->base, - content, - src_x, src_y, - width, height, - clone_offset_x, - clone_offset_y, - clone_out); + surface->backend->clone_similar (surface, &image->base, + content, + src_x, src_y, + width, height, + clone_offset_x, + clone_offset_y, + clone_out); cairo_surface_destroy(&image->base); } } diff --git a/gfx/cairo/wrap-source_image.patch b/gfx/cairo/wrap-source_image.patch index 24a98d91039..89da5a08dc5 100644 --- a/gfx/cairo/wrap-source_image.patch +++ b/gfx/cairo/wrap-source_image.patch @@ -1,15 +1,10 @@ -commit 367aa46142f7c0cf3405814487bbbbc7411b96a4 Author: Jeff Muizelaar -Date: Thu Apr 23 15:42:55 2009 -0400 - - wrap source_image - diff --git a/src/cairo-surface.c b/src/cairo-surface.c -index a4a7084..e4c3752 100644 +index 8278694..12f6242 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c -@@ -1264,6 +1264,63 @@ _cairo_surface_release_dest_image (cairo_surface_t *surface, - image, image_rect, image_extra); +@@ -1530,6 +1530,70 @@ _cairo_recording_surface_clone_similar (cairo_surface_t *surface, + return CAIRO_STATUS_SUCCESS; } +struct acquire_source_image_data @@ -23,7 +18,9 @@ index a4a7084..e4c3752 100644 +_wrap_release_source_image (void *data) +{ + struct acquire_source_image_data *acquire_data = data; -+ _cairo_surface_release_source_image (acquire_data->src, acquire_data->image, acquire_data->image_extra); ++ _cairo_surface_release_source_image (acquire_data->src, ++ acquire_data->image, ++ acquire_data->image_extra); + free(data); +} + @@ -37,59 +34,70 @@ index a4a7084..e4c3752 100644 + cairo_image_surface_t *surface; + cairo_status_t status; + -+ struct acquire_source_image_data *data = malloc(sizeof(*data)); ++ struct acquire_source_image_data *data = malloc (sizeof (*data)); ++ if (unlikely (data == NULL)) ++ return _cairo_error (CAIRO_STATUS_NO_MEMORY); + data->src = src; + data->image = image; + data->image_extra = image_extra; + -+ surface = (cairo_image_surface_t*)cairo_image_surface_create_for_data (image->data, -+ image->format, -+ image->width, -+ image->height, -+ image->stride); ++ surface = (cairo_image_surface_t *) ++ _cairo_image_surface_create_with_pixman_format (image->data, ++ image->pixman_format, ++ image->width, ++ image->height, ++ image->stride); + status = surface->base.status; -+ if (status) -+ return status; -+ -+ status = _cairo_user_data_array_set_data (&surface->base.user_data, -+ &wrap_image_key, -+ data, -+ _wrap_release_source_image); + if (status) { -+ cairo_surface_destroy (&surface->base); ++ free (data); + return status; + } + -+ pixman_image_set_component_alpha (surface->pixman_image, -+ pixman_image_get_component_alpha (surface->pixman_image)); ++ status = _cairo_user_data_array_set_data (&surface->base.user_data, ++ &wrap_image_key, ++ data, ++ _wrap_release_source_image); ++ if (status) { ++ cairo_surface_destroy (&surface->base); ++ free (data); ++ return status; ++ } ++ ++ pixman_image_set_component_alpha ( ++ surface->pixman_image, ++ pixman_image_get_component_alpha (surface->pixman_image)); + + *out = surface; + return CAIRO_STATUS_SUCCESS; +} -+ -+ + /** * _cairo_surface_clone_similar: * @surface: a #cairo_surface_t -@@ -1342,15 +1399,19 @@ _cairo_surface_clone_similar (cairo_surface_t *surface, +@@ -1606,15 +1670,19 @@ _cairo_surface_clone_similar (cairo_surface_t *surface, /* If we failed, try again with an image surface */ status = _cairo_surface_acquire_source_image (src, &image, &image_extra); if (status == CAIRO_STATUS_SUCCESS) { - status = +- surface->backend->clone_similar (surface, &image->base, +- src_x, src_y, +- width, height, +- clone_offset_x, +- clone_offset_y, +- clone_out); +- +- _cairo_surface_release_source_image (src, image, image_extra); + status = _wrap_image(src, image, image_extra, &image); + if (status != CAIRO_STATUS_SUCCESS) { + _cairo_surface_release_source_image (src, image, image_extra); + } else { + status = - surface->backend->clone_similar (surface, &image->base, - src_x, src_y, - width, height, - clone_offset_x, - clone_offset_y, - clone_out); -- -- _cairo_surface_release_source_image (src, image, image_extra); ++ surface->backend->clone_similar (surface, &image->base, ++ src_x, src_y, ++ width, height, ++ clone_offset_x, ++ clone_offset_y, ++ clone_out); + cairo_surface_destroy(&image->base); + } }