From e52bad5e33e0b69b868525056c95ebd473fd6b10 Mon Sep 17 00:00:00 2001 From: Vladimir Vukicevic Date: Fri, 7 Mar 2008 14:49:15 -0800 Subject: [PATCH] [quartz] split out (experimental) quartz-image into separate file --- configure.in | 15 ++++++++ src/Makefile.am | 5 +++ src/cairo-quartz-image-surface.c | 21 ++++++++---- src/cairo-quartz-image.h | 59 ++++++++++++++++++++++++++++++++ src/cairo-quartz-surface.c | 10 +++--- src/cairo-quartz.h | 6 ---- 6 files changed, 97 insertions(+), 19 deletions(-) create mode 100644 src/cairo-quartz-image.h diff --git a/configure.in b/configure.in index 9feb62181..4f19830ed 100644 --- a/configure.in +++ b/configure.in @@ -342,6 +342,16 @@ CAIRO_BACKEND_ENABLE(quartz, Quartz, quartz, QUARTZ_SURFACE, no, [ quartz_LIBS="-Xlinker -framework -Xlinker Carbon" ]) +CAIRO_BACKEND_ENABLE(quartz_image, Quartz Image, quartz-image, QUARTZ_IMAGE_SURFACE, no, [ + dnl There is no pkgconfig for quartz; lets do a header check + if test "x$use_quartz" != "xyes"; then + use_quartz_image="no (requires --enable-quartz)" + else + dnl we already have the header check and libs required from the quartz surface + use_quartz_image="yes" + fi +]) + dnl =========================================================================== AC_MSG_CHECKING([for native Win32]) @@ -1060,6 +1070,7 @@ echo " image: yes (always builtin)" echo " Xlib: $use_xlib" echo " Xlib Xrender: $use_xlib_xrender" echo " Quartz: $use_quartz" +echo " Quartz-image: $use_quartz_image" echo " XCB: $use_xcb" echo " Win32: $use_win32" echo " OS2: $use_os2" @@ -1121,6 +1132,10 @@ if test x"$use_quartz" = "xyes" ; then echo "$WARNING_MESSAGE" | sed 's/@BACKEND@/Quartz/' fi +if test x"$use_quartz_image" = "xyes" ; then + echo "$WARNING_MESSAGE" | sed 's/@BACKEND@/Quartz Image/' +fi + if test x"$use_atsui" = "xyes" ; then echo "$WARNING_MESSAGE" | sed 's/@BACKEND@/ATSUI/' fi diff --git a/src/Makefile.am b/src/Makefile.am index 3656f0507..79e387703 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -186,6 +186,11 @@ cairo_sources += $(quartz_sources) backend_pkgconfigs += cairo-quartz.pc endif +if CAIRO_HAS_QUARTZ_IMAGE_SURFACE +cairo_headers += cairo-quartz-image.h +backend_pkgconfigs += cairo-quartz-image.pc +endif + os_win32_sources = cairo-win32.c cairo_all_sources += $(os_win32_sources) if OS_WIN32 diff --git a/src/cairo-quartz-image-surface.c b/src/cairo-quartz-image-surface.c index 54b63fc68..541fa827a 100644 --- a/src/cairo-quartz-image-surface.c +++ b/src/cairo-quartz-image-surface.c @@ -36,18 +36,15 @@ #include "cairoint.h" +#ifdef CAIRO_HAS_QUARTZ_IMAGE_SURFACE +#include "cairo-quartz-image.h" +#endif + #include "cairo-quartz-private.h" #define SURFACE_ERROR_NO_MEMORY (_cairo_surface_create_in_error(_cairo_error(CAIRO_STATUS_NO_MEMORY))) #define SURFACE_ERROR_INVALID_FORMAT (_cairo_surface_create_in_error(_cairo_error(CAIRO_STATUS_INVALID_FORMAT))) -static void -DataProviderReleaseCallback (void *info, const void *data, size_t size) -{ - cairo_surface_t *surface = (cairo_surface_t *) info; - cairo_surface_destroy (surface); -} - CGImageRef _cairo_quartz_create_cgimage (cairo_format_t format, unsigned int width, @@ -129,6 +126,14 @@ FINISH: return image; } +#ifdef CAIRO_HAS_QUARTZ_IMAGE_SURFACE + +static void +DataProviderReleaseCallback (void *info, const void *data, size_t size) +{ + cairo_surface_t *surface = (cairo_surface_t *) info; + cairo_surface_destroy (surface); +} static cairo_surface_t * _cairo_quartz_image_surface_create_similar (void *asurface, @@ -368,3 +373,5 @@ cairo_quartz_image_surface_get_image (cairo_surface_t *asurface) return (cairo_surface_t*) surface->imageSurface; } + +#endif /* CAIRO_HAS_QUARTZ_IMAGE_SURFACE */ diff --git a/src/cairo-quartz-image.h b/src/cairo-quartz-image.h new file mode 100644 index 000000000..ae2b2f11f --- /dev/null +++ b/src/cairo-quartz-image.h @@ -0,0 +1,59 @@ +/* cairo - a vector graphics library with display and print output + * + * Copyright © 2008 Mozilla Corporation + * + * This library is free software; you can redistribute it and/or + * modify it either under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * (the "LGPL") or, at your option, under the terms of the Mozilla + * Public License Version 1.1 (the "MPL"). If you do not alter this + * notice, a recipient may use your version of this file under either + * the MPL or the LGPL. + * + * You should have received a copy of the LGPL along with this library + * in the file COPYING-LGPL-2.1; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the MPL along with this library + * in the file COPYING-MPL-1.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY + * OF ANY KIND, either express or implied. See the LGPL or the MPL for + * the specific language governing rights and limitations. + * + * The Original Code is the cairo graphics library. + * + * The Initial Developer of the Original Code is Mozilla Corporation. + * + * Contributor(s): + * Vladimir Vukicevic + */ + +#ifndef CAIRO_QUARTZ_IMAGE_H +#define CAIRO_QUARTZ_IMAGE_H + +#include + +#if CAIRO_HAS_QUARTZ_IMAGE_SURFACE + +#include + +CAIRO_BEGIN_DECLS + +cairo_public cairo_surface_t * +cairo_quartz_image_surface_create (cairo_surface_t *image_surface); + +cairo_public cairo_surface_t * +cairo_quartz_image_surface_get_image (cairo_surface_t *surface); + +CAIRO_END_DECLS + +#else /* CAIRO_HAS_QUARTZ_IMAGE_SURFACE */ +# error Cairo was not compiled with support for the quartz-image backend +#endif /* CAIRO_HAS_QUARTZ_IMAGE_SURFACE */ + +#endif /* CAIRO_QUARTZ_IMAGE_H */ diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c index a9f6580a7..e81b378bd 100644 --- a/src/cairo-quartz-surface.c +++ b/src/cairo-quartz-surface.c @@ -114,8 +114,10 @@ static cairo_bool_t _cairo_quartz_symbol_lookup_done = FALSE; * Utility functions */ +#ifdef QUARTZ_DEBUG static void quartz_surface_to_png (cairo_quartz_surface_t *nq, char *dest); static void quartz_image_to_png (CGImageRef, char *dest); +#endif static cairo_quartz_surface_t * _cairo_quartz_surface_create_internal (CGContextRef cgContext, @@ -2130,12 +2132,9 @@ void ExportCGImageToPNGFile(CGImageRef inImageRef, char* dest) } } -#endif - void quartz_image_to_png (CGImageRef imgref, char *dest) { -#if 0 static int sctr = 0; char sptr[] = "/Users/vladimir/Desktop/barXXXXX.png"; @@ -2147,13 +2146,11 @@ quartz_image_to_png (CGImageRef imgref, char *dest) } ExportCGImageToPNGFile(imgref, dest); -#endif } void quartz_surface_to_png (cairo_quartz_surface_t *nq, char *dest) { -#if 0 static int sctr = 0; char sptr[] = "/Users/vladimir/Desktop/fooXXXXX.png"; @@ -2178,5 +2175,6 @@ quartz_surface_to_png (cairo_quartz_surface_t *nq, char *dest) ExportCGImageToPNGFile(imgref, dest); CGImageRelease(imgref); -#endif } + +#endif /* QUARTZ_DEBUG */ diff --git a/src/cairo-quartz.h b/src/cairo-quartz.h index c0edb0ccd..5d78d3913 100644 --- a/src/cairo-quartz.h +++ b/src/cairo-quartz.h @@ -57,12 +57,6 @@ cairo_quartz_surface_create_for_cg_context (CGContextRef cgContext, cairo_public CGContextRef cairo_quartz_surface_get_cg_context (cairo_surface_t *surface); -cairo_public cairo_surface_t * -cairo_quartz_image_surface_create (cairo_surface_t *image_surface); - -cairo_public cairo_surface_t * -cairo_quartz_image_surface_get_image (cairo_surface_t *surface); - CAIRO_END_DECLS #else /* CAIRO_HAS_QUARTZ_SURFACE */