summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-01-27 08:56:14 (GMT)
committerBenjamin Otte <otte@redhat.com>2010-01-27 08:56:14 (GMT)
commit58980b4ad60a60923a59370c81d59bb0457a7922 (patch)
tree568fdd7f5a8449f0df75200907fec668844b1cd8
parent17ddb1598b3df374b6275d907441f34318b4257f (diff)
build: Remove glitz surface
glitz is unmaintained and the GL surface is far superior anyway.
-rw-r--r--README8
-rw-r--r--boilerplate/Makefile.am13
-rw-r--r--boilerplate/Makefile.sources5
-rw-r--r--boilerplate/Makefile.win32.features10
-rw-r--r--boilerplate/cairo-boilerplate-glitz-agl.c191
-rw-r--r--boilerplate/cairo-boilerplate-glitz-glx.c265
-rw-r--r--boilerplate/cairo-boilerplate-glitz-wgl.c188
-rw-r--r--build/Makefile.win32.features1
-rw-r--r--build/Makefile.win32.features-h3
-rw-r--r--build/configure.ac.features1
-rw-r--r--configure.ac38
-rw-r--r--doc/public/cairo-docs.xml1
-rw-r--r--doc/public/cairo-sections.txt1
-rw-r--r--doc/public/tmpl/cairo-glitz.sgml22
-rw-r--r--src/Makefile.sources4
-rw-r--r--src/Makefile.win32.features14
-rw-r--r--src/cairo-deprecated.h1
-rw-r--r--src/cairo-glitz-private.h41
-rw-r--r--src/cairo-glitz-surface.c2450
-rw-r--r--src/cairo-glitz.h57
-rw-r--r--test/Makefile.am8
-rw-r--r--test/Makefile.sources2
-rw-r--r--test/glitz-surface-source.argb32.ref.pngbin377 -> 0 bytes
-rw-r--r--test/glitz-surface-source.c293
-rw-r--r--test/glitz-surface-source.ps2.ref.pngbin376 -> 0 bytes
-rw-r--r--test/glitz-surface-source.ps3.ref.pngbin376 -> 0 bytes
-rw-r--r--test/glitz-surface-source.rgb24.ref.pngbin301 -> 0 bytes
-rw-r--r--util/cairo.modules10
28 files changed, 3 insertions, 3624 deletions
diff --git a/README b/README
index a4ace94..6f2eb4a 100644
--- a/README
+++ b/README
@@ -6,8 +6,8 @@ What is cairo
Cairo is a 2D graphics library with support for multiple output
devices. Currently supported output targets include the X Window
System, quartz, win32, and image buffers, as well as PDF, PostScript,
-and SVG file output. Experimental backends include OpenGL (through
-glitz), XCB, BeOS, OS/2, and DirectFB.
+and SVG file output. Experimental backends include OpenGL, XCB, BeOS,
+OS/2, and DirectFB.
Cairo is designed to produce consistent output on all output media
while taking advantage of display hardware acceleration when available
@@ -163,10 +163,6 @@ Font backends (required to have at least one)
Experimental surface backends
-----------------------------
- glitz
- -------------
- glitz >= 0.4.4 http://freedesktop.org/Software/glitz
-
xcb backend
-----------
XCB http://xcb.freedesktop.org
diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index 10fb6af..547f415 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -32,19 +32,6 @@ if CAIRO_HAS_BEOS_SURFACE
AM_CPPFLAGS += -Wno-multichar
endif
-if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
-libcairoboilerplate_la_LIBADD += $(GLITZ_AGL_LIBS)
-endif
-if CAIRO_CAN_TEST_GLITZ_EGL_SURFACE
-libcairoboilerplate_la_LIBADD += $(GLITZ_EGL_LIBS)
-endif
-if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
-libcairoboilerplate_la_LIBADD += $(GLITZ_GLX_LIBS)
-endif
-if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
-libcairoboilerplate_la_LIBADD += $(GLITZ_WGL_LIBS)
-endif
-
if CAIRO_HAS_WIN32_SURFACE
libcairoboilerplate_la_LIBADD += -lwinspool
endif
diff --git a/boilerplate/Makefile.sources b/boilerplate/Makefile.sources
index d40d7f9..b590b7f 100644
--- a/boilerplate/Makefile.sources
+++ b/boilerplate/Makefile.sources
@@ -26,11 +26,6 @@ cairo_boilerplate_private = \
cairo_boilerplate_directfb_sources = cairo-boilerplate-directfb.c
cairo_boilerplate_drm_sources = cairo-boilerplate-drm.c
cairo_boilerplate_gl_sources = cairo-boilerplate-gl.c
-cairo_boilerplate_glitz_sources = \
- cairo-boilerplate-glitz-agl.c \
- cairo-boilerplate-glitz-glx.c \
- cairo-boilerplate-glitz-wgl.c \
- $(NULL)
cairo_boilerplate_pdf_sources = cairo-boilerplate-pdf.c
cairo_boilerplate_ps_sources = cairo-boilerplate-ps.c
cairo_boilerplate_qt_sources = cairo-boilerplate-qt.cpp
diff --git a/boilerplate/Makefile.win32.features b/boilerplate/Makefile.win32.features
index 0742787..bcf41a8 100644
--- a/boilerplate/Makefile.win32.features
+++ b/boilerplate/Makefile.win32.features
@@ -209,16 +209,6 @@ enabled_cairo_boilerplate_private += $(cairo_boilerplate_gl_private)
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_gl_sources)
endif
-unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_glitz_headers)
-all_cairo_boilerplate_headers += $(cairo_boilerplate_glitz_headers)
-all_cairo_boilerplate_private += $(cairo_boilerplate_glitz_private)
-all_cairo_boilerplate_sources += $(cairo_boilerplate_glitz_sources)
-ifeq ($(CAIRO_HAS_GLITZ_SURFACE),1)
-enabled_cairo_boilerplate_headers += $(cairo_boilerplate_glitz_headers)
-enabled_cairo_boilerplate_private += $(cairo_boilerplate_glitz_private)
-enabled_cairo_boilerplate_sources += $(cairo_boilerplate_glitz_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)
diff --git a/boilerplate/cairo-boilerplate-glitz-agl.c b/boilerplate/cairo-boilerplate-glitz-agl.c
deleted file mode 100644
index 679593b..0000000
--- a/boilerplate/cairo-boilerplate-glitz-agl.c
+++ /dev/null
@@ -1,191 +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 <cworth@cworth.org>
- */
-
-#include "cairo-boilerplate-private.h"
-
-#if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
-#include <cairo-glitz.h>
-#include <glitz-agl.h>
-
-static const cairo_user_data_key_t glitz_closure_key;
-
-typedef struct _glitz_agl_target_closure {
- glitz_target_closure_base_t base;
-} glitz_agl_target_closure_t;
-
-static glitz_surface_t *
-_cairo_boilerplate_glitz_agl_create_surface_internal (glitz_format_name_t formatname,
- int width,
- int height,
- glitz_agl_target_closure_t *closure)
-{
- glitz_drawable_format_t *dformat;
- glitz_drawable_format_t templ;
- glitz_drawable_t *gdraw;
- glitz_format_t *format;
- glitz_surface_t *sr = NULL;
- unsigned long mask;
-
- memset(&templ, 0, sizeof(templ));
- templ.color.red_size = 8;
- templ.color.green_size = 8;
- templ.color.blue_size = 8;
- templ.color.alpha_size = 8;
- templ.color.fourcc = GLITZ_FOURCC_RGB;
- templ.samples = 1;
-
- mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK |
- GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK |
- GLITZ_FORMAT_BLUE_SIZE_MASK;
- if (formatname == GLITZ_STANDARD_ARGB32)
- mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
-
- dformat = glitz_agl_find_pbuffer_format (mask, &templ, 0);
- if (!dformat) {
- fprintf (stderr, "Glitz failed to find pbuffer format for template.");
- goto FAIL;
- }
-
- gdraw = glitz_agl_create_pbuffer_drawable (dformat, width, height);
- if (!gdraw) {
- fprintf (stderr, "Glitz failed to create pbuffer drawable.");
- goto FAIL;
- }
-
- format = glitz_find_standard_format (gdraw, formatname);
- if (!format) {
- fprintf (stderr, "Glitz failed to find standard format for drawable.");
- goto DESTROY_DRAWABLE;
- }
-
- sr = glitz_surface_create (gdraw, format, width, height, 0, NULL);
- if (!sr) {
- fprintf (stderr, "Glitz failed to create a surface.");
- goto DESTROY_DRAWABLE;
- }
-
- glitz_surface_attach (sr, gdraw, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
-
- DESTROY_DRAWABLE:
- glitz_drawable_destroy (gdraw);
- return sr;
-
- FAIL:
- return NULL;
-}
-
-static cairo_surface_t *
-_cairo_boilerplate_glitz_agl_create_surface (const char *name,
- cairo_content_t content,
- double width,
- double height,
- double max_width,
- double max_height,
- cairo_boilerplate_mode_t mode,
- int id,
- void **closure)
-{
- glitz_surface_t *glitz_surface;
- cairo_surface_t *surface = NULL;
- glitz_agl_target_closure_t *aglc;
- int status;
-
- glitz_agl_init ();
-
- *closure = aglc = xmalloc (sizeof (glitz_agl_target_closure_t));
-
- switch (content) {
- case CAIRO_CONTENT_COLOR:
- glitz_surface = _cairo_boilerplate_glitz_agl_create_surface_internal (GLITZ_STANDARD_RGB24, width, height, NULL);
- break;
- case CAIRO_CONTENT_COLOR_ALPHA:
- glitz_surface = _cairo_boilerplate_glitz_agl_create_surface_internal (GLITZ_STANDARD_ARGB32, width, height, NULL);
- break;
- case CAIRO_CONTENT_ALPHA:
- default:
- fprintf (stderr, "Invalid content for glitz-agl test: %d\n", content);
- goto FAIL;
- }
-
- if (!glitz_surface)
- goto FAIL;
-
- surface = cairo_glitz_surface_create (glitz_surface);
- glitz_surface_destroy (glitz_surface);
-
- if (cairo_surface_status (surface))
- goto FAIL;
-
- aglc->base.width = width;
- aglc->base.height = height;
- aglc->base.content = content;
- status = cairo_surface_set_user_data (surface,
- &glitz_closure_key, aglc, NULL);
- if (status == CAIRO_STATUS_SUCCESS)
- return surface;
-
- cairo_surface_destroy (surface);
- surface = cairo_boilerplate_surface_create_in_error (status);
-
- FAIL:
- glitz_agl_fini ();
- return surface;
-}
-
-static void
-_cairo_boilerplate_glitz_agl_cleanup (void *closure)
-{
- free (closure);
- glitz_agl_fini ();
-}
-
-#endif
-
-static const cairo_boilerplate_target_t targets[] = {
-#if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
- {
- "glitz-agl", "glitz", NULL, NULL,
- CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR_ALPHA, 0,
- "cairo_glitz_surface_create",
- _cairo_boilerplate_glitz_agl_create_surface,
- NULL, NULL,
- _cairo_boilerplate_get_image_surface,
- cairo_surface_write_to_png,
- _cairo_boilerplate_glitz_agl_cleanup
- },
- {
- "glitz-agl", "glitz", NULL, NULL,
- CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
- "cairo_glitz_surface_create",
- _cairo_boilerplate_glitz_agl_create_surface,
- NULL, NULL,
- _cairo_boilerplate_get_image_surface,
- cairo_surface_write_to_png,
- _cairo_boilerplate_glitz_agl_cleanup
- },
-#endif
-};
-CAIRO_BOILERPLATE (glitz_agl, targets)
diff --git a/boilerplate/cairo-boilerplate-glitz-glx.c b/boilerplate/cairo-boilerplate-glitz-glx.c
deleted file mode 100644
index d490aec..0000000
--- a/boilerplate/cairo-boilerplate-glitz-glx.c
+++ /dev/null
@@ -1,265 +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 <cworth@cworth.org>
- */
-
-#include "cairo-boilerplate-private.h"
-
-#if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
-#include <cairo-glitz.h>
-#include <glitz-glx.h>
-
-static const cairo_user_data_key_t glitz_closure_key;
-
-typedef struct _glitz_glx_target_closure {
- Display *dpy;
- int scr;
- Window win;
-} glitz_glx_target_closure_t;
-
-static glitz_surface_t *
-_cairo_boilerplate_glitz_glx_create_surface_internal (glitz_format_name_t formatname,
- int width,
- int height,
- glitz_glx_target_closure_t *closure)
-{
- Display * dpy = closure->dpy;
- int scr = closure->scr;
- glitz_drawable_format_t templ;
- glitz_drawable_format_t * dformat = NULL;
- unsigned long mask;
- glitz_drawable_t * drawable = NULL;
- glitz_format_t * format;
- glitz_surface_t * sr;
-
- XSizeHints xsh;
- XSetWindowAttributes xswa;
- XVisualInfo * vinfo;
-
- memset(&templ, 0, sizeof(templ));
- templ.color.red_size = 8;
- templ.color.green_size = 8;
- templ.color.blue_size = 8;
- templ.color.alpha_size = 8;
- templ.color.fourcc = GLITZ_FOURCC_RGB;
- templ.samples = 1;
-
- glitz_glx_init (NULL);
-
- mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK |
- GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK |
- GLITZ_FORMAT_BLUE_SIZE_MASK;
- if (formatname == GLITZ_STANDARD_ARGB32)
- mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
-
- /* Try for a pbuffer first */
- if (!getenv("CAIRO_TEST_FORCE_GLITZ_WINDOW"))
- dformat = glitz_glx_find_pbuffer_format (dpy, scr, mask, &templ, 0);
-
- if (dformat) {
- closure->win = None;
-
- drawable = glitz_glx_create_pbuffer_drawable (dpy, scr, dformat,
- width, height);
- if (!drawable)
- goto FAIL;
- } else {
- /* No pbuffer, try window */
- dformat = glitz_glx_find_window_format (dpy, scr, mask, &templ, 0);
-
- if (!dformat)
- goto FAIL;
-
- vinfo = glitz_glx_get_visual_info_from_format(dpy,
- DefaultScreen(dpy),
- dformat);
-
- if (!vinfo)
- goto FAIL;
-
- xsh.flags = PSize;
- xsh.x = 0;
- xsh.y = 0;
- xsh.width = width;
- xsh.height = height;
-
- xswa.colormap = XCreateColormap (dpy, RootWindow(dpy, scr),
- vinfo->visual, AllocNone);
- closure->win = XCreateWindow (dpy, RootWindow(dpy, scr),
- xsh.x, xsh.y, xsh.width, xsh.height,
- 0, vinfo->depth, CopyFromParent,
- vinfo->visual, CWColormap, &xswa);
- XFree (vinfo);
-
- drawable =
- glitz_glx_create_drawable_for_window (dpy, scr,
- dformat, closure->win,
- width, height);
-
- if (!drawable)
- goto DESTROY_WINDOW;
- }
-
- format = glitz_find_standard_format (drawable, formatname);
- if (!format)
- goto DESTROY_DRAWABLE;
-
- sr = glitz_surface_create (drawable, format, width, height, 0, NULL);
- if (!sr)
- goto DESTROY_DRAWABLE;
-
- if (closure->win == None || dformat->doublebuffer) {
- glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_BACK_COLOR);
- } else {
- XMapWindow (closure->dpy, closure->win);
- glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
- }
-
- glitz_drawable_destroy (drawable);
-
- return sr;
-
- DESTROY_DRAWABLE:
- glitz_drawable_destroy (drawable);
- DESTROY_WINDOW:
- if (closure->win)
- XDestroyWindow (dpy, closure->win);
- FAIL:
- return NULL;
-}
-
-static cairo_surface_t *
-_cairo_boilerplate_glitz_glx_create_surface (const char *name,
- cairo_content_t content,
- double width,
- double height,
- double max_width,
- double max_height,
- cairo_boilerplate_mode_t mode,
- int id,
- void **closure)
-{
- glitz_glx_target_closure_t *gxtc;
- glitz_surface_t * glitz_surface;
- cairo_surface_t * surface = NULL;
- cairo_status_t status;
-
- *closure = gxtc = xmalloc (sizeof (glitz_glx_target_closure_t));
-
- if (width == 0)
- width = 1;
- if (height == 0)
- height = 1;
-
- gxtc->dpy = XOpenDisplay (getenv("CAIRO_TEST_GLITZ_DISPLAY"));
- if (!gxtc->dpy) {
- fprintf (stderr, "Failed to open display: %s\n", XDisplayName(0));
- goto FAIL;
- }
-
- XSynchronize (gxtc->dpy, 1);
-
- gxtc->scr = DefaultScreen(gxtc->dpy);
-
- switch (content) {
- case CAIRO_CONTENT_COLOR:
- glitz_surface = _cairo_boilerplate_glitz_glx_create_surface_internal (GLITZ_STANDARD_RGB24, width, height, gxtc);
- break;
- case CAIRO_CONTENT_COLOR_ALPHA:
- glitz_surface = _cairo_boilerplate_glitz_glx_create_surface_internal (GLITZ_STANDARD_ARGB32, width, height, gxtc);
- break;
- case CAIRO_CONTENT_ALPHA:
- default:
- fprintf (stderr, "Invalid content for glitz-glx test: %d\n", content);
- goto FAIL_CLOSE_DISPLAY;
- }
- if (!glitz_surface) {
- fprintf (stderr, "Failed to create glitz-glx surface\n");
- goto FAIL_CLOSE_DISPLAY;
- }
-
- surface = cairo_glitz_surface_create (glitz_surface);
- glitz_surface_destroy (glitz_surface);
-
- if (cairo_surface_status (surface))
- goto FAIL_CLOSE_DISPLAY;
-
- status = cairo_surface_set_user_data (surface,
- &glitz_closure_key, gxtc, NULL);
- if (status == CAIRO_STATUS_SUCCESS)
- return surface;
-
- cairo_surface_destroy (surface);
- surface = cairo_boilerplate_surface_create_in_error (status);
-
- FAIL_CLOSE_DISPLAY:
- glitz_glx_fini ();
- XCloseDisplay (gxtc->dpy);
- FAIL:
- free (gxtc);
- return surface;
-}
-
-static void
-_cairo_boilerplate_glitz_glx_cleanup (void *closure)
-{
- glitz_glx_target_closure_t *gxtc = closure;
-
- glitz_glx_fini ();
-
- if (gxtc->win)
- XDestroyWindow (gxtc->dpy, gxtc->win);
-
- XCloseDisplay (gxtc->dpy);
-
- free (gxtc);
-}
-
-#endif
-
-static const cairo_boilerplate_target_t targets[] = {
-#if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
- {
- "glitz-glx", "glitz", NULL, NULL,
- CAIRO_SURFACE_TYPE_GLITZ,CAIRO_CONTENT_COLOR_ALPHA, 0,
- "cairo_glitz_surface_create",
- _cairo_boilerplate_glitz_glx_create_surface,
- NULL, NULL,
- _cairo_boilerplate_get_image_surface,
- cairo_surface_write_to_png,
- _cairo_boilerplate_glitz_glx_cleanup
- },
- {
- "glitz-glx", "glitz", NULL, NULL,
- CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
- "cairo_glitz_surface_create",
- _cairo_boilerplate_glitz_glx_create_surface,
- NULL, NULL,
- _cairo_boilerplate_get_image_surface,
- cairo_surface_write_to_png,
- _cairo_boilerplate_glitz_glx_cleanup
- },
-#endif
-};
-CAIRO_BOILERPLATE (glitz_glx, targets)
diff --git a/boilerplate/cairo-boilerplate-glitz-wgl.c b/boilerplate/cairo-boilerplate-glitz-wgl.c
deleted file mode 100644
index f50d68b..0000000
--- a/boilerplate/cairo-boilerplate-glitz-wgl.c
+++ /dev/null
@@ -1,188 +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 <cworth@cworth.org>
- */
-
-#include "cairo-boilerplate-private.h"
-
-#if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
-#include <cairo-glitz.h>
-#include <glitz-wgl.h>
-
-static const cairo_user_data_key_t glitz_closure_key;
-
-typedef struct _glitz_wgl_target_closure {
- glitz_target_closure_base_t base;
-} glitz_wgl_target_closure_t;
-
-static glitz_surface_t *
-_cairo_boilerplate_glitz_wgl_create_surface_internal (glitz_format_name_t formatname,
- int width,
- int height,
- glitz_wgl_target_closure_t *closure)
-{
- glitz_drawable_format_t *dformat;
- glitz_drawable_format_t templ;
- glitz_drawable_t *gdraw;
- glitz_format_t *format;
- glitz_surface_t *sr = NULL;
- unsigned long mask;
-
- memset(&templ, 0, sizeof(templ));
- templ.color.red_size = 8;
- templ.color.green_size = 8;
- templ.color.blue_size = 8;
- templ.color.alpha_size = 8;
- templ.color.fourcc = GLITZ_FOURCC_RGB;
- templ.samples = 1;
-
- mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK |
- GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK |
- GLITZ_FORMAT_BLUE_SIZE_MASK;
- if (formatname == GLITZ_STANDARD_ARGB32)
- mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
-
- dformat = glitz_wgl_find_pbuffer_format (mask, &templ, 0);
- if (!dformat) {
- fprintf (stderr, "Glitz failed to find pbuffer format for template.");
- goto FAIL;
- }
-
- gdraw = glitz_wgl_create_pbuffer_drawable (dformat, width, height);
- if (!gdraw) {
- fprintf (stderr, "Glitz failed to create pbuffer drawable.");
- goto FAIL;
- }
-
- format = glitz_find_standard_format (gdraw, formatname);
- if (!format) {
- fprintf (stderr, "Glitz failed to find standard format for drawable.");
- goto DESTROY_DRAWABLE;
- }
-
- sr = glitz_surface_create (gdraw, format, width, height, 0, NULL);
- if (!sr) {
- fprintf (stderr, "Glitz failed to create a surface.");
- goto DESTROY_DRAWABLE;
- }
-
- glitz_surface_attach (sr, gdraw, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
-
- DESTROY_DRAWABLE:
- glitz_drawable_destroy (gdraw);
-
- FAIL:
- return sr; /* will be NULL unless we create it and attach */
-}
-
-static cairo_surface_t *
-_cairo_boilerplate_glitz_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,
- int id,
- void **closure)
-{
- glitz_surface_t *glitz_surface;
- cairo_surface_t *surface = NULL;
- glitz_wgl_target_closure_t *wglc;
-
- glitz_wgl_init (NULL);
-
- *closure = wglc = xmalloc (sizeof (glitz_wgl_target_closure_t));
-
- switch (content) {
- case CAIRO_CONTENT_COLOR:
- glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface_internal (GLITZ_STANDARD_RGB24, width, height, NULL);
- break;
- case CAIRO_CONTENT_COLOR_ALPHA:
- glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface_internal (GLITZ_STANDARD_ARGB32, width, height, NULL);
- break;
- default:
- fprintf (stderr, "Invalid content for glitz-wgl test: %d\n", content);
- goto FAIL;
- }
-
- if (!glitz_surface)
- goto FAIL;
-
- surface = cairo_glitz_surface_create (glitz_surface);
- glitz_surface_destroy (glitz_surface);
-
- if (cairo_surface_status (surface))
- goto FAIL;
-
- wglc->base.width = width;
- wglc->base.height = height;
- wglc->base.content = content;
- status = cairo_surface_set_user_data (surface,
- &glitz_closure_key, wglc, NULL);
- if (status == CAIRO_STATUS_SUCCESS)
- return surface;
-
- cairo_surface_destroy (surface);
- surface = cairo_boilerplate_surface_create_in_error (status);
-
- FAIL:
- glitz_wgl_fini ();
- free (wglc);
- return surface;
-}
-
-static void
-_cairo_boilerplate_glitz_wgl_cleanup (void *closure)
-{
- free (closure);
- glitz_wgl_fini ();
-}
-#endif
-
-static const cairo_boilerplate_target_t targets[] = {
-#if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
- {
- "glitz-wgl", "glitz", NULL, NULL,
- CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR_ALPHA, 0,
- "cairo_glitz_surface_create",
- _cairo_boilerplate_glitz_wgl_create_surface,
- NULL, NULL,
- _cairo_boilerplate_get_image_surface,
- cairo_surface_write_to_png,
- _cairo_boilerplate_glitz_wgl_cleanup
- },
- {
- "glitz-wgl", "glitz", NULL, NULL,
- CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
- "cairo_glitz_surface_create",
- _cairo_boilerplate_glitz_wgl_create_surface,
- NULL, NULL,
- _cairo_boilerplate_get_image_surface,
- cairo_surface_write_to_png,
- _cairo_boilerplate_glitz_wgl_cleanup
- },
-#endif
-};
-CAIRO_BOILERPLATE (glitz_wgl, targets)
diff --git a/build/Makefile.win32.features b/build/Makefile.win32.features
index 66938fc..b32e7fc 100644
--- a/build/Makefile.win32.features
+++ b/build/Makefile.win32.features
@@ -19,7 +19,6 @@ CAIRO_HAS_GALLIUM_SURFACE=0
CAIRO_HAS_XCB_DRM_FUNCTIONS=0
CAIRO_HAS_PNG_FUNCTIONS=1
CAIRO_HAS_GL_SURFACE=0
-CAIRO_HAS_GLITZ_SURFACE=0
CAIRO_HAS_DIRECTFB_SURFACE=0
CAIRO_HAS_VG_SURFACE=0
CAIRO_HAS_EAGLE_FUNCTIONS=0
diff --git a/build/Makefile.win32.features-h b/build/Makefile.win32.features-h
index ca21aba..c5df7bd 100644
--- a/build/Makefile.win32.features-h
+++ b/build/Makefile.win32.features-h
@@ -62,9 +62,6 @@ endif
ifeq ($(CAIRO_HAS_GL_SURFACE),1)
@echo "#define CAIRO_HAS_GL_SURFACE 1" >> src/cairo-features.h
endif
-ifeq ($(CAIRO_HAS_GLITZ_SURFACE),1)
- @echo "#define CAIRO_HAS_GLITZ_SURFACE 1" >> src/cairo-features.h
-endif
ifeq ($(CAIRO_HAS_DIRECTFB_SURFACE),1)
@echo "#define CAIRO_HAS_DIRECTFB_SURFACE 1" >> src/cairo-features.h
endif
diff --git a/build/configure.ac.features b/build/configure.ac.features
index 8c96ed0..c4c5bd9 100644
--- a/build/configure.ac.features
+++ b/build/configure.ac.features
@@ -374,7 +374,6 @@ AC_DEFUN([CAIRO_REPORT],
echo " PDF: $use_pdf"
echo " SVG: $use_svg"
echo " OpenGL: $use_gl"
- echo " glitz: $use_glitz"
echo " BeOS: $use_beos"
echo " DirectFB: $use_directfb"
echo " OpenVG: $use_vg"
diff --git a/configure.ac b/configure.ac
index 97b0ecf..2e8a8a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -336,44 +336,6 @@ CAIRO_ENABLE_SURFACE_BACKEND(gl, OpenGL, no, [
dnl ===========================================================================
-GLITZ_MIN_VERSION=0.5.1
-CAIRO_ENABLE_SURFACE_BACKEND(glitz, glitz, no, [
- glitz_REQUIRES="glitz >= $GLITZ_MIN_VERSION"
- PKG_CHECK_MODULES(glitz, $glitz_REQUIRES, , [AC_MSG_RESULT(no)
- use_glitz="no (requires $glitz_REQUIRES http://freedesktop.org/Software/glitz)"])
-])
-
-if test "x$use_glitz" = "xyes";then
- PKG_CHECK_MODULES(GLITZ_AGL, glitz-agl >= $GLITZ_MIN_VERSION,
- [have_glitz_agl=yes], [have_glitz_agl=no; AC_MSG_RESULT(no)])
- PKG_CHECK_MODULES(GLITZ_EGL, glitz-egl >= $GLITZ_MIN_VERSION,
- [have_glitz_egl=yes], [have_glitz_egl=no; AC_MSG_RESULT(no)])
- PKG_CHECK_MODULES(GLITZ_GLX, glitz-glx >= $GLITZ_MIN_VERSION,
- [have_glitz_glx=yes], [have_glitz_glx=no; AC_MSG_RESULT(no)])
- PKG_CHECK_MODULES(GLITZ_WGL, glitz-wgl >= $GLITZ_MIN_VERSION,
- [have_glitz_wgl=yes], [have_glitz_wgl=no; AC_MSG_RESULT(no)])
-
- if test "x$have_glitz_agl" = "xyes";then
- AC_DEFINE(CAIRO_CAN_TEST_GLITZ_AGL_SURFACE, 1, [define if glitz backend can be tested against agl])
- fi
- if test "x$have_glitz_egl" = "xyes";then
- AC_DEFINE(CAIRO_CAN_TEST_GLITZ_EGL_SURFACE, 1, [define if glitz backend can be tested against egl])
- fi
- if test "x$have_glitz_glx" = "xyes";then
- AC_DEFINE(CAIRO_CAN_TEST_GLITZ_GLX_SURFACE, 1, [define if glitz backend can be tested against glx])
- fi
- if test "x$have_glitz_wgl" = "xyes";then
- AC_DEFINE(CAIRO_CAN_TEST_GLITZ_WGL_SURFACE, 1, [define if glitz backend can be tested against wgl])
- fi
-fi
-
-AM_CONDITIONAL(CAIRO_CAN_TEST_GLITZ_AGL_SURFACE, test "x$have_glitz_agl" = "xyes")
-AM_CONDITIONAL(CAIRO_CAN_TEST_GLITZ_EGL_SURFACE, test "x$have_glitz_egl" = "xyes")
-AM_CONDITIONAL(CAIRO_CAN_TEST_GLITZ_GLX_SURFACE, test "x$have_glitz_glx" = "xyes")
-AM_CONDITIONAL(CAIRO_CAN_TEST_GLITZ_WGL_SURFACE, test "x$have_glitz_wgl" = "xyes")
-
-dnl ===========================================================================
-
CAIRO_ENABLE_SURFACE_BACKEND(directfb, directfb, no, [
directfb_REQUIRES=directfb
PKG_CHECK_MODULES(directfb, $directfb_REQUIRES, , AC_MSG_RESULT(no)
diff --git a/doc/public/cairo-docs.xml b/doc/public/cairo-docs.xml
index 487f8a8..25bbe07 100644
--- a/doc/public/cairo-docs.xml
+++ b/doc/public/cairo-docs.xml
@@ -31,7 +31,6 @@
<title>Surfaces</title>
<xi:include href="xml/cairo-surface.xml"/>
<xi:include href="xml/cairo-image.xml"/>
- <!--xi:include href="xml/cairo-glitz.xml"/-->
<xi:include href="xml/cairo-pdf.xml"/>
<xi:include href="xml/cairo-png.xml"/>
<xi:include href="xml/cairo-ps.xml"/>
diff --git a/doc/public/cairo-sections.txt b/doc/public/cairo-sections.txt
index ff89db7..302ffa0 100644
--- a/doc/public/cairo-sections.txt
+++ b/doc/public/cairo-sections.txt
@@ -559,7 +559,6 @@ cairo_matrix_destroy
cairo_matrix_copy
cairo_matrix_get_affine
cairo_set_target_surface
-cairo_set_target_glitz
cairo_set_target_image
cairo_set_target_pdf
cairo_set_target_png
diff --git a/doc/public/tmpl/cairo-glitz.sgml b/doc/public/tmpl/cairo-glitz.sgml
deleted file mode 100644
index f7270c2..0000000
--- a/doc/public/tmpl/cairo-glitz.sgml
+++ /dev/null
@@ -1,22 +0,0 @@
-<!-- ##### SECTION Title ##### -->
-Glitz Surfaces
-
-<!-- ##### SECTION Short_Description ##### -->
-OpenGL accelerated rendering using the Glitz library
-
-<!-- ##### SECTION Long_Description ##### -->
-<para>
-The Glitz surface is used to render cairo graphics targeting the
-OpenGL hardware using the Glitz library.
-</para>
-
-<!-- ##### SECTION See_Also ##### -->
-<para>
-<itemizedlist>
-<listitem>#cairo_surface_t</listitem>
-</itemizedlist>
-</para>
-
-<!-- ##### SECTION Stability_Level ##### -->
-
-
diff --git a/src/Makefile.sources b/src/Makefile.sources
index a7f5839..3cd6c48 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -318,10 +318,6 @@ cairo_gl_sources = cairo-gl-surface.c cairo-gl-glyphs.c cairo-gl-shaders.c
cairo_glx_sources += cairo-glx-context.c
cairo_eagle_sources += cairo-eagle-context.c
-cairo_glitz_headers = cairo-glitz.h
-cairo_glitz_private = cairo-glitz-private.h
-cairo_glitz_sources = cairo-glitz-surface.c
-
cairo_directfb_headers = cairo-directfb.h
cairo_directfb_sources = cairo-directfb-surface.c
diff --git a/src/Makefile.win32.features b/src/Makefile.win32.features
index daf88a7..5e73486 100644
--- a/src/Makefile.win32.features
+++ b/src/Makefile.win32.features
@@ -287,20 +287,6 @@ ifeq ($(CAIRO_HAS_GL_SURFACE),1)
enabled_cairo_pkgconf += cairo-gl.pc
endif
-unsupported_cairo_headers += $(cairo_glitz_headers)
-all_cairo_headers += $(cairo_glitz_headers)
-all_cairo_private += $(cairo_glitz_private)
-all_cairo_sources += $(cairo_glitz_sources)
-ifeq ($(CAIRO_HAS_GLITZ_SURFACE),1)
-enabled_cairo_headers += $(cairo_glitz_headers)
-enabled_cairo_private += $(cairo_glitz_private)
-enabled_cairo_sources += $(cairo_glitz_sources)
-endif
-all_cairo_pkgconf += cairo-glitz.pc
-ifeq ($(CAIRO_HAS_GLITZ_SURFACE),1)
-enabled_cairo_pkgconf += cairo-glitz.pc
-endif
-
unsupported_cairo_headers += $(cairo_directfb_headers)
all_cairo_headers += $(cairo_directfb_headers)
all_cairo_private += $(cairo_directfb_private)
diff --git a/src/cairo-deprecated.h b/src/cairo-deprecated.h
index b59ea64..6397cc4 100644
--- a/src/cairo-deprecated.h
+++ b/src/cairo-deprecated.h
@@ -123,7 +123,6 @@
#define cairo_matrix_copy cairo_matrix_copy_DEPRECATED_BY_cairo_matrix_t
#define cairo_matrix_get_affine cairo_matrix_get_affine_DEPRECATED_BY_cairo_matrix_t
#define cairo_set_target_surface cairo_set_target_surface_DEPRECATED_BY_cairo_create
-#define cairo_set_target_glitz cairo_set_target_glitz_DEPRECATED_BY_cairo_glitz_surface_create
#define cairo_set_target_image cairo_set_target_image_DEPRECATED_BY_cairo_image_surface_create_for_data
#define cairo_set_target_pdf cairo_set_target_pdf_DEPRECATED_BY_cairo_pdf_surface_create
#define cairo_set_target_png cairo_set_target_png_DEPRECATED_BY_cairo_surface_write_to_png
diff --git a/src/cairo-glitz-private.h b/src/cairo-glitz-private.h
deleted file mode 100644
index 8a876ee..0000000
--- a/src/cairo-glitz-private.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- */
-
-#ifndef CAIRO_GLITZ_PRIVATE_H
-#define CAIRO_GLITZ_PRIVATE_H
-
-#include "cairoint.h"
-#include "cairo-glitz.h"
-
-slim_hidden_proto (cairo_glitz_surface_create);
-
-#endif /* CAIRO_GLITZ_PRIVATE_H */
diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
deleted file mode 100644
index 0aabed9..0000000
--- a/src/cairo-glitz-surface.c
+++ /dev/null
@@ -1,2450 +0,0 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 David Reveman
- *
- * 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 David
- * Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. David Reveman makes no representations about the
- * suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL DAVID REVEMAN 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: David Reveman <davidr@novell.com>
- */
-
-#include "cairoint.h"
-#include "cairo-glitz.h"
-#include "cairo-glitz-private.h"
-
-#include "cairo-error-private.h"
-#include "cairo-region-private.h"
-
-typedef struct _cairo_glitz_surface {
- cairo_surface_t base;
-
- glitz_surface_t *surface;
- glitz_format_t *format;
-
- cairo_region_t *clip_region;
- cairo_bool_t has_clip;
- glitz_box_t *clip_boxes;
- int num_clip_boxes;
-} cairo_glitz_surface_t;
-
-static const cairo_surface_backend_t *
-_cairo_glitz_surface_get_backend (void);
-
-static cairo_status_t
-_cairo_glitz_surface_finish (void *abstract_surface)
-{
- cairo_glitz_surface_t *surface = abstract_surface;
-
- if (surface->clip_boxes)
- free (surface->clip_boxes);
-
- cairo_region_destroy (surface->clip_region);
- glitz_surface_destroy (surface->surface);
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-static glitz_format_name_t
-_glitz_format_from_content (cairo_content_t content)
-{
- switch (content) {
- case CAIRO_CONTENT_COLOR:
- return GLITZ_STANDARD_RGB24;
- case CAIRO_CONTENT_ALPHA:
- return GLITZ_STANDARD_A8;
- case CAIRO_CONTENT_COLOR_ALPHA:
- return GLITZ_STANDARD_ARGB32;
- }
-
- ASSERT_NOT_REACHED;
- return GLITZ_STANDARD_ARGB32;
-}
-
-static cairo_surface_t *
-_cairo_glitz_surface_create_similar (void *abstract_src,
- cairo_content_t content,
- int width,
- int height)
-{
- cairo_glitz_surface_t *src = abstract_src;
- cairo_surface_t *crsurface;
- glitz_drawable_t *drawable;
- glitz_surface_t *surface;
- glitz_format_t *gformat;
-
- drawable = glitz_surface_get_drawable (src->surface);
-
- gformat =
- glitz_find_standard_format (drawable,
- _glitz_format_from_content (content));
- if (!gformat)
- return NULL;
-
- surface = glitz_surface_create (drawable, gformat,
- width <= 0 ? 1 : width,
- height <= 0 ? 1 : height,
- 0, NULL);
-
- if (surface == NULL)
- return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
-
- crsurface = cairo_glitz_surface_create (surface);
-
- glitz_surface_destroy (surface);
-
- return crsurface;
-}
-
-static cairo_status_t
-_cairo_glitz_surface_get_image (cairo_glitz_surface_t *surface,
- cairo_rectangle_int_t *interest,
- cairo_image_surface_t **image_out,
- cairo_rectangle_int_t *rect_out)
-{
- cairo_image_surface_t *image;
- cairo_rectangle_int_t extents;
- cairo_format_t format;
- cairo_format_masks_t masks;
- glitz_buffer_t *buffer;
- glitz_pixel_format_t pf;
-
- extents.x = 0;
- extents.y = 0;
- extents.width = glitz_surface_get_width (surface->surface);
- extents.height = glitz_surface_get_height (surface->surface);
-
- if (interest != NULL) {
- if (! _cairo_rectangle_intersect (&extents, interest)) {
- *image_out = NULL;
- return CAIRO_STATUS_SUCCESS;
- }
- }
-
- if (rect_out != NULL)
- *rect_out = extents;
-
- if (surface->format->color.fourcc == GLITZ_FOURCC_RGB) {
- if (surface->format->color.red_size > 0) {
- if (surface->format->color.alpha_size > 0)
- format = CAIRO_FORMAT_ARGB32;
- else
- format = CAIRO_FORMAT_RGB24;
- } else {
- format = CAIRO_FORMAT_A8;
- }
- } else
- format = CAIRO_FORMAT_ARGB32;
-
- image = (cairo_image_surface_t*)
- cairo_image_surface_create (format, extents.width, extents.height);
- if (image->base.status)
- return image->base.status;
-
- _pixman_format_to_masks (image->pixman_format, &masks);
- pf.fourcc = GLITZ_FOURCC_RGB;
- pf.masks.bpp = masks.bpp;
- pf.masks.alpha_mask = masks.alpha_mask;
- pf.masks.red_mask = masks.red_mask;
- pf.masks.green_mask = masks.green_mask;
- pf.masks.blue_mask = masks.blue_mask;
- pf.xoffset = 0;
- pf.skip_lines = 0;
-
- /* XXX: we should eventually return images with negative stride,
- need to verify that libpixman have no problem with this first. */
- pf.bytes_per_line = image->stride;
- pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
-
- buffer = glitz_buffer_create_for_data (image->data);
- if (buffer == NULL) {
- cairo_surface_destroy (&image->base);
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- }
-
- /* clear out the glitz clip; the clip affects glitz_get_pixels */
- if (surface->has_clip)
- glitz_surface_set_clip_region (surface->surface,
- 0, 0, NULL, 0);
-
- glitz_get_pixels (surface->surface,
- extents.x, extents.y,
- extents.width, extents.height,
- &pf,
- buffer);
-
- glitz_buffer_destroy (buffer);
-
- /* restore the clip, if any */
- if (surface->has_clip) {
- glitz_surface_set_clip_region (surface->surface,
- 0, 0,
- surface->clip_boxes,
- surface->num_clip_boxes);
- }
-
- *image_out = image;
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-static cairo_status_t
-_cairo_glitz_surface_set_image (void *abstract_surface,
- cairo_image_surface_t *image,
- int src_x,
- int src_y,
- int width,
- int height,
- int x_dst,
- int y_dst)
-{
- cairo_glitz_surface_t *surface = abstract_surface;
- glitz_buffer_t *buffer;
- glitz_pixel_format_t pf;
- cairo_format_masks_t masks;
- char *data;
-
- _pixman_format_to_masks (image->pixman_format, &masks);
-
- pf.fourcc = GLITZ_FOURCC_RGB;
- pf.masks.bpp = masks.bpp;
- pf.masks.alpha_mask = masks.alpha_mask;
- pf.masks.red_mask = masks.red_mask;
- pf.masks.green_mask = masks.green_mask;
- pf.masks.blue_mask = masks.blue_mask;
- pf.xoffset = src_x;
- pf.skip_lines = src_y;
-
- /* check for negative stride */
- if (image->stride < 0) {
- pf.bytes_per_line = -image->stride;
- pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
- data = (char *) image->data + image->stride * (image->height - 1);
- } else {
- pf.bytes_per_line = image->stride;
- pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
- data = (char *) image->data;
- }
-
- buffer = glitz_buffer_create_for_data (data);
- if (buffer == NULL)
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
- glitz_set_pixels (surface->surface,
- x_dst, y_dst,
- width, height,
- &pf,
- buffer);
-
- glitz_buffer_destroy (buffer);
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-static cairo_status_t
-_cairo_glitz_surface_acquire_source_image (void *abstract_surface,
- cairo_image_surface_t **image_out,
- void **image_extra)
-{
- cairo_glitz_surface_t *surface = abstract_surface;
-
- *image_extra = NULL;
-
- return _cairo_glitz_surface_get_image (surface, NULL, image_out, NULL);
-}
-
-static cairo_surface_t *
-_cairo_glitz_surface_snapshot (void *abstract_surface)
-{
- cairo_glitz_surface_t *surface = abstract_surface;
- cairo_status_t status;
- cairo_image_surface_t *image;
-
- status = _cairo_glitz_surface_get_image (surface, NULL, &image, NULL);
- if (unlikely (status))
- return _cairo_surface_create_in_error (status);
-
- return &image->base;
-}
-
-static void
-_cairo_glitz_surface_release_source_image (void *abstract_surface,
- cairo_image_surface_t *image,
- void *image_extra)
-{
- cairo_surface_destroy (&image->base);
-}
-
-static cairo_status_t
-_cairo_glitz_surface_acquire_dest_image (void *abstract_surface,
- cairo_rectangle_int_t *interest_rect,
- cairo_image_surface_t **image_out,
- cairo_rectangle_int_t *image_rect_out,
- void **image_extra)
-{
- cairo_glitz_surface_t *surface = abstract_surface;
- cairo_image_surface_t *image;
- cairo_status_t status;
-
- status = _cairo_glitz_surface_get_image (surface, interest_rect, &image,
- image_rect_out);
- if (status)
- return status;
-
- *image_out = image;
- *image_extra = NULL;
-
- return status;
-}
-
-static void
-_cairo_glitz_surface_release_dest_image (void *abstract_surface,
- cairo_rectangle_int_t *interest_rect,
- cairo_image_surface_t *image,
- cairo_rectangle_int_t *image_rect,
- void *image_extra)
-{
- cairo_glitz_surface_t *surface = abstract_surface;
- cairo_status_t status;
-
- status = _cairo_glitz_surface_set_image (surface, image, 0, 0,
- image->width, image->height,
- image_rect->x, image_rect->y);
- if (status)
- status = _cairo_surface_set_error (&surface->base, status);
-
- cairo_surface_destroy (&image->base);
-}
-
-static cairo_status_t
-_cairo_glitz_surface_clone_similar (void *abstract_surface,
- cairo_surface_t *src,
- int src_x,
- int src_y,
- int width,
- int height,
- int *clone_offset_x,
- int *clone_offset_y,
- cairo_surface_t **clone_out)
-{
- cairo_glitz_surface_t *surface = abstract_surface;
- cairo_glitz_surface_t *clone;
- cairo_status_t status;
-
- if (surface->base.status)
- return surface->base.status;
-
- if (src->backend == surface->base.backend)
- {
- *clone_offset_x = 0;
- *clone_offset_y = 0;
- *clone_out = cairo_surface_reference (src);
-
- return CAIRO_STATUS_SUCCESS;
- }
- else if (_cairo_surface_is_image (src))
- {
- cairo_image_surface_t *image_src = (cairo_image_surface_t *) src;
-
- clone = (cairo_glitz_surface_t *)
- _cairo_glitz_surface_create_similar (surface, src->content,
- width, height);
- if (clone == NULL)
- return CAIRO_INT_STATUS_UNSUPPORTED;
- if (clone->base.status)
- return clone->base.status;
-
- status = _cairo_glitz_surface_set_image (clone, image_src,
- src_x, src_y,
- width, height,
- 0, 0);
- if (status) {
- cairo_surface_destroy (&clone->base);
- return status;
- }
-
- *clone_out = &clone->base;
- *clone_offset_x = src_x;
- *clone_offset_y = src_y;
- return CAIRO_STATUS_SUCCESS;
- }
-
- return CAIRO_INT_STATUS_UNSUPPORTED;
-}
-
-static void
-_cairo_glitz_surface_set_matrix (cairo_glitz_surface_t *surface,
- cairo_matrix_t *matrix)
-{
- glitz_transform_t transform;
-
- transform.matrix[0][0] = _cairo_fixed_16_16_from_double (matrix->xx);
- transform.matrix[0][1] = _cairo_fixed_16_16_from_double (matrix->xy);
- transform.matrix[0][2] = _cairo_fixed_16_16_from_double (matrix->x0);
-
- transform.matrix[1][0] = _cairo_fixed_16_16_from_double (matrix->yx);
- transform.matrix[1][1] = _cairo_fixed_16_16_from_double (matrix->yy);
- transform.matrix[1][2] = _cairo_fixed_16_16_from_double (matrix->y0);
-
- transform.matrix[2][0] = 0;
- transform.matrix[2][1] = 0;
- transform.matrix[2][2] = _cairo_fixed_16_16_from_double (1);
-
- glitz_surface_set_transform (surface->surface, &transform);
-}
-
-static cairo_bool_t
-_is_supported_operator (cairo_operator_t op)
-{
- /* This is really just a if (op < SATURATE), but we use a switch
- * so the compiler will warn if we ever add more operators.
- */
- switch (op) {
- case CAIRO_OPERATOR_CLEAR:
- case CAIRO_OPERATOR_SOURCE:
- case CAIRO_OPERATOR_OVER:
- case CAIRO_OPERATOR_IN:
- case CAIRO_OPERATOR_OUT:
- case CAIRO_OPERATOR_ATOP:
- case CAIRO_OPERATOR_DEST:
- case CAIRO_OPERATOR_DEST_OVER:
- case CAIRO_OPERATOR_DEST_IN:
- case CAIRO_OPERATOR_DEST_OUT:
- case CAIRO_OPERATOR_DEST_ATOP:
- case CAIRO_OPERATOR_XOR:
- case CAIRO_OPERATOR_ADD:
- return TRUE;
-
- default:
- ASSERT_NOT_REACHED;
- case CAIRO_OPERATOR_SATURATE:
- /* nobody likes saturate, expect that it's required to do
- * seamless polygons!
- */
- case CAIRO_OPERATOR_MULTIPLY:
- case CAIRO_OPERATOR_SCREEN:
- case CAIRO_OPERATOR_OVERLAY:
- case CAIRO_OPERATOR_DARKEN:
- case CAIRO_OPERATOR_LIGHTEN:
- case CAIRO_OPERATOR_COLOR_DODGE:
- case CAIRO_OPERATOR_COLOR_BURN:
- case CAIRO_OPERATOR_HARD_LIGHT:
- case CAIRO_OPERATOR_SOFT_LIGHT:
- case CAIRO_OPERATOR_DIFFERENCE:
- case CAIRO_OPERATOR_EXCLUSION:
- case CAIRO_OPERATOR_HSL_HUE:
- case CAIRO_OPERATOR_HSL_SATURATION:
- case CAIRO_OPERATOR_HSL_COLOR:
- case CAIRO_OPERATOR_HSL_LUMINOSITY:
- return FALSE;
- }
-}
-
-static glitz_operator_t
-_glitz_operator (cairo_operator_t op)
-{
- switch ((int) op) {
- case CAIRO_OPERATOR_CLEAR:
- return GLITZ_OPERATOR_CLEAR;
-
- case CAIRO_OPERATOR_SOURCE:
- return GLITZ_OPERATOR_SRC;
- case CAIRO_OPERATOR_OVER:
- return GLITZ_OPERATOR_OVER;
- case CAIRO_OPERATOR_IN:
- return GLITZ_OPERATOR_IN;
- case CAIRO_OPERATOR_OUT:
- return GLITZ_OPERATOR_OUT;
- case CAIRO_OPERATOR_ATOP:
- return GLITZ_OPERATOR_ATOP;
-
- case CAIRO_OPERATOR_DEST:
- return GLITZ_OPERATOR_DST;
- case CAIRO_OPERATOR_DEST_OVER:
- return GLITZ_OPERATOR_OVER_REVERSE;
- case CAIRO_OPERATOR_DEST_IN:
- return GLITZ_OPERATOR_IN_REVERSE;
- case CAIRO_OPERATOR_DEST_OUT:
- return GLITZ_OPERATOR_OUT_REVERSE;
- case CAIRO_OPERATOR_DEST_ATOP:
- return GLITZ_OPERATOR_ATOP_REVERSE;
-
- case CAIRO_OPERATOR_XOR:
- return GLITZ_OPERATOR_XOR;
- case CAIRO_OPERATOR_ADD:
- return GLITZ_OPERATOR_ADD;
-
- default:
- ASSERT_NOT_REACHED;
-
- /* Something's very broken if this line of code can be reached, so
- * we want to return something that would give a noticeably
- * incorrect result. The XOR operator seems so rearely desired
- * that it should fit the bill here.
- */
- return CAIRO_OPERATOR_XOR;
- }
-}
-
-#define CAIRO_GLITZ_FEATURE_OK(surface, name) \
- (glitz_drawable_get_features (glitz_surface_get_drawable (surface)) & \
- (GLITZ_FEATURE_ ## name ## _MASK))
-
-static glitz_status_t
-_glitz_ensure_target (glitz_surface_t *surface)
-{
- if (!glitz_surface_get_attached_drawable (surface))
- {
- glitz_drawable_format_t *target_format, templ;
- glitz_format_t *format;
- glitz_drawable_t *drawable, *target;
- unsigned int width, height;
- unsigned long mask;
-
- drawable = glitz_surface_get_drawable (surface);
- format = glitz_surface_get_format (surface);
- width = glitz_surface_get_width (surface);
- height = glitz_surface_get_height (surface);
-
- if (format->color.fourcc != GLITZ_FOURCC_RGB)
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- templ.color = format->color;
- templ.depth_size = 0;
- templ.stencil_size = 0;
- templ.doublebuffer = 0;
- templ.samples = 1;
-
- mask =
- GLITZ_FORMAT_RED_SIZE_MASK |
- GLITZ_FORMAT_GREEN_SIZE_MASK |
- GLITZ_FORMAT_BLUE_SIZE_MASK |
- GLITZ_FORMAT_ALPHA_SIZE_MASK |
- GLITZ_FORMAT_DEPTH_SIZE_MASK |
- GLITZ_FORMAT_STENCIL_SIZE_MASK |
- GLITZ_FORMAT_DOUBLEBUFFER_MASK |
- GLITZ_FORMAT_SAMPLES_MASK;
-
- target_format = glitz_find_drawable_format (drawable, mask, &templ, 0);
- if (!target_format)
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- target = glitz_create_drawable (drawable, target_format,
- width, height);
- if (!target)
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- glitz_surface_attach (surface, target,
- GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
-
- glitz_drawable_destroy (target);
- }
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-typedef struct _cairo_glitz_surface_attributes {
- cairo_surface_attributes_t base;
-
- glitz_fill_t fill;
- glitz_filter_t filter;
- glitz_fixed16_16_t *params;
- int n_params;
- cairo_bool_t acquired;
-} cairo_glitz_surface_attributes_t;
-
-static cairo_int_status_t
-_cairo_glitz_pattern_acquire_surface (const cairo_pattern_t *pattern,
- cairo_glitz_surface_t *dst,
- int x,
- int y,
- unsigned int width,
- unsigned int height,
- cairo_glitz_surface_t **surface_out,
- cairo_glitz_surface_attributes_t *attr)
-{
- cairo_glitz_surface_t *src = NULL;
-
- attr->acquired = FALSE;
-
- switch (pattern->type) {
- case CAIRO_PATTERN_TYPE_LINEAR:
- case CAIRO_PATTERN_TYPE_RADIAL: {
- cairo_gradient_pattern_t *gradient =
- (cairo_gradient_pattern_t *) pattern;
- char *data;
- glitz_fixed16_16_t *params;
- unsigned int n_params;
- unsigned int *pixels;
- unsigned int i, n_base_params;
- glitz_buffer_t *buffer;
- static const glitz_pixel_format_t format = {
- GLITZ_FOURCC_RGB,
- {
- 32,
- 0xff000000,
- 0x00ff0000,
- 0x0000ff00,
- 0x000000ff
- },
- 0, 0, 0,
- GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP
- };
-
- /* XXX: the current color gradient acceleration provided by glitz is
- * experimental, it's been proven inappropriate in a number of ways,
- * most importantly, it's currently implemented as filters and
- * gradients are not filters. eventually, it will be replaced with
- * something more appropriate.
- */
-
- if (gradient->n_stops < 2)
- break;
-
- if (!CAIRO_GLITZ_FEATURE_OK (dst->surface, FRAGMENT_PROGRAM))
- break;
-
- if (pattern->type == CAIRO_PATTERN_TYPE_RADIAL)
- n_base_params = 6;
- else
- n_base_params = 4;
-
- n_params = gradient->n_stops * 3 + n_base_params;
-
- /* check for int overflow */
- {
- int size1, size2;
- if (n_params >= INT32_MAX / sizeof (glitz_fixed16_16_t) ||
- gradient->n_stops >= INT32_MAX / sizeof (unsigned int))
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
- size1 = n_params * sizeof (glitz_fixed16_16_t);
- size2 = gradient->n_stops * sizeof (unsigned int);
-
- if (size1 >= INT32_MAX - size2)
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
- data = malloc (size1 + size2);
- }
-
- if (!data)
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
- params = (glitz_fixed16_16_t *) data;
- pixels = (unsigned int *)
- (data + sizeof (glitz_fixed16_16_t) * n_params);
-
- buffer = glitz_buffer_create_for_data (pixels);
- if (!buffer) {
- free (data);
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- }
-
- src = (cairo_glitz_surface_t *)
- _cairo_glitz_surface_create_similar (&dst->base,
- CAIRO_CONTENT_COLOR_ALPHA,
- gradient->n_stops, 1);
- if (src->base.status) {
- glitz_buffer_destroy (buffer);
- free (data);
- return src->base.status;
- }
-
- for (i = 0; i < gradient->n_stops; i++)
- {
- pixels[i] =
- (((int) (gradient->stops[i].color.alpha_short >> 8)) << 24) |
- (((int) (gradient->stops[i].color.red_short >> 8)) << 16) |
- (((int) (gradient->stops[i].color.green_short >> 8)) << 8) |
- (((int) (gradient->stops[i].color.blue_short >> 8)));
-
- params[n_base_params + 3 * i + 0] = _cairo_fixed_16_16_from_double (gradient->stops[i].offset);
- params[n_base_params + 3 * i + 1] = i << 16;
- params[n_base_params + 3 * i + 2] = 0;
- }
-
- glitz_set_pixels (src->surface, 0, 0, gradient->n_stops, 1,
- (glitz_pixel_format_t *)&format, buffer);
-
- glitz_buffer_destroy (buffer);
-
- if (pattern->type == CAIRO_PATTERN_TYPE_LINEAR)
- {
- cairo_linear_pattern_t *grad = (cairo_linear_pattern_t *) pattern;
-
- params[0] = _cairo_fixed_to_16_16 (grad->p1.x);
- params[1] = _cairo_fixed_to_16_16 (grad->p1.y);
- params[2] = _cairo_fixed_to_16_16 (grad->p2.x);
- params[3] = _cairo_fixed_to_16_16 (grad->p2.y);
- attr->filter = GLITZ_FILTER_LINEAR_GRADIENT;
- }
- else
- {
- cairo_radial_pattern_t *grad = (cairo_radial_pattern_t *) pattern;
-
- params[0] = _cairo_fixed_to_16_16 (grad->c1.x);
- params[1] = _cairo_fixed_to_16_16 (grad->c1.y);
- params[2] = _cairo_fixed_to_16_16 (grad->r1);
- params[3] = _cairo_fixed_to_16_16 (grad->c2.x);
- params[4] = _cairo_fixed_to_16_16 (grad->c2.y);
- params[5] = _cairo_fixed_to_16_16 (grad->r2);
- attr->filter = GLITZ_FILTER_RADIAL_GRADIENT;
- }
-
- switch (pattern->extend) {
- case CAIRO_EXTEND_NONE:
- attr->fill = GLITZ_FILL_TRANSPARENT;
- break;
- case CAIRO_EXTEND_REPEAT:
- attr->fill = GLITZ_FILL_REPEAT;
- break;
- case CAIRO_EXTEND_REFLECT:
- attr->fill = GLITZ_FILL_REFLECT;
- break;
- case CAIRO_EXTEND_PAD:
- attr->fill = GLITZ_FILL_NEAREST;
- break;
- }
-
- attr->params = params;
- attr->n_params = n_params;
- attr->base.matrix = pattern->matrix;
- attr->base.x_offset = 0;
- attr->base.y_offset = 0;
- } break;
- case CAIRO_PATTERN_TYPE_SOLID:
- case CAIRO_PATTERN_TYPE_SURFACE:
- default:
- break;
- }
-
- if (!src)
- {
- cairo_int_status_t status;
-
- status = _cairo_pattern_acquire_surface (pattern, &dst->base,
- x, y, width, height,
- CAIRO_PATTERN_ACQUIRE_NONE,
- (cairo_surface_t **) &src,
- &attr->base);
- if (status)
- return status;
-
- if (src)
- {
- switch (attr->base.extend) {
- case CAIRO_EXTEND_NONE:
- attr->fill = GLITZ_FILL_TRANSPARENT;
- break;
- case CAIRO_EXTEND_REPEAT:
- attr->fill = GLITZ_FILL_REPEAT;
- break;
- case CAIRO_EXTEND_REFLECT:
- attr->fill = GLITZ_FILL_REFLECT;
- break;
- case CAIRO_EXTEND_PAD:
- default:
- attr->fill = GLITZ_FILL_NEAREST;
- break;
- }
-
- switch (attr->base.filter) {
- case CAIRO_FILTER_FAST:
- case CAIRO_FILTER_NEAREST:
- attr->filter = GLITZ_FILTER_NEAREST;
- break;
- case CAIRO_FILTER_GOOD:
- case CAIRO_FILTER_BEST:
- case CAIRO_FILTER_BILINEAR:
- case CAIRO_FILTER_GAUSSIAN:
- default:
- attr->filter = GLITZ_FILTER_BILINEAR;
- break;
- }
-
- attr->params = NULL;
- attr->n_params = 0;
- attr->acquired = TRUE;
- }
- }
-
- *surface_out = src;
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-static void
-_cairo_glitz_pattern_release_surface (const cairo_pattern_t *pattern,
- cairo_glitz_surface_t *surface,
- cairo_glitz_surface_attributes_t *attr)
-{
- if (attr->acquired)
- _cairo_pattern_release_surface (pattern, &surface->base, &attr->base);
- else
- cairo_surface_destroy (&surface->base);
-}
-
-static cairo_int_status_t
-_cairo_glitz_pattern_acquire_surfaces (const cairo_pattern_t *src,
- const cairo_pattern_t *mask,
- cairo_glitz_surface_t *dst,
- int src_x,
- int src_y,
- int mask_x,
- int mask_y,
- unsigned int width,
- unsigned int height,
- cairo_glitz_surface_t **src_out,
- cairo_glitz_surface_t **mask_out,
- cairo_glitz_surface_attributes_t *sattr,
- cairo_glitz_surface_attributes_t *mattr)
-{
- cairo_int_status_t status;
- cairo_solid_pattern_t tmp;
-
- /* If src and mask are both solid, then the mask alpha can be
- * combined into src and mask can be ignored. */
-
- /* XXX: This optimization assumes that there is no color
- * information in mask, so this will need to change when we
- * support RENDER-style 4-channel masks. */
-
- if (src->type == CAIRO_PATTERN_TYPE_SOLID &&
- mask->type == CAIRO_PATTERN_TYPE_SOLID)
- {
- cairo_color_t combined;
- cairo_solid_pattern_t *src_solid = (cairo_solid_pattern_t *) src;
- cairo_solid_pattern_t *mask_solid = (cairo_solid_pattern_t *) mask;
-
- combined = src_solid->color;
- _cairo_color_multiply_alpha (&combined, mask_solid->color.alpha);
-
- _cairo_pattern_init_solid (&tmp, &combined, CAIRO_CONTENT_COLOR_ALPHA);
-
- mask = NULL;
- src = &tmp.base;
- }
-
- status = _cairo_glitz_pattern_acquire_surface (src, dst,
- src_x, src_y,
- width, height,
- src_out, sattr);
-
- if (src == &tmp.base)
- _cairo_pattern_fini (&tmp.base);
-
- if (status)
- return status;
-
- if (mask)
- {
- status = _cairo_glitz_pattern_acquire_surface (mask, dst,
- mask_x, mask_y,
- width, height,
- mask_out, mattr);
-
- if (status) {
- /* XXX src == &tmp.base -> invalid (currently inconsequential) */
- _cairo_glitz_pattern_release_surface (src, *src_out, sattr);
- }
-
- return status;
- }
- else
- {
- *mask_out = NULL;
- }
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-static void
-_cairo_glitz_surface_set_attributes (cairo_glitz_surface_t *surface,
- cairo_glitz_surface_attributes_t *a)
-{
- _cairo_glitz_surface_set_matrix (surface, &a->base.matrix);
- glitz_surface_set_fill (surface->surface, a->fill);
- glitz_surface_set_filter (surface->surface, a->filter,
- a->params, a->n_params);
-}
-
-static cairo_status_t
-_cairo_glitz_get_boxes_from_region (cairo_region_t *region,
- glitz_box_t **boxes,
- int *nboxes)
-{
- pixman_box32_t *pboxes;
- cairo_status_t status = CAIRO_STATUS_SUCCESS;
-
- int n, i;
-
- n = 0;
- pboxes = pixman_region32_rectangles (&region->rgn, &n);
- if (n == 0) {
- *nboxes = 0;
- return CAIRO_STATUS_SUCCESS;
- }
-
- if (n > *nboxes) {
- *boxes = _cairo_malloc_ab (n, sizeof (glitz_box_t));
- if (*boxes == NULL) {
- status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
- goto done;
- }
- }
-
- for (i = 0; i < n; i++) {
- (*boxes)[i].x1 = pboxes[i].x1;
- (*boxes)[i].y1 = pboxes[i].y1;
- (*boxes)[i].x2 = pboxes[i].x2;
- (*boxes)[i].y2 = pboxes[i].y2;
- }
-
- *nboxes = n;
-done:
- return status;
-}
-
-static cairo_status_t
-_cairo_glitz_surface_set_clip_region (void *abstract_surface,
- cairo_region_t *region)
-{
- cairo_glitz_surface_t *surface = abstract_surface;
-
- if (region == surface->clip_region)
- return CAIRO_STATUS_SUCCESS;
-
- cairo_region_destroy (surface->clip_region);
- surface->clip_region = cairo_region_reference (region);
-
- if (region != NULL) {
- cairo_status_t status;
-
- status = _cairo_glitz_get_boxes_from_region (region,
- &surface->clip_boxes,
- &surface->num_clip_boxes);
- if (status)
- return status;
-
- glitz_surface_set_clip_region (surface->surface,
- 0, 0,
- surface->clip_boxes,
- surface->num_clip_boxes);
- surface->has_clip = TRUE;
- } else {
- glitz_surface_set_clip_region (surface->surface, 0, 0, NULL, 0);
- surface->has_clip = FALSE;
- }
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-static cairo_int_status_t
-_cairo_glitz_surface_composite (cairo_operator_t op,
- const cairo_pattern_t *src_pattern,
- const cairo_pattern_t *mask_pattern,
- void *abstract_dst,
- int src_x,
- int src_y,
- int mask_x,
- int mask_y,
- int dst_x,
- int dst_y,
- unsigned int width,
- unsigned int height,
- cairo_region_t *clip_region)
-{
- cairo_glitz_surface_attributes_t src_attr, mask_attr;
- cairo_glitz_surface_t *dst = abstract_dst;
- cairo_glitz_surface_t *src;
- cairo_glitz_surface_t *mask;
- cairo_int_status_t status;
-
- if (! _is_supported_operator (op))
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- if (_glitz_ensure_target (dst->surface))
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- status = _cairo_glitz_surface_set_clip_region (dst, clip_region);
- if (status)
- return status;
-
- status = _cairo_glitz_pattern_acquire_surfaces (src_pattern, mask_pattern,
- dst,
- src_x, src_y,
- mask_x, mask_y,
- width, height,
- &src, &mask,
- &src_attr, &mask_attr);
- if (status)
- return status;
-
- _cairo_glitz_surface_set_attributes (src, &src_attr);
- if (mask)
- {
- _cairo_glitz_surface_set_attributes (mask, &mask_attr);
- glitz_composite (_glitz_operator (op),
- src->surface,
- mask->surface,
- dst->surface,
- src_x + src_attr.base.x_offset,
- src_y + src_attr.base.y_offset,
- mask_x + mask_attr.base.x_offset,
- mask_y + mask_attr.base.y_offset,
- dst_x, dst_y,
- width, height);
- }
- else
- {
- glitz_composite (_glitz_operator (op),
- src->surface,
- NULL,
- dst->surface,
- src_x + src_attr.base.x_offset,
- src_y + src_attr.base.y_offset,
- 0, 0,
- dst_x, dst_y,
- width, height);
- }
-
- if (glitz_surface_get_status (dst->surface) == GLITZ_STATUS_NOT_SUPPORTED)
- status = CAIRO_INT_STATUS_UNSUPPORTED;
-
- if (status == CAIRO_STATUS_SUCCESS &&
- ! _cairo_operator_bounded_by_source (op))
- {
- int src_width, src_height;
- int mask_width, mask_height;
-
- src_width = glitz_surface_get_width (src->surface);
- src_height = glitz_surface_get_height (src->surface);
- if (mask)
- {
- mask_width = glitz_surface_get_width (mask->surface);
- mask_height = glitz_surface_get_height (mask->surface);
- }
- else
- {
- mask_width = 0;
- mask_height = 0;
- }
- status = _cairo_surface_composite_fixup_unbounded (&dst->base,
- &src_attr.base,
- src_width, src_height,
- mask ? &mask_attr.base : NULL,
- mask_width, mask_height,
- src_x, src_y,
- mask_x, mask_y,
- dst_x, dst_y, width, height,
- clip_region);
- }
-
- if (mask)
- {
- if (mask_attr.n_params)
- free (mask_attr.params);
-
- _cairo_glitz_pattern_release_surface (mask_pattern, mask, &mask_attr);
- }
-
- if (src_attr.n_params)
- free (src_attr.params);
-
- _cairo_glitz_pattern_release_surface (src_pattern, src, &src_attr);
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-static cairo_int_status_t
-_cairo_glitz_surface_fill_rectangles (void *abstract_dst,
- cairo_operator_t op,
- const cairo_color_t *color,
- cairo_rectangle_int_t *rects,
- int n_rects)
-{
- cairo_glitz_surface_t *dst = abstract_dst;
- cairo_glitz_surface_t *src;
- glitz_rectangle_t stack_rects[CAIRO_STACK_ARRAY_LENGTH (glitz_rectangle_t)];
- glitz_rectangle_t *glitz_rects = stack_rects;
- glitz_rectangle_t *current_rect;
- cairo_status_t status;
- int i;
-
- if (! _is_supported_operator (op))
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- status = _cairo_glitz_surface_set_clip_region (dst, NULL);
- assert (status == CAIRO_STATUS_SUCCESS);
-
- if (n_rects > ARRAY_LENGTH (stack_rects)) {
- glitz_rects = _cairo_malloc_ab (n_rects, sizeof (glitz_rectangle_t));
- if (glitz_rects == NULL)
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- }
-
- for (i = 0; i < n_rects; i++) {
- glitz_rects[i].x = rects[i].x;
- glitz_rects[i].y = rects[i].y;
- glitz_rects[i].width = rects[i].width;
- glitz_rects[i].height = rects[i].height;
- }
-
- switch (op) {
- case CAIRO_OPERATOR_CLEAR:
- case CAIRO_OPERATOR_SOURCE: {
- glitz_color_t glitz_color;
- glitz_format_t *format;
-
- glitz_color.red = color->red_short;
- glitz_color.green = color->green_short;
- glitz_color.blue = color->blue_short;
- glitz_color.alpha = color->alpha_short;
-
- /*
- * XXX even if the dst surface don't have an alpha channel, the
- * above alpha still effect the dst surface because the
- * underlying glitz drawable may have an alpha channel. So
- * replacing the color with an opaque one is needed.
- */
- format = glitz_surface_get_format (dst->surface);
- if (format->color.alpha_size == 0)
- glitz_color.alpha = 0xffff;
-
- glitz_set_rectangles (dst->surface, &glitz_color,
- glitz_rects, n_rects);
- } break;
- case CAIRO_OPERATOR_SATURATE:
- return CAIRO_INT_STATUS_UNSUPPORTED;
- case CAIRO_OPERATOR_OVER:
- case CAIRO_OPERATOR_IN:
- case CAIRO_OPERATOR_OUT:
- case CAIRO_OPERATOR_ATOP:
- case CAIRO_OPERATOR_DEST:
- case CAIRO_OPERATOR_DEST_OVER:
- case CAIRO_OPERATOR_DEST_IN:
- case CAIRO_OPERATOR_DEST_OUT:
- case CAIRO_OPERATOR_DEST_ATOP:
- case CAIRO_OPERATOR_XOR:
- case CAIRO_OPERATOR_ADD:
- default:
- if (_glitz_ensure_target (dst->surface))
- {
- if (glitz_rects != stack_rects)
- free (glitz_rects);
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
- src = (cairo_glitz_surface_t *)
- _cairo_surface_create_similar_solid (&dst->base,
- CAIRO_CONTENT_COLOR_ALPHA,
- 1, 1,
- (cairo_color_t *) color,
- FALSE);
- if (src == NULL || src->base.status) {
- if (glitz_rects != stack_rects)
- free (glitz_rects);
- return src ? src->base.status : CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
- glitz_surface_set_fill (src->surface, GLITZ_FILL_REPEAT);
-
- current_rect = glitz_rects;
- while (n_rects--)
- {
- glitz_composite (_glitz_operator (op),
- src->surface,
- NULL,
- dst->surface,
- 0, 0,
- 0, 0,
- current_rect->x, current_rect->y,
- current_rect->width, current_rect->height);
- current_rect++;
- }
-
- cairo_surface_destroy (&src->base);
- break;
- }
-
- if (glitz_rects != stack_rects)
- free (glitz_rects);
-
- if (glitz_surface_get_status (dst->surface) == GLITZ_STATUS_NOT_SUPPORTED)
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-static cairo_int_status_t
-_cairo_glitz_surface_composite_trapezoids (cairo_operator_t op,
- const cairo_pattern_t *pattern,
- void *abstract_dst,
- cairo_antialias_t antialias,
- int src_x,
- int src_y,
- int dst_x,
- int dst_y,
- unsigned int width,
- unsigned int height,
- cairo_trapezoid_t *traps,
- int n_traps,
- cairo_region_t *clip_region)
-{
- cairo_glitz_surface_attributes_t attributes;
- cairo_glitz_surface_t *dst = abstract_dst;
- cairo_glitz_surface_t *src;
- cairo_glitz_surface_t *mask = NULL;
- glitz_buffer_t *buffer = NULL;
- void *data = NULL;
- cairo_int_status_t status;
- unsigned short alpha;
- pixman_trapezoid_t stack_traps[CAIRO_STACK_ARRAY_LENGTH (pixman_trapezoid_t)];
- pixman_trapezoid_t *pixman_traps = stack_traps;
- int i;
-
- if (antialias != CAIRO_ANTIALIAS_DEFAULT &&
- antialias != CAIRO_ANTIALIAS_GRAY)
- {
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
- if (! _is_supported_operator (op))
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- if (_glitz_ensure_target (dst->surface))
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- status = _cairo_glitz_surface_set_clip_region (dst, clip_region);
- if (unlikely (status))
- return status;
-
- /* Convert traps to pixman traps */
- if (n_traps > ARRAY_LENGTH (stack_traps)) {
- pixman_traps = _cairo_malloc_ab (n_traps, sizeof (pixman_trapezoid_t));
- if (pixman_traps == NULL)
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- }
-
- for (i = 0; i < n_traps; i++) {
- pixman_traps[i].top = _cairo_fixed_to_16_16 (traps[i].top);
- pixman_traps[i].bottom = _cairo_fixed_to_16_16 (traps[i].bottom);
- pixman_traps[i].left.p1.x = _cairo_fixed_to_16_16 (traps[i].left.p1.x);
- pixman_traps[i].left.p1.y = _cairo_fixed_to_16_16 (traps[i].left.p1.y);
- pixman_traps[i].left.p2.x = _cairo_fixed_to_16_16 (traps[i].left.p2.x);
- pixman_traps[i].left.p2.y = _cairo_fixed_to_16_16 (traps[i].left.p2.y);
- pixman_traps[i].right.p1.x = _cairo_fixed_to_16_16 (traps[i].right.p1.x);
- pixman_traps[i].right.p1.y = _cairo_fixed_to_16_16 (traps[i].right.p1.y);
- pixman_traps[i].right.p2.x = _cairo_fixed_to_16_16 (traps[i].right.p2.x);
- pixman_traps[i].right.p2.y = _cairo_fixed_to_16_16 (traps[i].right.p2.y);
- }
-
- status = _cairo_glitz_pattern_acquire_surface (pattern, dst,
- src_x, src_y,
- width, height,
- &src, &attributes);
- if (status)
- goto FAIL;
-
- alpha = 0xffff;
-
- if (op == CAIRO_OPERATOR_ADD || n_traps <= 1) {
- static const glitz_color_t clear_black = { 0, 0, 0, 0 };
- glitz_color_t color;
- glitz_geometry_format_t format;
- int n_trap_added;
- int offset = 0;
- int data_size = 0;
- int size = 30 * n_traps; /* just a guess */
-
- format.vertex.primitive = GLITZ_PRIMITIVE_QUADS;
- format.vertex.type = GLITZ_DATA_TYPE_FLOAT;
- format.vertex.bytes_per_vertex = 3 * sizeof (glitz_float_t);
- format.vertex.attributes = GLITZ_VERTEX_ATTRIBUTE_MASK_COORD_MASK;
- format.vertex.mask.type = GLITZ_DATA_TYPE_FLOAT;
- format.vertex.mask.size = GLITZ_COORDINATE_SIZE_X;
- format.vertex.mask.offset = 2 * sizeof (glitz_float_t);
-
- mask = (cairo_glitz_surface_t *)
- _cairo_glitz_surface_create_similar (&dst->base,
- CAIRO_CONTENT_ALPHA,
- 2, 1);
- if (mask == NULL) {
- status = CAIRO_INT_STATUS_UNSUPPORTED;
- goto FAIL;
- }
- if (mask->base.status) {
- status = mask->base.status;
- goto FAIL;
- }
-
- color.red = color.green = color.blue = color.alpha = 0xffff;
-
- glitz_set_rectangle (mask->surface, &clear_black, 0, 0, 1, 1);
- glitz_set_rectangle (mask->surface, &color, 1, 0, 1, 1);
-
- glitz_surface_set_fill (mask->surface, GLITZ_FILL_NEAREST);
- glitz_surface_set_filter (mask->surface,
- GLITZ_FILTER_BILINEAR,
- NULL, 0);
-
- size *= format.vertex.bytes_per_vertex;
-
- while (n_traps) {
- if (data_size < size) {
- void *p;
-
- data_size = size;
- p = realloc (data, data_size);
- if (p == NULL) {
- status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
- goto FAIL;
- }
- data = p;
-
- if (buffer)
- glitz_buffer_destroy (buffer);
-
- buffer = glitz_buffer_create_for_data (data);
- if (buffer == NULL) {
- status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
- free (data);
- goto FAIL;
- }
- }
-
- offset +=
- glitz_add_trapezoids (buffer,
- offset, size - offset,
- format.vertex.type, mask->surface,
- (glitz_trapezoid_t *) pixman_traps, n_traps,
- &n_trap_added);
-
- n_traps -= n_trap_added;
- traps += n_trap_added;
- size *= 2;
- }
-
- glitz_set_geometry (dst->surface,
- GLITZ_GEOMETRY_TYPE_VERTEX,
- &format, buffer);
- glitz_set_array (dst->surface, 0, 3,
- offset / format.vertex.bytes_per_vertex,
- 0, 0);
- } else {
- cairo_image_surface_t *image;
- unsigned char *ptr;
- int stride;
-
- stride = (width + 3) & -4;
- data = calloc (stride, height);
- if (data == NULL) {
- status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
- goto FAIL;
- }
-
- /* using negative stride */
- ptr = (unsigned char *) data + stride * (height - 1);
-
- image = (cairo_image_surface_t *)
- cairo_image_surface_create_for_data (ptr,
- CAIRO_FORMAT_A8,
- width, height,
- -stride);
- status = image->base.status;
- if (status) {
- free (data);
- goto FAIL;
- }
-
- pixman_add_trapezoids (image->pixman_image, -dst_x, -dst_y,
- n_traps, (pixman_trapezoid_t *) pixman_traps);
-
- mask = (cairo_glitz_surface_t *)
- _cairo_glitz_surface_create_similar (&dst->base,
- CAIRO_CONTENT_ALPHA,
- width, height);
- status = mask->base.status;
- if (status) {
- free (data);
- cairo_surface_destroy (&image->base);
- goto FAIL;
- }
-
- status = _cairo_glitz_surface_set_image (mask, image,
- 0, 0, width, height, 0, 0);
-
- cairo_surface_destroy (&image->base);
-
- if (status)
- goto FAIL;
- }
-
- _cairo_glitz_surface_set_attributes (src, &attributes);
-
- glitz_composite (_glitz_operator (op),
- src->surface,
- mask->surface,
- dst->surface,
- src_x + attributes.base.x_offset,
- src_y + attributes.base.y_offset,
- 0, 0,
- dst_x, dst_y,
- width, height);
-
- if (attributes.n_params)
- free (attributes.params);
-
- glitz_set_geometry (dst->surface,
- GLITZ_GEOMETRY_TYPE_NONE,
- NULL, NULL);
-
- if (buffer)
- glitz_buffer_destroy (buffer);
-
- free (data);
-
- if (glitz_surface_get_status (dst->surface) == GLITZ_STATUS_NOT_SUPPORTED) {
- status = CAIRO_INT_STATUS_UNSUPPORTED;
- goto FAIL;
- }
-
- if (! _cairo_operator_bounded_by_mask (op)) {
- status = _cairo_surface_composite_shape_fixup_unbounded (&dst->base,
- &attributes.base,
- glitz_surface_get_width (src->surface),
- glitz_surface_get_height (src->surface),
- width, height,
- src_x, src_y,
- 0, 0,
- dst_x, dst_y,
- width, height,
- clip_region);
- }
-
-FAIL:
- _cairo_glitz_pattern_release_surface (pattern, src, &attributes);
-
- if (mask != NULL)
- cairo_surface_destroy (&mask->base);
-
- if (pixman_traps != stack_traps)
- free (pixman_traps);
-
- return status;
-}
-
-static cairo_bool_t
-_cairo_glitz_surface_get_extents (void *abstract_surface,
- cairo_rectangle_int_t *rectangle)
-{
- cairo_glitz_surface_t *surface = abstract_surface;
-
- rectangle->x = 0;
- rectangle->y = 0;
- rectangle->width = glitz_surface_get_width (surface->surface);
- rectangle->height = glitz_surface_get_height (surface->surface);
-
- return TRUE;
-}
-
-#define CAIRO_GLITZ_AREA_AVAILABLE 0
-#define CAIRO_GLITZ_AREA_DIVIDED 1
-#define CAIRO_GLITZ_AREA_OCCUPIED 2
-
-typedef struct _cairo_glitz_root_area cairo_glitz_root_area_t;
-
-typedef struct _cairo_glitz_area {
- int state;
- int level;
- int x, y;
- int width, height;
- struct _cairo_glitz_area *area[4];
- cairo_glitz_root_area_t *root;
- void *closure;
-} cairo_glitz_area_t;
-
-static cairo_glitz_area_t _empty_area = {
- 0, 0, 0, 0, 0, 0,
- { NULL, NULL, NULL, NULL },
- NULL,
- NULL
-};
-
-typedef struct _cairo_glitz_area_funcs {
- cairo_status_t (*move_in) (cairo_glitz_area_t *area,
- void *closure);
-
- void (*move_out) (cairo_glitz_area_t *area,
- void *closure);
-
- int (*compare_score) (cairo_glitz_area_t *area,
- void *closure1,
- void *closure2);
-} cairo_glitz_area_funcs_t;
-
-struct _cairo_glitz_root_area {
- int max_level;
- int width, height;
- cairo_glitz_area_t *area;
- const cairo_glitz_area_funcs_t *funcs;
-};
-
-static cairo_status_t
-_cairo_glitz_area_move_in (cairo_glitz_area_t *area,
- void *closure)
-{
- area->closure = closure;
- area->state = CAIRO_GLITZ_AREA_OCCUPIED;
-
- return (*area->root->funcs->move_in) (area, area->closure);
-}
-
-static void
-_cairo_glitz_area_move_out (cairo_glitz_area_t *area)
-{
- if (area->root)
- {
- (*area->root->funcs->move_out) (area, area->closure);
-
- area->closure = NULL;
- area->state = CAIRO_GLITZ_AREA_AVAILABLE;
- }
-}
-
-static cairo_glitz_area_t *
-_cairo_glitz_area_create (cairo_glitz_root_area_t *root,
- int level,
- int x,
- int y,
- int width,
- int height)
-{
- cairo_glitz_area_t *area;
- int n = 4;
-
- area = malloc (sizeof (cairo_glitz_area_t));
- if (!area) {
- _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
- return NULL;
- }
-
- area->level = level;
- area->x = x;
- area->y = y;
- area->width = width;
- area->height = height;
- area->root = root;
- area->closure = NULL;
- area->state = CAIRO_GLITZ_AREA_AVAILABLE;
-
- while (n--)
- area->area[n] = NULL;
-
- return area;
-}
-
-static void
-_cairo_glitz_area_destroy (cairo_glitz_area_t *area)
-{
- if (area == NULL)
- return;
-
- if (area->state == CAIRO_GLITZ_AREA_OCCUPIED)
- {
- _cairo_glitz_area_move_out (area);
- }
- else
- {
- int n = 4;
-
- while (n--)
- _cairo_glitz_area_destroy (area->area[n]);
- }
-
- free (area);
-}
-
-static cairo_glitz_area_t *
-_cairo_glitz_area_get_top_scored_sub_area (cairo_glitz_area_t *area)
-{
- if (!area)
- return NULL;
-
- switch (area->state) {
- case CAIRO_GLITZ_AREA_OCCUPIED:
- return area;
- case CAIRO_GLITZ_AREA_AVAILABLE:
- break;
- case CAIRO_GLITZ_AREA_DIVIDED: {
- cairo_glitz_area_t *tmp, *top = NULL;
- int i;
-
- for (i = 0; i < 4; i++)
- {
- tmp = _cairo_glitz_area_get_top_scored_sub_area (area->area[i]);
- if (tmp && top)
- {
- if ((*area->root->funcs->compare_score) (tmp,
- tmp->closure,
- top->closure) > 0)
- top = tmp;
- }
- else if (tmp)
- {
- top = tmp;
- }
- }
- return top;
- }
- }
-
- return NULL;
-}
-
-static cairo_int_status_t
-_cairo_glitz_area_find (cairo_glitz_area_t *area,
- int width,
- int height,
- cairo_bool_t kick_out,
- void *closure)
-{
- cairo_status_t status;
-
- if (area->width < width || area->height < height)
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- switch (area->state) {
- case CAIRO_GLITZ_AREA_OCCUPIED:
- if (kick_out)
- {
- if ((*area->root->funcs->compare_score) (area,
- area->closure,
- closure) >= 0)
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- _cairo_glitz_area_move_out (area);
- } else {
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
- /* fall-through */
- case CAIRO_GLITZ_AREA_AVAILABLE: {
- if (area->level == area->root->max_level ||
- (area->width == width && area->height == height))
- {
- return _cairo_glitz_area_move_in (area, closure);
- }
- else
- {
- int dx[4], dy[4], w[4], h[4], i;
-
- dx[0] = dx[2] = dy[0] = dy[1] = 0;
-
- w[0] = w[2] = dx[1] = dx[3] = width;
- h[0] = h[1] = dy[2] = dy[3] = height;
-
- w[1] = w[3] = area->width - width;
- h[2] = h[3] = area->height - height;
-
- for (i = 0; i < 2; i++)
- {
- if (w[i])
- area->area[i] =
- _cairo_glitz_area_create (area->root,
- area->level + 1,
- area->x + dx[i],
- area->y + dy[i],
- w[i], h[i]);
- }
-
- for (; i < 4; i++)
- {
- if (w[i] && h[i])
- area->area[i] =
- _cairo_glitz_area_create (area->root,
- area->level + 1,
- area->x + dx[i],
- area->y + dy[i],
- w[i], h[i]);
- }
-
- area->state = CAIRO_GLITZ_AREA_DIVIDED;
-
- status = _cairo_glitz_area_find (area->area[0],
- width, height,
- kick_out, closure);
- if (status == CAIRO_STATUS_SUCCESS)
- return CAIRO_STATUS_SUCCESS;
- }
- } break;
- case CAIRO_GLITZ_AREA_DIVIDED: {
- cairo_glitz_area_t *to_area;
- int i, rejected = FALSE;
-
- for (i = 0; i < 4; i++)
- {
- if (area->area[i])
- {
- if (area->area[i]->width >= width &&
- area->area[i]->height >= height)
- {
- status = _cairo_glitz_area_find (area->area[i],
- width, height,
- kick_out, closure);
- if (status == CAIRO_STATUS_SUCCESS)
- return CAIRO_STATUS_SUCCESS;
-
- rejected = TRUE;
- }
- }
- }
-
- if (rejected)
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- to_area = _cairo_glitz_area_get_top_scored_sub_area (area);
- if (to_area)
- {
- if (kick_out)
- {
- if ((*area->root->funcs->compare_score) (to_area,
- to_area->closure,
- closure) >= 0)
- return CAIRO_INT_STATUS_UNSUPPORTED;
- } else {
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
- }
-
- for (i = 0; i < 4; i++)
- {
- _cairo_glitz_area_destroy (area->area[i]);
- area->area[i] = NULL;
- }
-
- area->closure = NULL;
- area->state = CAIRO_GLITZ_AREA_AVAILABLE;
-
- status = _cairo_glitz_area_find (area, width, height,
- TRUE, closure);
- if (status == CAIRO_STATUS_SUCCESS)
- return CAIRO_STATUS_SUCCESS;
-
- } break;
- }
-
- return CAIRO_INT_STATUS_UNSUPPORTED;
-}
-
-static cairo_status_t
-_cairo_glitz_root_area_init (cairo_glitz_root_area_t *root,
- int max_level,
- int width,
- int height,
- const cairo_glitz_area_funcs_t *funcs)
-{
- root->max_level = max_level;
- root->funcs = funcs;
-
- root->area = _cairo_glitz_area_create (root, 0, 0, 0, width, height);
- if (!root->area)
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-static void
-_cairo_glitz_root_area_fini (cairo_glitz_root_area_t *root)
-{
- _cairo_glitz_area_destroy (root->area);
-}
-
-typedef struct _cairo_glitz_surface_font_private {
- cairo_glitz_root_area_t root;
- glitz_surface_t *surface;
-} cairo_glitz_surface_font_private_t;
-
-typedef struct _cairo_glitz_surface_glyph_private {
- cairo_glitz_area_t *area;
- cairo_bool_t locked;
- cairo_point_double_t p1, p2;
-} cairo_glitz_surface_glyph_private_t;
-
-static cairo_status_t
-_cairo_glitz_glyph_move_in (cairo_glitz_area_t *area,
- void *closure)
-{
- cairo_glitz_surface_glyph_private_t *glyph_private = closure;
-
- glyph_private->area = area;
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-static void
-_cairo_glitz_glyph_move_out (cairo_glitz_area_t *area,
- void *closure)
-{
- cairo_glitz_surface_glyph_private_t *glyph_private = closure;
-
- glyph_private->area = NULL;
-}
-
-static int
-_cairo_glitz_glyph_compare (cairo_glitz_area_t *area,
- void *closure1,
- void *closure2)
-{
- cairo_glitz_surface_glyph_private_t *glyph_private = closure1;
-
- if (glyph_private->locked)
- return 1;
-
- return -1;
-}
-
-static const cairo_glitz_area_funcs_t _cairo_glitz_area_funcs = {
- _cairo_glitz_glyph_move_in,
- _cairo_glitz_glyph_move_out,
- _cairo_glitz_glyph_compare
-};
-
-#define GLYPH_CACHE_TEXTURE_SIZE 512
-#define GLYPH_CACHE_MAX_LEVEL 64
-#define GLYPH_CACHE_MAX_HEIGHT 96
-#define GLYPH_CACHE_MAX_WIDTH 96
-
-#define WRITE_VEC2(ptr, _x, _y) \
- *(ptr)++ = (_x); \
- *(ptr)++ = (_y)
-
-#define WRITE_BOX(ptr, _vx1, _vy1, _vx2, _vy2, p1, p2) \
- WRITE_VEC2 (ptr, _vx1, _vy1); \
- WRITE_VEC2 (ptr, (p1)->x, (p2)->y); \
- WRITE_VEC2 (ptr, _vx2, _vy1); \
- WRITE_VEC2 (ptr, (p2)->x, (p2)->y); \
- WRITE_VEC2 (ptr, _vx2, _vy2); \
- WRITE_VEC2 (ptr, (p2)->x, (p1)->y); \
- WRITE_VEC2 (ptr, _vx1, _vy2); \
- WRITE_VEC2 (ptr, (p1)->x, (p1)->y)
-
-static cairo_status_t
-_cairo_glitz_surface_font_init (cairo_glitz_surface_t *surface,
- cairo_scaled_font_t *scaled_font,
- cairo_format_t format)
-{
- cairo_glitz_surface_font_private_t *font_private;
- glitz_drawable_t *drawable;
- glitz_format_t *surface_format = NULL;
- cairo_int_status_t status;
-
- drawable = glitz_surface_get_drawable (surface->surface);
-
- switch (format) {
- case CAIRO_FORMAT_A1:
- case CAIRO_FORMAT_A8:
- surface_format =
- glitz_find_standard_format (drawable, GLITZ_STANDARD_A8);
- break;
- case CAIRO_FORMAT_RGB24:
- ASSERT_NOT_REACHED;
- break;
- case CAIRO_FORMAT_ARGB32:
- surface_format =
- glitz_find_standard_format (drawable, GLITZ_STANDARD_ARGB32);
- default:
- break;
- }
-
- if (!surface_format)
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- font_private = malloc (sizeof (cairo_glitz_surface_font_private_t));
- if (!font_private)
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
- font_private->surface = glitz_surface_create (drawable, surface_format,
- GLYPH_CACHE_TEXTURE_SIZE,
- GLYPH_CACHE_TEXTURE_SIZE,
- 0, NULL);
- if (font_private->surface == NULL)
- {
- free (font_private);
-
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
- if (format == CAIRO_FORMAT_ARGB32)
- glitz_surface_set_component_alpha (font_private->surface, 1);
-
- status = _cairo_glitz_root_area_init (&font_private->root,
- GLYPH_CACHE_MAX_LEVEL,
- GLYPH_CACHE_TEXTURE_SIZE,
- GLYPH_CACHE_TEXTURE_SIZE,
- &_cairo_glitz_area_funcs);
- if (status != CAIRO_STATUS_SUCCESS)
- {
- glitz_surface_destroy (font_private->surface);
- free (font_private);
-
- return status;
- }
-
- scaled_font->surface_private = font_private;
- scaled_font->surface_backend = _cairo_glitz_surface_get_backend ();
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-static void
-_cairo_glitz_surface_scaled_font_fini (cairo_scaled_font_t *scaled_font)
-{
- cairo_glitz_surface_font_private_t *font_private;
-
- font_private = scaled_font->surface_private;
- if (font_private)
- {
- _cairo_glitz_root_area_fini (&font_private->root);
- glitz_surface_destroy (font_private->surface);
- free (font_private);
- }
-}
-
-static void
-_cairo_glitz_surface_scaled_glyph_fini (cairo_scaled_glyph_t *scaled_glyph,
- cairo_scaled_font_t *scaled_font)
-{
- cairo_glitz_surface_glyph_private_t *glyph_private;
-
- glyph_private = scaled_glyph->surface_private;
- if (glyph_private)
- {
- if (glyph_private->area)
- _cairo_glitz_area_move_out (glyph_private->area);
-
- free (glyph_private);
- }
-}
-
-#define FIXED_TO_FLOAT(f) (((glitz_float_t) (f)) / 65536)
-
-static cairo_status_t
-_cairo_glitz_surface_add_glyph (cairo_glitz_surface_t *surface,
- cairo_scaled_font_t *scaled_font,
- cairo_scaled_glyph_t *scaled_glyph)
-{
- cairo_image_surface_t *glyph_surface = scaled_glyph->surface;
- cairo_glitz_surface_font_private_t *font_private;
- cairo_glitz_surface_glyph_private_t *glyph_private;
- glitz_point_fixed_t p1, p2;
- glitz_pixel_format_t pf;
- glitz_buffer_t *buffer;
- cairo_format_masks_t masks;
- cairo_int_status_t status;
-
- glyph_private = scaled_glyph->surface_private;
- if (glyph_private == NULL)
- {
- glyph_private = malloc (sizeof (cairo_glitz_surface_glyph_private_t));
- if (!glyph_private)
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
- glyph_private->area = NULL;
- glyph_private->locked = FALSE;
-
- scaled_glyph->surface_private = (void *) glyph_private;
- }
-
- if (glyph_surface->width > GLYPH_CACHE_MAX_WIDTH ||
- glyph_surface->height > GLYPH_CACHE_MAX_HEIGHT)
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- if (scaled_font->surface_private == NULL)
- {
- status = _cairo_glitz_surface_font_init (surface, scaled_font,
- glyph_surface->format);
- if (status)
- return status;
- }
-
- font_private = scaled_font->surface_private;
-
- if (glyph_surface->width == 0 || glyph_surface->height == 0)
- {
- glyph_private->area = &_empty_area;
- return CAIRO_STATUS_SUCCESS;
- }
-
- if (_cairo_glitz_area_find (font_private->root.area,
- glyph_surface->width,
- glyph_surface->height,
- FALSE, glyph_private))
- {
- if (_cairo_glitz_area_find (font_private->root.area,
- glyph_surface->width,
- glyph_surface->height,
- TRUE, glyph_private))
- return CAIRO_STATUS_SUCCESS;
- }
-
- buffer = glitz_buffer_create_for_data (glyph_surface->data);
- if (!buffer)
- {
- _cairo_glitz_area_move_out (glyph_private->area);
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- }
-
- _pixman_format_to_masks (glyph_surface->pixman_format, &masks);
-
- pf.fourcc = GLITZ_FOURCC_RGB;
- pf.masks.bpp = masks.bpp;
- pf.masks.alpha_mask = masks.alpha_mask;
- pf.masks.red_mask = masks.red_mask;
- pf.masks.green_mask = masks.green_mask;
- pf.masks.blue_mask = masks.blue_mask;
-
- pf.bytes_per_line = glyph_surface->stride;
- pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
- pf.xoffset = 0;
- pf.skip_lines = 0;
-
- glitz_set_pixels (font_private->surface,
- glyph_private->area->x,
- glyph_private->area->y,
- glyph_surface->width,
- glyph_surface->height,
- &pf, buffer);
-
- glitz_buffer_destroy (buffer);
-
- p1.x = glyph_private->area->x << 16;
- p1.y = glyph_private->area->y << 16;
- p2.x = (glyph_private->area->x + glyph_surface->width) << 16;
- p2.y = (glyph_private->area->y + glyph_surface->height) << 16;
-
- glitz_surface_translate_point (font_private->surface, &p1, &p1);
- glitz_surface_translate_point (font_private->surface, &p2, &p2);
-
- glyph_private->p1.x = FIXED_TO_FLOAT (p1.x);
- glyph_private->p1.y = FIXED_TO_FLOAT (p1.y);
- glyph_private->p2.x = FIXED_TO_FLOAT (p2.x);
- glyph_private->p2.y = FIXED_TO_FLOAT (p2.y);
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-#define N_STACK_BUF 256
-
-static cairo_int_status_t
-_cairo_glitz_surface_old_show_glyphs (cairo_scaled_font_t *scaled_font,
- cairo_operator_t op,
- const cairo_pattern_t *pattern,
- void *abstract_surface,
- int src_x,
- int src_y,
- int dst_x,
- int dst_y,
- unsigned int width,
- unsigned int height,
- cairo_glyph_t *glyphs,
- int num_glyphs,
- cairo_region_t *clip_region)
-{
- cairo_glitz_surface_attributes_t attributes;
- cairo_glitz_surface_glyph_private_t *glyph_private;
- cairo_glitz_surface_t *dst = abstract_surface;
- cairo_glitz_surface_t *src;
- cairo_scaled_glyph_t *stack_scaled_glyphs[N_STACK_BUF];
- cairo_scaled_glyph_t **scaled_glyphs;
- glitz_float_t stack_vertices[N_STACK_BUF * 16];
- glitz_float_t *vertices;
- glitz_buffer_t *buffer;
- cairo_int_status_t status;
- int x_offset, y_offset;
- int i, cached_glyphs = 0;
- int remaining_glyps = num_glyphs;
- glitz_float_t x1, y1, x2, y2;
- static const glitz_vertex_format_t format = {
- GLITZ_PRIMITIVE_QUADS,
- GLITZ_DATA_TYPE_FLOAT,
- sizeof (glitz_float_t) * 4,
- GLITZ_VERTEX_ATTRIBUTE_MASK_COORD_MASK,
- { 0 },
- {
- GLITZ_DATA_TYPE_FLOAT,
- GLITZ_COORDINATE_SIZE_XY,
- sizeof (glitz_float_t) * 2,
- }
- };
-
- if (scaled_font->surface_backend != NULL &&
- scaled_font->surface_backend != _cairo_glitz_surface_get_backend ())
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- if (! _is_supported_operator (op))
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- /* XXX Unbounded operators are not handled correctly */
- if (! _cairo_operator_bounded_by_mask (op))
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- if (_glitz_ensure_target (dst->surface))
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- status = _cairo_glitz_surface_set_clip_region (dst, NULL);
- if (unlikely (status))
- return status;
-
- status = _cairo_glitz_pattern_acquire_surface (pattern, dst,
- src_x, src_y,
- width, height,
- &src, &attributes);
- if (status)
- return status;
-
- _cairo_glitz_surface_set_attributes (src, &attributes);
-
- if (num_glyphs > N_STACK_BUF)
- {
- char *data;
- size_t size1, size2;
-
- if ((size_t)num_glyphs >= INT32_MAX / sizeof(void*) ||
- (size_t)num_glyphs >= INT32_MAX / sizeof(glitz_float_t) ||
- ((size_t)num_glyphs * sizeof(glitz_float_t)) >= INT32_MAX / 16)
- goto FAIL1;
-
- size1 = num_glyphs * sizeof(void *);
- size2 = num_glyphs * sizeof(glitz_float_t) * 16;
- if (size1 >= INT32_MAX - size2)
- goto FAIL1;
-
- data = malloc (size1 + size2);
- if (!data) {
- _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
- goto FAIL1;
- }
-
- scaled_glyphs = (cairo_scaled_glyph_t **) data;
- vertices = (glitz_float_t *) (data + num_glyphs * sizeof (void *));
- }
- else
- {
- scaled_glyphs = stack_scaled_glyphs;
- vertices = stack_vertices;
- }
-
- buffer = glitz_buffer_create_for_data (vertices);
- if (!buffer)
- goto FAIL2;
-
- _cairo_scaled_font_freeze_cache (scaled_font);
-
- for (i = 0; i < num_glyphs; i++)
- {
- status = _cairo_scaled_glyph_lookup (scaled_font,
- glyphs[i].index,
- CAIRO_SCALED_GLYPH_INFO_SURFACE,
- &scaled_glyphs[i]);
- if (status != CAIRO_STATUS_SUCCESS)
- {
- num_glyphs = i;
- goto UNLOCK;
- }
-
- glyph_private = scaled_glyphs[i]->surface_private;
- if (!glyph_private || !glyph_private->area)
- {
- status = _cairo_glitz_surface_add_glyph (dst,
- scaled_font,
- scaled_glyphs[i]);
- if (status != CAIRO_STATUS_SUCCESS) {
- num_glyphs = i;
- goto UNLOCK;
- }
- }
- glyph_private = scaled_glyphs[i]->surface_private;
- if (glyph_private && glyph_private->area)
- {
- remaining_glyps--;
-
- if (glyph_private->area->width)
- {
- x_offset = scaled_glyphs[i]->surface->base.device_transform.x0;
- y_offset = scaled_glyphs[i]->surface->base.device_transform.y0;
-
- x1 = _cairo_lround (glyphs[i].x - x_offset);
- y1 = _cairo_lround (glyphs[i].y - y_offset);
- x2 = x1 + glyph_private->area->width;
- y2 = y1 + glyph_private->area->height;
-
- WRITE_BOX (vertices, x1, y1, x2, y2,
- &glyph_private->p1, &glyph_private->p2);
-
- glyph_private->locked = TRUE;
-
- cached_glyphs++;
- }
- }
- }
-
- if (remaining_glyps)
- {
- cairo_surface_t *image;
- cairo_glitz_surface_t *clone;
-
- for (i = 0; i < num_glyphs; i++)
- {
- glyph_private = scaled_glyphs[i]->surface_private;
- if (!glyph_private || !glyph_private->area)
- {
- int glyph_width, glyph_height;
- int clone_offset_x, clone_offset_y;
-
- image = &scaled_glyphs[i]->surface->base;
- glyph_width = scaled_glyphs[i]->surface->width;
- glyph_height = scaled_glyphs[i]->surface->height;
- status =
- _cairo_glitz_surface_clone_similar (abstract_surface,
- image,
- 0,
- 0,
- glyph_width,
- glyph_height,
- &clone_offset_x,
- &clone_offset_y,
- (cairo_surface_t **)
- &clone);
- if (status)
- goto UNLOCK;
-
- assert (clone_offset_x == 0);
- assert (clone_offset_y == 0);
-
- x_offset = scaled_glyphs[i]->surface->base.device_transform.x0;
- y_offset = scaled_glyphs[i]->surface->base.device_transform.y0;
- x1 = _cairo_lround (glyphs[i].x - x_offset);
- y1 = _cairo_lround (glyphs[i].y - y_offset);
-
- glitz_composite (_glitz_operator (op),
- src->surface,
- clone->surface,
- dst->surface,
- src_x + attributes.base.x_offset + x1,
- src_y + attributes.base.y_offset + y1,
- 0, 0,
- x1, y1,
- glyph_width,
- glyph_height);
-
- cairo_surface_destroy (&clone->base);
-
- if (glitz_surface_get_status (dst->surface) ==
- GLITZ_STATUS_NOT_SUPPORTED)
- {
- status = CAIRO_INT_STATUS_UNSUPPORTED;
- goto UNLOCK;
- }
- }
- }
- }
-
- if (cached_glyphs)
- {
- cairo_glitz_surface_font_private_t *font_private;
-
- glitz_set_geometry (dst->surface,
- GLITZ_GEOMETRY_TYPE_VERTEX,
- (glitz_geometry_format_t *) &format,
- buffer);
-
- glitz_set_array (dst->surface, 0, 4, cached_glyphs * 4, 0, 0);
-
- font_private = scaled_font->surface_private;
-
- glitz_composite (_glitz_operator (op),
- src->surface,
- font_private->surface,
- dst->surface,
- src_x + attributes.base.x_offset,
- src_y + attributes.base.y_offset,
- 0, 0,
- dst_x, dst_y,
- width, height);
-
- glitz_set_geometry (dst->surface,
- GLITZ_GEOMETRY_TYPE_NONE,
- NULL, NULL);
- }
-
-UNLOCK:
- if (cached_glyphs)
- {
- for (i = 0; i < num_glyphs; i++)
- {
- glyph_private = scaled_glyphs[i]->surface_private;
- if (glyph_private)
- glyph_private->locked = FALSE;
- }
- }
-
- _cairo_scaled_font_thaw_cache (scaled_font);
-
- glitz_buffer_destroy (buffer);
-
- FAIL2:
- if (num_glyphs > N_STACK_BUF)
- free (scaled_glyphs);
-
- FAIL1:
- if (attributes.n_params)
- free (attributes.params);
-
- _cairo_glitz_pattern_release_surface (pattern, src, &attributes);
-
- if (status)
- return status;
-
- if (glitz_surface_get_status (dst->surface) == GLITZ_STATUS_NOT_SUPPORTED)
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-static cairo_status_t
-_cairo_glitz_surface_flush (void *abstract_surface)
-{
- cairo_glitz_surface_t *surface = abstract_surface;
-
- glitz_surface_flush (surface->surface);
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-static cairo_bool_t
-_cairo_glitz_surface_is_similar (void *surface_a,
- void *surface_b,
- cairo_content_t content)
-{
- cairo_glitz_surface_t *a = (cairo_glitz_surface_t *) surface_a;
- cairo_glitz_surface_t *b = (cairo_glitz_surface_t *) surface_b;
-
- glitz_drawable_t *drawable_a = glitz_surface_get_drawable (a->surface);
- glitz_drawable_t *drawable_b = glitz_surface_get_drawable (b->surface);
-
- /* XXX Disable caching of glitz surfaces by the solid pattern cache.
- * Until glitz has a mechanism for releasing resources on connection
- * closure, we will attempt to access invalid pointers when evicting
- * old surfaces from the solid pattern cache.
- */
- return FALSE;
-
- return drawable_a == drawable_b;
-}
-
-static const cairo_surface_backend_t cairo_glitz_surface_backend = {
- CAIRO_SURFACE_TYPE_GLITZ,
- _cairo_glitz_surface_create_similar,
- _cairo_glitz_surface_finish,
- _cairo_glitz_surface_acquire_source_image,
- _cairo_glitz_surface_release_source_image,
-
- _cairo_glitz_surface_acquire_dest_image,
- _cairo_glitz_surface_release_dest_image,
- _cairo_glitz_surface_clone_similar,
- _cairo_glitz_surface_composite,
- _cairo_glitz_surface_fill_rectangles,
- _cairo_glitz_surface_composite_trapezoids,
- NULL, /* create_span_renderer */
- NULL, /* check_span_renderer */
-
- NULL, /* copy_page */
- NULL, /* show_page */
- _cairo_glitz_surface_get_extents,
- _cairo_glitz_surface_old_show_glyphs,
- NULL, /* get_font_options */
- _cairo_glitz_surface_flush,
- NULL, /* mark_dirty_rectangle */
- _cairo_glitz_surface_scaled_font_fini,
- _cairo_glitz_surface_scaled_glyph_fini,
-
- NULL, /* paint */
- NULL, /* mask */
- NULL, /* stroke */
- NULL, /* fill */
- NULL, /* show_glyphs */
-
- _cairo_glitz_surface_snapshot,
- _cairo_glitz_surface_is_similar,
-};
-
-static const cairo_surface_backend_t *
-_cairo_glitz_surface_get_backend (void)
-{
- return &cairo_glitz_surface_backend;
-}
-
-static cairo_content_t
-_glitz_format_to_content (glitz_format_t * format)
-{
- assert (format->color.fourcc == GLITZ_FOURCC_RGB);
-
- if (format->color.alpha_size != 0) {
- if (format->color.red_size != 0 &&
- format->color.green_size != 0 &&
- format->color.blue_size != 0)
- return CAIRO_CONTENT_COLOR_ALPHA;
- else
- return CAIRO_CONTENT_ALPHA;
- }
- return CAIRO_CONTENT_COLOR;
-}
-
-cairo_surface_t *
-cairo_glitz_surface_create (glitz_surface_t *surface)
-{
- cairo_glitz_surface_t *crsurface;
- glitz_format_t *format;
-
- if (surface == NULL)
- return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NULL_POINTER));
-
- crsurface = malloc (sizeof (cairo_glitz_surface_t));
- if (crsurface == NULL)
- return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
-
- format = glitz_surface_get_format (surface);
- _cairo_surface_init (&crsurface->base,
- &cairo_glitz_surface_backend,
- NULL, /* device */
- _glitz_format_to_content (format));
-
- glitz_surface_reference (surface);
-
- crsurface->surface = surface;
- crsurface->format = format;
-
- crsurface->has_clip = FALSE;
- crsurface->clip_boxes = NULL;
- crsurface->num_clip_boxes = 0;
- crsurface->clip_region = NULL;
-
- return &crsurface->base;
-}
-slim_hidden_def (cairo_glitz_surface_create);
diff --git a/src/cairo-glitz.h b/src/cairo-glitz.h
deleted file mode 100644
index 08519dc..0000000
--- a/src/cairo-glitz.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
-
-#ifndef CAIRO_GLITZ_H
-#define CAIRO_GLITZ_H
-
-#include "cairo.h"
-
-#if CAIRO_HAS_GLITZ_SURFACE
-
-#include <glitz.h>
-
-CAIRO_BEGIN_DECLS
-
-cairo_public cairo_surface_t *
-cairo_glitz_surface_create (glitz_surface_t *surface);
-
-CAIRO_END_DECLS
-
-#else /* CAIRO_HAS_GLITZ_SURFACE */
-# error Cairo was not compiled with support for the glitz backend
-#endif /* CAIRO_HAS_GLITZ_SURFACE */
-
-#endif /* CAIRO_GLITZ_H */
diff --git a/test/Makefile.am b/test/Makefile.am
index ac515eb..6dd734f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -21,10 +21,6 @@ if CAIRO_HAS_QUARTZ_SURFACE
test_sources += $(quartz_surface_test_sources)
endif
-if CAIRO_HAS_GLITZ_SURFACE
-test_sources += $(glitz_surface_test_sources)
-endif
-
if CAIRO_HAS_PDF_SURFACE
test_sources += $(pdf_surface_test_sources)
endif
@@ -524,10 +520,6 @@ REFERENCE_IMAGES = \
ft-text-vertical-layout-type3.svg.ref.png \
ft-text-vertical-layout-type3.xlib.ref.png \
get-group-target.ref.png \
- glitz-surface-source.argb32.ref.png \
- glitz-surface-source.rgb24.ref.png \
- glitz-surface-source.ps2.ref.png \
- glitz-surface-source.ps3.ref.png \
glyph-cache-pressure.ps2.ref.png \
glyph-cache-pressure.ps3.ref.png \
glyph-cache-pressure.quartz.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 824379e..caff447 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -266,8 +266,6 @@ ft_font_test_sources = \
quartz_surface_test_sources = quartz-surface-source.c
-glitz_surface_test_sources = glitz-surface-source.c
-
pdf_surface_test_sources = \
pdf-features.c \
pdf-mime-data.c \
diff --git a/test/glitz-surface-source.argb32.ref.png b/test/glitz-surface-source.argb32.ref.png
deleted file mode 100644
index 0182972..0000000
--- a/test/glitz-surface-source.argb32.ref.png
+++ /dev/null
Binary files differ
diff --git a/test/glitz-surface-source.c b/test/glitz-surface-source.c
deleted file mode 100644
index 89094e4..0000000
--- a/test/glitz-surface-source.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Copyright © 2008 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 <chris@chris-wilson.co.uk>
- */
-
-#include "cairo-test.h"
-#include <cairo-glitz.h>
-
-#define NAME "glitz"
-#include "surface-source.c"
-
-static cairo_user_data_key_t closure_key;
-
-#if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
-#include <cairo-xlib.h>
-#include <cairo-xlib-xrender.h>
-#include <glitz-glx.h>
-
-struct closure {
- Display *dpy;
- Window win;
-};
-
-static void
-cleanup (void *data)
-{
- struct closure *closure = data;
-
- glitz_glx_fini ();
-
- if (closure->win)
- XDestroyWindow (closure->dpy, closure->win);
-
- XCloseDisplay (closure->dpy);
-
- free (closure);
-}
-
-static glitz_surface_t *
-_glitz_glx_create_surface (glitz_format_name_t formatname,
- int width,
- int height,
- struct closure *closure)
-{
- Display * dpy = closure->dpy;
- int scr = DefaultScreen(dpy);
- glitz_drawable_format_t templ;
- glitz_drawable_format_t * dformat = NULL;
- unsigned long mask;
- glitz_drawable_t * drawable = NULL;
- glitz_format_t * format;
- glitz_surface_t * sr;
-
- XSizeHints xsh;
- XSetWindowAttributes xswa;
- XVisualInfo * vinfo;
-
- memset(&templ, 0, sizeof(templ));
- templ.color.red_size = 8;
- templ.color.green_size = 8;
- templ.color.blue_size = 8;
- templ.color.alpha_size = 8;
- templ.color.fourcc = GLITZ_FOURCC_RGB;
- templ.samples = 1;
-
- glitz_glx_init (NULL);
-
- mask = GLITZ_FORMAT_SAMPLES_MASK |
- GLITZ_FORMAT_FOURCC_MASK |
- GLITZ_FORMAT_RED_SIZE_MASK |
- GLITZ_FORMAT_GREEN_SIZE_MASK |
- GLITZ_FORMAT_BLUE_SIZE_MASK;
- if (formatname == GLITZ_STANDARD_ARGB32)
- mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
-
- /* Try for a pbuffer first */
- if (!getenv("CAIRO_TEST_FORCE_GLITZ_WINDOW"))
- dformat = glitz_glx_find_pbuffer_format (dpy, scr, mask, &templ, 0);
-
- if (dformat) {
- closure->win = None;
-
- drawable = glitz_glx_create_pbuffer_drawable (dpy, scr, dformat,
- width, height);
- if (!drawable)
- goto FAIL;
- } else {
- /* No pbuffer, try window */
- dformat = glitz_glx_find_window_format (dpy, scr, mask, &templ, 0);
-
- if (!dformat)
- goto FAIL;
-
- vinfo = glitz_glx_get_visual_info_from_format(dpy,
- DefaultScreen(dpy),
- dformat);
-
- if (!vinfo)
- goto FAIL;
-
- xsh.flags = PSize;
- xsh.x = 0;
- xsh.y = 0;
- xsh.width = width;
- xsh.height = height;
-
- xswa.colormap = XCreateColormap (dpy, RootWindow(dpy, scr),
- vinfo->visual, AllocNone);
- closure->win = XCreateWindow (dpy, RootWindow(dpy, scr),
- xsh.x, xsh.y, xsh.width, xsh.height,
- 0, vinfo->depth, CopyFromParent,
- vinfo->visual, CWColormap, &xswa);
- XFree (vinfo);
-
- drawable =
- glitz_glx_create_drawable_for_window (dpy, scr,
- dformat, closure->win,
- width, height);
-
- if (!drawable)
- goto DESTROY_WINDOW;
- }
-
- format = glitz_find_standard_format (drawable, formatname);
- if (!format)
- goto DESTROY_DRAWABLE;
-
- sr = glitz_surface_create (drawable, format, width, height, 0, NULL);
- if (!sr)
- goto DESTROY_DRAWABLE;
-
- if (closure->win == None || dformat->doublebuffer) {
- glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_BACK_COLOR);
- } else {
- XMapWindow (closure->dpy, closure->win);
- glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
- }
-
- glitz_drawable_destroy (drawable);
-
- return sr;
- DESTROY_DRAWABLE:
- glitz_drawable_destroy (drawable);
- DESTROY_WINDOW:
- if (closure->win)
- XDestroyWindow (dpy, closure->win);
- FAIL:
- return NULL;
-}
-
-static cairo_surface_t *
-create_source_surface (int size)
-{
- struct closure *closure;
- glitz_surface_t *glitz_surface;
- cairo_surface_t *surface;
-
- closure = xcalloc (1, sizeof (struct closure));
-
- closure->dpy = XOpenDisplay (getenv("CAIRO_TEST_GLITZ_DISPLAY"));
- if (closure->dpy == NULL) {
- free (closure);
- return NULL;
- }
-
- glitz_surface = _glitz_glx_create_surface (GLITZ_STANDARD_ARGB32,
- size, size,
- closure);
- if (glitz_surface == NULL) {
- XCloseDisplay (closure->dpy);
- free (closure);
- return NULL;
- }
-
- surface = cairo_glitz_surface_create (glitz_surface);
-
- cairo_surface_set_user_data (surface, &closure_key, closure, cleanup);
-
- return surface;
-}
-
-#elif CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
-#include <glitz-agl.h>
-
-static void
-cleanup (void *data)
-{
- glitz_agl_fini ();
-}
-
-static glitz_surface_t *
-_glitz_agl_create_surface (glitz_format_name_t formatname,
- int width,
- int height)
-{
- glitz_drawable_format_t * dformat = NULL;
- glitz_drawable_t * drawable = NULL;
- glitz_format_t * format;
- glitz_format_t templ;
- glitz_surface_t * sr;
- int i;
- int alpha_size;
-
- glitz_agl_init ();
-
- /* Find a reasonably lame window format and use it to create a pbuffer. */
- i = 0;
- alpha_size = (formatname == GLITZ_STANDARD_ARGB32) ? 8 : 0;
- while ((dformat = glitz_agl_find_window_format (0, 0, i)) != NULL
- && !(dformat->doublebuffer == 0
- && dformat->stencil_size == 0
- && dformat->depth_size == 0
- && dformat->color.fourcc == GLITZ_FOURCC_RGB
- && dformat->color.alpha_size == alpha_size))
- i++;
-
- if (!dformat)
- goto FAIL;
-
- /* Try for a pbuffer first */
- drawable = glitz_agl_create_pbuffer_drawable (dformat, width, height);
- if (!drawable)
- goto FAIL;
-
- templ.color = dformat->color;
- format = glitz_find_format (drawable,
- GLITZ_FORMAT_FOURCC_MASK |
- GLITZ_FORMAT_RED_SIZE_MASK |
- GLITZ_FORMAT_GREEN_SIZE_MASK |
- GLITZ_FORMAT_BLUE_SIZE_MASK |
- GLITZ_FORMAT_ALPHA_SIZE_MASK,
- &templ,
- 0);
- if (!format) {
- fprintf (stderr, "Error: couldn't find surface format\n");
- return NULL;
- }
-
- sr = glitz_surface_create (drawable, format, width, height, 0, NULL);
- if (!sr)
- goto DESTROY_DRAWABLE;
-
- glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
- glitz_drawable_destroy (drawable);
-
- return sr;
- DESTROY_DRAWABLE:
- glitz_drawable_destroy (drawable);
- FAIL:
- return NULL;
-}
-
-static cairo_surface_t *
-create_source_surface (int size)
-{
- glitz_surface_t *glitz_surface;
- cairo_surface_t *surface;
-
- glitz_surface = _glitz_agl_create_surface (GLITZ_STANDARD_ARGB32,
- size, size);
-
- surface = cairo_glitz_surface_create (glitz_surface);
- cairo_surface_set_user_data (surface, &closure_key, NULL, cleanup);
- return surface;
-}
-#endif
-
-CAIRO_TEST (glitz_surface_source,
- "Test using a Glitz surface as the source",
- "source", /* keywords */
- NULL, /* requirements */
- SIZE, SIZE,
- preamble, draw)
diff --git a/test/glitz-surface-source.ps2.ref.png b/test/glitz-surface-source.ps2.ref.png
deleted file mode 100644
index 1023158..0000000
--- a/test/glitz-surface-source.ps2.ref.png
+++ /dev/null
Binary files differ
diff --git a/test/glitz-surface-source.ps3.ref.png b/test/glitz-surface-source.ps3.ref.png
deleted file mode 100644
index 1023158..0000000
--- a/test/glitz-surface-source.ps3.ref.png
+++ /dev/null
Binary files differ
diff --git a/test/glitz-surface-source.rgb24.ref.png b/test/glitz-surface-source.rgb24.ref.png
deleted file mode 100644
index 0d68a82..0000000
--- a/test/glitz-surface-source.rgb24.ref.png
+++ /dev/null
Binary files differ
diff --git a/util/cairo.modules b/util/cairo.modules
index d41ea1b..71a3922 100644
--- a/util/cairo.modules
+++ b/util/cairo.modules
@@ -6,20 +6,12 @@
<repository type="git" name="git.freedesktop.org" href="git://anongit.freedesktop.org/git/"/>
- <autotools id="glitz">
- <branch repo="git.freedesktop.org" module="glitz"/>
- <dependencies>
- <dep package="libGL"/>
- </dependencies>
- </autotools>
-
- <autotools id="cairo" autogenargs="--enable-gl --enable-glitz">
+ <autotools id="cairo" autogenargs="--enable-gl">
<branch repo="git.freedesktop.org" module="cairo"/>
<dependencies>
<dep package="pixman"/>
<dep package="fontconfig"/>
<dep package="libGL"/>
- <dep package="glitz"/>
</dependencies>
<after>
<dep package="libXrender"/>