[cairo-commit] 2 commits - test/clip-contexts.c test/gl-surface-source.argb32.ref.png test/gl-surface-source.c test/gl-surface-source.image16.ref.png test/gl-surface-source.rgb24.ref.png test/Makefile.am test/Makefile.sources
Chris Wilson
ickle at kemper.freedesktop.org
Thu May 6 06:39:28 PDT 2010
test/Makefile.am | 7 ++
test/Makefile.sources | 3
test/clip-contexts.c | 2
test/gl-surface-source.argb32.ref.png |binary
test/gl-surface-source.c | 115 +++++++++++++++++++++++++++++++++
test/gl-surface-source.image16.ref.png |binary
test/gl-surface-source.rgb24.ref.png |binary
7 files changed, 127 insertions(+)
New commits:
commit 2e3acee410ff127d4557ca8191625338cd225313
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu May 6 14:38:55 2010 +0100
test: Add gl-surface-source
Exercise using GL sources.
diff --git a/test/Makefile.am b/test/Makefile.am
index 72023a0..0b9eb7e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -16,6 +16,10 @@ test_sources += $(ft_font_test_sources)
endif
endif
+if CAIRO_HAS_GL_SURFACE
+test_sources += $(gl_surface_test_sources)
+endif
+
# Need to add quartz-surface-source
if CAIRO_HAS_QUARTZ_SURFACE
test_sources += $(quartz_surface_test_sources)
@@ -591,6 +595,9 @@ REFERENCE_IMAGES = \
ft-text-vertical-layout-type3.svg.ref.png \
ft-text-vertical-layout-type3.xlib.ref.png \
get-group-target.ref.png \
+ gl-surface-source.rgb24.ref.png \
+ gl-surface-source.argb32.ref.png \
+ gl-surface-source.image16.ref.png \
glyph-cache-pressure.image16.ref.png \
glyph-cache-pressure.ps2.ref.png \
glyph-cache-pressure.ps3.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 01043c6..1464516 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -286,6 +286,9 @@ ft_font_test_sources = \
ft-text-vertical-layout-type3.c \
ft-text-antialias-none.c
+gl_surface_test_sources = \
+ gl-surface-source.c
+
quartz_surface_test_sources = quartz-surface-source.c
pdf_surface_test_sources = \
diff --git a/test/gl-surface-source.argb32.ref.png b/test/gl-surface-source.argb32.ref.png
new file mode 100644
index 0000000..0182972
Binary files /dev/null and b/test/gl-surface-source.argb32.ref.png differ
diff --git a/test/gl-surface-source.c b/test/gl-surface-source.c
new file mode 100644
index 0000000..60f8591
--- /dev/null
+++ b/test/gl-surface-source.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright © 2008 Chris Wilson
+ * Copyright © 2010 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Chris Wilson not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Chris Wilson makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL CHRIS WILSON BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Chris Wilson <chris at chris-wilson.co.uk>
+ */
+
+#include "cairo-test.h"
+#include <cairo-gl.h>
+
+#include "surface-source.c"
+
+struct closure {
+ Display *dpy;
+ GLXContext ctx;
+
+ cairo_device_t *device;
+};
+
+static void
+cleanup (void *data)
+{
+ struct closure *arg = data;
+
+ cairo_device_finish (arg->device);
+ cairo_device_destroy (arg->device);
+
+ glXDestroyContext (arg->dpy, arg->ctx);
+ XCloseDisplay (arg->dpy);
+
+ free (arg);
+}
+
+static cairo_surface_t *
+create_source_surface (int size)
+{
+ int rgba_attribs[] = {
+ GLX_RGBA,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ GLX_ALPHA_SIZE, 1,
+ GLX_DOUBLEBUFFER,
+ None
+ };
+ XVisualInfo *visinfo;
+ GLXContext ctx;
+ struct closure *arg;
+ cairo_surface_t *surface;
+ Display *dpy;
+
+ dpy = XOpenDisplay (NULL);
+ if (dpy == NULL)
+ return NULL;
+
+ visinfo = glXChooseVisual (dpy, DefaultScreen (dpy), rgba_attribs);
+ if (visinfo == NULL) {
+ XCloseDisplay (dpy);
+ return NULL;
+ }
+
+ ctx = glXCreateContext (dpy, visinfo, NULL, True);
+ XFree (visinfo);
+
+ if (ctx == NULL) {
+ XCloseDisplay (dpy);
+ return NULL;
+ }
+
+ arg = xmalloc (sizeof (struct closure));
+ arg->dpy = dpy;
+ arg->ctx = ctx;
+ arg->device = cairo_glx_device_create (dpy, ctx);
+ surface = cairo_gl_surface_create (arg->device,
+ CAIRO_CONTENT_COLOR_ALPHA,
+ size, size);
+
+ if (cairo_surface_set_user_data (surface,
+ (cairo_user_data_key_t *) create_source_surface,
+ arg,
+ cleanup))
+ {
+ cairo_surface_destroy (surface);
+ cleanup (arg);
+ return NULL;
+ }
+
+ return surface;
+}
+
+CAIRO_TEST (gl_surface_source,
+ "Test using a GL surface as the source",
+ "source", /* keywords */
+ NULL, /* requirements */
+ SIZE, SIZE,
+ preamble, draw)
diff --git a/test/gl-surface-source.image16.ref.png b/test/gl-surface-source.image16.ref.png
new file mode 100644
index 0000000..2a7460e
Binary files /dev/null and b/test/gl-surface-source.image16.ref.png differ
diff --git a/test/gl-surface-source.rgb24.ref.png b/test/gl-surface-source.rgb24.ref.png
new file mode 100644
index 0000000..0d68a82
Binary files /dev/null and b/test/gl-surface-source.rgb24.ref.png differ
commit 75d8550891b8b2c09200aaaa812c6c9332161cd7
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu May 6 13:50:27 2010 +0100
test/clip-contexts: Free secondary context
diff --git a/test/clip-contexts.c b/test/clip-contexts.c
index 8f767e1..39d2004 100644
--- a/test/clip-contexts.c
+++ b/test/clip-contexts.c
@@ -62,6 +62,8 @@ draw (cairo_t *cr, int width, int height)
cairo_set_source_rgba (cr, 0, 0, 1, .5);
cairo_paint (cr);
+ cairo_destroy (cr2);
+
return CAIRO_TEST_SUCCESS;
}
More information about the cairo-commit
mailing list