[cairo-commit] src/cairo-quartz-surface.c
Andrea Canciani
ranma42 at kemper.freedesktop.org
Sat Aug 7 03:40:54 PDT 2010
src/cairo-quartz-surface.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
New commits:
commit de606af5d673df193fc07fbd047ba2cec82d2f1c
Author: Andrea Canciani <ranma42 at gmail.com>
Date: Tue Jul 27 18:04:36 2010 +0200
quartz: improve backend detection
Quartz previously crashed with NULL backends and didn't check for
the backend type when getting a CGContext from a quartz surface,
returning meaningless data for subsurfaces.
diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 7360610..113674f 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -144,6 +144,9 @@ _cairo_quartz_surface_create_internal (CGContextRef cgContext,
unsigned int width,
unsigned int height);
+static cairo_bool_t
+_cairo_surface_is_quartz (const cairo_surface_t *surface);
+
/* Load all extra symbols */
static void quartz_ensure_symbols(void)
{
@@ -1104,15 +1107,14 @@ _cairo_surface_to_cgimage (cairo_surface_t *target,
{
cairo_status_t status;
quartz_source_image_t *source_img;
- cairo_surface_type_t stype = source->backend->type;
- if (stype == CAIRO_SURFACE_TYPE_QUARTZ_IMAGE) {
+ if (source->backend && source->backend->type == CAIRO_SURFACE_TYPE_QUARTZ_IMAGE) {
cairo_quartz_image_surface_t *surface = (cairo_quartz_image_surface_t *) source;
*image_out = CGImageRetain (surface->image);
return CAIRO_STATUS_SUCCESS;
}
- if (stype == CAIRO_SURFACE_TYPE_QUARTZ) {
+ if (_cairo_surface_is_quartz (source)) {
cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) source;
if (IS_EMPTY(surface)) {
*image_out = NULL;
@@ -2007,7 +2009,7 @@ _cairo_quartz_surface_clone_similar (void *abstract_surface,
return CAIRO_STATUS_SUCCESS;
}
- if (src->backend->type == CAIRO_SURFACE_TYPE_QUARTZ) {
+ if (_cairo_surface_is_quartz (src)) {
cairo_quartz_surface_t *qsurf = (cairo_quartz_surface_t *) src;
if (IS_EMPTY(qsurf)) {
@@ -3173,14 +3175,18 @@ cairo_quartz_surface_create (cairo_format_t format,
CGContextRef
cairo_quartz_surface_get_cg_context (cairo_surface_t *surface)
{
- cairo_quartz_surface_t *quartz = (cairo_quartz_surface_t*)surface;
-
- if (cairo_surface_get_type(surface) != CAIRO_SURFACE_TYPE_QUARTZ)
+ if (surface && _cairo_surface_is_quartz (surface)) {
+ cairo_quartz_surface_t *quartz = (cairo_quartz_surface_t *) surface;
+ return quartz->cgContext;
+ } else
return NULL;
-
- return quartz->cgContext;
}
+static cairo_bool_t
+_cairo_surface_is_quartz (const cairo_surface_t *surface)
+{
+ return surface->backend == &cairo_quartz_surface_backend;
+}
/* Debug stuff */
More information about the cairo-commit
mailing list