[cairo-commit] 4 commits - configure.ac src/cairo-xlib-surface.c test/any2ppm.c test/cairo-test.c test/.gitignore test/huge-pattern.c test/huge-pattern-ref.png test/Makefile.am
Chris Wilson
ickle at kemper.freedesktop.org
Sat Oct 11 12:05:56 PDT 2008
configure.ac | 5 ++-
src/cairo-xlib-surface.c | 64 ++++++++++++++++++++++++---------------
test/.gitignore | 1
test/Makefile.am | 6 +++
test/any2ppm.c | 28 ++++++++++++-----
test/cairo-test.c | 5 +--
test/huge-pattern-ref.png |binary
test/huge-pattern.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 147 insertions(+), 36 deletions(-)
New commits:
commit ab1d106cba7aa4abe5f7253c089aadd15e0bb06d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Sat Oct 11 19:52:28 2008 +0100
[xlib] Use the cached xrender formats.
Use the cached formats for consistency and simplify several double pointer
dereferences.
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 7de1031..d22337a 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -147,7 +147,7 @@ _cairo_xlib_surface_create_similar_with_format (void *abstract_src,
return NULL;
xrender_format = _cairo_xlib_display_get_xrender_format (
- src->screen_info->display,
+ src->display,
format);
if (xrender_format == NULL)
return NULL;
@@ -211,7 +211,7 @@ _cairo_xlib_surface_create_similar (void *abstract_src,
if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX)
return _cairo_surface_create_in_error (_cairo_error(CAIRO_STATUS_NO_MEMORY));
- _cairo_xlib_display_notify (src->screen_info->display);
+ _cairo_xlib_display_notify (src->display);
/* Start by examining the surface's XRenderFormat, or if it
* doesn't have one, then look one up through its visual (in the
@@ -259,9 +259,7 @@ static cairo_status_t
_cairo_xlib_surface_finish (void *abstract_surface)
{
cairo_xlib_surface_t *surface = abstract_surface;
- cairo_xlib_display_t *display = surface->screen_info ?
- surface->screen_info->display :
- NULL;
+ cairo_xlib_display_t *display = surface->display;
cairo_status_t status = CAIRO_STATUS_SUCCESS;
if (surface->owns_pixmap) {
@@ -1054,7 +1052,7 @@ _cairo_xlib_surface_acquire_source_image (void *abstract_surf
cairo_image_surface_t *image;
cairo_status_t status;
- _cairo_xlib_display_notify (surface->screen_info->display);
+ _cairo_xlib_display_notify (surface->display);
status = _get_image_surface (surface, NULL, &image, NULL);
if (status)
@@ -1085,7 +1083,7 @@ _cairo_xlib_surface_acquire_dest_image (void *abstract_surfac
cairo_image_surface_t *image;
cairo_status_t status;
- _cairo_xlib_display_notify (surface->screen_info->display);
+ _cairo_xlib_display_notify (surface->display);
status = _get_image_surface (surface, interest_rect, &image, image_rect_out);
if (status)
@@ -1142,7 +1140,7 @@ _cairo_xlib_surface_clone_similar (void *abstract_surface,
cairo_xlib_surface_t *clone;
cairo_status_t status;
- _cairo_xlib_display_notify (surface->screen_info->display);
+ _cairo_xlib_display_notify (surface->display);
if (src->backend == surface->base.backend ) {
cairo_xlib_surface_t *xlib_src = (cairo_xlib_surface_t *)src;
@@ -1663,7 +1661,7 @@ _cairo_xlib_surface_composite (cairo_operator_t op,
int itx, ity;
cairo_bool_t is_integer_translation;
- _cairo_xlib_display_notify (dst->screen_info->display);
+ _cairo_xlib_display_notify (dst->display);
operation = _categorize_composite_operation (dst, op, src_pattern,
mask_pattern != NULL);
@@ -1873,7 +1871,7 @@ _cairo_xlib_surface_fill_rectangles (void *abstract_surface,
XRectangle *xrects = static_xrects;
int i;
- _cairo_xlib_display_notify (surface->screen_info->display);
+ _cairo_xlib_display_notify (surface->display);
if (! CAIRO_SURFACE_RENDER_HAS_FILL_RECTANGLES (surface)) {
if (op == CAIRO_OPERATOR_CLEAR ||
@@ -1931,10 +1929,17 @@ _create_a8_picture (cairo_xlib_surface_t *surface,
Pixmap pixmap;
Picture picture;
+ XRenderPictFormat *xrender_format;
if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX)
return None;
+ xrender_format =
+ _cairo_xlib_display_get_xrender_format (surface->display,
+ CAIRO_FORMAT_A8);
+ if (xrender_format == NULL)
+ return None;
+
pixmap = XCreatePixmap (surface->dpy, surface->drawable,
width <= 0 ? 1 : width,
height <= 0 ? 1 : height,
@@ -1946,8 +1951,7 @@ _create_a8_picture (cairo_xlib_surface_t *surface,
}
picture = XRenderCreatePicture (surface->dpy, pixmap,
- XRenderFindStandardFormat (surface->dpy, PictStandardA8),
- mask, &pa);
+ xrender_format, mask, &pa);
XRenderFillRectangle (surface->dpy, PictOpSrc, picture, color,
0, 0, width, height);
XFreePixmap (surface->dpy, pixmap);
@@ -2006,6 +2010,11 @@ _create_trapezoid_mask (cairo_xlib_surface_t *dst,
}
solid_picture = _create_a8_picture (dst, &solid, width, height, TRUE);
+ if (solid_picture == None) {
+ XRenderFreePicture (dst->dpy, mask_picture);
+ free (offset_traps);
+ return None;
+ }
XRenderCompositeTrapezoids (dst->dpy, PictOpAdd,
solid_picture, mask_picture,
@@ -2042,7 +2051,7 @@ _cairo_xlib_surface_composite_trapezoids (cairo_operator_t op,
int render_src_x, render_src_y;
XRenderPictFormat *pict_format;
- _cairo_xlib_display_notify (dst->screen_info->display);
+ _cairo_xlib_display_notify (dst->display);
if (!CAIRO_SURFACE_RENDER_HAS_TRAPEZOIDS (dst))
return CAIRO_INT_STATUS_UNSUPPORTED;
@@ -2067,13 +2076,17 @@ _cairo_xlib_surface_composite_trapezoids (cairo_operator_t op,
switch (antialias) {
case CAIRO_ANTIALIAS_NONE:
- pict_format = XRenderFindStandardFormat (dst->dpy, PictStandardA1);
+ pict_format =
+ _cairo_xlib_display_get_xrender_format (dst->display,
+ CAIRO_FORMAT_A1);
break;
case CAIRO_ANTIALIAS_GRAY:
case CAIRO_ANTIALIAS_SUBPIXEL:
case CAIRO_ANTIALIAS_DEFAULT:
default:
- pict_format = XRenderFindStandardFormat (dst->dpy, PictStandardA8);
+ pict_format =
+ _cairo_xlib_display_get_xrender_format (dst->display,
+ CAIRO_FORMAT_A8);
break;
}
@@ -2324,7 +2337,7 @@ _cairo_xlib_surface_is_similar (void *surface_a,
_xrender_format_to_content (xrender_format) != content)
{
xrender_format = _cairo_xlib_display_get_xrender_format (
- b->screen_info->display,
+ b->display,
_cairo_format_from_content (content));
}
@@ -2500,10 +2513,13 @@ _cairo_xlib_surface_create_internal (Display *dpy,
if (CAIRO_SURFACE_RENDER_HAS_CREATE_PICTURE (surface)) {
if (!xrender_format) {
- if (visual)
+ if (visual) {
xrender_format = XRenderFindVisualFormat (dpy, visual);
- else if (depth == 1)
- xrender_format = XRenderFindStandardFormat (dpy, PictStandardA1);
+ } else if (depth == 1) {
+ xrender_format =
+ _cairo_xlib_display_get_xrender_format (display,
+ CAIRO_FORMAT_A1);
+ }
}
} else {
xrender_format = NULL;
@@ -2807,7 +2823,7 @@ cairo_xlib_surface_set_drawable (cairo_surface_t *abstract_surface,
if (surface->drawable != drawable) {
if (surface->dst_picture != None) {
status = _cairo_xlib_display_queue_resource (
- surface->screen_info->display,
+ surface->display,
XRenderFreePicture,
surface->dst_picture);
if (status) {
@@ -2820,7 +2836,7 @@ cairo_xlib_surface_set_drawable (cairo_surface_t *abstract_surface,
if (surface->src_picture != None) {
status = _cairo_xlib_display_queue_resource (
- surface->screen_info->display,
+ surface->display,
XRenderFreePicture,
surface->src_picture);
if (status) {
@@ -3725,7 +3741,7 @@ _cairo_xlib_surface_emit_glyphs (cairo_xlib_surface_t *dst,
int request_size = 0;
_cairo_xlib_surface_ensure_dst_picture (dst);
- _cairo_xlib_display_notify (dst->screen_info->display);
+ _cairo_xlib_display_notify (dst->display);
for (i = 0; i < num_glyphs; i++) {
int this_x, this_y;
@@ -3920,7 +3936,7 @@ _cairo_xlib_surface_show_glyphs (void *abstract_dst,
font_private = scaled_font->surface_private;
if ((scaled_font->surface_backend != NULL &&
scaled_font->surface_backend != &cairo_xlib_surface_backend) ||
- (font_private != NULL && font_private->display != dst->screen_info->display))
+ (font_private != NULL && font_private->display != dst->display))
return CAIRO_INT_STATUS_UNSUPPORTED;
/* After passing all those tests, we're now committed to rendering
@@ -3999,7 +4015,7 @@ _cairo_xlib_surface_show_glyphs (void *abstract_dst,
_cairo_pattern_fini (&solid_pattern.base);
BAIL0:
_cairo_scaled_font_thaw_cache (scaled_font);
- _cairo_xlib_display_notify (dst->screen_info->display);
+ _cairo_xlib_display_notify (dst->display);
return status;
}
commit 6736faba3ebe4eae4c1d2aeeb3153eb6f12a32de
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Sat Oct 11 18:10:16 2008 +0100
[test/any2ppm] Do not attempt to compile PS without spectre
Since CAN_TEST_PS_SURFACE does not currently require spectre, we were
attempting to compile in spectre support for any2ppm even on systems
without libspectre installed. Fix that by adding a separate flag for
CAIRO_HAS_SPECTRE.
diff --git a/configure.ac b/configure.ac
index 5545fb1..7385f0e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -357,7 +357,10 @@ if test "x$use_ps" = "xyes"; then
fi
AM_CONDITIONAL(CAIRO_CAN_TEST_PS_SURFACE, test "x$test_ps" = "xyes")
-AM_CONDITIONAL(BUILD_PS2PNG, test "x$any2ppm_ps" = "xyes")
+AM_CONDITIONAL(CAIRO_HAS_SPECTRE, test "x$any2ppm_ps" = "xyes")
+if test "x$any2ppm_ps" = "xyes"; then
+ AC_DEFINE([CAIRO_HAS_SPECTRE], 1, [Define to 1 if libspectre is available])
+fi
AC_SUBST(LIBSPECTRE_CFLAGS)
AC_SUBST(LIBSPECTRE_LIBS)
diff --git a/test/Makefile.am b/test/Makefile.am
index 91cd178..6a98cf6 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1098,7 +1098,7 @@ svg2png_LDFLAGS = $(CAIRO_TEST_UNDEFINED_LDFLAGS)
svg2png_LDADD = $(LDADD) $(LIBRSVG_LIBS)
endif
-if BUILD_PS2PNG
+if CAIRO_HAS_SPECTRE
check_PROGRAMS += ps2png
ps2png_CFLAGS = $(LIBSPECTRE_CFLAGS)
# add LDADD, so ps2png uses "our" cairo
diff --git a/test/any2ppm.c b/test/any2ppm.c
index 36c742f..94450b2 100644
--- a/test/any2ppm.c
+++ b/test/any2ppm.c
@@ -72,7 +72,7 @@
#include <librsvg/rsvg-cairo.h>
#endif
-#if CAIRO_CAN_TEST_PS_SURFACE
+#if CAIRO_HAS_SPECTRE
#include <libspectre/spectre.h>
#endif
@@ -293,6 +293,12 @@ pdf_convert (char **argv, int fd)
return err;
}
+#else
+static const char *
+pdf_convert (char **argv, int fd)
+{
+ return "compiled without PDF support.";
+}
#endif
#if CAIRO_CAN_TEST_SVG_SURFACE
@@ -347,9 +353,15 @@ svg_convert (char **argv, int fd)
return err;
}
+#else
+static const char *
+svg_convert (char **argv, int fd)
+{
+ return "compiled without SVG support.";
+}
#endif
-#if CAIRO_CAN_TEST_PS_SURFACE
+#if CAIRO_HAS_SPECTRE
static const char *
_spectre_render_page (const char *filename,
const char *page_label,
@@ -422,6 +434,12 @@ ps_convert (char **argv, int fd)
return err;
}
+#else
+static const char *
+ps_convert (char **argv, int fd)
+{
+ return "compiled without PostScript support.";
+}
#endif
static const char *
@@ -431,15 +449,9 @@ convert (char **argv, int fd)
const char *type;
const char *(*func) (char **, int);
} converters[] = {
-#if CAIRO_CAN_TEST_PDF_SURFACE
{ "pdf", pdf_convert },
-#endif
-#if CAIRO_CAN_TEST_PS_SURFACE
{ "ps", ps_convert },
-#endif
-#if CAIRO_CAN_TEST_SVG_SURFACE
{ "svg", svg_convert },
-#endif
{ NULL, NULL }
};
const struct converter *converter = converters;
commit b35871116243724b59738fce00b512818c83ea17
Author: Benjamin Otte <otte at gnome.org>
Date: Sat Oct 11 00:18:11 2008 +0100
[test] Add huge pattern.
Add a test case to exercise range overflow during gradient construction.
diff --git a/test/.gitignore b/test/.gitignore
index 5a57541..edcf41a 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -100,6 +100,7 @@ gradient-alpha
gradient-constant-alpha
gradient-zero-stops
group-paint
+huge-pattern
imagediff
image-surface-source
infinite-join
diff --git a/test/Makefile.am b/test/Makefile.am
index 583276e..91cd178 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -77,6 +77,7 @@ gradient-alpha$(EXEEXT) \
gradient-constant-alpha$(EXEEXT) \
gradient-zero-stops$(EXEEXT) \
group-paint$(EXEEXT) \
+huge-pattern$(EXEEXT) \
image-surface-source$(EXEEXT) \
infinite-join$(EXEEXT) \
in-fill-empty-trapezoid$(EXEEXT) \
@@ -539,6 +540,7 @@ REFERENCE_IMAGES = \
gradient-zero-stops-ref.png \
gradient-zero-stops-rgb24-ref.png \
group-paint-ref.png \
+ huge-pattern-ref.png \
image-surface-source-ref.png \
infinite-join-ref.png \
infinite-join-ps2-ref.png \
@@ -945,6 +947,7 @@ $(REFERENCE_IMAGES)
# room, with Carl as a moderator and not let them out
# until they have come up with an interface and
# semantics that actually work. :-)
+# huge-pattern - range overflow of fixed-point
# long-lines - range overflow of fixed-point
# self-copy-overlap - vector surfaces take snapshot of patterns in contrast
# to the raster backends which don't. One solution
@@ -968,6 +971,7 @@ degenerate-path$(EXEEXT) \
device-offset-scale$(EXEEXT) \
extend-pad$(EXEEXT) \
fallback-resolution$(EXEEXT) \
+huge-pattern$(EXEEXT) \
long-lines$(EXEEXT) \
self-copy-overlap$(EXEEXT) \
self-intersecting$(EXEEXT) \
diff --git a/test/huge-pattern-ref.png b/test/huge-pattern-ref.png
new file mode 100644
index 0000000..68f86b4
Binary files /dev/null and b/test/huge-pattern-ref.png differ
diff --git a/test/huge-pattern.c b/test/huge-pattern.c
new file mode 100644
index 0000000..cec12ff
--- /dev/null
+++ b/test/huge-pattern.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright © 2006 Benjamin Otte
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Author: Benjamin Otte <otte at gnome.org>
+ */
+
+#include "cairo-test.h"
+
+static cairo_test_draw_function_t draw;
+
+static const cairo_test_t test = {
+ "huge-pattern",
+ "Test huge linear patterns"
+ "\nhuge patterns seem to not be drawn correctly",
+ 600, 350,
+ draw
+};
+
+/* set this to 0.1 to make this test work */
+#define FACTOR 1
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_pattern_t *pattern;
+ cairo_matrix_t mat = {
+ 0, -4.5254285714285709 * FACTOR,
+ -2.6398333333333333 * FACTOR, 0,
+ 0, 0
+ };
+
+ pattern = cairo_pattern_create_linear (-16384 * FACTOR, 0,
+ 16384 * FACTOR, 0);
+ cairo_pattern_add_color_stop_rgba (pattern,
+ 0, 0.376471, 0.533333, 0.27451, 1);
+ cairo_pattern_add_color_stop_rgba (pattern, 1, 1, 1, 1, 1);
+ cairo_pattern_set_matrix (pattern, &mat);
+
+ cairo_scale (cr, 0.05, 0.05);
+ cairo_translate (cr, 6000, 3500);
+
+ cairo_set_source (cr, pattern);
+ cairo_rectangle (cr, -6000, -3500, 12000, 7000);
+ cairo_pattern_destroy (pattern);
+ cairo_fill (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test);
+}
commit 77070270813d2ca40d422e5301f75222d19e1d8f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri Oct 10 22:24:01 2008 +0100
[test] Use _POSIX_C_SOURCE for flockfile.
From bug 18010 (https://bugs.freedesktop.org/show_bug.cgi?id=18010),
in order to make flockfile() available we need to set _POSIX_C_SOURCE and
according to the man page, the appropriate feature check is
_POSIX_THREAD_SAFE_FUNCTIONS.
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 0e076c6..7edb4fb 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -24,6 +24,7 @@
*/
#define _GNU_SOURCE 1 /* for feenableexcept() et al */
+#define _POSIX_C_SOURCE 2000112L /* for flockfile() et al */
#if HAVE_CONFIG_H
#include "config.h"
@@ -1059,7 +1060,7 @@ cairo_test_run (cairo_test_context_t *ctx)
}
fflush (stdout);
} else {
-#ifdef HAVE_FLOCKFILE
+#if _POSIX_THREAD_SAFE_FUNCTIONS
flockfile (stdout);
#endif
printf ("%s-%s-%s %d [%d]:\t",
@@ -1090,7 +1091,7 @@ cairo_test_run (cairo_test_context_t *ctx)
}
fflush (stdout);
-#ifdef HAVE_FLOCKFILE
+#if _POSIX_THREAD_SAFE_FUNCTIONS
funlockfile (stdout);
#endif
}
More information about the cairo-commit
mailing list