[cairo-commit] cairo/test cairo-test.c,1.71,1.72
Carl Worth
commit at pdx.freedesktop.org
Wed Dec 21 16:46:47 PST 2005
- Previous message: [cairo-commit] cairo/src Makefile.am, 1.73,
1.74 cairo-paginated-surface-private.h, NONE,
1.1 cairo-paginated-surface.c, NONE,
1.1 test-paginated-surface.c, NONE,
1.1 test-paginated-surface.h, NONE, 1.1
- Next message: [cairo-commit] cairo ChangeLog,1.1192,1.1193
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: cworth
Update of /cvs/cairo/cairo/test
In directory gabe:/tmp/cvs-serv22836/test
Modified Files:
cairo-test.c
Log Message:
2005-12-21 Carl Worth <cworth at cworth.org>
* src/Makefile.am:
* src/cairo-paginated-surface-private.h:
* src/cairo-paginated-surface.c: (_cairo_paginated_surface_create),
(_cairo_paginated_surface_create_similar),
(_cairo_paginated_surface_finish),
(_cairo_paginated_surface_acquire_source_image),
(_cairo_paginated_surface_release_source_image),
(_cairo_paginated_surface_show_page),
(_cairo_paginated_surface_intersect_clip_path),
(_cairo_paginated_surface_get_extents),
(_cairo_paginated_surface_paint), (_cairo_paginated_surface_mask),
(_cairo_paginated_surface_stroke), (_cairo_paginated_surface_fill),
(_cairo_paginated_surface_show_glyphs),
(_cairo_paginated_surface_snapshot): Add a private
cairo_paginated_surface_t which builds on top of the meta surface
and is intended to provide an easy interface with common
functionality for the various paginated surface types (ps, pdf,
etc.).
* src/test-paginated-surface.c:
(_test_paginated_surface_create_for_data):
* src/test-paginated-surface.h:
* test/cairo-test.c: (create_test_paginated_surface),
(test_paginated_write_to_png), (cleanup_test_paginated),
(cairo_test_expecting): Add test_paginated_surface_t which is
another test surface enabled with --enable-test-surfaces. The
test_meta_surface code served as the basis for
cairo_paginated_surface_t so that test surface may be entirely
superfluous now.
Index: cairo-test.c
===================================================================
RCS file: /cvs/cairo/cairo/test/cairo-test.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- cairo-test.c 20 Dec 2005 06:01:39 -0000 1.71
+++ cairo-test.c 22 Dec 2005 00:46:45 -0000 1.72
@@ -190,6 +190,7 @@
#include "test-fallback-surface.h"
#include "test-meta-surface.h"
+#include "test-paginated-surface.h"
static cairo_surface_t *
create_test_fallback_surface (cairo_test_t *test, cairo_format_t format,
@@ -207,6 +208,86 @@
return _test_meta_surface_create (format, test->width, test->height);
}
+static const cairo_user_data_key_t test_paginated_closure_key;
+
+typedef struct {
+ unsigned char *data;
+ cairo_format_t format;
+ int width;
+ int height;
+ int stride;
+} test_paginated_closure_t;
+
+static cairo_surface_t *
+create_test_paginated_surface (cairo_test_t *test, cairo_format_t format,
+ void **closure)
+{
+ test_paginated_closure_t *tpc;
+ cairo_surface_t *surface;
+
+ *closure = tpc = xmalloc (sizeof (test_paginated_closure_t));
+
+ tpc->format = format;
+ tpc->width = test->width;
+ tpc->height = test->height;
+ tpc->stride = test->width * 4;
+
+ tpc->data = xcalloc (tpc->stride * test->height, 1);
+
+ surface = _test_paginated_surface_create_for_data (tpc->data,
+ tpc->format,
+ tpc->width,
+ tpc->height,
+ tpc->stride);
+
+ cairo_surface_set_user_data (surface, &test_paginated_closure_key,
+ tpc, NULL);
+
+ return surface;
+}
+
+/* The only reason we go through all these machinations to write a PNG
+ * image is to _really ensure_ that the data actually landed in our
+ * buffer through the paginated surface to the test_paginated_surface.
+ *
+ * If we didn't implement this function then the default
+ * cairo_surface_write_to_png would result in the paginated_surface's
+ * acquire_source_image function replaying the meta-surface to an
+ * intermediate image surface. And in that case the
+ * test_paginated_surface would not be involved and wouldn't be
+ * tested.
+ */
+static cairo_status_t
+test_paginated_write_to_png (cairo_surface_t *surface,
+ const char *filename)
+{
+ cairo_surface_t *image;
+ test_paginated_closure_t *tpc;
+
+ tpc = cairo_surface_get_user_data (surface, &test_paginated_closure_key);
+
+ image = cairo_image_surface_create_for_data (tpc->data,
+ tpc->format,
+ tpc->width,
+ tpc->height,
+ tpc->stride);
+
+ cairo_surface_write_to_png (image, filename);
+
+ cairo_surface_destroy (image);
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
+static void
+cleanup_test_paginated (void *closure)
+{
+ test_paginated_closure_t *tpc = closure;
+
+ free (tpc->data);
+ free (tpc);
+}
+
#endif
#ifdef CAIRO_HAS_GLITZ_SURFACE
@@ -1299,6 +1380,10 @@
create_test_fallback_surface, cairo_surface_write_to_png, NULL },
{ "test-meta", CAIRO_FORMAT_ARGB32,
create_test_meta_surface, cairo_surface_write_to_png, NULL },
+ { "test-paginated", CAIRO_FORMAT_ARGB32,
+ create_test_paginated_surface,
+ test_paginated_write_to_png,
+ cleanup_test_paginated },
#endif
#ifdef CAIRO_HAS_GLITZ_SURFACE
#if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
- Previous message: [cairo-commit] cairo/src Makefile.am, 1.73,
1.74 cairo-paginated-surface-private.h, NONE,
1.1 cairo-paginated-surface.c, NONE,
1.1 test-paginated-surface.c, NONE,
1.1 test-paginated-surface.h, NONE, 1.1
- Next message: [cairo-commit] cairo ChangeLog,1.1192,1.1193
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list