[cairo-commit] 2 commits - NEWS util/cairo-script
Chris Wilson
ickle at kemper.freedesktop.org
Thu Feb 12 10:27:57 PST 2009
NEWS | 20 ++++++
util/cairo-script/csi-replay.c | 122 ++++++++++++++++++++++-------------------
2 files changed, 85 insertions(+), 57 deletions(-)
New commits:
commit 17ce8584e7142d13bd7a777c9570e5548a06a90c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Feb 12 18:26:57 2009 +0000
[NEWS] Add API changes.
Scan the public headers for obvious additions.
diff --git a/NEWS b/NEWS
index cd694d8..0b485df 100644
--- a/NEWS
+++ b/NEWS
@@ -10,9 +10,27 @@ API additions:
"image/jpeg" is understood by PDF,PS,SVG,win32-printing.
"image/png" is understood by SVG.
-New backend:
+ cairo_pdf_version_t
+ cairo_pdf_surface_restrict_to_version()
+ cairo_pdf_get_versions()
+ cairo_pdf_version_to_string()
+ Similar to restrict to version and level found in SVG and PS, these
+ limit the features used in the output to comply with the PDF specification
+ for that version.
+
+ CAIRO_STATUS_INVALID_SIZE
+ Indicates that the request surface size is not supported by the backend.
+ This generally indicates that the request is too large.
+
+ The built-in twin font is now called "@cairo:" and supports a limited set
+ of options like "@cairo:mono". Where are these specified?
+
+ cairo_in_fill() now uses flash semantics... OTOH, top and left are outside.
+
+New experimental backends:
Simple DirectMedia Layer
+ CairoScript
New utility:
commit 2df611a3810eb64c8ed22dfae5f3d3157eef7e6a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Feb 10 10:28:28 2009 +0000
[script] Expose a normal xlib window for replay
Provide a visible surface for replaying scripts against.
diff --git a/util/cairo-script/csi-replay.c b/util/cairo-script/csi-replay.c
index cfae74c..4e0b606 100644
--- a/util/cairo-script/csi-replay.c
+++ b/util/cairo-script/csi-replay.c
@@ -6,10 +6,8 @@
static const cairo_user_data_key_t _key;
-#if CAIRO_HAS_XLIB_XRENDER_SURFACE
+#if CAIRO_HAS_XLIB_SURFACE
#include <cairo-xlib.h>
-#include <cairo-xlib-xrender.h>
-
static Display *
_get_display (void)
{
@@ -28,16 +26,49 @@ _get_display (void)
}
static void
-_destroy_pixmap (void *closure)
+_destroy_window (void *closure)
{
- XFreePixmap (_get_display(), (Pixmap) closure);
+ XFlush (_get_display ());
+ XDestroyWindow (_get_display(), (Window) closure);
}
+static cairo_surface_t *
+_xlib_surface_create (void *closure,
+ cairo_content_t content,
+ double width, double height)
+{
+ Display *dpy;
+ XSetWindowAttributes attr;
+ Visual *visual;
+ int depth;
+ Window w;
+ cairo_surface_t *surface;
+
+ dpy = _get_display ();
+
+ visual = DefaultVisual (dpy, DefaultScreen (dpy));
+ depth = DefaultDepth (dpy, DefaultScreen (dpy));
+ attr.override_redirect = True;
+ w = XCreateWindow (dpy, DefaultRootWindow (dpy), 0, 0,
+ width <= 0 ? 1 : width,
+ height <= 0 ? 1 : height,
+ 0, depth,
+ InputOutput, visual, CWOverrideRedirect, &attr);
+ XMapWindow (dpy, w);
+
+ surface = cairo_xlib_surface_create (dpy, w, visual, width, height);
+ cairo_surface_set_user_data (surface, &_key, (void *) w, _destroy_window);
+
+ return surface;
+}
+
+#if CAIRO_HAS_XLIB_XRENDER_SURFACE
+#include <cairo-xlib-xrender.h>
+
static void
-_destroy_window (void *closure)
+_destroy_pixmap (void *closure)
{
- XFlush (_get_display ());
- XDestroyWindow (_get_display(), (Window) closure);
+ XFreePixmap (_get_display(), (Pixmap) closure);
}
static cairo_surface_t *
@@ -46,66 +77,40 @@ _xrender_surface_create (void *closure,
double width, double height)
{
Display *dpy;
+ Pixmap pixmap;
XRenderPictFormat *xrender_format;
cairo_surface_t *surface;
dpy = _get_display ();
content = CAIRO_CONTENT_COLOR_ALPHA;
- if (1) {
- Pixmap pixmap;
-
- switch (content) {
- case CAIRO_CONTENT_COLOR_ALPHA:
- xrender_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
- break;
- case CAIRO_CONTENT_COLOR:
- xrender_format = XRenderFindStandardFormat (dpy, PictStandardRGB24);
- break;
- case CAIRO_CONTENT_ALPHA:
- default:
- xrender_format = XRenderFindStandardFormat (dpy, PictStandardA8);
- }
-
- pixmap = XCreatePixmap (dpy, DefaultRootWindow (dpy),
- width, height, xrender_format->depth);
-
- surface = cairo_xlib_surface_create_with_xrender_format (dpy, pixmap,
- DefaultScreenOfDisplay (dpy),
- xrender_format,
- width, height);
- cairo_surface_set_user_data (surface, &_key,
- (void *) pixmap, _destroy_pixmap);
- } else {
- XSetWindowAttributes attr;
- Visual *visual;
- Window w;
-
- visual = DefaultVisual (dpy, DefaultScreen (dpy));
- xrender_format = XRenderFindVisualFormat (dpy, visual);
- if (xrender_format == NULL) {
- fprintf (stderr, "X server does not have the Render extension.\n");
- exit (1);
- }
- attr.override_redirect = True;
- w = XCreateWindow (dpy, DefaultRootWindow (dpy), 0, 0,
- width <= 0 ? 1 : width,
- height <= 0 ? 1 : height,
- 0, xrender_format->depth,
- InputOutput, visual, CWOverrideRedirect, &attr);
- XMapWindow (dpy, w);
-
- surface = cairo_xlib_surface_create_with_xrender_format (dpy, w,
- DefaultScreenOfDisplay (dpy),
- xrender_format,
- width, height);
- cairo_surface_set_user_data (surface, &_key, (void *) w, _destroy_window);
+ switch (content) {
+ case CAIRO_CONTENT_COLOR_ALPHA:
+ xrender_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
+ break;
+ case CAIRO_CONTENT_COLOR:
+ xrender_format = XRenderFindStandardFormat (dpy, PictStandardRGB24);
+ break;
+ case CAIRO_CONTENT_ALPHA:
+ default:
+ xrender_format = XRenderFindStandardFormat (dpy, PictStandardA8);
}
+ pixmap = XCreatePixmap (dpy, DefaultRootWindow (dpy),
+ width, height, xrender_format->depth);
+
+ surface = cairo_xlib_surface_create_with_xrender_format (dpy, pixmap,
+ DefaultScreenOfDisplay (dpy),
+ xrender_format,
+ width, height);
+ cairo_surface_set_user_data (surface, &_key,
+ (void *) pixmap, _destroy_pixmap);
+
return surface;
}
#endif
+#endif
#if CAIRO_HAS_PDF_SURFACE
#include <cairo-pdf.h>
@@ -155,6 +160,8 @@ main (int argc, char **argv)
cairo_script_interpreter_hooks_t hooks = {
#if CAIRO_HAS_XLIB_XRENDER_SURFACE
.surface_create = _xrender_surface_create
+#elif CAIRO_HAS_XLIB_SURFACE
+ .surface_create = _xlib_surface_create
#elif CAIRO_PDF_SURFACE
.surface_create = _pdf_surface_create
#elif CAIRO_PS_SURFACE
@@ -174,6 +181,9 @@ main (int argc, char **argv)
#if CAIRO_HAS_XLIB_XRENDER_SURFACE
{ "--xrender", _xrender_surface_create },
#endif
+#if CAIRO_HAS_XLIB_SURFACE
+ { "--xlib", _xlib_surface_create },
+#endif
#if CAIRO_HAS_PDF_SURFACE
{ "--pdf", _pdf_surface_create },
#endif
More information about the cairo-commit
mailing list