From 0943bf528f223f9ccf2fcb15c87053f694052bfc Mon Sep 17 00:00:00 2001 From: "hk57.kim" Date: Thu, 30 Jun 2016 15:54:38 +0900 Subject: [PATCH 01/16] [T-Trace] Enable T-trace tracing utility for Cairo. By default T-trace is disabled in the build. Use --enable-ttrace=yes for enabling the same. Change-Id: I697c0a3f05bc9010620db563a4121c2ed0e46599 Signed-off-by: hk57.kim --- boilerplate/Makefile.win32.features | 9 + build/Makefile.win32.features | 1 + build/Makefile.win32.features-h | 3 + build/configure.ac.features | 1 + configure.ac | 16 ++ packaging/cairo.spec | 2 + src/Makefile.win32.features | 9 + src/cairo-compositor.c | 77 +++++--- src/cairo-default-context.c | 50 +++-- src/cairo-device.c | 16 +- src/cairo-egl-context.c | 53 +++-- src/cairo-gl-composite.c | 43 ++-- src/cairo-gl-device.c | 118 ++++++++--- src/cairo-gl-msaa-compositor.c | 112 ++++++++--- src/cairo-gl-surface.c | 246 ++++++++++++++++++----- src/cairo-gstate.c | 96 +++++++-- src/cairo-image-surface.c | 104 ++++++++-- src/cairo-png.c | 23 ++- src/cairo-region.c | 23 ++- src/cairo-surface.c | 384 +++++++++++++++++++++++++++--------- src/cairo-traps-compositor.c | 35 +++- src/cairo-ttrace.h | 47 +++++ src/cairo.c | 272 +++++++++++++++++++++---- 23 files changed, 1385 insertions(+), 355 deletions(-) create mode 100644 src/cairo-ttrace.h diff --git a/boilerplate/Makefile.win32.features b/boilerplate/Makefile.win32.features index 6087bff..c93b3b8 100644 --- a/boilerplate/Makefile.win32.features +++ b/boilerplate/Makefile.win32.features @@ -540,6 +540,15 @@ enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_trace_cxx_sources) enabled_cairo_boilerplate_sources += $(cairo_boilerplate_trace_sources) endif +all_cairo_boilerplate_private += $(cairo_boilerplate_ttrace_private) $(cairo_boilerplate_ttrace_headers) +all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_ttrace_cxx_sources) +all_cairo_boilerplate_sources += $(cairo_boilerplate_ttrace_sources) +ifeq ($(CAIRO_HAS_TTRACE),1) +enabled_cairo_boilerplate_private += $(cairo_boilerplate_ttrace_private) $(cairo_boilerplate_ttrace_headers) +enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_ttrace_cxx_sources) +enabled_cairo_boilerplate_sources += $(cairo_boilerplate_ttrace_sources) +endif + all_cairo_boilerplate_private += $(cairo_boilerplate_interpreter_private) $(cairo_boilerplate_interpreter_headers) all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_interpreter_cxx_sources) all_cairo_boilerplate_sources += $(cairo_boilerplate_interpreter_sources) diff --git a/build/Makefile.win32.features b/build/Makefile.win32.features index 5a5848d..be59490 100644 --- a/build/Makefile.win32.features +++ b/build/Makefile.win32.features @@ -40,5 +40,6 @@ CAIRO_HAS_XML_SURFACE=0 CAIRO_HAS_PTHREAD=0 CAIRO_HAS_GOBJECT_FUNCTIONS=0 CAIRO_HAS_TRACE=0 +CAIRO_HAS_TTRACE=0 CAIRO_HAS_INTERPRETER=1 CAIRO_HAS_SYMBOL_LOOKUP=0 diff --git a/build/Makefile.win32.features-h b/build/Makefile.win32.features-h index 6c0e91f..ed33c7c 100644 --- a/build/Makefile.win32.features-h +++ b/build/Makefile.win32.features-h @@ -130,6 +130,9 @@ endif ifeq ($(CAIRO_HAS_TRACE),1) @echo "#define CAIRO_HAS_TRACE 1" >> $(top_srcdir)/src/cairo-features.h endif +ifeq ($(CAIRO_HAS_TTRACE),1) + @echo "#define CAIRO_HAS_TTRACE 1" >> $(top_srcdir)/src/cairo-features.h +endif ifeq ($(CAIRO_HAS_INTERPRETER),1) @echo "#define CAIRO_HAS_INTERPRETER 1" >> $(top_srcdir)/src/cairo-features.h endif diff --git a/build/configure.ac.features b/build/configure.ac.features index adb840f..baac63e 100644 --- a/build/configure.ac.features +++ b/build/configure.ac.features @@ -410,6 +410,7 @@ AC_DEFUN([CAIRO_REPORT], echo "" echo "The following features and utilities:" echo " cairo-trace: $use_trace" + echo " cairo-ttrace: $use_ttrace" echo " cairo-script-interpreter: $use_interpreter" echo "" echo "And the following internal features:" diff --git a/configure.ac b/configure.ac index 0d85c2f..ef5725f 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,16 @@ AC_CHECK_LIB(z, compress, [have_libz="no (requires zlib http://www.gzip.org/zlib/)"])], [have_libz="no (requires zlib http://www.gzip.org/zlib/)"]) +AC_CHECK_LIB(ttrace, traceBegin, + [AC_CHECK_HEADER(ttrace.h, [ + have_ttrace=yes + AC_DEFINE(HAVE_TTRACE, 1, [Define to 1 if you have ttrace available]) + ttrace_LIBS="-lttrace" + ], + [have_ttrace="no (requires ttrace)"])], + [have_ttrace="no (requires ttraec)"]) +LIBS="$ttrace_LIBS $LIBS" + AC_CHECK_LIB(wayland-client, wl_display_connect, [AC_CHECK_HEADER(wayland-client.h, [ have_wayland=yes @@ -843,6 +853,12 @@ CAIRO_ENABLE(trace, cairo-trace, auto, [ fi ]) +CAIRO_ENABLE(ttrace, cairo-ttrace, no, [ + if test "x$have_ttrace" != "xyes"; then + use_ttrace="no (requires ttrace)" + fi +]) + CAIRO_ENABLE(interpreter, cairo-script-interpreter, yes, [ if test "x$have_libz" != "xyes"; then use_interpreter="no (requires zlib)" diff --git a/packaging/cairo.spec b/packaging/cairo.spec index 3d6bc60..51c24f7 100644 --- a/packaging/cairo.spec +++ b/packaging/cairo.spec @@ -27,6 +27,7 @@ BuildRequires: pkgconfig(pixman-1) BuildRequires: which BuildRequires: pkgconfig(ecore) BuildRequires: pkgconfig(evas) +BuildRequires: pkgconfig(ttrace) %if %{with cairo_gl_backend} %if %{with x} && %{with desktop} BuildRequires: pkgconfig(gl) @@ -142,6 +143,7 @@ NOCONFIGURE=1 ./autogen.sh --enable-script=yes \ --enable-svg=yes \ --enable-tee=no \ + --enable-ttrace=no \ %if %{with wayland} && !%{with x} --disable-xlib \ --disable-xcb \ diff --git a/src/Makefile.win32.features b/src/Makefile.win32.features index fe7627c..5f08272 100644 --- a/src/Makefile.win32.features +++ b/src/Makefile.win32.features @@ -690,6 +690,15 @@ enabled_cairo_cxx_sources += $(cairo_trace_cxx_sources) enabled_cairo_sources += $(cairo_trace_sources) endif +all_cairo_private += $(cairo_ttrace_private) $(cairo_ttrace_headers) +all_cairo_cxx_sources += $(cairo_ttrace_cxx_sources) +all_cairo_sources += $(cairo_ttrace_sources) +ifeq ($(CAIRO_HAS_TTRACE),1) +enabled_cairo_private += $(cairo_ttrace_private) $(cairo_ttrace_headers) +enabled_cairo_cxx_sources += $(cairo_ttrace_cxx_sources) +enabled_cairo_sources += $(cairo_ttrace_sources) +endif + all_cairo_private += $(cairo_interpreter_private) $(cairo_interpreter_headers) all_cairo_cxx_sources += $(cairo_interpreter_cxx_sources) all_cairo_sources += $(cairo_interpreter_sources) diff --git a/src/cairo-compositor.c b/src/cairo-compositor.c index 0c4d34c..32ca8d8 100644 --- a/src/cairo-compositor.c +++ b/src/cairo-compositor.c @@ -40,6 +40,7 @@ #include "cairo-compositor-private.h" #include "cairo-damage-private.h" #include "cairo-error-private.h" +#include "cairo-ttrace.h" cairo_int_status_t _cairo_compositor_paint (const cairo_compositor_t *compositor, @@ -48,6 +49,7 @@ _cairo_compositor_paint (const cairo_compositor_t *compositor, const cairo_pattern_t *source, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_composite_rectangles_t extents; cairo_int_status_t status; cairo_bool_t initialized = TRUE; @@ -66,8 +68,10 @@ _cairo_compositor_paint (const cairo_compositor_t *compositor, surface, op, source, clip); - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } do { while (compositor->paint == NULL) @@ -82,8 +86,10 @@ _cairo_compositor_paint (const cairo_compositor_t *compositor, clip); initialized = TRUE; - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } } status = compositor->paint (compositor, &extents); @@ -102,6 +108,7 @@ _cairo_compositor_paint (const cairo_compositor_t *compositor, _cairo_composite_rectangles_fini (&extents); + CAIRO_TRACE_END (__func__); return status; } @@ -113,6 +120,7 @@ _cairo_compositor_mask (const cairo_compositor_t *compositor, const cairo_pattern_t *mask, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_composite_rectangles_t extents; cairo_int_status_t status; cairo_bool_t initialized = TRUE; @@ -130,8 +138,10 @@ _cairo_compositor_mask (const cairo_compositor_t *compositor, surface, op, source, mask, clip); - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } do { while (compositor->mask == NULL) @@ -146,8 +156,10 @@ _cairo_compositor_mask (const cairo_compositor_t *compositor, mask, clip); initialized = TRUE; - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } } status = compositor->mask (compositor, &extents); @@ -166,6 +178,7 @@ _cairo_compositor_mask (const cairo_compositor_t *compositor, _cairo_composite_rectangles_fini (&extents); + CAIRO_TRACE_END (__func__); return status; } @@ -182,14 +195,17 @@ _cairo_compositor_stroke (const cairo_compositor_t *compositor, cairo_antialias_t antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_composite_rectangles_t extents; cairo_int_status_t status; cairo_bool_t initialized = TRUE; TRACE ((stderr, "%s\n", __FUNCTION__)); - if (_cairo_pen_vertices_needed (tolerance, style->line_width/2, ctm) <= 1) - return CAIRO_INT_STATUS_NOTHING_TO_DO; + if (_cairo_pen_vertices_needed (tolerance, style->line_width/2, ctm) <= 1) { + CAIRO_TRACE_END (__func__); + return CAIRO_INT_STATUS_NOTHING_TO_DO; + } if (compositor->lazy_init) { status = _cairo_composite_rectangles_lazy_init_for_stroke (&extents, @@ -205,8 +221,10 @@ _cairo_compositor_stroke (const cairo_compositor_t *compositor, op, source, path, style, ctm, clip); - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } do { while (compositor->stroke == NULL) @@ -225,8 +243,10 @@ _cairo_compositor_stroke (const cairo_compositor_t *compositor, clip); initialized = TRUE; - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } } status = compositor->stroke (compositor, &extents, @@ -247,6 +267,7 @@ _cairo_compositor_stroke (const cairo_compositor_t *compositor, _cairo_composite_rectangles_fini (&extents); + CAIRO_TRACE_END (__func__); return status; } @@ -261,6 +282,7 @@ _cairo_compositor_fill (const cairo_compositor_t *compositor, cairo_antialias_t antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_composite_rectangles_t extents; cairo_int_status_t status; cairo_bool_t initialized = TRUE; @@ -279,8 +301,10 @@ _cairo_compositor_fill (const cairo_compositor_t *compositor, surface, op, source, path, clip); - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } do { while (compositor->fill == NULL) @@ -295,8 +319,10 @@ _cairo_compositor_fill (const cairo_compositor_t *compositor, path, clip); initialized = TRUE; - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } } status = compositor->fill (compositor, &extents, @@ -316,6 +342,7 @@ _cairo_compositor_fill (const cairo_compositor_t *compositor, _cairo_composite_rectangles_fini (&extents); + CAIRO_TRACE_END (__func__); return status; } @@ -329,6 +356,7 @@ _cairo_compositor_glyphs (const cairo_compositor_t *compositor, cairo_scaled_font_t *scaled_font, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_composite_rectangles_t extents; cairo_bool_t overlap; cairo_int_status_t status; @@ -349,8 +377,10 @@ _cairo_compositor_glyphs (const cairo_compositor_t *compositor, scaled_font, glyphs, num_glyphs, clip, &overlap); - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } do { while (compositor->glyphs == NULL) @@ -366,8 +396,10 @@ _cairo_compositor_glyphs (const cairo_compositor_t *compositor, clip, &overlap); initialized = TRUE; - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } } status = compositor->glyphs (compositor, &extents, @@ -387,5 +419,6 @@ _cairo_compositor_glyphs (const cairo_compositor_t *compositor, _cairo_composite_rectangles_fini (&extents); + CAIRO_TRACE_END (__func__); return status; } diff --git a/src/cairo-default-context.c b/src/cairo-default-context.c index 4b63d53..26644ea 100644 --- a/src/cairo-default-context.c +++ b/src/cairo-default-context.c @@ -49,6 +49,7 @@ #include "cairo-freed-pool-private.h" #include "cairo-path-private.h" #include "cairo-pattern-private.h" +#include "cairo-ttrace.h" #define CAIRO_TOLERANCE_MINIMUM _cairo_fixed_to_double(1) @@ -88,6 +89,7 @@ _cairo_default_context_fini (cairo_default_context_t *cr) static void _cairo_default_context_destroy (void *abstract_cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_default_context_t *cr = abstract_cr; _cairo_default_context_fini (cr); @@ -95,6 +97,7 @@ _cairo_default_context_destroy (void *abstract_cr) /* mark the context as invalid to protect against misuse */ cr->base.status = CAIRO_STATUS_NULL_POINTER; _freed_pool_put (&context_pool, cr); + CAIRO_TRACE_END (__func__); } static cairo_surface_t * @@ -288,24 +291,32 @@ _current_source_matches_solid (const cairo_pattern_t *pattern, static cairo_status_t _cairo_default_context_set_source_rgba (void *abstract_cr, double red, double green, double blue, double alpha) { + CAIRO_TRACE_BEGIN (__func__); cairo_default_context_t *cr = abstract_cr; cairo_pattern_t *pattern; cairo_status_t status; if (_current_source_matches_solid (cr->gstate->source, - red, green, blue, alpha)) - return CAIRO_STATUS_SUCCESS; + red, green, blue, alpha)) { + CAIRO_TRACE_END (__func__); + return CAIRO_STATUS_SUCCESS; + } /* push the current pattern to the freed lists */ _cairo_default_context_set_source (cr, (cairo_pattern_t *) &_cairo_pattern_black); pattern = cairo_pattern_create_rgba (red, green, blue, alpha); - if (unlikely (pattern->status)) - return pattern->status; + if (unlikely (pattern->status)) { + status = pattern->status; + cairo_pattern_destroy (pattern); + CAIRO_TRACE_END (__func__); + return pattern->status; + } status = _cairo_default_context_set_source (cr, pattern); cairo_pattern_destroy (pattern); + CAIRO_TRACE_END (__func__); return status; } @@ -324,8 +335,11 @@ _cairo_default_context_set_source_surface (void *abstract_cr, _cairo_default_context_set_source (cr, (cairo_pattern_t *) &_cairo_pattern_black); pattern = cairo_pattern_create_for_surface (surface); - if (unlikely (pattern->status)) - return pattern->status; + if (unlikely (pattern->status)) { + status = pattern->status; + cairo_pattern_destroy (pattern); + return status; + } cairo_matrix_init_translate (&matrix, -x, -y); cairo_pattern_set_matrix (pattern, &matrix); @@ -1122,9 +1136,12 @@ _cairo_default_context_append_path (void *abstract_cr, static cairo_status_t _cairo_default_context_paint (void *abstract_cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_default_context_t *cr = abstract_cr; - return _cairo_gstate_paint (cr->gstate); + cairo_status_t status = _cairo_gstate_paint (cr->gstate); + CAIRO_TRACE_END (__func__); + return status; } static cairo_status_t @@ -1220,7 +1237,7 @@ _cairo_default_context_fill (void *abstract_cr) { cairo_default_context_t *cr = abstract_cr; cairo_status_t status; - + status = _cairo_gstate_fill (cr->gstate, cr->path); if (unlikely (status)) return status; @@ -1695,21 +1712,26 @@ _cairo_default_context_init (cairo_default_context_t *cr, void *target) cairo_t * _cairo_default_context_create (void *target) { + CAIRO_TRACE_BEGIN (__func__); cairo_default_context_t *cr; cairo_status_t status; cr = _freed_pool_get (&context_pool); if (unlikely (cr == NULL)) { - cr = malloc (sizeof (cairo_default_context_t)); - if (unlikely (cr == NULL)) - return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); - } + cr = malloc (sizeof (cairo_default_context_t)); + if (unlikely (cr == NULL)) { + CAIRO_TRACE_END (__func__); + return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); + } + } status = _cairo_default_context_init (cr, target); if (unlikely (status)) { - _freed_pool_put (&context_pool, cr); - return _cairo_create_in_error (status); + _freed_pool_put (&context_pool, cr); + CAIRO_TRACE_END (__func__); + return _cairo_create_in_error (status); } + CAIRO_TRACE_END (__func__); return &cr->base; } diff --git a/src/cairo-device.c b/src/cairo-device.c index b4d1f84..d858650 100644 --- a/src/cairo-device.c +++ b/src/cairo-device.c @@ -37,6 +37,7 @@ #include "cairo-device-private.h" #include "cairo-error-private.h" #include "cairo-list-inline.h" +#include "cairo-ttrace.h" /** * SECTION:cairo-device @@ -170,6 +171,7 @@ void _cairo_device_init (cairo_device_t *device, const cairo_device_backend_t *backend) { + CAIRO_TRACE_BEGIN (__func__); CAIRO_REFERENCE_COUNT_INIT (&device->ref_count, 1); device->status = CAIRO_STATUS_SUCCESS; @@ -184,6 +186,7 @@ _cairo_device_init (cairo_device_t *device, cairo_list_init (&device->shadow_caches); device->shadow_caches_size = 0; + CAIRO_TRACE_END (__func__); } /** @@ -331,22 +334,26 @@ slim_hidden_def (cairo_device_finish); void cairo_device_destroy (cairo_device_t *device) { + CAIRO_TRACE_BEGIN (__func__); cairo_user_data_array_t user_data; if (device == NULL || CAIRO_REFERENCE_COUNT_IS_INVALID (&device->ref_count)) { - return; + CAIRO_TRACE_END (__func__); + return; } assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&device->ref_count)); - if (! _cairo_reference_count_dec_and_test (&device->ref_count)) - return; + if (! _cairo_reference_count_dec_and_test (&device->ref_count)) { + CAIRO_TRACE_END (__func__); + return; + } while (! cairo_list_is_empty (&device->shadow_caches)) { cairo_shadow_cache_t *shadow; - shadow = cairo_list_first_entry (&device->shadow_caches, + shadow = cairo_list_first_entry (&device->shadow_caches, cairo_shadow_cache_t, link); @@ -366,6 +373,7 @@ cairo_device_destroy (cairo_device_t *device) device->backend->destroy (device); _cairo_user_data_array_fini (&user_data); + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_device_destroy); diff --git a/src/cairo-egl-context.c b/src/cairo-egl-context.c index 0a13c6a..5884f61 100644 --- a/src/cairo-egl-context.c +++ b/src/cairo-egl-context.c @@ -41,6 +41,7 @@ #include "cairo-gl-private.h" #include "cairo-error-private.h" +#include "cairo-ttrace.h" #if CAIRO_HAS_EVASGL_SURFACE && CAIRO_HAS_GLESV2_SURFACE extern void glActiveTexture (GLenum texture); @@ -179,21 +180,25 @@ static void _egl_swap_buffers (void *abstract_ctx, cairo_gl_surface_t *abstract_surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_egl_context_t *ctx = abstract_ctx; cairo_egl_surface_t *surface = (cairo_egl_surface_t *) abstract_surface; eglSwapBuffers (ctx->display, surface->egl); + CAIRO_TRACE_END (__func__); } static void _egl_destroy (void *abstract_ctx) { + CAIRO_TRACE_BEGIN (__func__); cairo_egl_context_t *ctx = abstract_ctx; eglMakeCurrent (ctx->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); if (ctx->dummy_surface != EGL_NO_SURFACE) eglDestroySurface (ctx->display, ctx->dummy_surface); + CAIRO_TRACE_END (__func__); } static cairo_bool_t @@ -269,6 +274,7 @@ _cairo_egl_get_proc_address (void *data, const char *name) cairo_device_t * cairo_egl_device_create (EGLDisplay dpy, EGLContext egl) { + CAIRO_TRACE_BEGIN (__func__); cairo_egl_context_t *ctx; cairo_status_t status; int attribs[] = { @@ -280,8 +286,10 @@ cairo_egl_device_create (EGLDisplay dpy, EGLContext egl) EGLint numConfigs; ctx = calloc (1, sizeof (cairo_egl_context_t)); - if (unlikely (ctx == NULL)) - return _cairo_gl_context_create_in_error (CAIRO_STATUS_NO_MEMORY); + if (unlikely (ctx == NULL)) { + CAIRO_TRACE_END (__func__); + return _cairo_gl_context_create_in_error (CAIRO_STATUS_NO_MEMORY); + } ctx->display = dpy; ctx->context = egl; @@ -315,11 +323,13 @@ cairo_egl_device_create (EGLDisplay dpy, EGLContext egl) ctx->dummy_surface = eglCreatePbufferSurface (dpy, config, attribs); if (ctx->dummy_surface == NULL) { free (ctx); + CAIRO_TRACE_END (__func__); return _cairo_gl_context_create_in_error (CAIRO_STATUS_NO_MEMORY); } if (!eglMakeCurrent (dpy, ctx->dummy_surface, ctx->dummy_surface, egl)) { free (ctx); + CAIRO_TRACE_END (__func__); return _cairo_gl_context_create_in_error (CAIRO_STATUS_NO_MEMORY); } } @@ -327,16 +337,18 @@ cairo_egl_device_create (EGLDisplay dpy, EGLContext egl) status = _cairo_gl_dispatch_init (&ctx->base.dispatch, _cairo_egl_get_proc_address, NULL); if (unlikely (status)) { - free (ctx); - return _cairo_gl_context_create_in_error (status); + free (ctx); + CAIRO_TRACE_END (__func__); + return _cairo_gl_context_create_in_error (status); } status = _cairo_gl_context_init (&ctx->base); if (unlikely (status)) { - if (ctx->dummy_surface != EGL_NO_SURFACE) - eglDestroySurface (dpy, ctx->dummy_surface); - free (ctx); - return _cairo_gl_context_create_in_error (status); + if (ctx->dummy_surface != EGL_NO_SURFACE) + eglDestroySurface (dpy, ctx->dummy_surface); + free (ctx); + CAIRO_TRACE_END (__func__); + return _cairo_gl_context_create_in_error (status); } /* Tune the default VBO size to reduce overhead on embedded devices. @@ -349,6 +361,7 @@ cairo_egl_device_create (EGLDisplay dpy, EGLContext egl) ctx->current_surface = EGL_NO_SURFACE; + CAIRO_TRACE_END (__func__); return &ctx->base.base; } @@ -358,25 +371,35 @@ cairo_gl_surface_create_for_egl (cairo_device_t *device, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_egl_surface_t *surface; - if (unlikely (device->status)) - return _cairo_surface_create_in_error (device->status); + if (unlikely (device->status)) { + CAIRO_TRACE_END (__func__); + return _cairo_surface_create_in_error (device->status); + } - if (device->backend->type != CAIRO_DEVICE_TYPE_GL) - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH)); + if (device->backend->type != CAIRO_DEVICE_TYPE_GL) { + CAIRO_TRACE_END (__func__); + return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH)); + } - if (width <= 0 || height <= 0) + if (width <= 0 || height <= 0) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); + } surface = calloc (1, sizeof (cairo_egl_surface_t)); - if (unlikely (surface == NULL)) - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); + if (unlikely (surface == NULL)) { + CAIRO_TRACE_END (__func__); + return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); + } _cairo_gl_surface_init (device, &surface->base, CAIRO_CONTENT_COLOR_ALPHA, width, height); surface->egl = egl; + CAIRO_TRACE_END (__func__); return &surface->base.base; } diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c index e8c0137..0683862 100644 --- a/src/cairo-gl-composite.c +++ b/src/cairo-gl-composite.c @@ -51,6 +51,7 @@ #include "cairo-clip-private.h" #include "cairo-error-private.h" #include "cairo-image-surface-private.h" +#include "cairo-ttrace.h" cairo_int_status_t _cairo_gl_composite_set_source (cairo_gl_composite_t *setup, @@ -76,7 +77,7 @@ _cairo_gl_composite_set_source_operand (cairo_gl_composite_t *setup, _cairo_gl_operand_copy (&setup->src, source); if (source->type == CAIRO_GL_OPERAND_TEXTURE || source->type == CAIRO_GL_OPERAND_GAUSSIAN) - status = _cairo_gl_surface_resolve_multisampling (source->texture.surface); + status = _cairo_gl_surface_resolve_multisampling (source->texture.surface); } void @@ -112,7 +113,7 @@ _cairo_gl_composite_set_mask_operand (cairo_gl_composite_t *setup, _cairo_gl_operand_copy (&setup->mask, mask); if (mask->type == CAIRO_GL_OPERAND_TEXTURE || mask->type == CAIRO_GL_OPERAND_GAUSSIAN) - status = _cairo_gl_surface_resolve_multisampling (mask->texture.surface); + status = _cairo_gl_surface_resolve_multisampling (mask->texture.surface); } } @@ -830,14 +831,17 @@ cairo_status_t _cairo_gl_composite_begin (cairo_gl_composite_t *setup, cairo_gl_context_t **ctx_out) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_context_t *ctx; cairo_status_t status; assert (setup->dst); status = _cairo_gl_context_acquire (setup->dst->base.device, &ctx); - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } setup->dst->content_cleared = FALSE; @@ -862,12 +866,14 @@ FAIL: if (unlikely (status)) status = _cairo_gl_context_release (ctx, status); + CAIRO_TRACE_END (__func__); return status; } static inline void _cairo_gl_composite_draw_tristrip (cairo_gl_context_t *ctx) { + CAIRO_TRACE_BEGIN (__func__); cairo_array_t* indices = &ctx->tristrip_indices; const unsigned short *indices_array = _cairo_array_index_const (indices, 0); @@ -890,11 +896,13 @@ _cairo_gl_composite_draw_tristrip (cairo_gl_context_t *ctx) ctx->dispatch.DrawElements (GL_TRIANGLE_STRIP, _cairo_array_num_elements (indices), GL_UNSIGNED_SHORT, ctx->ibo ? 0 :indices_array); _cairo_array_truncate (indices, 0); + CAIRO_TRACE_END (__func__); } static inline void _cairo_gl_composite_draw_line (cairo_gl_context_t *ctx) { + CAIRO_TRACE_BEGIN (__func__); GLenum type = GL_LINE_STRIP; cairo_array_t* indices = &ctx->tristrip_indices; const unsigned short *indices_array = _cairo_array_index_const (indices, 0); @@ -921,12 +929,14 @@ _cairo_gl_composite_draw_line (cairo_gl_context_t *ctx) ctx->dispatch.DrawElements (type, _cairo_array_num_elements (indices), GL_UNSIGNED_SHORT, ctx->ibo ? 0 : indices_array); _cairo_array_truncate (indices, 0); + CAIRO_TRACE_END (__func__); } static inline void _cairo_gl_composite_draw_triangles (cairo_gl_context_t *ctx, unsigned int count) { + CAIRO_TRACE_BEGIN (__func__); if (! ctx->pre_shader) { ctx->dispatch.DrawArrays (GL_TRIANGLES, 0, count); } else { @@ -940,17 +950,20 @@ _cairo_gl_composite_draw_triangles (cairo_gl_context_t *ctx, _cairo_gl_set_operator (ctx, CAIRO_OPERATOR_ADD, TRUE); ctx->dispatch.DrawArrays (GL_TRIANGLES, 0, count); } + CAIRO_TRACE_END (__func__); } static void _cairo_gl_composite_draw_triangles_with_clip_region (cairo_gl_context_t *ctx, unsigned int count) { + CAIRO_TRACE_BEGIN (__func__); int i, num_rectangles; if (!ctx->clip_region) { - _cairo_gl_composite_draw_triangles (ctx, count); - return; + _cairo_gl_composite_draw_triangles (ctx, count); + CAIRO_TRACE_END (__func__); + return; } num_rectangles = cairo_region_num_rectangles (ctx->clip_region); @@ -963,6 +976,7 @@ _cairo_gl_composite_draw_triangles_with_clip_region (cairo_gl_context_t *ctx, _enable_scissor_buffer (ctx); _cairo_gl_composite_draw_triangles (ctx, count); } + CAIRO_TRACE_END (__func__); } static void @@ -979,14 +993,14 @@ _cairo_gl_composite_unmap_vertex_buffer (cairo_gl_context_t *ctx) void _cairo_gl_composite_flush (cairo_gl_context_t *ctx) { + CAIRO_TRACE_BEGIN (__func__); unsigned int count; int i; - if (_cairo_gl_context_is_flushed (ctx)) + if (_cairo_gl_context_is_flushed (ctx)) { + CAIRO_TRACE_END (__func__); return; - - /* ensure we are binding to vbo and ibo */ - _cairo_gl_ensure_drawbuffers (ctx); + } count = ctx->vb_offset / ctx->vertex_size; @@ -1007,6 +1021,7 @@ _cairo_gl_composite_flush (cairo_gl_context_t *ctx) _cairo_gl_glyph_cache_unlock (&ctx->glyph_cache[i]); _cairo_gl_image_cache_unlock (ctx); + CAIRO_TRACE_END (__func__); } static void @@ -1482,18 +1497,22 @@ _cairo_gl_composite_init (cairo_gl_composite_t *setup, cairo_gl_surface_t *dst, cairo_bool_t assume_component_alpha) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; memset (setup, 0, sizeof (cairo_gl_composite_t)); status = _cairo_gl_composite_set_operator (setup, op, assume_component_alpha); - if (status) - return status; + if (status) { + CAIRO_TRACE_END (__func__); + return status; + } setup->dst = dst; setup->clip_region = dst->clip_region; + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c index 3258388..8ca2ed2 100644 --- a/src/cairo-gl-device.c +++ b/src/cairo-gl-device.c @@ -45,6 +45,7 @@ #include "cairo-error-private.h" #include "cairo-gl-private.h" #include "cairo-rtree-private.h" +#include "cairo-ttrace.h" #if CAIRO_HAS_EVASGL_SURFACE #include "cairo-evas-gl.h" @@ -272,6 +273,7 @@ test_can_read_bgra (cairo_gl_context_t *ctx, cairo_gl_flavor_t gl_flavor) cairo_status_t _cairo_gl_context_init (cairo_gl_context_t *ctx) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; cairo_gl_dispatch_t *dispatch = &ctx->dispatch; int gl_version = _cairo_gl_get_version (dispatch); @@ -306,8 +308,10 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) cairo_list_init (&ctx->fonts); /* Support only GL version >= 1.3 */ - if (gl_version < CAIRO_GL_VERSION_ENCODE (1, 3)) - return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); + if (gl_version < CAIRO_GL_VERSION_ENCODE (1, 3)) { + CAIRO_TRACE_END (__func__); + return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); + } /* Check for required extensions */ if (is_desktop) { @@ -318,8 +322,10 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) } else if (_cairo_gl_has_extension (&ctx->dispatch, "GL_ARB_texture_rectangle")) { ctx->tex_target = GL_TEXTURE_RECTANGLE; ctx->has_npot_repeat = FALSE; - } else + } else { + CAIRO_TRACE_END (__func__); return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); + } } else { ctx->tex_target = GL_TEXTURE_2D; if (_cairo_gl_has_extension (&ctx->dispatch, "GL_OES_texture_npot") || @@ -330,11 +336,15 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) } if (is_desktop && gl_version < CAIRO_GL_VERSION_ENCODE (2, 1) && - ! _cairo_gl_has_extension (&ctx->dispatch, "GL_ARB_pixel_buffer_object")) - return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); + ! _cairo_gl_has_extension (&ctx->dispatch, "GL_ARB_pixel_buffer_object")) { + CAIRO_TRACE_END (__func__); + return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); + } - if (is_gles && ! _cairo_gl_has_extension (&ctx->dispatch, "GL_EXT_texture_format_BGRA8888")) - return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); + if (is_gles && ! _cairo_gl_has_extension (&ctx->dispatch, "GL_EXT_texture_format_BGRA8888")) { + CAIRO_TRACE_END (__func__); + return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); + } ctx->has_map_buffer = is_desktop || (is_gles && _cairo_gl_has_extension (&ctx->dispatch, "GL_OES_mapbuffer")); @@ -420,16 +430,20 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) ctx->gl_flavor = gl_flavor; status = _cairo_gl_context_init_shaders (ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_cache_init (&ctx->gradients, _cairo_gl_gradient_equal, NULL, (cairo_destroy_func_t) _cairo_gl_gradient_destroy, CAIRO_GL_GRADIENT_CACHE_SIZE); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } ctx->vbo_size = _cairo_gl_get_vbo_size(); @@ -460,11 +474,12 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) ctx->vb = malloc (ctx->vbo_size); if (unlikely (ctx->vb == NULL)) { - _cairo_cache_fini (&ctx->gradients); - ctx->dispatch.DeleteVertexArrays (1, &ctx->vao); - ctx->dispatch.DeleteBuffers (1, &ctx->vbo); - ctx->dispatch.DeleteBuffers (1, &ctx->ibo); - return _cairo_error (CAIRO_STATUS_NO_MEMORY); + _cairo_cache_fini (&ctx->gradients); + ctx->dispatch.DeleteVertexArrays (1, &ctx->vao); + ctx->dispatch.DeleteBuffers (1, &ctx->vbo); + ctx->dispatch.DeleteBuffers (1, &ctx->ibo); + CAIRO_TRACE_END (__func__); + return _cairo_error (CAIRO_STATUS_NO_MEMORY); } ctx->primitive_type = CAIRO_GL_PRIMITIVE_TYPE_TRIANGLES; @@ -495,6 +510,7 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) _cairo_gl_context_reset (ctx); + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } @@ -547,6 +563,7 @@ static void _cairo_gl_clear_framebuffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); if (ctx->gl_flavor == CAIRO_GL_FLAVOR_DESKTOP) return; @@ -555,6 +572,7 @@ _cairo_gl_clear_framebuffer (cairo_gl_context_t *ctx, _disable_stencil_buffer (ctx); ctx->dispatch.Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } + CAIRO_TRACE_END (__func__); } #if CAIRO_HAS_GLESV2_SURFACE || CAIRO_HAS_EVASGL_SURFACE @@ -562,11 +580,16 @@ static void _cairo_gl_ensure_msaa_gles_framebuffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { - if (ctx->has_angle_multisampling) - return; + CAIRO_TRACE_BEGIN (__func__); + if (ctx->has_angle_multisampling) { + CAIRO_TRACE_END (__func__); + return; + } - if (surface->msaa_active) - return; + if (surface->msaa_active) { + CAIRO_TRACE_END (__func__); + return; + } ctx->dispatch.FramebufferTexture2DMultisample(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, @@ -577,6 +600,7 @@ _cairo_gl_ensure_msaa_gles_framebuffer (cairo_gl_context_t *ctx, /* From now on MSAA will always be active on this surface. */ surface->msaa_active = TRUE; + CAIRO_TRACE_END (__func__); } #endif @@ -584,11 +608,14 @@ void _cairo_gl_ensure_framebuffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); GLenum status; cairo_gl_dispatch_t *dispatch = &ctx->dispatch; - if (likely (surface->fb)) + if (likely (surface->fb)) { + CAIRO_TRACE_END (__func__); return; + } /* Create a framebuffer object wrapping the texture so that we can render * to it. @@ -639,22 +666,27 @@ _cairo_gl_ensure_framebuffer (cairo_gl_context_t *ctx, "destination is framebuffer incomplete: %s [%#x]\n", str, status); } + CAIRO_TRACE_END (__func__); } static void _cairo_gl_ensure_multisampling (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); GLenum rgba; if (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES2 && - ! ctx->has_angle_multisampling) - return; - + ! ctx->has_angle_multisampling) { + CAIRO_TRACE_END (__func__); + return; + } assert (surface->supports_msaa); - if (surface->msaa_fb) - return; + if (surface->msaa_fb) { + CAIRO_TRACE_END (__func__); + return; + } /* We maintain a separate framebuffer for multisampling operations. This allows us to do a fast paint to the non-multisampling framebuffer @@ -695,6 +727,7 @@ _cairo_gl_ensure_multisampling (cairo_gl_context_t *ctx, surface->msaa_rb = 0; ctx->dispatch.DeleteRenderbuffers (1, &surface->msaa_fb); surface->msaa_fb = 0; + CAIRO_TRACE_END (__func__); return; } @@ -705,16 +738,19 @@ _cairo_gl_ensure_multisampling (cairo_gl_context_t *ctx, memset (&ctx->states_cache.clear_red, 0, sizeof (GLclampf) * 4); ctx->dispatch.Clear (GL_COLOR_BUFFER_BIT); - + CAIRO_TRACE_END (__func__); } static cairo_bool_t _cairo_gl_ensure_msaa_depth_stencil_buffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_dispatch_t *dispatch = &ctx->dispatch; - if (surface->msaa_depth_stencil) - return TRUE; + if (surface->msaa_depth_stencil) { + CAIRO_TRACE_END (__func__); + return TRUE; + } //_cairo_gl_ensure_framebuffer (ctx, surface); @@ -754,9 +790,11 @@ _cairo_gl_ensure_msaa_depth_stencil_buffer (cairo_gl_context_t *ctx, if (dispatch->CheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { dispatch->DeleteRenderbuffers (1, &surface->msaa_depth_stencil); surface->msaa_depth_stencil = 0; + CAIRO_TRACE_END (__func__); return FALSE; } + CAIRO_TRACE_END (__func__); return TRUE; } @@ -764,10 +802,13 @@ static cairo_bool_t _cairo_gl_ensure_depth_stencil_buffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_dispatch_t *dispatch = &ctx->dispatch; - if (surface->depth_stencil) + if (surface->depth_stencil) { + CAIRO_TRACE_END (__func__); return TRUE; + } _cairo_gl_ensure_framebuffer (ctx, surface); @@ -784,9 +825,11 @@ _cairo_gl_ensure_depth_stencil_buffer (cairo_gl_context_t *ctx, if (dispatch->CheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { dispatch->DeleteRenderbuffers (1, &surface->depth_stencil); surface->depth_stencil = 0; + CAIRO_TRACE_END (__func__); return FALSE; } + CAIRO_TRACE_END (__func__); return TRUE; } @@ -849,6 +892,7 @@ static void bind_multisample_framebuffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); #if CAIRO_HAS_GL_SURFACE || CAIRO_HAS_EVASGL_SURFACE cairo_bool_t stencil_test_enabled = FALSE, scissor_test_enabled = FALSE; cairo_bool_t has_stencil_cache = FALSE; @@ -872,6 +916,7 @@ bind_multisample_framebuffer (cairo_gl_context_t *ctx, #endif ctx->dispatch.BindFramebuffer (GL_FRAMEBUFFER, surface->msaa_fb); + CAIRO_TRACE_END (__func__); return; } @@ -913,21 +958,25 @@ bind_multisample_framebuffer (cairo_gl_context_t *ctx, _enable_scissor_buffer (ctx); } #endif + CAIRO_TRACE_END (__func__); } static void bind_singlesample_framebuffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_bool_t has_stencil_cache = surface->clip_on_stencil_buffer ? TRUE : FALSE; cairo_bool_t stencil_test_enabled; cairo_bool_t scissor_test_enabled; GLbitfield mask = GL_COLOR_BUFFER_BIT; if (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES2 && - ! ctx->has_angle_multisampling) + ! ctx->has_angle_multisampling) { + CAIRO_TRACE_END (__func__); return; - + } + _cairo_gl_ensure_framebuffer (ctx, surface); if (! surface->msaa_active) { @@ -936,6 +985,7 @@ bind_singlesample_framebuffer (cairo_gl_context_t *ctx, ctx->dispatch.Disable (GL_MULTISAMPLE); #endif ctx->dispatch.BindFramebuffer (GL_FRAMEBUFFER, surface->fb); + CAIRO_TRACE_END (__func__); return; } @@ -984,6 +1034,7 @@ bind_singlesample_framebuffer (cairo_gl_context_t *ctx, _enable_stencil_buffer (ctx); if (scissor_test_enabled) _enable_scissor_buffer (ctx); + CAIRO_TRACE_END (__func__); } void @@ -991,6 +1042,7 @@ _cairo_gl_context_bind_framebuffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface, cairo_bool_t multisampling) { + CAIRO_TRACE_BEGIN (__func__); if (_cairo_gl_surface_is_texture (surface)) { /* OpenGL ES surfaces only have either a multisample framebuffer or a * singlesample framebuffer, so we cannot switch back and forth. */ @@ -999,6 +1051,7 @@ _cairo_gl_context_bind_framebuffer (cairo_gl_context_t *ctx, _cairo_gl_ensure_framebuffer (ctx, surface); ctx->dispatch.BindFramebuffer (GL_FRAMEBUFFER, surface->fb); _cairo_gl_clear_framebuffer (ctx, surface); + CAIRO_TRACE_END (__func__); return; } @@ -1029,6 +1082,7 @@ _cairo_gl_context_bind_framebuffer (cairo_gl_context_t *ctx, if (ctx->gl_flavor != CAIRO_GL_FLAVOR_DESKTOP && multisampling) _cairo_gl_clear_framebuffer (ctx, surface); + CAIRO_TRACE_END (__func__); } void @@ -1036,6 +1090,7 @@ _cairo_gl_context_set_destination (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface, cairo_bool_t multisampling) { + CAIRO_TRACE_BEGIN (__func__); cairo_bool_t changing_surface, changing_sampling; /* The decision whether or not to use multisampling happens when @@ -1050,11 +1105,13 @@ _cairo_gl_context_set_destination (cairo_gl_context_t *ctx, if (! changing_surface && ! changing_sampling) { if (surface->needs_update) _cairo_gl_composite_flush (ctx); + CAIRO_TRACE_END (__func__); return; } if (! changing_surface) { _cairo_gl_composite_flush (ctx); _cairo_gl_context_bind_framebuffer (ctx, surface, multisampling); + CAIRO_TRACE_END (__func__); return; } @@ -1094,6 +1151,7 @@ _cairo_gl_context_set_destination (cairo_gl_context_t *ctx, else _gl_identity_ortho (ctx->modelviewprojection_matrix, 0, surface->width, surface->height, 0); + CAIRO_TRACE_END (__func__); } void diff --git a/src/cairo-gl-msaa-compositor.c b/src/cairo-gl-msaa-compositor.c index 49717f0..888f7da 100644 --- a/src/cairo-gl-msaa-compositor.c +++ b/src/cairo-gl-msaa-compositor.c @@ -48,6 +48,7 @@ #include "cairo-path-private.h" #include "cairo-traps-private.h" #include "cairo-convex-fill-private.h" +#include "cairo-ttrace.h" static cairo_bool_t can_use_msaa_compositor (cairo_gl_surface_t *surface, @@ -238,15 +239,19 @@ _cairo_gl_msaa_compositor_draw_clip (cairo_gl_context_t *ctx, cairo_gl_composite_t *setup, cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_traps_t traps; status = _clip_to_traps (clip, &traps); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _draw_traps (ctx, setup, &traps); _cairo_traps_fini (&traps); + CAIRO_TRACE_END (__func__); return status; } @@ -484,6 +489,7 @@ static cairo_int_status_t _cairo_gl_msaa_compositor_mask_source_operator (const cairo_compositor_t *compositor, cairo_composite_rectangles_t *composite) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_composite_t setup; cairo_gl_surface_t *dst = (cairo_gl_surface_t *) composite->surface; cairo_gl_context_t *ctx = NULL; @@ -502,22 +508,27 @@ _cairo_gl_msaa_compositor_mask_source_operator (const cairo_compositor_t *compos status = _clip_to_traps (clip, &traps); if (unlikely (status)) { _cairo_traps_fini (&traps); + CAIRO_TRACE_END (__func__); return status; } } if (! is_pixel_aligned) { status = _blit_texture_to_renderbuffer (dst); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } } status = _cairo_gl_composite_init (&setup, CAIRO_OPERATOR_DEST_OUT, dst, FALSE /* assume_component_alpha */); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_gl_composite_set_source (&setup, composite->original_mask_pattern, &composite->mask_sample_area, @@ -583,6 +594,7 @@ finish: if (clip) _cairo_traps_fini (&traps); + CAIRO_TRACE_END (__func__); return status; } @@ -590,6 +602,7 @@ static cairo_int_status_t _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor, cairo_composite_rectangles_t *composite) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_composite_t setup; cairo_gl_surface_t *dst = (cairo_gl_surface_t *) composite->surface; cairo_gl_context_t *ctx = NULL; @@ -598,12 +611,16 @@ _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor, cairo_clip_t *clip = composite->clip; cairo_bool_t is_pixel_aligned = FALSE; - if (! can_use_msaa_compositor (dst, CAIRO_ANTIALIAS_DEFAULT)) + if (! can_use_msaa_compositor (dst, CAIRO_ANTIALIAS_DEFAULT)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } if (composite->op == CAIRO_OPERATOR_CLEAR && - composite->original_mask_pattern != NULL) + composite->original_mask_pattern != NULL) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } /* GL compositing operators cannot properly represent a mask operation using the SOURCE compositing operator in one pass. This only matters if @@ -616,6 +633,7 @@ _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor, if (! _cairo_pattern_is_opaque (&composite->source_pattern.base, &composite->source_sample_area)) { + CAIRO_TRACE_END (__func__); return _cairo_gl_msaa_compositor_mask_source_operator (compositor, composite); } @@ -626,8 +644,10 @@ _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor, if (_should_use_unbounded_surface (composite)) { cairo_surface_t* surface = _prepare_unbounded_surface (dst); - if (unlikely (surface == NULL)) + if (unlikely (surface == NULL)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } /* This may be a paint operation. */ if (composite->original_mask_pattern == NULL) { @@ -645,9 +665,11 @@ _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor, if (unlikely (status)) { cairo_surface_destroy (surface); + CAIRO_TRACE_END (__func__); return status; } + CAIRO_TRACE_END (__func__); return _paint_back_unbounded_surface (compositor, composite, surface); } @@ -658,16 +680,20 @@ _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor, if (! is_pixel_aligned) { status = _blit_texture_to_renderbuffer (dst); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } } status = _cairo_gl_composite_init (&setup, op, dst, FALSE /* assume_component_alpha */); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_gl_composite_set_source (&setup, composite->original_source_pattern, @@ -719,7 +745,7 @@ _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor, if (clip) { cairo_clip_t *clip_copy = _cairo_clip_copy (clip); - + clip_copy = _cairo_clip_intersect_rectangle (clip_copy, &rect); status = _cairo_gl_msaa_compositor_draw_clip (ctx, &setup, clip_copy); @@ -740,6 +766,7 @@ finish: if (ctx) status = _cairo_gl_context_release (ctx, status); + CAIRO_TRACE_END (__func__); return status; } @@ -963,24 +990,28 @@ _cairo_gl_msaa_compositor_stroke (const cairo_compositor_t *compositor, double tolerance, cairo_antialias_t antialias) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_gl_surface_t *dst = (cairo_gl_surface_t *) composite->surface; struct _tristrip_composite_info info; cairo_bool_t use_color_attribute; cairo_rectangle_int_t stroke_extents; - if (! can_use_msaa_compositor (dst, antialias)) + if (! can_use_msaa_compositor (dst, antialias)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } if (! _cairo_path_fixed_stroke_is_rectilinear (path)) { _cairo_path_fixed_approximate_fill_extents (path, &stroke_extents); if (stroke_extents.width != 0 && stroke_extents.height != 0) { - if ((stroke_extents.width / stroke_extents.height > 10 && + if ((stroke_extents.width / stroke_extents.height > 10 && stroke_extents.height < 10) || - (stroke_extents.height / stroke_extents.width > 10 && + (stroke_extents.height / stroke_extents.width > 10 && stroke_extents.width < 10)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; } } @@ -989,8 +1020,10 @@ _cairo_gl_msaa_compositor_stroke (const cairo_compositor_t *compositor, if (composite->is_bounded == FALSE) { cairo_surface_t* surface = _prepare_unbounded_surface (dst); - if (unlikely (surface == NULL)) + if (unlikely (surface == NULL)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } status = _cairo_compositor_stroke (compositor, surface, CAIRO_OPERATOR_SOURCE, @@ -999,24 +1032,30 @@ _cairo_gl_msaa_compositor_stroke (const cairo_compositor_t *compositor, tolerance, antialias, NULL); if (unlikely (status)) { cairo_surface_destroy (surface); + CAIRO_TRACE_END (__func__); return status; } + CAIRO_TRACE_END (__func__); return _paint_back_unbounded_surface (compositor, composite, surface); } if (antialias != CAIRO_ANTIALIAS_NONE) { status = _blit_texture_to_renderbuffer (dst); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } } status = _cairo_gl_composite_init (&info.setup, composite->op, dst, FALSE /* assume_component_alpha */); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } info.ctx = NULL; use_color_attribute = _cairo_gl_hairline_style_is_hairline (style, ctm); @@ -1102,6 +1141,7 @@ finish: if (info.ctx) status = _cairo_gl_context_release (info.ctx, status); + CAIRO_TRACE_END (__func__); return status; } @@ -1136,6 +1176,7 @@ _cairo_gl_msaa_compositor_fill (const cairo_compositor_t *compositor, double tolerance, cairo_antialias_t antialias) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_composite_t setup; cairo_gl_surface_t *dst = (cairo_gl_surface_t *) composite->surface; cairo_gl_context_t *ctx = NULL; @@ -1145,17 +1186,20 @@ _cairo_gl_msaa_compositor_fill (const cairo_compositor_t *compositor, cairo_rectangle_int_t fill_extents; struct _tristrip_composite_info info; - if (! can_use_msaa_compositor (dst, antialias)) + if (! can_use_msaa_compositor (dst, antialias)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } if (! _cairo_path_fixed_fill_is_rectilinear (path)) { _cairo_path_fixed_approximate_fill_extents (path, &fill_extents); if (fill_extents.width != 0 && fill_extents.height != 0) { - if ((fill_extents.width / fill_extents.height > 10 && + if ((fill_extents.width / fill_extents.height > 10 && fill_extents.height < 10) || - (fill_extents.height / fill_extents.width > 10 && + (fill_extents.height / fill_extents.width > 10 && fill_extents.width < 10)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; } } @@ -1164,8 +1208,10 @@ _cairo_gl_msaa_compositor_fill (const cairo_compositor_t *compositor, if (composite->is_bounded == FALSE) { cairo_surface_t* surface = _prepare_unbounded_surface (dst); - if (unlikely (surface == NULL)) + if (unlikely (surface == NULL)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } status = _cairo_compositor_fill (compositor, surface, @@ -1176,16 +1222,20 @@ _cairo_gl_msaa_compositor_fill (const cairo_compositor_t *compositor, if (unlikely (status)) { cairo_surface_destroy (surface); + CAIRO_TRACE_END (__func__); return status; } + CAIRO_TRACE_END (__func__); return _paint_back_unbounded_surface (compositor, composite, surface); } if (antialias != CAIRO_ANTIALIAS_NONE) { status = _blit_texture_to_renderbuffer (dst); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } } draw_path_with_traps = ! _cairo_path_fixed_is_simple_quad (path); @@ -1208,7 +1258,7 @@ _cairo_gl_msaa_compositor_fill (const cairo_compositor_t *compositor, _cairo_gl_msaa_compositor_set_clip (composite, &setup); if (antialias != CAIRO_ANTIALIAS_NONE) _cairo_gl_composite_set_multisample (&setup); - + status = _cairo_gl_composite_begin (&setup, &ctx); if (unlikely (status)) goto cleanup_setup; @@ -1261,6 +1311,7 @@ cleanup_traps: if (draw_path_with_traps && !path->is_convex) _cairo_traps_fini (&traps); + CAIRO_TRACE_END (__func__); return status; } @@ -1272,6 +1323,7 @@ _cairo_gl_msaa_compositor_glyphs (const cairo_compositor_t *compositor, int num_glyphs, cairo_bool_t overlap) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_surface_t *src = NULL; int src_x, src_y; @@ -1280,17 +1332,23 @@ _cairo_gl_msaa_compositor_glyphs (const cairo_compositor_t *compositor, cairo_gl_surface_t *dst = (cairo_gl_surface_t *) composite->surface; query_surface_capabilities (dst); - if (! dst->supports_stencil) + if (! dst->supports_stencil) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } - if (composite->op == CAIRO_OPERATOR_CLEAR) + if (composite->op == CAIRO_OPERATOR_CLEAR) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } if (composite->is_bounded == FALSE) { cairo_surface_t* surface = _prepare_unbounded_surface (dst); - if (unlikely (surface == NULL)) + if (unlikely (surface == NULL)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } status = _cairo_compositor_glyphs (compositor, surface, CAIRO_OPERATOR_SOURCE, @@ -1300,9 +1358,11 @@ _cairo_gl_msaa_compositor_glyphs (const cairo_compositor_t *compositor, if (unlikely (status)) { cairo_surface_destroy (surface); + CAIRO_TRACE_END (__func__); return status; } + CAIRO_TRACE_END (__func__); return _paint_back_unbounded_surface (compositor, composite, surface); } /* @@ -1351,7 +1411,7 @@ _cairo_gl_msaa_compositor_glyphs (const cairo_compositor_t *compositor, finish: if (src) cairo_surface_destroy (src); - + CAIRO_TRACE_END (__func__); return status; } @@ -1359,6 +1419,7 @@ static void _cairo_gl_msaa_compositor_init (cairo_compositor_t *compositor, const cairo_compositor_t *delegate) { + CAIRO_TRACE_BEGIN (__func__); compositor->delegate = delegate; compositor->lazy_init = TRUE; compositor->paint = _cairo_gl_msaa_compositor_paint; @@ -1366,6 +1427,7 @@ _cairo_gl_msaa_compositor_init (cairo_compositor_t *compositor, compositor->fill = _cairo_gl_msaa_compositor_fill; compositor->stroke = _cairo_gl_msaa_compositor_stroke; compositor->glyphs = _cairo_gl_msaa_compositor_glyphs; + CAIRO_TRACE_END (__func__); } const cairo_compositor_t * diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c index 7938f30..52c0772 100644 --- a/src/cairo-gl-surface.c +++ b/src/cairo-gl-surface.c @@ -50,6 +50,7 @@ #include "cairo-surface-backend-private.h" #include "cairo-surface-shadow-private.h" #include "cairo-surface-scale-translate-private.h" +#include "cairo-ttrace.h" static const cairo_surface_backend_t _cairo_gl_surface_backend; @@ -67,16 +68,19 @@ _cairo_gl_surface_shadow_surface (void *surface, int width, int height, int *width_out, int *height_out) { + CAIRO_TRACE_BEGIN (__func__); int shadow_width, shadow_height; cairo_gl_surface_t *shadow_surface = NULL; cairo_gl_surface_t *dst = (cairo_gl_surface_t *)surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; - if (ctx == NULL) + if (ctx == NULL) { + CAIRO_TRACE_END (__func__); return NULL; + } shadow_surface = ctx->shadow_scratch_surfaces[0]; - + if (shadow_surface) { shadow_width = shadow_surface->width; shadow_height = shadow_surface->height; @@ -86,6 +90,7 @@ _cairo_gl_surface_shadow_surface (void *surface, shadow_height >= height) { *width_out = width; *height_out = height; + CAIRO_TRACE_END (__func__); return cairo_surface_reference (&shadow_surface->base); } else { @@ -161,6 +166,7 @@ _cairo_gl_surface_shadow_surface (void *surface, shadow_height); if (unlikely (shadow_surface->base.status)) { cairo_surface_destroy (&shadow_surface->base); + CAIRO_TRACE_END (__func__); return NULL; } @@ -191,6 +197,7 @@ _cairo_gl_surface_shadow_surface (void *surface, *height_out *= 0.5; } + CAIRO_TRACE_END (__func__); return cairo_surface_reference (&shadow_surface->base); } @@ -199,15 +206,20 @@ _cairo_gl_surface_shadow_mask_surface (void *surface, int width, int height, unsigned int index) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_surface_t *mask_surface = NULL; cairo_gl_surface_t *dst = (cairo_gl_surface_t *)surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; - if (ctx == NULL) + if (ctx == NULL) { + CAIRO_TRACE_END (__func__); return NULL; + } - if (index > 1) + if (index > 1) { + CAIRO_TRACE_END (__func__); return NULL; + } mask_surface = ctx->shadow_masks[index]; @@ -228,6 +240,7 @@ _cairo_gl_surface_shadow_mask_surface (void *surface, height); if (unlikely (mask_surface->base.status)) { cairo_surface_destroy (&mask_surface->base); + CAIRO_TRACE_END (__func__); return NULL; } _cairo_surface_release_device_reference (&mask_surface->base); @@ -237,7 +250,7 @@ _cairo_gl_surface_shadow_mask_surface (void *surface, mask_surface->needs_to_cache = FALSE; mask_surface->force_no_cache = TRUE; - + CAIRO_TRACE_END (__func__); return cairo_surface_reference (&mask_surface->base); } @@ -246,19 +259,22 @@ _cairo_gl_surface_glyph_shadow_surface (void *surface, int width, int height, cairo_bool_t for_source) { + CAIRO_TRACE_BEGIN (__func__); int shadow_width, shadow_height; cairo_gl_surface_t *shadow_surface = NULL; cairo_gl_surface_t *dst = (cairo_gl_surface_t *)surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; - if (ctx == NULL) + if (ctx == NULL) { + CAIRO_TRACE_END (__func__); return NULL; + } if (! for_source) shadow_surface = ctx->shadow_scratch_surfaces[1]; else shadow_surface = ctx->shadow_scratch_surfaces[2]; - + if (shadow_surface) { shadow_width = shadow_surface->width; shadow_height = shadow_surface->height; @@ -273,10 +289,11 @@ _cairo_gl_surface_glyph_shadow_surface (void *surface, if (! shadow_surface) { shadow_surface = (cairo_gl_surface_t *) _cairo_gl_surface_create_scratch (ctx, - CAIRO_CONTENT_COLOR_ALPHA, + CAIRO_CONTENT_COLOR_ALPHA, width, height); if (unlikely (shadow_surface->base.status)) { cairo_surface_destroy (&shadow_surface->base); + CAIRO_TRACE_END (__func__); return NULL; } _cairo_surface_release_device_reference (&shadow_surface->base); @@ -290,6 +307,7 @@ _cairo_gl_surface_glyph_shadow_surface (void *surface, shadow_surface->needs_to_cache = FALSE; shadow_surface->force_no_cache = TRUE; + CAIRO_TRACE_END (__func__); return cairo_surface_reference (&shadow_surface->base); } @@ -298,21 +316,26 @@ _cairo_gl_surface_glyph_shadow_mask_surface (void *surface, int width, int height, unsigned index) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_surface_t *mask_surface = NULL; cairo_gl_surface_t *dst = (cairo_gl_surface_t *)surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; - if (ctx == NULL) + if (ctx == NULL) { + CAIRO_TRACE_END (__func__); return NULL; + } - if (index > 1) + if (index > 1) { + CAIRO_TRACE_END (__func__); return NULL; + } mask_surface = ctx->shadow_masks[index + 2]; - + if (mask_surface) { if (mask_surface->width != width || - mask_surface->height != height) { + mask_surface->height != height) { cairo_surface_destroy (&mask_surface->base); mask_surface = NULL; ctx->shadow_masks[index + 2] = NULL; @@ -327,6 +350,7 @@ _cairo_gl_surface_glyph_shadow_mask_surface (void *surface, height); if (unlikely (mask_surface->base.status)) { cairo_surface_destroy (&mask_surface->base); + CAIRO_TRACE_END (__func__); return NULL; } _cairo_surface_release_device_reference (&mask_surface->base); @@ -337,6 +361,7 @@ _cairo_gl_surface_glyph_shadow_mask_surface (void *surface, mask_surface->needs_to_cache = FALSE; mask_surface->force_no_cache = TRUE; + CAIRO_TRACE_END (__func__); return cairo_surface_reference (&mask_surface->base); } @@ -666,6 +691,7 @@ _cairo_gl_surface_init (cairo_device_t *device, cairo_content_t content, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); assert (width > 0 && height > 0); _cairo_surface_init (&surface->base, @@ -691,6 +717,7 @@ _cairo_gl_surface_init (cairo_device_t *device, surface->content_cleared = FALSE; _cairo_gl_surface_embedded_operand_init (surface); + CAIRO_TRACE_END (__func__); } static cairo_bool_t @@ -717,11 +744,14 @@ _cairo_gl_surface_create_scratch_for_texture (cairo_gl_context_t *ctx, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_surface_t *surface; surface = calloc (1, sizeof (cairo_gl_surface_t)); - if (unlikely (surface == NULL)) + if (unlikely (surface == NULL)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); + } surface->tex = tex; _cairo_gl_surface_init (&ctx->base, surface, content, width, height); @@ -736,6 +766,7 @@ _cairo_gl_surface_create_scratch_for_texture (cairo_gl_context_t *ctx, ctx->dispatch.TexParameteri (ctx->tex_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); ctx->dispatch.TexParameteri (ctx->tex_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + CAIRO_TRACE_END (__func__); return &surface->base; } @@ -746,6 +777,7 @@ _create_scratch_internal (cairo_gl_context_t *ctx, int height, cairo_bool_t for_caching) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_surface_t *surface; GLenum format; GLuint tex; @@ -754,8 +786,10 @@ _create_scratch_internal (cairo_gl_context_t *ctx, surface = (cairo_gl_surface_t *) _cairo_gl_surface_create_scratch_for_texture (ctx, content, tex, width, height); - if (unlikely (surface->base.status)) + if (unlikely (surface->base.status)) { + CAIRO_TRACE_END (__func__); return &surface->base; + } surface->owns_tex = TRUE; @@ -797,6 +831,7 @@ _create_scratch_internal (cairo_gl_context_t *ctx, width, height, 0, format, GL_UNSIGNED_BYTE, NULL); + CAIRO_TRACE_END (__func__); return &surface->base; } @@ -822,13 +857,16 @@ static cairo_status_t _cairo_gl_surface_clear (cairo_gl_surface_t *surface, const cairo_color_t *color) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_context_t *ctx; cairo_status_t status; double r, g, b, a; status = _cairo_gl_context_acquire (surface->base.device, &ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (ctx->current_target == surface) _cairo_gl_composite_flush (ctx); @@ -887,6 +925,7 @@ _cairo_gl_surface_clear (cairo_gl_surface_t *surface, surface->content_changed = TRUE; surface->content_synced = FALSE; surface->content_cleared = TRUE; + CAIRO_TRACE_END (__func__); return _cairo_gl_context_release (ctx, status); } @@ -896,21 +935,26 @@ _cairo_gl_surface_create_and_clear_scratch (cairo_gl_context_t *ctx, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_surface_t *surface; cairo_int_status_t status; surface = (cairo_gl_surface_t *) _cairo_gl_surface_create_scratch (ctx, content, width, height); - if (unlikely (surface->base.status)) + if (unlikely (surface->base.status)) { + CAIRO_TRACE_END (__func__); return &surface->base; + } /* Cairo surfaces start out initialized to transparent (black) */ status = _cairo_gl_surface_clear (surface, CAIRO_COLOR_TRANSPARENT); if (unlikely (status)) { cairo_surface_destroy (&surface->base); + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (status); } + CAIRO_TRACE_END (__func__); return &surface->base; } @@ -920,28 +964,40 @@ cairo_gl_surface_create (cairo_device_t *abstract_device, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_context_t *ctx; cairo_gl_surface_t *surface; cairo_status_t status; - if (! CAIRO_CONTENT_VALID (content)) + if (! CAIRO_CONTENT_VALID (content)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_CONTENT)); + } - if (abstract_device == NULL) + if (abstract_device == NULL) { + CAIRO_TRACE_END (__func__); return _cairo_image_surface_create_with_content (content, width, height); + } - if (abstract_device->status) + if (abstract_device->status) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (abstract_device->status); + } - if (abstract_device->backend->type != CAIRO_DEVICE_TYPE_GL) + if (abstract_device->backend->type != CAIRO_DEVICE_TYPE_GL) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH)); + } status = _cairo_gl_context_acquire (abstract_device, &ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (status); + } if (! _cairo_gl_surface_size_valid_for_context (ctx, width, height)) { status = _cairo_gl_context_release (ctx, status); + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); } @@ -950,15 +1006,18 @@ cairo_gl_surface_create (cairo_device_t *abstract_device, if (unlikely (surface->base.status)) { status = _cairo_gl_context_release (ctx, surface->base.status); cairo_surface_destroy (&surface->base); + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (status); } status = _cairo_gl_context_release (ctx, status); if (unlikely (status)) { cairo_surface_destroy (&surface->base); + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (status); } + CAIRO_TRACE_END (__func__); return &surface->base; } slim_hidden_def (cairo_gl_surface_create); @@ -997,28 +1056,40 @@ cairo_gl_surface_create_for_texture (cairo_device_t *abstract_device, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_context_t *ctx; cairo_gl_surface_t *surface; cairo_status_t status; - if (! CAIRO_CONTENT_VALID (content)) + if (! CAIRO_CONTENT_VALID (content)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_CONTENT)); + } - if (abstract_device == NULL) + if (abstract_device == NULL) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NULL_POINTER)); + } - if (abstract_device->status) + if (abstract_device->status) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (abstract_device->status); + } - if (abstract_device->backend->type != CAIRO_DEVICE_TYPE_GL) + if (abstract_device->backend->type != CAIRO_DEVICE_TYPE_GL) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_DEVICE_TYPE_MISMATCH)); + } status = _cairo_gl_context_acquire (abstract_device, &ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (status); + } if (! _cairo_gl_surface_size_valid_for_context (ctx, width, height)) { status = _cairo_gl_context_release (ctx, status); + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); } @@ -1026,7 +1097,7 @@ cairo_gl_surface_create_for_texture (cairo_device_t *abstract_device, _cairo_gl_surface_create_scratch_for_texture (ctx, content, tex, width, height); status = _cairo_gl_context_release (ctx, status); - + CAIRO_TRACE_END (__func__); return &surface->base; } slim_hidden_def (cairo_gl_surface_create_for_texture); @@ -1088,17 +1159,22 @@ cairo_gl_surface_swapbuffers (cairo_surface_t *abstract_surface) { cairo_gl_surface_t *surface = (cairo_gl_surface_t *) abstract_surface; - if (unlikely (abstract_surface->status)) + if (unlikely (abstract_surface->status)) { + CAIRO_TRACE_END (__func__); return; + } if (unlikely (abstract_surface->finished)) { _cairo_surface_set_error (abstract_surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); + CAIRO_TRACE_END (__func__); return; } if (! _cairo_surface_is_gl (abstract_surface)) { _cairo_surface_set_error (abstract_surface, CAIRO_STATUS_SURFACE_TYPE_MISMATCH); + + CAIRO_TRACE_END (__func__); return; } @@ -1107,8 +1183,11 @@ cairo_gl_surface_swapbuffers (cairo_surface_t *abstract_surface) cairo_status_t status; status = _cairo_gl_context_acquire (surface->base.device, &ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return; + } + /* And in any case we should flush any pending operations. */ _cairo_gl_composite_flush (ctx); @@ -1128,6 +1207,7 @@ cairo_gl_surface_swapbuffers (cairo_surface_t *abstract_surface) if (status) status = _cairo_surface_set_error (abstract_surface, status); } + CAIRO_TRACE_END (__func__); } static cairo_surface_t * @@ -1136,25 +1216,32 @@ _cairo_gl_surface_create_similar (void *abstract_surface, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_surface_t *surface = abstract_surface; cairo_gl_context_t *ctx; cairo_status_t status; - if (! _cairo_gl_surface_size_valid (abstract_surface, width, height)) + if (! _cairo_gl_surface_size_valid (abstract_surface, width, height)) { + CAIRO_TRACE_END (__func__); return _cairo_image_surface_create_with_content (content, width, height); + } status = _cairo_gl_context_acquire (surface->device, &ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (status); + } surface = _cairo_gl_surface_create_and_clear_scratch (ctx, content, width, height); status = _cairo_gl_context_release (ctx, status); if (unlikely (status)) { cairo_surface_destroy (surface); + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (status); } + CAIRO_TRACE_END (__func__); return surface; } @@ -1164,6 +1251,7 @@ _cairo_gl_surface_fill_alpha_channel (cairo_gl_surface_t *dst, int x, int y, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_composite_t setup; cairo_status_t status; @@ -1191,6 +1279,7 @@ _cairo_gl_surface_fill_alpha_channel (cairo_gl_surface_t *dst, _cairo_gl_composite_flush (ctx); ctx->dispatch.ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + CAIRO_TRACE_END (__func__); return status; } @@ -1202,6 +1291,7 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst, int dst_x, int dst_y, cairo_bool_t force_flush) { + CAIRO_TRACE_BEGIN (__func__); GLenum internal_format, format, type; cairo_bool_t has_alpha, needs_swap; cairo_image_surface_t *clone = NULL; @@ -1211,8 +1301,10 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst, cairo_int_status_t status = CAIRO_INT_STATUS_SUCCESS; status = _cairo_gl_context_acquire (dst->base.device, &ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (_cairo_gl_get_flavor (&ctx->dispatch) == CAIRO_GL_FLAVOR_ES2 || _cairo_gl_get_flavor (&ctx->dispatch) == CAIRO_GL_FLAVOR_ES3) { @@ -1438,6 +1530,7 @@ FAIL: dst->content_synced = FALSE; } + CAIRO_TRACE_END (__func__); return status; } @@ -1453,13 +1546,16 @@ static int _cairo_gl_surface_flavor (cairo_gl_surface_t *surface) static cairo_status_t _cairo_gl_surface_finish (void *abstract_surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_surface_t *surface = abstract_surface; cairo_status_t status; cairo_gl_context_t *ctx; status = _cairo_gl_context_acquire (surface->base.device, &ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if ((ctx->operands[CAIRO_GL_TEX_SOURCE].type == CAIRO_GL_OPERAND_TEXTURE || ctx->operands[CAIRO_GL_TEX_SOURCE].type == CAIRO_GL_OPERAND_GAUSSIAN) && @@ -1495,6 +1591,7 @@ _cairo_gl_surface_finish (void *abstract_surface) if (surface->clip_on_stencil_buffer) _cairo_clip_destroy (surface->clip_on_stencil_buffer); + CAIRO_TRACE_END (__func__); return _cairo_gl_context_release (ctx, status); } @@ -1502,6 +1599,7 @@ static cairo_image_surface_t * _cairo_gl_surface_map_to_image (void *abstract_surface, const cairo_rectangle_int_t *extents) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_surface_t *surface = abstract_surface; cairo_image_surface_t *image; cairo_gl_context_t *ctx; @@ -1514,6 +1612,7 @@ _cairo_gl_surface_map_to_image (void *abstract_surface, status = _cairo_gl_context_acquire (surface->base.device, &ctx); if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return _cairo_image_surface_create_in_error (status); } @@ -1535,6 +1634,7 @@ _cairo_gl_surface_map_to_image (void *abstract_surface, cpp = 1; } else { ASSERT_NOT_REACHED; + CAIRO_TRACE_END (__func__); return NULL; } @@ -1571,6 +1671,7 @@ _cairo_gl_surface_map_to_image (void *abstract_surface, -1); if (unlikely (image->base.status)) { status = _cairo_gl_context_release (ctx, status); + CAIRO_TRACE_END (__func__); return image; } @@ -1580,6 +1681,7 @@ _cairo_gl_surface_map_to_image (void *abstract_surface, * is clear, we can avoid downloading data. */ if (surface->base.is_clear || surface->base.serial == 0) { status = _cairo_gl_context_release (ctx, status); + CAIRO_TRACE_END (__func__); return image; } @@ -1616,6 +1718,7 @@ _cairo_gl_surface_map_to_image (void *abstract_surface, status = _cairo_gl_context_release (ctx, status); if (unlikely (status)) { cairo_surface_destroy (&image->base); + CAIRO_TRACE_END (__func__); return _cairo_image_surface_create_in_error (status); } @@ -1629,6 +1732,7 @@ _cairo_gl_surface_map_to_image (void *abstract_surface, row = malloc (image->stride); if (unlikely (row == NULL)) { cairo_surface_destroy (&image->base); + CAIRO_TRACE_END (__func__); return _cairo_image_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); } } @@ -1647,6 +1751,7 @@ _cairo_gl_surface_map_to_image (void *abstract_surface, image->base.is_clear = FALSE; + CAIRO_TRACE_END (__func__); return image; } @@ -1696,6 +1801,7 @@ static cairo_int_status_t _cairo_gl_surface_unmap_image (void *abstract_surface, cairo_image_surface_t *image) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; status = _cairo_gl_surface_draw_image (abstract_surface, image, @@ -1708,6 +1814,7 @@ _cairo_gl_surface_unmap_image (void *abstract_surface, cairo_surface_finish (&image->base); cairo_surface_destroy (&image->base); + CAIRO_TRACE_END (__func__); return status; } @@ -1728,16 +1835,21 @@ _cairo_gl_surface_get_extents (void *abstract_surface, static cairo_status_t _cairo_gl_surface_flush (void *abstract_surface, unsigned flags) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_surface_t *surface = abstract_surface; cairo_status_t status; cairo_gl_context_t *ctx; - if (flags) + if (flags) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } status = _cairo_gl_context_acquire (surface->base.device, &ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (((ctx->operands[CAIRO_GL_TEX_SOURCE].type == CAIRO_GL_OPERAND_TEXTURE || ctx->operands[CAIRO_GL_TEX_SOURCE].type == CAIRO_GL_OPERAND_GAUSSIAN) && @@ -1754,6 +1866,7 @@ _cairo_gl_surface_flush (void *abstract_surface, unsigned flags) ctx->dispatch.Flush (); #endif + CAIRO_TRACE_END (__func__); return _cairo_gl_context_release (ctx, status); } @@ -1803,19 +1916,23 @@ _cairo_gl_surface_paint (void *surface, const cairo_pattern_t *source, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_gl_surface_t *dst = (cairo_gl_surface_t *)surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; status = cairo_device_acquire (dst->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_surface_shadow_paint (surface, op, source, clip, &source->shadow); ctx->source_scratch_in_use = FALSE; if (unlikely (status)) { - cairo_device_release (dst->base.device); + cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1824,9 +1941,10 @@ _cairo_gl_surface_paint (void *surface, dst->content_changed = TRUE; dst->content_synced = FALSE; } - + ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1835,6 +1953,7 @@ _cairo_gl_surface_paint (void *surface, if (op == CAIRO_OPERATOR_CLEAR) { status = _cairo_gl_surface_clear (surface, CAIRO_COLOR_TRANSPARENT); cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } else if (source->type == CAIRO_PATTERN_TYPE_SOLID && @@ -1842,7 +1961,8 @@ _cairo_gl_surface_paint (void *surface, (op == CAIRO_OPERATOR_OVER && _cairo_pattern_is_opaque_solid (source)))) { status = _cairo_gl_surface_clear (surface, &((cairo_solid_pattern_t *) source)->color); - cairo_device_release (dst->base.device); + cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } } @@ -1853,9 +1973,10 @@ _cairo_gl_surface_paint (void *surface, dst->content_changed = TRUE; dst->content_synced = FALSE; } - + ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1866,19 +1987,23 @@ _cairo_gl_surface_mask (void *surface, const cairo_pattern_t *mask, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_gl_surface_t *dst = (cairo_gl_surface_t *) surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; status = cairo_device_acquire (dst->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_surface_shadow_mask (surface, op, source, mask, clip, &source->shadow); ctx->source_scratch_in_use = FALSE; if (unlikely (status)) { - cairo_device_release (dst->base.device); + cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1886,10 +2011,11 @@ _cairo_gl_surface_mask (void *surface, if (status == CAIRO_INT_STATUS_SUCCESS) { dst->content_changed = TRUE; dst->content_synced = FALSE; - } - + } + ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1898,9 +2024,10 @@ _cairo_gl_surface_mask (void *surface, if (status == CAIRO_INT_STATUS_SUCCESS) { dst->content_changed = TRUE; dst->content_synced = FALSE; - + ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1913,6 +2040,7 @@ _cairo_gl_surface_mask (void *surface, ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1928,14 +2056,17 @@ _cairo_gl_surface_stroke (void *surface, cairo_antialias_t antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_gl_surface_t *dst = (cairo_gl_surface_t *)surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; cairo_shadow_type_t shadow_type = source->shadow.type; status = cairo_device_acquire (dst->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (shadow_type != CAIRO_SHADOW_INSET) status = _cairo_surface_shadow_stroke (surface, op, source, path, @@ -1946,6 +2077,7 @@ _cairo_gl_surface_stroke (void *surface, ctx->source_scratch_in_use = FALSE; if (unlikely (status)) { cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1956,6 +2088,7 @@ _cairo_gl_surface_stroke (void *surface, source->shadow.draw_shadow_only) { ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1969,6 +2102,7 @@ _cairo_gl_surface_stroke (void *surface, if (unlikely (status)) { ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1982,6 +2116,7 @@ _cairo_gl_surface_stroke (void *surface, ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1995,14 +2130,17 @@ _cairo_gl_surface_fill (void *surface, cairo_antialias_t antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; cairo_gl_surface_t *dst = (cairo_gl_surface_t *)surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; cairo_shadow_type_t shadow_type = source->shadow.type; status = cairo_device_acquire (dst->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (shadow_type != CAIRO_SHADOW_INSET) status = _cairo_surface_shadow_fill (surface, op, source, path, @@ -2012,6 +2150,7 @@ _cairo_gl_surface_fill (void *surface, ctx->source_scratch_in_use = FALSE; if (unlikely (status)) { cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -2022,6 +2161,7 @@ _cairo_gl_surface_fill (void *surface, source->shadow.draw_shadow_only) { ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -2045,6 +2185,7 @@ _cairo_gl_surface_fill (void *surface, if (unlikely (status)) { ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -2057,6 +2198,8 @@ _cairo_gl_surface_fill (void *surface, ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + + CAIRO_TRACE_END (__func__); return status; } @@ -2069,14 +2212,17 @@ _cairo_gl_surface_glyphs (void *surface, cairo_scaled_font_t *font, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_gl_surface_t *dst = (cairo_gl_surface_t *)surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; cairo_shadow_type_t shadow_type = source->shadow.type; status = cairo_device_acquire (dst->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (shadow_type != CAIRO_SHADOW_INSET) status = _cairo_surface_shadow_glyphs (surface, op, source, @@ -2087,6 +2233,7 @@ _cairo_gl_surface_glyphs (void *surface, ctx->source_scratch_in_use = FALSE; if (unlikely (status)) { cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -2097,6 +2244,7 @@ _cairo_gl_surface_glyphs (void *surface, source->shadow.draw_shadow_only) { ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -2110,6 +2258,7 @@ _cairo_gl_surface_glyphs (void *surface, if (unlikely (status)) { ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -2123,6 +2272,7 @@ _cairo_gl_surface_glyphs (void *surface, ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c index c747b3f..cb64445 100644 --- a/src/cairo-gstate.c +++ b/src/cairo-gstate.c @@ -44,6 +44,7 @@ #include "cairo-gstate-private.h" #include "cairo-pattern-private.h" #include "cairo-traps-private.h" +#include "cairo-ttrace.h" #if _XOPEN_SOURCE >= 600 || defined (_ISOC99_SOURCE) #define ISFINITE(x) isfinite (x) @@ -105,6 +106,7 @@ cairo_status_t _cairo_gstate_init (cairo_gstate_t *gstate, cairo_surface_t *target) { + CAIRO_TRACE_BEGIN (__func__); VG (VALGRIND_MAKE_MEM_UNDEFINED (gstate, sizeof (cairo_gstate_t))); gstate->next = NULL; @@ -151,6 +153,7 @@ _cairo_gstate_init (cairo_gstate_t *gstate, /* Now that the gstate is fully initialized and ready for the eventual * _cairo_gstate_fini(), we can check for errors (and not worry about * the resource deallocation). */ + CAIRO_TRACE_END (__func__); return target->status; } @@ -217,6 +220,7 @@ _cairo_gstate_init_copy (cairo_gstate_t *gstate, cairo_gstate_t *other) void _cairo_gstate_fini (cairo_gstate_t *gstate) { + CAIRO_TRACE_BEGIN (__func__); _cairo_stroke_style_fini (&gstate->stroke_style); cairo_font_face_destroy (gstate->font_face); @@ -246,6 +250,7 @@ _cairo_gstate_fini (cairo_gstate_t *gstate) memset (&gstate->shadow, 0, sizeof (cairo_shadow_t)); + CAIRO_TRACE_END (__func__); VG (VALGRIND_MAKE_MEM_NOACCESS (gstate, sizeof (cairo_gstate_t))); } @@ -416,14 +421,18 @@ cairo_status_t _cairo_gstate_set_source (cairo_gstate_t *gstate, cairo_pattern_t *source) { - if (source->status) + CAIRO_TRACE_BEGIN (__func__); + if (source->status) { + CAIRO_TRACE_END (__func__); return source->status; + } source = cairo_pattern_reference (source); cairo_pattern_destroy (gstate->source); gstate->source = source; gstate->source_ctm_inverse = gstate->ctm_inverse; + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } @@ -1065,6 +1074,7 @@ _cairo_gstate_get_pattern_status (const cairo_pattern_t *pattern) cairo_status_t _cairo_gstate_paint (cairo_gstate_t *gstate) { + CAIRO_TRACE_BEGIN (__func__); cairo_pattern_union_t source_pattern; const cairo_pattern_t *pattern; cairo_status_t status; @@ -1072,14 +1082,20 @@ _cairo_gstate_paint (cairo_gstate_t *gstate) cairo_bool_t destroy_pattern = FALSE; status = _cairo_gstate_get_pattern_status (gstate->source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } - if (gstate->op == CAIRO_OPERATOR_DEST) + if (gstate->op == CAIRO_OPERATOR_DEST) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } - if (_cairo_clip_is_all_clipped (gstate->clip)) + if (_cairo_clip_is_all_clipped (gstate->clip)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } if (gstate->source->filter == CAIRO_FILTER_GAUSSIAN) status = _cairo_pattern_create_gaussian_matrix (gstate->source, 1024); @@ -1087,7 +1103,7 @@ _cairo_gstate_paint (cairo_gstate_t *gstate) op = _reduce_op (gstate); /* do not use static pattern */ if (op == CAIRO_OPERATOR_CLEAR) { - if (! _cairo_gstate_has_shadow (gstate)) + if (! _cairo_gstate_has_shadow (gstate)) pattern = &_cairo_pattern_clear.base; else { pattern = cairo_pattern_create_rgba (0, 0, 0, 0); @@ -1107,7 +1123,7 @@ _cairo_gstate_paint (cairo_gstate_t *gstate) gstate->clip); if (destroy_pattern) cairo_pattern_destroy ((cairo_pattern_t *)pattern); - + CAIRO_TRACE_END (__func__); return status; } @@ -1115,6 +1131,7 @@ cairo_status_t _cairo_gstate_mask (cairo_gstate_t *gstate, cairo_pattern_t *mask) { + CAIRO_TRACE_BEGIN (__func__); cairo_pattern_union_t source_pattern, mask_pattern; const cairo_pattern_t *source; cairo_operator_t op; @@ -1122,12 +1139,16 @@ _cairo_gstate_mask (cairo_gstate_t *gstate, cairo_bool_t destroy_pattern = FALSE; status = _cairo_gstate_get_pattern_status (mask); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_gstate_get_pattern_status (gstate->source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (gstate->source->filter == CAIRO_FILTER_GAUSSIAN) status = _cairo_pattern_create_gaussian_matrix (gstate->source, 1024); @@ -1135,20 +1156,27 @@ _cairo_gstate_mask (cairo_gstate_t *gstate, if (mask->filter == CAIRO_FILTER_GAUSSIAN) status = _cairo_pattern_create_gaussian_matrix (mask, 1024); - if (gstate->op == CAIRO_OPERATOR_DEST) + if (gstate->op == CAIRO_OPERATOR_DEST) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } - if (_cairo_clip_is_all_clipped (gstate->clip)) + if (_cairo_clip_is_all_clipped (gstate->clip)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } assert (gstate->opacity == 1.0); - if (_cairo_pattern_is_opaque (mask, NULL)) + if (_cairo_pattern_is_opaque (mask, NULL)) { + CAIRO_TRACE_END (__func__); return _cairo_gstate_paint (gstate); + } if (_cairo_pattern_is_clear (mask) && _cairo_operator_bounded_by_mask (gstate->op)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } @@ -1209,12 +1237,14 @@ _cairo_gstate_mask (cairo_gstate_t *gstate, if (destroy_pattern) cairo_pattern_destroy ((cairo_pattern_t *)source); + CAIRO_TRACE_END (__func__); return status; } cairo_status_t _cairo_gstate_stroke (cairo_gstate_t *gstate, cairo_path_fixed_t *path) { + CAIRO_TRACE_BEGIN (__func__); cairo_pattern_union_t source_pattern; cairo_stroke_style_t style; double dash[2]; @@ -1223,21 +1253,29 @@ _cairo_gstate_stroke (cairo_gstate_t *gstate, cairo_path_fixed_t *path) cairo_matrix_t aggregate_transform_inverse; status = _cairo_gstate_get_pattern_status (gstate->source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (gstate->source->filter == CAIRO_FILTER_GAUSSIAN) status = _cairo_pattern_create_gaussian_matrix (gstate->source, gstate->stroke_style.line_width); - if (gstate->op == CAIRO_OPERATOR_DEST) + if (gstate->op == CAIRO_OPERATOR_DEST) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } - if (gstate->stroke_style.line_width <= 0.0) + if (gstate->stroke_style.line_width <= 0.0) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } - if (_cairo_clip_is_all_clipped (gstate->clip)) + if (_cairo_clip_is_all_clipped (gstate->clip)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } assert (gstate->opacity == 1.0); @@ -1263,7 +1301,7 @@ _cairo_gstate_stroke (cairo_gstate_t *gstate, cairo_path_fixed_t *path) if (_cairo_gstate_has_shadow (gstate)) source_pattern.base.shadow = gstate->shadow; - return _cairo_surface_stroke (gstate->target, + status = _cairo_surface_stroke (gstate->target, gstate->op, &source_pattern.base, path, @@ -1273,6 +1311,8 @@ _cairo_gstate_stroke (cairo_gstate_t *gstate, cairo_path_fixed_t *path) gstate->tolerance, gstate->antialias, gstate->clip); + CAIRO_TRACE_END (__func__); + return status; } cairo_status_t @@ -1282,6 +1322,7 @@ _cairo_gstate_in_stroke (cairo_gstate_t *gstate, double y, cairo_bool_t *inside_ret) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; cairo_rectangle_int_t extents; cairo_box_t limit; @@ -1289,6 +1330,7 @@ _cairo_gstate_in_stroke (cairo_gstate_t *gstate, if (gstate->stroke_style.line_width <= 0.0) { *inside_ret = FALSE; + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } @@ -1305,6 +1347,7 @@ _cairo_gstate_in_stroke (cairo_gstate_t *gstate, y < extents.y || y > extents.y + extents.height) { *inside_ret = FALSE; + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } @@ -1330,34 +1373,44 @@ _cairo_gstate_in_stroke (cairo_gstate_t *gstate, BAIL: _cairo_traps_fini (&traps); + CAIRO_TRACE_END (__func__); return status; } cairo_status_t _cairo_gstate_fill (cairo_gstate_t *gstate, cairo_path_fixed_t *path) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; const cairo_pattern_t *pattern; cairo_bool_t destroy_pattern = FALSE; status = _cairo_gstate_get_pattern_status (gstate->source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (gstate->source->filter == CAIRO_FILTER_GAUSSIAN) status = _cairo_pattern_create_gaussian_matrix (gstate->source, 1024); - if (gstate->op == CAIRO_OPERATOR_DEST) + if (gstate->op == CAIRO_OPERATOR_DEST) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } - if (_cairo_clip_is_all_clipped (gstate->clip)) + if (_cairo_clip_is_all_clipped (gstate->clip)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } assert (gstate->opacity == 1.0); if (_cairo_path_fixed_fill_is_empty (path)) { - if (_cairo_operator_bounded_by_mask (gstate->op)) + if (_cairo_operator_bounded_by_mask (gstate->op)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } pattern = &_cairo_pattern_clear.base; status = _cairo_surface_paint (gstate->target, @@ -1373,7 +1426,7 @@ _cairo_gstate_fill (cairo_gstate_t *gstate, cairo_path_fixed_t *path) op = _reduce_op (gstate); /* FIXME: I don't like this */ if (op == CAIRO_OPERATOR_CLEAR) { - if (_cairo_gstate_has_shadow (gstate)) + if (_cairo_gstate_has_shadow (gstate)) pattern = &_cairo_pattern_clear.base; else { pattern = cairo_pattern_create_rgba (0, 0, 0, 0); @@ -1414,6 +1467,7 @@ _cairo_gstate_fill (cairo_gstate_t *gstate, cairo_path_fixed_t *path) if (destroy_pattern) cairo_pattern_destroy ((cairo_pattern_t *)pattern); + CAIRO_TRACE_END (__func__); return status; } diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index 1948a1a..a399a81 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -56,6 +56,7 @@ #include "cairo-surface-subsurface-private.h" #include "cairo-surface-shadow-private.h" #include "cairo-list-inline.h" +#include "cairo-ttrace.h" /* Limit on the width / height of an image surface in pixels. This is * mainly determined by coordinates of things sent to pixman at the @@ -124,7 +125,7 @@ _cairo_image_shadow_caches_destroy (void) cairo_surface_destroy (shadow->surface); free (shadow); } - shadow_caches_size = 0; + shadow_caches_size = 0; } } @@ -274,6 +275,7 @@ _cairo_image_surface_init (cairo_image_surface_t *surface, pixman_image_t *pixman_image, pixman_format_code_t pixman_format) { + CAIRO_TRACE_BEGIN (__func__); surface->parent = NULL; surface->pixman_image = pixman_image; @@ -294,17 +296,21 @@ _cairo_image_surface_init (cairo_image_surface_t *surface, surface->compositor = _cairo_image_spans_compositor_get (); _cairo_image_shadow_caches_init (); + CAIRO_TRACE_END (__func__); } cairo_surface_t * _cairo_image_surface_create_for_pixman_image (pixman_image_t *pixman_image, pixman_format_code_t pixman_format) { + CAIRO_TRACE_BEGIN (__func__); cairo_image_surface_t *surface; surface = malloc (sizeof (cairo_image_surface_t)); - if (unlikely (surface == NULL)) + if (unlikely (surface == NULL)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); + } _cairo_surface_init (&surface->base, &_cairo_image_surface_backend, @@ -313,6 +319,7 @@ _cairo_image_surface_create_for_pixman_image (pixman_image_t *pixman_image, _cairo_image_surface_init (surface, pixman_image, pixman_format); + CAIRO_TRACE_END (__func__); return &surface->base; } @@ -457,29 +464,35 @@ _cairo_image_surface_create_with_pixman_format (unsigned char *data, int height, int stride) { + CAIRO_TRACE_BEGIN (__func__); cairo_surface_t *surface; pixman_image_t *pixman_image; if (! _cairo_image_surface_is_size_valid (width, height)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); } pixman_image = pixman_image_create_bits (pixman_format, width, height, (uint32_t *) data, stride); - if (unlikely (pixman_image == NULL)) + if (unlikely (pixman_image == NULL)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); + } surface = _cairo_image_surface_create_for_pixman_image (pixman_image, pixman_format); if (unlikely (surface->status)) { pixman_image_unref (pixman_image); + CAIRO_TRACE_END (__func__); return surface; } /* we can not make any assumptions about the initial state of user data */ surface->is_clear = data == NULL; + CAIRO_TRACE_END (__func__); return surface; } @@ -510,15 +523,21 @@ cairo_image_surface_create (cairo_format_t format, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); pixman_format_code_t pixman_format; + cairo_surface_t *image_surface = NULL; - if (! CAIRO_FORMAT_VALID (format)) + if (! CAIRO_FORMAT_VALID (format)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT)); + } pixman_format = _cairo_format_to_pixman_format_code (format); - return _cairo_image_surface_create_with_pixman_format (NULL, pixman_format, + image_surface = _cairo_image_surface_create_with_pixman_format (NULL, pixman_format, width, height, -1); + CAIRO_TRACE_END (__func__); + return image_surface; } slim_hidden_def (cairo_image_surface_create); @@ -879,6 +898,7 @@ _cairo_image_surface_create_similar (void *abstract_other, cairo_surface_t * _cairo_image_surface_snapshot (void *abstract_surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_image_surface_t *image = abstract_surface; cairo_image_surface_t *clone; @@ -887,8 +907,10 @@ _cairo_image_surface_snapshot (void *abstract_surface) clone = (cairo_image_surface_t *) _cairo_image_surface_create_for_pixman_image (image->pixman_image, image->pixman_format); - if (unlikely (clone->base.status)) + if (unlikely (clone->base.status)) { + CAIRO_TRACE_END (__func__); return &clone->base; + } image->pixman_image = NULL; image->owns_data = FALSE; @@ -897,6 +919,7 @@ _cairo_image_surface_snapshot (void *abstract_surface) clone->color = image->color; clone->owns_data = TRUE; + CAIRO_TRACE_END (__func__); return &clone->base; } @@ -906,8 +929,10 @@ _cairo_image_surface_snapshot (void *abstract_surface) image->width, image->height, 0); - if (unlikely (clone->base.status)) + if (unlikely (clone->base.status)) { + CAIRO_TRACE_END (__func__); return &clone->base; + } if (clone->stride == image->stride) { memcpy (clone->data, image->data, clone->stride * clone->height); @@ -920,6 +945,7 @@ _cairo_image_surface_snapshot (void *abstract_surface) image->width, image->height); } clone->base.is_clear = FALSE; + CAIRO_TRACE_END (__func__); return &clone->base; } @@ -927,6 +953,7 @@ cairo_image_surface_t * _cairo_image_surface_map_to_image (void *abstract_other, const cairo_rectangle_int_t *extents) { + CAIRO_TRACE_BEGIN (__func__); cairo_image_surface_t *other = abstract_other; cairo_surface_t *surface; uint8_t *data; @@ -943,6 +970,7 @@ _cairo_image_surface_map_to_image (void *abstract_other, other->stride); cairo_surface_set_device_offset (surface, -extents->x, -extents->y); + CAIRO_TRACE_END (__func__); return (cairo_image_surface_t *) surface; } @@ -959,6 +987,7 @@ _cairo_image_surface_unmap_image (void *abstract_surface, cairo_status_t _cairo_image_surface_finish (void *abstract_surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_image_surface_t *surface = abstract_surface; if (surface->pixman_image) { @@ -979,6 +1008,7 @@ _cairo_image_surface_finish (void *abstract_surface) _cairo_image_shadow_caches_destroy (); + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } @@ -1042,32 +1072,38 @@ _cairo_image_surface_paint (void *abstract_surface, const cairo_pattern_t *source, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_image_surface_t *surface = abstract_surface; - cairo_int_status_t status; + cairo_int_status_t status; TRACE ((stderr, "%s (surface=%d)\n", __FUNCTION__, surface->base.unique_id)); status = cairo_device_acquire (surface->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_surface_shadow_paint (abstract_surface, op, source, clip, &source->shadow); if (unlikely (status)) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } if (source->shadow.draw_shadow_only) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } status = _cairo_compositor_paint (surface->compositor, &surface->base, op, source, clip); cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1078,6 +1114,7 @@ _cairo_image_surface_mask (void *abstract_surface, const cairo_pattern_t *mask, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_image_surface_t *surface = abstract_surface; cairo_int_status_t status; @@ -1085,25 +1122,30 @@ _cairo_image_surface_mask (void *abstract_surface, __FUNCTION__, surface->base.unique_id)); status = cairo_device_acquire (surface->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_surface_shadow_mask (abstract_surface, op, source, mask, clip, &source->shadow); if (unlikely (status)) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } if (source->shadow.draw_shadow_only) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } status = _cairo_compositor_mask (surface->compositor, &surface->base, op, source, mask, clip); cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1119,6 +1161,7 @@ _cairo_image_surface_stroke (void *abstract_surface, cairo_antialias_t antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_image_surface_t *surface = abstract_surface; cairo_shadow_type_t shadow_type = source->shadow.type; @@ -1127,8 +1170,10 @@ _cairo_image_surface_stroke (void *abstract_surface, __FUNCTION__, surface->base.unique_id)); status = cairo_device_acquire (surface->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (shadow_type != CAIRO_SHADOW_INSET) status = _cairo_surface_shadow_stroke (abstract_surface, op, source, @@ -1138,12 +1183,14 @@ _cairo_image_surface_stroke (void *abstract_surface, if (unlikely (status)) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } if (shadow_type == CAIRO_SHADOW_DROP && source->shadow.draw_shadow_only) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1155,6 +1202,7 @@ _cairo_image_surface_stroke (void *abstract_surface, if (unlikely (status)) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1165,6 +1213,7 @@ _cairo_image_surface_stroke (void *abstract_surface, &source->shadow); cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1178,6 +1227,7 @@ _cairo_image_surface_fill (void *abstract_surface, cairo_antialias_t antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_image_surface_t *surface = abstract_surface; cairo_shadow_type_t shadow_type = source->shadow.type; @@ -1186,8 +1236,10 @@ _cairo_image_surface_fill (void *abstract_surface, __FUNCTION__, surface->base.unique_id)); status = cairo_device_acquire (surface->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (shadow_type != CAIRO_SHADOW_INSET) status = _cairo_surface_shadow_fill (abstract_surface, op, source, @@ -1197,12 +1249,14 @@ _cairo_image_surface_fill (void *abstract_surface, if (unlikely (status)) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } if (shadow_type == CAIRO_SHADOW_DROP && source->shadow.draw_shadow_only) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1223,6 +1277,7 @@ _cairo_image_surface_fill (void *abstract_surface, if (unlikely (status)) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1233,6 +1288,7 @@ _cairo_image_surface_fill (void *abstract_surface, &source->shadow); cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1245,6 +1301,7 @@ _cairo_image_surface_glyphs (void *abstract_surface, cairo_scaled_font_t *scaled_font, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_image_surface_t *surface = abstract_surface; cairo_shadow_type_t shadow_type = source->shadow.type; @@ -1253,8 +1310,10 @@ _cairo_image_surface_glyphs (void *abstract_surface, __FUNCTION__, surface->base.unique_id)); status = cairo_device_acquire (surface->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (shadow_type != CAIRO_SHADOW_INSET) status = _cairo_surface_shadow_glyphs (abstract_surface, op, source, @@ -1265,12 +1324,14 @@ _cairo_image_surface_glyphs (void *abstract_surface, if (unlikely (status)) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } if (shadow_type == CAIRO_SHADOW_DROP && source->shadow.draw_shadow_only) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1282,6 +1343,7 @@ _cairo_image_surface_glyphs (void *abstract_surface, if (unlikely (status)) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1293,6 +1355,7 @@ _cairo_image_surface_glyphs (void *abstract_surface, &source->shadow); cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1312,6 +1375,7 @@ _cairo_image_surface_shadow_surface (void *surface, int width, int height, int *width_out, int *height_out) { + CAIRO_TRACE_BEGIN (__func__); int shadow_width, shadow_height; cairo_image_surface_t *shadow_surface = NULL; @@ -1331,7 +1395,7 @@ _cairo_image_surface_shadow_surface (void *surface, else shadow_width = width; } - + if (height < MIN_IMAGE_SHADOW_SIZE) shadow_height = height; else if (has_blur) { @@ -1355,12 +1419,14 @@ _cairo_image_surface_shadow_surface (void *surface, shadow_height); if (unlikely (shadow_surface->base.status)) { cairo_surface_destroy (&shadow_surface->base); + CAIRO_TRACE_END (__func__); return NULL; } *width_out = shadow_width; *height_out = shadow_height; + CAIRO_TRACE_END (__func__); return &shadow_surface->base; } @@ -1461,6 +1527,7 @@ _cairo_image_surface_create_from_image (cairo_image_surface_t *other, int x, int y, int width, int height, int stride) { + CAIRO_TRACE_BEGIN (__func__); cairo_image_surface_t *surface = NULL; cairo_status_t status; pixman_image_t *image; @@ -1500,6 +1567,7 @@ _cairo_image_surface_create_from_image (cairo_image_surface_t *other, surface->base.is_clear = FALSE; surface->owns_data = mem != NULL; + CAIRO_TRACE_END (__func__); return surface; cleanup_image: @@ -1508,6 +1576,7 @@ cleanup_mem: free (mem); cleanup: cairo_surface_destroy (&surface->base); + CAIRO_TRACE_END (__func__); return (cairo_image_surface_t *) _cairo_surface_create_in_error (status); } @@ -1633,6 +1702,7 @@ cairo_image_surface_t * _cairo_image_surface_clone_subimage (cairo_surface_t *surface, const cairo_rectangle_int_t *extents) { + CAIRO_TRACE_BEGIN (__func__); cairo_surface_t *image; cairo_surface_pattern_t pattern; cairo_status_t status; @@ -1641,8 +1711,10 @@ _cairo_image_surface_clone_subimage (cairo_surface_t *surface, _cairo_format_from_content (surface->content), extents->width, extents->height); - if (image->status) + if (image->status) { + CAIRO_TRACE_END (__func__); return to_image_surface (image); + } /* TODO: check me with non-identity device_transform. Should we * clone the scaling, too? */ @@ -1672,9 +1744,11 @@ _cairo_image_surface_clone_subimage (cairo_surface_t *surface, _cairo_image_surface_set_parent (to_image_surface (image), cairo_surface_reference (surface)); + CAIRO_TRACE_END (__func__); return to_image_surface (image); error: cairo_surface_destroy (image); + CAIRO_TRACE_END (__func__); return to_image_surface (_cairo_surface_create_in_error (status)); } diff --git a/src/cairo-png.c b/src/cairo-png.c index 068617d..9d7c5cc 100644 --- a/src/cairo-png.c +++ b/src/cairo-png.c @@ -41,6 +41,7 @@ #include "cairo-error-private.h" #include "cairo-image-surface-private.h" #include "cairo-output-stream-private.h" +#include "cairo-ttrace.h" #include #include @@ -171,6 +172,7 @@ write_png (cairo_surface_t *surface, png_rw_ptr write_func, void *closure) { + CAIRO_TRACE_BEGIN (__func__); int i; cairo_int_status_t status; cairo_image_surface_t *image; @@ -187,10 +189,14 @@ write_png (cairo_surface_t *surface, &image, &image_extra); - if (status == CAIRO_INT_STATUS_UNSUPPORTED) + if (status == CAIRO_INT_STATUS_UNSUPPORTED) { + CAIRO_TRACE_END (__func__); return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); - else if (unlikely (status)) - return status; + } + else if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } /* PNG complains about "Image width or height is zero in IHDR" */ if (image->width == 0 || image->height == 0) { @@ -314,6 +320,7 @@ BAIL2: BAIL1: _cairo_surface_release_source_image (surface, image, image_extra); + CAIRO_TRACE_END (__func__); return status; } @@ -426,17 +433,23 @@ cairo_surface_write_to_png_stream (cairo_surface_t *surface, cairo_write_func_t write_func, void *closure) { + CAIRO_TRACE_BEGIN (__func__); struct png_write_closure_t png_closure; - if (surface->status) + if (surface->status) { + CAIRO_TRACE_END (__func__); return surface->status; + } - if (surface->finished) + if (surface->finished) { + CAIRO_TRACE_END (__func__); return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED); + } png_closure.write_func = write_func; png_closure.closure = closure; + CAIRO_TRACE_END (__func__); return write_png (surface, stream_write_func, &png_closure); } slim_hidden_def (cairo_surface_write_to_png_stream); diff --git a/src/cairo-region.c b/src/cairo-region.c index ccfb220..f202c96 100644 --- a/src/cairo-region.c +++ b/src/cairo-region.c @@ -40,6 +40,7 @@ #include "cairo-error-private.h" #include "cairo-region-private.h" +#include "cairo-ttrace.h" /* XXX need to update pixman headers to be const as appropriate */ #define CONST_CAST (pixman_region32_t *) @@ -194,16 +195,20 @@ _cairo_region_fini (cairo_region_t *region) cairo_region_t * cairo_region_create (void) { + CAIRO_TRACE_BEGIN (__func__); cairo_region_t *region; region = _cairo_malloc (sizeof (cairo_region_t)); - if (region == NULL) + if (region == NULL) { + CAIRO_TRACE_END (__func__); return (cairo_region_t *) &_cairo_region_nil; + } region->status = CAIRO_STATUS_SUCCESS; CAIRO_REFERENCE_COUNT_INIT (®ion->ref_count, 1); pixman_region32_init (®ion->rgn); + CAIRO_TRACE_END (__func__); return region; } @@ -418,16 +423,22 @@ slim_hidden_def (cairo_region_reference); void cairo_region_destroy (cairo_region_t *region) { - if (region == NULL || CAIRO_REFERENCE_COUNT_IS_INVALID (®ion->ref_count)) + CAIRO_TRACE_BEGIN (__func__); + if (region == NULL || CAIRO_REFERENCE_COUNT_IS_INVALID (®ion->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (®ion->ref_count)); - if (! _cairo_reference_count_dec_and_test (®ion->ref_count)) + if (! _cairo_reference_count_dec_and_test (®ion->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } _cairo_region_fini (region); free (region); + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_region_destroy); @@ -701,11 +712,14 @@ cairo_status_t cairo_region_union_rectangle (cairo_region_t *dst, const cairo_rectangle_int_t *rectangle) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status = CAIRO_STATUS_SUCCESS; pixman_region32_t region; - if (dst->status) + if (dst->status) { + CAIRO_TRACE_END (__func__); return dst->status; + } pixman_region32_init_rect (®ion, rectangle->x, rectangle->y, @@ -715,6 +729,7 @@ cairo_region_union_rectangle (cairo_region_t *dst, status = _cairo_region_set_error (dst, CAIRO_STATUS_NO_MEMORY); pixman_region32_fini (®ion); + CAIRO_TRACE_END (__func__); return status; } diff --git a/src/cairo-surface.c b/src/cairo-surface.c index 24ad249..2c5bcf7 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c @@ -50,6 +50,7 @@ #include "cairo-region-private.h" #include "cairo-surface-inline.h" #include "cairo-tee-surface-private.h" +#include "cairo-ttrace.h" /** * SECTION:cairo-surface @@ -490,22 +491,32 @@ cairo_surface_create_similar (cairo_surface_t *other, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_surface_t *surface; cairo_status_t status; cairo_solid_pattern_t pattern; - if (unlikely (other->status)) + if (unlikely (other->status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (other->status); - if (unlikely (other->finished)) + } + if (unlikely (other->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_SURFACE_FINISHED); - if (unlikely (width < 0 || height < 0)) + } + if (unlikely (width < 0 || height < 0)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_SIZE); + } - if (unlikely (! CAIRO_CONTENT_VALID (content))) + if (unlikely (! CAIRO_CONTENT_VALID (content))) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_CONTENT); - - if (unlikely (other->status)) + } + if (unlikely (other->status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (other->status); + } /* We inherit the device scale, so create a larger surface */ width = width * other->device_transform.xx; @@ -519,16 +530,20 @@ cairo_surface_create_similar (cairo_surface_t *other, _cairo_format_from_content (content), width, height); - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface; + } _cairo_surface_copy_similar_properties (surface, other); cairo_surface_set_device_scale (surface, other->device_transform.xx, other->device_transform.yy); - if (unlikely (surface->status)) + if (unlikely (surface->status)){ + CAIRO_TRACE_END (__func__); return surface; + } _cairo_pattern_init_solid (&pattern, CAIRO_COLOR_TRANSPARENT); status = _cairo_surface_paint (surface, @@ -541,6 +556,7 @@ cairo_surface_create_similar (cairo_surface_t *other, assert (surface->is_clear); + CAIRO_TRACE_END (__func__); return surface; } @@ -576,17 +592,26 @@ cairo_surface_create_similar_image (cairo_surface_t *other, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_surface_t *image; - if (unlikely (other->status)) + if (unlikely (other->status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (other->status); - if (unlikely (other->finished)) + } + if (unlikely (other->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_SURFACE_FINISHED); + } - if (unlikely (width < 0 || height < 0)) + if (unlikely (width < 0 || height < 0)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_SIZE); - if (unlikely (! CAIRO_FORMAT_VALID (format))) + } + if (unlikely (! CAIRO_FORMAT_VALID (format))) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_FORMAT); + } image = NULL; if (other->backend->create_similar_image) @@ -597,6 +622,7 @@ cairo_surface_create_similar_image (cairo_surface_t *other, assert (image->is_clear); + CAIRO_TRACE_END (__func__); return image; } slim_hidden_def (cairo_surface_create_similar_image); @@ -635,6 +661,7 @@ cairo_image_surface_t * _cairo_surface_map_to_image (cairo_surface_t *surface, const cairo_rectangle_int_t *extents) { + CAIRO_TRACE_BEGIN (__func__); cairo_image_surface_t *image = NULL; assert (extents != NULL); @@ -646,6 +673,7 @@ _cairo_surface_map_to_image (cairo_surface_t *surface, if (image == NULL) image = _cairo_image_surface_clone_subimage (surface, extents); + CAIRO_TRACE_END (__func__); return image; } @@ -674,6 +702,7 @@ cairo_int_status_t _cairo_surface_unmap_image (cairo_surface_t *surface, cairo_image_surface_t *image) { + CAIRO_TRACE_BEGIN (__func__); cairo_surface_pattern_t pattern; cairo_rectangle_int_t extents; cairo_clip_t *clip; @@ -696,8 +725,10 @@ _cairo_surface_unmap_image (cairo_surface_t *surface, ! _cairo_image_surface_is_clone (image)) { status = surface->backend->unmap_image (surface, image); - if (status != CAIRO_INT_STATUS_UNSUPPORTED) + if (status != CAIRO_INT_STATUS_UNSUPPORTED) { + CAIRO_TRACE_END (__func__); return status; + } } _cairo_pattern_init_for_surface (&pattern, &image->base); @@ -727,6 +758,7 @@ destroy: cairo_surface_finish (&image->base); cairo_surface_destroy (&image->base); + CAIRO_TRACE_END (__func__); return status; } @@ -762,19 +794,25 @@ cairo_surface_t * cairo_surface_map_to_image (cairo_surface_t *surface, const cairo_rectangle_int_t *extents) { + CAIRO_TRACE_BEGIN (__func__); cairo_rectangle_int_t rect; cairo_image_surface_t *image; cairo_status_t status; - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (surface->status); - if (unlikely (surface->finished)) + } + if (unlikely (surface->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_SURFACE_FINISHED); + } if (extents == NULL) { - if (unlikely (! surface->backend->get_extents (surface, &rect))) + if (unlikely (! surface->backend->get_extents (surface, &rect))) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_SIZE); - + } extents = ▭ } else { cairo_rectangle_int_t surface_extents; @@ -782,8 +820,10 @@ cairo_surface_map_to_image (cairo_surface_t *surface, /* If this surface is bounded, we can't map parts * that are outside of it. */ if (likely (surface->backend->get_extents (surface, &surface_extents))) { - if (unlikely (! _cairo_rectangle_contains_rectangle (&surface_extents, extents))) + if (unlikely (! _cairo_rectangle_contains_rectangle (&surface_extents, extents))) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_SIZE); + } } } @@ -792,6 +832,7 @@ cairo_surface_map_to_image (cairo_surface_t *surface, status = image->base.status; if (unlikely (status)) { cairo_surface_destroy (&image->base); + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (status); } @@ -800,6 +841,7 @@ cairo_surface_map_to_image (cairo_surface_t *surface, image = _cairo_image_surface_clone_subimage (surface, extents); } + CAIRO_TRACE_END (__func__); return &image->base; } @@ -822,6 +864,7 @@ void cairo_surface_unmap_image (cairo_surface_t *surface, cairo_surface_t *image) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status = CAIRO_STATUS_SUCCESS; if (unlikely (surface->status)) { @@ -850,12 +893,14 @@ cairo_surface_unmap_image (cairo_surface_t *surface, if (unlikely (status)) _cairo_surface_set_error (surface, status); + CAIRO_TRACE_END (__func__); return; error: _cairo_surface_set_error (surface, status); cairo_surface_finish (image); cairo_surface_destroy (image); + CAIRO_TRACE_END (__func__); } cairo_surface_t * @@ -865,12 +910,15 @@ _cairo_surface_create_scratch (cairo_surface_t *other, int height, const cairo_color_t *color) { + CAIRO_TRACE_BEGIN (__func__); cairo_surface_t *surface; cairo_status_t status; cairo_solid_pattern_t pattern; - if (unlikely (other->status)) + if (unlikely (other->status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (other->status); + } surface = NULL; if (other->backend->create_similar) @@ -880,13 +928,17 @@ _cairo_surface_create_scratch (cairo_surface_t *other, _cairo_format_from_content (content), width, height); - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface; + } _cairo_surface_copy_similar_properties (surface, other); - if (unlikely (surface->status)) + if (unlikely (surface->status)){ + CAIRO_TRACE_END (__func__); return surface; + } if (color) { _cairo_pattern_init_solid (&pattern, color); @@ -900,6 +952,7 @@ _cairo_surface_create_scratch (cairo_surface_t *other, } } + CAIRO_TRACE_END (__func__); return surface; } @@ -974,14 +1027,19 @@ slim_hidden_def (cairo_surface_reference); void cairo_surface_destroy (cairo_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); if (surface == NULL || - CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) + CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)); - if (! _cairo_reference_count_dec_and_test (&surface->ref_count)) + if (! _cairo_reference_count_dec_and_test (&surface->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } assert (surface->snapshot_of == NULL); @@ -990,8 +1048,10 @@ cairo_surface_destroy (cairo_surface_t *surface) /* We may have been referenced by a snapshot prior to have * detaching it with the copy-on-write. */ - if (CAIRO_REFERENCE_COUNT_GET_VALUE (&surface->ref_count)) + if (CAIRO_REFERENCE_COUNT_GET_VALUE (&surface->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } _cairo_surface_finish (surface); } @@ -1011,6 +1071,7 @@ cairo_surface_destroy (cairo_surface_t *surface) assert (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)); free (surface); + CAIRO_TRACE_END (__func__); } slim_hidden_def(cairo_surface_destroy); @@ -1088,14 +1149,21 @@ _cairo_surface_finish (cairo_surface_t *surface) void cairo_surface_finish (cairo_surface_t *surface) { - if (surface == NULL) + CAIRO_TRACE_BEGIN (__func__); + if (surface == NULL) { + CAIRO_TRACE_END (__func__); return; + } - if (CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) + if (CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } - if (surface->finished) + if (surface->finished) { + CAIRO_TRACE_END (__func__); return; + } /* We have to be careful when decoupling potential reference cycles */ cairo_surface_reference (surface); @@ -1105,6 +1173,7 @@ cairo_surface_finish (cairo_surface_t *surface) _cairo_surface_finish (surface); cairo_surface_destroy (surface); + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_surface_finish); @@ -1207,6 +1276,7 @@ cairo_surface_get_mime_data (cairo_surface_t *surface, const unsigned char **data, unsigned long *length) { + CAIRO_TRACE_BEGIN (__func__); cairo_user_data_slot_t *slots; int i, num_slots; @@ -1214,8 +1284,10 @@ cairo_surface_get_mime_data (cairo_surface_t *surface, *length = 0; /* Prevent reads of the array during teardown */ - if (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)) + if (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } /* The number of mime-types attached to a surface is usually small, * typically zero. Therefore it is quicker to do a strcmp() against @@ -1230,9 +1302,11 @@ cairo_surface_get_mime_data (cairo_surface_t *surface, *data = mime_data->data; *length = mime_data->length; + CAIRO_TRACE_END (__func__); return; } } + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_surface_get_mime_data); @@ -1370,28 +1444,41 @@ cairo_surface_set_mime_data (cairo_surface_t *surface, cairo_destroy_func_t destroy, void *closure) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; cairo_mime_data_t *mime_data; - if (CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) + if (CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) { + CAIRO_TRACE_END (__func__); return surface->status; + } - if (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)) + if (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)) { + CAIRO_TRACE_END (__func__); return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED); + } - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface->status; - if (unlikely (surface->finished)) + } + if (unlikely (surface->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); + } status = _cairo_intern_string (&mime_type, -1); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, status); + } if (data != NULL) { mime_data = malloc (sizeof (cairo_mime_data_t)); - if (unlikely (mime_data == NULL)) + if (unlikely (mime_data == NULL)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_NO_MEMORY)); + } CAIRO_REFERENCE_COUNT_INIT (&mime_data->ref_count, 1); @@ -1408,10 +1495,10 @@ cairo_surface_set_mime_data (cairo_surface_t *surface, _cairo_mime_data_destroy); if (unlikely (status)) { free (mime_data); - + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, status); } - + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } slim_hidden_def (cairo_surface_set_mime_data); @@ -1468,24 +1555,32 @@ cairo_status_t _cairo_surface_copy_mime_data (cairo_surface_t *dst, cairo_surface_t *src) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (dst->status) + if (dst->status) { + CAIRO_TRACE_END (__func__); return dst->status; + } - if (src->status) + if (src->status) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (dst, src->status); + } /* first copy the mime-data, discarding any already set on dst */ status = _cairo_user_data_array_copy (&dst->mime_data, &src->mime_data); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (dst, status); + } /* now increment the reference counters for the copies */ _cairo_user_data_array_foreach (&dst->mime_data, _cairo_mime_data_reference, NULL); + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } @@ -1594,17 +1689,23 @@ _cairo_surface_flush (cairo_surface_t *surface, unsigned flags) void cairo_surface_flush (cairo_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (surface->status) + if (surface->status) { + CAIRO_TRACE_END (__func__); return; + } - if (surface->finished) + if (surface->finished) { + CAIRO_TRACE_END (__func__); return; + } status = _cairo_surface_flush (surface, 0); if (unlikely (status)) _cairo_surface_set_error (surface, status); + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_surface_flush); @@ -1988,23 +2089,31 @@ _cairo_surface_acquire_source_image (cairo_surface_t *surface, cairo_image_surface_t **image_out, void **image_extra) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface->status; + } assert (!surface->finished); - if (surface->backend->acquire_source_image == NULL) + if (surface->backend->acquire_source_image == NULL) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } status = surface->backend->acquire_source_image (surface, image_out, image_extra); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, status); + } _cairo_debug_check_image_surface_is_defined (&(*image_out)->base); + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } @@ -2013,14 +2122,18 @@ _cairo_surface_default_acquire_source_image (void *_surface, cairo_image_surface_t **image_out, void **image_extra) { + CAIRO_TRACE_BEGIN (__func__); cairo_surface_t *surface = _surface; cairo_rectangle_int_t extents; - if (unlikely (! surface->backend->get_extents (surface, &extents))) + if (unlikely (! surface->backend->get_extents (surface, &extents))) { + CAIRO_TRACE_END (__func__); return _cairo_error (CAIRO_STATUS_INVALID_SIZE); + } *image_out = _cairo_surface_map_to_image (surface, &extents); *image_extra = NULL; + CAIRO_TRACE_END (__func__); return (*image_out)->base.status; } @@ -2120,27 +2233,40 @@ _cairo_surface_paint (cairo_surface_t *surface, const cairo_pattern_t *source, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface->status; - if (unlikely (surface->finished)) + } + if (unlikely (surface->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); + } - if (_cairo_clip_is_all_clipped (clip)) + if (_cairo_clip_is_all_clipped (clip)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } status = _pattern_has_error (source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } - if (nothing_to_do (surface, op, source)) + if (nothing_to_do (surface, op, source)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } status = _cairo_surface_begin_modification (surface); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = surface->backend->paint (surface, op, source, clip); if (status != CAIRO_INT_STATUS_NOTHING_TO_DO) { @@ -2148,6 +2274,7 @@ _cairo_surface_paint (cairo_surface_t *surface, surface->serial++; } + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, status); } @@ -2158,38 +2285,54 @@ _cairo_surface_mask (cairo_surface_t *surface, const cairo_pattern_t *mask, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface->status; - if (unlikely (surface->finished)) + } + if (unlikely (surface->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); + } - if (_cairo_clip_is_all_clipped (clip)) + if (_cairo_clip_is_all_clipped (clip)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } /* If the mask is blank, this is just an expensive no-op */ if (_cairo_pattern_is_clear (mask) && _cairo_operator_bounded_by_mask (op)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } status = _pattern_has_error (source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _pattern_has_error (mask); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } - if (nothing_to_do (surface, op, source)) + if (nothing_to_do (surface, op, source)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } status = _cairo_surface_begin_modification (surface); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = surface->backend->mask (surface, op, source, mask, clip); if (status != CAIRO_INT_STATUS_NOTHING_TO_DO) { @@ -2197,6 +2340,7 @@ _cairo_surface_mask (cairo_surface_t *surface, surface->serial++; } + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, status); } @@ -2217,35 +2361,50 @@ _cairo_surface_fill_stroke (cairo_surface_t *surface, cairo_antialias_t stroke_antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface->status; - if (unlikely (surface->finished)) - return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); - - if (_cairo_clip_is_all_clipped (clip)) - return CAIRO_STATUS_SUCCESS; + } - if (surface->is_clear && - fill_op == CAIRO_OPERATOR_CLEAR && - stroke_op == CAIRO_OPERATOR_CLEAR) - { - return CAIRO_STATUS_SUCCESS; - } + if (unlikely (surface->finished)) { + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); + return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); + } + if (_cairo_clip_is_all_clipped (clip)) { + CAIRO_TRACE_END (__func__); + return CAIRO_STATUS_SUCCESS; + } + + if (surface->is_clear && + fill_op == CAIRO_OPERATOR_CLEAR && + stroke_op == CAIRO_OPERATOR_CLEAR) { + CAIRO_TRACE_END (__func__); + return CAIRO_STATUS_SUCCESS; + } + } - status = _pattern_has_error (fill_source); - if (unlikely (status)) + status = _pattern_has_error (fill_source); + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _pattern_has_error (stroke_source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_surface_begin_modification (surface); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (surface->backend->fill_stroke) { cairo_matrix_t dev_ctm = *stroke_ctm; @@ -2284,6 +2443,7 @@ _cairo_surface_fill_stroke (cairo_surface_t *surface, surface->serial++; } + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, status); } @@ -2299,27 +2459,40 @@ _cairo_surface_stroke (cairo_surface_t *surface, cairo_antialias_t antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface->status; - if (unlikely (surface->finished)) + } + if (unlikely (surface->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); + } - if (_cairo_clip_is_all_clipped (clip)) + if (_cairo_clip_is_all_clipped (clip)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } status = _pattern_has_error (source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } - if (nothing_to_do (surface, op, source)) + if (nothing_to_do (surface, op, source)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } status = _cairo_surface_begin_modification (surface); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = surface->backend->stroke (surface, op, source, path, stroke_style, @@ -2331,6 +2504,7 @@ _cairo_surface_stroke (cairo_surface_t *surface, surface->serial++; } + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, status); } @@ -2344,27 +2518,39 @@ _cairo_surface_fill (cairo_surface_t *surface, cairo_antialias_t antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface->status; - if (unlikely (surface->finished)) + } + if (unlikely (surface->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); - - if (_cairo_clip_is_all_clipped (clip)) + } + if (_cairo_clip_is_all_clipped (clip)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } status = _pattern_has_error (source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } - if (nothing_to_do (surface, op, source)) + if (nothing_to_do (surface, op, source)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } status = _cairo_surface_begin_modification (surface); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = surface->backend->fill (surface, op, source, path, fill_rule, @@ -2375,6 +2561,7 @@ _cairo_surface_fill (cairo_surface_t *surface, surface->serial++; } + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, status); } @@ -2395,20 +2582,27 @@ _cairo_surface_fill (cairo_surface_t *surface, void cairo_surface_copy_page (cairo_surface_t *surface) { - if (unlikely (surface->status)) + CAIRO_TRACE_BEGIN (__func__); + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return; + } assert (surface->snapshot_of == NULL); if (unlikely (surface->finished)) { _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED); + CAIRO_TRACE_END (__func__); return; } /* It's fine if some backends don't implement copy_page */ - if (surface->backend->copy_page == NULL) + if (surface->backend->copy_page == NULL) { + CAIRO_TRACE_END (__func__); return; + } + CAIRO_TRACE_END (__func__); _cairo_surface_set_error (surface, surface->backend->copy_page (surface)); } slim_hidden_def (cairo_surface_copy_page); @@ -2428,26 +2622,34 @@ slim_hidden_def (cairo_surface_copy_page); void cairo_surface_show_page (cairo_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return; + } if (unlikely (surface->finished)) { _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED); + CAIRO_TRACE_END (__func__); return; } status = _cairo_surface_begin_modification (surface); if (unlikely (status)) { _cairo_surface_set_error (surface, status); + CAIRO_TRACE_END (__func__); return; } /* It's fine if some backends don't implement show_page */ - if (surface->backend->show_page == NULL) + if (surface->backend->show_page == NULL) { + CAIRO_TRACE_END (__func__); return; + } + CAIRO_TRACE_END (__func__); _cairo_surface_set_error (surface, surface->backend->show_page (surface)); } slim_hidden_def (cairo_surface_show_page); diff --git a/src/cairo-traps-compositor.c b/src/cairo-traps-compositor.c index c26a5df..8c13ca2 100644 --- a/src/cairo-traps-compositor.c +++ b/src/cairo-traps-compositor.c @@ -59,6 +59,7 @@ #include "cairo-spans-private.h" #include "cairo-traps-private.h" #include "cairo-tristrip-private.h" +#include "cairo-ttrace.h" typedef cairo_int_status_t (*draw_func_t) (const cairo_traps_compositor_t *compositor, @@ -2110,6 +2111,7 @@ static cairo_int_status_t _cairo_traps_compositor_paint (const cairo_compositor_t *_compositor, cairo_composite_rectangles_t *extents) { + CAIRO_TRACE_BEGIN (__func__); cairo_traps_compositor_t *compositor = (cairo_traps_compositor_t*)_compositor; cairo_boxes_t boxes; cairo_int_status_t status; @@ -2117,13 +2119,16 @@ _cairo_traps_compositor_paint (const cairo_compositor_t *_compositor, TRACE ((stderr, "%s\n", __FUNCTION__)); status = compositor->check_composite (extents); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } _cairo_clip_steal_boxes (extents->clip, &boxes); status = clip_and_composite_boxes (compositor, extents, &boxes); _cairo_clip_unsteal_boxes (extents->clip, &boxes); + CAIRO_TRACE_END (__func__); return status; } @@ -2131,14 +2136,17 @@ static cairo_int_status_t _cairo_traps_compositor_mask (const cairo_compositor_t *_compositor, cairo_composite_rectangles_t *extents) { + CAIRO_TRACE_BEGIN (__func__); const cairo_traps_compositor_t *compositor = (cairo_traps_compositor_t*)_compositor; cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); status = compositor->check_composite (extents); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (extents->mask_pattern.base.type == CAIRO_PATTERN_TYPE_SOLID && extents->clip->path == NULL) { @@ -2157,8 +2165,10 @@ _cairo_traps_compositor_mask (const cairo_compositor_t *_compositor, &extents->mask_sample_area, &data.mask_x, &data.mask_y); - if (unlikely (data.mask->status)) + if (unlikely (data.mask->status)) { + CAIRO_TRACE_END (__func__); return data.mask->status; + } status = clip_and_composite (compositor, extents, composite_mask, @@ -2168,6 +2178,7 @@ _cairo_traps_compositor_mask (const cairo_compositor_t *_compositor, cairo_surface_destroy (data.mask); } + CAIRO_TRACE_END (__func__); return status; } @@ -2181,14 +2192,17 @@ _cairo_traps_compositor_stroke (const cairo_compositor_t *_compositor, double tolerance, cairo_antialias_t antialias) { + CAIRO_TRACE_BEGIN (__func__); const cairo_traps_compositor_t *compositor = (cairo_traps_compositor_t *)_compositor; cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); status = compositor->check_composite (extents); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = CAIRO_INT_STATUS_UNSUPPORTED; if (_cairo_path_fixed_stroke_is_rectilinear (path)) { @@ -2265,6 +2279,7 @@ _cairo_traps_compositor_stroke (const cairo_compositor_t *_compositor, _cairo_traps_fini (&info.traps); } + CAIRO_TRACE_END (__func__); return status; } @@ -2276,14 +2291,17 @@ _cairo_traps_compositor_fill (const cairo_compositor_t *_compositor, double tolerance, cairo_antialias_t antialias) { + CAIRO_TRACE_BEGIN (__func__); const cairo_traps_compositor_t *compositor = (cairo_traps_compositor_t *)_compositor; cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); status = compositor->check_composite (extents); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = CAIRO_INT_STATUS_UNSUPPORTED; if (_cairo_path_fixed_fill_is_rectilinear (path)) { @@ -2332,6 +2350,7 @@ _cairo_traps_compositor_fill (const cairo_compositor_t *_compositor, _cairo_polygon_fini (&polygon); } + CAIRO_TRACE_END (__func__); return status; } @@ -2367,14 +2386,17 @@ _cairo_traps_compositor_glyphs (const cairo_compositor_t *_compositor, int num_glyphs, cairo_bool_t overlap) { + CAIRO_TRACE_BEGIN (__func__); const cairo_traps_compositor_t *compositor = (cairo_traps_compositor_t *)_compositor; cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); status = compositor->check_composite (extents); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } _cairo_scaled_font_freeze_cache (scaled_font); status = compositor->check_composite_glyphs (extents, @@ -2395,6 +2417,7 @@ _cairo_traps_compositor_glyphs (const cairo_compositor_t *_compositor, } _cairo_scaled_font_thaw_cache (scaled_font); + CAIRO_TRACE_END (__func__); return status; } diff --git a/src/cairo-ttrace.h b/src/cairo-ttrace.h new file mode 100644 index 0000000..0733ba4 --- /dev/null +++ b/src/cairo-ttrace.h @@ -0,0 +1,47 @@ +/* Cairo - a vector graphics library with display and print output + * + * Copyright © 2009 Chris Wilson + * Copyright © 2014 Samsung Electronics + * + * 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, 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. + * + */ + + +#ifdef CAIRO_HAS_TTRACE +#include +//#define CAIRO_TRACE_BEGIN(NAME) traceBegin(TTRACE_TAG_GRAPHICS, NAME) +//#define CAIRO_TRACE_END() traceEnd(TTRACE_TAG_GRAPHICS) +#define CAIRO_TRACE_BEGIN(NAME) traceAsyncBegin (TTRACE_TAG_GRAPHICS, 0, NAME); +#define CAIRO_TRACE_END(NAME) traceAsyncEnd(TTRACE_TAG_GRAPHICS, 0, NAME); +#else +#define CAIRO_TRACE_BEGIN(NAME) +#define CAIRO_TRACE_END(NAME) +#define CAIRO_TRACE_ASYNC_BEGIN(NAME, KEY) +#define CAIRO_TRACE_ASYNC_END(NAME, KEY) +#endif + + diff --git a/src/cairo.c b/src/cairo.c index 983f02c..d339640 100644 --- a/src/cairo.c +++ b/src/cairo.c @@ -49,6 +49,7 @@ #include "cairo-surface-backend-private.h" #include +#include "cairo-ttrace.h" /** * SECTION:cairo @@ -226,17 +227,28 @@ _cairo_create_in_error (cairo_status_t status) cairo_t * cairo_create (cairo_surface_t *target) { - if (unlikely (target == NULL)) + CAIRO_TRACE_BEGIN (__func__); + if (unlikely (target == NULL)) { + CAIRO_TRACE_END (__func__); return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_NULL_POINTER)); - if (unlikely (target->status)) + } + if (unlikely (target->status)) { + CAIRO_TRACE_END (__func__); return _cairo_create_in_error (target->status); - if (unlikely (target->finished)) + } + if (unlikely (target->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); + } - if (target->backend->create_context == NULL) + if (target->backend->create_context == NULL) { + CAIRO_TRACE_END (__func__); return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_WRITE_ERROR)); + } - return target->backend->create_context (target); + cairo_t *cr = target->backend->create_context (target); + CAIRO_TRACE_END (__func__); + return cr; } slim_hidden_def (cairo_create); @@ -299,15 +311,21 @@ _cairo_fini (cairo_t *cr) void cairo_destroy (cairo_t *cr) { - if (cr == NULL || CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count)) + CAIRO_TRACE_BEGIN (__func__); + if (cr == NULL || CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&cr->ref_count)); - if (! _cairo_reference_count_dec_and_test (&cr->ref_count)) + if (! _cairo_reference_count_dec_and_test (&cr->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } cr->backend->destroy (cr); + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_destroy); @@ -404,14 +422,19 @@ cairo_get_reference_count (cairo_t *cr) void cairo_save (cairo_t *cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->save (cr); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def(cairo_save); @@ -428,14 +451,19 @@ slim_hidden_def(cairo_save); void cairo_restore (cairo_t *cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->restore (cr); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def(cairo_restore); @@ -675,14 +703,19 @@ cairo_set_opacity (cairo_t *cr, double opacity) void cairo_set_source_rgb (cairo_t *cr, double red, double green, double blue) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->set_source_rgba (cr, red, green, blue, 1.); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_set_source_rgb); @@ -753,19 +786,25 @@ cairo_set_source_surface (cairo_t *cr, double x, double y) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } if (unlikely (surface == NULL)) { _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); + CAIRO_TRACE_END (__func__); return; } status = cr->backend->set_source_surface (cr, surface, x, y); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_set_source_surface); @@ -1191,14 +1230,19 @@ cairo_set_miter_limit (cairo_t *cr, double limit) void cairo_translate (cairo_t *cr, double tx, double ty) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->translate (cr, tx, ty); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_translate); @@ -1218,14 +1262,19 @@ slim_hidden_def (cairo_translate); void cairo_scale (cairo_t *cr, double sx, double sy) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->scale (cr, sx, sy); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_scale); @@ -1246,14 +1295,19 @@ slim_hidden_def (cairo_scale); void cairo_rotate (cairo_t *cr, double angle) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->rotate (cr, angle); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -1346,10 +1400,14 @@ cairo_identity_matrix (cairo_t *cr) void cairo_user_to_device (cairo_t *cr, double *x, double *y) { - if (unlikely (cr->status)) + CAIRO_TRACE_BEGIN (__func__); + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } cr->backend->user_to_device (cr, x, y); + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_user_to_device); @@ -1369,10 +1427,14 @@ slim_hidden_def (cairo_user_to_device); void cairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy) { - if (unlikely (cr->status)) + CAIRO_TRACE_BEGIN (__func__); + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } cr->backend->user_to_device_distance (cr, dx, dy); + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_user_to_device_distance); @@ -1391,10 +1453,14 @@ slim_hidden_def (cairo_user_to_device_distance); void cairo_device_to_user (cairo_t *cr, double *x, double *y) { - if (unlikely (cr->status)) + CAIRO_TRACE_BEGIN (__func__); + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } cr->backend->device_to_user (cr, x, y); + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_device_to_user); @@ -1626,10 +1692,13 @@ cairo_arc (cairo_t *cr, double radius, double angle1, double angle2) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } if (angle2 < angle1) { /* increase angle2 by multiples of full circle until it @@ -1642,6 +1711,8 @@ cairo_arc (cairo_t *cr, status = cr->backend->arc (cr, xc, yc, radius, angle1, angle2, TRUE); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -1670,10 +1741,13 @@ cairo_arc_negative (cairo_t *cr, double radius, double angle1, double angle2) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } if (angle2 > angle1) { /* decrease angle2 by multiples of full circle until it @@ -1687,6 +1761,7 @@ cairo_arc_negative (cairo_t *cr, status = cr->backend->arc (cr, xc, yc, radius, angle1, angle2, FALSE); if (unlikely (status)) _cairo_set_error (cr, status); + CAIRO_TRACE_END (__func__); } /* XXX: NYI @@ -1861,14 +1936,19 @@ cairo_rectangle (cairo_t *cr, double x, double y, double width, double height) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->rectangle (cr, x, y, width, height); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -1906,16 +1986,21 @@ cairo_rounded_rectangle (cairo_t *cr, double r_top_left, double r_top_right, double r_bottom_left, double r_bottom_right) { - cairo_status_t status; + CAIRO_TRACE_BEGIN (__func__); + cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->rounded_rectangle (cr, x, y, width, height, r_top_left, r_top_right, r_bottom_left, r_bottom_right); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } #if 0 @@ -2041,14 +2126,19 @@ cairo_path_extents (cairo_t *cr, void cairo_paint (cairo_t *cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->paint (cr); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_paint); @@ -2068,14 +2158,19 @@ void cairo_paint_with_alpha (cairo_t *cr, double alpha) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->paint_with_alpha (cr, alpha); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -2094,24 +2189,31 @@ void cairo_mask (cairo_t *cr, cairo_pattern_t *pattern) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } if (unlikely (pattern == NULL)) { _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); + CAIRO_TRACE_END (__func__); return; } if (unlikely (pattern->status)) { _cairo_set_error (cr, pattern->status); + CAIRO_TRACE_END (__func__); return; } status = cr->backend->mask (cr, pattern); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_mask); @@ -2135,11 +2237,14 @@ cairo_mask_surface (cairo_t *cr, double surface_x, double surface_y) { + CAIRO_TRACE_BEGIN (__func__); cairo_pattern_t *pattern; cairo_matrix_t matrix; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } pattern = cairo_pattern_create_for_surface (surface); @@ -2149,6 +2254,7 @@ cairo_mask_surface (cairo_t *cr, cairo_mask (cr, pattern); cairo_pattern_destroy (pattern); + CAIRO_TRACE_END (__func__); } /** @@ -2188,14 +2294,19 @@ cairo_mask_surface (cairo_t *cr, void cairo_stroke (cairo_t *cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->stroke (cr); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def(cairo_stroke); @@ -2217,14 +2328,19 @@ slim_hidden_def(cairo_stroke); void cairo_stroke_preserve (cairo_t *cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->stroke_preserve (cr); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def(cairo_stroke_preserve); @@ -2243,14 +2359,19 @@ slim_hidden_def(cairo_stroke_preserve); void cairo_fill (cairo_t *cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->fill (cr); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -2269,14 +2390,19 @@ cairo_fill (cairo_t *cr) void cairo_fill_preserve (cairo_t *cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->fill_preserve (cr); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def(cairo_fill_preserve); @@ -2436,6 +2562,7 @@ void cairo_stroke_extents (cairo_t *cr, double *x1, double *y1, double *x2, double *y2) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; if (unlikely (cr->status)) { @@ -2448,12 +2575,15 @@ cairo_stroke_extents (cairo_t *cr, if (y2) *y2 = 0.0; + CAIRO_TRACE_END (__func__); return; } status = cr->backend->stroke_extents (cr, x1, y1, x2, y2); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -2487,6 +2617,7 @@ void cairo_fill_extents (cairo_t *cr, double *x1, double *y1, double *x2, double *y2) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; if (unlikely (cr->status)) { @@ -2499,12 +2630,15 @@ cairo_fill_extents (cairo_t *cr, if (y2) *y2 = 0.0; + CAIRO_TRACE_END (__func__); return; } status = cr->backend->fill_extents (cr, x1, y1, x2, y2); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -2631,6 +2765,7 @@ cairo_clip_extents (cairo_t *cr, double *x1, double *y1, double *x2, double *y2) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; if (x1) @@ -2642,12 +2777,16 @@ cairo_clip_extents (cairo_t *cr, if (y2) *y2 = 0.0; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->clip_extents (cr, x1, y1, x2, y2); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -3242,6 +3381,7 @@ cairo_glyph_extents (cairo_t *cr, void cairo_show_text (cairo_t *cr, const char *utf8) { + CAIRO_TRACE_BEGIN (__func__); cairo_text_extents_t extents; cairo_status_t status; cairo_glyph_t *glyphs, *last_glyph; @@ -3255,15 +3395,20 @@ cairo_show_text (cairo_t *cr, const char *utf8) cairo_scaled_font_t *scaled_font; cairo_glyph_text_info_t info, *i; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } - if (utf8 == NULL) + if (utf8 == NULL) { + CAIRO_TRACE_END (__func__); return; + } scaled_font = cairo_get_scaled_font (cr); if (unlikely (scaled_font->status)) { _cairo_set_error (cr, scaled_font->status); + CAIRO_TRACE_END (__func__); return; } @@ -3293,8 +3438,10 @@ cairo_show_text (cairo_t *cr, const char *utf8) if (unlikely (status)) goto BAIL; - if (num_glyphs == 0) + if (num_glyphs == 0) { + CAIRO_TRACE_END (__func__); return; + } i = NULL; if (has_show_text_glyphs) { @@ -3327,6 +3474,8 @@ cairo_show_text (cairo_t *cr, const char *utf8) if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -3344,27 +3493,36 @@ cairo_show_text (cairo_t *cr, const char *utf8) void cairo_show_glyphs (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } - if (num_glyphs == 0) + if (num_glyphs == 0) { + CAIRO_TRACE_END (__func__); return; + } if (num_glyphs < 0) { _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT); + CAIRO_TRACE_END (__func__); return; } if (glyphs == NULL) { _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); + CAIRO_TRACE_END (__func__); return; } status = cr->backend->glyphs (cr, glyphs, num_glyphs, NULL); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -3411,10 +3569,13 @@ cairo_show_text_glyphs (cairo_t *cr, int num_clusters, cairo_text_cluster_flags_t cluster_flags) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } /* A slew of sanity checks */ @@ -3427,6 +3588,7 @@ cairo_show_text_glyphs (cairo_t *cr, (utf8_len && utf8 == NULL) || (num_clusters && clusters == NULL)) { _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); + CAIRO_TRACE_END (__func__); return; } @@ -3437,11 +3599,14 @@ cairo_show_text_glyphs (cairo_t *cr, /* Apart from that, no negatives */ if (num_glyphs < 0 || utf8_len < 0 || num_clusters < 0) { _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT); + CAIRO_TRACE_END (__func__); return; } - if (num_glyphs == 0 && utf8_len == 0) + if (num_glyphs == 0 && utf8_len == 0) { + CAIRO_TRACE_END (__func__); return; + } if (utf8) { /* Make sure clusters cover the entire glyphs and utf8 arrays, @@ -3474,6 +3639,8 @@ cairo_show_text_glyphs (cairo_t *cr, } if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -3505,6 +3672,7 @@ cairo_show_text_glyphs (cairo_t *cr, void cairo_text_path (cairo_t *cr, const char *utf8) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; cairo_text_extents_t extents; cairo_glyph_t stack_glyphs[CAIRO_STACK_ARRAY_LENGTH (cairo_glyph_t)]; @@ -3513,11 +3681,15 @@ cairo_text_path (cairo_t *cr, const char *utf8) int num_glyphs; double x, y; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } - if (utf8 == NULL) + if (utf8 == NULL) { + CAIRO_TRACE_END (__func__); return; + } glyphs = stack_glyphs; @@ -3526,6 +3698,7 @@ cairo_text_path (cairo_t *cr, const char *utf8) scaled_font = cairo_get_scaled_font (cr); if (unlikely (scaled_font->status)) { _cairo_set_error (cr, scaled_font->status); + CAIRO_TRACE_END (__func__); return; } @@ -3536,8 +3709,10 @@ cairo_text_path (cairo_t *cr, const char *utf8) &glyphs, &num_glyphs, NULL, NULL, NULL); - if (num_glyphs == 0) + if (num_glyphs == 0) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->glyph_path (cr, glyphs, num_glyphs); @@ -3560,6 +3735,8 @@ cairo_text_path (cairo_t *cr, const char *utf8) if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -3577,27 +3754,36 @@ cairo_text_path (cairo_t *cr, const char *utf8) void cairo_glyph_path (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } - if (num_glyphs == 0) + if (num_glyphs == 0) { + CAIRO_TRACE_END (__func__); return; + } if (unlikely (num_glyphs < 0)) { _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT); + CAIRO_TRACE_END (__func__); return; } if (unlikely (glyphs == NULL)) { _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); + CAIRO_TRACE_END (__func__); return; } status = cr->backend->glyph_path (cr, glyphs, num_glyphs); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** -- 2.7.4 From b590fc75e24685bfdcc42d8b6eaa27a9d4449d98 Mon Sep 17 00:00:00 2001 From: "mh0310.choi" Date: Fri, 1 Jul 2016 15:21:45 +0900 Subject: [PATCH 02/16] Remove boilerplate/ - The code in boilerplate might be useful guide to use a paticular backend Change-Id: Idae1f33b05a3a512ad6045e44f0b0d6bb3a304bb --- Makefile.am | 3 +- Makefile.win32 | 1 - autogen.sh | 1 - boilerplate/.gitignore | 24 - boilerplate/Makefile.am | 80 -- boilerplate/Makefile.sources | 43 - boilerplate/Makefile.win32 | 24 - boilerplate/Makefile.win32.features | 568 ---------- boilerplate/README | 14 - boilerplate/cairo-boilerplate-beos.cpp | 273 ----- boilerplate/cairo-boilerplate-cgl.c | 150 --- boilerplate/cairo-boilerplate-cogl.c | 206 ---- boilerplate/cairo-boilerplate-directfb.c | 235 ----- boilerplate/cairo-boilerplate-drm.c | 112 -- boilerplate/cairo-boilerplate-egl.c | 202 ---- boilerplate/cairo-boilerplate-evas-gl.c | 148 --- boilerplate/cairo-boilerplate-getopt.c | 247 ----- boilerplate/cairo-boilerplate-getopt.h | 63 -- boilerplate/cairo-boilerplate-glx.c | 457 -------- boilerplate/cairo-boilerplate-pdf.c | 278 ----- boilerplate/cairo-boilerplate-private.h | 53 - boilerplate/cairo-boilerplate-ps.c | 369 ------- boilerplate/cairo-boilerplate-qt.cpp | 114 -- boilerplate/cairo-boilerplate-quartz.c | 76 -- boilerplate/cairo-boilerplate-scaled-font.h | 34 - boilerplate/cairo-boilerplate-script.c | 141 --- boilerplate/cairo-boilerplate-skia.c | 55 - boilerplate/cairo-boilerplate-svg.c | 344 ------ boilerplate/cairo-boilerplate-system.c | 166 --- boilerplate/cairo-boilerplate-system.h | 59 -- boilerplate/cairo-boilerplate-test-surfaces.c | 462 -------- boilerplate/cairo-boilerplate-vg.c | 363 ------- boilerplate/cairo-boilerplate-wgl.c | 239 ----- boilerplate/cairo-boilerplate-win32-printing.c | 407 -------- boilerplate/cairo-boilerplate-win32.c | 77 -- boilerplate/cairo-boilerplate-xcb.c | 876 ---------------- boilerplate/cairo-boilerplate-xlib.c | 638 ------------ boilerplate/cairo-boilerplate-xlib.h | 33 - boilerplate/cairo-boilerplate.c | 1101 -------------------- boilerplate/cairo-boilerplate.h | 252 ----- boilerplate/check-link.c | 24 - boilerplate/make-cairo-boilerplate-constructors.sh | 29 - build/Makefile.am.analysis | 1 - build/configure.ac.features | 3 +- configure.ac | 1 - 45 files changed, 2 insertions(+), 9044 deletions(-) delete mode 100644 boilerplate/.gitignore delete mode 100644 boilerplate/Makefile.am delete mode 100644 boilerplate/Makefile.sources delete mode 100644 boilerplate/Makefile.win32 delete mode 100644 boilerplate/Makefile.win32.features delete mode 100644 boilerplate/README delete mode 100644 boilerplate/cairo-boilerplate-beos.cpp delete mode 100644 boilerplate/cairo-boilerplate-cgl.c delete mode 100644 boilerplate/cairo-boilerplate-cogl.c delete mode 100644 boilerplate/cairo-boilerplate-directfb.c delete mode 100644 boilerplate/cairo-boilerplate-drm.c delete mode 100644 boilerplate/cairo-boilerplate-egl.c delete mode 100644 boilerplate/cairo-boilerplate-evas-gl.c delete mode 100644 boilerplate/cairo-boilerplate-getopt.c delete mode 100644 boilerplate/cairo-boilerplate-getopt.h delete mode 100644 boilerplate/cairo-boilerplate-glx.c delete mode 100644 boilerplate/cairo-boilerplate-pdf.c delete mode 100644 boilerplate/cairo-boilerplate-private.h delete mode 100644 boilerplate/cairo-boilerplate-ps.c delete mode 100644 boilerplate/cairo-boilerplate-qt.cpp delete mode 100644 boilerplate/cairo-boilerplate-quartz.c delete mode 100644 boilerplate/cairo-boilerplate-scaled-font.h delete mode 100644 boilerplate/cairo-boilerplate-script.c delete mode 100644 boilerplate/cairo-boilerplate-skia.c delete mode 100644 boilerplate/cairo-boilerplate-svg.c delete mode 100644 boilerplate/cairo-boilerplate-system.c delete mode 100644 boilerplate/cairo-boilerplate-system.h delete mode 100644 boilerplate/cairo-boilerplate-test-surfaces.c delete mode 100644 boilerplate/cairo-boilerplate-vg.c delete mode 100644 boilerplate/cairo-boilerplate-wgl.c delete mode 100644 boilerplate/cairo-boilerplate-win32-printing.c delete mode 100644 boilerplate/cairo-boilerplate-win32.c delete mode 100644 boilerplate/cairo-boilerplate-xcb.c delete mode 100644 boilerplate/cairo-boilerplate-xlib.c delete mode 100644 boilerplate/cairo-boilerplate-xlib.h delete mode 100644 boilerplate/cairo-boilerplate.c delete mode 100644 boilerplate/cairo-boilerplate.h delete mode 100644 boilerplate/check-link.c delete mode 100644 boilerplate/make-cairo-boilerplate-constructors.sh diff --git a/Makefile.am b/Makefile.am index 5fc8e3d..f655811 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,12 +18,11 @@ ACLOCAL_AMFLAGS = -I build ${ACLOCAL_FLAGS} #DIST_SUBDIRS = src doc util boilerplate test perf #SUBDIRS = src doc util -DIST_SUBDIRS = src util boilerplate +DIST_SUBDIRS = src util SUBDIRS = src util # libpng is required for our test programs if CAIRO_HAS_PNG_FUNCTIONS #SUBDIRS += boilerplate test perf -SUBDIRS += boilerplate endif configure: cairo-version.h diff --git a/Makefile.win32 b/Makefile.win32 index fbad7f3..f0549b4 100644 --- a/Makefile.win32 +++ b/Makefile.win32 @@ -18,7 +18,6 @@ test: inform @$(MAKE) -C test -f Makefile.win32 test clean: - @$(MAKE) -C boilerplate -f Makefile.win32 clean @$(MAKE) -C perf -f Makefile.win32 clean @$(MAKE) -C src -f Makefile.win32 clean @$(MAKE) -C test -f Makefile.win32 clean diff --git a/autogen.sh b/autogen.sh index 4d113f8..8ec9587 100755 --- a/autogen.sh +++ b/autogen.sh @@ -21,7 +21,6 @@ else fi # create dummy */Makefile.am.features and ChangeLog to make automake happy -> boilerplate/Makefile.am.features > src/Makefile.am.features touch ChangeLog diff --git a/boilerplate/.gitignore b/boilerplate/.gitignore deleted file mode 100644 index a81663b..0000000 --- a/boilerplate/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -TAGS -tags -Makefile -Makefile.in -Makefile.am.features -#Makefile.win32.features -*.lo -*.la -*.exe -*.manifest -*.o -*.gcda -*.gcno -*.obj -*.ilk -*.suo -*.lib -*.pdb -*~ -.*.sw? -check-link -cairo-boilerplate-constructors.c -cairo-boilerplate-constructors -make-cairo-boilerplate-constructors diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am deleted file mode 100644 index 240736c..0000000 --- a/boilerplate/Makefile.am +++ /dev/null @@ -1,80 +0,0 @@ -# Note: All source files are listed in Makefile.sources. - -include $(top_srcdir)/build/Makefile.am.common -include $(srcdir)/Makefile.am.features - -EXTRA_DIST += Makefile.win32 Makefile.win32.features -#MAINTAINERCLEANFILES += $(srcdir)/Makefile.win32.features - -AM_CPPFLAGS = \ - -I$(srcdir) \ - -I$(top_builddir)/src \ - -I$(top_srcdir)/src \ - $(CAIRO_CFLAGS) \ - $(NULL) -AM_LDFLAGS = $(CAIRO_LDFLAGS) - -if BUILD_CXX -cxx_boilerplate_lib = libcairoboilerplate_cxx.la -else -cxx_boilerplate_lib = -endif - -EXTRA_LTLIBRARIES += libcairoboilerplate.la $(cxx_boilerplate_lib) -#lib_LTLIBRARIES = libcairoboilerplate.la $(cxx_boilerplate_lib) - -libcairoboilerplate_la_SOURCES = \ - $(enabled_cairo_boilerplate_headers) \ - $(enabled_cairo_boilerplate_private) \ - $(enabled_cairo_boilerplate_sources) \ - cairo-boilerplate-constructors.c \ - $(NULL) -libcairoboilerplate_cxx_la_SOURCES = \ - $(enabled_cairo_boilerplate_cxx_sources) \ - $(NULL) -libcairoboilerplate_la_LIBADD = $(top_builddir)/src/libcairo.la \ - $(cxx_boilerplate_lib) \ - $(CAIRO_LIBS) \ - $(CAIROBOILERPLATE_LIBS) \ - $(NULL) -libcairoboilerplate_cxx_la_LIBADD = $(top_builddir)/src/libcairo.la \ - $(CAIRO_LIBS) \ - $(CAIROBOILERPLATE_LIBS) \ - $(NULL) -libcairoboilerplate_la_DEPENDENCIES = \ - $(cxx_boilerplate_lib) \ - $(NULL) - -if CAIRO_HAS_DL -libcairoboilerplate_la_LIBADD += -ldl -endif - -if CAIRO_HAS_BEOS_SURFACE -# BeOS system headers trigger this warning -libcairoboilerplate_cxx_la_CXXFLAGS = -Wno-multichar -endif - -if CAIRO_HAS_WIN32_SURFACE -libcairoboilerplate_la_LIBADD += -lwinspool -endif - -if CAIRO_HAS_CGL_FUNCTIONS -libcairoboilerplate_la_LDFLAGS = -framework OpenGL -endif - -cairo-boilerplate-constructors.c: Makefile $(enabled_cairo_boilerplate_sources) $(enabled_cairo_boilerplate_cxx_sources) make-cairo-boilerplate-constructors.sh - (cd $(srcdir) && sh ./make-cairo-boilerplate-constructors.sh $(enabled_cairo_boilerplate_sources) $(enabled_cairo_boilerplate_cxx_sources)) > $@ - -BUILT_SOURCES += cairo-boilerplate-constructors.c -EXTRA_DIST += $(BUILT_SOURCES) make-cairo-boilerplate-constructors.sh -CLEANFILES += $(BUILT_SOURCES) - -test: check - -if CROSS_COMPILING -else -TESTS += check-link$(EXEEXT) -endif - -check_PROGRAMS += check-link -check_link_LDADD = libcairoboilerplate.la diff --git a/boilerplate/Makefile.sources b/boilerplate/Makefile.sources deleted file mode 100644 index 73dbd77..0000000 --- a/boilerplate/Makefile.sources +++ /dev/null @@ -1,43 +0,0 @@ -# Makefile.sources -# -# This file is pretty similar to $(top_srcdir)/src/Makefile.sources, -# but for boilerplate. Unlike that file, there are no special headers. -# - -cairo_boilerplate_headers = \ - cairo-boilerplate-getopt.h \ - cairo-boilerplate-scaled-font.h \ - cairo-boilerplate-system.h \ - cairo-boilerplate.h \ - $(NULL) -cairo_boilerplate_sources = \ - cairo-boilerplate-getopt.c \ - cairo-boilerplate-system.c \ - cairo-boilerplate.c \ - $(NULL) -cairo_boilerplate_private = \ - cairo-boilerplate-private.h \ - $(NULL) - -cairo_boilerplate_beos_cxx_sources = cairo-boilerplate-beos.cpp -cairo_boilerplate_directfb_sources = cairo-boilerplate-directfb.c -cairo_boilerplate_drm_sources = cairo-boilerplate-drm.c -cairo_boilerplate_glx_sources = cairo-boilerplate-glx.c -cairo_boilerplate_wgl_sources = cairo-boilerplate-wgl.c -cairo_boilerplate_cgl_sources = cairo-boilerplate-cgl.c -cairo_boilerplate_egl_sources = cairo-boilerplate-egl.c -cairo_boilerplate_evasgl_sources = cairo-boilerplate-evas-gl.c -cairo_boilerplate_pdf_sources = cairo-boilerplate-pdf.c -cairo_boilerplate_ps_sources = cairo-boilerplate-ps.c -cairo_boilerplate_qt_cxx_sources = cairo-boilerplate-qt.cpp -cairo_boilerplate_quartz_sources = cairo-boilerplate-quartz.c -cairo_boilerplate_script_sources = cairo-boilerplate-script.c -cairo_boilerplate_skia_sources = cairo-boilerplate-skia.c -cairo_boilerplate_svg_sources = cairo-boilerplate-svg.c -cairo_boilerplate_test_surfaces_sources = cairo-boilerplate-test-surfaces.c -cairo_boilerplate_win32_sources = cairo-boilerplate-win32.c cairo-boilerplate-win32-printing.c -cairo_boilerplate_xcb_sources = cairo-boilerplate-xcb.c -cairo_boilerplate_xlib_headers = cairo-boilerplate-xlib.h -cairo_boilerplate_xlib_sources = cairo-boilerplate-xlib.c -cairo_boilerplate_vg_sources = cairo-boilerplate-vg.c -cairo_boilerplate_cogl_sources = cairo-boilerplate-cogl.c diff --git a/boilerplate/Makefile.win32 b/boilerplate/Makefile.win32 deleted file mode 100644 index 29df5cf..0000000 --- a/boilerplate/Makefile.win32 +++ /dev/null @@ -1,24 +0,0 @@ -top_srcdir = .. -include $(top_srcdir)/build/Makefile.win32.common -include Makefile.win32.features - -HEADERS = \ - $(enabled_cairo_boilerplate_headers) \ - $(enabled_cairo_boilerplate_private) \ - $(NULL) - -SOURCES = \ - $(enabled_cairo_boilerplate_sources) \ - cairo-boilerplate-constructors.c \ - $(NULL) - -OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(SOURCES)) - -cairo-boilerplate-constructors.c: Makefile.sources Makefile.win32 $(enabled_cairo_boilerplate_sources) make-cairo-boilerplate-constructors.sh - sh ./make-cairo-boilerplate-constructors.sh $(enabled_cairo_boilerplate_sources) > $@ - -all: $(CFG)/boiler.lib - - -$(CFG)/boiler.lib: $(OBJECTS) - @$(AR) $(CAIRO_ARFLAGS) -OUT:$@ $(OBJECTS) diff --git a/boilerplate/Makefile.win32.features b/boilerplate/Makefile.win32.features deleted file mode 100644 index c93b3b8..0000000 --- a/boilerplate/Makefile.win32.features +++ /dev/null @@ -1,568 +0,0 @@ -# Generated by configure. Do not edit. - -ifeq ($(top_srcdir),) -include Makefile.sources -else -include $(top_srcdir)/boilerplate/Makefile.sources -endif - -supported_cairo_boilerplate_headers = $(cairo_boilerplate_headers) -unsupported_cairo_boilerplate_headers = -all_cairo_boilerplate_headers = $(cairo_boilerplate_headers) -all_cairo_boilerplate_private = $(cairo_boilerplate_private) -all_cairo_boilerplate_cxx_sources = $(cairo_boilerplate_cxx_sources) -all_cairo_boilerplate_sources = $(cairo_boilerplate_sources) - -enabled_cairo_boilerplate_headers = $(cairo_boilerplate_headers) -enabled_cairo_boilerplate_private = $(cairo_boilerplate_private) -enabled_cairo_boilerplate_cxx_sources = $(cairo_boilerplate_cxx_sources) -enabled_cairo_boilerplate_sources = $(cairo_boilerplate_sources) - - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_xlib_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xlib_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_xlib_sources) -ifeq ($(CAIRO_HAS_XLIB_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_xlib_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xlib_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_xlib_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_xrender_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_xrender_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_xlib_xrender_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xlib_xrender_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_xlib_xrender_sources) -ifeq ($(CAIRO_HAS_XLIB_XRENDER_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_xrender_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_xlib_xrender_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xlib_xrender_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_xlib_xrender_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_xcb_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xcb_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_xcb_sources) -ifeq ($(CAIRO_HAS_XCB_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_xcb_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xcb_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_xcb_sources) -endif - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_xcb_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_xcb_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_xlib_xcb_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xlib_xcb_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_xlib_xcb_sources) -ifeq ($(CAIRO_HAS_XLIB_XCB_FUNCTIONS),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_xcb_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_xlib_xcb_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xlib_xcb_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_xlib_xcb_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_shm_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_shm_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_xcb_shm_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xcb_shm_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_xcb_shm_sources) -ifeq ($(CAIRO_HAS_XCB_SHM_FUNCTIONS),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_shm_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_xcb_shm_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xcb_shm_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_xcb_shm_sources) -endif - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_qt_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_qt_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_qt_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_qt_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_qt_sources) -ifeq ($(CAIRO_HAS_QT_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_qt_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_qt_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_qt_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_qt_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_quartz_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_quartz_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_quartz_sources) -ifeq ($(CAIRO_HAS_QUARTZ_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_quartz_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_quartz_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_quartz_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_font_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_font_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_quartz_font_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_quartz_font_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_quartz_font_sources) -ifeq ($(CAIRO_HAS_QUARTZ_FONT),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_font_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_quartz_font_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_quartz_font_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_quartz_font_sources) -endif - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_image_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_image_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_quartz_image_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_quartz_image_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_quartz_image_sources) -ifeq ($(CAIRO_HAS_QUARTZ_IMAGE_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_image_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_quartz_image_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_quartz_image_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_quartz_image_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_win32_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_win32_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_win32_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_win32_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_win32_sources) -ifeq ($(CAIRO_HAS_WIN32_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_win32_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_win32_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_win32_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_win32_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_win32_font_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_win32_font_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_win32_font_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_win32_font_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_win32_font_sources) -ifeq ($(CAIRO_HAS_WIN32_FONT),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_win32_font_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_win32_font_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_win32_font_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_win32_font_sources) -endif - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_skia_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_skia_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_skia_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_skia_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_skia_sources) -ifeq ($(CAIRO_HAS_SKIA_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_skia_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_skia_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_skia_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_skia_sources) -endif - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_os2_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_os2_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_os2_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_os2_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_os2_sources) -ifeq ($(CAIRO_HAS_OS2_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_os2_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_os2_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_os2_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_os2_sources) -endif - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_beos_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_beos_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_beos_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_beos_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_beos_sources) -ifeq ($(CAIRO_HAS_BEOS_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_beos_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_beos_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_beos_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_beos_sources) -endif - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_drm_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_drm_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_drm_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_drm_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_drm_sources) -ifeq ($(CAIRO_HAS_DRM_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_drm_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_drm_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_drm_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_drm_sources) -endif - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_gallium_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_gallium_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_gallium_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_gallium_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_gallium_sources) -ifeq ($(CAIRO_HAS_GALLIUM_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_gallium_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_gallium_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_gallium_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_gallium_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_png_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_png_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_png_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_png_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_png_sources) -ifeq ($(CAIRO_HAS_PNG_FUNCTIONS),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_png_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_png_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_png_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_png_sources) -endif - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_gl_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_gl_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_gl_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_gl_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_gl_sources) -ifeq ($(CAIRO_HAS_GL_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_gl_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_gl_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_gl_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_gl_sources) -endif - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_evasgl_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_evasgl_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_evasgl_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_evasgl_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_evasgl_sources) -ifeq ($(CAIRO_HAS_EVASGL_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_evasgl_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_evasgl_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_evasgl_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_evasgl_sources) -endif - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_glesv2_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_glesv2_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_glesv2_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_glesv2_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_glesv2_sources) -ifeq ($(CAIRO_HAS_GLESV2_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_glesv2_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_glesv2_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_glesv2_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_glesv2_sources) -endif - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_glesv3_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_glesv3_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_glesv3_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_glesv3_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_glesv3_sources) -ifeq ($(CAIRO_HAS_GLESV3_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_glesv3_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_glesv3_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_glesv3_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_glesv3_sources) -endif - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_cogl_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_cogl_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_cogl_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_cogl_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_cogl_sources) -ifeq ($(CAIRO_HAS_COGL_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_cogl_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_cogl_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_cogl_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_cogl_sources) -endif - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_directfb_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_directfb_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_directfb_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_directfb_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_directfb_sources) -ifeq ($(CAIRO_HAS_DIRECTFB_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_directfb_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_directfb_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_directfb_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_directfb_sources) -endif - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_vg_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_vg_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_vg_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_vg_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_vg_sources) -ifeq ($(CAIRO_HAS_VG_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_vg_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_vg_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_vg_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_vg_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_egl_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_egl_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_egl_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_egl_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_egl_sources) -ifeq ($(CAIRO_HAS_EGL_FUNCTIONS),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_egl_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_egl_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_egl_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_egl_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_glx_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_glx_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_glx_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_glx_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_glx_sources) -ifeq ($(CAIRO_HAS_GLX_FUNCTIONS),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_glx_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_glx_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_glx_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_glx_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_cgl_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_cgl_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_cgl_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_cgl_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_cgl_sources) -ifeq ($(CAIRO_HAS_CGL_FUNCTIONS),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_cgl_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_cgl_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_cgl_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_cgl_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_wgl_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_wgl_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_wgl_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_wgl_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_wgl_sources) -ifeq ($(CAIRO_HAS_WGL_FUNCTIONS),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_wgl_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_wgl_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_wgl_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_wgl_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_script_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_script_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_script_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_script_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_script_sources) -ifeq ($(CAIRO_HAS_SCRIPT_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_script_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_script_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_script_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_script_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_ft_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_ft_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_ft_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_ft_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_ft_sources) -ifeq ($(CAIRO_HAS_FT_FONT),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_ft_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_ft_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_ft_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_ft_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_fc_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_fc_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_fc_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_fc_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_fc_sources) -ifeq ($(CAIRO_HAS_FC_FONT),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_fc_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_fc_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_fc_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_fc_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_ps_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_ps_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_ps_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_ps_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_ps_sources) -ifeq ($(CAIRO_HAS_PS_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_ps_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_ps_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_ps_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_ps_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_pdf_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_pdf_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_pdf_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_pdf_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_pdf_sources) -ifeq ($(CAIRO_HAS_PDF_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_pdf_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_pdf_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_pdf_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_pdf_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_svg_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_svg_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_svg_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_svg_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_svg_sources) -ifeq ($(CAIRO_HAS_SVG_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_svg_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_svg_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_svg_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_svg_sources) -endif - -all_cairo_boilerplate_private += $(cairo_boilerplate_test_surfaces_private) $(cairo_boilerplate_test_surfaces_headers) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_test_surfaces_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_test_surfaces_sources) -ifeq ($(CAIRO_HAS_TEST_SURFACES),1) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_test_surfaces_private) $(cairo_boilerplate_test_surfaces_headers) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_test_surfaces_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_test_surfaces_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_image_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_image_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_image_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_image_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_image_sources) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_image_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_image_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_image_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_image_sources) - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_mime_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_mime_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_mime_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_mime_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_mime_sources) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_mime_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_mime_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_mime_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_mime_sources) - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_recording_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_recording_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_recording_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_recording_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_recording_sources) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_recording_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_recording_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_recording_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_recording_sources) - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_observer_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_observer_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_observer_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_observer_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_observer_sources) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_observer_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_observer_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_observer_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_observer_sources) - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_tee_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_tee_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_tee_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_tee_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_tee_sources) -ifeq ($(CAIRO_HAS_TEE_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_tee_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_tee_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_tee_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_tee_sources) -endif - -unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_xml_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_xml_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_xml_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xml_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_xml_sources) -ifeq ($(CAIRO_HAS_XML_SURFACE),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_xml_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_xml_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xml_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_xml_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_user_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_user_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_user_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_user_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_user_sources) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_user_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_user_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_user_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_user_sources) - -all_cairo_boilerplate_private += $(cairo_boilerplate_pthread_private) $(cairo_boilerplate_pthread_headers) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_pthread_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_pthread_sources) -ifeq ($(CAIRO_HAS_PTHREAD),1) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_pthread_private) $(cairo_boilerplate_pthread_headers) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_pthread_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_pthread_sources) -endif - -supported_cairo_boilerplate_headers += $(cairo_boilerplate_gobject_headers) -all_cairo_boilerplate_headers += $(cairo_boilerplate_gobject_headers) -all_cairo_boilerplate_private += $(cairo_boilerplate_gobject_private) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_gobject_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_gobject_sources) -ifeq ($(CAIRO_HAS_GOBJECT_FUNCTIONS),1) -enabled_cairo_boilerplate_headers += $(cairo_boilerplate_gobject_headers) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_gobject_private) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_gobject_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_gobject_sources) -endif - -all_cairo_boilerplate_private += $(cairo_boilerplate_trace_private) $(cairo_boilerplate_trace_headers) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_trace_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_trace_sources) -ifeq ($(CAIRO_HAS_TRACE),1) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_trace_private) $(cairo_boilerplate_trace_headers) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_trace_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_trace_sources) -endif - -all_cairo_boilerplate_private += $(cairo_boilerplate_ttrace_private) $(cairo_boilerplate_ttrace_headers) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_ttrace_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_ttrace_sources) -ifeq ($(CAIRO_HAS_TTRACE),1) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_ttrace_private) $(cairo_boilerplate_ttrace_headers) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_ttrace_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_ttrace_sources) -endif - -all_cairo_boilerplate_private += $(cairo_boilerplate_interpreter_private) $(cairo_boilerplate_interpreter_headers) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_interpreter_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_interpreter_sources) -ifeq ($(CAIRO_HAS_INTERPRETER),1) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_interpreter_private) $(cairo_boilerplate_interpreter_headers) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_interpreter_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_interpreter_sources) -endif - -all_cairo_boilerplate_private += $(cairo_boilerplate_symbol_lookup_private) $(cairo_boilerplate_symbol_lookup_headers) -all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_symbol_lookup_cxx_sources) -all_cairo_boilerplate_sources += $(cairo_boilerplate_symbol_lookup_sources) -ifeq ($(CAIRO_HAS_SYMBOL_LOOKUP),1) -enabled_cairo_boilerplate_private += $(cairo_boilerplate_symbol_lookup_private) $(cairo_boilerplate_symbol_lookup_headers) -enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_symbol_lookup_cxx_sources) -enabled_cairo_boilerplate_sources += $(cairo_boilerplate_symbol_lookup_sources) -endif diff --git a/boilerplate/README b/boilerplate/README deleted file mode 100644 index 2a27c41..0000000 --- a/boilerplate/README +++ /dev/null @@ -1,14 +0,0 @@ -This directory provides code that is common to both of cairo's tests -suites: - - * The test suite for correctness in test/ - * The test suite for performance in perf/ - -We call it boilerplate as it consists primarily of the boilerplate -code necessary for initializing a backend in order to create a surface -for that backend. - -The code here just might be useful for someone looking to get started -writing cairo code to use a particular backend, (but there are no -promises that the boilerplate code found here for any particular -backend is exemplary). diff --git a/boilerplate/cairo-boilerplate-beos.cpp b/boilerplate/cairo-boilerplate-beos.cpp deleted file mode 100644 index 8a1b1af..0000000 --- a/boilerplate/cairo-boilerplate-beos.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/* vim:set ts=8 sw=4 noet cin: */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.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/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Takashi Toyoshima - * Fredrik Holmqvist - * Christian Biesinger - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "cairo-boilerplate.h" -#include - -// Part of this code was originally part of -// xpfe/bootstrap/nsNativeAppSupportBeOS.cpp in the Mozilla source code. - -#include -#include -#include -#include - -class CairoTestWindow : public BWindow -{ -public: - CairoTestWindow(BRect frame, const char* title); - virtual ~CairoTestWindow(); - BView* View() const { return mView; } -private: - BView* mView; -}; - -CairoTestWindow::CairoTestWindow(BRect frame, const char* title) - : BWindow(frame, title, B_TITLED_WINDOW, - B_NOT_RESIZABLE|B_NOT_ZOOMABLE) -{ - mView = new BView(frame, "CairoWindowTestView", B_FOLLOW_ALL_SIDES, 0); - AddChild(mView); - Show(); - - // Make sure the window is actually on screen - Lock(); - Sync(); - mView->SetViewColor(B_TRANSPARENT_COLOR); - mView->Sync(); - Unlock(); -} - -CairoTestWindow::~CairoTestWindow() -{ - RemoveChild(mView); - delete mView; -} - - -class nsBeOSApp : public BApplication -{ -public: - nsBeOSApp(sem_id sem) : BApplication(GetAppSig()), init(sem) - {} - - void ReadyToRun() - { - release_sem(init); - } - - static int32 Main(void *args) - { - nsBeOSApp *app = new nsBeOSApp( (sem_id)args ); - if(app == NULL) - return B_ERROR; - return app->Run(); - } - -private: - - const char *GetAppSig() - { - return "application/x-vnd.cairo-test-app"; - } - - sem_id init; -}; //class nsBeOSApp - -class AppRunner -{ - public: - AppRunner(); - ~AppRunner(); -}; - -AppRunner::AppRunner() -{ - if (be_app) - return; - - sem_id initsem = create_sem(0, "Cairo BApplication init"); - if (initsem < B_OK) { - fprintf (stderr, "Error creating BeOS initialization semaphore\n"); - return; - } - - thread_id tid = spawn_thread(nsBeOSApp::Main, "Cairo/BeOS test", B_NORMAL_PRIORITY, (void *)initsem); - if (tid < B_OK || B_OK != resume_thread(tid)) { - fprintf (stderr, "Error spawning thread\n"); - return; - } - - if (B_OK != acquire_sem(initsem)) { - fprintf (stderr, "Error acquiring semaphore\n"); - return; - } - - delete_sem(initsem); - return; -} - -AppRunner::~AppRunner() -{ - if (be_app) { - if (be_app->Lock()) - be_app->Quit(); - delete be_app; - be_app = NULL; - } -} - -// Make sure that the BApplication is initialized -static AppRunner sAppRunner; - -struct beos_boilerplate_closure { - BView* view; - BBitmap* bitmap; - BWindow* window; -}; - -// Test a real window -static cairo_surface_t * -_cairo_boilerplate_beos_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - float right = width ? width - 1 : 0; - float bottom = height ? height - 1 : 0; - BRect rect(0.0, 0.0, right, bottom); - CairoTestWindow* wnd = new CairoTestWindow(rect, name); - - beos_boilerplate_closure* bclosure = new beos_boilerplate_closure; - bclosure->view = wnd->View(); - bclosure->bitmap = NULL; - bclosure->window = wnd; - - *closure = bclosure; - - return cairo_beos_surface_create(wnd->View()); -} - -static void -_cairo_boilerplate_beos_cleanup (void *closure) -{ - beos_boilerplate_closure* bclosure = reinterpret_cast(closure); - - bclosure->window->Lock(); - bclosure->window->Quit(); - - delete bclosure; -} - -// Test a bitmap -static cairo_surface_t * -_cairo_boilerplate_beos_create_surface_for_bitmap (const char *name, - cairo_content_t content, - double width, - double height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - BRect rect(0.0, 0.0, width - 1, height - 1); - color_space beosformat = (content == CAIRO_CONTENT_COLOR_ALPHA) ? B_RGBA32 - : B_RGB32; - BBitmap* bmp = new BBitmap(rect, beosformat, true); - BView* view = new BView(rect, "Cairo test view", B_FOLLOW_ALL_SIDES, 0); - bmp->AddChild(view); - - beos_boilerplate_closure* bclosure = new beos_boilerplate_closure; - bclosure->view = view; - bclosure->bitmap = bmp; - bclosure->window = NULL; - *closure = bclosure; - - return cairo_beos_surface_create_for_bitmap(view, bmp); -} - -static void -_cairo_boilerplate_beos_cleanup_bitmap (void *closure) -{ - beos_boilerplate_closure* bclosure = reinterpret_cast(closure); - - bclosure->bitmap->RemoveChild(bclosure->view); - - - delete bclosure->view; - delete bclosure->bitmap; - - delete bclosure; -} - -static const cairo_boilerplate_target_t targets[] = { - /* BeOS sometimes produces a slightly different image. Perhaps this - * is related to the fact that it doesn't use premultiplied alpha... - * Just ignore the small difference. */ - { - "beos", "beos", NULL, NULL, - CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR, 1, - _cairo_boilerplate_beos_create_surface, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_beos_cleanup - }, - { - "beos-bitmap", "beos", NULL, NULL, - CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR, 1, - _cairo_boilerplate_beos_create_surface_for_bitmap, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_beos_cleanup_bitmap - }, - { - "beos-bitmap", "beos", NULL, NULL, - CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR_ALPHA, 1, - _cairo_boilerplate_beos_create_surface_for_bitmap, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_beos_cleanup_bitmap - }, -}; -CAIRO_BOILERPLATE (beos, targets) - diff --git a/boilerplate/cairo-boilerplate-cgl.c b/boilerplate/cairo-boilerplate-cgl.c deleted file mode 100644 index b4d1abe..0000000 --- a/boilerplate/cairo-boilerplate-cgl.c +++ /dev/null @@ -1,150 +0,0 @@ -/* Cairo - a vector graphics library with display and print output - * - * Copyright © 2009 Chris Wilson - * Copyright © 2015 Samsung Research America Inc - Silicon Valley - * - * 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, 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 Chris Wilson. - */ - -#include "cairo-boilerplate-private.h" - -#include - -#include -#include - -static const cairo_user_data_key_t gl_closure_key; - -typedef struct _cgl_target_closure { - CGLContextObj context; - cairo_device_t *device; - cairo_surface_t *surface; -} cgl_target_closure_t; - -static void -_cairo_boilerplate_cgl_cleanup (void *closure) -{ - cgl_target_closure_t *gltc = closure; - - cairo_device_finish (gltc->device); - cairo_device_destroy (gltc->device); - - CGLSetCurrentContext (NULL); - CGLDestroyContext (gltc->context); - - free (gltc); -} - -static cairo_surface_t * -_cairo_boilerplate_cgl_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - cgl_target_closure_t *gltc; - cairo_surface_t *surface; - CGLPixelFormatObj pixelformat; - CGLContextObj context; - GLint npix; - CGLError error; - - CGLPixelFormatAttribute attribs[] = { - kCGLPFAAlphaSize, 8, - kCGLPFAColorSize, 24, - kCGLPFAOpenGLProfile, kCGLOGLPVersion_3_2_Core, - kCGLPFAAccelerated, - 0 - }; - - error = CGLChoosePixelFormat (attribs, &pixelformat, &npix); - if (error != kCGLNoError || ! pixelformat) - return NULL; - - error = CGLCreateContext (pixelformat, NULL, &context); - if (error != kCGLNoError) { - CGLReleasePixelFormat (pixelformat); - return NULL; - } - - CGLReleasePixelFormat (pixelformat); - - gltc = xcalloc (1, sizeof (cgl_target_closure_t)); - *closure = gltc; - gltc->context = context; - - gltc->device = cairo_cgl_device_create (gltc->context); - - if (width < 1) - width = 1; - if (height < 1) - height = 1; - - gltc->surface = surface = cairo_gl_surface_create (gltc->device, - content, - ceil (width), - ceil (height)); - if (cairo_surface_status (surface)) - _cairo_boilerplate_cgl_cleanup (gltc); - - return surface; -} - -static void -_cairo_boilerplate_cgl_synchronize (void *closure) -{ - cgl_target_closure_t *gltc = closure; - - if (cairo_device_acquire (gltc->device)) - return; - - glFinish (); - - cairo_device_release (gltc->device); -} - -static const cairo_boilerplate_target_t targets[] = { - { - "cgl", "gl", NULL, NULL, - CAIRO_SURFACE_TYPE_GL, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_cgl_device_create", - _cairo_boilerplate_cgl_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_cgl_cleanup, - _cairo_boilerplate_cgl_synchronize, - NULL, - TRUE, FALSE, FALSE - } -}; -CAIRO_BOILERPLATE (egl, targets) diff --git a/boilerplate/cairo-boilerplate-cogl.c b/boilerplate/cairo-boilerplate-cogl.c deleted file mode 100644 index e39ad33..0000000 --- a/boilerplate/cairo-boilerplate-cogl.c +++ /dev/null @@ -1,206 +0,0 @@ -/* Cairo - a vector graphics library with display and print output - * - * Copyright © 2009 Chris Wilson - * - * 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, 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 Chris Wilson. - */ - -#include "cairo-boilerplate-private.h" - -#include -#include - -typedef struct _cogl_closure { - cairo_device_t *device; - CoglFramebuffer *fb; - cairo_surface_t *surface; -} cogl_closure_t; - -static const cairo_user_data_key_t cogl_closure_key; - -static CoglContext *context = NULL; - -static void -_cairo_boilerplate_cogl_cleanup (void *abstract_closure) -{ - cogl_closure_t *closure = abstract_closure; - - cogl_object_unref (closure->fb); - - cairo_device_finish (closure->device); - cairo_device_destroy (closure->device); - - free (closure); -} - -static cairo_surface_t * -_cairo_boilerplate_cogl_create_offscreen_color_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **abstract_closure) -{ - cairo_device_t *device; - CoglTexture *tex; - CoglHandle offscreen; - CoglFramebuffer *fb; - cogl_closure_t *closure; - cairo_status_t status; - - if (!context) - context = cogl_context_new (NULL, NULL); - - device = cairo_cogl_device_create (context); - tex = cogl_texture_new_with_size (width, height, - COGL_TEXTURE_NO_SLICING, - COGL_PIXEL_FORMAT_BGRA_8888_PRE); - offscreen = cogl_offscreen_new_to_texture (tex); - fb = COGL_FRAMEBUFFER (offscreen); - - cogl_framebuffer_allocate (fb, NULL); - cogl_push_framebuffer (fb); - cogl_ortho (0, cogl_framebuffer_get_width (fb), - cogl_framebuffer_get_height (fb), 0, - -1, 100); - cogl_pop_framebuffer (); - - closure = malloc (sizeof (cogl_closure_t)); - *abstract_closure = closure; - closure->device = device; - closure->fb = fb; - closure->surface = cairo_cogl_surface_create (device, fb); - - status = cairo_surface_set_user_data (closure->surface, - &cogl_closure_key, closure, NULL); - if (status == CAIRO_STATUS_SUCCESS) - return closure->surface; - - _cairo_boilerplate_cogl_cleanup (closure); - return cairo_boilerplate_surface_create_in_error (status); -} - -static cairo_surface_t * -_cairo_boilerplate_cogl_create_onscreen_color_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **abstract_closure) -{ - cairo_device_t *device; - CoglOnscreen *onscreen; - CoglFramebuffer *fb; - cogl_closure_t *closure; - cairo_status_t status; - - if (!context) - context = cogl_context_new (NULL, NULL); - - device = cairo_cogl_device_create (context); - onscreen = cogl_onscreen_new (context, width, height); - fb = COGL_FRAMEBUFFER (onscreen); - - cogl_onscreen_show (onscreen); - - cogl_push_framebuffer (fb); - cogl_ortho (0, cogl_framebuffer_get_width (fb), - cogl_framebuffer_get_height (fb), 0, - -1, 100); - cogl_pop_framebuffer (); - - closure = malloc (sizeof (cogl_closure_t)); - *abstract_closure = closure; - closure->device = device; - closure->fb = fb; - closure->surface = cairo_cogl_surface_create (device, fb); - - status = cairo_surface_set_user_data (closure->surface, - &cogl_closure_key, closure, NULL); - if (status == CAIRO_STATUS_SUCCESS) - return closure->surface; - - _cairo_boilerplate_cogl_cleanup (closure); - return cairo_boilerplate_surface_create_in_error (status); -} - -static cairo_status_t -_cairo_boilerplate_cogl_finish_onscreen (cairo_surface_t *surface) -{ - cogl_closure_t *closure = cairo_surface_get_user_data (surface, &cogl_closure_key); - - cairo_cogl_surface_end_frame (surface); - - cogl_framebuffer_swap_buffers (closure->fb); - - return CAIRO_STATUS_SUCCESS; -} - -static void -_cairo_boilerplate_cogl_synchronize (void *abstract_closure) -{ - cogl_closure_t *closure = abstract_closure; - cogl_framebuffer_finish (closure->fb); -} - -static const cairo_boilerplate_target_t targets[] = { - { - "cogl-offscreen-color", "cogl", NULL, NULL, - CAIRO_SURFACE_TYPE_COGL, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_cogl_device_create", - _cairo_boilerplate_cogl_create_offscreen_color_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_cogl_cleanup, - _cairo_boilerplate_cogl_synchronize, - NULL, - TRUE, FALSE, FALSE - }, - { - "cogl-onscreen-color", "cogl", NULL, NULL, - CAIRO_SURFACE_TYPE_COGL, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_cogl_device_create", - _cairo_boilerplate_cogl_create_onscreen_color_surface, - cairo_surface_create_similar, - NULL, - _cairo_boilerplate_cogl_finish_onscreen, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_cogl_cleanup, - _cairo_boilerplate_cogl_synchronize, - NULL, - TRUE, FALSE, FALSE - } -}; -CAIRO_BOILERPLATE (cogl, targets) diff --git a/boilerplate/cairo-boilerplate-directfb.c b/boilerplate/cairo-boilerplate-directfb.c deleted file mode 100644 index a479011..0000000 --- a/boilerplate/cairo-boilerplate-directfb.c +++ /dev/null @@ -1,235 +0,0 @@ -/* -Test were run with the following script -target can be directfb_bitmap or directfb - -export CAIRO_TEST_TARGET=directfb_bitmap -export DFBARGS=quiet,no-banner,no-debug,log-file=dfblog,system=x11 -cd cairo/test -make check - -*/ - -#include "cairo-boilerplate-private.h" - -#include - -#include -#include - -#include - -D_DEBUG_DOMAIN (CairoDFB_Boiler, "CairoDFB/Boiler", "Cairo DirectFB Boilerplate"); - -/* macro for a safe call to DirectFB functions */ -#define DFBCHECK(x...) do{ \ - err = x; \ - if (err != DFB_OK) { \ - fprintf (stderr, "%s <%d>:\n\t", __FILE__, __LINE__); \ - goto ERROR; \ - } \ -} while (0) - -typedef struct _DFBInfo { - IDirectFB *dfb; - IDirectFBDisplayLayer *layer; - IDirectFBWindow *window; - IDirectFBSurface *surface; -} DFBInfo; - -static void -_cairo_boilerplate_directfb_cleanup (void *closure) -{ - DFBInfo *info = (DFBInfo *) closure; - - if (info->surface) - info->surface->Release (info->surface); - - if (info->window) - info->window->Release (info->window); - - if (info->layer) - info->layer->Release (info->layer); - - if (info->dfb) - info->dfb->Release (info->dfb); - - free (info); -} - -static DFBInfo * -init (void) -{ - DFBDisplayLayerConfig layer_config; - DFBGraphicsDeviceDescription desc; - int err; - DFBInfo *info; - - info = xcalloc (1, sizeof (DFBInfo)); - if (info == NULL) - return NULL; - - DFBCHECK (DirectFBInit (NULL, NULL)); - DFBCHECK (DirectFBCreate (&info->dfb)); - info->dfb->GetDeviceDescription (info->dfb, &desc); - - DFBCHECK (info->dfb->GetDisplayLayer (info->dfb, - DLID_PRIMARY, &info->layer)); - info->layer->SetCooperativeLevel (info->layer, DLSCL_ADMINISTRATIVE); - - if ((desc.blitting_flags & (DSBLIT_BLEND_ALPHACHANNEL | - DSBLIT_BLEND_COLORALPHA)) != - (DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_BLEND_COLORALPHA)) - { - layer_config.flags = DLCONF_BUFFERMODE; - layer_config.buffermode = DLBM_BACKSYSTEM; - info->layer->SetConfiguration (info->layer, &layer_config); - } - - return info; - -ERROR: - if (info != NULL) - _cairo_boilerplate_directfb_cleanup (info); - return NULL; -} - -static cairo_surface_t * -_cairo_boilerplate_directfb_window_create_surface (DFBInfo *info, - cairo_content_t content, - int width, - int height) -{ - DFBWindowDescription desc; - int err; - - D_DEBUG_AT (CairoDFB_Boiler, "%s (%p, %s, %dx%d)\n", __FUNCTION__, info, - content == CAIRO_CONTENT_ALPHA ? "ALPHA" : - content == CAIRO_CONTENT_COLOR ? "RGB" : - content == CAIRO_CONTENT_COLOR_ALPHA ? "ARGB" : "unknown content!", - width, height); - - desc.flags = DWDESC_POSX | DWDESC_POSY | - DWDESC_WIDTH | DWDESC_HEIGHT; - desc.caps = DSCAPS_NONE; - desc.posx = 0; - desc.posy = 0; - desc.width = width; - desc.height = height; - if (content == CAIRO_CONTENT_COLOR_ALPHA) { - desc.flags |= DWDESC_CAPS | DWDESC_PIXELFORMAT; - desc.caps |= DWCAPS_DOUBLEBUFFER | DWCAPS_ALPHACHANNEL; - desc.pixelformat = DSPF_ARGB; - } - - DFBCHECK (info->layer->CreateWindow (info->layer, &desc, &info->window)); - info->window->SetOpacity (info->window, 0xFF); - info->window->GetSurface (info->window, &info->surface); - info->surface->SetColor (info->surface, 0xFF, 0xFF, 0xFF, 0xFF); - info->surface->FillRectangle (info->surface,0, 0, desc.width, desc.height); - info->surface->Flip (info->surface, NULL, 0); - - return cairo_directfb_surface_create (info->dfb, info->surface); - -ERROR: - _cairo_boilerplate_directfb_cleanup (info); - return NULL; -} - -static cairo_surface_t * -_cairo_boilerplate_directfb_bitmap_create_surface (DFBInfo *info, - cairo_content_t content, - int width, - int height) -{ - int err; - DFBSurfaceDescription desc; - - D_DEBUG_AT (CairoDFB_Boiler, "%s (%p, %s, %dx%d)\n", __FUNCTION__, info, - content == CAIRO_CONTENT_ALPHA ? "ALPHA" : - content == CAIRO_CONTENT_COLOR ? "RGB" : - content == CAIRO_CONTENT_COLOR_ALPHA ? "ARGB" : "unknown content!", - width, height); - - desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT; - desc.caps = DSCAPS_NONE; - desc.width = width; - desc.height = height; - if (content == CAIRO_CONTENT_COLOR_ALPHA) { - desc.flags |= DSDESC_PIXELFORMAT; - desc.pixelformat = DSPF_ARGB; - } - DFBCHECK (info->dfb->CreateSurface (info->dfb, &desc, &info->surface)); - - return cairo_directfb_surface_create (info->dfb, info->surface); - -ERROR: - _cairo_boilerplate_directfb_cleanup (info); - return NULL; -} - -static cairo_surface_t * -_cairo_boilerplate_directfb_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - - DFBInfo *info; - - info = init (); - if (info == NULL) - return NULL; - - *closure = info; - - D_DEBUG_AT (CairoDFB_Boiler, "%s ('%s', %s, %dx%d, %s)\n", - __FUNCTION__, name, - content == CAIRO_CONTENT_ALPHA ? "ALPHA" : - content == CAIRO_CONTENT_COLOR ? "RGB" : - content == CAIRO_CONTENT_COLOR_ALPHA ? "ARGB" : "unknown content!", - width, height, - mode == CAIRO_BOILERPLATE_MODE_TEST ? "TEST" : - mode == CAIRO_BOILERPLATE_MODE_PERF ? "PERF" : "unknown mode!"); - - if (width == 0) - width = 1; - if (height == 0) - height = 1; - - if (mode == CAIRO_BOILERPLATE_MODE_TEST) - return _cairo_boilerplate_directfb_bitmap_create_surface (info, content, width, height); - else /* mode == CAIRO_BOILERPLATE_MODE_PERF */ - return _cairo_boilerplate_directfb_window_create_surface (info, content, width, height); -} - -static const cairo_boilerplate_target_t targets[] = { - { - "directfb", "directfb", NULL, NULL, - CAIRO_SURFACE_TYPE_DIRECTFB, CAIRO_CONTENT_COLOR, 0, - "cairo_directfb_surface_create", - _cairo_boilerplate_directfb_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_directfb_cleanup, - NULL, NULL, TRUE, FALSE, FALSE - }, - { - "directfb-bitmap", "directfb", NULL, NULL, - CAIRO_SURFACE_TYPE_DIRECTFB, CAIRO_CONTENT_COLOR_ALPHA, 0, - "cairo_directfb_surface_create", - _cairo_boilerplate_directfb_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_directfb_cleanup, - NULL, NULL, FALSE, FALSE, FALSE - }, -}; -CAIRO_BOILERPLATE (directfb, targets); diff --git a/boilerplate/cairo-boilerplate-drm.c b/boilerplate/cairo-boilerplate-drm.c deleted file mode 100644 index 79d9229..0000000 --- a/boilerplate/cairo-boilerplate-drm.c +++ /dev/null @@ -1,112 +0,0 @@ -/* Cairo - a vector graphics library with display and print output - * - * Copyright © 2009 Chris Wilson - * - * 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, 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 Chris Wilson. - */ - -#include "cairo-boilerplate-private.h" - -#include - -static cairo_surface_t * -_cairo_boilerplate_drm_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - cairo_device_t *device; - cairo_format_t format; - - device = cairo_drm_device_default (); - if (device == NULL) - return NULL; /* skip tests if no supported h/w found */ - - switch (content) { - case CAIRO_CONTENT_ALPHA: - format = CAIRO_FORMAT_A8; - break; - case CAIRO_CONTENT_COLOR: - format = CAIRO_FORMAT_RGB24; - break; - case CAIRO_CONTENT_COLOR_ALPHA: - default: - format = CAIRO_FORMAT_ARGB32; - break; - } - - return *closure = cairo_drm_surface_create (device, format, width, height); -} - -static void -_cairo_boilerplate_drm_synchronize (void *closure) -{ - cairo_surface_t *image; - - image = cairo_drm_surface_map_to_image (closure); - if (cairo_surface_status (image) == CAIRO_STATUS_SUCCESS) - cairo_drm_surface_unmap (closure, image); -} - -static const cairo_boilerplate_target_t targets[] = { - /* Acceleration architectures may make the results differ by a - * bit, so we set the error tolerance to 1. */ - { - "drm", "drm", NULL, NULL, - CAIRO_SURFACE_TYPE_DRM, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_drm_surface_create", - _cairo_boilerplate_drm_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, - _cairo_boilerplate_drm_synchronize, - NULL, - TRUE, FALSE, FALSE - }, - { - "drm", "drm", NULL, NULL, - CAIRO_SURFACE_TYPE_DRM, CAIRO_CONTENT_COLOR, 1, - "cairo_drm_surface_create", - _cairo_boilerplate_drm_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, - _cairo_boilerplate_drm_synchronize, - NULL, - FALSE, FALSE, FALSE - }, -}; -CAIRO_BOILERPLATE (drm, targets) diff --git a/boilerplate/cairo-boilerplate-egl.c b/boilerplate/cairo-boilerplate-egl.c deleted file mode 100644 index c5b1260..0000000 --- a/boilerplate/cairo-boilerplate-egl.c +++ /dev/null @@ -1,202 +0,0 @@ -/* Cairo - a vector graphics library with display and print output - * - * Copyright © 2009 Chris Wilson - * - * 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, 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 Chris Wilson. - */ - -#include "cairo-boilerplate-private.h" - -#if CAIRO_HAS_EVASGL_SURFACE && CAIRO_HAS_GLESV2_SURFACE -extern void glFinish (void); -#endif - -#include -#if CAIRO_HAS_GL_SURFACE -#include -#elif CAIRO_HAS_GLESV2_SURFACE -#include -#elif CAIRO_HAS_GLESV3_SURFACE -#include -#endif - -// For Wayland-egl -#ifdef HAVE_WAYLAND -#include -#include -#endif - -static const cairo_user_data_key_t gl_closure_key; - -typedef struct _egl_target_closure { - EGLDisplay dpy; - EGLContext ctx; - - cairo_device_t *device; - cairo_surface_t *surface; -} egl_target_closure_t; - -static void -_cairo_boilerplate_egl_cleanup (void *closure) -{ - egl_target_closure_t *gltc = closure; - - cairo_device_finish (gltc->device); - cairo_device_destroy (gltc->device); - - eglDestroyContext (gltc->dpy, gltc->ctx); - eglMakeCurrent (gltc->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - eglTerminate (gltc->dpy); - - free (gltc); -} - -static cairo_surface_t * -_cairo_boilerplate_egl_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - egl_target_closure_t *gltc; - cairo_surface_t *surface; - int major, minor; - EGLConfig config; - EGLint numConfigs; - EGLint config_attribs[] = { - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, 8, - EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, -#if CAIRO_HAS_GL_SURFACE - EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, -#elif CAIRO_HAS_GLESV2_SURFACE || CAIRO_HAS_GLESV3_SURFACE - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, -#endif - EGL_NONE - }; - const EGLint ctx_attribs[] = { -#if CAIRO_HAS_GLESV2_SURFACE - EGL_CONTEXT_CLIENT_VERSION, 2, -#elif CAIRO_HAS_GLESV3_SURFACE - EGL_CONTEXT_CLIENT_VERSION, 3, -#endif - EGL_NONE - }; - - gltc = xcalloc (1, sizeof (egl_target_closure_t)); - *closure = gltc; - -#ifdef HAVE_WAYLAND - static struct wl_display *display; - display = wl_display_connect (NULL); - struct wl_registry *registry = wl_display_get_registry (display); - wl_display_dispatch (display); - gltc->dpy = eglGetDisplay (display); -#else - gltc->dpy = eglGetDisplay (EGL_DEFAULT_DISPLAY); -#endif - - if (! eglInitialize (gltc->dpy, &major, &minor)) { - free (gltc); - return NULL; - } - - eglChooseConfig (gltc->dpy, config_attribs, &config, 1, &numConfigs); - if (numConfigs == 0) { - free (gltc); - return NULL; - } - -#if CAIRO_HAS_GL_SURFACE - eglBindAPI (EGL_OPENGL_API); -#elif CAIRO_HAS_GLESV2_SURFACE || CAIRO_HAS_GLESV3_SURFACE - eglBindAPI (EGL_OPENGL_ES_API); -#endif - - gltc->ctx = eglCreateContext (gltc->dpy, config, EGL_NO_CONTEXT, - ctx_attribs); - if (gltc->ctx == EGL_NO_CONTEXT) { - eglTerminate (gltc->dpy); - free (gltc); - return NULL; - } - - gltc->device = cairo_egl_device_create (gltc->dpy, gltc->ctx); - if (mode == CAIRO_BOILERPLATE_MODE_PERF) - cairo_gl_device_set_thread_aware(gltc->device, FALSE); - - if (width < 1) - width = 1; - if (height < 1) - height = 1; - - gltc->surface = surface = cairo_gl_surface_create (gltc->device, - content, - ceil (width), - ceil (height)); - if (cairo_surface_status (surface)) - _cairo_boilerplate_egl_cleanup (gltc); - - return surface; -} - -static void -_cairo_boilerplate_egl_synchronize (void *closure) -{ - egl_target_closure_t *gltc = closure; - - if (cairo_device_acquire (gltc->device)) - return; - - glFinish (); - - cairo_device_release (gltc->device); -} - -static const cairo_boilerplate_target_t targets[] = { - { - "egl", "gl", NULL, NULL, - CAIRO_SURFACE_TYPE_GL, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_egl_device_create", - _cairo_boilerplate_egl_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_egl_cleanup, - _cairo_boilerplate_egl_synchronize, - NULL, - TRUE, FALSE, FALSE - } -}; -CAIRO_BOILERPLATE (egl, targets) diff --git a/boilerplate/cairo-boilerplate-evas-gl.c b/boilerplate/cairo-boilerplate-evas-gl.c deleted file mode 100644 index 0b98de8..0000000 --- a/boilerplate/cairo-boilerplate-evas-gl.c +++ /dev/null @@ -1,148 +0,0 @@ -/* Cairo - a vector graphics library with display and print output - * - * Copyright © 2009 Chris Wilson - * Copyright © 2014 Samsung Research America, Inc - Silicon Valley - * - * 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, 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 Henry Song. - */ - -#include "cairo-boilerplate-private.h" -#include -#include -#include -#include -#include - -static const cairo_user_data_key_t gl_closure_key; - -typedef struct _evas_gl_target_closure { - Evas_GL *evas_gl; - Evas_GL_Context *evas_ctx; - Evas_GL_API *evas_api; - - cairo_device_t *device; - cairo_surface_t *surface; -} evas_gl_target_closure_t; - -static void -_cairo_boilerplate_evas_gl_cleanup (void *closure) -{ - evas_gl_target_closure_t *gltc = closure; - - cairo_device_finish (gltc->device); - cairo_device_destroy (gltc->device); - - evas_gl_context_destroy (gltc->evas_gl, gltc->evas_ctx); - evas_gl_free (gltc->evas_gl); - - free (gltc); - - ecore_evas_shutdown (); - ecore_shutdown (); -} - -static cairo_surface_t * -_cairo_boilerplate_evas_gl_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - Ecore_Evas *ee; - Evas *canvas; - - evas_gl_target_closure_t *gltc; - cairo_surface_t *surface; - - if (width < 1) - width = 1; - if (height < 1) - height = 1; - - ecore_init (); - ecore_evas_init (); - -#ifdef HAVE_WAYLAND //Wayland (Tizen 3.0) - ee = ecore_evas_wayland_egl_new (NULL, 0, 0, 0, ceil (width), ceil (height), EINA_TRUE); -#else - ee = ecore_evas_gl_x11_new (NULL, 0, 0, 0, ceil (width), ceil (height));; -#endif - - canvas = ecore_evas_get (ee); - - gltc = xcalloc (1, sizeof (evas_gl_target_closure_t)); - *closure = gltc; - - gltc->evas_gl = evas_gl_new (canvas); - gltc->evas_ctx = evas_gl_context_create (gltc->evas_gl, NULL); - gltc->evas_api = evas_gl_api_get (gltc->evas_gl); - - gltc->device = cairo_evas_gl_device_create (gltc->evas_gl, gltc->evas_ctx); - - gltc->surface = surface = - cairo_gl_surface_create (gltc->device, CAIRO_CONTENT_COLOR_ALPHA, - ceil (width), ceil (height)); - if (cairo_surface_status (surface)) - _cairo_boilerplate_evas_gl_cleanup (gltc); - - return surface; -} - -static void -_cairo_boilerplate_evas_gl_synchronize (void *closure) -{ - evas_gl_target_closure_t *gltc = closure; - - if (cairo_device_acquire (gltc->device)) - return; - - gltc->evas_api->glFinish (); - - cairo_device_release (gltc->device); -} - -static const cairo_boilerplate_target_t targets[] = { - { - "evasgl", "gl", NULL, NULL, - CAIRO_SURFACE_TYPE_GL, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_evas_gl_device_create", - _cairo_boilerplate_evas_gl_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_evas_gl_cleanup, - _cairo_boilerplate_evas_gl_synchronize, - NULL, - TRUE, FALSE, FALSE - } -}; -CAIRO_BOILERPLATE (evasgl, targets) diff --git a/boilerplate/cairo-boilerplate-getopt.c b/boilerplate/cairo-boilerplate-getopt.c deleted file mode 100644 index 53b150c..0000000 --- a/boilerplate/cairo-boilerplate-getopt.c +++ /dev/null @@ -1,247 +0,0 @@ -/***************************************************************************** -* getopt.c - competent and free getopt library. -* $Header: /cvsroot/freegetopt/freegetopt/getopt.c,v 1.2 2003/10/26 03:10:20 vindaci Exp $ -* -* Copyright (c)2002-2003 Mark K. Kim -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in -* the documentation and/or other materials provided with the -* distribution. -* -* * Neither the original author of this software nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -* DAMAGE. -*/ -#include -#include -#include -#include "cairo-boilerplate-getopt.h" - - -char* optarg = NULL; -int optind = 0; -int opterr = 1; -int optopt = '?'; - - -static char** prev_argv = NULL; /* Keep a copy of argv and argc to */ -static int prev_argc = 0; /* tell if getopt params change */ -static int argv_index = 0; /* Option we're checking */ -static int argv_index2 = 0; /* Option argument we're checking */ -static int opt_offset = 0; /* Index into compounded "-option" */ -static int dashdash = 0; /* True if "--" option reached */ -static int nonopt = 0; /* How many nonopts we've found */ - -static void increment_index(void) -{ - /* Move onto the next option */ - if(argv_index < argv_index2) - { - while(prev_argv[++argv_index] && prev_argv[argv_index][0] != '-' - && argv_index < argv_index2+1); - } - else argv_index++; - opt_offset = 1; -} - - -/* -* Permutes argv[] so that the argument currently being processed is moved -* to the end. -*/ -static int permute_argv_once(void) -{ - /* Movability check */ - if(argv_index + nonopt >= prev_argc) return 1; - /* Move the current option to the end, bring the others to front */ - else - { - char* tmp = prev_argv[argv_index]; - - /* Move the data */ - memmove(&prev_argv[argv_index], &prev_argv[argv_index+1], - sizeof(char**) * (prev_argc - argv_index - 1)); - prev_argv[prev_argc - 1] = tmp; - - nonopt++; - return 0; - } -} - - -int _cairo_getopt(int argc, char** argv, const char* optstr) -{ - int c = 0; - - /* If we have new argv, reinitialize */ - if(prev_argv != argv || prev_argc != argc) - { - /* Initialize variables */ - prev_argv = argv; - prev_argc = argc; - argv_index = 1; - argv_index2 = 1; - opt_offset = 1; - dashdash = 0; - nonopt = 0; - } - - /* Jump point in case we want to ignore the current argv_index */ - getopt_top: - - /* Misc. initializations */ - optarg = NULL; - - /* Dash-dash check */ - if(argv[argv_index] && !strcmp(argv[argv_index], "--")) - { - dashdash = 1; - increment_index(); - } - - /* If we're at the end of argv, that's it. */ - if(argv[argv_index] == NULL) - { - c = -1; - } - /* Are we looking at a string? Single dash is also a string */ - else if(dashdash || argv[argv_index][0] != '-' || !strcmp(argv[argv_index], "-")) - { - /* If we want a string... */ - if(optstr[0] == '-') - { - c = 1; - optarg = argv[argv_index]; - increment_index(); - } - /* If we really don't want it (we're in POSIX mode), we're done */ - else if(optstr[0] == '+' || getenv("POSIXLY_CORRECT")) - { - c = -1; - - /* Everything else is a non-opt argument */ - nonopt = argc - argv_index; - } - /* If we mildly don't want it, then move it back */ - else - { - if(!permute_argv_once()) goto getopt_top; - else c = -1; - } - } - /* Otherwise we're looking at an option */ - else - { - char* opt_ptr = NULL; - - /* Grab the option */ - c = argv[argv_index][opt_offset++]; - - /* Is the option in the optstr? */ - if(optstr[0] == '-') opt_ptr = strchr(optstr+1, c); - else opt_ptr = strchr(optstr, c); - /* Invalid argument */ - if(!opt_ptr) - { - if(opterr) - { - fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c); - } - - optopt = c; - c = '?'; - - /* Move onto the next option */ - increment_index(); - } - /* Option takes argument */ - else if(opt_ptr[1] == ':') - { - /* ie, -oARGUMENT, -xxxoARGUMENT, etc. */ - if(argv[argv_index][opt_offset] != '\0') - { - optarg = &argv[argv_index][opt_offset]; - increment_index(); - } - /* ie, -o ARGUMENT (only if it's a required argument) */ - else if(opt_ptr[2] != ':') - { - /* One of those "you're not expected to understand this" moment */ - if(argv_index2 < argv_index) argv_index2 = argv_index; - while(argv[++argv_index2] && argv[argv_index2][0] == '-'); - optarg = argv[argv_index2]; - - /* Don't cross into the non-option argument list */ - if(argv_index2 + nonopt >= prev_argc) optarg = NULL; - - /* Move onto the next option */ - increment_index(); - } - else - { - /* Move onto the next option */ - increment_index(); - } - - /* In case we got no argument for an option with required argument */ - if(optarg == NULL && opt_ptr[2] != ':') - { - optopt = c; - c = '?'; - - if(opterr) - { - fprintf(stderr,"%s: option requires an argument -- %c\n", - argv[0], optopt); - } - } - } - /* Option does not take argument */ - else - { - /* Next argv_index */ - if(argv[argv_index][opt_offset] == '\0') - { - increment_index(); - } - } - } - - /* Calculate optind */ - if(c == -1) - { - optind = argc - nonopt; - } - else - { - optind = argv_index; - } - - return c; -} - - -/* vim:ts=3 -*/ diff --git a/boilerplate/cairo-boilerplate-getopt.h b/boilerplate/cairo-boilerplate-getopt.h deleted file mode 100644 index 74bce14..0000000 --- a/boilerplate/cairo-boilerplate-getopt.h +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************** -* getopt.h - competent and free getopt library. -* $Header: /cvsroot/freegetopt/freegetopt/getopt.h,v 1.2 2003/10/26 03:10:20 vindaci Exp $ -* -* Copyright (c)2002-2003 Mark K. Kim -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in -* the documentation and/or other materials provided with the -* distribution. -* -* * Neither the original author of this software nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -* DAMAGE. -*/ -#ifndef GETOPT_H_ -#define GETOPT_H_ - - -#ifdef __cplusplus -extern "C" { -#endif - - -extern char* optarg; -extern int optind; -extern int opterr; -extern int optopt; - -int _cairo_getopt(int argc, char** argv, const char* optstr); - - -#ifdef __cplusplus -} -#endif - - -#endif /* GETOPT_H_ */ - - -/* vim:ts=3 -*/ diff --git a/boilerplate/cairo-boilerplate-glx.c b/boilerplate/cairo-boilerplate-glx.c deleted file mode 100644 index 3d58215..0000000 --- a/boilerplate/cairo-boilerplate-glx.c +++ /dev/null @@ -1,457 +0,0 @@ -/* Cairo - a vector graphics library with display and print output - * - * Copyright © 2009 Chris Wilson - * - * 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, 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 Chris Wilson. - */ - -#include "cairo-boilerplate-private.h" - -#include - -#include -#include /* for XDestroyImage */ - -static const cairo_user_data_key_t gl_closure_key; - -typedef struct _gl_target_closure { - Display *dpy; - int screen; - Window drawable; - - GLXContext ctx; - cairo_device_t *device; - cairo_surface_t *surface; -} gl_target_closure_t; - -static void -_cairo_boilerplate_gl_cleanup (void *closure) -{ - gl_target_closure_t *gltc = closure; - - cairo_device_finish (gltc->device); - cairo_device_destroy (gltc->device); - - glXDestroyContext (gltc->dpy, gltc->ctx); - - if (gltc->drawable) - XDestroyWindow (gltc->dpy, gltc->drawable); - XCloseDisplay (gltc->dpy); - - free (gltc); -} - -static cairo_surface_t * -_cairo_boilerplate_gl_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - int rgba_attribs[] = { GLX_RGBA, - GLX_RED_SIZE, 1, - GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, - GLX_ALPHA_SIZE, 1, - GLX_DOUBLEBUFFER, - GLX_NONE }; - int rgb_attribs[] = { GLX_RGBA, - GLX_RED_SIZE, 1, - GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, - GLX_DOUBLEBUFFER, - GLX_NONE }; - XVisualInfo *visinfo; - GLXContext ctx; - gl_target_closure_t *gltc; - cairo_surface_t *surface; - Display *dpy; - - gltc = calloc (1, sizeof (gl_target_closure_t)); - *closure = gltc; - - width = ceil (width); - height = ceil (height); - - if (width == 0) - width = 1; - if (height == 0) - height = 1; - - dpy = XOpenDisplay (NULL); - gltc->dpy = dpy; - if (!gltc->dpy) { - fprintf (stderr, "Failed to open display: %s\n", XDisplayName(0)); - free (gltc); - return NULL; - } - - if (mode == CAIRO_BOILERPLATE_MODE_TEST) - XSynchronize (gltc->dpy, 1); - - if (content == CAIRO_CONTENT_COLOR) - visinfo = glXChooseVisual (dpy, DefaultScreen (dpy), rgb_attribs); - else - visinfo = glXChooseVisual (dpy, DefaultScreen (dpy), rgba_attribs); - - if (visinfo == NULL) { - fprintf (stderr, "Failed to create RGB, double-buffered visual\n"); - XCloseDisplay (dpy); - free (gltc); - return NULL; - } - - ctx = glXCreateContext (dpy, visinfo, NULL, True); - XFree (visinfo); - - gltc->ctx = ctx; - gltc->device = cairo_glx_device_create (dpy, ctx); - - if (mode == CAIRO_BOILERPLATE_MODE_PERF) - cairo_gl_device_set_thread_aware(gltc->device, FALSE); - - gltc->surface = surface = cairo_gl_surface_create (gltc->device, - content, width, height); - if (cairo_surface_status (surface)) - _cairo_boilerplate_gl_cleanup (gltc); - - return surface; -} - -static cairo_surface_t * -_cairo_boilerplate_gl_create_window_common (int rgba_attribs[], - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - gl_target_closure_t *gltc) -{ - XVisualInfo *vi; - GLXContext ctx; - cairo_surface_t *surface; - Display *dpy; - XSetWindowAttributes attr; - - width = ceil (width); - height = ceil (height); - - if (width == 0) - width = 1; - if (height == 0) - height = 1; - - dpy = XOpenDisplay (NULL); - gltc->dpy = dpy; - if (!gltc->dpy) { - fprintf (stderr, "Failed to open display: %s\n", XDisplayName(0)); - free (gltc); - return NULL; - } - - if (mode == CAIRO_BOILERPLATE_MODE_TEST) - XSynchronize (gltc->dpy, 1); - - vi = glXChooseVisual (dpy, DefaultScreen (dpy), rgba_attribs); - if (vi == NULL) { - fprintf (stderr, "Failed to create RGBA, double-buffered visual\n"); - XCloseDisplay (dpy); - free (gltc); - return NULL; - } - - attr.colormap = XCreateColormap (dpy, - RootWindow (dpy, vi->screen), - vi->visual, - AllocNone); - attr.border_pixel = 0; - attr.override_redirect = True; - gltc->drawable = XCreateWindow (dpy, DefaultRootWindow (dpy), 0, 0, - width, height, 0, vi->depth, - InputOutput, vi->visual, - CWOverrideRedirect | CWBorderPixel | CWColormap, - &attr); - XMapWindow (dpy, gltc->drawable); - - ctx = glXCreateContext (dpy, vi, NULL, True); - XFree (vi); - - gltc->ctx = ctx; - gltc->device = cairo_glx_device_create (dpy, ctx); - - gltc->surface = surface = cairo_gl_surface_create_for_window (gltc->device, - gltc->drawable, - width, height); - if (cairo_surface_status (surface)) { - _cairo_boilerplate_gl_cleanup (gltc); - return NULL; - } - return surface; -} - -static cairo_surface_t * -_cairo_boilerplate_gl_create_window (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - gl_target_closure_t *gltc; - - int rgba_attribs[] = { GLX_RGBA, - GLX_RED_SIZE, 1, - GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, - GLX_ALPHA_SIZE, 1, - GLX_DOUBLEBUFFER, - GLX_NONE }; - - gltc = calloc (1, sizeof (gl_target_closure_t)); - *closure = gltc; - - return _cairo_boilerplate_gl_create_window_common (rgba_attribs, content, - width, height, - max_width, max_height, - mode, gltc); -} - -static cairo_surface_t * -_cairo_boilerplate_gl_create_window_msaa (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - gl_target_closure_t *gltc; - - int rgba_attribs[] = { GLX_RGBA, - GLX_RED_SIZE, 1, - GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, - GLX_ALPHA_SIZE, 1, - GLX_STENCIL_SIZE, 1, - GLX_SAMPLES, 4, - GLX_SAMPLE_BUFFERS, 1, - GLX_DOUBLEBUFFER, - GLX_NONE }; - - gltc = calloc (1, sizeof (gl_target_closure_t)); - *closure = gltc; - return _cairo_boilerplate_gl_create_window_common (rgba_attribs, content, - width, height, - max_width, max_height, - mode, gltc); - -} - -static cairo_surface_t * -_cairo_boilerplate_gl_create_window_db (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - cairo_status_t status; - cairo_surface_t *surface; - gl_target_closure_t *gltc; - - int rgba_attribs[] = { GLX_RGBA, - GLX_RED_SIZE, 1, - GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, - GLX_ALPHA_SIZE, 1, - GLX_DOUBLEBUFFER, - GLX_NONE }; - - gltc = calloc (1, sizeof (gl_target_closure_t)); - *closure = gltc; - - surface = _cairo_boilerplate_gl_create_window_common (rgba_attribs, content, - width, height, - max_width, max_height, - mode, gltc); - - if (! surface) - return NULL; - - surface = cairo_surface_create_similar (gltc->surface, content, width, height); - status = cairo_surface_set_user_data (surface, &gl_closure_key, gltc, NULL); - if (status == CAIRO_STATUS_SUCCESS) - return surface; - - cairo_surface_destroy (surface); - _cairo_boilerplate_gl_cleanup (gltc); - return cairo_boilerplate_surface_create_in_error (status); -} - -static cairo_status_t -_cairo_boilerplate_gl_finish_window (cairo_surface_t *surface) -{ - gl_target_closure_t *gltc = cairo_surface_get_user_data (surface, - &gl_closure_key); - - if (gltc != NULL && gltc->surface != NULL) { - cairo_t *cr; - - cr = cairo_create (gltc->surface); - cairo_surface_set_device_offset (surface, 0, 0); - cairo_set_source_surface (cr, surface, 0, 0); - cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); - cairo_paint (cr); - cairo_destroy (cr); - - surface = gltc->surface; - } - - cairo_gl_surface_swapbuffers (surface); - return CAIRO_STATUS_SUCCESS; -} - -static void -_cairo_boilerplate_gl_synchronize (void *closure) -{ - gl_target_closure_t *gltc = closure; - - if (cairo_device_acquire (gltc->device)) - return; - - glFinish (); - - cairo_device_release (gltc->device); -} - -static char * -_cairo_boilerplate_gl_describe (void *closure) -{ - gl_target_closure_t *gltc = closure; - char *s; - const GLubyte *vendor, *renderer, *version; - - if (cairo_device_acquire (gltc->device)) - return NULL; - - vendor = glGetString (GL_VENDOR); - renderer = glGetString (GL_RENDERER); - version = glGetString (GL_VERSION); - - xasprintf (&s, "%s %s %s", vendor, renderer, version); - - cairo_device_release (gltc->device); - - return s; -} - -static const cairo_boilerplate_target_t targets[] = { - { - "gl", "gl", NULL, NULL, - CAIRO_SURFACE_TYPE_GL, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_gl_surface_create", - _cairo_boilerplate_gl_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_gl_cleanup, - _cairo_boilerplate_gl_synchronize, - _cairo_boilerplate_gl_describe, - TRUE, FALSE, FALSE - }, - { - "gl", "gl", NULL, NULL, - CAIRO_SURFACE_TYPE_GL, CAIRO_CONTENT_COLOR, 1, - "cairo_gl_surface_create", - _cairo_boilerplate_gl_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_gl_cleanup, - _cairo_boilerplate_gl_synchronize, - _cairo_boilerplate_gl_describe, - FALSE, FALSE, FALSE - }, - { - "gl-window", "gl", NULL, NULL, - CAIRO_SURFACE_TYPE_GL, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_gl_surface_create_for_window", - _cairo_boilerplate_gl_create_window, - cairo_surface_create_similar, - NULL, - _cairo_boilerplate_gl_finish_window, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_gl_cleanup, - _cairo_boilerplate_gl_synchronize, - _cairo_boilerplate_gl_describe, - FALSE, FALSE, FALSE - }, - { - "gl-window-msaa", "gl", NULL, NULL, - CAIRO_SURFACE_TYPE_GL, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_gl_surface_create_for_window", - _cairo_boilerplate_gl_create_window_msaa, - cairo_surface_create_similar, - NULL, - _cairo_boilerplate_gl_finish_window, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_gl_cleanup, - _cairo_boilerplate_gl_synchronize, - _cairo_boilerplate_gl_describe, - FALSE, FALSE, FALSE - }, - { - "gl-window&", "gl", NULL, NULL, - CAIRO_SURFACE_TYPE_GL, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_gl_surface_create_for_window", - _cairo_boilerplate_gl_create_window_db, - cairo_surface_create_similar, - NULL, - _cairo_boilerplate_gl_finish_window, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_gl_cleanup, - _cairo_boilerplate_gl_synchronize, - _cairo_boilerplate_gl_describe, - FALSE, FALSE, FALSE - }, -}; -CAIRO_BOILERPLATE (gl, targets) diff --git a/boilerplate/cairo-boilerplate-pdf.c b/boilerplate/cairo-boilerplate-pdf.c deleted file mode 100644 index 177cdf1..0000000 --- a/boilerplate/cairo-boilerplate-pdf.c +++ /dev/null @@ -1,278 +0,0 @@ -/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ -/* - * Copyright © 2004,2006 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Red Hat, Inc. not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Red Hat, Inc. makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Carl D. Worth - */ - -#include "cairo-boilerplate-private.h" - -#if CAIRO_CAN_TEST_PDF_SURFACE - -#include -#include -#include - -#if HAVE_SIGNAL_H -#include -#endif - -#if HAVE_SYS_WAIT_H -#include -#endif - -#if ! CAIRO_HAS_RECORDING_SURFACE -#define CAIRO_SURFACE_TYPE_RECORDING CAIRO_INTERNAL_SURFACE_TYPE_RECORDING -#endif - -static const cairo_user_data_key_t pdf_closure_key; - -typedef struct _pdf_target_closure -{ - char *filename; - int width; - int height; - cairo_surface_t *target; -} pdf_target_closure_t; - -static cairo_surface_t * -_cairo_boilerplate_pdf_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - pdf_target_closure_t *ptc; - cairo_surface_t *surface; - cairo_status_t status; - - /* Sanitize back to a real cairo_content_t value. */ - if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED) - content = CAIRO_CONTENT_COLOR_ALPHA; - - *closure = ptc = xmalloc (sizeof (pdf_target_closure_t)); - - ptc->width = ceil (width); - ptc->height = ceil (height); - - xasprintf (&ptc->filename, "%s.out.pdf", name); - xunlink (ptc->filename); - - surface = cairo_pdf_surface_create (ptc->filename, width, height); - if (cairo_surface_status (surface)) - goto CLEANUP_FILENAME; - - cairo_surface_set_fallback_resolution (surface, 72., 72.); - - if (content == CAIRO_CONTENT_COLOR) { - ptc->target = surface; - surface = cairo_surface_create_similar (ptc->target, - CAIRO_CONTENT_COLOR, - ptc->width, ptc->height); - if (cairo_surface_status (surface)) - goto CLEANUP_TARGET; - } else { - ptc->target = NULL; - } - - status = cairo_surface_set_user_data (surface, &pdf_closure_key, ptc, NULL); - if (status == CAIRO_STATUS_SUCCESS) - return surface; - - cairo_surface_destroy (surface); - surface = cairo_boilerplate_surface_create_in_error (status); - - CLEANUP_TARGET: - cairo_surface_destroy (ptc->target); - CLEANUP_FILENAME: - free (ptc->filename); - free (ptc); - return surface; -} - -static cairo_status_t -_cairo_boilerplate_pdf_finish_surface (cairo_surface_t *surface) -{ - pdf_target_closure_t *ptc = cairo_surface_get_user_data (surface, - &pdf_closure_key); - cairo_status_t status; - - /* Both surface and ptc->target were originally created at the - * same dimensions. We want a 1:1 copy here, so we first clear any - * device offset on surface. - * - * In a more realistic use case of device offsets, the target of - * this copying would be of a different size than the source, and - * the offset would be desirable during the copy operation. */ - cairo_surface_set_device_offset (surface, 0, 0); - - if (ptc->target) { - cairo_t *cr; - cr = cairo_create (ptc->target); - cairo_set_source_surface (cr, surface, 0, 0); - cairo_paint (cr); - cairo_show_page (cr); - status = cairo_status (cr); - cairo_destroy (cr); - - if (status) - return status; - - cairo_surface_finish (surface); - status = cairo_surface_status (surface); - if (status) - return status; - - surface = ptc->target; - } - - cairo_surface_finish (surface); - status = cairo_surface_status (surface); - if (status) - return status; - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_status_t -_cairo_boilerplate_pdf_surface_write_to_png (cairo_surface_t *surface, - const char *filename) -{ - pdf_target_closure_t *ptc = cairo_surface_get_user_data (surface, &pdf_closure_key); - char command[4096]; - int exitstatus; - - sprintf (command, "./pdf2png %s %s 1", - ptc->filename, filename); - - exitstatus = system (command); -#if _XOPEN_SOURCE && HAVE_SIGNAL_H - if (WIFSIGNALED (exitstatus)) - raise (WTERMSIG (exitstatus)); -#endif - if (exitstatus) - return CAIRO_STATUS_WRITE_ERROR; - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_surface_t * -_cairo_boilerplate_pdf_convert_to_image (cairo_surface_t *surface, - int page) -{ - pdf_target_closure_t *ptc = cairo_surface_get_user_data (surface, - &pdf_closure_key); - - return cairo_boilerplate_convert_to_image (ptc->filename, page+1); -} - -static cairo_surface_t * -_cairo_boilerplate_pdf_get_image_surface (cairo_surface_t *surface, - int page, - int width, - int height) -{ - cairo_surface_t *image; - - image = _cairo_boilerplate_pdf_convert_to_image (surface, page); - cairo_surface_set_device_offset (image, - cairo_image_surface_get_width (image) - width, - cairo_image_surface_get_height (image) - height); - surface = _cairo_boilerplate_get_image_surface (image, 0, width, height); - cairo_surface_destroy (image); - - return surface; -} - -static void -_cairo_boilerplate_pdf_cleanup (void *closure) -{ - pdf_target_closure_t *ptc = closure; - if (ptc->target) { - cairo_surface_finish (ptc->target); - cairo_surface_destroy (ptc->target); - } - free (ptc->filename); - free (ptc); -} - -static void -_cairo_boilerplate_pdf_force_fallbacks (cairo_surface_t *abstract_surface, - double x_pixels_per_inch, - double y_pixels_per_inch) -{ - pdf_target_closure_t *ptc = cairo_surface_get_user_data (abstract_surface, - &pdf_closure_key); - - cairo_paginated_surface_t *paginated; - cairo_pdf_surface_t *surface; - - if (ptc->target) - abstract_surface = ptc->target; - - paginated = (cairo_paginated_surface_t*) abstract_surface; - surface = (cairo_pdf_surface_t*) paginated->target; - surface->force_fallbacks = TRUE; - cairo_surface_set_fallback_resolution (&paginated->base, - x_pixels_per_inch, - y_pixels_per_inch); -} - -static const cairo_boilerplate_target_t targets[] = { - { - "pdf", "pdf", ".pdf", NULL, - CAIRO_SURFACE_TYPE_PDF, - CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0, - "cairo_pdf_surface_create", - _cairo_boilerplate_pdf_create_surface, - cairo_surface_create_similar, - _cairo_boilerplate_pdf_force_fallbacks, - _cairo_boilerplate_pdf_finish_surface, - _cairo_boilerplate_pdf_get_image_surface, - _cairo_boilerplate_pdf_surface_write_to_png, - _cairo_boilerplate_pdf_cleanup, - NULL, NULL, FALSE, TRUE, TRUE - }, - { - "pdf", "pdf", ".pdf", NULL, - CAIRO_SURFACE_TYPE_RECORDING, CAIRO_CONTENT_COLOR, 0, - "cairo_pdf_surface_create", - _cairo_boilerplate_pdf_create_surface, - cairo_surface_create_similar, - _cairo_boilerplate_pdf_force_fallbacks, - _cairo_boilerplate_pdf_finish_surface, - _cairo_boilerplate_pdf_get_image_surface, - _cairo_boilerplate_pdf_surface_write_to_png, - _cairo_boilerplate_pdf_cleanup, - NULL, NULL, FALSE, TRUE, TRUE - }, -}; -CAIRO_BOILERPLATE (pdf, targets) - -#else - -CAIRO_NO_BOILERPLATE (pdf) - -#endif diff --git a/boilerplate/cairo-boilerplate-private.h b/boilerplate/cairo-boilerplate-private.h deleted file mode 100644 index d16a645..0000000 --- a/boilerplate/cairo-boilerplate-private.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright © 2009 Chris Wilson - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Red Hat, Inc. not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Red Hat, Inc. makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Chris Wilson - */ - -#ifndef _CAIRO_BOILERPLATE_PRIVATE_H_ -#define _CAIRO_BOILERPLATE_PRIVATE_H_ - -#include "cairo-boilerplate.h" - -CAIRO_BEGIN_DECLS - -void -_cairo_boilerplate_register_all (void); - -void -_cairo_boilerplate_register_backend (const cairo_boilerplate_target_t *targets, - unsigned int count); - -#define CAIRO_BOILERPLATE(name__, targets__) \ -void _register_##name__ (void); \ -void _register_##name__ (void) { \ - _cairo_boilerplate_register_backend (targets__, \ - ARRAY_LENGTH(targets__)); \ -} - -#define CAIRO_NO_BOILERPLATE(name__) \ -void _register_##name__ (void); \ -void _register_##name__ (void) { } - -CAIRO_END_DECLS - -#endif /* _CAIRO_BOILERPLATE_PRIVATE_H_ */ diff --git a/boilerplate/cairo-boilerplate-ps.c b/boilerplate/cairo-boilerplate-ps.c deleted file mode 100644 index ae61239..0000000 --- a/boilerplate/cairo-boilerplate-ps.c +++ /dev/null @@ -1,369 +0,0 @@ -/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ -/* - * Copyright © 2004,2006 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Red Hat, Inc. not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Red Hat, Inc. makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Carl D. Worth - */ - -#include "cairo-boilerplate-private.h" - -#if CAIRO_CAN_TEST_PS_SURFACE - -#include - -#include -#include - -#if HAVE_SIGNAL_H -#include -#endif - -#if HAVE_SYS_WAIT_H -#include -#endif - -#if ! CAIRO_HAS_RECORDING_SURFACE -#define CAIRO_SURFACE_TYPE_RECORDING CAIRO_INTERNAL_SURFACE_TYPE_RECORDING -#endif - -static const cairo_user_data_key_t ps_closure_key; - -typedef struct _ps_target_closure { - char *filename; - int width; - int height; - cairo_surface_t *target; - cairo_ps_level_t level; -} ps_target_closure_t; - -static cairo_status_t -_cairo_boilerplate_ps_surface_set_creation_date (cairo_surface_t *abstract_surface, - time_t date) -{ - cairo_paginated_surface_t *paginated = (cairo_paginated_surface_t*) abstract_surface; - cairo_ps_surface_t *surface; - - if (cairo_surface_get_type (abstract_surface) != CAIRO_SURFACE_TYPE_PS) - return CAIRO_STATUS_SURFACE_TYPE_MISMATCH; - - surface = (cairo_ps_surface_t*) paginated->target; - - surface->has_creation_date = TRUE; - surface->creation_date = date; - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_surface_t * -_cairo_boilerplate_ps_create_surface (const char *name, - cairo_content_t content, - cairo_ps_level_t level, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - ps_target_closure_t *ptc; - cairo_surface_t *surface; - cairo_status_t status; - - /* Sanitize back to a real cairo_content_t value. */ - if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED) - content = CAIRO_CONTENT_COLOR_ALPHA; - - *closure = ptc = xmalloc (sizeof (ps_target_closure_t)); - - xasprintf (&ptc->filename, "%s.out.ps", name); - xunlink (ptc->filename); - - ptc->level = level; - ptc->width = ceil (width); - ptc->height = ceil (height); - - surface = cairo_ps_surface_create (ptc->filename, width, height); - if (cairo_surface_status (surface)) - goto CLEANUP_FILENAME; - - cairo_ps_surface_restrict_to_level (surface, level); - _cairo_boilerplate_ps_surface_set_creation_date (surface, 0); - cairo_surface_set_fallback_resolution (surface, 72., 72.); - - if (content == CAIRO_CONTENT_COLOR) { - ptc->target = surface; - surface = cairo_surface_create_similar (ptc->target, - CAIRO_CONTENT_COLOR, - ptc->width, ptc->height); - if (cairo_surface_status (surface)) - goto CLEANUP_TARGET; - } else { - ptc->target = NULL; - } - - status = cairo_surface_set_user_data (surface, &ps_closure_key, ptc, NULL); - if (status == CAIRO_STATUS_SUCCESS) - return surface; - - cairo_surface_destroy (surface); - surface = cairo_boilerplate_surface_create_in_error (status); - - CLEANUP_TARGET: - cairo_surface_destroy (ptc->target); - CLEANUP_FILENAME: - free (ptc->filename); - free (ptc); - return surface; -} - -static cairo_surface_t * -_cairo_boilerplate_ps2_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - return _cairo_boilerplate_ps_create_surface (name, content, - CAIRO_PS_LEVEL_2, - width, height, - max_width, max_height, - mode, - closure); -} - -static cairo_surface_t * -_cairo_boilerplate_ps3_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - return _cairo_boilerplate_ps_create_surface (name, content, - CAIRO_PS_LEVEL_3, - width, height, - max_width, max_height, - mode, - closure); -} - -static cairo_status_t -_cairo_boilerplate_ps_finish_surface (cairo_surface_t *surface) -{ - ps_target_closure_t *ptc = cairo_surface_get_user_data (surface, - &ps_closure_key); - cairo_status_t status; - - /* Both surface and ptc->target were originally created at the - * same dimensions. We want a 1:1 copy here, so we first clear any - * device offset on surface. - * - * In a more realistic use case of device offsets, the target of - * this copying would be of a different size than the source, and - * the offset would be desirable during the copy operation. */ - cairo_surface_set_device_offset (surface, 0, 0); - - if (ptc->target) { - cairo_t *cr; - - cr = cairo_create (ptc->target); - cairo_set_source_surface (cr, surface, 0, 0); - cairo_paint (cr); - cairo_show_page (cr); - status = cairo_status (cr); - cairo_destroy (cr); - - if (status) - return status; - - cairo_surface_finish (surface); - status = cairo_surface_status (surface); - if (status) - return status; - - surface = ptc->target; - } - - cairo_surface_finish (surface); - return cairo_surface_status (surface); -} - -static cairo_status_t -_cairo_boilerplate_ps_surface_write_to_png (cairo_surface_t *surface, - const char *filename) -{ - ps_target_closure_t *ptc = cairo_surface_get_user_data (surface, - &ps_closure_key); - char command[4096]; - int exitstatus; - - sprintf (command, "gs -q -r72 -g%dx%d -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=%s %s %s", - ptc->width, ptc->height, filename, - ptc->level == CAIRO_PS_LEVEL_2 ? "-c 2 .setlanguagelevel -f" : "", - ptc->filename); - exitstatus = system (command); -#if _XOPEN_SOURCE && HAVE_SIGNAL_H - if (WIFSIGNALED (exitstatus)) - raise (WTERMSIG (exitstatus)); -#endif - if (exitstatus) - return CAIRO_STATUS_WRITE_ERROR; - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_surface_t * -_cairo_boilerplate_ps_get_image_surface (cairo_surface_t *surface, - int page, - int width, - int height) -{ - ps_target_closure_t *ptc = cairo_surface_get_user_data (surface, - &ps_closure_key); - char *filename; - cairo_status_t status; - - if (page == 0) - xasprintf (&filename, "%s.png", ptc->filename); - else - xasprintf (&filename, "%s-%%05d.png", ptc->filename); - status = _cairo_boilerplate_ps_surface_write_to_png (surface, filename); - if (status) - return cairo_boilerplate_surface_create_in_error (status); - - if (page != 0) { - free (filename); - xasprintf (&filename, "%s-%05d.png", ptc->filename, page); - } - surface = cairo_boilerplate_get_image_surface_from_png (filename, - width, - height, - ptc->target == NULL); - - remove (filename); - free (filename); - - return surface; -} - -static void -_cairo_boilerplate_ps_cleanup (void *closure) -{ - ps_target_closure_t *ptc = closure; - if (ptc->target) { - cairo_surface_finish (ptc->target); - cairo_surface_destroy (ptc->target); - } - free (ptc->filename); - free (ptc); -} - -static void -_cairo_boilerplate_ps_force_fallbacks (cairo_surface_t *abstract_surface, - double x_pixels_per_inch, - double y_pixels_per_inch) -{ - ps_target_closure_t *ptc = cairo_surface_get_user_data (abstract_surface, - &ps_closure_key); - - cairo_paginated_surface_t *paginated; - cairo_ps_surface_t *surface; - - if (ptc->target) - abstract_surface = ptc->target; - - paginated = (cairo_paginated_surface_t*) abstract_surface; - surface = (cairo_ps_surface_t*) paginated->target; - surface->force_fallbacks = TRUE; - cairo_surface_set_fallback_resolution (&paginated->base, - x_pixels_per_inch, - y_pixels_per_inch); -} - -static const cairo_boilerplate_target_t targets[] = { - { - "ps2", "ps", ".ps", NULL, - CAIRO_SURFACE_TYPE_PS, - CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0, - "cairo_ps_surface_create", - _cairo_boilerplate_ps2_create_surface, - cairo_surface_create_similar, - _cairo_boilerplate_ps_force_fallbacks, - _cairo_boilerplate_ps_finish_surface, - _cairo_boilerplate_ps_get_image_surface, - _cairo_boilerplate_ps_surface_write_to_png, - _cairo_boilerplate_ps_cleanup, - NULL, NULL, FALSE, TRUE, TRUE - }, - { - "ps2", "ps", ".ps", NULL, - CAIRO_SURFACE_TYPE_RECORDING, CAIRO_CONTENT_COLOR, 0, - "cairo_ps_surface_create", - _cairo_boilerplate_ps2_create_surface, - cairo_surface_create_similar, - _cairo_boilerplate_ps_force_fallbacks, - _cairo_boilerplate_ps_finish_surface, - _cairo_boilerplate_ps_get_image_surface, - _cairo_boilerplate_ps_surface_write_to_png, - _cairo_boilerplate_ps_cleanup, - NULL, NULL, FALSE, TRUE, TRUE - }, - { - "ps3", "ps", ".ps", NULL, - CAIRO_SURFACE_TYPE_PS, - CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0, - "cairo_ps_surface_create", - _cairo_boilerplate_ps3_create_surface, - cairo_surface_create_similar, - _cairo_boilerplate_ps_force_fallbacks, - _cairo_boilerplate_ps_finish_surface, - _cairo_boilerplate_ps_get_image_surface, - _cairo_boilerplate_ps_surface_write_to_png, - _cairo_boilerplate_ps_cleanup, - NULL, NULL, FALSE, TRUE, TRUE - }, - { - "ps3", "ps", ".ps", NULL, - CAIRO_SURFACE_TYPE_RECORDING, CAIRO_CONTENT_COLOR, 0, - "cairo_ps_surface_create", - _cairo_boilerplate_ps3_create_surface, - cairo_surface_create_similar, - _cairo_boilerplate_ps_force_fallbacks, - _cairo_boilerplate_ps_finish_surface, - _cairo_boilerplate_ps_get_image_surface, - _cairo_boilerplate_ps_surface_write_to_png, - _cairo_boilerplate_ps_cleanup, - NULL, NULL, FALSE, TRUE, TRUE - }, -}; -CAIRO_BOILERPLATE (ps, targets) - -#else - -CAIRO_NO_BOILERPLATE (ps) - -#endif diff --git a/boilerplate/cairo-boilerplate-qt.cpp b/boilerplate/cairo-boilerplate-qt.cpp deleted file mode 100644 index 31c0814..0000000 --- a/boilerplate/cairo-boilerplate-qt.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* Cairo - a vector graphics library with display and print output - * - * Copyright © 2009 Chris Wilson - * - * 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, 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 Chris Wilson. - */ - -#include "cairo-boilerplate-private.h" - -#include - -#include -#include - -typedef struct _qt_closure { - Display *dpy; - QApplication *app; -} qt_closure_t; - -static void -_cairo_boilerplate_qt_cleanup (void *closure) -{ - qt_closure_t *qtc = (qt_closure_t *) closure; - - delete qtc->app; - XCloseDisplay (qtc->dpy); - free (qtc); -} - -static cairo_surface_t * -_cairo_boilerplate_qt_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - qt_closure_t *qtc; - - qtc = (qt_closure_t *) xcalloc (1, sizeof (qt_closure_t)); - qtc->dpy = XOpenDisplay (NULL); - if (qtc->dpy == NULL) { - free (qtc); - return NULL; - } - - if (mode == CAIRO_BOILERPLATE_MODE_TEST) - XSynchronize (qtc->dpy, True); - - qtc->app = new QApplication (qtc->dpy); - *closure = qtc; - return cairo_qt_surface_create_with_qpixmap (content, width, height); -} - -static void -_cairo_boilerplate_qt_synchronize (void *closure) -{ - qt_closure_t *qtc = (qt_closure_t *) closure; - - qtc->app->flush (); /* not sure if this is sufficient */ -} - -static const cairo_boilerplate_target_t targets[] = { - { - "qt", "qt", NULL, NULL, - CAIRO_SURFACE_TYPE_QT, CAIRO_CONTENT_COLOR_ALPHA, 0, - "cairo_qt_surface_create", - _cairo_boilerplate_qt_create_surface, - NULL, NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_qt_cleanup - }, - { - "qt", "qt", NULL, NULL, - CAIRO_SURFACE_TYPE_QT, CAIRO_CONTENT_COLOR, 0, - "cairo_qt_surface_create", - _cairo_boilerplate_qt_create_surface, - NULL, NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_qt_cleanup - }, -}; -extern "C" { -CAIRO_BOILERPLATE (qt, targets) -} diff --git a/boilerplate/cairo-boilerplate-quartz.c b/boilerplate/cairo-boilerplate-quartz.c deleted file mode 100644 index d4ca353..0000000 --- a/boilerplate/cairo-boilerplate-quartz.c +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ -/* - * Copyright © 2004,2007 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Red Hat, Inc. not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Red Hat, Inc. makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Carl D. Worth - */ - -#include "cairo-boilerplate-private.h" - -#include - -static cairo_surface_t * -_cairo_boilerplate_quartz_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - cairo_format_t format; - - format = cairo_boilerplate_format_from_content (content); - - *closure = NULL; - - return cairo_quartz_surface_create (format, width, height); -} - -static const cairo_boilerplate_target_t targets[] = { - { - "quartz", "quartz", NULL, NULL, - CAIRO_SURFACE_TYPE_QUARTZ, CAIRO_CONTENT_COLOR_ALPHA, 0, - "cairo_quartz_surface_create", - _cairo_boilerplate_quartz_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, - TRUE, FALSE, FALSE - }, - { - "quartz", "quartz", NULL, NULL, - CAIRO_SURFACE_TYPE_QUARTZ, CAIRO_CONTENT_COLOR, 0, - "cairo_quartz_surface_create", - _cairo_boilerplate_quartz_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, - FALSE, FALSE, FALSE - }, -}; -CAIRO_BOILERPLATE (quartz, targets) diff --git a/boilerplate/cairo-boilerplate-scaled-font.h b/boilerplate/cairo-boilerplate-scaled-font.h deleted file mode 100644 index a7ba2fe..0000000 --- a/boilerplate/cairo-boilerplate-scaled-font.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ -/* - * Copyright © 2007 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Red Hat, Inc. not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Red Hat, Inc. makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Behdad Esfahbod - */ - -#ifndef _CAIRO_BOILERPLATE_SCALED_FONT_H_ -#define _CAIRO_BOILERPLATE_SCALED_FONT_H_ - -void -cairo_boilerplate_scaled_font_set_max_glyphs_cached (cairo_scaled_font_t *scaled_font, - int max_glyphs); - -#endif diff --git a/boilerplate/cairo-boilerplate-script.c b/boilerplate/cairo-boilerplate-script.c deleted file mode 100644 index da8ae3b..0000000 --- a/boilerplate/cairo-boilerplate-script.c +++ /dev/null @@ -1,141 +0,0 @@ -/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ -/* - * Copyright © Chris Wilson - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Chris Wilson not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Chris Wilson makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL CHRIS WILSON BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Chris Wilson - */ - -#include "cairo-boilerplate-private.h" - -#include "cairo-script.h" - -static cairo_user_data_key_t script_closure_key; - -typedef struct _script_target_closure { - char *filename; - double width; - double height; -} script_target_closure_t; - -static cairo_surface_t * -_cairo_boilerplate_script_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - script_target_closure_t *ptc; - cairo_device_t *ctx; - cairo_surface_t *surface; - cairo_status_t status; - - *closure = ptc = xmalloc (sizeof (script_target_closure_t)); - - ptc->width = width; - ptc->height = height; - - xasprintf (&ptc->filename, "%s.out.cs", name); - xunlink (ptc->filename); - - ctx = cairo_script_create (ptc->filename); - surface = cairo_script_surface_create (ctx, content, width, height); - cairo_device_destroy (ctx); - - status = cairo_surface_set_user_data (surface, - &script_closure_key, ptc, NULL); - if (status == CAIRO_STATUS_SUCCESS) - return surface; - - cairo_surface_destroy (surface); - surface = cairo_boilerplate_surface_create_in_error (status); - - free (ptc->filename); - free (ptc); - return surface; -} - -static cairo_status_t -_cairo_boilerplate_script_finish_surface (cairo_surface_t *surface) -{ - cairo_surface_finish (surface); - return cairo_surface_status (surface); -} - -static cairo_status_t -_cairo_boilerplate_script_surface_write_to_png (cairo_surface_t *surface, - const char *filename) -{ - return CAIRO_STATUS_WRITE_ERROR; -} - -static cairo_surface_t * -_cairo_boilerplate_script_convert_to_image (cairo_surface_t *surface, - int page) -{ - script_target_closure_t *ptc = cairo_surface_get_user_data (surface, - &script_closure_key); - return cairo_boilerplate_convert_to_image (ptc->filename, page); -} - -static cairo_surface_t * -_cairo_boilerplate_script_get_image_surface (cairo_surface_t *surface, - int page, - int width, - int height) -{ - cairo_surface_t *image; - - image = _cairo_boilerplate_script_convert_to_image (surface, page); - cairo_surface_set_device_offset (image, - cairo_image_surface_get_width (image) - width, - cairo_image_surface_get_height (image) - height); - surface = _cairo_boilerplate_get_image_surface (image, 0, width, height); - cairo_surface_destroy (image); - - return surface; -} - -static void -_cairo_boilerplate_script_cleanup (void *closure) -{ - script_target_closure_t *ptc = closure; - free (ptc->filename); - free (ptc); -} - -static const cairo_boilerplate_target_t target[] = {{ - "script", "script", ".cs", NULL, - CAIRO_SURFACE_TYPE_SCRIPT, CAIRO_CONTENT_COLOR_ALPHA, 0, - "cairo_script_surface_create", - _cairo_boilerplate_script_create_surface, - cairo_surface_create_similar, - NULL, - _cairo_boilerplate_script_finish_surface, - _cairo_boilerplate_script_get_image_surface, - _cairo_boilerplate_script_surface_write_to_png, - _cairo_boilerplate_script_cleanup, - NULL, NULL, FALSE, FALSE, FALSE -}}; -CAIRO_BOILERPLATE (script, target) diff --git a/boilerplate/cairo-boilerplate-skia.c b/boilerplate/cairo-boilerplate-skia.c deleted file mode 100644 index c06e7f0..0000000 --- a/boilerplate/cairo-boilerplate-skia.c +++ /dev/null @@ -1,55 +0,0 @@ - -#include "cairo-boilerplate-private.h" - -#include - -static cairo_surface_t * -_cairo_boilerplate_skia_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - cairo_format_t format; - - *closure = NULL; - - if (content == CAIRO_CONTENT_COLOR_ALPHA) { - format = CAIRO_FORMAT_ARGB32; - } else if (content == CAIRO_CONTENT_COLOR) { - format = CAIRO_FORMAT_RGB24; - } else { - return NULL; - } - - return cairo_skia_surface_create (format, width, height); -} - -static const cairo_boilerplate_target_t targets[] = { - { - "skia", "skia", NULL, NULL, - CAIRO_SURFACE_TYPE_SKIA, CAIRO_CONTENT_COLOR_ALPHA, 0, - "cairo_skia_surface_create", - _cairo_boilerplate_skia_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, TRUE, FALSE, FALSE - }, - { - "skia", "skia", NULL, NULL, - CAIRO_SURFACE_TYPE_SKIA, CAIRO_CONTENT_COLOR, 0, - "cairo_skia_surface_create", - _cairo_boilerplate_skia_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, FALSE, FALSE, FALSE - }, -}; -CAIRO_BOILERPLATE (skia, targets) diff --git a/boilerplate/cairo-boilerplate-svg.c b/boilerplate/cairo-boilerplate-svg.c deleted file mode 100644 index 797106e..0000000 --- a/boilerplate/cairo-boilerplate-svg.c +++ /dev/null @@ -1,344 +0,0 @@ -/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ -/* - * Copyright © 2004,2006 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Red Hat, Inc. not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Red Hat, Inc. makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Carl D. Worth - */ - -#include "cairo-boilerplate-private.h" - -#if CAIRO_CAN_TEST_SVG_SURFACE - -#include -#include -#include - -#if HAVE_SIGNAL_H -#include -#include -#endif - -#if HAVE_SYS_WAIT_H -#include -#endif - -#if ! CAIRO_HAS_RECORDING_SURFACE -#define CAIRO_SURFACE_TYPE_RECORDING CAIRO_INTERNAL_SURFACE_TYPE_RECORDING -#endif - -static const cairo_user_data_key_t svg_closure_key; - -typedef struct _svg_target_closure { - char *filename; - int width, height; - cairo_surface_t *target; -} svg_target_closure_t; - -static cairo_surface_t * -_cairo_boilerplate_svg_create_surface (const char *name, - cairo_content_t content, - cairo_svg_version_t version, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - svg_target_closure_t *ptc; - cairo_surface_t *surface; - cairo_status_t status; - - *closure = ptc = xmalloc (sizeof (svg_target_closure_t)); - - ptc->width = ceil (width); - ptc->height = ceil (height); - - xasprintf (&ptc->filename, "%s.out.svg", name); - xunlink (ptc->filename); - - surface = cairo_svg_surface_create (ptc->filename, width, height); - if (cairo_surface_status (surface)) - goto CLEANUP_FILENAME; - - cairo_svg_surface_restrict_to_version (surface, version); - cairo_surface_set_fallback_resolution (surface, 72., 72.); - - if (content == CAIRO_CONTENT_COLOR) { - ptc->target = surface; - surface = cairo_surface_create_similar (ptc->target, - CAIRO_CONTENT_COLOR, - ptc->width, ptc->height); - if (cairo_surface_status (surface)) - goto CLEANUP_TARGET; - } else - ptc->target = NULL; - - status = cairo_surface_set_user_data (surface, &svg_closure_key, ptc, NULL); - if (status == CAIRO_STATUS_SUCCESS) - return surface; - - cairo_surface_destroy (surface); - surface = cairo_boilerplate_surface_create_in_error (status); - - CLEANUP_TARGET: - cairo_surface_destroy (ptc->target); - CLEANUP_FILENAME: - free (ptc->filename); - free (ptc); - return surface; -} - -static cairo_surface_t * -_cairo_boilerplate_svg11_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - /* current default, but be explicit in case the default changes */ - return _cairo_boilerplate_svg_create_surface (name, content, - CAIRO_SVG_VERSION_1_1, - width, height, - max_width, max_height, - mode, - closure); -} - -static cairo_surface_t * -_cairo_boilerplate_svg12_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - return _cairo_boilerplate_svg_create_surface (name, content, - CAIRO_SVG_VERSION_1_2, - width, height, - max_width, max_height, - mode, - closure); -} - -static cairo_status_t -_cairo_boilerplate_svg_finish_surface (cairo_surface_t *surface) -{ - svg_target_closure_t *ptc = cairo_surface_get_user_data (surface, - &svg_closure_key); - cairo_status_t status; - - /* Both surface and ptc->target were originally created at the - * same dimensions. We want a 1:1 copy here, so we first clear any - * device offset on surface. - * - * In a more realistic use case of device offsets, the target of - * this copying would be of a different size than the source, and - * the offset would be desirable during the copy operation. */ - cairo_surface_set_device_offset (surface, 0, 0); - - if (ptc->target) { - cairo_t *cr; - cr = cairo_create (ptc->target); - cairo_set_source_surface (cr, surface, 0, 0); - cairo_paint (cr); - cairo_show_page (cr); - status = cairo_status (cr); - cairo_destroy (cr); - - if (status) - return status; - - cairo_surface_finish (surface); - status = cairo_surface_status (surface); - if (status) - return status; - - surface = ptc->target; - } - - cairo_surface_finish (surface); - status = cairo_surface_status (surface); - if (status) - return status; - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_status_t -_cairo_boilerplate_svg_surface_write_to_png (cairo_surface_t *surface, - const char *filename) -{ - svg_target_closure_t *ptc = cairo_surface_get_user_data (surface, - &svg_closure_key); - char command[4096]; - int exitstatus; - - sprintf (command, "./svg2png %s %s", - ptc->filename, filename); - - exitstatus = system (command); -#if _XOPEN_SOURCE && HAVE_SIGNAL_H - if (WIFSIGNALED (exitstatus)) - raise (WTERMSIG (exitstatus)); -#endif - if (exitstatus) - return CAIRO_STATUS_WRITE_ERROR; - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_surface_t * -_cairo_boilerplate_svg_convert_to_image (cairo_surface_t *surface) -{ - svg_target_closure_t *ptc = cairo_surface_get_user_data (surface, - &svg_closure_key); - - return cairo_boilerplate_convert_to_image (ptc->filename, 0); -} - -static cairo_surface_t * -_cairo_boilerplate_svg_get_image_surface (cairo_surface_t *surface, - int page, - int width, - int height) -{ - cairo_surface_t *image; - - if (page != 0) - return cairo_boilerplate_surface_create_in_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); - - image = _cairo_boilerplate_svg_convert_to_image (surface); - cairo_surface_set_device_offset (image, - cairo_image_surface_get_width (image) - width, - cairo_image_surface_get_height (image) - height); - surface = _cairo_boilerplate_get_image_surface (image, 0, width, height); - cairo_surface_destroy (image); - - return surface; -} - -static void -_cairo_boilerplate_svg_cleanup (void *closure) -{ - svg_target_closure_t *ptc = closure; - if (ptc->target != NULL) { - cairo_surface_finish (ptc->target); - cairo_surface_destroy (ptc->target); - } - free (ptc->filename); - free (ptc); -} - -static void -_cairo_boilerplate_svg_force_fallbacks (cairo_surface_t *abstract_surface, - double x_pixels_per_inch, - double y_pixels_per_inch) -{ - svg_target_closure_t *ptc = cairo_surface_get_user_data (abstract_surface, - &svg_closure_key); - - cairo_paginated_surface_t *paginated; - cairo_svg_surface_t *surface; - - if (ptc->target) - abstract_surface = ptc->target; - - paginated = (cairo_paginated_surface_t*) abstract_surface; - surface = (cairo_svg_surface_t*) paginated->target; - surface->force_fallbacks = TRUE; - cairo_surface_set_fallback_resolution (&paginated->base, - x_pixels_per_inch, - y_pixels_per_inch); -} - -static const cairo_boilerplate_target_t targets[] = { - /* It seems we should be able to round-trip SVG content perfectly - * through librsvg and cairo, but for some mysterious reason, some - * systems get an error of 1 for some pixels on some of the text - * tests. XXX: I'd still like to chase these down at some point. - * For now just set the svg error tolerance to 1. */ - { - "svg11", "svg", ".svg", NULL, - CAIRO_SURFACE_TYPE_SVG, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_svg_surface_create", - _cairo_boilerplate_svg11_create_surface, - cairo_surface_create_similar, - _cairo_boilerplate_svg_force_fallbacks, - _cairo_boilerplate_svg_finish_surface, - _cairo_boilerplate_svg_get_image_surface, - _cairo_boilerplate_svg_surface_write_to_png, - _cairo_boilerplate_svg_cleanup, - NULL, NULL, FALSE, TRUE, TRUE - }, - { - "svg11", "svg", ".svg", NULL, - CAIRO_SURFACE_TYPE_RECORDING, CAIRO_CONTENT_COLOR, 1, - "cairo_svg_surface_create", - _cairo_boilerplate_svg11_create_surface, - cairo_surface_create_similar, - _cairo_boilerplate_svg_force_fallbacks, - _cairo_boilerplate_svg_finish_surface, - _cairo_boilerplate_svg_get_image_surface, - _cairo_boilerplate_svg_surface_write_to_png, - _cairo_boilerplate_svg_cleanup, - NULL, NULL, FALSE, TRUE, TRUE - }, - { - "svg12", "svg", ".svg", NULL, - CAIRO_SURFACE_TYPE_SVG, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_svg_surface_create", - _cairo_boilerplate_svg12_create_surface, - cairo_surface_create_similar, - _cairo_boilerplate_svg_force_fallbacks, - _cairo_boilerplate_svg_finish_surface, - _cairo_boilerplate_svg_get_image_surface, - _cairo_boilerplate_svg_surface_write_to_png, - _cairo_boilerplate_svg_cleanup, - NULL, NULL, FALSE, TRUE, TRUE - }, - { - "svg12", "svg", ".svg", NULL, - CAIRO_SURFACE_TYPE_RECORDING, CAIRO_CONTENT_COLOR, 1, - "cairo_svg_surface_create", - _cairo_boilerplate_svg12_create_surface, - cairo_surface_create_similar, - _cairo_boilerplate_svg_force_fallbacks, - _cairo_boilerplate_svg_finish_surface, - _cairo_boilerplate_svg_get_image_surface, - _cairo_boilerplate_svg_surface_write_to_png, - _cairo_boilerplate_svg_cleanup, - NULL, NULL, FALSE, TRUE, TRUE - }, -}; -CAIRO_BOILERPLATE (svg, targets) - -#else - -CAIRO_NO_BOILERPLATE (svg) - -#endif diff --git a/boilerplate/cairo-boilerplate-system.c b/boilerplate/cairo-boilerplate-system.c deleted file mode 100644 index ec23341..0000000 --- a/boilerplate/cairo-boilerplate-system.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright © 2004 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Red Hat, Inc. not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Red Hat, Inc. makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Carl D. Worth - */ - -#define _GNU_SOURCE 1 /* for vasprintf */ - -#include "cairo-boilerplate.h" -#include "cairo-boilerplate-system.h" - -#include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#include - -void * -xmalloc (size_t size) -{ - void *buf; - - if (size == 0) - return NULL; - - buf = malloc (size); - if (buf == NULL) { - fprintf (stderr, "Error: Out of memory. Exiting.\n"); - exit (1); - } - - return buf; -} - -void * -xcalloc (size_t nmemb, - size_t size) -{ - void *buf; - - if (nmemb == 0 || size == 0) - return NULL; - - buf = calloc (nmemb, size); - if (buf == NULL) { - fprintf (stderr, "Error: Out of memory. Exiting\n"); - exit (1); - } - - return buf; -} - -void * -xrealloc (void *buf, - size_t size) -{ - buf = realloc (buf, size); - if (buf == NULL && size != 0) { - fprintf (stderr, "Error: Out of memory. Exiting\n"); - exit (1); - } - - return buf; -} - -void -xasprintf (char **strp, - const char *fmt, - ...) -{ -#ifdef HAVE_VASPRINTF - va_list va; - int ret; - - va_start (va, fmt); - ret = vasprintf (strp, fmt, va); - va_end (va); - - if (ret < 0) { - fprintf (stderr, "Error: Out of memory. Exiting.\n"); - exit (1); - } -#else /* !HAVE_VASNPRINTF */ -#define BUF_SIZE 1024 - va_list va; - char buffer[BUF_SIZE]; - int ret, len; - - va_start (va, fmt); - ret = vsnprintf (buffer, sizeof (buffer), fmt, va); - va_end (va); - - if (ret < 0) { - fprintf (stderr, "Failure in vsnprintf\n"); - exit (1); - } - - len = (ret + sizeof (int)) & -sizeof (int); - *strp = malloc (len); - if (*strp == NULL) { - fprintf (stderr, "Out of memory\n"); - exit (1); - } - - if ((unsigned) ret < sizeof (buffer)) { - memcpy (*strp, buffer, ret); - } else { - va_start (va, fmt); - ret = vsnprintf (*strp, len, fmt, va); - va_end (va); - - if (ret >= len) { - free (*strp); - fprintf (stderr, "Overflowed dynamic buffer\n"); - exit (1); - } - } - memset (*strp + ret, 0, len-ret); -#endif /* !HAVE_VASNPRINTF */ -} - -void -xunlink (const char *pathname) -{ - if (unlink (pathname) < 0 && errno != ENOENT) { - fprintf (stderr, "Error: Cannot remove %s: %s\n", - pathname, strerror (errno)); - exit (1); - } -} - -char * -xstrdup (const char *str) -{ - if (str == NULL) - return NULL; - - str = strdup (str); - if (str == NULL) { - fprintf (stderr, "Error: Out of memory. Exiting.\n"); - exit (1); - } - - return (char *) str; -} diff --git a/boilerplate/cairo-boilerplate-system.h b/boilerplate/cairo-boilerplate-system.h deleted file mode 100644 index 2816567..0000000 --- a/boilerplate/cairo-boilerplate-system.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright © 2004 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Red Hat, Inc. not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Red Hat, Inc. makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Carl D. Worth - */ - -#ifndef _XMALLOC_H_ -#define _XMALLOC_H_ - -#include "cairo-boilerplate.h" - -#define xmalloc cairo_boilerplate_xmalloc -void * -xmalloc (size_t size); - -#define xcalloc cairo_boilerplate_xcalloc -void * -xcalloc (size_t nmemb, - size_t size); - -#define xrealloc cairo_boilerplate_xrealloc -void * -xrealloc (void *buf, - size_t size); - -#define xasprintf cairo_boilerplate_xasprintf -void -xasprintf (char **strp, - const char *fmt, - ...) CAIRO_BOILERPLATE_PRINTF_FORMAT(2, 3); - -#define xunlink cairo_boilerplate_xunlink -void -xunlink (const char *path); - -#define xstrdup cairo_boilerplate_xstrdup -char * -xstrdup (const char *str); - -#endif diff --git a/boilerplate/cairo-boilerplate-test-surfaces.c b/boilerplate/cairo-boilerplate-test-surfaces.c deleted file mode 100644 index 293b77f..0000000 --- a/boilerplate/cairo-boilerplate-test-surfaces.c +++ /dev/null @@ -1,462 +0,0 @@ -/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ -/* - * Copyright © 2004,2006 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Red Hat, Inc. not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Red Hat, Inc. makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Carl D. Worth - */ - -#include "../cairo-version.h" - -#include "cairo-boilerplate-private.h" - -#include - -#include -#include -#if CAIRO_HAS_TEST_PAGINATED_SURFACE -#include -#endif - -static cairo_surface_t * -_cairo_boilerplate_test_base_compositor_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - *closure = NULL; - return _cairo_test_base_compositor_surface_create (content, ceil (width), ceil (height)); -} - - -static cairo_surface_t * -_cairo_boilerplate_test_fallback_compositor_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - *closure = NULL; - return _cairo_test_fallback_compositor_surface_create (content, ceil (width), ceil (height)); -} - -static cairo_surface_t * -_cairo_boilerplate_test_mask_compositor_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - *closure = NULL; - return _cairo_test_mask_compositor_surface_create (content, ceil (width), ceil (height)); -} - - -static cairo_surface_t * -_cairo_boilerplate_test_traps_compositor_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - *closure = NULL; - return _cairo_test_traps_compositor_surface_create (content, ceil (width), ceil (height)); -} - -static cairo_surface_t * -_cairo_boilerplate_test_spans_compositor_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - *closure = NULL; - return _cairo_test_spans_compositor_surface_create (content, ceil (width), ceil (height)); -} - -static cairo_surface_t * -_cairo_boilerplate_test_no_fallback_compositor_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - if (mode == CAIRO_BOILERPLATE_MODE_TEST) - return NULL; - - *closure = NULL; - return _cairo_test_no_fallback_compositor_surface_create (content, ceil (width), ceil (height)); -} - -static cairo_surface_t * -_cairo_boilerplate_test_no_traps_compositor_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - if (mode == CAIRO_BOILERPLATE_MODE_TEST) - return NULL; - - *closure = NULL; - return _cairo_test_no_traps_compositor_surface_create (content, ceil (width), ceil (height)); -} - -static cairo_surface_t * -_cairo_boilerplate_test_no_spans_compositor_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - if (mode == CAIRO_BOILERPLATE_MODE_TEST) - return NULL; - - *closure = NULL; - return _cairo_test_no_spans_compositor_surface_create (content, ceil (width), ceil (height)); -} - -#if CAIRO_HAS_TEST_PAGINATED_SURFACE -static const cairo_user_data_key_t test_paginated_closure_key; - -typedef struct { - cairo_surface_t *target; -} test_paginated_closure_t; - -static cairo_surface_t * -_cairo_boilerplate_test_paginated_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - test_paginated_closure_t *tpc; - cairo_format_t format; - cairo_surface_t *surface; - cairo_status_t status; - - *closure = tpc = xmalloc (sizeof (test_paginated_closure_t)); - - format = cairo_boilerplate_format_from_content (content); - tpc->target = cairo_image_surface_create (format, - ceil (width), ceil (height)); - - surface = _cairo_test_paginated_surface_create (tpc->target); - if (cairo_surface_status (surface)) - goto CLEANUP; - - status = cairo_surface_set_user_data (surface, - &test_paginated_closure_key, - tpc, NULL); - if (status == CAIRO_STATUS_SUCCESS) - return surface; - - cairo_surface_destroy (surface); - surface = cairo_boilerplate_surface_create_in_error (status); - - cairo_surface_destroy (tpc->target); - - CLEANUP: - free (tpc); - return surface; -} - -/* The only reason we go through all these machinations to write a PNG - * image is to _really ensure_ that the data actually landed in our - * buffer through the paginated surface to the test_paginated_surface. - * - * If we didn't implement this function then the default - * cairo_surface_write_to_png would result in the paginated_surface's - * acquire_source_image function replaying the recording-surface to an - * intermediate image surface. And in that case the - * test_paginated_surface would not be involved and wouldn't be - * tested. - */ -static cairo_status_t -_cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t *surface, - const char *filename) -{ - test_paginated_closure_t *tpc; - cairo_status_t status; - - /* show page first. the automatic show_page is too late for us */ - cairo_surface_show_page (surface); - status = cairo_surface_status (surface); - if (status) - return status; - - tpc = cairo_surface_get_user_data (surface, &test_paginated_closure_key); - return cairo_surface_write_to_png (tpc->target, filename); -} - -static cairo_surface_t * -_cairo_boilerplate_test_paginated_get_image_surface (cairo_surface_t *surface, - int page, - int width, - int height) -{ - test_paginated_closure_t *tpc; - cairo_status_t status; - - /* XXX separate finish as per PDF */ - if (page != 0) - return cairo_boilerplate_surface_create_in_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); - - /* show page first. the automatic show_page is too late for us */ - cairo_surface_show_page (surface); - status = cairo_surface_status (surface); - if (status) - return cairo_boilerplate_surface_create_in_error (status); - - tpc = cairo_surface_get_user_data (surface, &test_paginated_closure_key); - return _cairo_boilerplate_get_image_surface (tpc->target, 0, width, height); -} - -static void -_cairo_boilerplate_test_paginated_cleanup (void *closure) -{ - test_paginated_closure_t *tpc = closure; - - cairo_surface_destroy (tpc->target); - free (tpc); -} -#endif - -static const cairo_boilerplate_target_t targets[] = { - { - "test-base", "base", NULL, NULL, - CAIRO_SURFACE_TYPE_IMAGE, - CAIRO_CONTENT_COLOR_ALPHA, 0, - "_cairo_test_base_compositor_surface_create", - _cairo_boilerplate_test_base_compositor_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, TRUE, FALSE, FALSE - }, - { - "test-base", "base", NULL, NULL, - CAIRO_SURFACE_TYPE_IMAGE, - CAIRO_CONTENT_COLOR, 0, - "_cairo_test_base_compositor_surface_create", - _cairo_boilerplate_test_base_compositor_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, FALSE, FALSE, FALSE - }, - - { - "test-fallback", "image", NULL, NULL, - CAIRO_SURFACE_TYPE_IMAGE, - CAIRO_CONTENT_COLOR_ALPHA, 0, - "_cairo_test_fallback_compositor_surface_create", - _cairo_boilerplate_test_fallback_compositor_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, FALSE, FALSE, FALSE - }, - { - "test-fallback", "image", NULL, NULL, - CAIRO_SURFACE_TYPE_IMAGE, - CAIRO_CONTENT_COLOR, 0, - "_cairo_test_fallback_compositor_surface_create", - _cairo_boilerplate_test_fallback_compositor_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, FALSE, FALSE, FALSE - }, - - { - "test-mask", "mask", NULL, NULL, - CAIRO_SURFACE_TYPE_IMAGE, - CAIRO_CONTENT_COLOR_ALPHA, 0, - "_cairo_test_mask_compositor_surface_create", - _cairo_boilerplate_test_mask_compositor_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, TRUE, FALSE, FALSE - }, - { - "test-mask", "mask", NULL, NULL, - CAIRO_SURFACE_TYPE_IMAGE, - CAIRO_CONTENT_COLOR, 0, - "_cairo_test_mask_compositor_surface_create", - _cairo_boilerplate_test_mask_compositor_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, FALSE, FALSE, FALSE - }, - - { - "test-traps", "traps", NULL, NULL, - CAIRO_SURFACE_TYPE_IMAGE, - CAIRO_CONTENT_COLOR_ALPHA, 0, - "_cairo_test_traps_compositor_surface_create", - _cairo_boilerplate_test_traps_compositor_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, TRUE, FALSE, FALSE - }, - { - "test-traps", "traps", NULL, NULL, - CAIRO_SURFACE_TYPE_IMAGE, - CAIRO_CONTENT_COLOR, 0, - "_cairo_test_traps_compositor_surface_create", - _cairo_boilerplate_test_traps_compositor_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, FALSE, FALSE, FALSE - }, - - { - "test-spans", "spans", NULL, NULL, - CAIRO_SURFACE_TYPE_IMAGE, - CAIRO_CONTENT_COLOR_ALPHA, 0, - "_cairo_test_spans_compositor_surface_create", - _cairo_boilerplate_test_spans_compositor_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, TRUE, FALSE, FALSE - }, - { - "test-spans", "spans", NULL, NULL, - CAIRO_SURFACE_TYPE_IMAGE, - CAIRO_CONTENT_COLOR, 0, - "_cairo_test_spans_compositor_surface_create", - _cairo_boilerplate_test_spans_compositor_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, FALSE, FALSE, FALSE - }, - - { - "no-fallback", "image", NULL, NULL, - CAIRO_SURFACE_TYPE_IMAGE, - CAIRO_CONTENT_COLOR_ALPHA, 0, - "_cairo_test_no_fallback_compositor_surface_create", - _cairo_boilerplate_test_no_fallback_compositor_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, FALSE, FALSE, FALSE - }, - { - "no-traps", "traps", NULL, NULL, - CAIRO_SURFACE_TYPE_IMAGE, - CAIRO_CONTENT_COLOR_ALPHA, 0, - "_cairo_test_no_traps_compositor_surface_create", - _cairo_boilerplate_test_no_traps_compositor_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, TRUE, FALSE, FALSE - }, - { - "no-spans", "spans", NULL, NULL, - CAIRO_SURFACE_TYPE_IMAGE, - CAIRO_CONTENT_COLOR_ALPHA, 0, - "_cairo_test_no_spans_compositor_surface_create", - _cairo_boilerplate_test_no_spans_compositor_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, TRUE, FALSE, FALSE - }, -#if CAIRO_HAS_TEST_PAGINATED_SURFACE - { - "test-paginated", "image", NULL, NULL, - CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED, - CAIRO_CONTENT_COLOR_ALPHA, 0, - "_cairo_test_paginated_surface_create", - _cairo_boilerplate_test_paginated_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_test_paginated_get_image_surface, - _cairo_boilerplate_test_paginated_surface_write_to_png, - _cairo_boilerplate_test_paginated_cleanup, - NULL, NULL, FALSE, TRUE, FALSE - }, - { - "test-paginated", "image", NULL, NULL, - CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED, - CAIRO_CONTENT_COLOR, 0, - "_cairo_test_paginated_surface_create", - _cairo_boilerplate_test_paginated_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_test_paginated_get_image_surface, - _cairo_boilerplate_test_paginated_surface_write_to_png, - _cairo_boilerplate_test_paginated_cleanup, - NULL, NULL, FALSE, TRUE, FALSE - }, -#endif -}; -CAIRO_BOILERPLATE (test, targets) diff --git a/boilerplate/cairo-boilerplate-vg.c b/boilerplate/cairo-boilerplate-vg.c deleted file mode 100644 index 6927657..0000000 --- a/boilerplate/cairo-boilerplate-vg.c +++ /dev/null @@ -1,363 +0,0 @@ -/* Cairo - a vector graphics library with display and print output - * - * Copyright © 2009 Chris Wilson - * - * 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, 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 Chris Wilson. - */ - -#include "cairo-boilerplate-private.h" - -#include - - /* XXX Not sure how to handle library specific context initialization */ -//#define USE_SHIVA -//#define USE_AMANITH - -#if CAIRO_HAS_GLX_FUNCTIONS - -#include -#include - -typedef struct _vg_closure { - Display *dpy; - int screen; - Window win; - - GLXContext ctx; - cairo_surface_t *surface; -} vg_closure_glx_t; - -static void -_cairo_boilerplate_vg_cleanup_glx (void *closure) -{ - vg_closure_glx_t *vgc = closure; - -#ifdef USE_AMANITH - vgDestroyContextAM (); -#endif -#ifdef USE_SHIVA - vgDestroyContextSH (); -#endif - - glXDestroyContext (vgc->dpy, vgc->ctx); - XDestroyWindow (vgc->dpy, vgc->win); - XCloseDisplay (vgc->dpy); - free (vgc); -} - -static cairo_surface_t * -_cairo_boilerplate_vg_create_surface_glx (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - int rgba_attribs[] = { - GLX_RGBA, - GLX_RED_SIZE, 1, - GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, - GLX_ALPHA_SIZE, 1, - GLX_DOUBLEBUFFER, - GLX_NONE - }; - int rgb_attribs[] = { - GLX_RGBA, - GLX_RED_SIZE, 1, - GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, - GLX_DOUBLEBUFFER, - GLX_NONE - }; - XVisualInfo *vi; - Display *dpy; - Colormap cmap; - XSetWindowAttributes swa; - cairo_surface_t *surface; - cairo_vg_context_t *context; - vg_closure_glx_t *vgc; - - vgc = malloc (sizeof (vg_closure_glx_t)); - *closure = vgc; - - if (width == 0) - width = 1; - if (height == 0) - height = 1; - - dpy = XOpenDisplay (NULL); - vgc->dpy = dpy; - if (vgc->dpy == NULL) { - fprintf (stderr, "Failed to open display: %s\n", XDisplayName(0)); - free (vgc); - return NULL; - } - - if (content == CAIRO_CONTENT_COLOR) - vi = glXChooseVisual (dpy, DefaultScreen (dpy), rgb_attribs); - else - vi = glXChooseVisual (dpy, DefaultScreen (dpy), rgba_attribs); - - if (vi == NULL) { - fprintf (stderr, "Failed to create RGB, double-buffered visual\n"); - XCloseDisplay (dpy); - free (vgc); - return NULL; - } - - vgc->ctx = glXCreateContext (dpy, vi, NULL, True); - cmap = XCreateColormap (dpy, - RootWindow (dpy, vi->screen), - vi->visual, - AllocNone); - swa.colormap = cmap; - swa.border_pixel = 0; - vgc->win = XCreateWindow (dpy, RootWindow (dpy, vi->screen), - -1, -1, 1, 1, 0, - vi->depth, - InputOutput, - vi->visual, - CWBorderPixel | CWColormap, &swa); - XFreeColormap (dpy, cmap); - XFree (vi); - - XMapWindow (dpy, vgc->win); - - /* we need an active context to initialise VG */ - glXMakeContextCurrent (dpy, vgc->win, vgc->win, vgc->ctx); - -#ifdef USE_AMANITH - vgInitContextAM (width, height, VG_FALSE, VG_TRUE); -#endif -#ifdef USE_SHIVA - vgCreateContextSH (width, height); -#endif - - context = cairo_vg_context_create_for_glx (dpy, vgc->ctx); - vgc->surface = cairo_vg_surface_create (context, content, width, height); - cairo_vg_context_destroy (context); - - surface = vgc->surface; - if (cairo_surface_status (surface)) - _cairo_boilerplate_vg_cleanup_glx (vgc); - - return surface; -} -#endif - -#if CAIRO_HAS_EGL_FUNCTIONS -typedef struct _vg_closure_egl { - EGLDisplay *dpy; - EGLContext *ctx; - EGLSurface *dummy; -} vg_closure_egl_t; - -static void -_cairo_boilerplate_vg_cleanup_egl (void *closure) -{ - vg_closure_egl_t *vgc = closure; - -#ifdef USE_AMANITH - vgDestroyContextAM (); -#endif -#ifdef USE_SHIVA - vgDestroyContextSH (); -#endif - - eglDestroyContext (vgc->dpy, vgc->ctx); - eglDestroySurface (vgc->dpy, vgc->dummy); - eglTerminate (vgc->dpy); - free (vgc); -} - -static cairo_surface_t * -_cairo_boilerplate_vg_create_surface_egl (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - int rgba_attribs[] = { - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, 8, - EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, - EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT, - EGL_NONE - }; - int rgb_attribs[] = { - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, 8, - EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE_BIT, - EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, - EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT, - EGL_NONE - }; - int dummy_attribs[] = { - EGL_WIDTH, 8, EGL_HEIGHT, 8, - EGL_NONE - }; - EGLDisplay *dpy; - int major, minor; - EGLConfig config; - int num_configs; - EGLContext *egl_context; - EGLSurface *dummy; - cairo_vg_context_t *context; - cairo_surface_t *surface; - vg_closure_egl_t *vgc; - - dpy = eglGetDisplay (EGL_DEFAULT_DISPLAY); - - if (! eglInitialize (dpy, &major, &minor)) - return NULL; - - eglBindAPI (EGL_OPENVG_API); - - if (! eglChooseConfig (dpy, - content == CAIRO_CONTENT_COLOR_ALPHA ? - rgba_attribs : rgb_attribs, - &config, 1, &num_configs) || - num_configs != 1) - { - return NULL; - } - - egl_context = eglCreateContext (dpy, config, NULL, NULL); - if (egl_context == NULL) - return NULL; - - /* Create a dummy surface in order to enable a context to initialise VG */ - dummy = eglCreatePbufferSurface (dpy, config, dummy_attribs); - if (dummy == NULL) - return NULL; - if (! eglMakeCurrent (dpy, dummy, dummy, egl_context)) - return NULL; - -#ifdef USE_AMANITH - vgInitContextAM (width, height, VG_FALSE, VG_TRUE); -#endif -#ifdef USE_SHIVA - vgCreateContextSH (width, height); -#endif - - vgc = xmalloc (sizeof (vg_closure_egl_t)); - vgc->dpy = dpy; - vgc->ctx = egl_context; - vgc->dummy = dummy; - *closure = vgc; - - context = cairo_vg_context_create_for_egl (vgc->dpy, vgc->ctx); - surface = cairo_vg_surface_create (context, content, width, height); - cairo_vg_context_destroy (context); - - if (cairo_surface_status (surface)) - _cairo_boilerplate_vg_cleanup_egl (vgc); - - return surface; -} -#endif - -static void -_cairo_boilerplate_vg_synchronize (void *closure) -{ - vgFinish (); -} - -static const cairo_boilerplate_target_t targets[] = { -#if CAIRO_HAS_GLX_FUNCTIONS - { - "vg-glx", "vg", NULL, NULL, - CAIRO_SURFACE_TYPE_VG, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_vg_context_create_for_glx", - _cairo_boilerplate_vg_create_surface_glx, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_vg_cleanup_glx, - _cairo_boilerplate_vg_synchronize, - NULL, - TRUE, FALSE, FALSE - }, - { - "vg-glx", "vg", NULL, NULL, - CAIRO_SURFACE_TYPE_VG, CAIRO_CONTENT_COLOR, 1, - "cairo_vg_context_create_for_glx", - _cairo_boilerplate_vg_create_surface_glx, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_vg_cleanup_glx, - _cairo_boilerplate_vg_synchronize, - NULL, - FALSE, FALSE, FALSE - }, -#endif -#if CAIRO_HAS_EGL_FUNCTIONS - { - "vg-egl", "vg", NULL, NULL, - CAIRO_SURFACE_TYPE_VG, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_vg_context_create_for_egl", - _cairo_boilerplate_vg_create_surface_egl, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_vg_cleanup_egl, - _cairo_boilerplate_vg_synchronize, - NULL, - TRUE, FALSE, FALSE - }, - { - "vg-egl", "vg", NULL, NULL, - CAIRO_SURFACE_TYPE_VG, CAIRO_CONTENT_COLOR, 1, - "cairo_vg_context_create_for_egl", - _cairo_boilerplate_vg_create_surface_egl, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_vg_cleanup_egl, - _cairo_boilerplate_vg_synchronize, - NULL, - FALSE, FALSE, FALSE - }, -#endif -}; -CAIRO_BOILERPLATE (vg, targets) diff --git a/boilerplate/cairo-boilerplate-wgl.c b/boilerplate/cairo-boilerplate-wgl.c deleted file mode 100644 index 9088177..0000000 --- a/boilerplate/cairo-boilerplate-wgl.c +++ /dev/null @@ -1,239 +0,0 @@ -/* cairo - a vector graphics library with display and print output - * - * Copyright © 2009 Chris Wilson - * - * 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, 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 Chris Wilson. - * - * Contributor(s): - * Zoxc - */ - -#include "cairo-boilerplate-private.h" - -#include - -static const cairo_user_data_key_t gl_closure_key; - -typedef struct _wgl_target_closure { - HWND wnd; - HDC dc; - HGLRC rc; - cairo_device_t *device; - cairo_surface_t *surface; -} wgl_target_closure_t; - -static void -_cairo_boilerplate_wgl_cleanup (void *closure) -{ - wgl_target_closure_t *wgltc = closure; - - cairo_device_finish (wgltc->device); - cairo_device_destroy (wgltc->device); - - wglDeleteContext(wgltc->rc); - - ReleaseDC(wgltc->wnd, wgltc->dc); - DestroyWindow (wgltc->wnd); - - free (wgltc); -} - -static void -_cairo_boilerplate_wgl_create_window (int width, - int height, - wgl_target_closure_t *wgltc) -{ - WNDCLASSEXA wincl; - PIXELFORMATDESCRIPTOR pfd; - int format; - cairo_surface_t *surface; - - ZeroMemory (&wincl, sizeof (WNDCLASSEXA)); - wincl.cbSize = sizeof (WNDCLASSEXA); - wincl.hInstance = GetModuleHandle (0); - wincl.lpszClassName = "cairo_boilerplate_wgl_dummy"; - wincl.lpfnWndProc = DefWindowProcA; - wincl.style = CS_OWNDC; - - RegisterClassExA (&wincl); - - wgltc->wnd = CreateWindow ("cairo_boilerplate_wgl_dummy", 0, WS_POPUP, 0, 0, width, height, 0, 0, 0, 0); - wgltc->dc = GetDC (wgltc->wnd); - - ZeroMemory (&pfd, sizeof (PIXELFORMATDESCRIPTOR)); - pfd.nSize = sizeof (PIXELFORMATDESCRIPTOR); - pfd.nVersion = 1; - pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; - pfd.iPixelType = PFD_TYPE_RGBA; - pfd.cColorBits = 24; - pfd.cDepthBits = 16; - pfd.iLayerType = PFD_MAIN_PLANE; - - format = ChoosePixelFormat (wgltc->dc, &pfd); - SetPixelFormat (wgltc->dc, format, &pfd); - - wgltc->rc = wglCreateContext (wgltc->dc); - wgltc->device = cairo_wgl_device_create (wgltc->rc); -} - -static cairo_surface_t * -_cairo_boilerplate_wgl_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - wgl_target_closure_t *wgltc; - cairo_surface_t *surface; - - wgltc = calloc (1, sizeof (wgl_target_closure_t)); - - *closure = wgltc; - - _cairo_boilerplate_wgl_create_window(0, 0, wgltc); - - if (width == 0) - width = 1; - if (height == 0) - height = 1; - - wgltc->surface = surface = cairo_gl_surface_create (wgltc->device, - content, - ceil (width), - ceil (height)); - if (cairo_surface_status (surface)) { - _cairo_boilerplate_wgl_cleanup (wgltc); - return NULL; - } - - return surface; -} - -static cairo_surface_t * -_cairo_boilerplate_wgl_for_create_window (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - wgl_target_closure_t *wgltc; - cairo_surface_t *surface; - - wgltc = calloc (1, sizeof (wgl_target_closure_t)); - - *closure = wgltc; - - _cairo_boilerplate_wgl_create_window(width, height, wgltc); - - wgltc->surface = surface = cairo_gl_surface_create_for_dc (wgltc->device, - wgltc->dc, - ceil (width), - ceil (height)); - - if (cairo_surface_status (surface)) { - _cairo_boilerplate_wgl_cleanup (wgltc); - return NULL; - } - - return surface; -} - -static cairo_status_t -_cairo_boilerplate_wgl_finish_window (cairo_surface_t *surface) -{ - wgl_target_closure_t *wgltc = cairo_surface_get_user_data (surface, - &gl_closure_key); - - if (wgltc != NULL && wgltc->surface != NULL) { - cairo_t *cr; - - cr = cairo_create (wgltc->surface); - cairo_surface_set_device_offset (surface, 0, 0); - cairo_set_source_surface (cr, surface, 0, 0); - cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); - cairo_paint (cr); - cairo_destroy (cr); - - surface = wgltc->surface; - } - - cairo_gl_surface_swapbuffers (surface); - return CAIRO_STATUS_SUCCESS; -} - -static void -_cairo_boilerplate_wgl_synchronize (void *closure) -{ - wgl_target_closure_t *wgltc = closure; - - if (cairo_device_acquire (wgltc->device)) - return; - - glFinish (); - - cairo_device_release (wgltc->device); -} - -static const cairo_boilerplate_target_t targets[] = { - { - "gl", "gl", NULL, NULL, - CAIRO_SURFACE_TYPE_GL, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_gl_surface_create", - _cairo_boilerplate_wgl_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_wgl_cleanup, - _cairo_boilerplate_wgl_synchronize, - NULL, - TRUE, FALSE, FALSE - }, - { - "gl-dc", "gl", NULL, NULL, - CAIRO_SURFACE_TYPE_GL, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_gl_surface_create_for_dc", - _cairo_boilerplate_wgl_for_create_window, - NULL, - _cairo_boilerplate_wgl_finish_window, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_wgl_cleanup, - _cairo_boilerplate_wgl_synchronize, - NULL, - FALSE, FALSE, FALSE - }, -}; - -CAIRO_BOILERPLATE (wgl, targets) diff --git a/boilerplate/cairo-boilerplate-win32-printing.c b/boilerplate/cairo-boilerplate-win32-printing.c deleted file mode 100644 index 625d52c..0000000 --- a/boilerplate/cairo-boilerplate-win32-printing.c +++ /dev/null @@ -1,407 +0,0 @@ -/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ -/* - * Copyright © 2004,2006 Red Hat, Inc. - * Copyright © 2007, Adrian Johnson - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Red Hat, Inc. not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Red Hat, Inc. makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Carl D. Worth - * Adrian Johnson - */ - -/* We require Windows 2000 features such as GetDefaultPrinter() */ -#if !defined(WINVER) || (WINVER < 0x0500) -# define WINVER 0x0500 -#endif -#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500) -# define _WIN32_WINNT 0x0500 -#endif - -#include "cairo-boilerplate-private.h" - -#if CAIRO_CAN_TEST_WIN32_PRINTING_SURFACE - -#include -#include - -#include - -#if !defined(POSTSCRIPT_IDENTIFY) -# define POSTSCRIPT_IDENTIFY 0x1015 -#endif - -#if !defined(PSIDENT_GDICENTRIC) -# define PSIDENT_GDICENTRIC 0x0000 -#endif - -#if !defined(GET_PS_FEATURESETTING) -# define GET_PS_FEATURESETTING 0x1019 -#endif - -#if !defined(FEATURESETTING_PSLEVEL) -# define FEATURESETTING_PSLEVEL 0x0002 -#endif - -static cairo_status_t -_cairo_win32_print_gdi_error (const char *context) -{ - void *lpMsgBuf; - DWORD last_error = GetLastError (); - - if (!FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - last_error, - MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPWSTR) &lpMsgBuf, - 0, NULL)) { - fprintf (stderr, "%s: Unknown GDI error", context); - } else { - fprintf (stderr, "%s: %S", context, (wchar_t *)lpMsgBuf); - - LocalFree (lpMsgBuf); - } - - fflush (stderr); - - /* We should switch off of last_status, but we'd either return - * CAIRO_STATUS_NO_MEMORY or CAIRO_STATUS_UNKNOWN_ERROR and there - * is no CAIRO_STATUS_UNKNOWN_ERROR. - */ - return CAIRO_STATUS_NO_MEMORY; -} - -static cairo_user_data_key_t win32_closure_key; - -typedef struct _win32_target_closure { - char *filename; - int width; - int height; - cairo_surface_t *target; - HDC dc; - int left_margin; - int bottom_margin; -} win32_target_closure_t; - -static cairo_bool_t -printer_is_postscript_level_3 (HDC dc) -{ - DWORD word; - INT ps_feature, ps_level; - - word = PSIDENT_GDICENTRIC; - if (ExtEscape (dc, POSTSCRIPT_IDENTIFY, sizeof(DWORD), (char *)&word, 0, (char *)NULL) <= 0) - return FALSE; - - ps_feature = FEATURESETTING_PSLEVEL; - if (ExtEscape (dc, GET_PS_FEATURESETTING, sizeof(INT), - (char *)&ps_feature, sizeof(INT), (char *)&ps_level) <= 0) - return FALSE; - - if (ps_level >= 3) - return TRUE; - - return FALSE; -} - -static void -create_printer_dc (win32_target_closure_t *ptc) -{ - char *printer_name; - DWORD size; - int x_dpi, y_dpi, left_margin, top_margin, page_height, printable_height; - XFORM xform; - - ptc->dc = NULL; - GetDefaultPrinter (NULL, &size); - printer_name = malloc (size); - - if (printer_name == NULL) - return; - - if (GetDefaultPrinter (printer_name, &size) == 0) { - free (printer_name); - return; - } - - /* printf("\nPrinting to : %s\n", printer_name); */ - ptc->dc = CreateDC (NULL, printer_name, NULL, NULL); - free (printer_name); - - if (!printer_is_postscript_level_3 (ptc->dc)) { - printf("The default printer driver must be a color PostScript level 3 printer\n"); - ptc->dc = NULL; - return; - } - - /* The printer device units on win32 are 1 unit == 1 dot and the - * origin is the start of the printable area. We transform the - * cordinate space to 1 unit is 1 point as expected by the - * tests. As the page size is larger than the test surface, the - * origin is translated down so that the each test is drawn at the - * bottom left corner of the page. This is because the bottom left - * corner of the PNG image that ghostscript creates is positioned - * at origin of the PS coordinates (ie the bottom left of the - * page). The left and bottom margins are stored in - * win32_target_closure as size of the PNG image needs to be - * increased because the test output is offset from the bottom - * left by the non printable margins. After the PNG is created the - * margins will be chopped off so the image matches the reference - * image. - */ - printable_height = GetDeviceCaps (ptc->dc, VERTRES); - x_dpi = GetDeviceCaps (ptc->dc, LOGPIXELSX); - y_dpi = GetDeviceCaps (ptc->dc, LOGPIXELSY); - left_margin = GetDeviceCaps (ptc->dc, PHYSICALOFFSETX); - top_margin = GetDeviceCaps (ptc->dc, PHYSICALOFFSETY); - page_height = GetDeviceCaps (ptc->dc, PHYSICALHEIGHT); - - SetGraphicsMode (ptc->dc, GM_ADVANCED); - xform.eM11 = x_dpi/72.0; - xform.eM12 = 0; - xform.eM21 = 0; - xform.eM22 = y_dpi/72.0; - xform.eDx = 0; - xform.eDy = printable_height - ptc->height*y_dpi/72.0; - if (!SetWorldTransform (ptc->dc, &xform)) { - _cairo_win32_print_gdi_error ("cairo-boilerplate-win32-printing:SetWorldTransform"); - return; - } - - ptc->left_margin = 72.0*left_margin/x_dpi; - ptc->bottom_margin = 72.0*(page_height - printable_height - top_margin)/y_dpi; -} - -static cairo_surface_t * -_cairo_boilerplate_win32_printing_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - win32_target_closure_t *ptc; - cairo_surface_t *surface; - DOCINFO di; - - if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED) - content = CAIRO_CONTENT_COLOR_ALPHA; - - *closure = ptc = xmalloc (sizeof (win32_target_closure_t)); - - xasprintf (&ptc->filename, "%s.out.ps", name); - xunlink (ptc->filename); - - memset (&di, 0, sizeof (DOCINFO)); - di.cbSize = sizeof (DOCINFO); - di.lpszDocName = ptc->filename; - di.lpszOutput = ptc->filename; - - ptc->width = width; - ptc->height = height; - - create_printer_dc (ptc); - if (ptc->dc == NULL) { - printf("\nFailed to create printer\n"); - free (ptc->filename); - free (ptc); - return NULL; - } - StartDoc (ptc->dc, &di); - StartPage (ptc->dc); - surface = cairo_win32_printing_surface_create (ptc->dc); - if (cairo_surface_status (surface)) { - free (ptc->filename); - free (ptc); - return NULL; - } - cairo_surface_set_fallback_resolution (surface, 72., 72.); - - if (content == CAIRO_CONTENT_COLOR) { - ptc->target = surface; - surface = cairo_surface_create_similar (ptc->target, - CAIRO_CONTENT_COLOR, - width, height); - } else { - ptc->target = NULL; - } - - if (cairo_surface_set_user_data (surface, - &win32_closure_key, - ptc, - NULL) != CAIRO_STATUS_SUCCESS) { - cairo_surface_destroy (surface); - if (ptc->target != NULL) - cairo_surface_destroy (ptc->target); - free (ptc->filename); - free (ptc); - return NULL; - } - - return surface; -} - -static cairo_status_t -_cairo_boilerplate_win32_printing_surface_write_to_png (cairo_surface_t *surface, - const char *filename) -{ - win32_target_closure_t *ptc = cairo_surface_get_user_data (surface, &win32_closure_key); - char command[4096]; - cairo_surface_t *src_image, *dst_image; - cairo_t *cr; - cairo_status_t status; - - /* Both surface and ptc->target were originally created at the - * same dimensions. We want a 1:1 copy here, so we first clear any - * device offset on surface. - * - * In a more realistic use case of device offsets, the target of - * this copying would be of a different size than the source, and - * the offset would be desirable during the copy operation. */ - cairo_surface_set_device_offset (surface, 0, 0); - - if (ptc->target) { - cairo_t *cr; - cr = cairo_create (ptc->target); - cairo_set_source_surface (cr, surface, 0, 0); - cairo_paint (cr); - cairo_show_page (cr); - cairo_destroy (cr); - - cairo_surface_finish (surface); - surface = ptc->target; - } - - cairo_surface_finish (surface); - EndPage (ptc->dc); - EndDoc (ptc->dc); - sprintf (command, "gs -q -r72 -g%dx%d -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=%s %s", - ptc->width + ptc->left_margin, ptc->height + ptc->bottom_margin, filename, ptc->filename); - - if (system (command) != 0) - return CAIRO_STATUS_WRITE_ERROR; - - /* Create a new image from the ghostscript image that has the - * left and bottom margins removed */ - - src_image = cairo_image_surface_create_from_png (filename); - status = cairo_surface_status (src_image); - if (status) - return status; - - dst_image = cairo_image_surface_create (CAIRO_FORMAT_RGB24, - ptc->width, - ptc->height); - cr = cairo_create (dst_image); - cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); - cairo_set_source_surface (cr, src_image, -ptc->left_margin, 0); - cairo_paint (cr); - cairo_destroy (cr); - - cairo_surface_write_to_png (dst_image, filename); - status = cairo_surface_status (dst_image); - if (status) - return status; - - cairo_surface_destroy (src_image); - cairo_surface_destroy (dst_image); - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_surface_t * -_cairo_boilerplate_win32_printing_get_image_surface (cairo_surface_t *surface, - int page, - int width, - int height) -{ - win32_target_closure_t *ptc = cairo_surface_get_user_data (surface, - &win32_closure_key); - char *filename; - cairo_status_t status; - - /* XXX test paginated interface */ - if (page != 0) - return cairo_boilerplate_surface_create_in_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); - - xasprintf (&filename, "%s.png", ptc->filename); - status = _cairo_boilerplate_win32_printing_surface_write_to_png (surface, filename); - if (status) - return cairo_boilerplate_surface_create_in_error (status); - - surface = cairo_boilerplate_get_image_surface_from_png (filename, - width, - height, - ptc->target == NULL); - - remove (filename); - free (filename); - - return surface; -} - -static void -_cairo_boilerplate_win32_printing_cleanup (void *closure) -{ - win32_target_closure_t *ptc = closure; - - if (ptc->target) - cairo_surface_destroy (ptc->target); - free (ptc->filename); - free (ptc); - DeleteDC (ptc->dc); -} - -static const cairo_boilerplate_target_t targets[] = { - { - "win32-printing", "win32", ".ps", NULL, - CAIRO_SURFACE_TYPE_WIN32_PRINTING, - CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0, - "cairo_win32_printing_surface_create", - _cairo_boilerplate_win32_printing_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_win32_printing_get_image_surface, - _cairo_boilerplate_win32_printing_surface_write_to_png, - _cairo_boilerplate_win32_printing_cleanup, - NULL, NULL, FALSE, TRUE, TRUE - }, - { - "win32-printing", "win32", ".ps", NULL, - CAIRO_SURFACE_TYPE_RECORDING, CAIRO_CONTENT_COLOR, 0, - "cairo_win32_printing_surface_create", - _cairo_boilerplate_win32_printing_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_win32_printing_get_image_surface, - _cairo_boilerplate_win32_printing_surface_write_to_png, - _cairo_boilerplate_win32_printing_cleanup, - NULL, NULL, FALSE, TRUE, TRUE - }, -}; -CAIRO_BOILERPLATE (win32_printing, targets) - -#else - -CAIRO_NO_BOILERPLATE (win32_printing) - -#endif diff --git a/boilerplate/cairo-boilerplate-win32.c b/boilerplate/cairo-boilerplate-win32.c deleted file mode 100644 index 7469cc7..0000000 --- a/boilerplate/cairo-boilerplate-win32.c +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ -/* - * Copyright © 2004,2006 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Red Hat, Inc. not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Red Hat, Inc. makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Carl D. Worth - */ - -#include "cairo-boilerplate-private.h" - -#include - -static cairo_surface_t * -_cairo_boilerplate_win32_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - cairo_format_t format; - - format = cairo_boilerplate_format_from_content (content); - - *closure = NULL; - - return cairo_win32_surface_create_with_dib (format, width, height); -} - -static const cairo_boilerplate_target_t targets[] = { - { - "win32", "win32", NULL, NULL, - CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR, 0, - "cairo_win32_surface_create_with_dib", - _cairo_boilerplate_win32_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, TRUE, FALSE, FALSE - }, - /* Testing the win32 surface isn't interesting, since for - * ARGB images it just chains to the image backend - */ - { - "win32", "win32", NULL, NULL, - CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR_ALPHA, 0, - "cairo_win32_surface_create_with_dib", - _cairo_boilerplate_win32_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, NULL, FALSE, FALSE, FALSE - }, -}; -CAIRO_BOILERPLATE (win32, targets) diff --git a/boilerplate/cairo-boilerplate-xcb.c b/boilerplate/cairo-boilerplate-xcb.c deleted file mode 100644 index cc9b422..0000000 --- a/boilerplate/cairo-boilerplate-xcb.c +++ /dev/null @@ -1,876 +0,0 @@ -/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ -/* - * Copyright © 2004,2006 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Red Hat, Inc. not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Red Hat, Inc. makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Carl D. Worth - */ - -#include "cairo-boilerplate-private.h" - -#include - -#include - -/* Errors have response_type == 0 */ -#define CAIRO_XCB_ERROR 0 - -static const cairo_user_data_key_t xcb_closure_key; - -typedef struct _xcb_target_closure { - xcb_connection_t *c; - cairo_device_t *device; - uint32_t drawable; - cairo_bool_t is_pixmap; - cairo_surface_t *surface; -} xcb_target_closure_t; - -static cairo_status_t -_cairo_boilerplate_xcb_handle_errors (xcb_target_closure_t *xtc) -{ - xcb_generic_event_t *ev = NULL; - - /* Ignore all MappingNotify events; those might happen without us causing them */ - do { - free(ev); - ev = xcb_poll_for_event(xtc->c); - } while (ev != NULL && ev->response_type == XCB_MAPPING_NOTIFY); - - if (ev != NULL) { - if (ev->response_type == CAIRO_XCB_ERROR) { - xcb_generic_error_t *error = (xcb_generic_error_t *) ev; - - fprintf (stderr, - "Detected error during xcb run: error=%d, " - "seqno=0x%02x, major=%d, minor=%d\n", - error->error_code, error->sequence, - error->major_code, error->minor_code); - } else { - fprintf (stderr, - "Detected unexpected event during xcb run: type=%d, seqno=0x%02x\n", - ev->response_type, ev->sequence); - } - free (ev); - - /* Silently discard all following errors */ - while ((ev = xcb_poll_for_event (xtc->c)) != NULL) - free (ev); - - return CAIRO_STATUS_WRITE_ERROR; - } - - return CAIRO_STATUS_SUCCESS; -} - -static void -_cairo_boilerplate_xcb_sync_server (xcb_target_closure_t *xtc) -{ - free (xcb_get_input_focus_reply (xtc->c, - xcb_get_input_focus (xtc->c), NULL)); -} - -static void -_cairo_boilerplate_xcb_setup_test_surface (cairo_surface_t *surface) -{ - - /* For testing purposes, tell the X server to strictly adhere to the - * Render specification. - */ - cairo_xcb_device_debug_set_precision(cairo_surface_get_device(surface), - XCB_RENDER_POLY_MODE_PRECISE); -} - -static void -_cairo_boilerplate_xcb_cleanup (void *closure) -{ - xcb_target_closure_t *xtc = closure; - cairo_status_t status; - - cairo_surface_finish (xtc->surface); - if (xtc->is_pixmap) - xcb_free_pixmap (xtc->c, xtc->drawable); - else - xcb_destroy_window (xtc->c, xtc->drawable); - cairo_surface_destroy (xtc->surface); - - cairo_device_finish (xtc->device); - cairo_device_destroy (xtc->device); - - /* First synchronize with the X server to make sure there are no more errors - * in-flight which we would miss otherwise */ - _cairo_boilerplate_xcb_sync_server (xtc); - status = _cairo_boilerplate_xcb_handle_errors (xtc); - assert (status == CAIRO_STATUS_SUCCESS); - - xcb_disconnect (xtc->c); - - free (xtc); -} - -static void -_cairo_boilerplate_xcb_synchronize (void *closure) -{ - xcb_target_closure_t *xtc = closure; - cairo_status_t status; - free (xcb_get_image_reply (xtc->c, - xcb_get_image (xtc->c, XCB_IMAGE_FORMAT_Z_PIXMAP, - xtc->drawable, 0, 0, 1, 1, /* AllPlanes */ -1), - 0)); - - status = _cairo_boilerplate_xcb_handle_errors (xtc); - assert (status == CAIRO_STATUS_SUCCESS); -} - -static xcb_render_pictforminfo_t * -find_depth (xcb_connection_t *connection, - int depth, - void **formats_out) -{ - xcb_render_query_pict_formats_reply_t *formats; - xcb_render_query_pict_formats_cookie_t cookie; - xcb_render_pictforminfo_iterator_t i; - - cookie = xcb_render_query_pict_formats (connection); - xcb_flush (connection); - - formats = xcb_render_query_pict_formats_reply (connection, cookie, 0); - if (formats == NULL) - return NULL; - - for (i = xcb_render_query_pict_formats_formats_iterator (formats); - i.rem; - xcb_render_pictforminfo_next (&i)) - { - if (XCB_RENDER_PICT_TYPE_DIRECT != i.data->type) - continue; - - if (depth != i.data->depth) - continue; - - *formats_out = formats; - return i.data; - } - - free (formats); - return NULL; -} - -static const cairo_user_data_key_t key; - -struct similar { - xcb_connection_t *connection; - xcb_drawable_t pixmap; -}; - -static void _destroy_similar (void *closure) -{ - struct similar *similar = closure; - - xcb_free_pixmap (similar->connection, similar->pixmap); - free (similar); -} - -struct xcb_info { - xcb_render_query_pict_formats_reply_t *formats; - xcb_render_pictforminfo_t *render_format[3]; -}; - -static cairo_surface_t * -_cairo_boilerplate_xcb_create_similar (cairo_surface_t *other, - cairo_content_t content, - int width, int height) -{ - cairo_device_t *device = cairo_surface_get_device (other); - struct xcb_info *info = cairo_device_get_user_data (device, &key); - xcb_screen_t *root; - cairo_surface_t *surface; - struct similar *similar; - xcb_render_pictforminfo_t *render_format; - int depth; - - similar = malloc (sizeof (*similar)); - - switch (content) { - default: - case CAIRO_CONTENT_COLOR_ALPHA: - depth = 32; - render_format = info->render_format[0]; - break; - case CAIRO_CONTENT_COLOR: - depth = 24; - render_format = info->render_format[1]; - break; - case CAIRO_CONTENT_ALPHA: - depth = 8; - render_format = info->render_format[2]; - break; - } - - similar->connection = - cairo_xcb_device_get_connection (cairo_surface_get_device(other)); - similar->pixmap = xcb_generate_id (similar->connection); - - root = xcb_setup_roots_iterator(xcb_get_setup(similar->connection)).data; - xcb_create_pixmap (similar->connection, depth, - similar->pixmap, root->root, - width, height); - - surface = cairo_xcb_surface_create_with_xrender_format (similar->connection, - root, - similar->pixmap, - render_format, - width, height); - cairo_surface_set_user_data (surface, &key, similar, _destroy_similar); - - return surface; -} - -static cairo_surface_t * -_cairo_boilerplate_xcb_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - xcb_screen_t *root; - xcb_target_closure_t *xtc; - xcb_connection_t *c; - xcb_render_query_pict_formats_cookie_t formats_cookie; - xcb_render_pictforminfo_t *render_format; - xcb_render_pictforminfo_iterator_t i; - struct xcb_info *info; - int depth; - xcb_void_cookie_t cookie; - cairo_surface_t *surface; - cairo_status_t status; - - *closure = xtc = xmalloc (sizeof (xcb_target_closure_t)); - info = xcalloc (1, sizeof (struct xcb_info)); - - if (width == 0) - width = 1; - if (height == 0) - height = 1; - - xtc->c = c = xcb_connect(NULL,NULL); - if (c == NULL || xcb_connection_has_error(c)) { - free (xtc); - return NULL; - } - - root = xcb_setup_roots_iterator(xcb_get_setup(c)).data; - formats_cookie = xcb_render_query_pict_formats (c); - - xtc->surface = NULL; - xtc->is_pixmap = TRUE; - xtc->drawable = xcb_generate_id (c); - switch (content) { - case CAIRO_CONTENT_COLOR: - depth = 24; - break; - - case CAIRO_CONTENT_COLOR_ALPHA: - depth = 32; - break; - - case CAIRO_CONTENT_ALPHA: /* would be XCB_PICT_STANDARD_A_8 */ - default: - xcb_disconnect (c); - free (xtc); - return NULL; - } - - cookie = xcb_create_pixmap_checked (c, depth, - xtc->drawable, root->root, - width, height); - - /* slow, but sure */ - if (xcb_request_check (c, cookie) != NULL) { - xcb_disconnect (c); - free (xtc); - return NULL; - } - - info->formats = xcb_render_query_pict_formats_reply (c, formats_cookie, 0); - if (info->formats == NULL) - return NULL; - - for (i = xcb_render_query_pict_formats_formats_iterator (info->formats); - i.rem; - xcb_render_pictforminfo_next (&i)) - { - if (XCB_RENDER_PICT_TYPE_DIRECT != i.data->type) - continue; - - if (i.data->depth == 32) { - if (info->render_format[0] == 0) - info->render_format[0] = i.data; - } else if (i.data->depth == 24) { - if (info->render_format[1] == 0) - info->render_format[1] = i.data; - } else if (i.data->depth == 8) { - if (info->render_format[2] == 0) - info->render_format[2] = i.data; - } - } - - assert (info->render_format[0]); - assert (info->render_format[1]); - assert (info->render_format[2]); - - switch (content) { - default: - case CAIRO_CONTENT_COLOR_ALPHA: - render_format = info->render_format[0]; - break; - - case CAIRO_CONTENT_COLOR: - render_format = info->render_format[1]; - break; - - case CAIRO_CONTENT_ALPHA: /* would be XCB_PICT_STANDARD_A_8 */ - render_format = info->render_format[2]; - break; - } - - surface = cairo_xcb_surface_create_with_xrender_format (c, root, - xtc->drawable, - render_format, - width, height); - cairo_device_set_user_data (cairo_surface_get_device (surface), &key, info, free); - if (mode != CAIRO_BOILERPLATE_MODE_PERF) - _cairo_boilerplate_xcb_setup_test_surface(surface); - - xtc->device = cairo_device_reference (cairo_surface_get_device (surface)); - status = cairo_surface_set_user_data (surface, &xcb_closure_key, xtc, NULL); - if (status == CAIRO_STATUS_SUCCESS) - return surface; - - cairo_surface_destroy (surface); - - _cairo_boilerplate_xcb_cleanup (xtc); - return cairo_boilerplate_surface_create_in_error (status); -} - -static xcb_visualtype_t * -lookup_visual (xcb_screen_t *s, - xcb_visualid_t visual) -{ - xcb_depth_iterator_t d; - - d = xcb_screen_allowed_depths_iterator (s); - for (; d.rem; xcb_depth_next (&d)) { - xcb_visualtype_iterator_t v = xcb_depth_visuals_iterator (d.data); - for (; v.rem; xcb_visualtype_next (&v)) { - if (v.data->visual_id == visual) - return v.data; - } - } - - return 0; -} - -static cairo_surface_t * -_cairo_boilerplate_xcb_create_window (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - xcb_target_closure_t *xtc; - xcb_connection_t *c; - xcb_screen_t *s; - xcb_void_cookie_t cookie; - cairo_surface_t *surface; - cairo_status_t status; - uint32_t values[] = { 1 }; - - *closure = xtc = xmalloc (sizeof (xcb_target_closure_t)); - - if (width == 0) - width = 1; - if (height == 0) - height = 1; - - xtc->c = c = xcb_connect(NULL,NULL); - if (xcb_connection_has_error(c)) { - free (xtc); - return NULL; - } - - xtc->surface = NULL; - - s = xcb_setup_roots_iterator (xcb_get_setup (c)).data; - if (width > s->width_in_pixels || height > s->height_in_pixels) { - xcb_disconnect (c); - free (xtc); - return NULL; - } - - xtc->is_pixmap = FALSE; - xtc->drawable = xcb_generate_id (c); - cookie = xcb_create_window_checked (c, - s->root_depth, - xtc->drawable, - s->root, - 0, 0, width, height, 0, - XCB_WINDOW_CLASS_INPUT_OUTPUT, - s->root_visual, - XCB_CW_OVERRIDE_REDIRECT, - values); - xcb_map_window (c, xtc->drawable); - - /* slow, but sure */ - if (xcb_request_check (c, cookie) != NULL) { - xcb_disconnect (c); - free (xtc); - return NULL; - } - - surface = cairo_xcb_surface_create (c, - xtc->drawable, - lookup_visual (s, s->root_visual), - width, height); - - xtc->device = cairo_device_reference (cairo_surface_get_device (surface)); - status = cairo_surface_set_user_data (surface, &xcb_closure_key, xtc, NULL); - if (status == CAIRO_STATUS_SUCCESS) - return surface; - - cairo_surface_destroy (surface); - - _cairo_boilerplate_xcb_cleanup (xtc); - return cairo_boilerplate_surface_create_in_error (status); -} - -static cairo_surface_t * -_cairo_boilerplate_xcb_create_window_db (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - xcb_target_closure_t *xtc; - xcb_connection_t *c; - xcb_screen_t *s; - xcb_void_cookie_t cookie; - cairo_surface_t *surface; - cairo_status_t status; - uint32_t values[] = { 1 }; - - *closure = xtc = xmalloc (sizeof (xcb_target_closure_t)); - - if (width == 0) - width = 1; - if (height == 0) - height = 1; - - xtc->c = c = xcb_connect(NULL,NULL); - if (xcb_connection_has_error(c)) { - free (xtc); - return NULL; - } - - xtc->surface = NULL; - - s = xcb_setup_roots_iterator (xcb_get_setup (c)).data; - if (width > s->width_in_pixels || height > s->height_in_pixels) { - xcb_disconnect (c); - free (xtc); - return NULL; - } - - xtc->is_pixmap = FALSE; - xtc->drawable = xcb_generate_id (c); - cookie = xcb_create_window_checked (c, - s->root_depth, - xtc->drawable, - s->root, - 0, 0, width, height, 0, - XCB_WINDOW_CLASS_INPUT_OUTPUT, - s->root_visual, - XCB_CW_OVERRIDE_REDIRECT, - values); - xcb_map_window (c, xtc->drawable); - - /* slow, but sure */ - if (xcb_request_check (c, cookie) != NULL) { - xcb_disconnect (c); - free (xtc); - return NULL; - } - - xtc->surface = cairo_xcb_surface_create (c, - xtc->drawable, - lookup_visual (s, s->root_visual), - width, height); - surface = cairo_surface_create_similar (xtc->surface, content, width, height); - - xtc->device = cairo_device_reference (cairo_surface_get_device (surface)); - status = cairo_surface_set_user_data (surface, &xcb_closure_key, xtc, NULL); - if (status == CAIRO_STATUS_SUCCESS) - return surface; - - cairo_surface_destroy (surface); - - _cairo_boilerplate_xcb_cleanup (xtc); - return cairo_boilerplate_surface_create_in_error (status); -} - -static cairo_surface_t * -_cairo_boilerplate_xcb_create_render_0_0 (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - xcb_screen_t *root; - xcb_target_closure_t *xtc; - xcb_connection_t *c; - xcb_render_pictforminfo_t *render_format; - int depth; - xcb_void_cookie_t cookie; - cairo_surface_t *surface; - cairo_status_t status; - void *formats; - - *closure = xtc = xmalloc (sizeof (xcb_target_closure_t)); - - if (width == 0) - width = 1; - if (height == 0) - height = 1; - - xtc->c = c = xcb_connect(NULL,NULL); - if (xcb_connection_has_error(c)) { - free (xtc); - return NULL; - } - - root = xcb_setup_roots_iterator(xcb_get_setup(c)).data; - - xtc->surface = NULL; - xtc->is_pixmap = TRUE; - xtc->drawable = xcb_generate_id (c); - switch (content) { - case CAIRO_CONTENT_COLOR: - depth = 24; - cookie = xcb_create_pixmap_checked (c, depth, - xtc->drawable, root->root, - width, height); - break; - - case CAIRO_CONTENT_COLOR_ALPHA: - depth = 32; - cookie = xcb_create_pixmap_checked (c, depth, - xtc->drawable, root->root, - width, height); - break; - - case CAIRO_CONTENT_ALPHA: /* would be XCB_PICT_STANDARD_A_8 */ - default: - xcb_disconnect (c); - free (xtc); - return NULL; - } - - /* slow, but sure */ - if (xcb_request_check (c, cookie) != NULL) { - xcb_disconnect (c); - free (xtc); - return NULL; - } - xcb_flush (c); - - render_format = find_depth (c, depth, &formats); - if (render_format == NULL) { - xcb_disconnect (c); - free (xtc); - return NULL; - } - - surface = cairo_xcb_surface_create_with_xrender_format (c, root, - xtc->drawable, - render_format, - width, height); - if (cairo_surface_status (surface)) { - free (formats); - xcb_disconnect (c); - free (xtc); - return surface; - } - - xtc->device = cairo_device_reference (cairo_surface_get_device (surface)); - cairo_xcb_device_debug_cap_xrender_version (xtc->device, 0, 0); - - assert (cairo_surface_get_device (surface) == xtc->device); - - status = cairo_surface_set_user_data (surface, &xcb_closure_key, xtc, NULL); - if (status == CAIRO_STATUS_SUCCESS) - return surface; - - cairo_surface_destroy (surface); - - _cairo_boilerplate_xcb_cleanup (xtc); - return cairo_boilerplate_surface_create_in_error (status); -} - -static cairo_surface_t * -_cairo_boilerplate_xcb_create_fallback (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - xcb_target_closure_t *xtc; - xcb_connection_t *c; - xcb_screen_t *s; - xcb_void_cookie_t cookie; - cairo_surface_t *surface; - cairo_status_t status; - uint32_t values[] = { 1 }; - - *closure = xtc = xmalloc (sizeof (xcb_target_closure_t)); - - if (width == 0) - width = 1; - if (height == 0) - height = 1; - - xtc->c = c = xcb_connect (NULL,NULL); - if (xcb_connection_has_error(c)) { - free (xtc); - return NULL; - } - - s = xcb_setup_roots_iterator (xcb_get_setup (c)).data; - if (width > s->width_in_pixels || height > s->height_in_pixels) { - xcb_disconnect (c); - free (xtc); - return NULL; - } - - xtc->surface = NULL; - xtc->is_pixmap = FALSE; - xtc->drawable = xcb_generate_id (c); - cookie = xcb_create_window_checked (c, - s->root_depth, - xtc->drawable, - s->root, - 0, 0, width, height, 0, - XCB_WINDOW_CLASS_INPUT_OUTPUT, - s->root_visual, - XCB_CW_OVERRIDE_REDIRECT, - values); - xcb_map_window (c, xtc->drawable); - - /* slow, but sure */ - if (xcb_request_check (c, cookie) != NULL) { - xcb_disconnect (c); - free (xtc); - return NULL; - } - - surface = cairo_xcb_surface_create (c, - xtc->drawable, - lookup_visual (s, s->root_visual), - width, height); - if (cairo_surface_status (surface)) { - xcb_disconnect (c); - free (xtc); - return surface; - } - - cairo_xcb_device_debug_cap_xrender_version (cairo_surface_get_device (surface), - -1, -1); - - xtc->device = cairo_device_reference (cairo_surface_get_device (surface)); - status = cairo_surface_set_user_data (surface, &xcb_closure_key, xtc, NULL); - if (status == CAIRO_STATUS_SUCCESS) - return surface; - - cairo_surface_destroy (surface); - - _cairo_boilerplate_xcb_cleanup (xtc); - return cairo_boilerplate_surface_create_in_error (status); -} - -static cairo_status_t -_cairo_boilerplate_xcb_finish_surface (cairo_surface_t *surface) -{ - xcb_target_closure_t *xtc = cairo_surface_get_user_data (surface, - &xcb_closure_key); - cairo_status_t status; - - if (xtc->surface != NULL) { - cairo_t *cr; - - cr = cairo_create (xtc->surface); - cairo_set_source_surface (cr, surface, 0, 0); - cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); - cairo_paint (cr); - cairo_destroy (cr); - - surface = xtc->surface; - } - - cairo_surface_flush (surface); - if (cairo_surface_status (surface)) - return cairo_surface_status (surface); - - /* First synchronize with the X server to make sure there are no more errors - * in-flight which we would miss otherwise */ - _cairo_boilerplate_xcb_sync_server (xtc); - status = _cairo_boilerplate_xcb_handle_errors (xtc); - if (status) - return status; - - if (xcb_connection_has_error (xtc->c)) - return CAIRO_STATUS_WRITE_ERROR; - - return CAIRO_STATUS_SUCCESS; -} - -static const cairo_boilerplate_target_t targets[] = { - /* Acceleration architectures may make the results differ by a - * bit, so we set the error tolerance to 1. */ - { - "xcb", "traps", NULL, NULL, - CAIRO_SURFACE_TYPE_XCB, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_xcb_surface_create_with_xrender_format", - _cairo_boilerplate_xcb_create_surface, - _cairo_boilerplate_xcb_create_similar, - NULL, - _cairo_boilerplate_xcb_finish_surface, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_xcb_cleanup, - _cairo_boilerplate_xcb_synchronize, - NULL, - TRUE, FALSE, FALSE - }, - { - "xcb", "traps", NULL, NULL, - CAIRO_SURFACE_TYPE_XCB, CAIRO_CONTENT_COLOR, 1, - "cairo_xcb_surface_create_with_xrender_format", - _cairo_boilerplate_xcb_create_surface, - _cairo_boilerplate_xcb_create_similar, - NULL, - _cairo_boilerplate_xcb_finish_surface, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_xcb_cleanup, - _cairo_boilerplate_xcb_synchronize, - NULL, - FALSE, FALSE, FALSE - }, - { - "xcb-window", "traps", NULL, NULL, - CAIRO_SURFACE_TYPE_XCB, CAIRO_CONTENT_COLOR, 1, - "cairo_xcb_surface_create_with_xrender_format", - _cairo_boilerplate_xcb_create_window, - _cairo_boilerplate_xcb_create_similar, - NULL, - _cairo_boilerplate_xcb_finish_surface, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_xcb_cleanup, - _cairo_boilerplate_xcb_synchronize, - NULL, - FALSE, FALSE, FALSE - }, - { - "xcb-window&", "traps", NULL, NULL, - CAIRO_SURFACE_TYPE_XCB, CAIRO_CONTENT_COLOR, 1, - "cairo_xcb_surface_create_with_xrender_format", - _cairo_boilerplate_xcb_create_window_db, - _cairo_boilerplate_xcb_create_similar, - NULL, - _cairo_boilerplate_xcb_finish_surface, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_xcb_cleanup, - _cairo_boilerplate_xcb_synchronize, - NULL, - FALSE, FALSE, FALSE - }, - { - "xcb-render-0_0", "xlib-fallback", NULL, NULL, - CAIRO_SURFACE_TYPE_XCB, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_xcb_surface_create_with_xrender_format", - _cairo_boilerplate_xcb_create_render_0_0, - cairo_surface_create_similar, - NULL, - _cairo_boilerplate_xcb_finish_surface, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_xcb_cleanup, - _cairo_boilerplate_xcb_synchronize, - NULL, - FALSE, FALSE, FALSE - }, - { - "xcb-render-0_0", "xlib-fallback", NULL, NULL, - CAIRO_SURFACE_TYPE_XCB, CAIRO_CONTENT_COLOR, 1, - "cairo_xcb_surface_create_with_xrender_format", - _cairo_boilerplate_xcb_create_render_0_0, - cairo_surface_create_similar, - NULL, - _cairo_boilerplate_xcb_finish_surface, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_xcb_cleanup, - _cairo_boilerplate_xcb_synchronize, - NULL, - FALSE, FALSE, FALSE - }, - { - "xcb-fallback", "xlib-fallback", NULL, NULL, - CAIRO_SURFACE_TYPE_XCB, CAIRO_CONTENT_COLOR, 1, - "cairo_xcb_surface_create_with_xrender_format", - _cairo_boilerplate_xcb_create_fallback, - cairo_surface_create_similar, - NULL, - _cairo_boilerplate_xcb_finish_surface, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_xcb_cleanup, - _cairo_boilerplate_xcb_synchronize, - NULL, - FALSE, FALSE, FALSE - }, -}; -CAIRO_BOILERPLATE (xcb, targets) diff --git a/boilerplate/cairo-boilerplate-xlib.c b/boilerplate/cairo-boilerplate-xlib.c deleted file mode 100644 index f3d5598..0000000 --- a/boilerplate/cairo-boilerplate-xlib.c +++ /dev/null @@ -1,638 +0,0 @@ -/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ -/* - * Copyright © 2004,2006 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Red Hat, Inc. not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Red Hat, Inc. makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Carl D. Worth - */ - -#include "cairo-boilerplate-private.h" -#include "cairo-boilerplate-xlib.h" - -#include -#if CAIRO_HAS_XLIB_XRENDER_SURFACE -#include -#endif - -#include /* for XDestroyImage */ - -#if !CAIRO_HAS_XLIB_XRENDER_SURFACE -#define PolyModePrecise 0 -#endif - -static const cairo_user_data_key_t key; - -typedef struct _xlib_target_closure { - Display *dpy; - Drawable drawable; - cairo_bool_t drawable_is_pixmap; -} xlib_target_closure_t; - -static void -_cairo_boilerplate_xlib_cleanup (void *closure) -{ - xlib_target_closure_t *xtc = closure; - - if (xtc->drawable) { - if (xtc->drawable_is_pixmap) - XFreePixmap (xtc->dpy, xtc->drawable); - else - XDestroyWindow (xtc->dpy, xtc->drawable); - } - XCloseDisplay (xtc->dpy); - free (xtc); -} - -static void -_cairo_boilerplate_xlib_synchronize (void *closure) -{ - xlib_target_closure_t *xtc = closure; - XImage *ximage; - - ximage = XGetImage (xtc->dpy, xtc->drawable, - 0, 0, 1, 1, AllPlanes, ZPixmap); - if (ximage != NULL) - XDestroyImage (ximage); -} - -static cairo_bool_t -_cairo_boilerplate_xlib_check_screen_size (Display *dpy, - int screen, - int width, - int height) -{ - Screen *scr = XScreenOfDisplay (dpy, screen); - return width <= WidthOfScreen (scr) && height <= HeightOfScreen (scr); -} - -static void -_cairo_boilerplate_xlib_setup_test_surface (cairo_surface_t *surface) -{ - - /* For testing purposes, tell the X server to strictly adhere to the - * Render specification. - */ - cairo_xlib_device_debug_set_precision(cairo_surface_get_device(surface), - PolyModePrecise); -} - - -#if CAIRO_HAS_XLIB_XRENDER_SURFACE -/* For the xlib backend we distinguish between TEST and PERF mode in a - * couple of ways. - * - * For TEST, we always test against pixmaps of depth 32 (for - * COLOR_ALPHA) or 24 (for COLOR) and we use XSynchronize to make it - * easier to debug problems. - * - * For PERF, we test against 32-bit pixmaps for COLOR_ALPHA, but for - * COLOR we test against _windows_ at the depth of the default visual. - * For obvious reasons, we don't use XSynchronize. - */ -static cairo_surface_t * -_cairo_boilerplate_xlib_test_create_surface (Display *dpy, - cairo_content_t content, - int width, - int height, - xlib_target_closure_t *xtc) -{ - XRenderPictFormat *xrender_format; - cairo_surface_t *surface; - - /* This kills performance, but it makes debugging much - * easier. That's why we have it here when in TEST mode, but not - * over in PERF mode. */ - XSynchronize (xtc->dpy, 1); - - /* XXX: Currently we don't do any xlib testing when the X server - * doesn't have the Render extension. We could do better here, - * (perhaps by converting the tests from ARGB32 to RGB24). One - * step better would be to always test the non-Render fallbacks - * for each test even if the server does have the Render - * extension. That would probably be through another - * cairo_boilerplate_target which would use an extended version of - * cairo_test_xlib_disable_render. */ - switch (content) { - case CAIRO_CONTENT_COLOR_ALPHA: - xrender_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); - break; - case CAIRO_CONTENT_COLOR: - xrender_format = XRenderFindStandardFormat (dpy, PictStandardRGB24); - break; - case CAIRO_CONTENT_ALPHA: - default: - CAIRO_BOILERPLATE_DEBUG (("Invalid content for xlib test: %d\n", content)); - return NULL; - } - if (xrender_format == NULL) { - CAIRO_BOILERPLATE_DEBUG (("X server does not have the Render extension.\n")); - return NULL; - } - - xtc->drawable = XCreatePixmap (dpy, DefaultRootWindow (dpy), - width, height, xrender_format->depth); - xtc->drawable_is_pixmap = TRUE; - - surface = cairo_xlib_surface_create_with_xrender_format (dpy, xtc->drawable, - DefaultScreenOfDisplay (dpy), - xrender_format, - width, height); - - _cairo_boilerplate_xlib_setup_test_surface(surface); - - return surface; -} - -static cairo_surface_t * -_cairo_boilerplate_xlib_perf_create_surface (Display *dpy, - cairo_content_t content, - int width, - int height, - xlib_target_closure_t *xtc) -{ - XSetWindowAttributes attr; - XRenderPictFormat *xrender_format; - Visual *visual; - - switch (content) { - case CAIRO_CONTENT_COLOR_ALPHA: - xrender_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); - if (xrender_format == NULL) { - CAIRO_BOILERPLATE_DEBUG (("X server does not have the Render extension.\n")); - return NULL; - } - - xtc->drawable = XCreatePixmap (dpy, DefaultRootWindow (dpy), - width, height, xrender_format->depth); - xtc->drawable_is_pixmap = TRUE; - break; - - case CAIRO_CONTENT_COLOR: - if (! _cairo_boilerplate_xlib_check_screen_size (dpy, - DefaultScreen (dpy), - width, height)) { - CAIRO_BOILERPLATE_DEBUG (("Surface is larger than the Screen.\n")); - return NULL; - } - - visual = DefaultVisual (dpy, DefaultScreen (dpy)); - xrender_format = XRenderFindVisualFormat (dpy, visual); - if (xrender_format == NULL) { - CAIRO_BOILERPLATE_DEBUG (("X server does not have the Render extension.\n")); - return NULL; - } - - attr.override_redirect = True; - xtc->drawable = XCreateWindow (dpy, DefaultRootWindow (dpy), 0, 0, - width, height, 0, xrender_format->depth, - InputOutput, visual, CWOverrideRedirect, &attr); - XMapWindow (dpy, xtc->drawable); - xtc->drawable_is_pixmap = FALSE; - break; - - case CAIRO_CONTENT_ALPHA: - default: - CAIRO_BOILERPLATE_DEBUG (("Invalid content for xlib test: %d\n", content)); - return NULL; - } - - return cairo_xlib_surface_create_with_xrender_format (dpy, xtc->drawable, - DefaultScreenOfDisplay (dpy), - xrender_format, - width, height); -} - -struct similar { - Display *dpy; - Pixmap pixmap; -}; - -static void _destroy_similar (void *closure) -{ - struct similar *similar = closure; - - XFreePixmap (similar->dpy, similar->pixmap); - free (similar); -} - -static cairo_surface_t * -_cairo_boilerplate_xlib_create_similar (cairo_surface_t *other, - cairo_content_t content, - int width, - int height) -{ - XRenderPictFormat *xrender_format; - uint32_t format; - struct similar *similar; - cairo_surface_t *surface; - - similar = malloc (sizeof (*similar)); - similar->dpy = cairo_xlib_surface_get_display (other); - - switch (content) { - case CAIRO_CONTENT_COLOR: - format = PictStandardRGB24; - break; - case CAIRO_CONTENT_ALPHA: - format = PictStandardA8; - break; - case CAIRO_CONTENT_COLOR_ALPHA: - default: - format = PictStandardARGB32; - break; - } - - xrender_format = XRenderFindStandardFormat (similar->dpy, format); - similar->pixmap = XCreatePixmap (similar->dpy, - DefaultRootWindow (similar->dpy), - width, height, - xrender_format->depth); - - surface = - cairo_xlib_surface_create_with_xrender_format (similar->dpy, - similar->pixmap, - DefaultScreenOfDisplay (similar->dpy), - xrender_format, - width, height); - - cairo_surface_set_user_data (surface, &key, similar, _destroy_similar); - - return surface; -} - -static cairo_surface_t * -_cairo_boilerplate_xlib_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - xlib_target_closure_t *xtc; - Display *dpy; - cairo_surface_t *surface; - - *closure = xtc = xcalloc (1, sizeof (xlib_target_closure_t)); - - width = ceil (width); - if (width < 1) - width = 1; - - height = ceil (height); - if (height < 1) - height = 1; - - xtc->dpy = dpy = XOpenDisplay (NULL); - if (xtc->dpy == NULL) { - free (xtc); - CAIRO_BOILERPLATE_DEBUG (("Failed to open display: %s\n", XDisplayName(0))); - return NULL; - } - - if (mode == CAIRO_BOILERPLATE_MODE_TEST) - surface = _cairo_boilerplate_xlib_test_create_surface (dpy, content, width, height, xtc); - else /* mode == CAIRO_BOILERPLATE_MODE_PERF */ - surface = _cairo_boilerplate_xlib_perf_create_surface (dpy, content, width, height, xtc); - - if (surface == NULL || cairo_surface_status (surface)) - _cairo_boilerplate_xlib_cleanup (xtc); - - return surface; -} - -static cairo_surface_t * -_cairo_boilerplate_xlib_render_0_0_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - xlib_target_closure_t *xtc; - Display *dpy; - int screen; - Pixmap pixmap; - cairo_surface_t *surface, *dummy; - - *closure = xtc = xcalloc (1, sizeof (xlib_target_closure_t)); - - width = ceil (width); - if (width < 1) - width = 1; - - height = ceil (height); - if (height < 1) - height = 1; - - xtc->dpy = dpy = XOpenDisplay (NULL); - if (xtc->dpy == NULL) { - free (xtc); - CAIRO_BOILERPLATE_DEBUG (("Failed to open display: %s\n", XDisplayName(0))); - return NULL; - } - - - screen = DefaultScreen (dpy); - pixmap = XCreatePixmap (dpy, DefaultRootWindow (dpy), 1, 1, - DefaultDepth (dpy, screen)); - dummy = cairo_xlib_surface_create (dpy, pixmap, - DefaultVisual (dpy, screen), - 1, 1); - cairo_xlib_device_debug_cap_xrender_version (cairo_surface_get_device (dummy), - 0, 0); - - if (mode == CAIRO_BOILERPLATE_MODE_TEST) - surface = _cairo_boilerplate_xlib_test_create_surface (dpy, content, width, height, xtc); - else /* mode == CAIRO_BOILERPLATE_MODE_PERF */ - surface = _cairo_boilerplate_xlib_perf_create_surface (dpy, content, width, height, xtc); - - cairo_surface_destroy (dummy); - XFreePixmap (dpy, pixmap); - - if (surface == NULL || cairo_surface_status (surface)) - _cairo_boilerplate_xlib_cleanup (xtc); - - return surface; -} - -static cairo_surface_t * -_cairo_boilerplate_xlib_window_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - xlib_target_closure_t *xtc; - Display *dpy; - int screen; - XSetWindowAttributes attr; - cairo_surface_t *surface; - - /* We're not yet bothering to support perf mode for the - * xlib-fallback surface. */ - if (mode == CAIRO_BOILERPLATE_MODE_PERF) - return NULL; - - /* We also don't support drawing with destination-alpha in the - * xlib-fallback surface. */ - if (content == CAIRO_CONTENT_COLOR_ALPHA) - return NULL; - - *closure = xtc = xmalloc (sizeof (xlib_target_closure_t)); - - width = ceil (width); - if (width < 1) - width = 1; - - height = ceil (height); - if (height < 1) - height = 1; - - xtc->dpy = dpy = XOpenDisplay (NULL); - if (xtc->dpy == NULL) { - CAIRO_BOILERPLATE_DEBUG (("Failed to open display: %s\n", XDisplayName(0))); - free (xtc); - return NULL; - } - - /* This kills performance, but it makes debugging much - * easier. That's why we have it here only after explicitly not - * supporting PERF mode.*/ - XSynchronize (dpy, 1); - - screen = DefaultScreen (dpy); - if (! _cairo_boilerplate_xlib_check_screen_size (dpy, screen, - width, height)) { - CAIRO_BOILERPLATE_DEBUG (("Surface is larger than the Screen.\n")); - XCloseDisplay (dpy); - free (xtc); - return NULL; - } - - attr.override_redirect = True; - xtc->drawable = XCreateWindow (dpy, DefaultRootWindow (dpy), - 0, 0, - width, height, 0, - DefaultDepth (dpy, screen), - InputOutput, - DefaultVisual (dpy, screen), - CWOverrideRedirect, &attr); - XMapWindow (dpy, xtc->drawable); - xtc->drawable_is_pixmap = FALSE; - - surface = cairo_xlib_surface_create (dpy, xtc->drawable, - DefaultVisual (dpy, screen), - width, height); - if (cairo_surface_status (surface)) - _cairo_boilerplate_xlib_cleanup (xtc); - - _cairo_boilerplate_xlib_setup_test_surface(surface); - - return surface; -} -#endif - - -#if CAIRO_HAS_XLIB_SURFACE -/* The xlib-fallback target differs from the xlib target in two ways: - * - * 1. It creates its surfaces without relying on the Render extension - * - * 2. It disables use of the Render extension for its surfaces - * - * This provides testing of the non-Render fallback paths we have in - * cairo-xlib-surface.c - */ -static cairo_surface_t * -_cairo_boilerplate_xlib_fallback_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - xlib_target_closure_t *xtc; - Display *dpy; - int screen; - XSetWindowAttributes attr; - cairo_surface_t *surface, *dummy; - - /* We're not yet bothering to support perf mode for the - * xlib-fallback surface. */ - if (mode == CAIRO_BOILERPLATE_MODE_PERF) - return NULL; - - /* We also don't support drawing with destination-alpha in the - * xlib-fallback surface. */ - if (content == CAIRO_CONTENT_COLOR_ALPHA) - return NULL; - - *closure = xtc = xmalloc (sizeof (xlib_target_closure_t)); - - width = ceil (width); - if (width < 1) - width = 1; - - height = ceil (height); - if (height < 1) - height = 1; - - xtc->dpy = dpy = XOpenDisplay (NULL); - if (xtc->dpy == NULL) { - CAIRO_BOILERPLATE_DEBUG (("Failed to open display: %s\n", XDisplayName(0))); - free (xtc); - return NULL; - } - - /* This kills performance, but it makes debugging much - * easier. That's why we have it here only after explicitly not - * supporting PERF mode.*/ - XSynchronize (dpy, 1); - - screen = DefaultScreen (dpy); - if (! _cairo_boilerplate_xlib_check_screen_size (dpy, screen, - width, height)) { - CAIRO_BOILERPLATE_DEBUG (("Surface is larger than the Screen.\n")); - XCloseDisplay (dpy); - free (xtc); - return NULL; - } - - attr.override_redirect = True; - xtc->drawable = XCreateWindow (dpy, DefaultRootWindow (dpy), - 0, 0, - width, height, 0, - DefaultDepth (dpy, screen), - InputOutput, - DefaultVisual (dpy, screen), - CWOverrideRedirect, &attr); - XMapWindow (dpy, xtc->drawable); - xtc->drawable_is_pixmap = FALSE; - - dummy = cairo_xlib_surface_create (dpy, xtc->drawable, - DefaultVisual (dpy, screen), - width, height); - cairo_xlib_device_debug_cap_xrender_version (cairo_surface_get_device (dummy), - -1, -1); - - surface = cairo_xlib_surface_create (dpy, xtc->drawable, - DefaultVisual (dpy, screen), - width, height); - cairo_surface_destroy (dummy); - if (cairo_surface_status (surface)) - _cairo_boilerplate_xlib_cleanup (xtc); - - _cairo_boilerplate_xlib_setup_test_surface(surface); - - return surface; -} -#endif - -static const cairo_boilerplate_target_t targets[] = { -#if CAIRO_HAS_XLIB_XRENDER_SURFACE - /* Acceleration architectures may make the results differ by a - * bit, so we set the error tolerance to 1. */ - { - "xlib", "traps", NULL, "xlib-fallback", - CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR_ALPHA, 1, - "cairo_xlib_surface_create_with_xrender_format", - _cairo_boilerplate_xlib_create_surface, - _cairo_boilerplate_xlib_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_xlib_cleanup, - _cairo_boilerplate_xlib_synchronize, - NULL, - TRUE, FALSE, FALSE - }, - { - "xlib", "traps", NULL, "xlib-fallback", - CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR, 1, - "cairo_xlib_surface_create_with_xrender_format", - _cairo_boilerplate_xlib_create_surface, - _cairo_boilerplate_xlib_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_xlib_cleanup, - _cairo_boilerplate_xlib_synchronize, - NULL, - FALSE, FALSE, FALSE - }, - { - "xlib-window", "traps", NULL, NULL, - CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR, 1, - "cairo_xlib_surface_create", - _cairo_boilerplate_xlib_window_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_xlib_cleanup, - _cairo_boilerplate_xlib_synchronize, - NULL, - FALSE, FALSE, FALSE - }, - { - "xlib-render-0_0", "mask", NULL, NULL, - CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR, 1, - "cairo_xlib_surface_create", - _cairo_boilerplate_xlib_render_0_0_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_xlib_cleanup, - _cairo_boilerplate_xlib_synchronize, - NULL, - FALSE, FALSE, FALSE - }, -#endif -#if CAIRO_HAS_XLIB_SURFACE - /* This is a fallback surface which uses xlib fallbacks instead of - * the Render extension. */ - { - "xlib-fallback", "image", NULL, NULL, - CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR, 1, - "cairo_xlib_surface_create", - _cairo_boilerplate_xlib_fallback_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_xlib_cleanup, - _cairo_boilerplate_xlib_synchronize, - NULL, - FALSE, FALSE, FALSE - }, -#endif -}; -CAIRO_BOILERPLATE (xlib, targets) diff --git a/boilerplate/cairo-boilerplate-xlib.h b/boilerplate/cairo-boilerplate-xlib.h deleted file mode 100644 index 9a63918..0000000 --- a/boilerplate/cairo-boilerplate-xlib.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ -/* - * Copyright © 2007 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Red Hat, Inc. not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Red Hat, Inc. makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Behdad Esfahbod - */ - -#ifndef _CAIRO_BOILERPLATE_XLIB_H_ -#define _CAIRO_BOILERPLATE_XLIB_H_ - -cairo_status_t -cairo_boilerplate_xlib_surface_disable_render (cairo_surface_t *surface); - -#endif diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c deleted file mode 100644 index 7fdbf79..0000000 --- a/boilerplate/cairo-boilerplate.c +++ /dev/null @@ -1,1101 +0,0 @@ -/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ -/* - * Copyright © 2004,2006 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Red Hat, Inc. not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Red Hat, Inc. makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Carl D. Worth - */ - -#define CAIRO_VERSION_H 1 - -#include "cairo-boilerplate-private.h" -#include "cairo-boilerplate-scaled-font.h" - -#include - -#include -#include - -#if CAIRO_HAS_SCRIPT_SURFACE -#include -#endif - -/* get the "real" version info instead of dummy cairo-version.h */ -#undef CAIRO_VERSION_H -#include "../cairo-version.h" - -#include -#include -#include -#include - -#if HAVE_DLFCN_H -#include -#endif - -#if HAVE_UNISTD_H && HAVE_FCNTL_H && HAVE_SIGNAL_H && HAVE_SYS_STAT_H && HAVE_SYS_SOCKET_H && HAVE_SYS_UN_H -#include -#include -#include -#include -#include -#include - -#define HAS_DAEMON 1 -#define SOCKET_PATH "./.any2ppm" -#endif - -cairo_content_t -cairo_boilerplate_content (cairo_content_t content) -{ - if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED) - content = CAIRO_CONTENT_COLOR_ALPHA; - - return content; -} - -const char * -cairo_boilerplate_content_name (cairo_content_t content) -{ - /* For the purpose of the content name, we don't distinguish the - * flattened content value. - */ - switch (cairo_boilerplate_content (content)) { - case CAIRO_CONTENT_COLOR: - return "rgb24"; - case CAIRO_CONTENT_COLOR_ALPHA: - return "argb32"; - case CAIRO_CONTENT_ALPHA: - default: - assert (0); /* not reached */ - return "---"; - } -} - -static const char * -_cairo_boilerplate_content_visible_name (cairo_content_t content) -{ - switch (cairo_boilerplate_content (content)) { - case CAIRO_CONTENT_COLOR: - return "rgb"; - case CAIRO_CONTENT_COLOR_ALPHA: - return "rgba"; - case CAIRO_CONTENT_ALPHA: - return "a"; - default: - assert (0); /* not reached */ - return "---"; - } -} - -cairo_format_t -cairo_boilerplate_format_from_content (cairo_content_t content) -{ - cairo_format_t format; - - switch (content) { - case CAIRO_CONTENT_COLOR: - format = CAIRO_FORMAT_RGB24; - break; - case CAIRO_CONTENT_COLOR_ALPHA: - format = CAIRO_FORMAT_ARGB32; - break; - case CAIRO_CONTENT_ALPHA: - format = CAIRO_FORMAT_A8; - break; - default: - assert (0); /* not reached */ - format = CAIRO_FORMAT_INVALID; - break; - } - - return format; -} - -static cairo_surface_t * -_cairo_boilerplate_image_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - cairo_format_t format; - - *closure = NULL; - - if (content == CAIRO_CONTENT_COLOR_ALPHA) { - format = CAIRO_FORMAT_ARGB32; - } else if (content == CAIRO_CONTENT_COLOR) { - format = CAIRO_FORMAT_RGB24; - } else { - assert (0); /* not reached */ - return NULL; - } - - return cairo_image_surface_create (format, ceil (width), ceil (height)); -} - -static const cairo_user_data_key_t key; - -static cairo_surface_t * -_cairo_boilerplate_image_create_similar (cairo_surface_t *other, - cairo_content_t content, - int width, int height) -{ - cairo_format_t format; - cairo_surface_t *surface; - int stride; - void *ptr; - - switch (content) { - case CAIRO_CONTENT_ALPHA: - format = CAIRO_FORMAT_A8; - break; - case CAIRO_CONTENT_COLOR: - format = CAIRO_FORMAT_RGB24; - break; - case CAIRO_CONTENT_COLOR_ALPHA: - default: - format = CAIRO_FORMAT_ARGB32; - break; - } - - stride = cairo_format_stride_for_width(format, width); - ptr = malloc (stride* height); - - surface = cairo_image_surface_create_for_data (ptr, format, - width, height, stride); - cairo_surface_set_user_data (surface, &key, ptr, free); - - return surface; -} - -static cairo_surface_t * -_cairo_boilerplate_image16_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - *closure = NULL; - - /* XXX force CAIRO_CONTENT_COLOR */ - return cairo_image_surface_create (CAIRO_FORMAT_RGB16_565, ceil (width), ceil (height)); -} - -static cairo_surface_t * -_cairo_boilerplate_image16_create_similar (cairo_surface_t *other, - cairo_content_t content, - int width, int height) -{ - cairo_format_t format; - cairo_surface_t *surface; - int stride; - void *ptr; - - switch (content) { - case CAIRO_CONTENT_ALPHA: - format = CAIRO_FORMAT_A8; - break; - case CAIRO_CONTENT_COLOR: - format = CAIRO_FORMAT_RGB16_565; - break; - case CAIRO_CONTENT_COLOR_ALPHA: - default: - format = CAIRO_FORMAT_ARGB32; - break; - } - - stride = cairo_format_stride_for_width(format, width); - ptr = malloc (stride* height); - - surface = cairo_image_surface_create_for_data (ptr, format, - width, height, stride); - cairo_surface_set_user_data (surface, &key, ptr, free); - - return surface; -} - -static char * -_cairo_boilerplate_image_describe (void *closure) -{ - char *s; - - xasprintf (&s, "pixman %s", pixman_version_string ()); - - return s; -} - -#if CAIRO_HAS_RECORDING_SURFACE -static cairo_surface_t * -_cairo_boilerplate_recording_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure) -{ - cairo_rectangle_t extents; - - extents.x = 0; - extents.y = 0; - extents.width = width; - extents.height = height; - return *closure = cairo_surface_reference (cairo_recording_surface_create (content, &extents)); -} - -static void -_cairo_boilerplate_recording_surface_cleanup (void *closure) -{ - cairo_surface_finish (closure); - cairo_surface_destroy (closure); -} -#endif - -const cairo_user_data_key_t cairo_boilerplate_output_basename_key; - -cairo_surface_t * -_cairo_boilerplate_get_image_surface (cairo_surface_t *src, - int page, - int width, - int height) -{ - cairo_surface_t *surface, *image; - cairo_t *cr; - cairo_status_t status; - cairo_format_t format; - - if (cairo_surface_status (src)) - return cairo_surface_reference (src); - - if (page != 0) - return cairo_boilerplate_surface_create_in_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); - - /* extract sub-surface */ - switch (cairo_surface_get_content (src)) { - case CAIRO_CONTENT_ALPHA: - format = CAIRO_FORMAT_A8; - break; - case CAIRO_CONTENT_COLOR: - format = CAIRO_FORMAT_RGB24; - break; - default: - case CAIRO_CONTENT_COLOR_ALPHA: - format = CAIRO_FORMAT_ARGB32; - break; - } - surface = cairo_image_surface_create (format, width, height); - assert (cairo_surface_get_content (surface) == cairo_surface_get_content (src)); - image = cairo_surface_reference (surface); - - /* open a logging channel (only interesting for recording surfaces) */ -#if CAIRO_HAS_SCRIPT_SURFACE && CAIRO_HAS_RECORDING_SURFACE - if (cairo_surface_get_type (src) == CAIRO_SURFACE_TYPE_RECORDING) { - const char *test_name; - - test_name = cairo_surface_get_user_data (src, - &cairo_boilerplate_output_basename_key); - if (test_name != NULL) { - cairo_device_t *ctx; - char *filename; - - cairo_surface_destroy (surface); - - xasprintf (&filename, "%s.out.trace", test_name); - ctx = cairo_script_create (filename); - surface = cairo_script_surface_create_for_target (ctx, image); - cairo_device_destroy (ctx); - free (filename); - } - } -#endif - - cr = cairo_create (surface); - cairo_surface_destroy (surface); - cairo_set_source_surface (cr, src, 0, 0); - cairo_paint (cr); - - status = cairo_status (cr); - if (status) { - cairo_surface_destroy (image); - image = cairo_surface_reference (cairo_get_target (cr)); - } - cairo_destroy (cr); - - return image; -} - -cairo_surface_t * -cairo_boilerplate_get_image_surface_from_png (const char *filename, - int width, - int height, - cairo_bool_t flatten) -{ - cairo_surface_t *surface; - - surface = cairo_image_surface_create_from_png (filename); - if (cairo_surface_status (surface)) - return surface; - - if (flatten) { - cairo_t *cr; - cairo_surface_t *flattened; - - flattened = cairo_image_surface_create (cairo_image_surface_get_format (surface), - width, - height); - cr = cairo_create (flattened); - cairo_surface_destroy (flattened); - - cairo_set_source_rgb (cr, 1, 1, 1); - cairo_paint (cr); - - cairo_set_source_surface (cr, surface, - width - cairo_image_surface_get_width (surface), - height - cairo_image_surface_get_height (surface)); - cairo_paint (cr); - - cairo_surface_destroy (surface); - surface = cairo_surface_reference (cairo_get_target (cr)); - cairo_destroy (cr); - } else if (cairo_image_surface_get_width (surface) != width || - cairo_image_surface_get_height (surface) != height) - { - cairo_t *cr; - cairo_surface_t *sub; - - sub = cairo_image_surface_create (cairo_image_surface_get_format (surface), - width, - height); - cr = cairo_create (sub); - cairo_surface_destroy (sub); - - cairo_set_source_surface (cr, surface, - width - cairo_image_surface_get_width (surface), - height - cairo_image_surface_get_height (surface)); - cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); - cairo_paint (cr); - - cairo_surface_destroy (surface); - surface = cairo_surface_reference (cairo_get_target (cr)); - cairo_destroy (cr); - } - - return surface; -} - -static const cairo_boilerplate_target_t builtin_targets[] = { - /* I'm uncompromising about leaving the image backend as 0 - * for tolerance. There shouldn't ever be anything that is out of - * our control here. */ - { - "image", "image", NULL, NULL, - CAIRO_SURFACE_TYPE_IMAGE, CAIRO_CONTENT_COLOR_ALPHA, 0, - NULL, - _cairo_boilerplate_image_create_surface, - _cairo_boilerplate_image_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, - _cairo_boilerplate_image_describe, - TRUE, FALSE, FALSE - }, - { - "image", "image", NULL, NULL, - CAIRO_SURFACE_TYPE_IMAGE, CAIRO_CONTENT_COLOR, 0, - NULL, - _cairo_boilerplate_image_create_surface, - _cairo_boilerplate_image_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, - _cairo_boilerplate_image_describe, - FALSE, FALSE, FALSE - }, - { - "image16", "image", NULL, NULL, - CAIRO_SURFACE_TYPE_IMAGE, CAIRO_CONTENT_COLOR, 0, - NULL, - _cairo_boilerplate_image16_create_surface, - _cairo_boilerplate_image16_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, - _cairo_boilerplate_image_describe, - TRUE, FALSE, FALSE - }, -#if CAIRO_HAS_RECORDING_SURFACE - { - "recording", "image", NULL, NULL, - CAIRO_SURFACE_TYPE_RECORDING, CAIRO_CONTENT_COLOR_ALPHA, 0, - "cairo_recording_surface_create", - _cairo_boilerplate_recording_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_recording_surface_cleanup, - NULL, NULL, - FALSE, FALSE, TRUE - }, - { - "recording", "image", NULL, NULL, - CAIRO_SURFACE_TYPE_RECORDING, CAIRO_CONTENT_COLOR, 0, - "cairo_recording_surface_create", - _cairo_boilerplate_recording_create_surface, - cairo_surface_create_similar, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - _cairo_boilerplate_recording_surface_cleanup, - NULL, NULL, - FALSE, FALSE, TRUE - }, -#endif -}; -CAIRO_BOILERPLATE (builtin, builtin_targets) - -static struct cairo_boilerplate_target_list { - struct cairo_boilerplate_target_list *next; - const cairo_boilerplate_target_t *target; -} *cairo_boilerplate_targets; - -static cairo_bool_t -probe_target (const cairo_boilerplate_target_t *target) -{ - if (target->probe == NULL) - return TRUE; - -#if HAVE_DLSYM - return dlsym (NULL, target->probe) != NULL; -#else - return TRUE; -#endif -} - -void -_cairo_boilerplate_register_backend (const cairo_boilerplate_target_t *targets, - unsigned int count) -{ - targets += count; - while (count--) { - struct cairo_boilerplate_target_list *list; - - --targets; - if (! probe_target (targets)) - continue; - - list = xmalloc (sizeof (*list)); - list->next = cairo_boilerplate_targets; - list->target = targets; - cairo_boilerplate_targets = list; - } -} - -static cairo_bool_t -_cairo_boilerplate_target_format_matches_name (const cairo_boilerplate_target_t *target, - const char *tcontent_name, - const char *tcontent_end) -{ - char const *content_name; - const char *content_end = tcontent_end; - size_t content_len; - - content_name = _cairo_boilerplate_content_visible_name (target->content); - if (tcontent_end) - content_len = content_end - tcontent_name; - else - content_len = strlen(tcontent_name); - if (strlen(content_name) != content_len) - return FALSE; - if (0 == strncmp (content_name, tcontent_name, content_len)) - return TRUE; - - return FALSE; -} - -static cairo_bool_t -_cairo_boilerplate_target_matches_name (const cairo_boilerplate_target_t *target, - const char *tname, - const char *end) -{ - char const *content_name; - const char *content_start = strpbrk (tname, "."); - const char *content_end = end; - size_t name_len; - size_t content_len; - - if (content_start >= end) - content_start = NULL; - if (content_start != NULL) - end = content_start++; - - name_len = end - tname; - - /* Check name. */ - if (! (name_len == 1 && 0 == strncmp (tname, "?", 1))) { /* wildcard? */ - if (0 != strncmp (target->name, tname, name_len)) /* exact match? */ - return FALSE; - if (isalnum (target->name[name_len])) - return FALSE; - } - - /* Check optional content. */ - if (content_start == NULL) /* none given? */ - return TRUE; - - /* Exact content match? */ - content_name = _cairo_boilerplate_content_visible_name (target->content); - content_len = content_end - content_start; - if (strlen(content_name) != content_len) - return FALSE; - if (0 == strncmp (content_name, content_start, content_len)) - return TRUE; - - return FALSE; -} - -const cairo_boilerplate_target_t ** -cairo_boilerplate_get_targets (int *pnum_targets, - cairo_bool_t *plimited_targets) -{ - size_t i, num_targets; - cairo_bool_t limited_targets = FALSE; - const char *tname; - const cairo_boilerplate_target_t **targets_to_test; - struct cairo_boilerplate_target_list *list; - - if (cairo_boilerplate_targets == NULL) - _cairo_boilerplate_register_all (); - - if ((tname = getenv ("CAIRO_TEST_TARGET")) != NULL && *tname) { - /* check the list of targets specified by the user */ - limited_targets = TRUE; - - num_targets = 0; - targets_to_test = NULL; - - while (*tname) { - int found = 0; - const char *end = strpbrk (tname, " \t\r\n;:,"); - if (!end) - end = tname + strlen (tname); - - if (end == tname) { - tname = end + 1; - continue; - } - - for (list = cairo_boilerplate_targets; - list != NULL; - list = list->next) - { - const cairo_boilerplate_target_t *target = list->target; - const char *tcontent_name; - const char *tcontent_end; - if (_cairo_boilerplate_target_matches_name (target, tname, end)) { - if ((tcontent_name = getenv ("CAIRO_TEST_TARGET_FORMAT")) != NULL && *tcontent_name) { - while(tcontent_name) { - tcontent_end = strpbrk (tcontent_name, " \t\r\n;:,"); - if (tcontent_end == tcontent_name) { - tcontent_name = tcontent_end + 1; - continue; - } - if(_cairo_boilerplate_target_format_matches_name (target, - tcontent_name, tcontent_end)) { - /* realloc isn't exactly the best thing here, but meh. */ - targets_to_test = xrealloc (targets_to_test, - sizeof(cairo_boilerplate_target_t *) * (num_targets+1)); - targets_to_test[num_targets++] = target; - found = 1; - } - - if (tcontent_end) - tcontent_end++; - tcontent_name = tcontent_end; - } - } else { - /* realloc isn't exactly the best thing here, but meh. */ - targets_to_test = xrealloc (targets_to_test, - sizeof(cairo_boilerplate_target_t *) * (num_targets+1)); - targets_to_test[num_targets++] = target; - found = 1; - } - } - } - - if (!found) { - const char *last_name = NULL; - - fprintf (stderr, "Cannot find target '%.*s'.\n", - (int)(end - tname), tname); - fprintf (stderr, "Known targets:"); - for (list = cairo_boilerplate_targets; - list != NULL; - list = list->next) - { - const cairo_boilerplate_target_t *target = list->target; - if (last_name != NULL) { - if (strcmp (target->name, last_name) == 0) { - /* filter out repeats that differ in content */ - continue; - } - fprintf (stderr, ","); - } - fprintf (stderr, " %s", target->name); - last_name = target->name; - } - fprintf (stderr, "\n"); - exit(-1); - } - - if (*end) - end++; - tname = end; - } - } else { - int found = 0; - int not_found_targets = 0; - num_targets = 0; - targets_to_test = xmalloc (sizeof(cairo_boilerplate_target_t*) * num_targets); - for (list = cairo_boilerplate_targets; list != NULL; list = list->next) - { - const cairo_boilerplate_target_t *target = list->target; - const char *tcontent_name; - const char *tcontent_end; - if ((tcontent_name = getenv ("CAIRO_TEST_TARGET_FORMAT")) != NULL && *tcontent_name) { - while(tcontent_name) { - tcontent_end = strpbrk (tcontent_name, " \t\r\n;:,"); - if (tcontent_end == tcontent_name) { - tcontent_name = tcontent_end + 1; - continue; - } - if (_cairo_boilerplate_target_format_matches_name (target, - tcontent_name, tcontent_end)) { - /* realloc isn't exactly the best thing here, but meh. */ - targets_to_test = xrealloc (targets_to_test, - sizeof(cairo_boilerplate_target_t *) * (num_targets+1)); - targets_to_test[num_targets++] = target; - found =1; - } - else - { - not_found_targets++; - } - - if (tcontent_end) - tcontent_end++; - - tcontent_name = tcontent_end; - } - } - else - { - num_targets++; - } - } - if (!found) - { - /* check all compiled in targets */ - num_targets = num_targets + not_found_targets; - targets_to_test = xrealloc (targets_to_test, - sizeof(cairo_boilerplate_target_t*) * num_targets); - num_targets = 0; - for (list = cairo_boilerplate_targets; - list != NULL; - list = list->next) - { - const cairo_boilerplate_target_t *target = list->target; - targets_to_test[num_targets++] = target; - } - } - - } - - /* exclude targets as specified by the user */ - if ((tname = getenv ("CAIRO_TEST_TARGET_EXCLUDE")) != NULL && *tname) { - limited_targets = TRUE; - - while (*tname) { - int j; - const char *end = strpbrk (tname, " \t\r\n;:,"); - if (!end) - end = tname + strlen (tname); - - if (end == tname) { - tname = end + 1; - continue; - } - - for (i = j = 0; i < num_targets; i++) { - const cairo_boilerplate_target_t *target = targets_to_test[i]; - if (! _cairo_boilerplate_target_matches_name (target, - tname, end)) - { - targets_to_test[j++] = targets_to_test[i]; - } - } - num_targets = j; - - if (*end) - end++; - tname = end; - } - } - - if (pnum_targets) - *pnum_targets = num_targets; - - if (plimited_targets) - *plimited_targets = limited_targets; - - return targets_to_test; -} - -const cairo_boilerplate_target_t * -cairo_boilerplate_get_image_target (cairo_content_t content) -{ - if (cairo_boilerplate_targets == NULL) - _cairo_boilerplate_register_all (); - - switch (content) { - case CAIRO_CONTENT_COLOR: - return &builtin_targets[1]; - case CAIRO_CONTENT_COLOR_ALPHA: - return &builtin_targets[0]; - case CAIRO_CONTENT_ALPHA: - default: - return NULL; - } -} - -const cairo_boilerplate_target_t * -cairo_boilerplate_get_target_by_name (const char *name, - cairo_content_t content) -{ - struct cairo_boilerplate_target_list *list; - - if (cairo_boilerplate_targets == NULL) - _cairo_boilerplate_register_all (); - - /* first return an exact match */ - for (list = cairo_boilerplate_targets; list != NULL; list = list->next) { - const cairo_boilerplate_target_t *target = list->target; - if (strcmp (target->name, name) == 0 && - target->content == content) - { - return target; - } - } - - /* otherwise just return a match that may differ in content */ - for (list = cairo_boilerplate_targets; list != NULL; list = list->next) { - const cairo_boilerplate_target_t *target = list->target; - if (strcmp (target->name, name) == 0) - return target; - } - - return NULL; -} - -void -cairo_boilerplate_free_targets (const cairo_boilerplate_target_t **targets) -{ - free (targets); -} - -cairo_surface_t * -cairo_boilerplate_surface_create_in_error (cairo_status_t status) -{ - cairo_surface_t *surface = NULL; - int loop = 5; - - do { - cairo_surface_t *intermediate; - cairo_t *cr; - cairo_path_t path; - - intermediate = cairo_image_surface_create (CAIRO_FORMAT_A8, 0, 0); - cr = cairo_create (intermediate); - cairo_surface_destroy (intermediate); - - path.status = status; - cairo_append_path (cr, &path); - - cairo_surface_destroy (surface); - surface = cairo_surface_reference (cairo_get_target (cr)); - cairo_destroy (cr); - } while (cairo_surface_status (surface) != status && --loop); - - return surface; -} - -void -cairo_boilerplate_scaled_font_set_max_glyphs_cached (cairo_scaled_font_t *scaled_font, - int max_glyphs) -{ - /* XXX CAIRO_DEBUG */ -} - -#if HAS_DAEMON -static int -any2ppm_daemon_exists (void) -{ - struct stat st; - int fd; - char buf[80]; - int pid; - int ret; - - if (stat (SOCKET_PATH, &st) < 0) - return 0; - - fd = open (SOCKET_PATH ".pid", O_RDONLY); - if (fd < 0) - return 0; - - pid = 0; - ret = read (fd, buf, sizeof (buf) - 1); - if (ret > 0) { - buf[ret] = '\0'; - pid = atoi (buf); - } - close (fd); - - return pid > 0 && kill (pid, 0) != -1; -} -#endif - -FILE * -cairo_boilerplate_open_any2ppm (const char *filename, - int page, - unsigned int flags, - int (**close_cb) (FILE *)) -{ - char command[4096]; - const char *any2ppm; -#if HAS_DAEMON - int sk; - struct sockaddr_un addr; - int len; -#endif - - any2ppm = getenv ("ANY2PPM"); - if (any2ppm == NULL) - any2ppm = "./any2ppm"; - -#if HAS_DAEMON - if (flags & CAIRO_BOILERPLATE_OPEN_NO_DAEMON) - goto POPEN; - - if (! any2ppm_daemon_exists ()) { - if (system (any2ppm) != 0) - goto POPEN; - } - - sk = socket (PF_UNIX, SOCK_STREAM, 0); - if (sk == -1) - goto POPEN; - - memset (&addr, 0, sizeof (addr)); - addr.sun_family = AF_UNIX; - strcpy (addr.sun_path, SOCKET_PATH); - - if (connect (sk, (struct sockaddr *) &addr, sizeof (addr)) == -1) { - close (sk); - goto POPEN; - } - - len = sprintf (command, "%s %d\n", filename, page); - if (write (sk, command, len) != len) { - close (sk); - goto POPEN; - } - - *close_cb = fclose; - return fdopen (sk, "rb"); - -POPEN: -#endif - - *close_cb = pclose; - sprintf (command, "%s %s %d", any2ppm, filename, page); - return popen (command, "rb"); -} - -static cairo_bool_t -freadn (unsigned char *buf, - int len, - FILE *file) -{ - int ret; - - while (len) { - ret = fread (buf, 1, len, file); - if (ret != len) { - if (ferror (file) || feof (file)) - return FALSE; - } - len -= ret; - buf += len; - } - - return TRUE; -} - -cairo_surface_t * -cairo_boilerplate_image_surface_create_from_ppm_stream (FILE *file) -{ - char format; - int width, height, stride; - int x, y; - unsigned char *data; - cairo_surface_t *image = NULL; - - if (fscanf (file, "P%c %d %d 255\n", &format, &width, &height) != 3) - goto FAIL; - - switch (format) { - case '7': /* XXX */ - image = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); - break; - case '6': - image = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height); - break; - case '5': - image = cairo_image_surface_create (CAIRO_FORMAT_A8, width, height); - break; - default: - goto FAIL; - } - if (cairo_surface_status (image)) - return image; - - data = cairo_image_surface_get_data (image); - stride = cairo_image_surface_get_stride (image); - for (y = 0; y < height; y++) { - unsigned char *buf = data + y*stride; - switch (format) { - case '7': - if (! freadn (buf, 4 * width, file)) - goto FAIL; - break; - case '6': - if (! freadn (buf, 3*width, file)) - goto FAIL; - buf += 3*width; - for (x = width; x--; ) { - buf -= 3; - ((uint32_t *) (data + y*stride))[x] = - (buf[0] << 16) | (buf[1] << 8) | (buf[2] << 0); - } - break; - case '5': - if (! freadn (buf, width, file)) - goto FAIL; - break; - } - } - cairo_surface_mark_dirty (image); - - return image; - -FAIL: - cairo_surface_destroy (image); - return cairo_boilerplate_surface_create_in_error (CAIRO_STATUS_READ_ERROR); -} - -cairo_surface_t * -cairo_boilerplate_convert_to_image (const char *filename, - int page) -{ - FILE *file; - unsigned int flags = 0; - cairo_surface_t *image; - int (*close_cb) (FILE *); - int ret; - - RETRY: - file = cairo_boilerplate_open_any2ppm (filename, page, flags, &close_cb); - if (file == NULL) { - switch (errno) { - case ENOMEM: - return cairo_boilerplate_surface_create_in_error (CAIRO_STATUS_NO_MEMORY); - default: - return cairo_boilerplate_surface_create_in_error (CAIRO_STATUS_READ_ERROR); - } - } - - image = cairo_boilerplate_image_surface_create_from_ppm_stream (file); - ret = close_cb (file); - /* check for fatal errors from the interpreter */ - if (ret) { /* any2pmm should never die... */ - cairo_surface_destroy (image); - return cairo_boilerplate_surface_create_in_error (CAIRO_STATUS_INVALID_STATUS); - } - - if (ret == 0 && cairo_surface_status (image) == CAIRO_STATUS_READ_ERROR) { - if (flags == 0) { - /* Try again in a standalone process. */ - cairo_surface_destroy (image); - flags = CAIRO_BOILERPLATE_OPEN_NO_DAEMON; - goto RETRY; - } - } - - return image; -} - -int -cairo_boilerplate_version (void) -{ - return CAIRO_VERSION; -} - -const char* -cairo_boilerplate_version_string (void) -{ - return CAIRO_VERSION_STRING; -} - -void -cairo_boilerplate_fini (void) -{ - while (cairo_boilerplate_targets != NULL) { - struct cairo_boilerplate_target_list *next; - - next = cairo_boilerplate_targets->next; - - free (cairo_boilerplate_targets); - cairo_boilerplate_targets = next; - } -} diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h deleted file mode 100644 index 515bb03..0000000 --- a/boilerplate/cairo-boilerplate.h +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright © 2004,2006 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Red Hat, Inc. not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Red Hat, Inc. makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Carl D. Worth - */ - -#ifndef _CAIRO_BOILERPLATE_H_ -#define _CAIRO_BOILERPLATE_H_ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include - -#include "cairo-compiler-private.h" - -#if HAVE_STDINT_H -# include -#elif HAVE_INTTYPES_H -# include -#elif HAVE_SYS_INT_TYPES_H -# include -#elif defined(_MSC_VER) -# include - typedef __int8 int8_t; - typedef unsigned __int8 uint8_t; - typedef __int16 int16_t; - typedef unsigned __int16 uint16_t; - typedef __int32 int32_t; - typedef unsigned __int32 uint32_t; - typedef __int64 int64_t; - typedef unsigned __int64 uint64_t; -#else -#error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, etc.) -#endif - -#ifndef HAVE_UINT64_T -# define HAVE_UINT64_T 1 -#endif -#ifndef INT16_MIN -# define INT16_MIN (-32767-1) -#endif -#ifndef INT16_MAX -# define INT16_MAX (32767) -#endif -#ifndef UINT16_MAX -# define UINT16_MAX (65535) -#endif - -#ifndef CAIRO_BOILERPLATE_DEBUG -#define CAIRO_BOILERPLATE_DEBUG(x) -#endif - -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) -#define CAIRO_BOILERPLATE_PRINTF_FORMAT(fmt_index, va_index) \ - __attribute__((__format__(__printf__, fmt_index, va_index))) -#else -#define CAIRO_BOILERPLATE_PRINTF_FORMAT(fmt_index, va_index) -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -#ifndef ARRAY_LENGTH -#define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0]))) -#endif - -CAIRO_BEGIN_DECLS - -/* A fake format we use for the flattened ARGB output of the PS and - * PDF surfaces. */ -#define CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED ((unsigned int) -1) - -extern const cairo_user_data_key_t cairo_boilerplate_output_basename_key; - -cairo_content_t -cairo_boilerplate_content (cairo_content_t content); - -const char * -cairo_boilerplate_content_name (cairo_content_t content); - -cairo_format_t -cairo_boilerplate_format_from_content (cairo_content_t content); - -typedef enum { - CAIRO_BOILERPLATE_MODE_TEST, - CAIRO_BOILERPLATE_MODE_PERF, - - /* This will allow running performance test with threads. The - * GL backend is very slow on some drivers when run with thread - * awareness turned on. */ - CAIRO_BOILERPLATE_MODE_PERF_THREADS, -} cairo_boilerplate_mode_t; - -typedef cairo_surface_t * -(*cairo_boilerplate_create_surface_t) (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - void **closure); - -typedef cairo_surface_t * -(*cairo_boilerplate_create_similar_t) (cairo_surface_t *other, - cairo_content_t content, - int width, - int height); - -typedef void -(*cairo_boilerplate_force_fallbacks_t) (cairo_surface_t *surface, - double x_pixels_per_inch, - double y_pixels_per_inch); - -typedef cairo_status_t -(*cairo_boilerplate_finish_surface_t) (cairo_surface_t *surface); - -typedef cairo_surface_t * -(*cairo_boilerplate_get_image_surface_t) (cairo_surface_t *surface, - int page, - int width, - int height); - -typedef cairo_status_t -(*cairo_boilerplate_write_to_png_t) (cairo_surface_t *surface, - const char *filename); - -typedef void -(*cairo_boilerplate_cleanup_t) (void *closure); - -typedef void -(*cairo_boilerplate_wait_t) (void *closure); - -typedef char * -(*cairo_boilerplate_describe_t) (void *closure); - -typedef struct _cairo_boilerplate_target { - const char *name; - const char *basename; - const char *file_extension; - const char *reference_target; - cairo_surface_type_t expected_type; - cairo_content_t content; - unsigned int error_tolerance; - const char *probe; /* runtime dl check */ - cairo_boilerplate_create_surface_t create_surface; - cairo_boilerplate_create_similar_t create_similar; - cairo_boilerplate_force_fallbacks_t force_fallbacks; - cairo_boilerplate_finish_surface_t finish_surface; - cairo_boilerplate_get_image_surface_t get_image_surface; - cairo_boilerplate_write_to_png_t write_to_png; - cairo_boilerplate_cleanup_t cleanup; - cairo_boilerplate_wait_t synchronize; - cairo_boilerplate_describe_t describe; - cairo_bool_t is_measurable; - cairo_bool_t is_vector; - cairo_bool_t is_recording; -} cairo_boilerplate_target_t; - -const cairo_boilerplate_target_t * -cairo_boilerplate_get_image_target (cairo_content_t content); - -const cairo_boilerplate_target_t * -cairo_boilerplate_get_target_by_name (const char *name, - cairo_content_t content); - -const cairo_boilerplate_target_t ** -cairo_boilerplate_get_targets (int *num_targets, - cairo_bool_t *limited_targets); - -void -cairo_boilerplate_free_targets (const cairo_boilerplate_target_t **targets); - -cairo_surface_t * -_cairo_boilerplate_get_image_surface (cairo_surface_t *src, - int page, - int width, - int height); -cairo_surface_t * -cairo_boilerplate_get_image_surface_from_png (const char *filename, - int width, - int height, - cairo_bool_t flatten); - -cairo_surface_t * -cairo_boilerplate_surface_create_in_error (cairo_status_t status); - -enum { - CAIRO_BOILERPLATE_OPEN_NO_DAEMON = 0x1, -}; - -FILE * -cairo_boilerplate_open_any2ppm (const char *filename, - int page, - unsigned int flags, - int (**close_cb) (FILE *)); - -cairo_surface_t * -cairo_boilerplate_image_surface_create_from_ppm_stream (FILE *file); - -cairo_surface_t * -cairo_boilerplate_convert_to_image (const char *filename, - int page); - -int -cairo_boilerplate_version (void); - -const char* -cairo_boilerplate_version_string (void); - -void -cairo_boilerplate_fini (void); - -#include "cairo-boilerplate-system.h" - -CAIRO_END_DECLS - -#endif diff --git a/boilerplate/check-link.c b/boilerplate/check-link.c deleted file mode 100644 index f164448..0000000 --- a/boilerplate/check-link.c +++ /dev/null @@ -1,24 +0,0 @@ -#define CAIRO_VERSION_H 1 - -#include - -/* get the "real" version info instead of dummy cairo-version.h */ -#undef CAIRO_VERSION_H -#include "../cairo-version.h" - -#include - -int -main (void) -{ - printf ("Check linking to the just built cairo boilerplate library\n"); - if (cairo_boilerplate_version () == CAIRO_VERSION) { - return 0; - } else { - fprintf (stderr, - "Error: linked to cairo boilerplate version %s instead of %s\n", - cairo_boilerplate_version_string (), - CAIRO_VERSION_STRING); - return 1; - } -} diff --git a/boilerplate/make-cairo-boilerplate-constructors.sh b/boilerplate/make-cairo-boilerplate-constructors.sh deleted file mode 100644 index 09716ca..0000000 --- a/boilerplate/make-cairo-boilerplate-constructors.sh +++ /dev/null @@ -1,29 +0,0 @@ -#! /bin/sh - -if test $# -eq 0; then - echo "$0: no input files." >&2 - exit 0 -fi - -cat < cairo-lcov.info.tmp LANG=C $(LTP_GENHTML) --prefix $(top_builddir) --output-directory cairo-lcov --title "Cairo Code Coverage" --show-details cairo-lcov.info.tmp diff --git a/build/configure.ac.features b/build/configure.ac.features index baac63e..7aaac94 100644 --- a/build/configure.ac.features +++ b/build/configure.ac.features @@ -53,12 +53,11 @@ dnl =========================================================================== dnl =========================================================================== dnl -dnl Generate {src,boilerplate}/Makefile.{am,win32}.config +dnl Generate {src}/Makefile.{am,win32}.config dnl CAIRO_INIT_MAKEFILES([build]) CAIRO_CONFIG_MAKEFILE([cairo], [src])dnl -CAIRO_CONFIG_MAKEFILE([cairo_boilerplate], [boilerplate])dnl CAIRO_MAKEFILE_INCLUDE(*,[Makefile.sources])dnl dnl An empty line per feature for readability CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,*,*,*,[])dnl diff --git a/configure.ac b/configure.ac index ef5725f..50d6507 100644 --- a/configure.ac +++ b/configure.ac @@ -932,7 +932,6 @@ AM_CONDITIONAL(HAVE_GTK, test "x$have_gtk" = "xyes") AC_CONFIG_FILES([ Makefile -boilerplate/Makefile src/Makefile util/Makefile util/cairo-gobject/Makefile -- 2.7.4 From 6a579e08bbc995f7b14cc41e7d1e0b616508568d Mon Sep 17 00:00:00 2001 From: "mh0310.choi" Date: Fri, 26 Aug 2016 15:42:41 +0900 Subject: [PATCH 03/16] Add gbs.conf --- .gbs.conf | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gbs.conf diff --git a/.gbs.conf b/.gbs.conf new file mode 100644 index 0000000..35106e8 --- /dev/null +++ b/.gbs.conf @@ -0,0 +1,3 @@ +[general] +upstream_branch = origin +upstream_tag = v${upstreamversion} -- 2.7.4 From f153543dc01736bb1009dfd6f2455c1606673831 Mon Sep 17 00:00:00 2001 From: "mh0310.choi" Date: Fri, 26 Aug 2016 15:42:41 +0900 Subject: [PATCH 04/16] Add gbs.conf Change-Id: I721a91ca2c4ae269dfaed7aa5267ae672066b582 --- .gbs.conf | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gbs.conf diff --git a/.gbs.conf b/.gbs.conf new file mode 100644 index 0000000..35106e8 --- /dev/null +++ b/.gbs.conf @@ -0,0 +1,3 @@ +[general] +upstream_branch = origin +upstream_tag = v${upstreamversion} -- 2.7.4 From 996e7dfe39899e78e8b7d52edd438f4451f7c19d Mon Sep 17 00:00:00 2001 From: "mh0310.choi" Date: Thu, 1 Sep 2016 11:13:52 +0900 Subject: [PATCH 05/16] Delete .gbs.conf Change-Id: If617fc0cdaacbb977611b2e44ba0a5b2868fd5b0 --- .gbs.conf | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .gbs.conf diff --git a/.gbs.conf b/.gbs.conf deleted file mode 100644 index 35106e8..0000000 --- a/.gbs.conf +++ /dev/null @@ -1,3 +0,0 @@ -[general] -upstream_branch = origin -upstream_tag = v${upstreamversion} -- 2.7.4 From 9819660fc447c5d1723960c092394b35d80b2ffb Mon Sep 17 00:00:00 2001 From: "mh0310.choi" Date: Mon, 5 Sep 2016 21:40:07 +0900 Subject: [PATCH 06/16] Disable separable convolution - disable PIXMAN_FILTER_SEPARABLE_CONVOLUTION Change-Id: Ib445178c84a0b904bd68267185898158030b2d87 --- packaging/cairo.spec | 18 +++++++++--------- src/cairo-image-source.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/packaging/cairo.spec b/packaging/cairo.spec index 51c24f7..24759db 100644 --- a/packaging/cairo.spec +++ b/packaging/cairo.spec @@ -6,7 +6,6 @@ Name: cairo -#Version: 1.12.16 Version: 1.14.2 Release: 0 License: MPL-1.1 or LGPL-2.1+ @@ -16,7 +15,6 @@ Group: Graphics/Libraries Source: http://cairographics.org/releases/%{name}-%{version}.tar.xz Source99: baselibs.conf Source1001: cairo.manifest -#BuildRequires: libtool BuildRequires: pkg-config BuildRequires: xz BuildRequires: pkgconfig(fontconfig) @@ -144,18 +142,20 @@ NOCONFIGURE=1 ./autogen.sh --enable-svg=yes \ --enable-tee=no \ --enable-ttrace=no \ -%if %{with wayland} && !%{with x} + --disable-gtk-doc \ + --disable-static \ +%if %{with wayland} --disable-xlib \ - --disable-xcb \ -%else + --disable-xcb \ +%endif +%if %{with x} --enable-xlib \ %if %{with cairo_xcb_backend} - --enable-xcb \ + --enable-xcb %endif %endif - --disable-gtk-doc \ - --disable-static -make %{?_smp_mflags} V=1 + +#make %{?_smp_mflags} V=1 %install %make_install diff --git a/src/cairo-image-source.c b/src/cairo-image-source.c index 25cdf93..d811d45 100644 --- a/src/cairo-image-source.c +++ b/src/cairo-image-source.c @@ -62,6 +62,8 @@ #define PIXMAN_HAS_ATOMIC_OPS 1 #endif +#define SEPARABLE_CONVOLUTION 0 + #if PIXMAN_HAS_ATOMIC_OPS static pixman_image_t *__pixman_transparent_image; static pixman_image_t *__pixman_black_image; @@ -941,6 +943,10 @@ _pixman_image_set_properties (pixman_image_t *pixman_image, case CAIRO_FILTER_FAST: pixman_filter = PIXMAN_FILTER_FAST; break; + /* In order to prevent performance drop, Disable PIXMAN_FILTER_SEPERABLE_CONVOLTION + * same as cairo 1.12.14 in Tizen2.4 + */ +#if SEPARABLE_CONVOLUTION case CAIRO_FILTER_GOOD: pixman_filter = PIXMAN_FILTER_SEPARABLE_CONVOLUTION; kernel = KERNEL_BOX; @@ -971,6 +977,14 @@ _pixman_image_set_properties (pixman_image_t *pixman_image, else dy = 1.0; } break; +#else + case CAIRO_FILTER_GOOD: + pixman_filter = PIXMAN_FILTER_GOOD; + break; + case CAIRO_FILTER_BEST: + pixman_filter = PIXMAN_FILTER_BEST; + break; +#endif case CAIRO_FILTER_NEAREST: pixman_filter = PIXMAN_FILTER_NEAREST; break; -- 2.7.4 From 41f7145306892f5cafa1d25013a9841342f1a27e Mon Sep 17 00:00:00 2001 From: Ravi Nanjundappa Date: Wed, 5 Oct 2016 14:35:14 +0530 Subject: [PATCH 07/16] Fix for VDSvace issue: DF160920-00017 Return the locally assigned status value instead of pattern->status, because the pattern handle will be invalid after the call to cairo_pattern_destroy(pattern) Change-Id: I0c38f6c4aac619de2d27b5136a41870bee6e78cc Signed-off-by: Ravi Nanjundappa --- src/cairo-default-context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cairo-default-context.c b/src/cairo-default-context.c index 26644ea..36ddb75 100644 --- a/src/cairo-default-context.c +++ b/src/cairo-default-context.c @@ -310,7 +310,7 @@ _cairo_default_context_set_source_rgba (void *abstract_cr, double red, double gr status = pattern->status; cairo_pattern_destroy (pattern); CAIRO_TRACE_END (__func__); - return pattern->status; + return status; } status = _cairo_default_context_set_source (cr, pattern); -- 2.7.4 From 692cbd26e6d858fecb7a679a173723fa2c77840d Mon Sep 17 00:00:00 2001 From: Ravi Nanjundappa Date: Wed, 5 Oct 2016 15:07:21 +0530 Subject: [PATCH 08/16] Fix for VDSvace issue: DF160920-00047 Added the missing break at the end of switch case Change-Id: Iffe747d77e3bf64b96abe284f7fb838b7eab8eec Signed-off-by: Ravi Nanjundappa --- util/cairo-script/cairo-script-scanner.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/cairo-script/cairo-script-scanner.c b/util/cairo-script/cairo-script-scanner.c index b9d445b..4b7598d 100644 --- a/util/cairo-script/cairo-script-scanner.c +++ b/util/cairo-script/cairo-script-scanner.c @@ -1328,6 +1328,7 @@ scan_base64: goto scan_none; } longjmp (scan->jmpbuf, _csi_error (CSI_STATUS_INVALID_SCRIPT)); + break; default: base64_add (ctx, scan, c); -- 2.7.4 From 9bc3e5ab934f3aab30a8dcde41494d8021be766c Mon Sep 17 00:00:00 2001 From: Ravi Nanjundappa Date: Wed, 5 Oct 2016 15:16:10 +0530 Subject: [PATCH 09/16] Fix for VDSvace issue: DF160920-00051 Assigned the group handle to NULL after free inside _cairo_pdf_smask_group_destroy() and then checking against NULL value before freeing its members further. Change-Id: Icf9eacf075478244fb09dc6e2678b8d12cd7e292 Signed-off-by: Ravi Nanjundappa --- src/cairo-pdf-surface.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index 552e4bf..db50062 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -1101,18 +1101,22 @@ _cairo_pdf_surface_create_smask_group (cairo_pdf_surface_t *surface, static void _cairo_pdf_smask_group_destroy (cairo_pdf_smask_group_t *group) { + if(group != NULL) + { if (group->operation == PDF_FILL || group->operation == PDF_STROKE) - _cairo_path_fixed_fini (&group->path); + _cairo_path_fixed_fini (&group->path); if (group->source) - cairo_pattern_destroy (group->source); + cairo_pattern_destroy (group->source); if (group->mask) - cairo_pattern_destroy (group->mask); + cairo_pattern_destroy (group->mask); free (group->utf8); free (group->glyphs); free (group->clusters); if (group->scaled_font) - cairo_scaled_font_destroy (group->scaled_font); + cairo_scaled_font_destroy (group->scaled_font); free (group); + group = NULL; + } } static cairo_int_status_t -- 2.7.4 From f8129efb3559ad1e0730403c21ab2b90763ed1ca Mon Sep 17 00:00:00 2001 From: "mh0310.choi" Date: Mon, 10 Oct 2016 19:52:33 +0900 Subject: [PATCH 10/16] Modify the patch for DF160920-00051 Delete Unnecessary code Change-Id: I011c81321442b2bc8b47fcd9ea543fbc4e176413 --- src/cairo-pdf-surface.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index db50062..0412808 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -1115,7 +1115,6 @@ _cairo_pdf_smask_group_destroy (cairo_pdf_smask_group_t *group) if (group->scaled_font) cairo_scaled_font_destroy (group->scaled_font); free (group); - group = NULL; } } -- 2.7.4 From 2024ce7f23df8e0914fd54e8080fc4fe37591bf8 Mon Sep 17 00:00:00 2001 From: Ravi Nanjundappa Date: Fri, 11 Nov 2016 17:32:23 +0530 Subject: [PATCH 11/16] Fix for Svace issue: 150830 Checking api handle against NULL value before referencing its value. Change-Id: Ia23fef4b606cbc0f49e63f4a17d2867d10538bb1 Signed-off-by: Ravi Nanjundappa --- src/cairo-evas-gl-context.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/cairo-evas-gl-context.c b/src/cairo-evas-gl-context.c index 8135eda..2dde155 100644 --- a/src/cairo-evas-gl-context.c +++ b/src/cairo-evas-gl-context.c @@ -174,13 +174,15 @@ _cairo_evas_gl_get_proc_addr (void *data, const char *name) api = evas_gl_api_get (gl); - for (i = 0; evas_gl_func_map[i].name; i++) { - if (! strncmp (evas_gl_func_map[i].name, name, strlen(name))) - return *((cairo_gl_generic_func_t *) (((char *) &api->version) + evas_gl_func_map[i].func)); - } - - return evas_gl_proc_address_get (gl, name); -} + if(api != NULL) { + for (i = 0; evas_gl_func_map[i].name; i++) { + if (! strncmp (evas_gl_func_map[i].name, name, strlen(name))) + return *((cairo_gl_generic_func_t *) (((char *) &api->version) + evas_gl_func_map[i].func)); + } + } + + return evas_gl_proc_address_get (gl, name); +} static cairo_bool_t _context_acquisition_changed_evas_gl_state (cairo_evas_gl_context_t *ctx, -- 2.7.4 From c2eff77dc9e3320e1e3e44cc13e9946ec5b46715 Mon Sep 17 00:00:00 2001 From: "moonhee, choi" Date: Thu, 17 Nov 2016 15:13:44 +0900 Subject: [PATCH 12/16] Bug Fix in _evas_gl_destroy of cairo evas-gl backend Change-Id: I8b3c73b61cb5a2e82e8d2326be5821ec2f48626d --- src/cairo-evas-gl-context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 src/cairo-evas-gl-context.c diff --git a/src/cairo-evas-gl-context.c b/src/cairo-evas-gl-context.c old mode 100644 new mode 100755 index 8135eda..3805118 --- a/src/cairo-evas-gl-context.c +++ b/src/cairo-evas-gl-context.c @@ -264,7 +264,7 @@ _evas_gl_destroy (void *abstract_ctx) cairo_evas_gl_context_t *ctx = abstract_ctx; evas_gl_make_current (ctx->evas_gl, NULL, NULL); - if (! ctx->dummy_surface) + if (ctx->dummy_surface) evas_gl_surface_destroy (ctx->evas_gl, ctx->dummy_surface); } -- 2.7.4 From 90aea65d9219091b3519399301d5bc3517e56276 Mon Sep 17 00:00:00 2001 From: Moonhee Choi Date: Wed, 12 Apr 2017 15:32:06 +0900 Subject: [PATCH 13/16] Fix Svace issue & Memory leak - # of Svace : 39967 related to strcpy (Secure issue) Change-Id: I8e9092986331fa64d08ca0ff2f5979d94b70a203 Signed-off-by: Moonhee Choi --- src/cairo-cff-subset.c | 8 +++++++- src/cairo-evas-gl-context.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c index da49e8e..ca1437e 100644 --- a/src/cairo-cff-subset.c +++ b/src/cairo-cff-subset.c @@ -51,6 +51,7 @@ #include "cairo-scaled-font-subsets-private.h" #include "cairo-truetype-subset-private.h" +#include #include #include @@ -331,7 +332,12 @@ decode_real (unsigned char *p, double *real) buf = buffer2 + (q - buffer); strncpy (buf, decimal_point, decimal_point_len); buf += decimal_point_len; - strcpy (buf, q + 1); + + //(2017.04.17) Since securitY issue, replace strcpy to strncpy. + //strcpy (buf, q + 1); + strncpy (buf, q + 1, (buffer + sizeof(buffer)/sizeof(buffer[0])) - (q + 1)); + //same as strncpy (buf, q + 1, 100 - (q + 1)); + buf = buffer2; } diff --git a/src/cairo-evas-gl-context.c b/src/cairo-evas-gl-context.c index 10d6808..433aafd 100755 --- a/src/cairo-evas-gl-context.c +++ b/src/cairo-evas-gl-context.c @@ -304,7 +304,7 @@ cairo_evas_gl_device_create (Evas_GL *evas_gl, ctx->dummy_surface = evas_gl_pbuffer_surface_create (ctx->evas_gl, evas_cfg, 1, 1, NULL); - //evas_gl_config_free (evas_cfg); + evas_gl_config_free (evas_cfg); if (ctx->dummy_surface == NULL) { free (ctx); -- 2.7.4 From 4d9e2b04057fab1e18c4b0ddb948d87fb045c28b Mon Sep 17 00:00:00 2001 From: Moonhee Choi Date: Wed, 31 May 2017 18:44:08 +0900 Subject: [PATCH 14/16] [Cairo] Fix Kona defect & Svace issue - Kona RQ170526-01074 - warning : passing argument of 'cairo_surface_destory' from incompatible pointer type (cairo-gl-operand.c) - Svace 171678 related to memory leak (cairo-pdf-surface.c) Change-Id: If5b06985ad3be89ef639bfa1cbb07002304ea3d7 --- src/cairo-gl-operand.c | 2 +- src/cairo-pdf-surface.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cairo-gl-operand.c b/src/cairo-gl-operand.c index 575096a..de3cee7 100644 --- a/src/cairo-gl-operand.c +++ b/src/cairo-gl-operand.c @@ -833,7 +833,7 @@ _cairo_gl_pattern_texture_setup (cairo_gl_operand_t *operand, fail: cairo_surface_destroy (&surface->base); - cairo_surface_destroy (image); + cairo_surface_destroy (&image->base); return status; } diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index 0412808..e1612b2 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -5497,8 +5497,10 @@ _cairo_pdf_surface_emit_truetype_font_subset (cairo_pdf_surface_t *surface, char *pdf_str; status = _utf8_to_pdf_string (subset.family_name_utf8, &pdf_str); - if (unlikely (status)) - return status; + if (unlikely (status)) { + _cairo_truetype_subset_fini (&subset); + return status; + } _cairo_output_stream_printf (surface->output, " /FontFamily %s\n", -- 2.7.4 From c2843b1c511bb7f4fb418664e5ad66a92c3cadbd Mon Sep 17 00:00:00 2001 From: Moonhee Choi Date: Mon, 3 Jul 2017 18:17:32 +0900 Subject: [PATCH 15/16] [RQ170526-01074] gl:Fix bug in _cairo_gl_pattern_texture_setup() - The "image" allocated at line 786 is not freed before moving to label fail at line 803. - It was fixed in community: https://bugs.freedesktop.org/show_bug.cgi?id=91537 Change-Id: I91833b0f7be723f050e7c1d38ae64e5f07d831fe --- src/cairo-gl-operand.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cairo-gl-operand.c b/src/cairo-gl-operand.c index de3cee7..0d5c053 100644 --- a/src/cairo-gl-operand.c +++ b/src/cairo-gl-operand.c @@ -790,12 +790,18 @@ _cairo_gl_pattern_texture_setup (cairo_gl_operand_t *operand, if (src_is_gl_surface) { status = _cairo_gl_context_release (ctx, status); if (unlikely (status)) + { + _cairo_surface_unmap_image (&surface->base, image); goto fail; + } /* we need to release one more time */ status = _cairo_gl_context_release (ctx, status); if (unlikely (status)) + { + _cairo_surface_unmap_image (&surface->base, image); goto fail; + } } status = _cairo_surface_offset_paint (&image->base, extents->x, extents->y, @@ -833,7 +839,7 @@ _cairo_gl_pattern_texture_setup (cairo_gl_operand_t *operand, fail: cairo_surface_destroy (&surface->base); - cairo_surface_destroy (&image->base); + return status; } -- 2.7.4 From 0e68c694d0b8aed10d396e17efd214f36971dee3 Mon Sep 17 00:00:00 2001 From: Moonhee Choi Date: Fri, 18 Aug 2017 10:57:56 +0900 Subject: [PATCH 16/16] Fixed typo in _cairo_default_context_rounded_rectangle(). - svace # : 250144 Change-Id: Ia2cca4710e2df77221609de850f364228c05b1e5 Signed-off-by: Moonhee Choi --- src/cairo-default-context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cairo-default-context.c b/src/cairo-default-context.c index 36ddb75..375c0af 100644 --- a/src/cairo-default-context.c +++ b/src/cairo-default-context.c @@ -951,7 +951,7 @@ _cairo_default_context_rounded_rectangle (void *abstract_cr, if (r_top_left <= 0.0) r_top_left = 0.0; if (r_top_right <= 0.0) - r_top_left = 0.0; + r_top_right = 0.0; if (r_bottom_left < 0.0) r_bottom_left = 0.0; if (r_bottom_right <= 0.0) -- 2.7.4