diff options
author | Benjamin Otte <otte@redhat.com> | 2010-01-27 09:56:14 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-01-27 09:56:14 +0100 |
commit | 58980b4ad60a60923a59370c81d59bb0457a7922 (patch) | |
tree | 568fdd7f5a8449f0df75200907fec668844b1cd8 | |
parent | 17ddb1598b3df374b6275d907441f34318b4257f (diff) |
build: Remove glitz surface
glitz is unmaintained and the GL surface is far superior anyway.
28 files changed, 3 insertions, 3624 deletions
@@ -6,8 +6,8 @@ What is cairo | |||
6 | Cairo is a 2D graphics library with support for multiple output | 6 | Cairo is a 2D graphics library with support for multiple output |
7 | devices. Currently supported output targets include the X Window | 7 | devices. Currently supported output targets include the X Window |
8 | System, quartz, win32, and image buffers, as well as PDF, PostScript, | 8 | System, quartz, win32, and image buffers, as well as PDF, PostScript, |
9 | and SVG file output. Experimental backends include OpenGL (through | 9 | and SVG file output. Experimental backends include OpenGL, XCB, BeOS, |
10 | glitz), XCB, BeOS, OS/2, and DirectFB. | 10 | OS/2, and DirectFB. |
11 | 11 | ||
12 | Cairo is designed to produce consistent output on all output media | 12 | Cairo is designed to produce consistent output on all output media |
13 | while taking advantage of display hardware acceleration when available | 13 | while taking advantage of display hardware acceleration when available |
@@ -163,10 +163,6 @@ Font backends (required to have at least one) | |||
163 | 163 | ||
164 | Experimental surface backends | 164 | Experimental surface backends |
165 | ----------------------------- | 165 | ----------------------------- |
166 | glitz | ||
167 | ------------- | ||
168 | glitz >= 0.4.4 http://freedesktop.org/Software/glitz | ||
169 | |||
170 | xcb backend | 166 | xcb backend |
171 | ----------- | 167 | ----------- |
172 | XCB http://xcb.freedesktop.org | 168 | XCB http://xcb.freedesktop.org |
diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am index 10fb6af31..547f41567 100644 --- a/boilerplate/Makefile.am +++ b/boilerplate/Makefile.am | |||
@@ -32,19 +32,6 @@ if CAIRO_HAS_BEOS_SURFACE | |||
32 | AM_CPPFLAGS += -Wno-multichar | 32 | AM_CPPFLAGS += -Wno-multichar |
33 | endif | 33 | endif |
34 | 34 | ||
35 | if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE | ||
36 | libcairoboilerplate_la_LIBADD += $(GLITZ_AGL_LIBS) | ||
37 | endif | ||
38 | if CAIRO_CAN_TEST_GLITZ_EGL_SURFACE | ||
39 | libcairoboilerplate_la_LIBADD += $(GLITZ_EGL_LIBS) | ||
40 | endif | ||
41 | if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE | ||
42 | libcairoboilerplate_la_LIBADD += $(GLITZ_GLX_LIBS) | ||
43 | endif | ||
44 | if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE | ||
45 | libcairoboilerplate_la_LIBADD += $(GLITZ_WGL_LIBS) | ||
46 | endif | ||
47 | |||
48 | if CAIRO_HAS_WIN32_SURFACE | 35 | if CAIRO_HAS_WIN32_SURFACE |
49 | libcairoboilerplate_la_LIBADD += -lwinspool | 36 | libcairoboilerplate_la_LIBADD += -lwinspool |
50 | endif | 37 | endif |
diff --git a/boilerplate/Makefile.sources b/boilerplate/Makefile.sources index d40d7f9fe..b590b7f1a 100644 --- a/boilerplate/Makefile.sources +++ b/boilerplate/Makefile.sources | |||
@@ -26,11 +26,6 @@ cairo_boilerplate_private = \ | |||
26 | cairo_boilerplate_directfb_sources = cairo-boilerplate-directfb.c | 26 | cairo_boilerplate_directfb_sources = cairo-boilerplate-directfb.c |
27 | cairo_boilerplate_drm_sources = cairo-boilerplate-drm.c | 27 | cairo_boilerplate_drm_sources = cairo-boilerplate-drm.c |
28 | cairo_boilerplate_gl_sources = cairo-boilerplate-gl.c | 28 | cairo_boilerplate_gl_sources = cairo-boilerplate-gl.c |
29 | cairo_boilerplate_glitz_sources = \ | ||
30 | cairo-boilerplate-glitz-agl.c \ | ||
31 | cairo-boilerplate-glitz-glx.c \ | ||
32 | cairo-boilerplate-glitz-wgl.c \ | ||
33 | $(NULL) | ||
34 | cairo_boilerplate_pdf_sources = cairo-boilerplate-pdf.c | 29 | cairo_boilerplate_pdf_sources = cairo-boilerplate-pdf.c |
35 | cairo_boilerplate_ps_sources = cairo-boilerplate-ps.c | 30 | cairo_boilerplate_ps_sources = cairo-boilerplate-ps.c |
36 | cairo_boilerplate_qt_sources = cairo-boilerplate-qt.cpp | 31 | cairo_boilerplate_qt_sources = cairo-boilerplate-qt.cpp |
diff --git a/boilerplate/Makefile.win32.features b/boilerplate/Makefile.win32.features index 07427872b..bcf41a8ce 100644 --- a/boilerplate/Makefile.win32.features +++ b/boilerplate/Makefile.win32.features | |||
@@ -209,16 +209,6 @@ enabled_cairo_boilerplate_private += $(cairo_boilerplate_gl_private) | |||
209 | enabled_cairo_boilerplate_sources += $(cairo_boilerplate_gl_sources) | 209 | enabled_cairo_boilerplate_sources += $(cairo_boilerplate_gl_sources) |
210 | endif | 210 | endif |
211 | 211 | ||
212 | unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_glitz_headers) | ||
213 | all_cairo_boilerplate_headers += $(cairo_boilerplate_glitz_headers) | ||
214 | all_cairo_boilerplate_private += $(cairo_boilerplate_glitz_private) | ||
215 | all_cairo_boilerplate_sources += $(cairo_boilerplate_glitz_sources) | ||
216 | ifeq ($(CAIRO_HAS_GLITZ_SURFACE),1) | ||
217 | enabled_cairo_boilerplate_headers += $(cairo_boilerplate_glitz_headers) | ||
218 | enabled_cairo_boilerplate_private += $(cairo_boilerplate_glitz_private) | ||
219 | enabled_cairo_boilerplate_sources += $(cairo_boilerplate_glitz_sources) | ||
220 | endif | ||
221 | |||
222 | unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_directfb_headers) | 212 | unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_directfb_headers) |
223 | all_cairo_boilerplate_headers += $(cairo_boilerplate_directfb_headers) | 213 | all_cairo_boilerplate_headers += $(cairo_boilerplate_directfb_headers) |
224 | all_cairo_boilerplate_private += $(cairo_boilerplate_directfb_private) | 214 | 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 679593bca..000000000 --- a/boilerplate/cairo-boilerplate-glitz-agl.c +++ /dev/null | |||
@@ -1,191 +0,0 @@ | |||
1 | /* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ | ||
2 | /* | ||
3 | * Copyright © 2004,2006 Red Hat, Inc. | ||
4 | * | ||
5 | * Permission to use, copy, modify, distribute, and sell this software | ||
6 | * and its documentation for any purpose is hereby granted without | ||
7 | * fee, provided that the above copyright notice appear in all copies | ||
8 | * and that both that copyright notice and this permission notice | ||
9 | * appear in supporting documentation, and that the name of | ||
10 | * Red Hat, Inc. not be used in advertising or publicity pertaining to | ||
11 | * distribution of the software without specific, written prior | ||
12 | * permission. Red Hat, Inc. makes no representations about the | ||
13 | * suitability of this software for any purpose. It is provided "as | ||
14 | * is" without express or implied warranty. | ||
15 | * | ||
16 | * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS | ||
17 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
18 | * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, | ||
19 | * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER | ||
20 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | ||
21 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
22 | * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
23 | * | ||
24 | * Author: Carl D. Worth <cworth@cworth.org> | ||
25 | */ | ||
26 | |||
27 | #include "cairo-boilerplate-private.h" | ||
28 | |||
29 | #if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE | ||
30 | #include <cairo-glitz.h> | ||
31 | #include <glitz-agl.h> | ||
32 | |||
33 | static const cairo_user_data_key_t glitz_closure_key; | ||
34 | |||
35 | typedef struct _glitz_agl_target_closure { | ||
36 | glitz_target_closure_base_t base; | ||
37 | } glitz_agl_target_closure_t; | ||
38 | |||
39 | static glitz_surface_t * | ||
40 | _cairo_boilerplate_glitz_agl_create_surface_internal (glitz_format_name_t formatname, | ||
41 | int width, | ||
42 | int height, | ||
43 | glitz_agl_target_closure_t *closure) | ||
44 | { | ||
45 | glitz_drawable_format_t *dformat; | ||
46 | glitz_drawable_format_t templ; | ||
47 | glitz_drawable_t *gdraw; | ||
48 | glitz_format_t *format; | ||
49 | glitz_surface_t *sr = NULL; | ||
50 | unsigned long mask; | ||
51 | |||
52 | memset(&templ, 0, sizeof(templ)); | ||
53 | templ.color.red_size = 8; | ||
54 | templ.color.green_size = 8; | ||
55 | templ.color.blue_size = 8; | ||
56 | templ.color.alpha_size = 8; | ||
57 | templ.color.fourcc = GLITZ_FOURCC_RGB; | ||
58 | templ.samples = 1; | ||
59 | |||
60 | mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK | | ||
61 | GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK | | ||
62 | GLITZ_FORMAT_BLUE_SIZE_MASK; | ||
63 | if (formatname == GLITZ_STANDARD_ARGB32) | ||
64 | mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK; | ||
65 | |||
66 | dformat = glitz_agl_find_pbuffer_format (mask, &templ, 0); | ||
67 | if (!dformat) { | ||
68 | fprintf (stderr, "Glitz failed to find pbuffer format for template."); | ||
69 | goto FAIL; | ||
70 | } | ||
71 | |||
72 | gdraw = glitz_agl_create_pbuffer_drawable (dformat, width, height); | ||
73 | if (!gdraw) { | ||
74 | fprintf (stderr, "Glitz failed to create pbuffer drawable."); | ||
75 | goto FAIL; | ||
76 | } | ||
77 | |||
78 | format = glitz_find_standard_format (gdraw, formatname); | ||
79 | if (!format) { | ||
80 | fprintf (stderr, "Glitz failed to find standard format for drawable."); | ||
81 | goto DESTROY_DRAWABLE; | ||
82 | } | ||
83 | |||
84 | sr = glitz_surface_create (gdraw, format, width, height, 0, NULL); | ||
85 | if (!sr) { | ||
86 | fprintf (stderr, "Glitz failed to create a surface."); | ||
87 | goto DESTROY_DRAWABLE; | ||
88 | } | ||
89 | |||
90 | glitz_surface_attach (sr, gdraw, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR); | ||
91 | |||
92 | DESTROY_DRAWABLE: | ||
93 | glitz_drawable_destroy (gdraw); | ||
94 | return sr; | ||
95 | |||
96 | FAIL: | ||
97 | return NULL; | ||
98 | } | ||
99 | |||
100 | static cairo_surface_t * | ||
101 | _cairo_boilerplate_glitz_agl_create_surface (const char *name, | ||
102 | cairo_content_t content, | ||
103 | double width, | ||
104 | double height, | ||
105 | double max_width, | ||
106 | double max_height, | ||
107 | cairo_boilerplate_mode_t mode, | ||
108 | int id, | ||
109 | void **closure) | ||
110 | { | ||
111 | glitz_surface_t *glitz_surface; | ||
112 | cairo_surface_t *surface = NULL; | ||
113 | glitz_agl_target_closure_t *aglc; | ||
114 | int status; | ||
115 | |||
116 | glitz_agl_init (); | ||
117 | |||
118 | *closure = aglc = xmalloc (sizeof (glitz_agl_target_closure_t)); | ||
119 | |||
120 | switch (content) { | ||
121 | case CAIRO_CONTENT_COLOR: | ||
122 | glitz_surface = _cairo_boilerplate_glitz_agl_create_surface_internal (GLITZ_STANDARD_RGB24, width, height, NULL); | ||
123 | break; | ||
124 | case CAIRO_CONTENT_COLOR_ALPHA: | ||
125 | glitz_surface = _cairo_boilerplate_glitz_agl_create_surface_internal (GLITZ_STANDARD_ARGB32, width, height, NULL); | ||
126 | break; | ||
127 | case CAIRO_CONTENT_ALPHA: | ||
128 | default: | ||
129 | fprintf (stderr, "Invalid content for glitz-agl test: %d\n", content); | ||
130 | goto FAIL; | ||
131 | } | ||
132 | |||
133 | if (!glitz_surface) | ||
134 | goto FAIL; | ||
135 | |||
136 | surface = cairo_glitz_surface_create (glitz_surface); | ||
137 | glitz_surface_destroy (glitz_surface); | ||
138 | |||
139 | if (cairo_surface_status (surface)) | ||
140 | goto FAIL; | ||
141 | |||
142 | aglc->base.width = width; | ||
143 | aglc->base.height = height; | ||
144 | aglc->base.content = content; | ||
145 | status = cairo_surface_set_user_data (surface, | ||
146 | &glitz_closure_key, aglc, NULL); | ||
147 | if (status == CAIRO_STATUS_SUCCESS) | ||
148 | return surface; | ||
149 | |||
150 | cairo_surface_destroy (surface); | ||
151 | surface = cairo_boilerplate_surface_create_in_error (status); | ||
152 | |||
153 | FAIL: | ||
154 | glitz_agl_fini (); | ||
155 | return surface; | ||
156 | } | ||
157 | |||
158 | static void | ||
159 | _cairo_boilerplate_glitz_agl_cleanup (void *closure) | ||
160 | { | ||
161 | free (closure); | ||
162 | glitz_agl_fini (); | ||
163 | } | ||
164 | |||
165 | #endif | ||
166 | |||
167 | static const cairo_boilerplate_target_t targets[] = { | ||
168 | #if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE | ||
169 | { | ||
170 | "glitz-agl", "glitz", NULL, NULL, | ||
171 | CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR_ALPHA, 0, | ||
172 | "cairo_glitz_surface_create", | ||
173 | _cairo_boilerplate_glitz_agl_create_surface, | ||
174 | NULL, NULL, | ||
175 | _cairo_boilerplate_get_image_surface, | ||
176 | cairo_surface_write_to_png, | ||
177 | _cairo_boilerplate_glitz_agl_cleanup | ||
178 | }, | ||
179 | { | ||
180 | "glitz-agl", "glitz", NULL, NULL, | ||
181 | CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0, | ||
182 | "cairo_glitz_surface_create", | ||
183 | _cairo_boilerplate_glitz_agl_create_surface, | ||
184 | NULL, NULL, | ||
185 | _cairo_boilerplate_get_image_surface, | ||
186 | cairo_surface_write_to_png, | ||
187 | _cairo_boilerplate_glitz_agl_cleanup | ||
188 | }, | ||
189 | #endif | ||
190 | }; | ||
191 | 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 d490aecb7..000000000 --- a/boilerplate/cairo-boilerplate-glitz-glx.c +++ /dev/null | |||
@@ -1,265 +0,0 @@ | |||
1 | /* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ | ||
2 | /* | ||
3 | * Copyright © 2004,2006 Red Hat, Inc. | ||
4 | * | ||
5 | * Permission to use, copy, modify, distribute, and sell this software | ||
6 | * and its documentation for any purpose is hereby granted without | ||
7 | * fee, provided that the above copyright notice appear in all copies | ||
8 | * and that both that copyright notice and this permission notice | ||
9 | * appear in supporting documentation, and that the name of | ||
10 | * Red Hat, Inc. not be used in advertising or publicity pertaining to | ||
11 | * distribution of the software without specific, written prior | ||
12 | * permission. Red Hat, Inc. makes no representations about the | ||
13 | * suitability of this software for any purpose. It is provided "as | ||
14 | * is" without express or implied warranty. | ||
15 | * | ||
16 | * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS | ||
17 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
18 | * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, | ||
19 | * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER | ||
20 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | ||
21 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
22 | * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
23 | * | ||
24 | * Author: Carl D. Worth <cworth@cworth.org> | ||
25 | */ | ||
26 | |||
27 | #include "cairo-boilerplate-private.h" | ||
28 | |||
29 | #if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE | ||
30 | #include <cairo-glitz.h> | ||
31 | #include <glitz-glx.h> | ||
32 | |||
33 | static const cairo_user_data_key_t glitz_closure_key; | ||
34 | |||
35 | typedef struct _glitz_glx_target_closure { | ||
36 | Display *dpy; | ||
37 | int scr; | ||
38 | Window win; | ||
39 | } glitz_glx_target_closure_t; | ||
40 | |||
41 | static glitz_surface_t * | ||
42 | _cairo_boilerplate_glitz_glx_create_surface_internal (glitz_format_name_t formatname, | ||
43 | int width, | ||
44 | int height, | ||
45 | glitz_glx_target_closure_t *closure) | ||
46 | { | ||
47 | Display * dpy = closure->dpy; | ||
48 | int scr = closure->scr; | ||
49 | glitz_drawable_format_t templ; | ||
50 | glitz_drawable_format_t * dformat = NULL; | ||
51 | unsigned long mask; | ||
52 | glitz_drawable_t * drawable = NULL; | ||
53 | glitz_format_t * format; | ||
54 | glitz_surface_t * sr; | ||
55 | |||
56 | XSizeHints xsh; | ||
57 | XSetWindowAttributes xswa; | ||
58 | XVisualInfo * vinfo; | ||
59 | |||
60 | memset(&templ, 0, sizeof(templ)); | ||
61 | templ.color.red_size = 8; | ||
62 | templ.color.green_size = 8; | ||
63 | templ.color.blue_size = 8; | ||
64 | templ.color.alpha_size = 8; | ||
65 | templ.color.fourcc = GLITZ_FOURCC_RGB; | ||
66 | templ.samples = 1; | ||
67 | |||
68 | glitz_glx_init (NULL); | ||
69 | |||
70 | mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK | | ||
71 | GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK | | ||
72 | GLITZ_FORMAT_BLUE_SIZE_MASK; | ||
73 | if (formatname == GLITZ_STANDARD_ARGB32) | ||
74 | mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK; | ||
75 | |||
76 | /* Try for a pbuffer first */ | ||
77 | if (!getenv("CAIRO_TEST_FORCE_GLITZ_WINDOW")) | ||
78 | dformat = glitz_glx_find_pbuffer_format (dpy, scr, mask, &templ, 0); | ||
79 | |||
80 | if (dformat) { | ||
81 | closure->win = None; | ||
82 | |||
83 | drawable = glitz_glx_create_pbuffer_drawable (dpy, scr, dformat, | ||
84 | width, height); | ||
85 | if (!drawable) | ||
86 | goto FAIL; | ||
87 | } else { | ||
88 | /* No pbuffer, try window */ | ||
89 | dformat = glitz_glx_find_window_format (dpy, scr, mask, &templ, 0); | ||
90 | |||
91 | if (!dformat) | ||
92 | goto FAIL; | ||
93 | |||
94 | vinfo = glitz_glx_get_visual_info_from_format(dpy, | ||
95 | DefaultScreen(dpy), | ||
96 | dformat); | ||
97 | |||
98 | if (!vinfo) | ||
99 | goto FAIL; | ||
100 | |||
101 | xsh.flags = PSize; | ||
102 | xsh.x = 0; | ||
103 | xsh.y = 0; | ||
104 | xsh.width = width; | ||
105 | xsh.height = height; | ||
106 | |||
107 | xswa.colormap = XCreateColormap (dpy, RootWindow(dpy, scr), | ||
108 | vinfo->visual, AllocNone); | ||
109 | closure->win = XCreateWindow (dpy, RootWindow(dpy, scr), | ||
110 | xsh.x, xsh.y, xsh.width, xsh.height, | ||
111 | 0, vinfo->depth, CopyFromParent, | ||
112 | vinfo->visual, CWColormap, &xswa); | ||
113 | XFree (vinfo); | ||
114 | |||
115 | drawable = | ||
116 | glitz_glx_create_drawable_for_window (dpy, scr, | ||
117 | dformat, closure->win, | ||
118 | width, height); | ||
119 | |||
120 | if (!drawable) | ||
121 | goto DESTROY_WINDOW; | ||
122 | } | ||
123 | |||
124 | format = glitz_find_standard_format (drawable, formatname); | ||
125 | if (!format) | ||
126 | goto DESTROY_DRAWABLE; | ||
127 | |||
128 | sr = glitz_surface_create (drawable, format, width, height, 0, NULL); | ||
129 | if (!sr) | ||
130 | goto DESTROY_DRAWABLE; | ||
131 | |||
132 | if (closure->win == None || dformat->doublebuffer) { | ||
133 | glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_BACK_COLOR); | ||
134 | } else { | ||
135 | XMapWindow (closure->dpy, closure->win); | ||
136 | glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR); | ||
137 | } | ||
138 | |||
139 | glitz_drawable_destroy (drawable); | ||
140 | |||
141 | return sr; | ||
142 | |||
143 | DESTROY_DRAWABLE: | ||
144 | glitz_drawable_destroy (drawable); | ||
145 | DESTROY_WINDOW: | ||
146 | if (closure->win) | ||
147 | XDestroyWindow (dpy, closure->win); | ||
148 | FAIL: | ||
149 | return NULL; | ||
150 | } | ||
151 | |||
152 | static cairo_surface_t * | ||
153 | _cairo_boilerplate_glitz_glx_create_surface (const char *name, | ||
154 | cairo_content_t content, | ||
155 | double width, | ||
156 | double height, | ||
157 | double max_width, | ||
158 | double max_height, | ||
159 | cairo_boilerplate_mode_t mode, | ||
160 | int id, | ||
161 | void **closure) | ||
162 | { | ||
163 | glitz_glx_target_closure_t *gxtc; | ||
164 | glitz_surface_t * glitz_surface; | ||
165 | cairo_surface_t * surface = NULL; | ||
166 | cairo_status_t status; | ||
167 | |||
168 | *closure = gxtc = xmalloc (sizeof (glitz_glx_target_closure_t)); | ||
169 | |||
170 | if (width == 0) | ||
171 | width = 1; | ||
172 | if (height == 0) | ||
173 | height = 1; | ||
174 | |||
175 | gxtc->dpy = XOpenDisplay (getenv("CAIRO_TEST_GLITZ_DISPLAY")); | ||
176 | if (!gxtc->dpy) { | ||
177 | fprintf (stderr, "Failed to open display: %s\n", XDisplayName(0)); | ||
178 | goto FAIL; | ||
179 | } | ||
180 | |||
181 | XSynchronize (gxtc->dpy, 1); | ||
182 | |||
183 | gxtc->scr = DefaultScreen(gxtc->dpy); | ||
184 | |||
185 | switch (content) { | ||
186 | case CAIRO_CONTENT_COLOR: | ||
187 | glitz_surface = _cairo_boilerplate_glitz_glx_create_surface_internal (GLITZ_STANDARD_RGB24, width, height, gxtc); | ||
188 | break; | ||
189 | case CAIRO_CONTENT_COLOR_ALPHA: | ||
190 | glitz_surface = _cairo_boilerplate_glitz_glx_create_surface_internal (GLITZ_STANDARD_ARGB32, width, height, gxtc); | ||
191 | break; | ||
192 | case CAIRO_CONTENT_ALPHA: | ||
193 | default: | ||
194 | fprintf (stderr, "Invalid content for glitz-glx test: %d\n", content); | ||
195 | goto FAIL_CLOSE_DISPLAY; | ||
196 | } | ||
197 | if (!glitz_surface) { | ||
198 | fprintf (stderr, "Failed to create glitz-glx surface\n"); | ||
199 | goto FAIL_CLOSE_DISPLAY; | ||
200 | } | ||
201 | |||
202 | surface = cairo_glitz_surface_create (glitz_surface); | ||
203 | glitz_surface_destroy (glitz_surface); | ||
204 | |||
205 | if (cairo_surface_status (surface)) | ||
206 | goto FAIL_CLOSE_DISPLAY; | ||
207 | |||
208 | status = cairo_surface_set_user_data (surface, | ||
209 | &glitz_closure_key, gxtc, NULL); | ||
210 | if (status == CAIRO_STATUS_SUCCESS) | ||
211 | return surface; | ||
212 | |||
213 | cairo_surface_destroy (surface); | ||
214 | surface = cairo_boilerplate_surface_create_in_error (status); | ||
215 | |||
216 | FAIL_CLOSE_DISPLAY: | ||
217 | glitz_glx_fini (); | ||
218 | XCloseDisplay (gxtc->dpy); | ||
219 | FAIL: | ||
220 | free (gxtc); | ||
221 | return surface; | ||
222 | } | ||
223 | |||
224 | static void | ||
225 | _cairo_boilerplate_glitz_glx_cleanup (void *closure) | ||
226 | { | ||
227 | glitz_glx_target_closure_t *gxtc = closure; | ||
228 | |||
229 | glitz_glx_fini (); | ||
230 | |||
231 | if (gxtc->win) | ||
232 | XDestroyWindow (gxtc->dpy, gxtc->win); | ||
233 | |||
234 | XCloseDisplay (gxtc->dpy); | ||
235 | |||
236 | free (gxtc); | ||
237 | } | ||
238 | |||
239 | #endif | ||
240 | |||
241 | static const cairo_boilerplate_target_t targets[] = { | ||
242 | #if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE | ||
243 | { | ||
244 | "glitz-glx", "glitz", NULL, NULL, | ||
245 | CAIRO_SURFACE_TYPE_GLITZ,CAIRO_CONTENT_COLOR_ALPHA, 0, | ||
246 | "cairo_glitz_surface_create", | ||
247 | _cairo_boilerplate_glitz_glx_create_surface, | ||
248 | NULL, NULL, | ||
249 | _cairo_boilerplate_get_image_surface, | ||
250 | cairo_surface_write_to_png, | ||
251 | _cairo_boilerplate_glitz_glx_cleanup | ||
252 | }, | ||
253 | { | ||
254 | "glitz-glx", "glitz", NULL, NULL, | ||
255 | CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0, | ||
256 | "cairo_glitz_surface_create", | ||
257 | _cairo_boilerplate_glitz_glx_create_surface, | ||
258 | NULL, NULL, | ||
259 | _cairo_boilerplate_get_image_surface, | ||
260 | cairo_surface_write_to_png, | ||
261 | _cairo_boilerplate_glitz_glx_cleanup | ||
262 | }, | ||
263 | #endif | ||
264 | }; | ||
265 | 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 f50d68b7c..000000000 --- a/boilerplate/cairo-boilerplate-glitz-wgl.c +++ /dev/null | |||
@@ -1,188 +0,0 @@ | |||
1 | /* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ | ||
2 | /* | ||
3 | * Copyright © 2004,2006 Red Hat, Inc. | ||
4 | * | ||
5 | * Permission to use, copy, modify, distribute, and sell this software | ||
6 | * and its documentation for any purpose is hereby granted without | ||
7 | * fee, provided that the above copyright notice appear in all copies | ||
8 | * and that both that copyright notice and this permission notice | ||
9 | * appear in supporting documentation, and that the name of | ||
10 | * Red Hat, Inc. not be used in advertising or publicity pertaining to | ||
11 | * distribution of the software without specific, written prior | ||
12 | * permission. Red Hat, Inc. makes no representations about the | ||
13 | * suitability of this software for any purpose. It is provided "as | ||
14 | * is" without express or implied warranty. | ||
15 | * | ||
16 | * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS | ||
17 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
18 | * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, | ||
19 | * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER | ||
20 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | ||
21 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
22 | * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
23 | * | ||
24 | * Author: Carl D. Worth <cworth@cworth.org> | ||
25 | */ | ||
26 | |||
27 | #include "cairo-boilerplate-private.h" | ||
28 | |||
29 | #if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE | ||
30 | #include <cairo-glitz.h> | ||
31 | #include <glitz-wgl.h> | ||
32 | |||
33 | static const cairo_user_data_key_t glitz_closure_key; | ||
34 | |||
35 | typedef struct _glitz_wgl_target_closure { | ||
36 | glitz_target_closure_base_t base; | ||
37 | } glitz_wgl_target_closure_t; | ||
38 | |||
39 | static glitz_surface_t * | ||
40 | _cairo_boilerplate_glitz_wgl_create_surface_internal (glitz_format_name_t formatname, | ||
41 | int width, | ||
42 | int height, | ||
43 | glitz_wgl_target_closure_t *closure) | ||
44 | { | ||
45 | glitz_drawable_format_t *dformat; | ||
46 | glitz_drawable_format_t templ; | ||
47 | glitz_drawable_t *gdraw; | ||
48 | glitz_format_t *format; | ||
49 | glitz_surface_t *sr = NULL; | ||
50 | unsigned long mask; | ||
51 | |||
52 | memset(&templ, 0, sizeof(templ)); | ||
53 | templ.color.red_size = 8; | ||
54 | templ.color.green_size = 8; | ||
55 | templ.color.blue_size = 8; | ||
56 | templ.color.alpha_size = 8; | ||
57 | templ.color.fourcc = GLITZ_FOURCC_RGB; | ||
58 | templ.samples = 1; | ||
59 | |||
60 | mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK | | ||
61 | GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK | | ||
62 | GLITZ_FORMAT_BLUE_SIZE_MASK; | ||
63 | if (formatname == GLITZ_STANDARD_ARGB32) | ||
64 | mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK; | ||
65 | |||
66 | dformat = glitz_wgl_find_pbuffer_format (mask, &templ, 0); | ||
67 | if (!dformat) { | ||
68 | fprintf (stderr, "Glitz failed to find pbuffer format for template."); | ||
69 | goto FAIL; | ||
70 | } | ||
71 | |||
72 | gdraw = glitz_wgl_create_pbuffer_drawable (dformat, width, height); | ||
73 | if (!gdraw) { | ||
74 | fprintf (stderr, "Glitz failed to create pbuffer drawable."); | ||
75 | goto FAIL; | ||
76 | } | ||
77 | |||
78 | format = glitz_find_standard_format (gdraw, formatname); | ||
79 | if (!format) { | ||
80 | fprintf (stderr, "Glitz failed to find standard format for drawable."); | ||
81 | goto DESTROY_DRAWABLE; | ||
82 | } | ||
83 | |||
84 | sr = glitz_surface_create (gdraw, format, width, height, 0, NULL); | ||
85 | if (!sr) { | ||
86 | fprintf (stderr, "Glitz failed to create a surface."); | ||
87 | goto DESTROY_DRAWABLE; | ||
88 | } | ||
89 | |||
90 | glitz_surface_attach (sr, gdraw, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR); | ||
91 | |||
92 | DESTROY_DRAWABLE: | ||
93 | glitz_drawable_destroy (gdraw); | ||
94 | |||
95 | FAIL: | ||
96 | return sr; /* will be NULL unless we create it and attach */ | ||
97 | } | ||
98 | |||
99 | static cairo_surface_t * | ||
100 | _cairo_boilerplate_glitz_wgl_create_surface (const char *name, | ||
101 | cairo_content_t content, | ||
102 | double width, | ||
103 | double height, | ||
104 | double max_width, | ||
105 | double max_height, | ||
106 | cairo_boilerplate_mode_t mode, | ||
107 | int id, | ||
108 | void **closure) | ||
109 | { | ||
110 | glitz_surface_t *glitz_surface; | ||
111 | cairo_surface_t *surface = NULL; | ||
112 | glitz_wgl_target_closure_t *wglc; | ||
113 | |||
114 | glitz_wgl_init (NULL); | ||
115 | |||
116 | *closure = wglc = xmalloc (sizeof (glitz_wgl_target_closure_t)); | ||
117 | |||
118 | switch (content) { | ||
119 | case CAIRO_CONTENT_COLOR: | ||
120 | glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface_internal (GLITZ_STANDARD_RGB24, width, height, NULL); | ||
121 | break; | ||
122 | case CAIRO_CONTENT_COLOR_ALPHA: | ||
123 | glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface_internal (GLITZ_STANDARD_ARGB32, width, height, NULL); | ||
124 | break; | ||
125 | default: | ||
126 | fprintf (stderr, "Invalid content for glitz-wgl test: %d\n", content); | ||
127 | goto FAIL; | ||
128 | } | ||
129 | |||
130 | if (!glitz_surface) | ||
131 | goto FAIL; | ||
132 | |||
133 | surface = cairo_glitz_surface_create (glitz_surface); | ||
134 | glitz_surface_destroy (glitz_surface); | ||
135 | |||
136 | if (cairo_surface_status (surface)) | ||
137 | goto FAIL; | ||
138 | |||
139 | wglc->base.width = width; | ||
140 | wglc->base.height = height; | ||
141 | wglc->base.content = content; | ||
142 | status = cairo_surface_set_user_data (surface, | ||
143 | &glitz_closure_key, wglc, NULL); | ||
144 | if (status == CAIRO_STATUS_SUCCESS) | ||
145 | return surface; | ||
146 | |||
147 | cairo_surface_destroy (surface); | ||
148 | surface = cairo_boilerplate_surface_create_in_error (status); | ||
149 | |||
150 | FAIL: | ||
151 | glitz_wgl_fini (); | ||
152 | free (wglc); | ||
153 | return surface; | ||
154 | } | ||
155 | |||
156 | static void | ||
157 | _cairo_boilerplate_glitz_wgl_cleanup (void *closure) | ||
158 | { | ||
159 | free (closure); | ||
160 | glitz_wgl_fini (); | ||
161 | } | ||
162 | #endif | ||
163 | |||
164 | static const cairo_boilerplate_target_t targets[] = { | ||
165 | #if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE | ||
166 | { | ||
167 | "glitz-wgl", "glitz", NULL, NULL, | ||
168 | CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR_ALPHA, 0, | ||
169 | "cairo_glitz_surface_create", | ||
170 | _cairo_boilerplate_glitz_wgl_create_surface, | ||
171 | NULL, NULL, | ||
172 | _cairo_boilerplate_get_image_surface, | ||
173 | cairo_surface_write_to_png, | ||
174 | _cairo_boilerplate_glitz_wgl_cleanup | ||
175 | }, | ||
176 | { | ||
177 | "glitz-wgl", "glitz", NULL, NULL, | ||
178 | CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0, | ||
179 | "cairo_glitz_surface_create", | ||
180 | _cairo_boilerplate_glitz_wgl_create_surface, | ||
181 | NULL, NULL, | ||
182 | _cairo_boilerplate_get_image_surface, | ||
183 | cairo_surface_write_to_png, | ||
184 | _cairo_boilerplate_glitz_wgl_cleanup | ||
185 | }, | ||
186 | #endif | ||
187 | }; | ||
188 | CAIRO_BOILERPLATE (glitz_wgl, targets) | ||
diff --git a/build/Makefile.win32.features b/build/Makefile.win32.features index 66938fc06..b32e7fcf1 100644 --- a/build/Makefile.win32.features +++ b/build/Makefile.win32.features | |||
@@ -19,7 +19,6 @@ CAIRO_HAS_GALLIUM_SURFACE=0 | |||
19 | CAIRO_HAS_XCB_DRM_FUNCTIONS=0 | 19 | CAIRO_HAS_XCB_DRM_FUNCTIONS=0 |
20 | CAIRO_HAS_PNG_FUNCTIONS=1 | 20 | CAIRO_HAS_PNG_FUNCTIONS=1 |
21 | CAIRO_HAS_GL_SURFACE=0 | 21 | CAIRO_HAS_GL_SURFACE=0 |
22 | CAIRO_HAS_GLITZ_SURFACE=0 | ||
23 | CAIRO_HAS_DIRECTFB_SURFACE=0 | 22 | CAIRO_HAS_DIRECTFB_SURFACE=0 |
24 | CAIRO_HAS_VG_SURFACE=0 | 23 | CAIRO_HAS_VG_SURFACE=0 |
25 | CAIRO_HAS_EAGLE_FUNCTIONS=0 | 24 | CAIRO_HAS_EAGLE_FUNCTIONS=0 |
diff --git a/build/Makefile.win32.features-h b/build/Makefile.win32.features-h index ca21aba26..c5df7bdbf 100644 --- a/build/Makefile.win32.features-h +++ b/build/Makefile.win32.features-h | |||
@@ -62,9 +62,6 @@ endif | |||
62 | ifeq ($(CAIRO_HAS_GL_SURFACE),1) | 62 | ifeq ($(CAIRO_HAS_GL_SURFACE),1) |
63 | @echo "#define CAIRO_HAS_GL_SURFACE 1" >> src/cairo-features.h | 63 | @echo "#define CAIRO_HAS_GL_SURFACE 1" >> src/cairo-features.h |
64 | endif | 64 | endif |
65 | ifeq ($(CAIRO_HAS_GLITZ_SURFACE),1) | ||
66 | @echo "#define CAIRO_HAS_GLITZ_SURFACE 1" >> src/cairo-features.h | ||
67 | endif | ||
68 | ifeq ($(CAIRO_HAS_DIRECTFB_SURFACE),1) | 65 | ifeq ($(CAIRO_HAS_DIRECTFB_SURFACE),1) |
69 | @echo "#define CAIRO_HAS_DIRECTFB_SURFACE 1" >> src/cairo-features.h | 66 | @echo "#define CAIRO_HAS_DIRECTFB_SURFACE 1" >> src/cairo-features.h |
70 | endif | 67 | endif |
diff --git a/build/configure.ac.features b/build/configure.ac.features index 8c96ed0a0..c4c5bd9d3 100644 --- a/build/configure.ac.features +++ b/build/configure.ac.features | |||
@@ -374,7 +374,6 @@ AC_DEFUN([CAIRO_REPORT], | |||
374 | echo " PDF: $use_pdf" | 374 | echo " PDF: $use_pdf" |
375 | echo " SVG: $use_svg" | 375 | echo " SVG: $use_svg" |
376 | echo " OpenGL: $use_gl" | 376 | echo " OpenGL: $use_gl" |
377 | echo " glitz: $use_glitz" | ||
378 | echo " BeOS: $use_beos" | 377 | echo " BeOS: $use_beos" |
379 | echo " DirectFB: $use_directfb" | 378 | echo " DirectFB: $use_directfb" |
380 | echo " OpenVG: $use_vg" | 379 | echo " OpenVG: $use_vg" |
diff --git a/configure.ac b/configure.ac index 97b0ecf83..2e8a8a539 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -336,44 +336,6 @@ CAIRO_ENABLE_SURFACE_BACKEND(gl, OpenGL, no, [ | |||
336 | 336 | ||
337 | dnl =========================================================================== | 337 | dnl =========================================================================== |
338 | 338 | ||
339 | GLITZ_MIN_VERSION=0.5.1 | ||
340 | CAIRO_ENABLE_SURFACE_BACKEND(glitz, glitz, no, [ | ||
341 | glitz_REQUIRES="glitz >= $GLITZ_MIN_VERSION" | ||
342 | PKG_CHECK_MODULES(glitz, $glitz_REQUIRES, , [AC_MSG_RESULT(no) | ||
343 | use_glitz="no (requires $glitz_REQUIRES http://freedesktop.org/Software/glitz)"]) | ||
344 | ]) | ||
345 | |||
346 | if test "x$use_glitz" = "xyes";then | ||
347 | PKG_CHECK_MODULES(GLITZ_AGL, glitz-agl >= $GLITZ_MIN_VERSION, | ||
348 | [have_glitz_agl=yes], [have_glitz_agl=no; AC_MSG_RESULT(no)]) | ||
349 | PKG_CHECK_MODULES(GLITZ_EGL, glitz-egl >= $GLITZ_MIN_VERSION, | ||
350 | [have_glitz_egl=yes], [have_glitz_egl=no; AC_MSG_RESULT(no)]) | ||
351 | PKG_CHECK_MODULES(GLITZ_GLX, glitz-glx >= $GLITZ_MIN_VERSION, | ||
352 | [have_glitz_glx=yes], [have_glitz_glx=no; AC_MSG_RESULT(no)]) | ||
353 | PKG_CHECK_MODULES(GLITZ_WGL, glitz-wgl >= $GLITZ_MIN_VERSION, | ||
354 | [have_glitz_wgl=yes], [have_glitz_wgl=no; AC_MSG_RESULT(no)]) | ||
355 | |||
356 | if test "x$have_glitz_agl" = "xyes";then | ||
357 | AC_DEFINE(CAIRO_CAN_TEST_GLITZ_AGL_SURFACE, 1, [define if glitz backend can be tested against agl]) | ||
358 | fi | ||
359 | if test "x$have_glitz_egl" = "xyes";then | ||
360 | AC_DEFINE(CAIRO_CAN_TEST_GLITZ_EGL_SURFACE, 1, [define if glitz backend can be tested against egl]) | ||
361 | fi | ||
362 | if test "x$have_glitz_glx" = "xyes";then | ||
363 | AC_DEFINE(CAIRO_CAN_TEST_GLITZ_GLX_SURFACE, 1, [define if glitz backend can be tested against glx]) | ||
364 | fi | ||
365 | if test "x$have_glitz_wgl" = "xyes";then | ||
366 | AC_DEFINE(CAIRO_CAN_TEST_GLITZ_WGL_SURFACE, 1, [define if glitz backend can be tested against wgl]) | ||
367 | fi | ||
368 | fi | ||
369 | |||
370 | AM_CONDITIONAL(CAIRO_CAN_TEST_GLITZ_AGL_SURFACE, test "x$have_glitz_agl" = "xyes") | ||
371 | AM_CONDITIONAL(CAIRO_CAN_TEST_GLITZ_EGL_SURFACE, test "x$have_glitz_egl" = "xyes") | ||
372 | AM_CONDITIONAL(CAIRO_CAN_TEST_GLITZ_GLX_SURFACE, test "x$have_glitz_glx" = "xyes") | ||
373 | AM_CONDITIONAL(CAIRO_CAN_TEST_GLITZ_WGL_SURFACE, test "x$have_glitz_wgl" = "xyes") | ||
374 | |||
375 | dnl =========================================================================== | ||
376 | |||
377 | CAIRO_ENABLE_SURFACE_BACKEND(directfb, directfb, no, [ | 339 | CAIRO_ENABLE_SURFACE_BACKEND(directfb, directfb, no, [ |
378 | directfb_REQUIRES=directfb | 340 | directfb_REQUIRES=directfb |
379 | PKG_CHECK_MODULES(directfb, $directfb_REQUIRES, , AC_MSG_RESULT(no) | 341 | 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 487f8a8aa..25bbe075d 100644 --- a/doc/public/cairo-docs.xml +++ b/doc/public/cairo-docs.xml | |||
@@ -31,7 +31,6 @@ | |||
31 | <title>Surfaces</title> | 31 | <title>Surfaces</title> |
32 | <xi:include href="xml/cairo-surface.xml"/> | 32 | <xi:include href="xml/cairo-surface.xml"/> |
33 | <xi:include href="xml/cairo-image.xml"/> | 33 | <xi:include href="xml/cairo-image.xml"/> |
34 | <!--xi:include href="xml/cairo-glitz.xml"/--> | ||
35 | <xi:include href="xml/cairo-pdf.xml"/> | 34 | <xi:include href="xml/cairo-pdf.xml"/> |
36 | <xi:include href="xml/cairo-png.xml"/> | 35 | <xi:include href="xml/cairo-png.xml"/> |
37 | <xi:include href="xml/cairo-ps.xml"/> | 36 | <xi:include href="xml/cairo-ps.xml"/> |
diff --git a/doc/public/cairo-sections.txt b/doc/public/cairo-sections.txt index ff89db715..302ffa02f 100644 --- a/doc/public/cairo-sections.txt +++ b/doc/public/cairo-sections.txt | |||
@@ -559,7 +559,6 @@ cairo_matrix_destroy | |||
559 | cairo_matrix_copy | 559 | cairo_matrix_copy |
560 | cairo_matrix_get_affine | 560 | cairo_matrix_get_affine |
561 | cairo_set_target_surface | 561 | cairo_set_target_surface |
562 | cairo_set_target_glitz | ||
563 | cairo_set_target_image | 562 | cairo_set_target_image |
564 | cairo_set_target_pdf | 563 | cairo_set_target_pdf |
565 | cairo_set_target_png | 564 | 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 f7270c228..000000000 --- a/doc/public/tmpl/cairo-glitz.sgml +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | <!-- ##### SECTION Title ##### --> | ||
2 | Glitz Surfaces | ||
3 | |||
4 | <!-- ##### SECTION Short_Description ##### --> | ||
5 | OpenGL accelerated rendering using the Glitz library | ||
6 | |||
7 | <!-- ##### SECTION Long_Description ##### --> | ||
8 | <para> | ||
9 | The Glitz surface is used to render cairo graphics targeting the | ||
10 | OpenGL hardware using the Glitz library. | ||
11 | </para> | ||
12 | |||
13 | <!-- ##### SECTION See_Also ##### --> | ||
14 | <para> | ||
15 | <itemizedlist> | ||
16 | <listitem>#cairo_surface_t</listitem> | ||
17 | </itemizedlist> | ||
18 | </para> | ||
19 | |||
20 | <!-- ##### SECTION Stability_Level ##### --> | ||
21 | |||
22 | |||
diff --git a/src/Makefile.sources b/src/Makefile.sources index a7f5839b0..3cd6c4841 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 | |||
318 | cairo_glx_sources += cairo-glx-context.c | 318 | cairo_glx_sources += cairo-glx-context.c |
319 | cairo_eagle_sources += cairo-eagle-context.c | 319 | cairo_eagle_sources += cairo-eagle-context.c |
320 | 320 | ||
321 | cairo_glitz_headers = cairo-glitz.h | ||
322 | cairo_glitz_private = cairo-glitz-private.h | ||
323 | cairo_glitz_sources = cairo-glitz-surface.c | ||
324 | |||
325 | cairo_directfb_headers = cairo-directfb.h | 321 | cairo_directfb_headers = cairo-directfb.h |
326 | cairo_directfb_sources = cairo-directfb-surface.c | 322 | cairo_directfb_sources = cairo-directfb-surface.c |
327 | 323 | ||
diff --git a/src/Makefile.win32.features b/src/Makefile.win32.features index daf88a783..5e734869e 100644 --- a/src/Makefile.win32.features +++ b/src/Makefile.win32.features | |||
@@ -287,20 +287,6 @@ ifeq ($(CAIRO_HAS_GL_SURFACE),1) | |||
287 | enabled_cairo_pkgconf += cairo-gl.pc | 287 | enabled_cairo_pkgconf += cairo-gl.pc |
288 | endif | 288 | endif |
289 | 289 | ||
290 | unsupported_cairo_headers += $(cairo_glitz_headers) | ||
291 | all_cairo_headers += $(cairo_glitz_headers) | ||
292 | all_cairo_private += $(cairo_glitz_private) | ||
293 | all_cairo_sources += $(cairo_glitz_sources) | ||
294 | ifeq ($(CAIRO_HAS_GLITZ_SURFACE),1) | ||
295 | enabled_cairo_headers += $(cairo_glitz_headers) | ||
296 | enabled_cairo_private += $(cairo_glitz_private) | ||
297 | enabled_cairo_sources += $(cairo_glitz_sources) | ||
298 | endif | ||
299 | all_cairo_pkgconf += cairo-glitz.pc | ||
300 | ifeq ($(CAIRO_HAS_GLITZ_SURFACE),1) | ||
301 | enabled_cairo_pkgconf += cairo-glitz.pc | ||
302 | endif | ||
303 | |||
304 | unsupported_cairo_headers += $(cairo_directfb_headers) | 290 | unsupported_cairo_headers += $(cairo_directfb_headers) |
305 | all_cairo_headers += $(cairo_directfb_headers) | 291 | all_cairo_headers += $(cairo_directfb_headers) |
306 | all_cairo_private += $(cairo_directfb_private) | 292 | all_cairo_private += $(cairo_directfb_private) |
diff --git a/src/cairo-deprecated.h b/src/cairo-deprecated.h index b59ea643a..6397cc42d 100644 --- a/src/cairo-deprecated.h +++ b/src/cairo-deprecated.h | |||
@@ -123,7 +123,6 @@ | |||
123 | #define cairo_matrix_copy cairo_matrix_copy_DEPRECATED_BY_cairo_matrix_t | 123 | #define cairo_matrix_copy cairo_matrix_copy_DEPRECATED_BY_cairo_matrix_t |
124 | #define cairo_matrix_get_affine cairo_matrix_get_affine_DEPRECATED_BY_cairo_matrix_t | 124 | #define cairo_matrix_get_affine cairo_matrix_get_affine_DEPRECATED_BY_cairo_matrix_t |
125 | #define cairo_set_target_surface cairo_set_target_surface_DEPRECATED_BY_cairo_create | 125 | #define cairo_set_target_surface cairo_set_target_surface_DEPRECATED_BY_cairo_create |
126 | #define cairo_set_target_glitz cairo_set_target_glitz_DEPRECATED_BY_cairo_glitz_surface_create | ||
127 | #define cairo_set_target_image cairo_set_target_image_DEPRECATED_BY_cairo_image_surface_create_for_data | 126 | #define cairo_set_target_image cairo_set_target_image_DEPRECATED_BY_cairo_image_surface_create_for_data |
128 | #define cairo_set_target_pdf cairo_set_target_pdf_DEPRECATED_BY_cairo_pdf_surface_create | 127 | #define cairo_set_target_pdf cairo_set_target_pdf_DEPRECATED_BY_cairo_pdf_surface_create |
129 | #define cairo_set_target_png cairo_set_target_png_DEPRECATED_BY_cairo_surface_write_to_png | 128 | #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 8a876eeab..000000000 --- a/src/cairo-glitz-private.h +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | /* Cairo - a vector graphics library with display and print output | ||
2 | * | ||
3 | * Copyright © 2005 Red Hat, Inc. | ||
4 | * | ||
5 | * This library is free software; you can redistribute it and/or | ||
6 | * modify it either under the terms of the GNU Lesser General Public | ||
7 | * License version 2.1 as published by the Free Software Foundation | ||
8 | * (the "LGPL") or, at your option, under the terms of the Mozilla | ||
9 | * Public License Version 1.1 (the "MPL"). If you do not alter this | ||
10 | * notice, a recipient may use your version of this file under either | ||
11 | * the MPL or the LGPL. | ||
12 | * | ||
13 | * You should have received a copy of the LGPL along with this library | ||
14 | * in the file COPYING-LGPL-2.1; if not, write to the Free Software | ||
15 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
16 | * You should have received a copy of the MPL along with this library | ||
17 | * in the file COPYING-MPL-1.1 | ||
18 | * | ||
19 | * The contents of this file are subject to the Mozilla Public License | ||
20 | * Version 1.1 (the "License"); you may not use this file except in | ||
21 | * compliance with the License. You may obtain a copy of the License at | ||
22 | * http://www.mozilla.org/MPL/ | ||
23 | * | ||
24 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY | ||
25 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for | ||
26 | * the specific language governing rights and limitations. | ||
27 | * | ||
28 | * The Original Code is the cairo graphics library. | ||
29 | * | ||
30 | * The Initial Developer of the Original Code is Red Hat, Inc. | ||
31 | */ | ||
32 | |||
33 | #ifndef CAIRO_GLITZ_PRIVATE_H | ||
34 | #define CAIRO_GLITZ_PRIVATE_H | ||
35 | |||
36 | #include "cairoint.h" | ||
37 | #include "cairo-glitz.h" | ||
38 | |||
39 | slim_hidden_proto (cairo_glitz_surface_create); | ||
40 | |||
41 | #endif /* CAIRO_GLITZ_PRIVATE_H */ | ||
diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c deleted file mode 100644 index 0aabed998..000000000 --- a/src/cairo-glitz-surface.c +++ /dev/null | |||
@@ -1,2450 +0,0 @@ | |||
1 | /* cairo - a vector graphics library with display and print output | ||
2 | * | ||
3 | * Copyright © 2004 David Reveman | ||
4 | * | ||
5 | * Permission to use, copy, modify, distribute, and sell this software | ||
6 | * and its documentation for any purpose is hereby granted without | ||
7 | * fee, provided that the above copyright notice appear in all copies | ||
8 | * and that both that copyright notice and this permission notice | ||
9 | * appear in supporting documentation, and that the name of David | ||
10 | * Reveman not be used in advertising or publicity pertaining to | ||
11 | * distribution of the software without specific, written prior | ||
12 | * permission. David Reveman makes no representations about the | ||
13 | * suitability of this software for any purpose. It is provided "as | ||
14 | * is" without express or implied warranty. | ||
15 | * | ||
16 | * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS | ||
17 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
18 | * FITNESS, IN NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, | ||
19 | * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER | ||
20 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | ||
21 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
22 | * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
23 | * | ||
24 | * Author: David Reveman <davidr@novell.com> | ||
25 | */ | ||
26 | |||
27 | #include "cairoint.h" | ||
28 | #include "cairo-glitz.h" | ||
29 | #include "cairo-glitz-private.h" | ||
30 | |||
31 | #include "cairo-error-private.h" | ||
32 | #include "cairo-region-private.h" | ||
33 | |||
34 | typedef struct _cairo_glitz_surface { | ||
35 | cairo_surface_t base; | ||
36 | |||
37 | glitz_surface_t *surface; | ||
38 | glitz_format_t *format; | ||
39 | |||
40 | cairo_region_t *clip_region; | ||
41 | cairo_bool_t has_clip; | ||
42 | glitz_box_t *clip_boxes; | ||
43 | int num_clip_boxes; | ||
44 | } cairo_glitz_surface_t; | ||
45 | |||
46 | static const cairo_surface_backend_t * | ||
47 | _cairo_glitz_surface_get_backend (void); | ||
48 | |||
49 | static cairo_status_t | ||
50 | _cairo_glitz_surface_finish (void *abstract_surface) | ||
51 | { | ||
52 | cairo_glitz_surface_t *surface = abstract_surface; | ||
53 | |||
54 | if (surface->clip_boxes) | ||
55 | free (surface->clip_boxes); | ||
56 | |||
57 | cairo_region_destroy (surface->clip_region); | ||
58 | glitz_surface_destroy (surface->surface); | ||
59 | |||
60 | return CAIRO_STATUS_SUCCESS; | ||
61 | } | ||
62 | |||
63 | static glitz_format_name_t | ||
64 | _glitz_format_from_content (cairo_content_t content) | ||
65 | { | ||
66 | switch (content) { | ||
67 | case CAIRO_CONTENT_COLOR: | ||
68 | return GLITZ_STANDARD_RGB24; | ||
69 | case CAIRO_CONTENT_ALPHA: | ||
70 | return GLITZ_STANDARD_A8; | ||
71 | case CAIRO_CONTENT_COLOR_ALPHA: | ||
72 | return GLITZ_STANDARD_ARGB32; | ||
73 | } | ||
74 | |||
75 | ASSERT_NOT_REACHED; | ||
76 | return GLITZ_STANDARD_ARGB32; | ||
77 | } | ||
78 | |||
79 | static cairo_surface_t * | ||
80 | _cairo_glitz_surface_create_similar (void *abstract_src, | ||
81 | cairo_content_t content, | ||
82 | int width, | ||
83 | int height) | ||
84 | { | ||
85 | cairo_glitz_surface_t *src = abstract_src; | ||
86 | cairo_surface_t *crsurface; | ||
87 | glitz_drawable_t *drawable; | ||
88 | glitz_surface_t *surface; | ||
89 | glitz_format_t *gformat; | ||
90 | |||
91 | drawable = glitz_surface_get_drawable (src->surface); | ||
92 | |||
93 | gformat = | ||
94 | glitz_find_standard_format (drawable, | ||
95 | _glitz_format_from_content (content)); | ||
96 | if (!gformat) | ||
97 | return NULL; | ||
98 | |||
99 | surface = glitz_surface_create (drawable, gformat, | ||
100 | width <= 0 ? 1 : width, | ||
101 | height <= 0 ? 1 : height, | ||
102 | 0, NULL); | ||
103 | |||
104 | if (surface == NULL) | ||
105 | return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); | ||
106 | |||
107 | crsurface = cairo_glitz_surface_create (surface); | ||
108 | |||
109 | glitz_surface_destroy (surface); | ||
110 | |||
111 | return crsurface; | ||
112 | } | ||
113 | |||
114 | static cairo_status_t | ||
115 | _cairo_glitz_surface_get_image (cairo_glitz_surface_t *surface, | ||
116 | cairo_rectangle_int_t *interest, | ||
117 | cairo_image_surface_t **image_out, | ||
118 | cairo_rectangle_int_t *rect_out) | ||
119 | { | ||
120 | cairo_image_surface_t *image; | ||
121 | cairo_rectangle_int_t extents; | ||
122 | cairo_format_t format; | ||
123 | cairo_format_masks_t masks; | ||
124 | glitz_buffer_t *buffer; | ||
125 | glitz_pixel_format_t pf; | ||
126 | |||
127 | extents.x = 0; | ||
128 | extents.y = 0; | ||
129 | extents.width = glitz_surface_get_width (surface->surface); | ||
130 | extents.height = glitz_surface_get_height (surface->surface); | ||
131 | |||
132 | if (interest != NULL) { | ||
133 | if (! _cairo_rectangle_intersect (&extents, interest)) { | ||
134 | *image_out = NULL; | ||
135 | return CAIRO_STATUS_SUCCESS; | ||
136 | } | ||
137 | } | ||
138 | |||
139 | if (rect_out != NULL) | ||
140 | *rect_out = extents; | ||
141 | |||
142 | if (surface->format->color.fourcc == GLITZ_FOURCC_RGB) { | ||
143 | if (surface->format->color.red_size > 0) { | ||
144 | if (surface->format->color.alpha_size > 0) | ||
145 | format = CAIRO_FORMAT_ARGB32; | ||
146 | else | ||
147 | format = CAIRO_FORMAT_RGB24; | ||
148 | } else { | ||
149 | format = CAIRO_FORMAT_A8; | ||
150 | } | ||
151 | } else | ||
152 | format = CAIRO_FORMAT_ARGB32; | ||
153 | |||
154 | image = (cairo_image_surface_t*) | ||
155 | cairo_image_surface_create (format, extents.width, extents.height); | ||
156 | if (image->base.status) | ||
157 | return image->base.status; | ||
158 | |||
159 | _pixman_format_to_masks (image->pixman_format, &masks); | ||
160 | pf.fourcc = GLITZ_FOURCC_RGB; | ||
161 | pf.masks.bpp = masks.bpp; | ||
162 | pf.masks.alpha_mask = masks.alpha_mask; | ||
163 | pf.masks.red_mask = masks.red_mask; | ||
164 | pf.masks.green_mask = masks.green_mask; | ||
165 | pf.masks.blue_mask = masks.blue_mask; | ||
166 | pf.xoffset = 0; | ||
167 | pf.skip_lines = 0; | ||
168 | |||
169 | /* XXX: we should eventually return images with negative stride, | ||
170 | need to verify that libpixman have no problem with this first. */ | ||
171 | pf.bytes_per_line = image->stride; | ||
172 | pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN; | ||
173 | |||
174 | buffer = glitz_buffer_create_for_data (image->data); | ||
175 | if (buffer == NULL) { | ||
176 | cairo_surface_destroy (&image->base); | ||
177 | return _cairo_error (CAIRO_STATUS_NO_MEMORY); | ||
178 | } | ||
179 | |||
180 | /* clear out the glitz clip; the clip affects glitz_get_pixels */ | ||
181 | if (surface->has_clip) | ||
182 | glitz_surface_set_clip_region (surface->surface, | ||
183 | 0, 0, NULL, 0); | ||
184 | |||
185 | glitz_get_pixels (surface->surface, | ||
186 | extents.x, extents.y, | ||
187 | extents.width, extents.height, | ||
188 | &pf, | ||
189 | buffer); | ||
190 | |||
191 | glitz_buffer_destroy (buffer); | ||
192 | |||
193 | /* restore the clip, if any */ | ||
194 | if (surface->has_clip) { | ||
195 | glitz_surface_set_clip_region (surface->surface, | ||
196 | 0, 0, | ||
197 | surface->clip_boxes, | ||
198 | surface->num_clip_boxes); | ||
199 | } | ||
200 | |||
201 | *image_out = image; | ||
202 | |||
203 | return CAIRO_STATUS_SUCCESS; | ||
204 | } | ||
205 | |||
206 | static cairo_status_t | ||
207 | _cairo_glitz_surface_set_image (void *abstract_surface, | ||
208 | cairo_image_surface_t *image, | ||
209 | int src_x, | ||
210 | int src_y, | ||
211 | int width, | ||
212 | int height, | ||
213 | int x_dst, | ||
214 | int y_dst) | ||
215 | { | ||
216 | cairo_glitz_surface_t *surface = abstract_surface; | ||
217 | glitz_buffer_t *buffer; | ||
218 | glitz_pixel_format_t pf; | ||
219 | cairo_format_masks_t masks; | ||
220 | char *data; | ||
221 | |||
222 | _pixman_format_to_masks (image->pixman_format, &masks); | ||
223 | |||
224 | pf.fourcc = GLITZ_FOURCC_RGB; | ||
225 | pf.masks.bpp = masks.bpp; | ||
226 | pf.masks.alpha_mask = masks.alpha_mask; | ||
227 | pf.masks.red_mask = masks.red_mask; | ||
228 | pf.masks.green_mask = masks.green_mask; | ||
229 | pf.masks.blue_mask = masks.blue_mask; | ||
230 | pf.xoffset = src_x; | ||
231 | pf.skip_lines = src_y; | ||
232 | |||
233 | /* check for negative stride */ | ||
234 | if (image->stride < 0) { | ||
235 | pf.bytes_per_line = -image->stride; | ||
236 | pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP; | ||
237 | data = (char *) image->data + image->stride * (image->height - 1); | ||
238 | } else { | ||
239 | pf.bytes_per_line = image->stride; | ||
240 | pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN; | ||
241 | data = (char *) image->data; | ||
242 | } | ||
243 | |||
244 | buffer = glitz_buffer_create_for_data (data); | ||
245 | if (buffer == NULL) | ||
246 | return _cairo_error (CAIRO_STATUS_NO_MEMORY); | ||
247 | |||
248 | glitz_set_pixels (surface->surface, | ||
249 | x_dst, y_dst, | ||
250 | width, height, | ||
251 | &pf, | ||
252 | buffer); | ||
253 | |||
254 | glitz_buffer_destroy (buffer); | ||
255 | |||
256 | return CAIRO_STATUS_SUCCESS; | ||
257 | } | ||
258 | |||
259 | static cairo_status_t | ||
260 | _cairo_glitz_surface_acquire_source_image (void *abstract_surface, | ||
261 | cairo_image_surface_t **image_out, | ||
262 | void **image_extra) | ||
263 | { | ||
264 | cairo_glitz_surface_t *surface = abstract_surface; | ||
265 | |||
266 | *image_extra = NULL; | ||
267 | |||
268 | return _cairo_glitz_surface_get_image (surface, NULL, image_out, NULL); | ||
269 | } | ||
270 | |||
271 | static cairo_surface_t * | ||
272 | _cairo_glitz_surface_snapshot (void *abstract_surface) | ||
273 | { | ||
274 | cairo_glitz_surface_t *surface = abstract_surface; | ||
275 | cairo_status_t status; | ||
276 | cairo_image_surface_t *image; | ||
277 | |||
278 | status = _cairo_glitz_surface_get_image (surface, NULL, &image, NULL); | ||
279 | if (unlikely (status)) | ||
280 | return _cairo_surface_create_in_error (status); | ||
281 | |||
282 | return &image->base; | ||
283 | } | ||
284 | |||
285 | static void | ||
286 | _cairo_glitz_surface_release_source_image (void *abstract_surface, | ||
287 | cairo_image_surface_t *image, | ||
288 | void *image_extra) | ||
289 | { | ||
290 | cairo_surface_destroy (&image->base); | ||
291 | } | ||
292 | |||
293 | static cairo_status_t | ||
294 | _cairo_glitz_surface_acquire_dest_image (void *abstract_surface, | ||
295 | cairo_rectangle_int_t *interest_rect, | ||
296 | cairo_image_surface_t **image_out, | ||
297 | cairo_rectangle_int_t *image_rect_out, | ||
298 | void **image_extra) | ||
299 | { | ||
300 | cairo_glitz_surface_t *surface = abstract_surface; | ||
301 | cairo_image_surface_t *image; | ||
302 | cairo_status_t status; | ||
303 | |||
304 | status = _cairo_glitz_surface_get_image (surface, interest_rect, &image, | ||
305 | image_rect_out); | ||
306 | if (status) | ||
307 | return status; | ||
308 | |||
309 | *image_out = image; | ||
310 | *image_extra = NULL; | ||
311 | |||
312 | return status; | ||
313 | } | ||
314 | |||
315 | static void | ||
316 | _cairo_glitz_surface_release_dest_image (void *abstract_surface, | ||
317 | cairo_rectangle_int_t *interest_rect, | ||
318 | cairo_image_surface_t *image, | ||
319 | cairo_rectangle_int_t *image_rect, | ||
320 | void *image_extra) | ||
321 | { | ||
322 | cairo_glitz_surface_t *surface = abstract_surface; | ||
323 | cairo_status_t status; | ||
324 | |||
325 | status = _cairo_glitz_surface_set_image (surface, image, 0, 0, | ||
326 | image->width, image->height, | ||
327 | image_rect->x, image_rect->y); | ||
328 | if (status) | ||
329 | status = _cairo_surface_set_error (&surface->base, status); | ||
330 | |||
331 | cairo_surface_destroy (&image->base); | ||
332 | } | ||
333 | |||
334 | static cairo_status_t | ||
335 | _cairo_glitz_surface_clone_similar (void *abstract_surface, | ||
336 | cairo_surface_t *src, | ||
337 | int src_x, | ||
338 | int src_y, | ||
339 | int width, | ||
340 | int height, | ||
341 | int *clone_offset_x, | ||
342 | int *clone_offset_y, | ||
343 | cairo_surface_t **clone_out) | ||
344 | { | ||
345 | cairo_glitz_surface_t *surface = abstract_surface; | ||
346 | cairo_glitz_surface_t *clone; | ||
347 | cairo_status_t status; | ||
348 | |||
349 | if (surface->base.status) | ||
350 | return surface->base.status; | ||
351 | |||
352 | if (src->backend == surface->base.backend) | ||
353 | { | ||
354 | *clone_offset_x = 0; | ||
355 | *clone_offset_y = 0; | ||
356 | *clone_out = cairo_surface_reference (src); | ||
357 | |||
358 | return CAIRO_STATUS_SUCCESS; | ||
359 | } | ||
360 | else if (_cairo_surface_is_image (src)) | ||
361 | { | ||
362 | cairo_image_surface_t *image_src = (cairo_image_surface_t *) src; | ||
363 | |||
364 | clone = (cairo_glitz_surface_t *) | ||
365 | _cairo_glitz_surface_create_similar (surface, src->content, | ||
366 | width, height); | ||
367 | if (clone == NULL) | ||
368 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
369 | if (clone->base.status) | ||
370 | return clone->base.status; | ||
371 | |||
372 | status = _cairo_glitz_surface_set_image (clone, image_src, | ||
373 | src_x, src_y, | ||
374 | width, height, | ||
375 | 0, 0); | ||
376 | if (status) { | ||
377 | cairo_surface_destroy (&clone->base); | ||
378 | return status; | ||
379 | } | ||
380 | |||
381 | *clone_out = &clone->base; | ||
382 | *clone_offset_x = src_x; | ||
383 | *clone_offset_y = src_y; | ||
384 | return CAIRO_STATUS_SUCCESS; | ||
385 | } | ||
386 | |||
387 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
388 | } | ||
389 | |||
390 | static void | ||
391 | _cairo_glitz_surface_set_matrix (cairo_glitz_surface_t *surface, | ||
392 | cairo_matrix_t *matrix) | ||
393 | { | ||
394 | glitz_transform_t transform; | ||
395 | |||
396 | transform.matrix[0][0] = _cairo_fixed_16_16_from_double (matrix->xx); | ||
397 | transform.matrix[0][1] = _cairo_fixed_16_16_from_double (matrix->xy); | ||
398 | transform.matrix[0][2] = _cairo_fixed_16_16_from_double (matrix->x0); | ||
399 | |||
400 | transform.matrix[1][0] = _cairo_fixed_16_16_from_double (matrix->yx); | ||
401 | transform.matrix[1][1] = _cairo_fixed_16_16_from_double (matrix->yy); | ||
402 | transform.matrix[1][2] = _cairo_fixed_16_16_from_double (matrix->y0); | ||
403 | |||
404 | transform.matrix[2][0] = 0; | ||
405 | transform.matrix[2][1] = 0; | ||
406 | transform.matrix[2][2] = _cairo_fixed_16_16_from_double (1); | ||
407 | |||
408 | glitz_surface_set_transform (surface->surface, &transform); | ||
409 | } | ||
410 | |||
411 | static cairo_bool_t | ||
412 | _is_supported_operator (cairo_operator_t op) | ||
413 | { | ||
414 | /* This is really just a if (op < SATURATE), but we use a switch | ||
415 | * so the compiler will warn if we ever add more operators. | ||
416 | */ | ||
417 | switch (op) { | ||
418 | case CAIRO_OPERATOR_CLEAR: | ||
419 | case CAIRO_OPERATOR_SOURCE: | ||
420 | case CAIRO_OPERATOR_OVER: | ||
421 | case CAIRO_OPERATOR_IN: | ||
422 | case CAIRO_OPERATOR_OUT: | ||
423 | case CAIRO_OPERATOR_ATOP: | ||
424 | case CAIRO_OPERATOR_DEST: | ||
425 | case CAIRO_OPERATOR_DEST_OVER: | ||
426 | case CAIRO_OPERATOR_DEST_IN: | ||
427 | case CAIRO_OPERATOR_DEST_OUT: | ||
428 | case CAIRO_OPERATOR_DEST_ATOP: | ||
429 | case CAIRO_OPERATOR_XOR: | ||
430 | case CAIRO_OPERATOR_ADD: | ||
431 | return TRUE; | ||
432 | |||
433 | default: | ||
434 | ASSERT_NOT_REACHED; | ||
435 | case CAIRO_OPERATOR_SATURATE: | ||
436 | /* nobody likes saturate, expect that it's required to do | ||
437 | * seamless polygons! | ||
438 | */ | ||
439 | case CAIRO_OPERATOR_MULTIPLY: | ||
440 | case CAIRO_OPERATOR_SCREEN: | ||
441 | case CAIRO_OPERATOR_OVERLAY: | ||
442 | case CAIRO_OPERATOR_DARKEN: | ||
443 | case CAIRO_OPERATOR_LIGHTEN: | ||
444 | case CAIRO_OPERATOR_COLOR_DODGE: | ||
445 | case CAIRO_OPERATOR_COLOR_BURN: | ||
446 | case CAIRO_OPERATOR_HARD_LIGHT: | ||
447 | case CAIRO_OPERATOR_SOFT_LIGHT: | ||
448 | case CAIRO_OPERATOR_DIFFERENCE: | ||
449 | case CAIRO_OPERATOR_EXCLUSION: | ||
450 | case CAIRO_OPERATOR_HSL_HUE: | ||
451 | case CAIRO_OPERATOR_HSL_SATURATION: | ||
452 | case CAIRO_OPERATOR_HSL_COLOR: | ||
453 | case CAIRO_OPERATOR_HSL_LUMINOSITY: | ||
454 | return FALSE; | ||
455 | } | ||
456 | } | ||
457 | |||
458 | static glitz_operator_t | ||
459 | _glitz_operator (cairo_operator_t op) | ||
460 | { | ||
461 | switch ((int) op) { | ||
462 | case CAIRO_OPERATOR_CLEAR: | ||
463 | return GLITZ_OPERATOR_CLEAR; | ||
464 | |||
465 | case CAIRO_OPERATOR_SOURCE: | ||
466 | return GLITZ_OPERATOR_SRC; | ||
467 | case CAIRO_OPERATOR_OVER: | ||
468 | return GLITZ_OPERATOR_OVER; | ||
469 | case CAIRO_OPERATOR_IN: | ||
470 | return GLITZ_OPERATOR_IN; | ||
471 | case CAIRO_OPERATOR_OUT: | ||
472 | return GLITZ_OPERATOR_OUT; | ||
473 | case CAIRO_OPERATOR_ATOP: | ||
474 | return GLITZ_OPERATOR_ATOP; | ||
475 | |||
476 | case CAIRO_OPERATOR_DEST: | ||
477 | return GLITZ_OPERATOR_DST; | ||
478 | case CAIRO_OPERATOR_DEST_OVER: | ||
479 | return GLITZ_OPERATOR_OVER_REVERSE; | ||
480 | case CAIRO_OPERATOR_DEST_IN: | ||
481 | return GLITZ_OPERATOR_IN_REVERSE; | ||
482 | case CAIRO_OPERATOR_DEST_OUT: | ||
483 | return GLITZ_OPERATOR_OUT_REVERSE; | ||
484 | case CAIRO_OPERATOR_DEST_ATOP: | ||
485 | return GLITZ_OPERATOR_ATOP_REVERSE; | ||
486 | |||
487 | case CAIRO_OPERATOR_XOR: | ||
488 | return GLITZ_OPERATOR_XOR; | ||
489 | case CAIRO_OPERATOR_ADD: | ||
490 | return GLITZ_OPERATOR_ADD; | ||
491 | |||
492 | default: | ||
493 | ASSERT_NOT_REACHED; | ||
494 | |||
495 | /* Something's very broken if this line of code can be reached, so | ||
496 | * we want to return something that would give a noticeably | ||
497 | * incorrect result. The XOR operator seems so rearely desired | ||
498 | * that it should fit the bill here. | ||
499 | */ | ||
500 | return CAIRO_OPERATOR_XOR; | ||
501 | } | ||
502 | } | ||
503 | |||
504 | #define CAIRO_GLITZ_FEATURE_OK(surface, name) \ | ||
505 | (glitz_drawable_get_features (glitz_surface_get_drawable (surface)) & \ | ||
506 | (GLITZ_FEATURE_ ## name ## _MASK)) | ||
507 | |||
508 | static glitz_status_t | ||
509 | _glitz_ensure_target (glitz_surface_t *surface) | ||
510 | { | ||
511 | if (!glitz_surface_get_attached_drawable (surface)) | ||
512 | { | ||
513 | glitz_drawable_format_t *target_format, templ; | ||
514 | glitz_format_t *format; | ||
515 | glitz_drawable_t *drawable, *target; | ||
516 | unsigned int width, height; | ||
517 | unsigned long mask; | ||
518 | |||
519 | drawable = glitz_surface_get_drawable (surface); | ||
520 | format = glitz_surface_get_format (surface); | ||
521 | width = glitz_surface_get_width (surface); | ||
522 | height = glitz_surface_get_height (surface); | ||
523 | |||
524 | if (format->color.fourcc != GLITZ_FOURCC_RGB) | ||
525 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
526 | |||
527 | templ.color = format->color; | ||
528 | templ.depth_size = 0; | ||
529 | templ.stencil_size = 0; | ||
530 | templ.doublebuffer = 0; | ||
531 | templ.samples = 1; | ||
532 | |||
533 | mask = | ||
534 | GLITZ_FORMAT_RED_SIZE_MASK | | ||
535 | GLITZ_FORMAT_GREEN_SIZE_MASK | | ||
536 | GLITZ_FORMAT_BLUE_SIZE_MASK | | ||
537 | GLITZ_FORMAT_ALPHA_SIZE_MASK | | ||
538 | GLITZ_FORMAT_DEPTH_SIZE_MASK | | ||
539 | GLITZ_FORMAT_STENCIL_SIZE_MASK | | ||
540 | GLITZ_FORMAT_DOUBLEBUFFER_MASK | | ||
541 | GLITZ_FORMAT_SAMPLES_MASK; | ||
542 | |||
543 | target_format = glitz_find_drawable_format (drawable, mask, &templ, 0); | ||
544 | if (!target_format) | ||
545 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
546 | |||
547 | target = glitz_create_drawable (drawable, target_format, | ||
548 | width, height); | ||
549 | if (!target) | ||
550 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
551 | |||
552 | glitz_surface_attach (surface, target, | ||
553 | GLITZ_DRAWABLE_BUFFER_FRONT_COLOR); | ||
554 | |||
555 | glitz_drawable_destroy (target); | ||
556 | } | ||
557 | |||
558 | return CAIRO_STATUS_SUCCESS; | ||
559 | } | ||
560 | |||
561 | typedef struct _cairo_glitz_surface_attributes { | ||
562 | cairo_surface_attributes_t base; | ||
563 | |||
564 | glitz_fill_t fill; | ||
565 | glitz_filter_t filter; | ||
566 | glitz_fixed16_16_t *params; | ||
567 | int n_params; | ||
568 | cairo_bool_t acquired; | ||
569 | } cairo_glitz_surface_attributes_t; | ||
570 | |||
571 | static cairo_int_status_t | ||
572 | _cairo_glitz_pattern_acquire_surface (const cairo_pattern_t *pattern, | ||
573 | cairo_glitz_surface_t *dst, | ||
574 | int x, | ||
575 | int y, | ||
576 | unsigned int width, | ||
577 | unsigned int height, | ||
578 | cairo_glitz_surface_t **surface_out, | ||
579 | cairo_glitz_surface_attributes_t *attr) | ||
580 | { | ||
581 | cairo_glitz_surface_t *src = NULL; | ||
582 | |||
583 | attr->acquired = FALSE; | ||
584 | |||
585 | switch (pattern->type) { | ||
586 | case CAIRO_PATTERN_TYPE_LINEAR: | ||
587 | case CAIRO_PATTERN_TYPE_RADIAL: { | ||
588 | cairo_gradient_pattern_t *gradient = | ||
589 | (cairo_gradient_pattern_t *) pattern; | ||
590 | char *data; | ||
591 | glitz_fixed16_16_t *params; | ||
592 | unsigned int n_params; | ||
593 | unsigned int *pixels; | ||
594 | unsigned int i, n_base_params; | ||
595 | glitz_buffer_t *buffer; | ||
596 | static const glitz_pixel_format_t format = { | ||
597 | GLITZ_FOURCC_RGB, | ||
598 | { | ||
599 | 32, | ||
600 | 0xff000000, | ||
601 | 0x00ff0000, | ||
602 | 0x0000ff00, | ||
603 | 0x000000ff | ||
604 | }, | ||
605 | 0, 0, 0, | ||
606 | GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP | ||
607 | }; | ||
608 | |||
609 | /* XXX: the current color gradient acceleration provided by glitz is | ||
610 | * experimental, it's been proven inappropriate in a number of ways, | ||
611 | * most importantly, it's currently implemented as filters and | ||
612 | * gradients are not filters. eventually, it will be replaced with | ||
613 | * something more appropriate. | ||
614 | */ | ||
615 | |||
616 | if (gradient->n_stops < 2) | ||
617 | break; | ||
618 | |||
619 | if (!CAIRO_GLITZ_FEATURE_OK (dst->surface, FRAGMENT_PROGRAM)) | ||
620 | break; | ||
621 | |||
622 | if (pattern->type == CAIRO_PATTERN_TYPE_RADIAL) | ||
623 | n_base_params = 6; | ||
624 | else | ||
625 | n_base_params = 4; | ||
626 | |||
627 | n_params = gradient->n_stops * 3 + n_base_params; | ||
628 | |||
629 | /* check for int overflow */ | ||
630 | { | ||
631 | int size1, size2; | ||
632 | if (n_params >= INT32_MAX / sizeof (glitz_fixed16_16_t) || | ||
633 | gradient->n_stops >= INT32_MAX / sizeof (unsigned int)) | ||
634 | return _cairo_error (CAIRO_STATUS_NO_MEMORY); | ||
635 | |||
636 | size1 = n_params * sizeof (glitz_fixed16_16_t); | ||
637 | size2 = gradient->n_stops * sizeof (unsigned int); | ||
638 | |||
639 | if (size1 >= INT32_MAX - size2) | ||
640 | return _cairo_error (CAIRO_STATUS_NO_MEMORY); | ||
641 | |||
642 | data = malloc (size1 + size2); | ||
643 | } | ||
644 | |||
645 | if (!data) | ||
646 | return _cairo_error (CAIRO_STATUS_NO_MEMORY); | ||
647 | |||
648 | params = (glitz_fixed16_16_t *) data; | ||
649 | pixels = (unsigned int *) | ||
650 | (data + sizeof (glitz_fixed16_16_t) * n_params); | ||
651 | |||
652 | buffer = glitz_buffer_create_for_data (pixels); | ||
653 | if (!buffer) { | ||
654 | free (data); | ||
655 | return _cairo_error (CAIRO_STATUS_NO_MEMORY); | ||
656 | } | ||
657 | |||
658 | src = (cairo_glitz_surface_t *) | ||
659 | _cairo_glitz_surface_create_similar (&dst->base, | ||
660 | CAIRO_CONTENT_COLOR_ALPHA, | ||
661 | gradient->n_stops, 1); | ||
662 | if (src->base.status) { | ||
663 | glitz_buffer_destroy (buffer); | ||
664 | free (data); | ||
665 | return src->base.status; | ||
666 | } | ||
667 | |||
668 | for (i = 0; i < gradient->n_stops; i++) | ||
669 | { | ||
670 | pixels[i] = | ||
671 | (((int) (gradient->stops[i].color.alpha_short >> 8)) << 24) | | ||
672 | (((int) (gradient->stops[i].color.red_short >> 8)) << 16) | | ||
673 | (((int) (gradient->stops[i].color.green_short >> 8)) << 8) | | ||
674 | (((int) (gradient->stops[i].color.blue_short >> 8))); | ||
675 | |||
676 | params[n_base_params + 3 * i + 0] = _cairo_fixed_16_16_from_double (gradient->stops[i].offset); | ||
677 | params[n_base_params + 3 * i + 1] = i << 16; | ||
678 | params[n_base_params + 3 * i + 2] = 0; | ||
679 | } | ||
680 | |||
681 | glitz_set_pixels (src->surface, 0, 0, gradient->n_stops, 1, | ||
682 | (glitz_pixel_format_t *)&format, buffer); | ||
683 | |||
684 | glitz_buffer_destroy (buffer); | ||
685 | |||
686 | if (pattern->type == CAIRO_PATTERN_TYPE_LINEAR) | ||
687 | { | ||
688 | cairo_linear_pattern_t *grad = (cairo_linear_pattern_t *) pattern; | ||
689 | |||
690 | params[0] = _cairo_fixed_to_16_16 (grad->p1.x); | ||
691 | params[1] = _cairo_fixed_to_16_16 (grad->p1.y); | ||
692 | params[2] = _cairo_fixed_to_16_16 (grad->p2.x); | ||
693 | params[3] = _cairo_fixed_to_16_16 (grad->p2.y); | ||
694 | attr->filter = GLITZ_FILTER_LINEAR_GRADIENT; | ||
695 | } | ||
696 | else | ||
697 | { | ||
698 | cairo_radial_pattern_t *grad = (cairo_radial_pattern_t *) pattern; | ||
699 | |||
700 | params[0] = _cairo_fixed_to_16_16 (grad->c1.x); | ||
701 | params[1] = _cairo_fixed_to_16_16 (grad->c1.y); | ||
702 | params[2] = _cairo_fixed_to_16_16 (grad->r1); | ||
703 | params[3] = _cairo_fixed_to_16_16 (grad->c2.x); | ||
704 | params[4] = _cairo_fixed_to_16_16 (grad->c2.y); | ||
705 | params[5] = _cairo_fixed_to_16_16 (grad->r2); | ||
706 | attr->filter = GLITZ_FILTER_RADIAL_GRADIENT; | ||
707 | } | ||
708 | |||
709 | switch (pattern->extend) { | ||
710 | case CAIRO_EXTEND_NONE: | ||
711 | attr->fill = GLITZ_FILL_TRANSPARENT; | ||
712 | break; | ||
713 | case CAIRO_EXTEND_REPEAT: | ||
714 | attr->fill = GLITZ_FILL_REPEAT; | ||
715 | break; | ||
716 | case CAIRO_EXTEND_REFLECT: | ||
717 | attr->fill = GLITZ_FILL_REFLECT; | ||
718 | break; | ||
719 | case CAIRO_EXTEND_PAD: | ||
720 | attr->fill = GLITZ_FILL_NEAREST; | ||
721 | break; | ||
722 | } | ||
723 | |||
724 | attr->params = params; | ||
725 | attr->n_params = n_params; | ||
726 | attr->base.matrix = pattern->matrix; | ||
727 | attr->base.x_offset = 0; | ||
728 | attr->base.y_offset = 0; | ||
729 | } break; | ||
730 | case CAIRO_PATTERN_TYPE_SOLID: | ||
731 | case CAIRO_PATTERN_TYPE_SURFACE: | ||
732 | default: | ||
733 | break; | ||
734 | } | ||
735 | |||
736 | if (!src) | ||
737 | { | ||
738 | cairo_int_status_t status; | ||
739 | |||
740 | status = _cairo_pattern_acquire_surface (pattern, &dst->base, | ||
741 | x, y, width, height, | ||
742 | CAIRO_PATTERN_ACQUIRE_NONE, | ||
743 | (cairo_surface_t **) &src, | ||
744 | &attr->base); | ||
745 | if (status) | ||
746 | return status; | ||
747 | |||
748 | if (src) | ||
749 | { | ||
750 | switch (attr->base.extend) { | ||
751 | case CAIRO_EXTEND_NONE: | ||
752 | attr->fill = GLITZ_FILL_TRANSPARENT; | ||
753 | break; | ||
754 | case CAIRO_EXTEND_REPEAT: | ||
755 | attr->fill = GLITZ_FILL_REPEAT; | ||
756 | break; | ||
757 | case CAIRO_EXTEND_REFLECT: | ||
758 | attr->fill = GLITZ_FILL_REFLECT; | ||
759 | break; | ||
760 | case CAIRO_EXTEND_PAD: | ||
761 | default: | ||
762 | attr->fill = GLITZ_FILL_NEAREST; | ||
763 | break; | ||
764 | } | ||
765 | |||
766 | switch (attr->base.filter) { | ||
767 | case CAIRO_FILTER_FAST: | ||
768 | case CAIRO_FILTER_NEAREST: | ||
769 | attr->filter = GLITZ_FILTER_NEAREST; | ||
770 | break; | ||
771 | case CAIRO_FILTER_GOOD: | ||
772 | case CAIRO_FILTER_BEST: | ||
773 | case CAIRO_FILTER_BILINEAR: | ||
774 | case CAIRO_FILTER_GAUSSIAN: | ||
775 | default: | ||
776 | attr->filter = GLITZ_FILTER_BILINEAR; | ||
777 | break; | ||
778 | } | ||
779 | |||
780 | attr->params = NULL; | ||
781 | attr->n_params = 0; | ||
782 | attr->acquired = TRUE; | ||
783 | } | ||
784 | } | ||
785 | |||
786 | *surface_out = src; | ||
787 | |||
788 | return CAIRO_STATUS_SUCCESS; | ||
789 | } | ||
790 | |||
791 | static void | ||
792 | _cairo_glitz_pattern_release_surface (const cairo_pattern_t *pattern, | ||
793 | cairo_glitz_surface_t *surface, | ||
794 | cairo_glitz_surface_attributes_t *attr) | ||
795 | { | ||
796 | if (attr->acquired) | ||
797 | _cairo_pattern_release_surface (pattern, &surface->base, &attr->base); | ||
798 | else | ||
799 | cairo_surface_destroy (&surface->base); | ||
800 | } | ||
801 | |||
802 | static cairo_int_status_t | ||
803 | _cairo_glitz_pattern_acquire_surfaces (const cairo_pattern_t *src, | ||
804 | const cairo_pattern_t *mask, | ||
805 | cairo_glitz_surface_t *dst, | ||
806 | int src_x, | ||
807 | int src_y, | ||
808 | int mask_x, | ||
809 | int mask_y, | ||
810 | unsigned int width, | ||
811 | unsigned int height, | ||
812 | cairo_glitz_surface_t **src_out, | ||
813 | cairo_glitz_surface_t **mask_out, | ||
814 | cairo_glitz_surface_attributes_t *sattr, | ||
815 | cairo_glitz_surface_attributes_t *mattr) | ||
816 | { | ||
817 | cairo_int_status_t status; | ||
818 | cairo_solid_pattern_t tmp; | ||
819 | |||
820 | /* If src and mask are both solid, then the mask alpha can be | ||
821 | * combined into src and mask can be ignored. */ | ||
822 | |||
823 | /* XXX: This optimization assumes that there is no color | ||
824 | * information in mask, so this will need to change when we | ||
825 | * support RENDER-style 4-channel masks. */ | ||
826 | |||
827 | if (src->type == CAIRO_PATTERN_TYPE_SOLID && | ||
828 | mask->type == CAIRO_PATTERN_TYPE_SOLID) | ||
829 | { | ||
830 | cairo_color_t combined; | ||
831 | cairo_solid_pattern_t *src_solid = (cairo_solid_pattern_t *) src; | ||
832 | cairo_solid_pattern_t *mask_solid = (cairo_solid_pattern_t *) mask; | ||
833 | |||
834 | combined = src_solid->color; | ||
835 | _cairo_color_multiply_alpha (&combined, mask_solid->color.alpha); | ||
836 | |||
837 | _cairo_pattern_init_solid (&tmp, &combined, CAIRO_CONTENT_COLOR_ALPHA); | ||
838 | |||
839 | mask = NULL; | ||
840 | src = &tmp.base; | ||
841 | } | ||
842 | |||
843 | status = _cairo_glitz_pattern_acquire_surface (src, dst, | ||
844 | src_x, src_y, | ||
845 | width, height, | ||
846 | src_out, sattr); | ||
847 | |||
848 | if (src == &tmp.base) | ||
849 | _cairo_pattern_fini (&tmp.base); | ||
850 | |||
851 | if (status) | ||
852 | return status; | ||
853 | |||
854 | if (mask) | ||
855 | { | ||
856 | status = _cairo_glitz_pattern_acquire_surface (mask, dst, | ||
857 | mask_x, mask_y, | ||
858 | width, height, | ||
859 | mask_out, mattr); | ||
860 | |||
861 | if (status) { | ||
862 | /* XXX src == &tmp.base -> invalid (currently inconsequential) */ | ||
863 | _cairo_glitz_pattern_release_surface (src, *src_out, sattr); | ||
864 | } | ||
865 | |||
866 | return status; | ||
867 | } | ||
868 | else | ||
869 | { | ||
870 | *mask_out = NULL; | ||
871 | } | ||
872 | |||
873 | return CAIRO_STATUS_SUCCESS; | ||
874 | } | ||
875 | |||
876 | static void | ||
877 | _cairo_glitz_surface_set_attributes (cairo_glitz_surface_t *surface, | ||
878 | cairo_glitz_surface_attributes_t *a) | ||
879 | { | ||
880 | _cairo_glitz_surface_set_matrix (surface, &a->base.matrix); | ||
881 | glitz_surface_set_fill (surface->surface, a->fill); | ||
882 | glitz_surface_set_filter (surface->surface, a->filter, | ||
883 | a->params, a->n_params); | ||
884 | } | ||
885 | |||
886 | static cairo_status_t | ||
887 | _cairo_glitz_get_boxes_from_region (cairo_region_t *region, | ||
888 | glitz_box_t **boxes, | ||
889 | int *nboxes) | ||
890 | { | ||
891 | pixman_box32_t *pboxes; | ||
892 | cairo_status_t status = CAIRO_STATUS_SUCCESS; | ||
893 | |||
894 | int n, i; | ||
895 | |||
896 | n = 0; | ||
897 | pboxes = pixman_region32_rectangles (®ion->rgn, &n); | ||
898 | if (n == 0) { | ||
899 | *nboxes = 0; | ||
900 | return CAIRO_STATUS_SUCCESS; | ||
901 | } | ||
902 | |||
903 | if (n > *nboxes) { | ||
904 | *boxes = _cairo_malloc_ab (n, sizeof (glitz_box_t)); | ||
905 | if (*boxes == NULL) { | ||
906 | status = _cairo_error (CAIRO_STATUS_NO_MEMORY); | ||
907 | goto done; | ||
908 | } | ||
909 | } | ||
910 | |||
911 | for (i = 0; i < n; i++) { | ||
912 | (*boxes)[i].x1 = pboxes[i].x1; | ||
913 | (*boxes)[i].y1 = pboxes[i].y1; | ||
914 | (*boxes)[i].x2 = pboxes[i].x2; | ||
915 | (*boxes)[i].y2 = pboxes[i].y2; | ||
916 | } | ||
917 | |||
918 | *nboxes = n; | ||
919 | done: | ||
920 | return status; | ||
921 | } | ||
922 | |||
923 | static cairo_status_t | ||
924 | _cairo_glitz_surface_set_clip_region (void *abstract_surface, | ||
925 | cairo_region_t *region) | ||
926 | { | ||
927 | cairo_glitz_surface_t *surface = abstract_surface; | ||
928 | |||
929 | if (region == surface->clip_region) | ||
930 | return CAIRO_STATUS_SUCCESS; | ||
931 | |||
932 | cairo_region_destroy (surface->clip_region); | ||
933 | surface->clip_region = cairo_region_reference (region); | ||
934 | |||
935 | if (region != NULL) { | ||
936 | cairo_status_t status; | ||
937 | |||
938 | status = _cairo_glitz_get_boxes_from_region (region, | ||
939 | &surface->clip_boxes, | ||
940 | &surface->num_clip_boxes); | ||
941 | if (status) | ||
942 | return status; | ||
943 | |||
944 | glitz_surface_set_clip_region (surface->surface, | ||
945 | 0, 0, | ||
946 | surface->clip_boxes, | ||
947 | surface->num_clip_boxes); | ||
948 | surface->has_clip = TRUE; | ||
949 | } else { | ||
950 | glitz_surface_set_clip_region (surface->surface, 0, 0, NULL, 0); | ||
951 | surface->has_clip = FALSE; | ||
952 | } | ||
953 | |||
954 | return CAIRO_STATUS_SUCCESS; | ||
955 | } | ||
956 | |||
957 | static cairo_int_status_t | ||
958 | _cairo_glitz_surface_composite (cairo_operator_t op, | ||
959 | const cairo_pattern_t *src_pattern, | ||
960 | const cairo_pattern_t *mask_pattern, | ||
961 | void *abstract_dst, | ||
962 | int src_x, | ||
963 | int src_y, | ||
964 | int mask_x, | ||
965 | int mask_y, | ||
966 | int dst_x, | ||
967 | int dst_y, | ||
968 | unsigned int width, | ||
969 | unsigned int height, | ||
970 | cairo_region_t *clip_region) | ||
971 | { | ||
972 | cairo_glitz_surface_attributes_t src_attr, mask_attr; | ||
973 | cairo_glitz_surface_t *dst = abstract_dst; | ||
974 | cairo_glitz_surface_t *src; | ||
975 | cairo_glitz_surface_t *mask; | ||
976 | cairo_int_status_t status; | ||
977 | |||
978 | if (! _is_supported_operator (op)) | ||
979 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
980 | |||
981 | if (_glitz_ensure_target (dst->surface)) | ||
982 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
983 | |||
984 | status = _cairo_glitz_surface_set_clip_region (dst, clip_region); | ||
985 | if (status) | ||
986 | return status; | ||
987 | |||
988 | status = _cairo_glitz_pattern_acquire_surfaces (src_pattern, mask_pattern, | ||
989 | dst, | ||
990 | src_x, src_y, | ||
991 | mask_x, mask_y, | ||
992 | width, height, | ||
993 | &src, &mask, | ||
994 | &src_attr, &mask_attr); | ||
995 | if (status) | ||
996 | return status; | ||
997 | |||
998 | _cairo_glitz_surface_set_attributes (src, &src_attr); | ||
999 | if (mask) | ||
1000 | { | ||
1001 | _cairo_glitz_surface_set_attributes (mask, &mask_attr); | ||
1002 | glitz_composite (_glitz_operator (op), | ||
1003 | src->surface, | ||
1004 | mask->surface, | ||
1005 | dst->surface, | ||
1006 | src_x + src_attr.base.x_offset, | ||
1007 | src_y + src_attr.base.y_offset, | ||
1008 | mask_x + mask_attr.base.x_offset, | ||
1009 | mask_y + mask_attr.base.y_offset, | ||
1010 | dst_x, dst_y, | ||
1011 | width, height); | ||
1012 | } | ||
1013 | else | ||
1014 | { | ||
1015 | glitz_composite (_glitz_operator (op), | ||
1016 | src->surface, | ||
1017 | NULL, | ||
1018 | dst->surface, | ||
1019 | src_x + src_attr.base.x_offset, | ||
1020 | src_y + src_attr.base.y_offset, | ||
1021 | 0, 0, | ||
1022 | dst_x, dst_y, | ||
1023 | width, height); | ||
1024 | } | ||
1025 | |||
1026 | if (glitz_surface_get_status (dst->surface) == GLITZ_STATUS_NOT_SUPPORTED) | ||
1027 | status = CAIRO_INT_STATUS_UNSUPPORTED; | ||
1028 | |||
1029 | if (status == CAIRO_STATUS_SUCCESS && | ||
1030 | ! _cairo_operator_bounded_by_source (op)) | ||
1031 | { | ||
1032 | int src_width, src_height; | ||
1033 | int mask_width, mask_height; | ||
1034 | |||
1035 | src_width = glitz_surface_get_width (src->surface); | ||
1036 | src_height = glitz_surface_get_height (src->surface); | ||
1037 | if (mask) | ||
1038 | { | ||
1039 | mask_width = glitz_surface_get_width (mask->surface); | ||
1040 | mask_height = glitz_surface_get_height (mask->surface); | ||
1041 | } | ||
1042 | else | ||
1043 | { | ||
1044 | mask_width = 0; | ||
1045 | mask_height = 0; | ||
1046 | } | ||
1047 | status = _cairo_surface_composite_fixup_unbounded (&dst->base, | ||
1048 | &src_attr.base, | ||
1049 | src_width, src_height, | ||
1050 | mask ? &mask_attr.base : NULL, | ||
1051 | mask_width, mask_height, | ||
1052 | src_x, src_y, | ||
1053 | mask_x, mask_y, | ||
1054 | dst_x, dst_y, width, height, | ||
1055 | clip_region); | ||
1056 | } | ||
1057 | |||
1058 | if (mask) | ||
1059 | { | ||
1060 | if (mask_attr.n_params) | ||
1061 | free (mask_attr.params); | ||
1062 | |||
1063 | _cairo_glitz_pattern_release_surface (mask_pattern, mask, &mask_attr); | ||
1064 | } | ||
1065 | |||
1066 | if (src_attr.n_params) | ||
1067 | free (src_attr.params); | ||
1068 | |||
1069 | _cairo_glitz_pattern_release_surface (src_pattern, src, &src_attr); | ||
1070 | |||
1071 | return CAIRO_STATUS_SUCCESS; | ||
1072 | } | ||
1073 | |||
1074 | static cairo_int_status_t | ||
1075 | _cairo_glitz_surface_fill_rectangles (void *abstract_dst, | ||
1076 | cairo_operator_t op, | ||
1077 | const cairo_color_t *color, | ||
1078 | cairo_rectangle_int_t *rects, | ||
1079 | int n_rects) | ||
1080 | { | ||
1081 | cairo_glitz_surface_t *dst = abstract_dst; | ||
1082 | cairo_glitz_surface_t *src; | ||
1083 | glitz_rectangle_t stack_rects[CAIRO_STACK_ARRAY_LENGTH (glitz_rectangle_t)]; | ||
1084 | glitz_rectangle_t *glitz_rects = stack_rects; | ||
1085 | glitz_rectangle_t *current_rect; | ||
1086 | cairo_status_t status; | ||
1087 | int i; | ||
1088 | |||
1089 | if (! _is_supported_operator (op)) | ||
1090 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1091 | |||
1092 | status = _cairo_glitz_surface_set_clip_region (dst, NULL); | ||
1093 | assert (status == CAIRO_STATUS_SUCCESS); | ||
1094 | |||
1095 | if (n_rects > ARRAY_LENGTH (stack_rects)) { | ||
1096 | glitz_rects = _cairo_malloc_ab (n_rects, sizeof (glitz_rectangle_t)); | ||
1097 | if (glitz_rects == NULL) | ||
1098 | return _cairo_error (CAIRO_STATUS_NO_MEMORY); | ||
1099 | } | ||
1100 | |||
1101 | for (i = 0; i < n_rects; i++) { | ||
1102 | glitz_rects[i].x = rects[i].x; | ||
1103 | glitz_rects[i].y = rects[i].y; | ||
1104 | glitz_rects[i].width = rects[i].width; | ||
1105 | glitz_rects[i].height = rects[i].height; | ||
1106 | } | ||
1107 | |||
1108 | switch (op) { | ||
1109 | case CAIRO_OPERATOR_CLEAR: | ||
1110 | case CAIRO_OPERATOR_SOURCE: { | ||
1111 | glitz_color_t glitz_color; | ||
1112 | glitz_format_t *format; | ||
1113 | |||
1114 | glitz_color.red = color->red_short; | ||
1115 | glitz_color.green = color->green_short; | ||
1116 | glitz_color.blue = color->blue_short; | ||
1117 | glitz_color.alpha = color->alpha_short; | ||
1118 | |||
1119 | /* | ||
1120 | * XXX even if the dst surface don't have an alpha channel, the | ||
1121 | * above alpha still effect the dst surface because the | ||
1122 | * underlying glitz drawable may have an alpha channel. So | ||
1123 | * replacing the color with an opaque one is needed. | ||
1124 | */ | ||
1125 | format = glitz_surface_get_format (dst->surface); | ||
1126 | if (format->color.alpha_size == 0) | ||
1127 | glitz_color.alpha = 0xffff; | ||
1128 | |||
1129 | glitz_set_rectangles (dst->surface, &glitz_color, | ||
1130 | glitz_rects, n_rects); | ||
1131 | } break; | ||
1132 | case CAIRO_OPERATOR_SATURATE: | ||
1133 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1134 | case CAIRO_OPERATOR_OVER: | ||
1135 | case CAIRO_OPERATOR_IN: | ||
1136 | case CAIRO_OPERATOR_OUT: | ||
1137 | case CAIRO_OPERATOR_ATOP: | ||
1138 | case CAIRO_OPERATOR_DEST: | ||
1139 | case CAIRO_OPERATOR_DEST_OVER: | ||
1140 | case CAIRO_OPERATOR_DEST_IN: | ||
1141 | case CAIRO_OPERATOR_DEST_OUT: | ||
1142 | case CAIRO_OPERATOR_DEST_ATOP: | ||
1143 | case CAIRO_OPERATOR_XOR: | ||
1144 | case CAIRO_OPERATOR_ADD: | ||
1145 | default: | ||
1146 | if (_glitz_ensure_target (dst->surface)) | ||
1147 | { | ||
1148 | if (glitz_rects != stack_rects) | ||
1149 | free (glitz_rects); | ||
1150 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1151 | } | ||
1152 | |||
1153 | src = (cairo_glitz_surface_t *) | ||
1154 | _cairo_surface_create_similar_solid (&dst->base, | ||
1155 | CAIRO_CONTENT_COLOR_ALPHA, | ||
1156 | 1, 1, | ||
1157 | (cairo_color_t *) color, | ||
1158 | FALSE); | ||
1159 | if (src == NULL || src->base.status) { | ||
1160 | if (glitz_rects != stack_rects) | ||
1161 | free (glitz_rects); | ||
1162 | return src ? src->base.status : CAIRO_INT_STATUS_UNSUPPORTED; | ||
1163 | } | ||
1164 | |||
1165 | glitz_surface_set_fill (src->surface, GLITZ_FILL_REPEAT); | ||
1166 | |||
1167 | current_rect = glitz_rects; | ||
1168 | while (n_rects--) | ||
1169 | { | ||
1170 | glitz_composite (_glitz_operator (op), | ||
1171 | src->surface, | ||
1172 | NULL, | ||
1173 | dst->surface, | ||
1174 | 0, 0, | ||
1175 | 0, 0, | ||
1176 | current_rect->x, current_rect->y, | ||
1177 | current_rect->width, current_rect->height); | ||
1178 | current_rect++; | ||
1179 | } | ||
1180 | |||
1181 | cairo_surface_destroy (&src->base); | ||
1182 | break; | ||
1183 | } | ||
1184 | |||
1185 | if (glitz_rects != stack_rects) | ||
1186 | free (glitz_rects); | ||
1187 | |||
1188 | if (glitz_surface_get_status (dst->surface) == GLITZ_STATUS_NOT_SUPPORTED) | ||
1189 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1190 | |||
1191 | return CAIRO_STATUS_SUCCESS; | ||
1192 | } | ||
1193 | |||
1194 | static cairo_int_status_t | ||
1195 | _cairo_glitz_surface_composite_trapezoids (cairo_operator_t op, | ||
1196 | const cairo_pattern_t *pattern, | ||
1197 | void *abstract_dst, | ||
1198 | cairo_antialias_t antialias, | ||
1199 | int src_x, | ||
1200 | int src_y, | ||
1201 | int dst_x, | ||
1202 | int dst_y, | ||
1203 | unsigned int width, | ||
1204 | unsigned int height, | ||
1205 | cairo_trapezoid_t *traps, | ||
1206 | int n_traps, | ||
1207 | cairo_region_t *clip_region) | ||
1208 | { | ||
1209 | cairo_glitz_surface_attributes_t attributes; | ||
1210 | cairo_glitz_surface_t *dst = abstract_dst; | ||
1211 | cairo_glitz_surface_t *src; | ||
1212 | cairo_glitz_surface_t *mask = NULL; | ||
1213 | glitz_buffer_t *buffer = NULL; | ||
1214 | void *data = NULL; | ||
1215 | cairo_int_status_t status; | ||
1216 | unsigned short alpha; | ||
1217 | pixman_trapezoid_t stack_traps[CAIRO_STACK_ARRAY_LENGTH (pixman_trapezoid_t)]; | ||
1218 | pixman_trapezoid_t *pixman_traps = stack_traps; | ||
1219 | int i; | ||
1220 | |||
1221 | if (antialias != CAIRO_ANTIALIAS_DEFAULT && | ||
1222 | antialias != CAIRO_ANTIALIAS_GRAY) | ||
1223 | { | ||
1224 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1225 | } | ||
1226 | |||
1227 | if (! _is_supported_operator (op)) | ||
1228 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1229 | |||
1230 | if (_glitz_ensure_target (dst->surface)) | ||
1231 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1232 | |||
1233 | status = _cairo_glitz_surface_set_clip_region (dst, clip_region); | ||
1234 | if (unlikely (status)) | ||
1235 | return status; | ||
1236 | |||
1237 | /* Convert traps to pixman traps */ | ||
1238 | if (n_traps > ARRAY_LENGTH (stack_traps)) { | ||
1239 | pixman_traps = _cairo_malloc_ab (n_traps, sizeof (pixman_trapezoid_t)); | ||
1240 | if (pixman_traps == NULL) | ||
1241 | return _cairo_error (CAIRO_STATUS_NO_MEMORY); | ||
1242 | } | ||
1243 | |||
1244 | for (i = 0; i < n_traps; i++) { | ||
1245 | pixman_traps[i].top = _cairo_fixed_to_16_16 (traps[i].top); | ||
1246 | pixman_traps[i].bottom = _cairo_fixed_to_16_16 (traps[i].bottom); | ||
1247 | pixman_traps[i].left.p1.x = _cairo_fixed_to_16_16 (traps[i].left.p1.x); | ||
1248 | pixman_traps[i].left.p1.y = _cairo_fixed_to_16_16 (traps[i].left.p1.y); | ||
1249 | pixman_traps[i].left.p2.x = _cairo_fixed_to_16_16 (traps[i].left.p2.x); | ||
1250 | pixman_traps[i].left.p2.y = _cairo_fixed_to_16_16 (traps[i].left.p2.y); | ||
1251 | pixman_traps[i].right.p1.x = _cairo_fixed_to_16_16 (traps[i].right.p1.x); | ||
1252 | pixman_traps[i].right.p1.y = _cairo_fixed_to_16_16 (traps[i].right.p1.y); | ||
1253 | pixman_traps[i].right.p2.x = _cairo_fixed_to_16_16 (traps[i].right.p2.x); | ||
1254 | pixman_traps[i].right.p2.y = _cairo_fixed_to_16_16 (traps[i].right.p2.y); | ||
1255 | } | ||
1256 | |||
1257 | status = _cairo_glitz_pattern_acquire_surface (pattern, dst, | ||
1258 | src_x, src_y, | ||
1259 | width, height, | ||
1260 | &src, &attributes); | ||
1261 | if (status) | ||
1262 | goto FAIL; | ||
1263 | |||
1264 | alpha = 0xffff; | ||
1265 | |||
1266 | if (op == CAIRO_OPERATOR_ADD || n_traps <= 1) { | ||
1267 | static const glitz_color_t clear_black = { 0, 0, 0, 0 }; | ||
1268 | glitz_color_t color; | ||
1269 | glitz_geometry_format_t format; | ||
1270 | int n_trap_added; | ||
1271 | int offset = 0; | ||
1272 | int data_size = 0; | ||
1273 | int size = 30 * n_traps; /* just a guess */ | ||
1274 | |||
1275 | format.vertex.primitive = GLITZ_PRIMITIVE_QUADS; | ||
1276 | format.vertex.type = GLITZ_DATA_TYPE_FLOAT; | ||
1277 | format.vertex.bytes_per_vertex = 3 * sizeof (glitz_float_t); | ||
1278 | format.vertex.attributes = GLITZ_VERTEX_ATTRIBUTE_MASK_COORD_MASK; | ||
1279 | format.vertex.mask.type = GLITZ_DATA_TYPE_FLOAT; | ||
1280 | format.vertex.mask.size = GLITZ_COORDINATE_SIZE_X; | ||
1281 | format.vertex.mask.offset = 2 * sizeof (glitz_float_t); | ||
1282 | |||
1283 | mask = (cairo_glitz_surface_t *) | ||
1284 | _cairo_glitz_surface_create_similar (&dst->base, | ||
1285 | CAIRO_CONTENT_ALPHA, | ||
1286 | 2, 1); | ||
1287 | if (mask == NULL) { | ||
1288 | status = CAIRO_INT_STATUS_UNSUPPORTED; | ||
1289 | goto FAIL; | ||
1290 | } | ||
1291 | if (mask->base.status) { | ||
1292 | status = mask->base.status; | ||
1293 | goto FAIL; | ||
1294 | } | ||
1295 | |||
1296 | color.red = color.green = color.blue = color.alpha = 0xffff; | ||
1297 | |||
1298 | glitz_set_rectangle (mask->surface, &clear_black, 0, 0, 1, 1); | ||
1299 | glitz_set_rectangle (mask->surface, &color, 1, 0, 1, 1); | ||
1300 | |||
1301 | glitz_surface_set_fill (mask->surface, GLITZ_FILL_NEAREST); | ||
1302 | glitz_surface_set_filter (mask->surface, | ||
1303 | GLITZ_FILTER_BILINEAR, | ||
1304 | NULL, 0); | ||
1305 | |||
1306 | size *= format.vertex.bytes_per_vertex; | ||
1307 | |||
1308 | while (n_traps) { | ||
1309 | if (data_size < size) { | ||
1310 | void *p; | ||
1311 | |||
1312 | data_size = size; | ||
1313 | p = realloc (data, data_size); | ||
1314 | if (p == NULL) { | ||
1315 | status = _cairo_error (CAIRO_STATUS_NO_MEMORY); | ||
1316 | goto FAIL; | ||
1317 | } | ||
1318 | data = p; | ||
1319 | |||
1320 | if (buffer) | ||
1321 | glitz_buffer_destroy (buffer); | ||
1322 | |||
1323 | buffer = glitz_buffer_create_for_data (data); | ||
1324 | if (buffer == NULL) { | ||
1325 | status = _cairo_error (CAIRO_STATUS_NO_MEMORY); | ||
1326 | free (data); | ||
1327 | goto FAIL; | ||
1328 | } | ||
1329 | } | ||
1330 | |||
1331 | offset += | ||
1332 | glitz_add_trapezoids (buffer, | ||
1333 | offset, size - offset, | ||
1334 | format.vertex.type, mask->surface, | ||
1335 | (glitz_trapezoid_t *) pixman_traps, n_traps, | ||
1336 | &n_trap_added); | ||
1337 | |||
1338 | n_traps -= n_trap_added; | ||
1339 | traps += n_trap_added; | ||
1340 | size *= 2; | ||
1341 | } | ||
1342 | |||
1343 | glitz_set_geometry (dst->surface, | ||
1344 | GLITZ_GEOMETRY_TYPE_VERTEX, | ||
1345 | &format, buffer); | ||
1346 | glitz_set_array (dst->surface, 0, 3, | ||
1347 | offset / format.vertex.bytes_per_vertex, | ||
1348 | 0, 0); | ||
1349 | } else { | ||
1350 | cairo_image_surface_t *image; | ||
1351 | unsigned char *ptr; | ||
1352 | int stride; | ||
1353 | |||
1354 | stride = (width + 3) & -4; | ||
1355 | data = calloc (stride, height); | ||
1356 | if (data == NULL) { | ||
1357 | status = _cairo_error (CAIRO_STATUS_NO_MEMORY); | ||
1358 | goto FAIL; | ||
1359 | } | ||
1360 | |||
1361 | /* using negative stride */ | ||
1362 | ptr = (unsigned char *) data + stride * (height - 1); | ||
1363 | |||
1364 | image = (cairo_image_surface_t *) | ||
1365 | cairo_image_surface_create_for_data (ptr, | ||
1366 | CAIRO_FORMAT_A8, | ||
1367 | width, height, | ||
1368 | -stride); | ||
1369 | status = image->base.status; | ||
1370 | if (status) { | ||
1371 | free (data); | ||
1372 | goto FAIL; | ||
1373 | } | ||
1374 | |||
1375 | pixman_add_trapezoids (image->pixman_image, -dst_x, -dst_y, | ||
1376 | n_traps, (pixman_trapezoid_t *) pixman_traps); | ||
1377 | |||
1378 | mask = (cairo_glitz_surface_t *) | ||
1379 | _cairo_glitz_surface_create_similar (&dst->base, | ||
1380 | CAIRO_CONTENT_ALPHA, | ||
1381 | width, height); | ||
1382 | status = mask->base.status; | ||
1383 | if (status) { | ||
1384 | free (data); | ||
1385 | cairo_surface_destroy (&image->base); | ||
1386 | goto FAIL; | ||
1387 | } | ||
1388 | |||
1389 | status = _cairo_glitz_surface_set_image (mask, image, | ||
1390 | 0, 0, width, height, 0, 0); | ||
1391 | |||
1392 | cairo_surface_destroy (&image->base); | ||
1393 | |||
1394 | if (status) | ||
1395 | goto FAIL; | ||
1396 | } | ||
1397 | |||
1398 | _cairo_glitz_surface_set_attributes (src, &attributes); | ||
1399 | |||
1400 | glitz_composite (_glitz_operator (op), | ||
1401 | src->surface, | ||
1402 | mask->surface, | ||
1403 | dst->surface, | ||
1404 | src_x + attributes.base.x_offset, | ||
1405 | src_y + attributes.base.y_offset, | ||
1406 | 0, 0, | ||
1407 | dst_x, dst_y, | ||
1408 | width, height); | ||
1409 | |||
1410 | if (attributes.n_params) | ||
1411 | free (attributes.params); | ||
1412 | |||
1413 | glitz_set_geometry (dst->surface, | ||
1414 | GLITZ_GEOMETRY_TYPE_NONE, | ||
1415 | NULL, NULL); | ||
1416 | |||
1417 | if (buffer) | ||
1418 | glitz_buffer_destroy (buffer); | ||
1419 | |||
1420 | free (data); | ||
1421 | |||
1422 | if (glitz_surface_get_status (dst->surface) == GLITZ_STATUS_NOT_SUPPORTED) { | ||
1423 | status = CAIRO_INT_STATUS_UNSUPPORTED; | ||
1424 | goto FAIL; | ||
1425 | } | ||
1426 | |||
1427 | if (! _cairo_operator_bounded_by_mask (op)) { | ||
1428 | status = _cairo_surface_composite_shape_fixup_unbounded (&dst->base, | ||
1429 | &attributes.base, | ||
1430 | glitz_surface_get_width (src->surface), | ||
1431 | glitz_surface_get_height (src->surface), | ||
1432 | width, height, | ||
1433 | src_x, src_y, | ||
1434 | 0, 0, | ||
1435 | dst_x, dst_y, | ||
1436 | width, height, | ||
1437 | clip_region); | ||
1438 | } | ||
1439 | |||
1440 | FAIL: | ||
1441 | _cairo_glitz_pattern_release_surface (pattern, src, &attributes); | ||
1442 | |||
1443 | if (mask != NULL) | ||
1444 | cairo_surface_destroy (&mask->base); | ||
1445 | |||
1446 | if (pixman_traps != stack_traps) | ||
1447 | free (pixman_traps); | ||
1448 | |||
1449 | return status; | ||
1450 | } | ||
1451 | |||
1452 | static cairo_bool_t | ||
1453 | _cairo_glitz_surface_get_extents (void *abstract_surface, | ||
1454 | cairo_rectangle_int_t *rectangle) | ||
1455 | { | ||
1456 | cairo_glitz_surface_t *surface = abstract_surface; | ||
1457 | |||
1458 | rectangle->x = 0; | ||
1459 | rectangle->y = 0; | ||
1460 | rectangle->width = glitz_surface_get_width (surface->surface); | ||
1461 | rectangle->height = glitz_surface_get_height (surface->surface); | ||
1462 | |||
1463 | return TRUE; | ||
1464 | } | ||
1465 | |||
1466 | #define CAIRO_GLITZ_AREA_AVAILABLE 0 | ||
1467 | #define CAIRO_GLITZ_AREA_DIVIDED 1 | ||
1468 | #define CAIRO_GLITZ_AREA_OCCUPIED 2 | ||
1469 | |||
1470 | typedef struct _cairo_glitz_root_area cairo_glitz_root_area_t; | ||
1471 | |||
1472 | typedef struct _cairo_glitz_area { | ||
1473 | int state; | ||
1474 | int level; | ||
1475 | int x, y; | ||
1476 | int width, height; | ||
1477 | struct _cairo_glitz_area *area[4]; | ||
1478 | cairo_glitz_root_area_t *root; | ||
1479 | void *closure; | ||
1480 | } cairo_glitz_area_t; | ||
1481 | |||
1482 | static cairo_glitz_area_t _empty_area = { | ||
1483 | 0, 0, 0, 0, 0, 0, | ||
1484 | { NULL, NULL, NULL, NULL }, | ||
1485 | NULL, | ||
1486 | NULL | ||
1487 | }; | ||
1488 | |||
1489 | typedef struct _cairo_glitz_area_funcs { | ||
1490 | cairo_status_t (*move_in) (cairo_glitz_area_t *area, | ||
1491 | void *closure); | ||
1492 | |||
1493 | void (*move_out) (cairo_glitz_area_t *area, | ||
1494 | void *closure); | ||
1495 | |||
1496 | int (*compare_score) (cairo_glitz_area_t *area, | ||
1497 | void *closure1, | ||
1498 | void *closure2); | ||
1499 | } cairo_glitz_area_funcs_t; | ||
1500 | |||
1501 | struct _cairo_glitz_root_area { | ||
1502 | int max_level; | ||
1503 | int width, height; | ||
1504 | cairo_glitz_area_t *area; | ||
1505 | const cairo_glitz_area_funcs_t *funcs; | ||
1506 | }; | ||
1507 | |||
1508 | static cairo_status_t | ||
1509 | _cairo_glitz_area_move_in (cairo_glitz_area_t *area, | ||
1510 | void *closure) | ||
1511 | { | ||
1512 | area->closure = closure; | ||
1513 | area->state = CAIRO_GLITZ_AREA_OCCUPIED; | ||
1514 | |||
1515 | return (*area->root->funcs->move_in) (area, area->closure); | ||
1516 | } | ||
1517 | |||
1518 | static void | ||
1519 | _cairo_glitz_area_move_out (cairo_glitz_area_t *area) | ||
1520 | { | ||
1521 | if (area->root) | ||
1522 | { | ||
1523 | (*area->root->funcs->move_out) (area, area->closure); | ||
1524 | |||
1525 | area->closure = NULL; | ||
1526 | area->state = CAIRO_GLITZ_AREA_AVAILABLE; | ||
1527 | } | ||
1528 | } | ||
1529 | |||
1530 | static cairo_glitz_area_t * | ||
1531 | _cairo_glitz_area_create (cairo_glitz_root_area_t *root, | ||
1532 | int level, | ||
1533 | int x, | ||
1534 | int y, | ||
1535 | int width, | ||
1536 | int height) | ||
1537 | { | ||
1538 | cairo_glitz_area_t *area; | ||
1539 | int n = 4; | ||
1540 | |||
1541 | area = malloc (sizeof (cairo_glitz_area_t)); | ||
1542 | if (!area) { | ||
1543 | _cairo_error_throw (CAIRO_STATUS_NO_MEMORY); | ||
1544 | return NULL; | ||
1545 | } | ||
1546 | |||
1547 | area->level = level; | ||
1548 | area->x = x; | ||
1549 | area->y = y; | ||
1550 | area->width = width; | ||
1551 | area->height = height; | ||
1552 | area->root = root; | ||
1553 | area->closure = NULL; | ||
1554 | area->state = CAIRO_GLITZ_AREA_AVAILABLE; | ||
1555 | |||
1556 | while (n--) | ||
1557 | area->area[n] = NULL; | ||
1558 | |||
1559 | return area; | ||
1560 | } | ||
1561 | |||
1562 | static void | ||
1563 | _cairo_glitz_area_destroy (cairo_glitz_area_t *area) | ||
1564 | { | ||
1565 | if (area == NULL) | ||
1566 | return; | ||
1567 | |||
1568 | if (area->state == CAIRO_GLITZ_AREA_OCCUPIED) | ||
1569 | { | ||
1570 | _cairo_glitz_area_move_out (area); | ||
1571 | } | ||
1572 | else | ||
1573 | { | ||
1574 | int n = 4; | ||
1575 | |||
1576 | while (n--) | ||
1577 | _cairo_glitz_area_destroy (area->area[n]); | ||
1578 | } | ||
1579 | |||
1580 | free (area); | ||
1581 | } | ||
1582 | |||
1583 | static cairo_glitz_area_t * | ||
1584 | _cairo_glitz_area_get_top_scored_sub_area (cairo_glitz_area_t *area) | ||
1585 | { | ||
1586 | if (!area) | ||
1587 | return NULL; | ||
1588 | |||
1589 | switch (area->state) { | ||
1590 | case CAIRO_GLITZ_AREA_OCCUPIED: | ||
1591 | return area; | ||
1592 | case CAIRO_GLITZ_AREA_AVAILABLE: | ||
1593 | break; | ||
1594 | case CAIRO_GLITZ_AREA_DIVIDED: { | ||
1595 | cairo_glitz_area_t *tmp, *top = NULL; | ||
1596 | int i; | ||
1597 | |||
1598 | for (i = 0; i < 4; i++) | ||
1599 | { | ||
1600 | tmp = _cairo_glitz_area_get_top_scored_sub_area (area->area[i]); | ||
1601 | if (tmp && top) | ||
1602 | { | ||
1603 | if ((*area->root->funcs->compare_score) (tmp, | ||
1604 | tmp->closure, | ||
1605 | top->closure) > 0) | ||
1606 | top = tmp; | ||
1607 | } | ||
1608 | else if (tmp) | ||
1609 | { | ||
1610 | top = tmp; | ||
1611 | } | ||
1612 | } | ||
1613 | return top; | ||
1614 | } | ||
1615 | } | ||
1616 | |||
1617 | return NULL; | ||
1618 | } | ||
1619 | |||
1620 | static cairo_int_status_t | ||
1621 | _cairo_glitz_area_find (cairo_glitz_area_t *area, | ||
1622 | int width, | ||
1623 | int height, | ||
1624 | cairo_bool_t kick_out, | ||
1625 | void *closure) | ||
1626 | { | ||
1627 | cairo_status_t status; | ||
1628 | |||
1629 | if (area->width < width || area->height < height) | ||
1630 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1631 | |||
1632 | switch (area->state) { | ||
1633 | case CAIRO_GLITZ_AREA_OCCUPIED: | ||
1634 | if (kick_out) | ||
1635 | { | ||
1636 | if ((*area->root->funcs->compare_score) (area, | ||
1637 | area->closure, | ||
1638 | closure) >= 0) | ||
1639 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1640 | |||
1641 | _cairo_glitz_area_move_out (area); | ||
1642 | } else { | ||
1643 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1644 | } | ||
1645 | |||
1646 | /* fall-through */ | ||
1647 | case CAIRO_GLITZ_AREA_AVAILABLE: { | ||
1648 | if (area->level == area->root->max_level || | ||
1649 | (area->width == width && area->height == height)) | ||
1650 | { | ||
1651 | return _cairo_glitz_area_move_in (area, closure); | ||
1652 | } | ||
1653 | else | ||
1654 | { | ||
1655 | int dx[4], dy[4], w[4], h[4], i; | ||
1656 | |||
1657 | dx[0] = dx[2] = dy[0] = dy[1] = 0; | ||
1658 | |||
1659 | w[0] = w[2] = dx[1] = dx[3] = width; | ||
1660 | h[0] = h[1] = dy[2] = dy[3] = height; | ||
1661 | |||
1662 | w[1] = w[3] = area->width - width; | ||
1663 | h[2] = h[3] = area->height - height; | ||
1664 | |||
1665 | for (i = 0; i < 2; i++) | ||
1666 | { | ||
1667 | if (w[i]) | ||
1668 | area->area[i] = | ||
1669 | _cairo_glitz_area_create (area->root, | ||
1670 | area->level + 1, | ||
1671 | area->x + dx[i], | ||
1672 | area->y + dy[i], | ||
1673 | w[i], h[i]); | ||
1674 | } | ||
1675 | |||
1676 | for (; i < 4; i++) | ||
1677 | { | ||
1678 | if (w[i] && h[i]) | ||
1679 | area->area[i] = | ||
1680 | _cairo_glitz_area_create (area->root, | ||
1681 | area->level + 1, | ||
1682 | area->x + dx[i], | ||
1683 | area->y + dy[i], | ||
1684 | w[i], h[i]); | ||
1685 | } | ||
1686 | |||
1687 | area->state = CAIRO_GLITZ_AREA_DIVIDED; | ||
1688 | |||
1689 | status = _cairo_glitz_area_find (area->area[0], | ||
1690 | width, height, | ||
1691 | kick_out, closure); | ||
1692 | if (status == CAIRO_STATUS_SUCCESS) | ||
1693 | return CAIRO_STATUS_SUCCESS; | ||
1694 | } | ||
1695 | } break; | ||
1696 | case CAIRO_GLITZ_AREA_DIVIDED: { | ||
1697 | cairo_glitz_area_t *to_area; | ||
1698 | int i, rejected = FALSE; | ||
1699 | |||
1700 | for (i = 0; i < 4; i++) | ||
1701 | { | ||
1702 | if (area->area[i]) | ||
1703 | { | ||
1704 | if (area->area[i]->width >= width && | ||
1705 | area->area[i]->height >= height) | ||
1706 | { | ||
1707 | status = _cairo_glitz_area_find (area->area[i], | ||
1708 | width, height, | ||
1709 | kick_out, closure); | ||
1710 | if (status == CAIRO_STATUS_SUCCESS) | ||
1711 | return CAIRO_STATUS_SUCCESS; | ||
1712 | |||
1713 | rejected = TRUE; | ||
1714 | } | ||
1715 | } | ||
1716 | } | ||
1717 | |||
1718 | if (rejected) | ||
1719 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1720 | |||
1721 | to_area = _cairo_glitz_area_get_top_scored_sub_area (area); | ||
1722 | if (to_area) | ||
1723 | { | ||
1724 | if (kick_out) | ||
1725 | { | ||
1726 | if ((*area->root->funcs->compare_score) (to_area, | ||
1727 | to_area->closure, | ||
1728 | closure) >= 0) | ||
1729 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1730 | } else { | ||
1731 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1732 | } | ||
1733 | } | ||
1734 | |||
1735 | for (i = 0; i < 4; i++) | ||
1736 | { | ||
1737 | _cairo_glitz_area_destroy (area->area[i]); | ||
1738 | area->area[i] = NULL; | ||
1739 | } | ||
1740 | |||
1741 | area->closure = NULL; | ||
1742 | area->state = CAIRO_GLITZ_AREA_AVAILABLE; | ||
1743 | |||
1744 | status = _cairo_glitz_area_find (area, width, height, | ||
1745 | TRUE, closure); | ||
1746 | if (status == CAIRO_STATUS_SUCCESS) | ||
1747 | return CAIRO_STATUS_SUCCESS; | ||
1748 | |||
1749 | } break; | ||
1750 | } | ||
1751 | |||
1752 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1753 | } | ||
1754 | |||
1755 | static cairo_status_t | ||
1756 | _cairo_glitz_root_area_init (cairo_glitz_root_area_t *root, | ||
1757 | int max_level, | ||
1758 | int width, | ||
1759 | int height, | ||
1760 | const cairo_glitz_area_funcs_t *funcs) | ||
1761 | { | ||
1762 | root->max_level = max_level; | ||
1763 | root->funcs = funcs; | ||
1764 | |||
1765 | root->area = _cairo_glitz_area_create (root, 0, 0, 0, width, height); | ||
1766 | if (!root->area) | ||
1767 | return _cairo_error (CAIRO_STATUS_NO_MEMORY); | ||
1768 | |||
1769 | return CAIRO_STATUS_SUCCESS; | ||
1770 | } | ||
1771 | |||
1772 | static void | ||
1773 | _cairo_glitz_root_area_fini (cairo_glitz_root_area_t *root) | ||
1774 | { | ||
1775 | _cairo_glitz_area_destroy (root->area); | ||
1776 | } | ||
1777 | |||
1778 | typedef struct _cairo_glitz_surface_font_private { | ||
1779 | cairo_glitz_root_area_t root; | ||
1780 | glitz_surface_t *surface; | ||
1781 | } cairo_glitz_surface_font_private_t; | ||
1782 | |||
1783 | typedef struct _cairo_glitz_surface_glyph_private { | ||
1784 | cairo_glitz_area_t *area; | ||
1785 | cairo_bool_t locked; | ||
1786 | cairo_point_double_t p1, p2; | ||
1787 | } cairo_glitz_surface_glyph_private_t; | ||
1788 | |||
1789 | static cairo_status_t | ||
1790 | _cairo_glitz_glyph_move_in (cairo_glitz_area_t *area, | ||
1791 | void *closure) | ||
1792 | { | ||
1793 | cairo_glitz_surface_glyph_private_t *glyph_private = closure; | ||
1794 | |||
1795 | glyph_private->area = area; | ||
1796 | |||
1797 | return CAIRO_STATUS_SUCCESS; | ||
1798 | } | ||
1799 | |||
1800 | static void | ||
1801 | _cairo_glitz_glyph_move_out (cairo_glitz_area_t *area, | ||
1802 | void *closure) | ||
1803 | { | ||
1804 | cairo_glitz_surface_glyph_private_t *glyph_private = closure; | ||
1805 | |||
1806 | glyph_private->area = NULL; | ||
1807 | } | ||
1808 | |||
1809 | static int | ||
1810 | _cairo_glitz_glyph_compare (cairo_glitz_area_t *area, | ||
1811 | void *closure1, | ||
1812 | void *closure2) | ||
1813 | { | ||
1814 | cairo_glitz_surface_glyph_private_t *glyph_private = closure1; | ||
1815 | |||
1816 | if (glyph_private->locked) | ||
1817 | return 1; | ||
1818 | |||
1819 | return -1; | ||
1820 | } | ||
1821 | |||
1822 | static const cairo_glitz_area_funcs_t _cairo_glitz_area_funcs = { | ||
1823 | _cairo_glitz_glyph_move_in, | ||
1824 | _cairo_glitz_glyph_move_out, | ||
1825 | _cairo_glitz_glyph_compare | ||
1826 | }; | ||
1827 | |||
1828 | #define GLYPH_CACHE_TEXTURE_SIZE 512 | ||
1829 | #define GLYPH_CACHE_MAX_LEVEL 64 | ||
1830 | #define GLYPH_CACHE_MAX_HEIGHT 96 | ||
1831 | #define GLYPH_CACHE_MAX_WIDTH 96 | ||
1832 | |||
1833 | #define WRITE_VEC2(ptr, _x, _y) \ | ||
1834 | *(ptr)++ = (_x); \ | ||
1835 | *(ptr)++ = (_y) | ||
1836 | |||
1837 | #define WRITE_BOX(ptr, _vx1, _vy1, _vx2, _vy2, p1, p2) \ | ||
1838 | WRITE_VEC2 (ptr, _vx1, _vy1); \ | ||
1839 | WRITE_VEC2 (ptr, (p1)->x, (p2)->y); \ | ||
1840 | WRITE_VEC2 (ptr, _vx2, _vy1); \ | ||
1841 | WRITE_VEC2 (ptr, (p2)->x, (p2)->y); \ | ||
1842 | WRITE_VEC2 (ptr, _vx2, _vy2); \ | ||
1843 | WRITE_VEC2 (ptr, (p2)->x, (p1)->y); \ | ||
1844 | WRITE_VEC2 (ptr, _vx1, _vy2); \ | ||
1845 | WRITE_VEC2 (ptr, (p1)->x, (p1)->y) | ||
1846 | |||
1847 | static cairo_status_t | ||
1848 | _cairo_glitz_surface_font_init (cairo_glitz_surface_t *surface, | ||
1849 | cairo_scaled_font_t *scaled_font, | ||
1850 | cairo_format_t format) | ||
1851 | { | ||
1852 | cairo_glitz_surface_font_private_t *font_private; | ||
1853 | glitz_drawable_t *drawable; | ||
1854 | glitz_format_t *surface_format = NULL; | ||
1855 | cairo_int_status_t status; | ||
1856 | |||
1857 | drawable = glitz_surface_get_drawable (surface->surface); | ||
1858 | |||
1859 | switch (format) { | ||
1860 | case CAIRO_FORMAT_A1: | ||
1861 | case CAIRO_FORMAT_A8: | ||
1862 | surface_format = | ||
1863 | glitz_find_standard_format (drawable, GLITZ_STANDARD_A8); | ||
1864 | break; | ||
1865 | case CAIRO_FORMAT_RGB24: | ||
1866 | ASSERT_NOT_REACHED; | ||
1867 | break; | ||
1868 | case CAIRO_FORMAT_ARGB32: | ||
1869 | surface_format = | ||
1870 | glitz_find_standard_format (drawable, GLITZ_STANDARD_ARGB32); | ||
1871 | default: | ||
1872 | break; | ||
1873 | } | ||
1874 | |||
1875 | if (!surface_format) | ||
1876 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1877 | |||
1878 | font_private = malloc (sizeof (cairo_glitz_surface_font_private_t)); | ||
1879 | if (!font_private) | ||
1880 | return _cairo_error (CAIRO_STATUS_NO_MEMORY); | ||
1881 | |||
1882 | font_private->surface = glitz_surface_create (drawable, surface_format, | ||
1883 | GLYPH_CACHE_TEXTURE_SIZE, | ||
1884 | GLYPH_CACHE_TEXTURE_SIZE, | ||
1885 | 0, NULL); | ||
1886 | if (font_private->surface == NULL) | ||
1887 | { | ||
1888 | free (font_private); | ||
1889 | |||
1890 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1891 | } | ||
1892 | |||
1893 | if (format == CAIRO_FORMAT_ARGB32) | ||
1894 | glitz_surface_set_component_alpha (font_private->surface, 1); | ||
1895 | |||
1896 | status = _cairo_glitz_root_area_init (&font_private->root, | ||
1897 | GLYPH_CACHE_MAX_LEVEL, | ||
1898 | GLYPH_CACHE_TEXTURE_SIZE, | ||
1899 | GLYPH_CACHE_TEXTURE_SIZE, | ||
1900 | &_cairo_glitz_area_funcs); | ||
1901 | if (status != CAIRO_STATUS_SUCCESS) | ||
1902 | { | ||
1903 | glitz_surface_destroy (font_private->surface); | ||
1904 | free (font_private); | ||
1905 | |||
1906 | return status; | ||
1907 | } | ||
1908 | |||
1909 | scaled_font->surface_private = font_private; | ||
1910 | scaled_font->surface_backend = _cairo_glitz_surface_get_backend (); | ||
1911 | |||
1912 | return CAIRO_STATUS_SUCCESS; | ||
1913 | } | ||
1914 | |||
1915 | static void | ||
1916 | _cairo_glitz_surface_scaled_font_fini (cairo_scaled_font_t *scaled_font) | ||
1917 | { | ||
1918 | cairo_glitz_surface_font_private_t *font_private; | ||
1919 | |||
1920 | font_private = scaled_font->surface_private; | ||
1921 | if (font_private) | ||
1922 | { | ||
1923 | _cairo_glitz_root_area_fini (&font_private->root); | ||
1924 | glitz_surface_destroy (font_private->surface); | ||
1925 | free (font_private); | ||
1926 | } | ||
1927 | } | ||
1928 | |||
1929 | static void | ||
1930 | _cairo_glitz_surface_scaled_glyph_fini (cairo_scaled_glyph_t *scaled_glyph, | ||
1931 | cairo_scaled_font_t *scaled_font) | ||
1932 | { | ||
1933 | cairo_glitz_surface_glyph_private_t *glyph_private; | ||
1934 | |||
1935 | glyph_private = scaled_glyph->surface_private; | ||
1936 | if (glyph_private) | ||
1937 | { | ||
1938 | if (glyph_private->area) | ||
1939 | _cairo_glitz_area_move_out (glyph_private->area); | ||
1940 | |||
1941 | free (glyph_private); | ||
1942 | } | ||
1943 | } | ||
1944 | |||
1945 | #define FIXED_TO_FLOAT(f) (((glitz_float_t) (f)) / 65536) | ||
1946 | |||
1947 | static cairo_status_t | ||
1948 | _cairo_glitz_surface_add_glyph (cairo_glitz_surface_t *surface, | ||
1949 | cairo_scaled_font_t *scaled_font, | ||
1950 | cairo_scaled_glyph_t *scaled_glyph) | ||
1951 | { | ||
1952 | cairo_image_surface_t *glyph_surface = scaled_glyph->surface; | ||
1953 | cairo_glitz_surface_font_private_t *font_private; | ||
1954 | cairo_glitz_surface_glyph_private_t *glyph_private; | ||
1955 | glitz_point_fixed_t p1, p2; | ||
1956 | glitz_pixel_format_t pf; | ||
1957 | glitz_buffer_t *buffer; | ||
1958 | cairo_format_masks_t masks; | ||
1959 | cairo_int_status_t status; | ||
1960 | |||
1961 | glyph_private = scaled_glyph->surface_private; | ||
1962 | if (glyph_private == NULL) | ||
1963 | { | ||
1964 | glyph_private = malloc (sizeof (cairo_glitz_surface_glyph_private_t)); | ||
1965 | if (!glyph_private) | ||
1966 | return _cairo_error (CAIRO_STATUS_NO_MEMORY); | ||
1967 | |||
1968 | glyph_private->area = NULL; | ||
1969 | glyph_private->locked = FALSE; | ||
1970 | |||
1971 | scaled_glyph->surface_private = (void *) glyph_private; | ||
1972 | } | ||
1973 | |||
1974 | if (glyph_surface->width > GLYPH_CACHE_MAX_WIDTH || | ||
1975 | glyph_surface->height > GLYPH_CACHE_MAX_HEIGHT) | ||
1976 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
1977 | |||
1978 | if (scaled_font->surface_private == NULL) | ||
1979 | { | ||
1980 | status = _cairo_glitz_surface_font_init (surface, scaled_font, | ||
1981 | glyph_surface->format); | ||
1982 | if (status) | ||
1983 | return status; | ||
1984 | } | ||
1985 | |||
1986 | font_private = scaled_font->surface_private; | ||
1987 | |||
1988 | if (glyph_surface->width == 0 || glyph_surface->height == 0) | ||
1989 | { | ||
1990 | glyph_private->area = &_empty_area; | ||
1991 | return CAIRO_STATUS_SUCCESS; | ||
1992 | } | ||
1993 | |||
1994 | if (_cairo_glitz_area_find (font_private->root.area, | ||
1995 | glyph_surface->width, | ||
1996 | glyph_surface->height, | ||
1997 | FALSE, glyph_private)) | ||
1998 | { | ||
1999 | if (_cairo_glitz_area_find (font_private->root.area, | ||
2000 | glyph_surface->width, | ||
2001 | glyph_surface->height, | ||
2002 | TRUE, glyph_private)) | ||
2003 | return CAIRO_STATUS_SUCCESS; | ||
2004 | } | ||
2005 | |||
2006 | buffer = glitz_buffer_create_for_data (glyph_surface->data); | ||
2007 | if (!buffer) | ||
2008 | { | ||
2009 | _cairo_glitz_area_move_out (glyph_private->area); | ||
2010 | return _cairo_error (CAIRO_STATUS_NO_MEMORY); | ||
2011 | } | ||
2012 | |||
2013 | _pixman_format_to_masks (glyph_surface->pixman_format, &masks); | ||
2014 | |||
2015 | pf.fourcc = GLITZ_FOURCC_RGB; | ||
2016 | pf.masks.bpp = masks.bpp; | ||
2017 | pf.masks.alpha_mask = masks.alpha_mask; | ||
2018 | pf.masks.red_mask = masks.red_mask; | ||
2019 | pf.masks.green_mask = masks.green_mask; | ||
2020 | pf.masks.blue_mask = masks.blue_mask; | ||
2021 | |||
2022 | pf.bytes_per_line = glyph_surface->stride; | ||
2023 | pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP; | ||
2024 | pf.xoffset = 0; | ||
2025 | pf.skip_lines = 0; | ||
2026 | |||
2027 | glitz_set_pixels (font_private->surface, | ||
2028 | glyph_private->area->x, | ||
2029 | glyph_private->area->y, | ||
2030 | glyph_surface->width, | ||
2031 | glyph_surface->height, | ||
2032 | &pf, buffer); | ||
2033 | |||
2034 | glitz_buffer_destroy (buffer); | ||
2035 | |||
2036 | p1.x = glyph_private->area->x << 16; | ||
2037 | p1.y = glyph_private->area->y << 16; | ||
2038 | p2.x = (glyph_private->area->x + glyph_surface->width) << 16; | ||
2039 | p2.y = (glyph_private->area->y + glyph_surface->height) << 16; | ||
2040 | |||
2041 | glitz_surface_translate_point (font_private->surface, &p1, &p1); | ||
2042 | glitz_surface_translate_point (font_private->surface, &p2, &p2); | ||
2043 | |||
2044 | glyph_private->p1.x = FIXED_TO_FLOAT (p1.x); | ||
2045 | glyph_private->p1.y = FIXED_TO_FLOAT (p1.y); | ||
2046 | glyph_private->p2.x = FIXED_TO_FLOAT (p2.x); | ||
2047 | glyph_private->p2.y = FIXED_TO_FLOAT (p2.y); | ||
2048 | |||
2049 | return CAIRO_STATUS_SUCCESS; | ||
2050 | } | ||
2051 | |||
2052 | #define N_STACK_BUF 256 | ||
2053 | |||
2054 | static cairo_int_status_t | ||
2055 | _cairo_glitz_surface_old_show_glyphs (cairo_scaled_font_t *scaled_font, | ||
2056 | cairo_operator_t op, | ||
2057 | const cairo_pattern_t *pattern, | ||
2058 | void *abstract_surface, | ||
2059 | int src_x, | ||
2060 | int src_y, | ||
2061 | int dst_x, | ||
2062 | int dst_y, | ||
2063 | unsigned int width, | ||
2064 | unsigned int height, | ||
2065 | cairo_glyph_t *glyphs, | ||
2066 | int num_glyphs, | ||
2067 | cairo_region_t *clip_region) | ||
2068 | { | ||
2069 | cairo_glitz_surface_attributes_t attributes; | ||
2070 | cairo_glitz_surface_glyph_private_t *glyph_private; | ||
2071 | cairo_glitz_surface_t *dst = abstract_surface; | ||
2072 | cairo_glitz_surface_t *src; | ||
2073 | cairo_scaled_glyph_t *stack_scaled_glyphs[N_STACK_BUF]; | ||
2074 | cairo_scaled_glyph_t **scaled_glyphs; | ||
2075 | glitz_float_t stack_vertices[N_STACK_BUF * 16]; | ||
2076 | glitz_float_t *vertices; | ||
2077 | glitz_buffer_t *buffer; | ||
2078 | cairo_int_status_t status; | ||
2079 | int x_offset, y_offset; | ||
2080 | int i, cached_glyphs = 0; | ||
2081 | int remaining_glyps = num_glyphs; | ||
2082 | glitz_float_t x1, y1, x2, y2; | ||
2083 | static const glitz_vertex_format_t format = { | ||
2084 | GLITZ_PRIMITIVE_QUADS, | ||
2085 | GLITZ_DATA_TYPE_FLOAT, | ||
2086 | sizeof (glitz_float_t) * 4, | ||
2087 | GLITZ_VERTEX_ATTRIBUTE_MASK_COORD_MASK, | ||
2088 | { 0 }, | ||
2089 | { | ||
2090 | GLITZ_DATA_TYPE_FLOAT, | ||
2091 | GLITZ_COORDINATE_SIZE_XY, | ||
2092 | sizeof (glitz_float_t) * 2, | ||
2093 | } | ||
2094 | }; | ||
2095 | |||
2096 | if (scaled_font->surface_backend != NULL && | ||
2097 | scaled_font->surface_backend != _cairo_glitz_surface_get_backend ()) | ||
2098 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
2099 | |||
2100 | if (! _is_supported_operator (op)) | ||
2101 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
2102 | |||
2103 | /* XXX Unbounded operators are not handled correctly */ | ||
2104 | if (! _cairo_operator_bounded_by_mask (op)) | ||
2105 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
2106 | |||
2107 | if (_glitz_ensure_target (dst->surface)) | ||
2108 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
2109 | |||
2110 | status = _cairo_glitz_surface_set_clip_region (dst, NULL); | ||
2111 | if (unlikely (status)) | ||
2112 | return status; | ||
2113 | |||
2114 | status = _cairo_glitz_pattern_acquire_surface (pattern, dst, | ||
2115 | src_x, src_y, | ||
2116 | width, height, | ||
2117 | &src, &attributes); | ||
2118 | if (status) | ||
2119 | return status; | ||
2120 | |||
2121 | _cairo_glitz_surface_set_attributes (src, &attributes); | ||
2122 | |||
2123 | if (num_glyphs > N_STACK_BUF) | ||
2124 | { | ||
2125 | char *data; | ||
2126 | size_t size1, size2; | ||
2127 | |||
2128 | if ((size_t)num_glyphs >= INT32_MAX / sizeof(void*) || | ||
2129 | (size_t)num_glyphs >= INT32_MAX / sizeof(glitz_float_t) || | ||
2130 | ((size_t)num_glyphs * sizeof(glitz_float_t)) >= INT32_MAX / 16) | ||
2131 | goto FAIL1; | ||
2132 | |||
2133 | size1 = num_glyphs * sizeof(void *); | ||
2134 | size2 = num_glyphs * sizeof(glitz_float_t) * 16; | ||
2135 | if (size1 >= INT32_MAX - size2) | ||
2136 | goto FAIL1; | ||
2137 | |||
2138 | data = malloc (size1 + size2); | ||
2139 | if (!data) { | ||
2140 | _cairo_error_throw (CAIRO_STATUS_NO_MEMORY); | ||
2141 | goto FAIL1; | ||
2142 | } | ||
2143 | |||
2144 | scaled_glyphs = (cairo_scaled_glyph_t **) data; | ||
2145 | vertices = (glitz_float_t *) (data + num_glyphs * sizeof (void *)); | ||
2146 | } | ||
2147 | else | ||
2148 | { | ||
2149 | scaled_glyphs = stack_scaled_glyphs; | ||
2150 | vertices = stack_vertices; | ||
2151 | } | ||
2152 | |||
2153 | buffer = glitz_buffer_create_for_data (vertices); | ||
2154 | if (!buffer) | ||
2155 | goto FAIL2; | ||
2156 | |||
2157 | _cairo_scaled_font_freeze_cache (scaled_font); | ||
2158 | |||
2159 | for (i = 0; i < num_glyphs; i++) | ||
2160 | { | ||
2161 | status = _cairo_scaled_glyph_lookup (scaled_font, | ||
2162 | glyphs[i].index, | ||
2163 | CAIRO_SCALED_GLYPH_INFO_SURFACE, | ||
2164 | &scaled_glyphs[i]); | ||
2165 | if (status != CAIRO_STATUS_SUCCESS) | ||
2166 | { | ||
2167 | num_glyphs = i; | ||
2168 | goto UNLOCK; | ||
2169 | } | ||
2170 | |||
2171 | glyph_private = scaled_glyphs[i]->surface_private; | ||
2172 | if (!glyph_private || !glyph_private->area) | ||
2173 | { | ||
2174 | status = _cairo_glitz_surface_add_glyph (dst, | ||
2175 | scaled_font, | ||
2176 | scaled_glyphs[i]); | ||
2177 | if (status != CAIRO_STATUS_SUCCESS) { | ||
2178 | num_glyphs = i; | ||
2179 | goto UNLOCK; | ||
2180 | } | ||
2181 | } | ||
2182 | glyph_private = scaled_glyphs[i]->surface_private; | ||
2183 | if (glyph_private && glyph_private->area) | ||
2184 | { | ||
2185 | remaining_glyps--; | ||
2186 | |||
2187 | if (glyph_private->area->width) | ||
2188 | { | ||
2189 | x_offset = scaled_glyphs[i]->surface->base.device_transform.x0; | ||
2190 | y_offset = scaled_glyphs[i]->surface->base.device_transform.y0; | ||
2191 | |||
2192 | x1 = _cairo_lround (glyphs[i].x - x_offset); | ||
2193 | y1 = _cairo_lround (glyphs[i].y - y_offset); | ||
2194 | x2 = x1 + glyph_private->area->width; | ||
2195 | y2 = y1 + glyph_private->area->height; | ||
2196 | |||
2197 | WRITE_BOX (vertices, x1, y1, x2, y2, | ||
2198 | &glyph_private->p1, &glyph_private->p2); | ||
2199 | |||
2200 | glyph_private->locked = TRUE; | ||
2201 | |||
2202 | cached_glyphs++; | ||
2203 | } | ||
2204 | } | ||
2205 | } | ||
2206 | |||
2207 | if (remaining_glyps) | ||
2208 | { | ||
2209 | cairo_surface_t *image; | ||
2210 | cairo_glitz_surface_t *clone; | ||
2211 | |||
2212 | for (i = 0; i < num_glyphs; i++) | ||
2213 | { | ||
2214 | glyph_private = scaled_glyphs[i]->surface_private; | ||
2215 | if (!glyph_private || !glyph_private->area) | ||
2216 | { | ||
2217 | int glyph_width, glyph_height; | ||
2218 | int clone_offset_x, clone_offset_y; | ||
2219 | |||
2220 | image = &scaled_glyphs[i]->surface->base; | ||
2221 | glyph_width = scaled_glyphs[i]->surface->width; | ||
2222 | glyph_height = scaled_glyphs[i]->surface->height; | ||
2223 | status = | ||
2224 | _cairo_glitz_surface_clone_similar (abstract_surface, | ||
2225 | image, | ||
2226 | 0, | ||
2227 | 0, | ||
2228 | glyph_width, | ||
2229 | glyph_height, | ||
2230 | &clone_offset_x, | ||
2231 | &clone_offset_y, | ||
2232 | (cairo_surface_t **) | ||
2233 | &clone); | ||
2234 | if (status) | ||
2235 | goto UNLOCK; | ||
2236 | |||
2237 | assert (clone_offset_x == 0); | ||
2238 | assert (clone_offset_y == 0); | ||
2239 | |||
2240 | x_offset = scaled_glyphs[i]->surface->base.device_transform.x0; | ||
2241 | y_offset = scaled_glyphs[i]->surface->base.device_transform.y0; | ||
2242 | x1 = _cairo_lround (glyphs[i].x - x_offset); | ||
2243 | y1 = _cairo_lround (glyphs[i].y - y_offset); | ||
2244 | |||
2245 | glitz_composite (_glitz_operator (op), | ||
2246 | src->surface, | ||
2247 | clone->surface, | ||
2248 | dst->surface, | ||
2249 | src_x + attributes.base.x_offset + x1, | ||
2250 | src_y + attributes.base.y_offset + y1, | ||
2251 | 0, 0, | ||
2252 | x1, y1, | ||
2253 | glyph_width, | ||
2254 | glyph_height); | ||
2255 | |||
2256 | cairo_surface_destroy (&clone->base); | ||
2257 | |||
2258 | if (glitz_surface_get_status (dst->surface) == | ||
2259 | GLITZ_STATUS_NOT_SUPPORTED) | ||
2260 | { | ||
2261 | status = CAIRO_INT_STATUS_UNSUPPORTED; | ||
2262 | goto UNLOCK; | ||
2263 | } | ||
2264 | } | ||
2265 | } | ||
2266 | } | ||
2267 | |||
2268 | if (cached_glyphs) | ||
2269 | { | ||
2270 | cairo_glitz_surface_font_private_t *font_private; | ||
2271 | |||
2272 | glitz_set_geometry (dst->surface, | ||
2273 | GLITZ_GEOMETRY_TYPE_VERTEX, | ||
2274 | (glitz_geometry_format_t *) &format, | ||
2275 | buffer); | ||
2276 | |||
2277 | glitz_set_array (dst->surface, 0, 4, cached_glyphs * 4, 0, 0); | ||
2278 | |||
2279 | font_private = scaled_font->surface_private; | ||
2280 | |||
2281 | glitz_composite (_glitz_operator (op), | ||
2282 | src->surface, | ||
2283 | font_private->surface, | ||
2284 | dst->surface, | ||
2285 | src_x + attributes.base.x_offset, | ||
2286 | src_y + attributes.base.y_offset, | ||
2287 | 0, 0, | ||
2288 | dst_x, dst_y, | ||
2289 | width, height); | ||
2290 | |||
2291 | glitz_set_geometry (dst->surface, | ||
2292 | GLITZ_GEOMETRY_TYPE_NONE, | ||
2293 | NULL, NULL); | ||
2294 | } | ||
2295 | |||
2296 | UNLOCK: | ||
2297 | if (cached_glyphs) | ||
2298 | { | ||
2299 | for (i = 0; i < num_glyphs; i++) | ||
2300 | { | ||
2301 | glyph_private = scaled_glyphs[i]->surface_private; | ||
2302 | if (glyph_private) | ||
2303 | glyph_private->locked = FALSE; | ||
2304 | } | ||
2305 | } | ||
2306 | |||
2307 | _cairo_scaled_font_thaw_cache (scaled_font); | ||
2308 | |||
2309 | glitz_buffer_destroy (buffer); | ||
2310 | |||
2311 | FAIL2: | ||
2312 | if (num_glyphs > N_STACK_BUF) | ||
2313 | free (scaled_glyphs); | ||
2314 | |||
2315 | FAIL1: | ||
2316 | if (attributes.n_params) | ||
2317 | free (attributes.params); | ||
2318 | |||
2319 | _cairo_glitz_pattern_release_surface (pattern, src, &attributes); | ||
2320 | |||
2321 | if (status) | ||
2322 | return status; | ||
2323 | |||
2324 | if (glitz_surface_get_status (dst->surface) == GLITZ_STATUS_NOT_SUPPORTED) | ||
2325 | return CAIRO_INT_STATUS_UNSUPPORTED; | ||
2326 | |||
2327 | return CAIRO_STATUS_SUCCESS; | ||
2328 | } | ||
2329 | |||
2330 | static cairo_status_t | ||
2331 | _cairo_glitz_surface_flush (void *abstract_surface) | ||
2332 | { | ||
2333 | cairo_glitz_surface_t *surface = abstract_surface; | ||
2334 | |||
2335 | glitz_surface_flush (surface->surface); | ||
2336 | |||
2337 | return CAIRO_STATUS_SUCCESS; | ||
2338 | } | ||
2339 | |||
2340 | static cairo_bool_t | ||
2341 | _cairo_glitz_surface_is_similar (void *surface_a, | ||
2342 | void *surface_b, | ||
2343 | cairo_content_t content) | ||
2344 | { | ||
2345 | cairo_glitz_surface_t *a = (cairo_glitz_surface_t *) surface_a; | ||
2346 | cairo_glitz_surface_t *b = (cairo_glitz_surface_t *) surface_b; | ||
2347 | |||
2348 | glitz_drawable_t *drawable_a = glitz_surface_get_drawable (a->surface); | ||
2349 | glitz_drawable_t *drawable_b = glitz_surface_get_drawable (b->surface); | ||
2350 | |||
2351 | /* XXX Disable caching of glitz surfaces by the solid pattern cache. | ||
2352 | * Until glitz has a mechanism for releasing resources on connection | ||
2353 | * closure, we will attempt to access invalid pointers when evicting | ||
2354 | * old surfaces from the solid pattern cache. | ||
2355 | */ | ||
2356 | return FALSE; | ||
2357 | |||
2358 | return drawable_a == drawable_b; | ||
2359 | } | ||
2360 | |||
2361 | static const cairo_surface_backend_t cairo_glitz_surface_backend = { | ||
2362 | CAIRO_SURFACE_TYPE_GLITZ, | ||
2363 | _cairo_glitz_surface_create_similar, | ||
2364 | _cairo_glitz_surface_finish, | ||
2365 | _cairo_glitz_surface_acquire_source_image, | ||
2366 | _cairo_glitz_surface_release_source_image, | ||
2367 | |||
2368 | _cairo_glitz_surface_acquire_dest_image, | ||
2369 | _cairo_glitz_surface_release_dest_image, | ||
2370 | _cairo_glitz_surface_clone_similar, | ||
2371 | _cairo_glitz_surface_composite, | ||
2372 | _cairo_glitz_surface_fill_rectangles, | ||
2373 | _cairo_glitz_surface_composite_trapezoids, | ||
2374 | NULL, /* create_span_renderer */ | ||
2375 | NULL, /* check_span_renderer */ | ||
2376 | |||
2377 | NULL, /* copy_page */ | ||
2378 | NULL, /* show_page */ | ||
2379 | _cairo_glitz_surface_get_extents, | ||
2380 | _cairo_glitz_surface_old_show_glyphs, | ||
2381 | NULL, /* get_font_options */ | ||
2382 | _cairo_glitz_surface_flush, | ||
2383 | NULL, /* mark_dirty_rectangle */ | ||
2384 | _cairo_glitz_surface_scaled_font_fini, | ||
2385 | _cairo_glitz_surface_scaled_glyph_fini, | ||
2386 | |||
2387 | NULL, /* paint */ | ||
2388 | NULL, /* mask */ | ||
2389 | NULL, /* stroke */ | ||
2390 | NULL, /* fill */ | ||
2391 | NULL, /* show_glyphs */ | ||
2392 | |||
2393 | _cairo_glitz_surface_snapshot, | ||
2394 | _cairo_glitz_surface_is_similar, | ||
2395 | }; | ||
2396 | |||
2397 | static const cairo_surface_backend_t * | ||
2398 | _cairo_glitz_surface_get_backend (void) | ||
2399 | { | ||
2400 | return &cairo_glitz_surface_backend; | ||
2401 | } | ||
2402 | |||
2403 | static cairo_content_t | ||
2404 | _glitz_format_to_content (glitz_format_t * format) | ||
2405 | { | ||
2406 | assert (format->color.fourcc == GLITZ_FOURCC_RGB); | ||
2407 | |||
2408 | if (format->color.alpha_size != 0) { | ||
2409 | if (format->color.red_size != 0 && | ||
2410 | format->color.green_size != 0 && | ||
2411 | format->color.blue_size != 0) | ||
2412 | return CAIRO_CONTENT_COLOR_ALPHA; | ||
2413 | else | ||
2414 | return CAIRO_CONTENT_ALPHA; | ||
2415 | } | ||
2416 | return CAIRO_CONTENT_COLOR; | ||
2417 | } | ||
2418 | |||
2419 | cairo_surface_t * | ||
2420 | cairo_glitz_surface_create (glitz_surface_t *surface) | ||
2421 | { | ||
2422 | cairo_glitz_surface_t *crsurface; | ||
2423 | glitz_format_t *format; | ||
2424 | |||
2425 | if (surface == NULL) | ||
2426 | return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NULL_POINTER)); | ||
2427 | |||
2428 | crsurface = malloc (sizeof (cairo_glitz_surface_t)); | ||
2429 | if (crsurface == NULL) | ||
2430 | return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); | ||
2431 | |||
2432 | format = glitz_surface_get_format (surface); | ||
2433 | _cairo_surface_init (&crsurface->base, | ||
2434 | &cairo_glitz_surface_backend, | ||
2435 | NULL, /* device */ | ||
2436 | _glitz_format_to_content (format)); | ||
2437 | |||
2438 | glitz_surface_reference (surface); | ||
2439 | |||
2440 | crsurface->surface = surface; | ||
2441 | crsurface->format = format; | ||
2442 | |||
2443 | crsurface->has_clip = FALSE; | ||
2444 | crsurface->clip_boxes = NULL; | ||
2445 | crsurface->num_clip_boxes = 0; | ||
2446 | crsurface->clip_region = NULL; | ||
2447 | |||
2448 | return &crsurface->base; | ||
2449 | } | ||
2450 | slim_hidden_def (cairo_glitz_surface_create); | ||
diff --git a/src/cairo-glitz.h b/src/cairo-glitz.h deleted file mode 100644 index 08519dcbd..000000000 --- a/src/cairo-glitz.h +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | /* cairo - a vector graphics library with display and print output | ||
2 | * | ||
3 | * Copyright © 2002 University of Southern California | ||
4 | * | ||
5 | * This library is free software; you can redistribute it and/or | ||
6 | * modify it either under the terms of the GNU Lesser General Public | ||
7 | * License version 2.1 as published by the Free Software Foundation | ||
8 | * (the "LGPL") or, at your option, under the terms of the Mozilla | ||
9 | * Public License Version 1.1 (the "MPL"). If you do not alter this | ||
10 | * notice, a recipient may use your version of this file under either | ||
11 | * the MPL or the LGPL. | ||
12 | * | ||
13 | * You should have received a copy of the LGPL along with this library | ||
14 | * in the file COPYING-LGPL-2.1; if not, write to the Free Software | ||
15 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
16 | * You should have received a copy of the MPL along with this library | ||
17 | * in the file COPYING-MPL-1.1 | ||
18 | * | ||
19 | * The contents of this file are subject to the Mozilla Public License | ||
20 | * Version 1.1 (the "License"); you may not use this file except in | ||
21 | * compliance with the License. You may obtain a copy of the License at | ||
22 | * http://www.mozilla.org/MPL/ | ||
23 | * | ||
24 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY | ||
25 | * OF ANY KIND, either express or implied. See the LGPL or the MPL for | ||
26 | * the specific language governing rights and limitations. | ||
27 | * | ||
28 | * The Original Code is the cairo graphics library. | ||
29 | * | ||
30 | * The Initial Developer of the Original Code is University of Southern | ||
31 | * California. | ||
32 | * | ||
33 | * Contributor(s): | ||
34 | * Carl D. Worth <cworth@cworth.org> | ||
35 | */ | ||
36 | |||
37 | #ifndef CAIRO_GLITZ_H | ||
38 | #define CAIRO_GLITZ_H | ||
39 | |||
40 | #include "cairo.h" | ||
41 | |||
42 | #if CAIRO_HAS_GLITZ_SURFACE | ||
43 | |||
44 | #include <glitz.h> | ||
45 | |||
46 | CAIRO_BEGIN_DECLS | ||
47 | |||
48 | cairo_public cairo_surface_t * | ||
49 | cairo_glitz_surface_create (glitz_surface_t *surface); | ||
50 | |||
51 | CAIRO_END_DECLS | ||
52 | |||
53 | #else /* CAIRO_HAS_GLITZ_SURFACE */ | ||
54 | # error Cairo was not compiled with support for the glitz backend | ||
55 | #endif /* CAIRO_HAS_GLITZ_SURFACE */ | ||
56 | |||
57 | #endif /* CAIRO_GLITZ_H */ | ||
diff --git a/test/Makefile.am b/test/Makefile.am index ac515ebfe..6dd734f29 100644 --- a/test/Makefile.am +++ b/test/Makefile.am | |||
@@ -21,10 +21,6 @@ if CAIRO_HAS_QUARTZ_SURFACE | |||
21 | test_sources += $(quartz_surface_test_sources) | 21 | test_sources += $(quartz_surface_test_sources) |
22 | endif | 22 | endif |
23 | 23 | ||
24 | if CAIRO_HAS_GLITZ_SURFACE | ||
25 | test_sources += $(glitz_surface_test_sources) | ||
26 | endif | ||
27 | |||
28 | if CAIRO_HAS_PDF_SURFACE | 24 | if CAIRO_HAS_PDF_SURFACE |
29 | test_sources += $(pdf_surface_test_sources) | 25 | test_sources += $(pdf_surface_test_sources) |
30 | endif | 26 | endif |
@@ -524,10 +520,6 @@ REFERENCE_IMAGES = \ | |||
524 | ft-text-vertical-layout-type3.svg.ref.png \ | 520 | ft-text-vertical-layout-type3.svg.ref.png \ |
525 | ft-text-vertical-layout-type3.xlib.ref.png \ | 521 | ft-text-vertical-layout-type3.xlib.ref.png \ |
526 | get-group-target.ref.png \ | 522 | get-group-target.ref.png \ |
527 | glitz-surface-source.argb32.ref.png \ | ||
528 | glitz-surface-source.rgb24.ref.png \ | ||
529 | glitz-surface-source.ps2.ref.png \ | ||
530 | glitz-surface-source.ps3.ref.png \ | ||
531 | glyph-cache-pressure.ps2.ref.png \ | 523 | glyph-cache-pressure.ps2.ref.png \ |
532 | glyph-cache-pressure.ps3.ref.png \ | 524 | glyph-cache-pressure.ps3.ref.png \ |
533 | glyph-cache-pressure.quartz.ref.png \ | 525 | glyph-cache-pressure.quartz.ref.png \ |
diff --git a/test/Makefile.sources b/test/Makefile.sources index 824379eb0..caff4470b 100644 --- a/test/Makefile.sources +++ b/test/Makefile.sources | |||
@@ -266,8 +266,6 @@ ft_font_test_sources = \ | |||
266 | 266 | ||
267 | quartz_surface_test_sources = quartz-surface-source.c | 267 | quartz_surface_test_sources = quartz-surface-source.c |
268 | 268 | ||
269 | glitz_surface_test_sources = glitz-surface-source.c | ||
270 | |||
271 | pdf_surface_test_sources = \ | 269 | pdf_surface_test_sources = \ |
272 | pdf-features.c \ | 270 | pdf-features.c \ |
273 | pdf-mime-data.c \ | 271 | 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 018297208..000000000 --- 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 89094e486..000000000 --- a/test/glitz-surface-source.c +++ /dev/null | |||
@@ -1,293 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright © 2008 Chris Wilson | ||
3 | * | ||
4 | * Permission to use, copy, modify, distribute, and sell this software | ||
5 | * and its documentation for any purpose is hereby granted without | ||
6 | * fee, provided that the above copyright notice appear in all copies | ||
7 | * and that both that copyright notice and this permission notice | ||
8 | * appear in supporting documentation, and that the name of | ||
9 | * Chris Wilson not be used in advertising or publicity pertaining to | ||
10 | * distribution of the software without specific, written prior | ||
11 | * permission. Chris Wilson makes no representations about the | ||
12 | * suitability of this software for any purpose. It is provided "as | ||
13 | * is" without express or implied warranty. | ||
14 | * | ||
15 | * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS | ||
16 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
17 | * FITNESS, IN NO EVENT SHALL CHRIS WILSON BE LIABLE FOR ANY SPECIAL, | ||
18 | * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER | ||
19 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | ||
20 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
21 | * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
22 | * | ||
23 | * Author: Chris Wilson <chris@chris-wilson.co.uk> | ||
24 | */ | ||
25 | |||
26 | #include "cairo-test.h" | ||
27 | #include <cairo-glitz.h> | ||
28 | |||
29 | #define NAME "glitz" | ||
30 | #include "surface-source.c" | ||
31 | |||
32 | static cairo_user_data_key_t closure_key; | ||
33 | |||
34 | #if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE | ||
35 | #include <cairo-xlib.h> | ||
36 | #include <cairo-xlib-xrender.h> | ||
37 | #include <glitz-glx.h> | ||
38 | |||
39 | struct closure { | ||
40 | Display *dpy; | ||
41 | Window win; | ||
42 | }; | ||
43 | |||
44 | static void | ||
45 | cleanup (void *data) | ||
46 | { | ||
47 | struct closure *closure = data; | ||
48 | |||
49 | glitz_glx_fini (); | ||
50 | |||
51 | if (closure->win) | ||
52 | XDestroyWindow (closure->dpy, closure->win); | ||
53 | |||
54 | XCloseDisplay (closure->dpy); | ||
55 | |||
56 | free (closure); | ||
57 | } | ||
58 | |||
59 | static glitz_surface_t * | ||
60 | _glitz_glx_create_surface (glitz_format_name_t formatname, | ||
61 | int width, | ||
62 | int height, | ||
63 | struct closure *closure) | ||
64 | { | ||
65 | Display * dpy = closure->dpy; | ||
66 | int scr = DefaultScreen(dpy); | ||
67 | glitz_drawable_format_t templ; | ||
68 | glitz_drawable_format_t * dformat = NULL; | ||
69 | unsigned long mask; | ||
70 | glitz_drawable_t * drawable = NULL; | ||
71 | glitz_format_t * format; | ||
72 | glitz_surface_t * sr; | ||
73 | |||
74 | XSizeHints xsh; | ||
75 | XSetWindowAttributes xswa; | ||
76 | XVisualInfo * vinfo; | ||
77 | |||
78 | memset(&templ, 0, sizeof(templ)); | ||
79 | templ.color.red_size = 8; | ||
80 | templ.color.green_size = 8; | ||
81 | templ.color.blue_size = 8; | ||
82 | templ.color.alpha_size = 8; | ||
83 | templ.color.fourcc = GLITZ_FOURCC_RGB; | ||
84 | templ.samples = 1; | ||
85 | |||
86 | glitz_glx_init (NULL); | ||
87 | |||
88 | mask = GLITZ_FORMAT_SAMPLES_MASK | | ||
89 | GLITZ_FORMAT_FOURCC_MASK | | ||
90 | GLITZ_FORMAT_RED_SIZE_MASK | | ||
91 | GLITZ_FORMAT_GREEN_SIZE_MASK | | ||
92 | GLITZ_FORMAT_BLUE_SIZE_MASK; | ||
93 | if (formatname == GLITZ_STANDARD_ARGB32) | ||
94 | mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK; | ||
95 | |||
96 | /* Try for a pbuffer first */ | ||
97 | if (!getenv("CAIRO_TEST_FORCE_GLITZ_WINDOW")) | ||
98 | dformat = glitz_glx_find_pbuffer_format (dpy, scr, mask, &templ, 0); | ||
99 | |||
100 | if (dformat) { | ||
101 | closure->win = None; | ||
102 | |||
103 | drawable = glitz_glx_create_pbuffer_drawable (dpy, scr, dformat, | ||
104 | width, height); | ||
105 | if (!drawable) | ||
106 | goto FAIL; | ||
107 | } else { | ||
108 | /* No pbuffer, try window */ | ||
109 | dformat = glitz_glx_find_window_format (dpy, scr, mask, &templ, 0); | ||
110 | |||
111 | if (!dformat) | ||
112 | goto FAIL; | ||
113 | |||
114 | vinfo = glitz_glx_get_visual_info_from_format(dpy, | ||
115 | DefaultScreen(dpy), | ||
116 | dformat); | ||
117 | |||
118 | if (!vinfo) | ||
119 | goto FAIL; | ||
120 | |||
121 | xsh.flags = PSize; | ||
122 | xsh.x = 0; | ||
123 | xsh.y = 0; | ||
124 | xsh.width = width; | ||
125 | xsh.height = height; | ||
126 | |||
127 | xswa.colormap = XCreateColormap (dpy, RootWindow(dpy, scr), | ||
128 | vinfo->visual, AllocNone); | ||
129 | closure->win = XCreateWindow (dpy, RootWindow(dpy, scr), | ||
130 | xsh.x, xsh.y, xsh.width, xsh.height, | ||
131 | 0, vinfo->depth, CopyFromParent, | ||
132 | vinfo->visual, CWColormap, &xswa); | ||
133 | XFree (vinfo); | ||
134 | |||
135 | drawable = | ||
136 | glitz_glx_create_drawable_for_window (dpy, scr, | ||
137 | dformat, closure->win, | ||
138 | width, height); | ||
139 | |||
140 | if (!drawable) | ||
141 | goto DESTROY_WINDOW; | ||
142 | } | ||
143 | |||
144 | format = glitz_find_standard_format (drawable, formatname); | ||
145 | if (!format) | ||
146 | goto DESTROY_DRAWABLE; | ||
147 | |||
148 | sr = glitz_surface_create (drawable, format, width, height, 0, NULL); | ||
149 | if (!sr) | ||
150 | goto DESTROY_DRAWABLE; | ||
151 | |||
152 | if (closure->win == None || dformat->doublebuffer) { | ||
153 | glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_BACK_COLOR); | ||
154 | } else { | ||
155 | XMapWindow (closure->dpy, closure->win); | ||
156 | glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR); | ||
157 | } | ||
158 | |||
159 | glitz_drawable_destroy (drawable); | ||
160 | |||
161 | return sr; | ||
162 | DESTROY_DRAWABLE: | ||
163 | glitz_drawable_destroy (drawable); | ||
164 | DESTROY_WINDOW: | ||
165 | if (closure->win) | ||
166 | XDestroyWindow (dpy, closure->win); | ||
167 | FAIL: | ||
168 | return NULL; | ||
169 | } | ||
170 | |||
171 | static cairo_surface_t * | ||
172 | create_source_surface (int size) | ||
173 | { | ||
174 | struct closure *closure; | ||
175 | glitz_surface_t *glitz_surface; | ||
176 | cairo_surface_t *surface; | ||
177 | |||
178 | closure = xcalloc (1, sizeof (struct closure)); | ||
179 | |||
180 | closure->dpy = XOpenDisplay (getenv("CAIRO_TEST_GLITZ_DISPLAY")); | ||
181 | if (closure->dpy == NULL) { | ||
182 | free (closure); | ||
183 | return NULL; | ||
184 | } | ||
185 | |||
186 | glitz_surface = _glitz_glx_create_surface (GLITZ_STANDARD_ARGB32, | ||
187 | size, size, | ||
188 | closure); | ||
189 | if (glitz_surface == NULL) { | ||
190 | XCloseDisplay (closure->dpy); | ||
191 | free (closure); | ||
192 | return NULL; | ||
193 | } | ||
194 | |||
195 | surface = cairo_glitz_surface_create (glitz_surface); | ||
196 | |||
197 | cairo_surface_set_user_data (surface, &closure_key, closure, cleanup); | ||
198 | |||
199 | return surface; | ||
200 | } | ||
201 | |||
202 | #elif CAIRO_CAN_TEST_GLITZ_AGL_SURFACE | ||
203 | #include <glitz-agl.h> | ||
204 | |||
205 | static void | ||
206 | cleanup (void *data) | ||
207 | { | ||
208 | glitz_agl_fini (); | ||
209 | } | ||
210 | |||
211 | static glitz_surface_t * | ||
212 | _glitz_agl_create_surface (glitz_format_name_t formatname, | ||
213 | int width, | ||
214 | int height) | ||
215 | { | ||
216 | glitz_drawable_format_t * dformat = NULL; | ||
217 | glitz_drawable_t * drawable = NULL; | ||
218 | glitz_format_t * format; | ||
219 | glitz_format_t templ; | ||
220 | glitz_surface_t * sr; | ||
221 | int i; | ||
222 | int alpha_size; | ||
223 | |||
224 | glitz_agl_init (); | ||
225 | |||
226 | /* Find a reasonably lame window format and use it to create a pbuffer. */ | ||
227 | i = 0; | ||
228 | alpha_size = (formatname == GLITZ_STANDARD_ARGB32) ? 8 : 0; | ||
229 | while ((dformat = glitz_agl_find_window_format (0, 0, i)) != NULL | ||
230 | && !(dformat->doublebuffer == 0 | ||
231 | && dformat->stencil_size == 0 | ||
232 | && dformat->depth_size == 0 | ||
233 | && dformat->color.fourcc == GLITZ_FOURCC_RGB | ||
234 | && dformat->color.alpha_size == alpha_size)) | ||
235 | i++; | ||
236 | |||
237 | if (!dformat) | ||
238 | goto FAIL; | ||
239 | |||
240 | /* Try for a pbuffer first */ | ||
241 | drawable = glitz_agl_create_pbuffer_drawable (dformat, width, height); | ||
242 | if (!drawable) | ||
243 | goto FAIL; | ||
244 | |||
245 | templ.color = dformat->color; | ||
246 | format = glitz_find_format (drawable, | ||
247 | GLITZ_FORMAT_FOURCC_MASK | | ||
248 | GLITZ_FORMAT_RED_SIZE_MASK | | ||
249 | GLITZ_FORMAT_GREEN_SIZE_MASK | | ||
250 | GLITZ_FORMAT_BLUE_SIZE_MASK | | ||
251 | GLITZ_FORMAT_ALPHA_SIZE_MASK, | ||
252 | &templ, | ||
253 | 0); | ||
254 | if (!format) { | ||
255 | fprintf (stderr, "Error: couldn't find surface format\n"); | ||
256 | return NULL; | ||
257 | } | ||
258 | |||
259 | sr = glitz_surface_create (drawable, format, width, height, 0, NULL); | ||
260 | if (!sr) | ||
261 | goto DESTROY_DRAWABLE; | ||
262 | |||
263 | glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR); | ||
264 | glitz_drawable_destroy (drawable); | ||
265 | |||
266 | return sr; | ||
267 | DESTROY_DRAWABLE: | ||
268 | glitz_drawable_destroy (drawable); | ||
269 | FAIL: | ||
270 | return NULL; | ||
271 | } | ||
272 | |||
273 | static cairo_surface_t * | ||
274 | create_source_surface (int size) | ||
275 | { | ||
276 | glitz_surface_t *glitz_surface; | ||
277 | cairo_surface_t *surface; | ||
278 | |||
279 | glitz_surface = _glitz_agl_create_surface (GLITZ_STANDARD_ARGB32, | ||
280 | size, size); | ||
281 | |||
282 | surface = cairo_glitz_surface_create (glitz_surface); | ||
283 | cairo_surface_set_user_data (surface, &closure_key, NULL, cleanup); | ||
284 | return surface; | ||
285 | } | ||
286 | #endif | ||
287 | |||
288 | CAIRO_TEST (glitz_surface_source, | ||
289 | "Test using a Glitz surface as the source", | ||
290 | "source", /* keywords */ | ||
291 | NULL, /* requirements */ | ||
292 | SIZE, SIZE, | ||
293 | 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 10231581b..000000000 --- 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 10231581b..000000000 --- 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 0d68a82cc..000000000 --- a/test/glitz-surface-source.rgb24.ref.png +++ /dev/null | |||
Binary files differ | |||
diff --git a/util/cairo.modules b/util/cairo.modules index d41ea1b62..71a3922fd 100644 --- a/util/cairo.modules +++ b/util/cairo.modules | |||
@@ -6,20 +6,12 @@ | |||
6 | 6 | ||
7 | <repository type="git" name="git.freedesktop.org" href="git://anongit.freedesktop.org/git/"/> | 7 | <repository type="git" name="git.freedesktop.org" href="git://anongit.freedesktop.org/git/"/> |
8 | 8 | ||
9 | <autotools id="glitz"> | 9 | <autotools id="cairo" autogenargs="--enable-gl"> |
10 | <branch repo="git.freedesktop.org" module="glitz"/> | ||
11 | <dependencies> | ||
12 | <dep package="libGL"/> | ||
13 | </dependencies> | ||
14 | </autotools> | ||
15 | |||
16 | <autotools id="cairo" autogenargs="--enable-gl --enable-glitz"> | ||
17 | <branch repo="git.freedesktop.org" module="cairo"/> | 10 | <branch repo="git.freedesktop.org" module="cairo"/> |
18 | <dependencies> | 11 | <dependencies> |
19 | <dep package="pixman"/> | 12 | <dep package="pixman"/> |
20 | <dep package="fontconfig"/> | 13 | <dep package="fontconfig"/> |
21 | <dep package="libGL"/> | 14 | <dep package="libGL"/> |
22 | <dep package="glitz"/> | ||
23 | </dependencies> | 15 | </dependencies> |
24 | <after> | 16 | <after> |
25 | <dep package="libXrender"/> | 17 | <dep package="libXrender"/> |