mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 09:58:12 +02:00
Merge commit 'anholt/gl'
Conflicts: boilerplate/Makefile.sources boilerplate/cairo-boilerplate.c build/configure.ac.features src/cairo.h util/cairo-script/Makefile.am
This commit is contained in:
commit
1ae5942a3a
20 changed files with 2408 additions and 8 deletions
|
|
@ -23,7 +23,7 @@ cairo_boilerplate_private = \
|
|||
# following lines, even if beos surface is not enabled. Disable it for now.
|
||||
#libcairoboilerplate_la_SOURCES += cairo-boilerplate-beos.cpp
|
||||
|
||||
cairo_boilerplate_directfb_sources = cairo-boilerplate-directfb.c
|
||||
cairo_boilerplate_gl_sources = cairo-boilerplate-gl.c
|
||||
cairo_boilerplate_glitz_sources = \
|
||||
cairo-boilerplate-glitz-agl.c \
|
||||
cairo-boilerplate-glitz-glx.c \
|
||||
|
|
|
|||
|
|
@ -139,6 +139,16 @@ enabled_cairo_boilerplate_private += $(cairo_boilerplate_png_private)
|
|||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_png_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_gl_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_gl_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_gl_private)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_gl_sources)
|
||||
ifeq ($(CAIRO_HAS_GL_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_gl_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_gl_private)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_gl_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_glitz_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_glitz_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_glitz_private)
|
||||
|
|
@ -169,6 +179,16 @@ enabled_cairo_boilerplate_private += $(cairo_boilerplate_vg_private)
|
|||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_vg_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_eagle_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_eagle_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_eagle_private)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_eagle_sources)
|
||||
ifeq ($(CAIRO_HAS_EAGLE_FUNCTIONS),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_eagle_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_eagle_private)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_eagle_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_egl_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_egl_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_egl_private)
|
||||
|
|
|
|||
162
boilerplate/cairo-boilerplate-gl.c
Normal file
162
boilerplate/cairo-boilerplate-gl.c
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson.
|
||||
*/
|
||||
|
||||
#include "cairo-boilerplate-private.h"
|
||||
|
||||
#include <cairo-gl.h>
|
||||
|
||||
typedef struct _gl_target_closure {
|
||||
Display *dpy;
|
||||
int screen;
|
||||
|
||||
GLXContext gl_ctx;
|
||||
cairo_gl_context_t *ctx;
|
||||
cairo_surface_t *surface;
|
||||
} gl_target_closure_t;
|
||||
|
||||
static void
|
||||
_cairo_boilerplate_gl_cleanup (void *closure)
|
||||
{
|
||||
gl_target_closure_t *gltc = closure;
|
||||
|
||||
cairo_gl_context_destroy (gltc->ctx);
|
||||
glXDestroyContext (gltc->dpy, gltc->gl_ctx);
|
||||
XCloseDisplay (gltc->dpy);
|
||||
free (gltc);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_boilerplate_gl_create_surface (const char *name,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height,
|
||||
double max_width,
|
||||
double max_height,
|
||||
cairo_boilerplate_mode_t mode,
|
||||
int id,
|
||||
void **closure)
|
||||
{
|
||||
int rgba_attribs[] = { GLX_RGBA,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
GLX_ALPHA_SIZE, 1,
|
||||
GLX_DOUBLEBUFFER,
|
||||
None };
|
||||
int rgb_attribs[] = { GLX_RGBA,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
GLX_DOUBLEBUFFER,
|
||||
None };
|
||||
XVisualInfo *visinfo;
|
||||
GLXContext gl_ctx;
|
||||
gl_target_closure_t *gltc;
|
||||
Display *dpy;
|
||||
|
||||
gltc = malloc (sizeof (gl_target_closure_t));
|
||||
*closure = gltc;
|
||||
|
||||
if (width == 0)
|
||||
width = 1;
|
||||
if (height == 0)
|
||||
height = 1;
|
||||
|
||||
dpy = XOpenDisplay (NULL);
|
||||
gltc->dpy = dpy;
|
||||
if (!gltc->dpy) {
|
||||
fprintf (stderr, "Failed to open display: %s\n", XDisplayName(0));
|
||||
free (gltc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (mode == CAIRO_BOILERPLATE_MODE_TEST)
|
||||
XSynchronize (gltc->dpy, 1);
|
||||
|
||||
if (content == CAIRO_CONTENT_COLOR)
|
||||
visinfo = glXChooseVisual (dpy, DefaultScreen (dpy), rgb_attribs);
|
||||
else
|
||||
visinfo = glXChooseVisual (dpy, DefaultScreen (dpy), rgba_attribs);
|
||||
|
||||
if (visinfo == NULL) {
|
||||
fprintf (stderr, "Failed to create RGB, double-buffered visual\n");
|
||||
XCloseDisplay (dpy);
|
||||
free (gltc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gl_ctx = glXCreateContext (dpy, visinfo, NULL, True);
|
||||
XFree (visinfo);
|
||||
|
||||
gltc->gl_ctx = gl_ctx;
|
||||
gltc->ctx = cairo_glx_context_create (dpy, gl_ctx);
|
||||
|
||||
gltc->surface = cairo_gl_surface_create (gltc->ctx, content,
|
||||
ceil (width), ceil (height));
|
||||
|
||||
if (gltc->surface == NULL || cairo_surface_status (gltc->surface))
|
||||
_cairo_boilerplate_gl_cleanup (gltc);
|
||||
|
||||
return gltc->surface;
|
||||
}
|
||||
|
||||
static void
|
||||
_cairo_boilerplate_gl_synchronize (void *closure)
|
||||
{
|
||||
gl_target_closure_t *gltc = closure;
|
||||
|
||||
cairo_gl_surface_glfinish (gltc->surface);
|
||||
}
|
||||
|
||||
static const cairo_boilerplate_target_t targets[] = {
|
||||
{
|
||||
"gl", "gl", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_GL, CAIRO_CONTENT_COLOR_ALPHA, 1,
|
||||
_cairo_boilerplate_gl_create_surface,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
_cairo_boilerplate_gl_cleanup,
|
||||
_cairo_boilerplate_gl_synchronize
|
||||
},
|
||||
{
|
||||
"gl", "gl", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_GL, CAIRO_CONTENT_COLOR, 1,
|
||||
_cairo_boilerplate_gl_create_surface,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
_cairo_boilerplate_gl_cleanup,
|
||||
_cairo_boilerplate_gl_synchronize
|
||||
},
|
||||
};
|
||||
CAIRO_BOILERPLATE (gl, targets)
|
||||
|
|
@ -12,9 +12,11 @@ CAIRO_HAS_WIN32_FONT=1
|
|||
CAIRO_HAS_OS2_SURFACE=0
|
||||
CAIRO_HAS_BEOS_SURFACE=0
|
||||
CAIRO_HAS_PNG_FUNCTIONS=1
|
||||
CAIRO_HAS_GL_SURFACE=0
|
||||
CAIRO_HAS_GLITZ_SURFACE=0
|
||||
CAIRO_HAS_DIRECTFB_SURFACE=0
|
||||
CAIRO_HAS_VG_SURFACE=0
|
||||
CAIRO_HAS_EAGLE_FUNCTIONS=0
|
||||
CAIRO_HAS_EGL_FUNCTIONS=0
|
||||
CAIRO_HAS_GLX_FUNCTIONS=0
|
||||
CAIRO_HAS_SCRIPT_SURFACE=0
|
||||
|
|
|
|||
|
|
@ -41,6 +41,9 @@ endif
|
|||
ifeq ($(CAIRO_HAS_PNG_FUNCTIONS),1)
|
||||
@echo "#define CAIRO_HAS_PNG_FUNCTIONS 1" >> src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_GL_SURFACE),1)
|
||||
@echo "#define CAIRO_HAS_GL_SURFACE 1" >> src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_GLITZ_SURFACE),1)
|
||||
@echo "#define CAIRO_HAS_GLITZ_SURFACE 1" >> src/cairo-features.h
|
||||
endif
|
||||
|
|
@ -50,6 +53,9 @@ endif
|
|||
ifeq ($(CAIRO_HAS_VG_SURFACE),1)
|
||||
@echo "#define CAIRO_HAS_VG_SURFACE 1" >> src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_EAGLE_FUNCTIONS),1)
|
||||
@echo "#define CAIRO_HAS_EAGLE_FUNCTIONS 1" >> src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_EGL_FUNCTIONS),1)
|
||||
@echo "#define CAIRO_HAS_EGL_FUNCTIONS 1" >> src/cairo-features.h
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -374,6 +374,7 @@ AC_DEFUN([CAIRO_REPORT],
|
|||
echo " PostScript: $use_ps"
|
||||
echo " PDF: $use_pdf"
|
||||
echo " SVG: $use_svg"
|
||||
echo " OpenGL: $use_gl"
|
||||
echo " glitz: $use_glitz"
|
||||
echo " BeOS: $use_beos"
|
||||
echo " DirectFB: $use_directfb"
|
||||
|
|
@ -387,9 +388,10 @@ AC_DEFUN([CAIRO_REPORT],
|
|||
echo " Quartz: $use_quartz_font"
|
||||
echo ""
|
||||
echo "The following functions:"
|
||||
echo " PNG functions: $use_png"
|
||||
echo " GLX functions: $use_glx"
|
||||
echo " EGL functions: $use_egl"
|
||||
echo " PNG functions: $use_png"
|
||||
echo " GLX functions: $use_glx"
|
||||
echo " EGL functions: $use_egl"
|
||||
echo " Eagle functions: $use_eagle"
|
||||
echo ""
|
||||
echo "And the following internal features:"
|
||||
echo " gtk-doc: $enable_gtk_doc"
|
||||
|
|
|
|||
29
configure.ac
29
configure.ac
|
|
@ -194,6 +194,24 @@ CAIRO_ENABLE_FUNCTIONS(png, PNG, yes, [
|
|||
fi
|
||||
])
|
||||
|
||||
dnl ===========================================================================
|
||||
CAIRO_ENABLE_SURFACE_BACKEND(gl, OpenGL, no, [
|
||||
gl_REQUIRES="gl"
|
||||
PKG_CHECK_MODULES(gl, $gl_REQUIRES, , [AC_MSG_RESULT(no)
|
||||
use_gl="no (requires gl.pc)"])
|
||||
|
||||
AC_CHECK_LIB(GLEW, glewInit, [
|
||||
AC_CHECK_HEADER(GL/glew.h, [], [
|
||||
use_gl="no (requires glew http://glew.sourceforge.net/)"
|
||||
])
|
||||
], [
|
||||
use_gl="no (requires glew http://glew.sourceforge.net/)"
|
||||
])
|
||||
gl_NONPKGCONFIG_LIBS="-lGLEW"
|
||||
need_glx_functions=yes
|
||||
need_eagle_functions=yes
|
||||
])
|
||||
|
||||
dnl ===========================================================================
|
||||
|
||||
GLITZ_MIN_VERSION=0.5.1
|
||||
|
|
@ -253,6 +271,17 @@ CAIRO_ENABLE_SURFACE_BACKEND(vg, OpenVG, no, [
|
|||
fi
|
||||
])
|
||||
|
||||
CAIRO_ENABLE_FUNCTIONS(eagle, eagle, auto, [
|
||||
if test "x$need_eagle_functions" = "xyes"; then
|
||||
eagle_REQUIRES="eagle"
|
||||
PKG_CHECK_MODULES(eagle, $eagle_REQUIRES, ,
|
||||
[AC_MSG_RESULT(no)
|
||||
use_eagle="no (requires eagle)"])
|
||||
else
|
||||
use_eagle="no (not required by any backend)"
|
||||
fi
|
||||
])
|
||||
|
||||
CAIRO_ENABLE_FUNCTIONS(egl, EGL, auto, [
|
||||
if test "x$need_egl_functions" = "xyes"; then
|
||||
AC_CHECK_HEADER(EGL/egl.h,, [use_egl="no (EGL headers not found)"])
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ target_is_measurable (const cairo_boilerplate_target_t *target)
|
|||
return TRUE;
|
||||
}
|
||||
case CAIRO_SURFACE_TYPE_XCB:
|
||||
case CAIRO_SURFACE_TYPE_GL:
|
||||
case CAIRO_SURFACE_TYPE_GLITZ:
|
||||
case CAIRO_SURFACE_TYPE_QUARTZ:
|
||||
case CAIRO_SURFACE_TYPE_WIN32:
|
||||
|
|
|
|||
|
|
@ -165,6 +165,10 @@ _cairo_font_subset_sources = \
|
|||
cairo_private += $(_cairo_font_subset_private)
|
||||
cairo_sources += $(_cairo_font_subset_sources)
|
||||
|
||||
cairo_glx_sources =
|
||||
cairo_egl_sources =
|
||||
cairo_eagle_sources =
|
||||
|
||||
_cairo_pdf_operators_private = cairo-pdf-operators-private.h
|
||||
_cairo_pdf_operators_sources = cairo-pdf-operators.c
|
||||
cairo_private += $(_cairo_pdf_operators_private)
|
||||
|
|
@ -249,6 +253,12 @@ cairo_os2_sources = cairo-os2-surface.c
|
|||
cairo_beos_headers = cairo-beos.h
|
||||
#cairo_beos_sources = cairo-beos-surface.cpp
|
||||
|
||||
cairo_gl_headers = cairo-gl.h
|
||||
cairo_gl_private = cairo-gl-private.h
|
||||
cairo_gl_sources = cairo-gl-surface.c
|
||||
cairo_glx_sources += cairo-glx-context.c
|
||||
cairo_eagle_sources += cairo-eagle-context.c
|
||||
|
||||
cairo_glitz_headers = cairo-glitz.h
|
||||
cairo_glitz_private = cairo-glitz-private.h
|
||||
cairo_glitz_sources = cairo-glitz-surface.c
|
||||
|
|
|
|||
|
|
@ -189,6 +189,20 @@ ifeq ($(CAIRO_HAS_PNG_FUNCTIONS),1)
|
|||
enabled_cairo_pkgconf += cairo-png.pc
|
||||
endif
|
||||
|
||||
unsupported_cairo_headers += $(cairo_gl_headers)
|
||||
all_cairo_headers += $(cairo_gl_headers)
|
||||
all_cairo_private += $(cairo_gl_private)
|
||||
all_cairo_sources += $(cairo_gl_sources)
|
||||
ifeq ($(CAIRO_HAS_GL_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_gl_headers)
|
||||
enabled_cairo_private += $(cairo_gl_private)
|
||||
enabled_cairo_sources += $(cairo_gl_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-gl.pc
|
||||
ifeq ($(CAIRO_HAS_GL_SURFACE),1)
|
||||
enabled_cairo_pkgconf += cairo-gl.pc
|
||||
endif
|
||||
|
||||
unsupported_cairo_headers += $(cairo_glitz_headers)
|
||||
all_cairo_headers += $(cairo_glitz_headers)
|
||||
all_cairo_private += $(cairo_glitz_private)
|
||||
|
|
@ -231,6 +245,20 @@ ifeq ($(CAIRO_HAS_VG_SURFACE),1)
|
|||
enabled_cairo_pkgconf += cairo-vg.pc
|
||||
endif
|
||||
|
||||
supported_cairo_headers += $(cairo_eagle_headers)
|
||||
all_cairo_headers += $(cairo_eagle_headers)
|
||||
all_cairo_private += $(cairo_eagle_private)
|
||||
all_cairo_sources += $(cairo_eagle_sources)
|
||||
ifeq ($(CAIRO_HAS_EAGLE_FUNCTIONS),1)
|
||||
enabled_cairo_headers += $(cairo_eagle_headers)
|
||||
enabled_cairo_private += $(cairo_eagle_private)
|
||||
enabled_cairo_sources += $(cairo_eagle_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-eagle.pc
|
||||
ifeq ($(CAIRO_HAS_EAGLE_FUNCTIONS),1)
|
||||
enabled_cairo_pkgconf += cairo-eagle.pc
|
||||
endif
|
||||
|
||||
supported_cairo_headers += $(cairo_egl_headers)
|
||||
all_cairo_headers += $(cairo_egl_headers)
|
||||
all_cairo_private += $(cairo_egl_private)
|
||||
|
|
|
|||
181
src/cairo-eagle-context.c
Normal file
181
src/cairo-eagle-context.c
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Eric Anholt
|
||||
* Copyright © 2009 Chris Wilson
|
||||
* Copyright © 2005 Red Hat, Inc
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Red Hat, Inc.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Carl Worth <cworth@cworth.org>
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-gl-private.h"
|
||||
|
||||
#include <i915_drm.h> /* XXX dummy surface for glewInit() */
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
typedef struct _cairo_eagle_context {
|
||||
cairo_gl_context_t base;
|
||||
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
} cairo_eagle_context_t;
|
||||
|
||||
typedef struct _cairo_eagle_surface {
|
||||
cairo_gl_surface_t base;
|
||||
|
||||
EGLSurface eagle;
|
||||
} cairo_eagle_surface_t;
|
||||
|
||||
static void
|
||||
_eagle_make_current (void *abstract_ctx,
|
||||
cairo_gl_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_eagle_context_t *ctx = abstract_ctx;
|
||||
cairo_eagle_surface_t *surface = (cairo_eagle_surface_t *) abstract_surface;
|
||||
|
||||
eagleMakeCurrent (ctx->display, surface->eagle, surface->eagle, ctx->context);
|
||||
}
|
||||
|
||||
static void
|
||||
_eagle_swap_buffers (void *abstract_ctx,
|
||||
cairo_gl_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_eagle_context_t *ctx = abstract_ctx;
|
||||
cairo_eagle_surface_t *surface = (cairo_eagle_surface_t *) abstract_surface;
|
||||
|
||||
eagleSwapBuffers (ctx->display, surface->eagle);
|
||||
}
|
||||
|
||||
static void
|
||||
_eagle_destroy (void *abstract_ctx)
|
||||
{
|
||||
}
|
||||
|
||||
static cairo_bool_t
|
||||
_eagle_init (EGLDisplay display, EGLContext context)
|
||||
{
|
||||
const EGLint config_attribs[] = {
|
||||
EGL_CONFIG_CAVEAT, EGL_NONE,
|
||||
EGL_NONE
|
||||
};
|
||||
const EGLint surface_attribs[] = {
|
||||
EGL_RENDER_BUFFER, EGL_BACK_BUFFER,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLConfig config;
|
||||
EGLSurface dummy;
|
||||
struct drm_i915_gem_create create;
|
||||
struct drm_gem_flink flink;
|
||||
int fd;
|
||||
GLenum err;
|
||||
|
||||
if (! eagleChooseConfig (display, config_attribs, &config, 1, NULL)) {
|
||||
fprintf (stderr, "Unable to choose config\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* XXX */
|
||||
fd = eagleGetDisplayFD (display);
|
||||
|
||||
create.size = 4096;
|
||||
if (ioctl (fd, DRM_IOCTL_I915_GEM_CREATE, &create) != 0) {
|
||||
fprintf (stderr, "gem create failed: %m\n");
|
||||
return FALSE;
|
||||
}
|
||||
flink.handle = create.handle;
|
||||
if (ioctl (fd, DRM_IOCTL_GEM_FLINK, &flink) != 0) {
|
||||
fprintf (stderr, "gem flink failed: %m\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
dummy = eagleCreateSurfaceForName (display, config, flink.name,
|
||||
1, 1, 4, surface_attribs);
|
||||
if (dummy == NULL) {
|
||||
fprintf (stderr, "Failed to create dummy surface\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
eagleMakeCurrent (display, dummy, dummy, context);
|
||||
}
|
||||
|
||||
cairo_gl_context_t *
|
||||
cairo_eagle_context_create (EGLDisplay display, EGLContext context)
|
||||
{
|
||||
cairo_eagle_context_t *ctx;
|
||||
cairo_status_t status;
|
||||
|
||||
if (! _eagle_init (display, context)) {
|
||||
return _cairo_gl_context_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
}
|
||||
|
||||
ctx = calloc (1, sizeof (cairo_eagle_context_t));
|
||||
if (ctx == NULL)
|
||||
return _cairo_gl_context_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
ctx->display = display;
|
||||
ctx->context = context;
|
||||
|
||||
ctx->base.make_current = _eagle_make_current;
|
||||
ctx->base.swap_buffers = _eagle_swap_buffers;
|
||||
ctx->base.destroy = _eagle_destroy;
|
||||
|
||||
status = _cairo_gl_context_init (&ctx->base);
|
||||
if (status) {
|
||||
free (ctx);
|
||||
return _cairo_gl_context_create_in_error (status);
|
||||
}
|
||||
|
||||
return &ctx->base;
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
cairo_gl_surface_create_for_eagle (cairo_gl_context_t *ctx,
|
||||
EGLSurface eagle,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
cairo_eagle_surface_t *surface;
|
||||
|
||||
if (ctx->status)
|
||||
return _cairo_surface_create_in_error (ctx->status);
|
||||
|
||||
surface = calloc (1, sizeof (cairo_eagle_surface_t));
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
_cairo_gl_surface_init (ctx, &surface->base,
|
||||
CAIRO_CONTENT_COLOR_ALPHA, width, height);
|
||||
surface->eagle = eagle;
|
||||
|
||||
return &surface->base.base;
|
||||
}
|
||||
88
src/cairo-gl-private.h
Normal file
88
src/cairo-gl-private.h
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Eric Anholt
|
||||
* Copyright © 2009 Chris Wilson
|
||||
* Copyright © 2005 Red Hat, Inc
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Red Hat, Inc.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Carl Worth <cworth@cworth.org>
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_GL_PRIVATE_H
|
||||
#define CAIRO_GL_PRIVATE_H
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include "cairo-gl.h"
|
||||
|
||||
#include <GL/gl.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glext.h>
|
||||
|
||||
typedef struct _cairo_gl_surface {
|
||||
cairo_surface_t base;
|
||||
|
||||
cairo_gl_context_t *ctx;
|
||||
int width, height;
|
||||
|
||||
GLuint tex; /* GL texture object containing our data. */
|
||||
GLuint fb; /* GL framebuffer object wrapping our data. */
|
||||
} cairo_gl_surface_t;
|
||||
|
||||
struct _cairo_gl_context {
|
||||
cairo_reference_count_t ref_count;
|
||||
cairo_status_t status;
|
||||
|
||||
cairo_mutex_t mutex; /* needed? */
|
||||
GLuint dummy_tex;
|
||||
|
||||
cairo_gl_surface_t *current_target;
|
||||
|
||||
void (*make_current)(void *ctx, cairo_gl_surface_t *surface);
|
||||
void (*swap_buffers)(void *ctx, cairo_gl_surface_t *surface);
|
||||
void (*destroy) (void *ctx);
|
||||
};
|
||||
|
||||
cairo_private cairo_gl_context_t *
|
||||
_cairo_gl_context_create_in_error (cairo_status_t status);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_gl_context_init (cairo_gl_context_t *ctx);
|
||||
|
||||
cairo_private void
|
||||
_cairo_gl_surface_init (cairo_gl_context_t *ctx,
|
||||
cairo_gl_surface_t *surface,
|
||||
cairo_content_t content,
|
||||
int width, int height);
|
||||
|
||||
#endif /* CAIRO_GL_PRIVATE_H */
|
||||
1569
src/cairo-gl-surface.c
Normal file
1569
src/cairo-gl-surface.c
Normal file
File diff suppressed because it is too large
Load diff
101
src/cairo-gl.h
Normal file
101
src/cairo-gl.h
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Eric Anholt
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric Anholt.
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_GL_H
|
||||
#define CAIRO_GL_H
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
#if CAIRO_HAS_GL_SURFACE
|
||||
|
||||
CAIRO_BEGIN_DECLS
|
||||
|
||||
typedef struct _cairo_gl_context cairo_gl_context_t;
|
||||
|
||||
cairo_public cairo_gl_context_t *
|
||||
cairo_gl_context_reference (cairo_gl_context_t *context);
|
||||
|
||||
cairo_public void
|
||||
cairo_gl_context_destroy (cairo_gl_context_t *context);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_gl_surface_create (cairo_gl_context_t *ctx,
|
||||
cairo_content_t content,
|
||||
int width, int height);
|
||||
|
||||
cairo_public void
|
||||
cairo_gl_surface_set_size (cairo_surface_t *surface, int width, int height);
|
||||
|
||||
cairo_public int
|
||||
cairo_gl_surface_get_width (cairo_surface_t *abstract_surface);
|
||||
|
||||
cairo_public int
|
||||
cairo_gl_surface_get_height (cairo_surface_t *abstract_surface);
|
||||
|
||||
cairo_public void
|
||||
cairo_gl_surface_swapbuffers (cairo_surface_t *surface);
|
||||
|
||||
cairo_public cairo_status_t
|
||||
cairo_gl_surface_glfinish (cairo_surface_t *surface);
|
||||
|
||||
#if CAIRO_HAS_GLX_FUNCTIONS
|
||||
#include <GL/glx.h>
|
||||
|
||||
cairo_public cairo_gl_context_t *
|
||||
cairo_glx_context_create (Display *dpy, GLXContext gl_ctx);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_gl_surface_create_for_window (cairo_gl_context_t *ctx,
|
||||
Window win,
|
||||
int width, int height);
|
||||
#endif
|
||||
|
||||
#if CAIRO_HAS_EAGLE_FUNCTIONS
|
||||
#include <eagle.h>
|
||||
|
||||
cairo_public cairo_gl_context_t *
|
||||
cairo_eagle_context_create (EGLDisplay display, EGLContext context);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_gl_surface_create_for_eagle (cairo_gl_context_t *ctx,
|
||||
EGLSurface surface,
|
||||
int width, int height);
|
||||
#endif
|
||||
|
||||
CAIRO_END_DECLS
|
||||
|
||||
#else /* CAIRO_HAS_GL_SURFACE */
|
||||
# error Cairo was not compiled with support for the GL backend
|
||||
#endif /* CAIRO_HAS_GL_SURFACE */
|
||||
|
||||
#endif /* CAIRO_GL_H */
|
||||
136
src/cairo-glx-context.c
Normal file
136
src/cairo-glx-context.c
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Eric Anholt
|
||||
* Copyright © 2009 Chris Wilson
|
||||
* Copyright © 2005 Red Hat, Inc
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Red Hat, Inc.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Carl Worth <cworth@cworth.org>
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-gl-private.h"
|
||||
|
||||
typedef struct _cairo_glx_context {
|
||||
cairo_gl_context_t base;
|
||||
|
||||
Display *display;
|
||||
GLXContext context;
|
||||
} cairo_glx_context_t;
|
||||
|
||||
typedef struct _cairo_glx_surface {
|
||||
cairo_gl_surface_t base;
|
||||
|
||||
Window win;
|
||||
} cairo_glx_surface_t;
|
||||
|
||||
static void
|
||||
_glx_make_current (void *abstract_ctx,
|
||||
cairo_gl_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_glx_context_t *ctx = abstract_ctx;
|
||||
cairo_glx_surface_t *surface = (cairo_glx_surface_t *) abstract_surface;
|
||||
|
||||
/* Set the window as the target of our context. */
|
||||
glXMakeCurrent (ctx->display, surface->win, ctx->context);
|
||||
}
|
||||
|
||||
static void
|
||||
_glx_swap_buffers (void *abstract_ctx,
|
||||
cairo_gl_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_glx_context_t *ctx = abstract_ctx;
|
||||
cairo_glx_surface_t *surface = (cairo_glx_surface_t *) abstract_surface;
|
||||
|
||||
glXSwapBuffers (ctx->display, surface->win);
|
||||
}
|
||||
|
||||
static void
|
||||
_glx_destroy (void *abstract_ctx)
|
||||
{
|
||||
}
|
||||
|
||||
cairo_gl_context_t *
|
||||
cairo_glx_context_create (Display *dpy, GLXContext gl_ctx)
|
||||
{
|
||||
cairo_glx_context_t *ctx;
|
||||
cairo_status_t status;
|
||||
|
||||
/* Make our GL context active. While we'll be setting the destination
|
||||
* drawable with each rendering operation, in order to set the context
|
||||
* we have to choose a drawable. The root window happens to be convenient
|
||||
* for this.
|
||||
*/
|
||||
if (! glXMakeCurrent (dpy, RootWindow (dpy, DefaultScreen (dpy)), gl_ctx))
|
||||
return _cairo_gl_context_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
ctx = calloc (1, sizeof (cairo_glx_context_t));
|
||||
if (ctx == NULL)
|
||||
return _cairo_gl_context_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
ctx->display = dpy;
|
||||
ctx->context = gl_ctx;
|
||||
|
||||
ctx->base.make_current = _glx_make_current;
|
||||
ctx->base.swap_buffers = _glx_swap_buffers;
|
||||
ctx->base.destroy = _glx_destroy;
|
||||
|
||||
status = _cairo_gl_context_init (&ctx->base);
|
||||
if (status) {
|
||||
free (ctx);
|
||||
return _cairo_gl_context_create_in_error (status);
|
||||
}
|
||||
|
||||
return &ctx->base;
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
cairo_gl_surface_create_for_window (cairo_gl_context_t *ctx,
|
||||
Window win,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
cairo_glx_surface_t *surface;
|
||||
|
||||
if (ctx->status)
|
||||
return _cairo_surface_create_in_error (ctx->status);
|
||||
|
||||
surface = calloc (1, sizeof (cairo_glx_surface_t));
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
_cairo_gl_surface_init (ctx, &surface->base,
|
||||
CAIRO_CONTENT_COLOR_ALPHA, width, height);
|
||||
surface->win = win;
|
||||
|
||||
return &surface->base.base;
|
||||
}
|
||||
|
|
@ -52,6 +52,10 @@ CAIRO_MUTEX_DECLARE (_cairo_ft_unscaled_font_map_mutex)
|
|||
CAIRO_MUTEX_DECLARE (_cairo_xlib_display_mutex)
|
||||
#endif
|
||||
|
||||
#if CAIRO_HAS_GL_SURFACE
|
||||
CAIRO_MUTEX_DECLARE (_cairo_gl_context_mutex)
|
||||
#endif
|
||||
|
||||
#if !defined (HAS_ATOMIC_OPS) || defined (ATOMIC_OP_NEEDS_MEMORY_BARRIER)
|
||||
CAIRO_MUTEX_DECLARE (_cairo_atomic_mutex)
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1943,6 +1943,7 @@ cairo_surface_status (cairo_surface_t *surface);
|
|||
* @CAIRO_SURFACE_TYPE_QT: The surface is of type Qt, since 1.10
|
||||
* @CAIRO_SURFACE_TYPE_META: The surface is a meta-type, since 1.10
|
||||
* @CAIRO_SURFACE_TYPE_VG: The surface is a OpenVG surface, since 1.10
|
||||
* @CAIRO_SURFACE_TYPE_GL: The surface is of type OpenGL, since 1.10
|
||||
*
|
||||
* #cairo_surface_type_t is used to describe the type of a given
|
||||
* surface. The surface types are also known as "backends" or "surface
|
||||
|
|
@ -1985,7 +1986,8 @@ typedef enum _cairo_surface_type {
|
|||
CAIRO_SURFACE_TYPE_SCRIPT,
|
||||
CAIRO_SURFACE_TYPE_QT,
|
||||
CAIRO_SURFACE_TYPE_META,
|
||||
CAIRO_SURFACE_TYPE_VG
|
||||
CAIRO_SURFACE_TYPE_VG,
|
||||
CAIRO_SURFACE_TYPE_GL,
|
||||
} cairo_surface_type_t;
|
||||
|
||||
cairo_public cairo_surface_type_t
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ draw (cairo_t *cr, int width, int height)
|
|||
case CAIRO_SURFACE_TYPE_WIN32:
|
||||
case CAIRO_SURFACE_TYPE_BEOS:
|
||||
case CAIRO_SURFACE_TYPE_DIRECTFB:
|
||||
case CAIRO_SURFACE_TYPE_GL:
|
||||
uses_clip_rects = TRUE;
|
||||
break;
|
||||
case CAIRO_SURFACE_TYPE_QUARTZ:
|
||||
|
|
|
|||
|
|
@ -22,13 +22,11 @@ libcairo_script_interpreter_la_LDFLAGS = -version-info $(CAIRO_LIBTOOL_VERSION_I
|
|||
libcairo_script_interpreter_la_LIBADD = $(top_builddir)/src/libcairo.la $(CAIRO_LIBS)
|
||||
|
||||
csi_replay_SOURCES = csi-replay.c
|
||||
csi_replay_CFLAGS = $(CAIRO_CFLAGS)
|
||||
csi_replay_LDADD = libcairo-script-interpreter.la $(top_builddir)/src/libcairo.la $(CAIRO_LIBS)
|
||||
|
||||
csi_exec_SOURCES = csi-exec.c
|
||||
csi_exec_LDADD = libcairo-script-interpreter.la $(top_builddir)/src/libcairo.la $(CAIRO_LIBS)
|
||||
|
||||
csi_bind_SOURCES = csi-bind.c
|
||||
csi_bind_LDADD = libcairo-script-interpreter.la $(top_builddir)/src/libcairo.la $(CAIRO_LIBS)
|
||||
|
||||
EXTRA_DIST = \
|
||||
COPYING
|
||||
|
|
|
|||
|
|
@ -113,6 +113,63 @@ _xrender_surface_create (void *closure,
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if CAIRO_HAS_GL_GLX_SURFACE
|
||||
#include <cairo-gl.h>
|
||||
static cairo_gl_context_t *
|
||||
_glx_get_context (cairo_content_t content)
|
||||
{
|
||||
static cairo_gl_context_t *context;
|
||||
|
||||
if (context == NULL) {
|
||||
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 gl_ctx;
|
||||
Display *dpy;
|
||||
|
||||
dpy = XOpenDisplay (NULL);
|
||||
if (dpy == NULL) {
|
||||
fprintf (stderr, "Failed to open display.\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
visinfo = glXChooseVisual (dpy, DefaultScreen (dpy), rgba_attribs);
|
||||
if (visinfo == NULL) {
|
||||
fprintf (stderr, "Failed to create RGBA, double-buffered visual\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
gl_ctx = glXCreateContext (dpy, visinfo, NULL, True);
|
||||
XFree (visinfo);
|
||||
|
||||
context = cairo_glx_context_create (dpy, gl_ctx);
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
_glx_surface_create (void *closure,
|
||||
cairo_content_t content,
|
||||
double width, double height)
|
||||
{
|
||||
if (width == 0)
|
||||
width = 1;
|
||||
if (height == 0)
|
||||
height = 1;
|
||||
|
||||
return cairo_gl_surface_create (_glx_get_context (content),
|
||||
content, width, height);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CAIRO_HAS_PDF_SURFACE
|
||||
#include <cairo-pdf.h>
|
||||
static cairo_surface_t *
|
||||
|
|
@ -182,6 +239,9 @@ main (int argc, char **argv)
|
|||
#if CAIRO_HAS_XLIB_XRENDER_SURFACE
|
||||
{ "--xrender", _xrender_surface_create },
|
||||
#endif
|
||||
#if CAIRO_HAS_GL_GLX_SURFACE
|
||||
{ "--glx", _glx_surface_create },
|
||||
#endif
|
||||
#if CAIRO_HAS_XLIB_SURFACE
|
||||
{ "--xlib", _xlib_surface_create },
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue