Add OpenVG backend.

Based on the work by Øyvind Kolås and Pierre Tardy -- many thanks to
Pierre for pushing this backend for inclusion as well as testing and
reviewing my initial patch. And many more thanks to pippin for writing the
backend in the first place!

Hacked and chopped by myself into a suitable basis for a backend. Quite a
few issues remain open, but would seem to be ready for testing on suitable
hardware.
This commit is contained in:
Chris Wilson 2009-07-15 16:37:25 +01:00
parent 34d5b862bc
commit 52fa8760ae
17 changed files with 2606 additions and 3 deletions

View file

@ -43,7 +43,7 @@ Amaury Jacquot <sxpert@esitcom.org> Documentation review, appplication testing
Adrian Johnson <ajohnson@redneon.com> PDF backend improvement
Michael Johnson <ahze@ahze.net> Bug fix for pre-C99 compilers
Jonathon Jongsma <jonathon.jongsma@gmail.com> Fix documentation typos
Øyvind Kolås <pippin@freedesktop.org> Bug fixes. Better default values.
Øyvind Kolås <pippin@freedesktop.org> OpenVG backend, Bug fixes. Better default values.
Martin Kretzschmar <martink@gnome.org> Arithmetic fix for 64-bit architectures
Mathieu Lacage <Mathieu.Lacage@sophia.inria.fr> several bug/typo fixes
Dominic Lachowicz <domlachowicz@gmail.com> PDF conformance fix, fix image surface to zero out contents
@ -89,6 +89,7 @@ Travis Spencer <tspencer@cs.pdx.edu> XCB backend fix
Bill Spitzak <spitzak@d2.com> Build fix to find Xrender.h without xrender.pc
Zhe Su <james.su@gmail.com> Add support for fontconfig's embeddedbitmap option
Owen Taylor <otaylor@redhat.com> Font rewrite, documentation, win32 backend
Pierre Tardy <tardyp@gmail.com> EGL support and testing, OpenVG backend
Karl Tomlinson <karlt+@karlt.net> Optimisation and obscure bug fixes (mozilla)
Alp Toker <alp@atoker.com> Fix several code/comment typos
Malcolm Tredinnick <malcolm@commsecure.com.au> Documentation fixes

3
NEWS
View file

@ -24,6 +24,9 @@ New experimental backends:
QT
OpenVG - The initial work was done by Øyvind Kolås, and made ready for
inclusion by Pierre Tardy.
Snapshot 1.9.2 (2009-06-12)
===========================

View file

@ -40,3 +40,4 @@ cairo_boilerplate_win32_sources = cairo-boilerplate-win32.c cairo-boilerplate-wi
cairo_boilerplate_xcb_sources = cairo-boilerplate-xcb.c
cairo_boilerplate_xlib_headers = cairo-boilerplate-xlib.h
cairo_boilerplate_xlib_sources = cairo-boilerplate-xlib.c
cairo_boilerplate_vg_sources = cairo-boilerplate-vg.c

View file

@ -159,6 +159,36 @@ enabled_cairo_boilerplate_private += $(cairo_boilerplate_directfb_private)
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_directfb_sources)
endif
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_vg_headers)
all_cairo_boilerplate_headers += $(cairo_boilerplate_vg_headers)
all_cairo_boilerplate_private += $(cairo_boilerplate_vg_private)
all_cairo_boilerplate_sources += $(cairo_boilerplate_vg_sources)
ifeq ($(CAIRO_HAS_VG_SURFACE),1)
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_vg_headers)
enabled_cairo_boilerplate_private += $(cairo_boilerplate_vg_private)
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_vg_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)
all_cairo_boilerplate_sources += $(cairo_boilerplate_egl_sources)
ifeq ($(CAIRO_HAS_EGL_FUNCTIONS),1)
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_egl_headers)
enabled_cairo_boilerplate_private += $(cairo_boilerplate_egl_private)
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_egl_sources)
endif
supported_cairo_boilerplate_headers += $(cairo_boilerplate_glx_headers)
all_cairo_boilerplate_headers += $(cairo_boilerplate_glx_headers)
all_cairo_boilerplate_private += $(cairo_boilerplate_glx_private)
all_cairo_boilerplate_sources += $(cairo_boilerplate_glx_sources)
ifeq ($(CAIRO_HAS_GLX_FUNCTIONS),1)
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_glx_headers)
enabled_cairo_boilerplate_private += $(cairo_boilerplate_glx_private)
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_glx_sources)
endif
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_script_headers)
all_cairo_boilerplate_headers += $(cairo_boilerplate_script_headers)
all_cairo_boilerplate_private += $(cairo_boilerplate_script_private)

View file

@ -0,0 +1,350 @@
/* 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-vg.h>
/* XXX Not sure how to handle library specific context initialization */
//#define USE_SHIVA
//#define USE_AMANITH
#if CAIRO_HAS_GLX_FUNCTIONS
#include <X11/Xlib.h>
#include <GL/glx.h>
typedef struct _vg_closure {
Display *dpy;
int screen;
Window win;
GLXContext ctx;
cairo_surface_t *surface;
} vg_closure_glx_t;
static void
_cairo_boilerplate_vg_cleanup_glx (void *closure)
{
vg_closure_glx_t *vgc = closure;
#ifdef USE_AMANITH
vgDestroyContextAM ();
#endif
#ifdef USE_SHIVA
vgDestroyContextSH ();
#endif
glXDestroyContext (vgc->dpy, vgc->ctx);
XDestroyWindow (vgc->dpy, vgc->win);
XCloseDisplay (vgc->dpy);
free (vgc);
}
static cairo_surface_t *
_cairo_boilerplate_vg_create_surface_glx (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 *vi;
Display *dpy;
Colormap cmap;
XSetWindowAttributes swa;
cairo_surface_t *surface;
cairo_vg_context_t *context;
vg_closure_glx_t *vgc;
vgc = malloc (sizeof (vg_closure_glx_t));
*closure = vgc;
if (width == 0)
width = 1;
if (height == 0)
height = 1;
dpy = XOpenDisplay (NULL);
vgc->dpy = dpy;
if (vgc->dpy == NULL) {
fprintf (stderr, "Failed to open display: %s\n", XDisplayName(0));
free (vgc);
return NULL;
}
if (content == CAIRO_CONTENT_COLOR)
vi = glXChooseVisual (dpy, DefaultScreen (dpy), rgb_attribs);
else
vi = glXChooseVisual (dpy, DefaultScreen (dpy), rgba_attribs);
if (vi == NULL) {
fprintf (stderr, "Failed to create RGB, double-buffered visual\n");
XCloseDisplay (dpy);
free (vgc);
return NULL;
}
vgc->ctx = glXCreateContext (dpy, vi, NULL, True);
cmap = XCreateColormap (dpy,
RootWindow (dpy, vi->screen),
vi->visual,
AllocNone);
swa.colormap = cmap;
swa.border_pixel = 0;
vgc->win = XCreateWindow (dpy, RootWindow (dpy, vi->screen),
-1, -1, 1, 1, 0,
vi->depth,
InputOutput,
vi->visual,
CWBorderPixel | CWColormap, &swa);
XFreeColormap (dpy, cmap);
XFree (vi);
XMapWindow (dpy, vgc->win);
/* we need an active context to initialise VG */
glXMakeContextCurrent (dpy, vgc->win, vgc->win, vgc->ctx);
#ifdef USE_AMANITH
vgInitContextAM (width, height, VG_FALSE, VG_TRUE);
#endif
#ifdef USE_SHIVA
vgCreateContextSH (width, height);
#endif
context = cairo_vg_context_create_for_glx (dpy, vgc->ctx);
vgc->surface = cairo_vg_surface_create (context, content, width, height);
cairo_vg_context_destroy (context);
surface = vgc->surface;
if (cairo_surface_status (surface))
_cairo_boilerplate_vg_cleanup_glx (vgc);
return surface;
}
#endif
#if CAIRO_HAS_EGL_FUNCTIONS
typedef struct _vg_closure_egl {
EGLDisplay *dpy;
EGLContext *ctx;
EGLSurface *dummy;
} vg_closure_egl_t;
static void
_cairo_boilerplate_vg_cleanup_egl (void *closure)
{
vg_closure_egl_t *vgc = closure;
#ifdef USE_AMANITH
vgDestroyContextAM ();
#endif
#ifdef USE_SHIVA
vgDestroyContextSH ();
#endif
eglDestroyContext (vgc->dpy, vgc->ctx);
eglDestroySurface (vgc->dpy, vgc->dummy);
eglDestroyDisplay (vgc->dpy);
free (vgc);
}
static cairo_surface_t *
_cairo_boilerplate_vg_create_surface_egl (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[] = {
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
ELG_RENDERABLE_TYPE, EGL_OPENVG_BIT,
None
};
int rgb_attribs[] = {
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_VG_ALPHA_FORMAT, VG_ALPHA_FORMAT_PRE,
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
ELG_RENDERABLE_TYPE, EGL_OPENVG_BIT,
None
};
int dummy_attribs[] = {
EGL_WIDTH, 8, EGL_HEIGHT, 8,
EGL_NONE
};
EGLDisplay *dpy;
int major, minor;
EGLConfig *config;
int num_configs;
EGLContext *egl_context;
cairo_vg_context_t *context;
cairo_vg_surface_t *surface;
vg_closure_egl_t *vgc;
dpy = eglGetDisplay (EGL_DEFAULT_DISPLAY);
if (! eglInitialize (dpy, &major, &minor))
return NULL;
eglBindAPI (EGL_OPENVG_API);
if (! eglChooseConfig (dpy,
attribs,
content == CAIRO_CONTENT_COLOR_ALPHA ?
rgba_attribs : rgb_attribs,
1, &num_configs) ||
num_configs != 1)
{
return NULL;
}
egl_context = eglCreateContext (dpy, config, NULL, NULL);
if (egl_context == NULL)
return NULL;
/* Create a dummy surface in order to enable a context to initialise VG */
dummy = eglCreatePbufferSurface (dpy, config, dummy_attribs);
if (dummy == NULL)
return NULL;
if (! eglMakeCurrent (dpy, dummy, dummy, egl_context))
return NULL;
#ifdef USE_AMANITH
vgInitContextAM (width, height, VG_FALSE, VG_TRUE);
#endif
#ifdef USE_SHIVA
vgCreateContextSH (width, height);
#endif
vgc = xmalloc (sizeof (vg_closure_egl_t));
vgc->dpy = dpy;
vgc->ctx = egl_context;
vgc->dummy = dummy;
*closure = vgc;
context = cairo_vg_context_create_for_egl (vgc->dpy, vgc->ctx);
vgc->surface = cairo_vg_surface_create (context, content, width, height);
cairo_vg_context_destroy (context);
surface = vgc->surface;
if (cairo_surface_status (surface))
_cairo_boilerplate_vg_cleanup_egl (vgc);
return surface;
}
#endif
static void
_cairo_boilerplate_vg_synchronize (void *closure)
{
vgFinish ();
}
static const cairo_boilerplate_target_t targets[] = {
#if CAIRO_HAS_GLX_FUNCTIONS
{
"vg-glx", "vg", NULL, NULL,
CAIRO_SURFACE_TYPE_VG, CAIRO_CONTENT_COLOR_ALPHA, 1,
_cairo_boilerplate_vg_create_surface_glx,
NULL, NULL,
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
_cairo_boilerplate_vg_cleanup_glx,
_cairo_boilerplate_vg_synchronize
},
{
"vg-glx", "vg", NULL, NULL,
CAIRO_SURFACE_TYPE_VG, CAIRO_CONTENT_COLOR, 1,
_cairo_boilerplate_vg_create_surface_glx,
NULL, NULL,
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
_cairo_boilerplate_vg_cleanup_glx,
_cairo_boilerplate_vg_synchronize
},
#endif
#if CAIRO_HAS_EGL_FUNCTIONS
{
"vg-egl", "vg", NULL, NULL,
CAIRO_SURFACE_TYPE_VG, CAIRO_CONTENT_COLOR_ALPHA, 1,
_cairo_boilerplate_vg_create_surface_egl,
NULL, NULL,
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
_cairo_boilerplate_vg_cleanup_egl,
_cairo_boilerplate_vg_synchronize
},
{
"vg-egl", "vg", NULL, NULL,
CAIRO_SURFACE_TYPE_VG, CAIRO_CONTENT_COLOR, 1,
_cairo_boilerplate_vg_create_surface_egl,
NULL, NULL,
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
_cairo_boilerplate_vg_cleanup_egl,
_cairo_boilerplate_vg_synchronize
},
#endif
};
CAIRO_BOILERPLATE (vg, targets)

View file

@ -14,6 +14,9 @@ CAIRO_HAS_BEOS_SURFACE=0
CAIRO_HAS_PNG_FUNCTIONS=1
CAIRO_HAS_GLITZ_SURFACE=0
CAIRO_HAS_DIRECTFB_SURFACE=0
CAIRO_HAS_VG_SURFACE=0
CAIRO_HAS_EGL_FUNCTIONS=0
CAIRO_HAS_GLX_FUNCTIONS=0
CAIRO_HAS_SCRIPT_SURFACE=0
CAIRO_HAS_FT_FONT=0
CAIRO_HAS_FC_FONT=0

View file

@ -47,6 +47,15 @@ endif
ifeq ($(CAIRO_HAS_DIRECTFB_SURFACE),1)
@echo "#define CAIRO_HAS_DIRECTFB_SURFACE 1" >> src/cairo-features.h
endif
ifeq ($(CAIRO_HAS_VG_SURFACE),1)
@echo "#define CAIRO_HAS_VG_SURFACE 1" >> src/cairo-features.h
endif
ifeq ($(CAIRO_HAS_EGL_FUNCTIONS),1)
@echo "#define CAIRO_HAS_EGL_FUNCTIONS 1" >> src/cairo-features.h
endif
ifeq ($(CAIRO_HAS_GLX_FUNCTIONS),1)
@echo "#define CAIRO_HAS_GLX_FUNCTIONS 1" >> src/cairo-features.h
endif
ifeq ($(CAIRO_HAS_SCRIPT_SURFACE),1)
@echo "#define CAIRO_HAS_SCRIPT_SURFACE 1" >> src/cairo-features.h
endif

