[PATCH] restore glitz-surface-source test
Paolo Bonzini
bonzini at gnu.org
Wed Nov 26 06:56:48 PST 2008
---
test/glitz-surface-source.c | 96 +++++++++++++++++++-
...s2.ref.png => glitz-surface-source.ps2.ref.png} | Bin 376 -> 376 bytes
...s2.ref.png => glitz-surface-source.ps3.ref.png} | Bin 376 -> 376 bytes
3 files changed, 94 insertions(+), 2 deletions(-)
copy test/{image-surface-source.ps2.ref.png => glitz-surface-source.ps2.ref.png} (100%)
copy test/{image-surface-source.ps2.ref.png => glitz-surface-source.ps3.ref.png} (100%)
diff --git a/test/glitz-surface-source.c b/test/glitz-surface-source.c
index 2dfa735..89094e4 100644
--- a/test/glitz-surface-source.c
+++ b/test/glitz-surface-source.c
@@ -25,8 +25,6 @@
#include "cairo-test.h"
#include <cairo-glitz.h>
-#include <cairo-xlib.h>
-#include <cairo-xlib-xrender.h>
#define NAME "glitz"
#include "surface-source.c"
@@ -34,6 +32,8 @@
static cairo_user_data_key_t closure_key;
#if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
+#include <cairo-xlib.h>
+#include <cairo-xlib-xrender.h>
#include <glitz-glx.h>
struct closure {
@@ -198,4 +198,96 @@ create_source_surface (int size)
return surface;
}
+
+#elif CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
+#include <glitz-agl.h>
+
+static void
+cleanup (void *data)
+{
+ glitz_agl_fini ();
+}
+
+static glitz_surface_t *
+_glitz_agl_create_surface (glitz_format_name_t formatname,
+ int width,
+ int height)
+{
+ glitz_drawable_format_t * dformat = NULL;
+ glitz_drawable_t * drawable = NULL;
+ glitz_format_t * format;
+ glitz_format_t templ;
+ glitz_surface_t * sr;
+ int i;
+ int alpha_size;
+
+ glitz_agl_init ();
+
+ /* Find a reasonably lame window format and use it to create a pbuffer. */
+ i = 0;
+ alpha_size = (formatname == GLITZ_STANDARD_ARGB32) ? 8 : 0;
+ while ((dformat = glitz_agl_find_window_format (0, 0, i)) != NULL
+ && !(dformat->doublebuffer == 0
+ && dformat->stencil_size == 0
+ && dformat->depth_size == 0
+ && dformat->color.fourcc == GLITZ_FOURCC_RGB
+ && dformat->color.alpha_size == alpha_size))
+ i++;
+
+ if (!dformat)
+ goto FAIL;
+
+ /* Try for a pbuffer first */
+ drawable = glitz_agl_create_pbuffer_drawable (dformat, width, height);
+ if (!drawable)
+ goto FAIL;
+
+ templ.color = dformat->color;
+ format = glitz_find_format (drawable,
+ GLITZ_FORMAT_FOURCC_MASK |
+ GLITZ_FORMAT_RED_SIZE_MASK |
+ GLITZ_FORMAT_GREEN_SIZE_MASK |
+ GLITZ_FORMAT_BLUE_SIZE_MASK |
+ GLITZ_FORMAT_ALPHA_SIZE_MASK,
+ &templ,
+ 0);
+ if (!format) {
+ fprintf (stderr, "Error: couldn't find surface format\n");
+ return NULL;
+ }
+
+ sr = glitz_surface_create (drawable, format, width, height, 0, NULL);
+ if (!sr)
+ goto DESTROY_DRAWABLE;
+
+ glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
+ glitz_drawable_destroy (drawable);
+
+ return sr;
+ DESTROY_DRAWABLE:
+ glitz_drawable_destroy (drawable);
+ FAIL:
+ return NULL;
+}
+
+static cairo_surface_t *
+create_source_surface (int size)
+{
+ glitz_surface_t *glitz_surface;
+ cairo_surface_t *surface;
+
+ glitz_surface = _glitz_agl_create_surface (GLITZ_STANDARD_ARGB32,
+ size, size);
+
+ surface = cairo_glitz_surface_create (glitz_surface);
+ cairo_surface_set_user_data (surface, &closure_key, NULL, cleanup);
+ return surface;
+}
#endif
+
+CAIRO_TEST (glitz_surface_source,
+ "Test using a Glitz surface as the source",
+ "source", /* keywords */
+ NULL, /* requirements */
+ SIZE, SIZE,
+ preamble, draw)
diff --git a/test/image-surface-source.ps2.ref.png b/test/glitz-surface-source.ps2.ref.png
similarity index 100%
copy from test/image-surface-source.ps2.ref.png
copy to test/glitz-surface-source.ps2.ref.png
diff --git a/test/image-surface-source.ps2.ref.png b/test/glitz-surface-source.ps3.ref.png
similarity index 100%
copy from test/image-surface-source.ps2.ref.png
copy to test/glitz-surface-source.ps3.ref.png
--
1.5.5
--------------090104020901040606000609--
More information about the cairo
mailing list