summaryrefslogtreecommitdiffstatsci
path: root/src/caskbench.cpp
diff options
context:
space:
mode:
authorBryce Harrington <b.harrington@samsung.com>2013-11-14 12:22:06 -0800
committerBryce Harrington <b.harrington@samsung.com>2013-11-14 12:30:58 -0800
commitcc9e2372e887273a608fdb54b885b58f2743bf46 (patch)
tree9ea53ade89e8122ad3d940f149b1c6c678ff6d86 /src/caskbench.cpp
parentd2d46205e5494e1c74548a837219b46348864683 (diff)
Split out glx surface creation to its own file
Diffstat (limited to 'src/caskbench.cpp')
-rw-r--r--src/caskbench.cpp84
1 files changed, 6 insertions, 78 deletions
diff --git a/src/caskbench.cpp b/src/caskbench.cpp
index a296db6..09fa519 100644
--- a/src/caskbench.cpp
+++ b/src/caskbench.cpp
@@ -40,6 +40,12 @@ typedef struct _caskbench_result {
int status;
} caskbench_result_t;
+// Surfaces
+cairo_surface_t *
+create_source_surface_glx (int width, int height);
+
+
+
void
write_image_file_cairo (const char *fname, caskbench_context_t *context)
{
@@ -194,84 +200,6 @@ randomize_color(cairo_t *cr)
cairo_set_source_rgba (cr, red, green, blue, alpha);
}
-struct closure {
- Display *dpy;
- GLXContext ctx;
-};
-
-static void
-cleanup (void *data)
-{
- struct closure *arg = (closure*)data;
-
- glXDestroyContext (arg->dpy, arg->ctx);
- XCloseDisplay (arg->dpy);
-
- free (arg);
-}
-
-static cairo_surface_t *
-create_source_surface_glx (int width, int height)
-{
- 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_device_t *device;
- 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 = (closure*) malloc (sizeof (struct closure));
- if (!arg) {
- XCloseDisplay (dpy);
- return NULL;
- }
- arg->dpy = dpy;
- arg->ctx = ctx;
- device = cairo_glx_device_create (dpy, ctx);
- if (cairo_device_set_user_data (device,
- (cairo_user_data_key_t *) cleanup,
- arg,
- cleanup))
- {
- cleanup (arg);
- return NULL;
- }
-
- surface = cairo_gl_surface_create (device,
- CAIRO_CONTENT_COLOR_ALPHA,
- width, height);
- cairo_device_destroy (device);
-
- return surface;
-}
-
int
main (int argc, char *argv[])
{