View file

@ -377,6 +377,7 @@ AC_DEFUN([CAIRO_REPORT],
echo " glitz: $use_glitz"
echo " BeOS: $use_beos"
echo " DirectFB: $use_directfb"
echo " OpenVG: $use_vg"
echo ""
echo "The following font backends:"
echo " User: yes (always builtin)"
@ -387,6 +388,8 @@ AC_DEFUN([CAIRO_REPORT],
echo ""
echo "The following functions:"
echo " PNG functions: $use_png"
echo " GLX functions: $use_glx"
echo " EGL functions: $use_egl"
echo ""
echo "And the following internal features:"
echo " gtk-doc: $enable_gtk_doc"

View file

@ -242,6 +242,49 @@ CAIRO_ENABLE_SURFACE_BACKEND(directfb, directfb, no, [
dnl ===========================================================================
CAIRO_ENABLE_SURFACE_BACKEND(vg, OpenVG, no, [
dnl There is no pkgconfig for OpenVG; lets do a header check
AC_CHECK_HEADER(VG/openvg.h,, [use_vg="no (OpenVG headers not found)"])
if test "x$use_vg" = "xyes"; then
vg_NONPKGCONFIG_CFLAGS=
vg_NONPKGCONFIG_LIBS="-lOpenVG"
need_egl_functions=yes
need_glx_functions=yes
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)"])
if test "x$use_egl" = "xyes"; then
egl_NONPKGCONFIG_CFLAGS=
egl_NONPKGCONFIG_LIBS=
for lib in EGL egl13 egl12 egl11; do
if test -z "$egl_NONPKGCONFIG_LIBS"; then
AC_CHECK_LIB($lib, eglGetError, egl_NONPKGCONFIG_LIBS="-l$lib")
fi
done
if test -z "$egl_NONPKGCONFIG_LIBS"; then
use_egl="no (EGL library not found)"
fi
fi
else
use_egl="no (not required by any backend)"
fi
])
CAIRO_ENABLE_FUNCTIONS(glx, GLX, auto, [
if test "x$need_glx_functions" = "xyes"; then
AC_CHECK_HEADER(GL/glx.h,, [use_glx="no (GLX headers not found)"])
glx_NONPKGCONFIG_CFLAGS=
glx_NONPKGCONFIG_LIBS="-lGL"
else
use_glx="no (not required by any backend)"
fi
])
dnl ===========================================================================
any2ppm_cs=no
CAIRO_ENABLE_SURFACE_BACKEND(script, script, no, [
any2ppm_cs=yes

View file

@ -258,3 +258,6 @@ cairo_directfb_sources = cairo-directfb-surface.c
cairo_script_headers = cairo-script.h
cairo_script_sources = cairo-script-surface.c
cairo_vg_headers = cairo-vg.h
cairo_vg_sources = cairo-vg-surface.c

View file

@ -217,6 +217,48 @@ ifeq ($(CAIRO_HAS_DIRECTFB_SURFACE),1)
enabled_cairo_pkgconf += cairo-directfb.pc
endif
unsupported_cairo_headers += $(cairo_vg_headers)
all_cairo_headers += $(cairo_vg_headers)
all_cairo_private += $(cairo_vg_private)
all_cairo_sources += $(cairo_vg_sources)
ifeq ($(CAIRO_HAS_VG_SURFACE),1)
enabled_cairo_headers += $(cairo_vg_headers)
enabled_cairo_private += $(cairo_vg_private)
enabled_cairo_sources += $(cairo_vg_sources)
endif
all_cairo_pkgconf += cairo-vg.pc
ifeq ($(CAIRO_HAS_VG_SURFACE),1)
enabled_cairo_pkgconf += cairo-vg.pc
endif
supported_cairo_headers += $(cairo_egl_headers)
all_cairo_headers += $(cairo_egl_headers)
all_cairo_private += $(cairo_egl_private)
all_cairo_sources += $(cairo_egl_sources)
ifeq ($(CAIRO_HAS_EGL_FUNCTIONS),1)
enabled_cairo_headers += $(cairo_egl_headers)
enabled_cairo_private += $(cairo_egl_private)
enabled_cairo_sources += $(cairo_egl_sources)
endif
all_cairo_pkgconf += cairo-egl.pc
ifeq ($(CAIRO_HAS_EGL_FUNCTIONS),1)
enabled_cairo_pkgconf += cairo-egl.pc
endif
supported_cairo_headers += $(cairo_glx_headers)
all_cairo_headers += $(cairo_glx_headers)
all_cairo_private += $(cairo_glx_private)
all_cairo_sources += $(cairo_glx_sources)
ifeq ($(CAIRO_HAS_GLX_FUNCTIONS),1)
enabled_cairo_headers += $(cairo_glx_headers)
enabled_cairo_private += $(cairo_glx_private)
enabled_cairo_sources += $(cairo_glx_sources)
endif
all_cairo_pkgconf += cairo-glx.pc
ifeq ($(CAIRO_HAS_GLX_FUNCTIONS),1)
enabled_cairo_pkgconf += cairo-glx.pc
endif
unsupported_cairo_headers += $(cairo_script_headers)
all_cairo_headers += $(cairo_script_headers)
all_cairo_private += $(cairo_script_private)

1938
src/cairo-vg-surface.c Normal file

File diff suppressed because it is too large Load diff

103
src/cairo-vg.h Normal file
View file

@ -0,0 +1,103 @@
/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
/* cairo - a vector graphics library with display and print output
*
* Copyright © 2007 * Mozilla Corporation
* 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 Mozilla Corporation.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@mozilla.com>
* Chris Wilson <chris@chris-wilson.co.uk>
*/
#ifndef CAIRO_VG_H
#define CAIRO_VG_H
#include "cairo.h"
#if CAIRO_HAS_VG_SURFACE
#include <VG/openvg.h>
CAIRO_BEGIN_DECLS
typedef struct _cairo_vg_context cairo_vg_context_t;
#if CAIRO_HAS_GLX_FUNCTIONS
typedef struct __GLXcontextRec *GLXContext;
typedef struct _XDisplay Display;
cairo_public cairo_vg_context_t *
cairo_vg_context_create_for_glx (Display *dpy,
GLXContext ctx);
#endif
#if CAIRO_HAS_EGL_FUNCTIONS
#include <EGL/egl.h>
cairo_public cairo_vg_context_t *
cairo_vg_context_create_for_egl (EGLDisplay egl_display,
EGLContext egl_context);
#endif
cairo_public cairo_status_t
cairo_vg_context_status (cairo_vg_context_t *context);
cairo_public void
cairo_vg_context_destroy (cairo_vg_context_t *context);
cairo_public cairo_surface_t *
cairo_vg_surface_create (cairo_vg_context_t *context,
cairo_content_t content, int width, int height);
cairo_public cairo_surface_t *
cairo_vg_surface_create_for_image (cairo_vg_context_t *context,
VGImage image,
VGImageFormat format,
int width, int height);
cairo_public VGImage
cairo_vg_surface_get_image (cairo_surface_t *abstract_surface);
cairo_public VGImageFormat
cairo_vg_surface_get_format (cairo_surface_t *abstract_surface);
cairo_public int
cairo_vg_surface_get_height (cairo_surface_t *abstract_surface);
cairo_public int
cairo_vg_surface_get_width (cairo_surface_t *abstract_surface);
CAIRO_END_DECLS
#else /* CAIRO_HAS_VG_SURFACE*/
# error Cairo was not compiled with support for the OpenVG backend
#endif /* CAIRO_HAS_VG_SURFACE*/
#endif /* CAIRO_VG_H */

View file

@ -1942,6 +1942,7 @@ cairo_surface_status (cairo_surface_t *surface);
* @CAIRO_SURFACE_TYPE_SCRIPT: The surface is of type script, since 1.10
* @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_t is used to describe the type of a given
* surface. The surface types are also known as "backends" or "surface
@ -1983,7 +1984,8 @@ typedef enum _cairo_surface_type {
CAIRO_SURFACE_TYPE_QUARTZ_IMAGE,
CAIRO_SURFACE_TYPE_SCRIPT,
CAIRO_SURFACE_TYPE_QT,
CAIRO_SURFACE_TYPE_META
CAIRO_SURFACE_TYPE_META,
CAIRO_SURFACE_TYPE_VG
} cairo_surface_type_t;
cairo_public cairo_surface_type_t

View file

@ -855,7 +855,8 @@ REPEAT:
if (cairo_surface_status (surface)) {
MF (MEMFAULT_PRINT_FAULTS ());
cairo_test_log (ctx, "Error: Created an error surface\n");
cairo_test_log (ctx, "Error: Created an error surface: %s\n",
cairo_status_to_string (cairo_surface_status (surface)));
ret = CAIRO_TEST_FAILURE;
goto UNWIND_STRINGS;
}

View file

@ -141,6 +141,7 @@ draw (cairo_t *cr, int width, int height)
case CAIRO_SURFACE_TYPE_SCRIPT:
case CAIRO_SURFACE_TYPE_QT:
case CAIRO_SURFACE_TYPE_META:
case CAIRO_SURFACE_TYPE_VG:
default:
uses_clip_rects = FALSE;
break;

View file

@ -4357,3 +4357,73 @@ cairo_meta_surface_replay (cairo_surface_t *meta, cairo_surface_t *target)
return ret;
}
#if CAIRO_HAS_VG_SURFACE
#include <cairo-vg.h>
cairo_surface_t *
cairo_vg_surface_create (cairo_vg_context_t *context,
cairo_content_t content,
int width, int height)
{
cairo_surface_t *ret;
long surface_id;
ret = DLCALL (cairo_vg_surface_create, context, content, width, height);
surface_id = _create_surface_id (ret);
_emit_line_info ();
if (_write_lock ()) {
_trace_printf ("dict\n"
" /type /vg set\n"
" /content //%s set\n"
" /width %d set\n"
" /height %d set\n"
" surface dup /s%ld exch def\n",
_content_to_string (content),
width, height,
surface_id);
_surface_object_set_size (ret, width, height);
_get_object (SURFACE, ret)->defined = true;
_push_operand (SURFACE, ret);
_write_unlock ();
}
return ret;
}
cairo_surface_t *
cairo_vg_surface_create_for_image (cairo_vg_context_t *context,
VGImage image,
VGImageFormat format,
int width, int height)
{
cairo_surface_t *ret;
long surface_id;
ret = DLCALL (cairo_vg_surface_create_for_image,
context, image, format, width, height);
surface_id = _create_surface_id (ret);
_emit_line_info ();
if (_write_lock ()) {
cairo_content_t content;
content = DLCALL (cairo_surface_get_content, ret);
_trace_printf ("dict\n"
" /type /vg set\n"
" /content //%s set\n"
" /width %d set\n"
" /height %d set\n"
" surface dup /s%ld exch def\n",
_content_to_string (content),
width, height,
surface_id);
_surface_object_set_size (ret, width, height);
_get_object (SURFACE, ret)->defined = true;
_push_operand (SURFACE, ret);
_write_unlock ();
}
return ret;
}
#endif