summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLoïc Minier <lool@dooz.org>2009-04-14 23:41:59 +0200
committerLoïc Minier <lool@dooz.org>2009-04-14 23:41:59 +0200
commite781cc575ab4adb1d9822c628fc9f19ed35b0c88 (patch)
tree508bb3bbb77c328418dd609124d278d116519cbf /test
parent7ad32874f16257ec3d7509310ffa00e7308581f4 (diff)
Imported Upstream version 0.5.1
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am220
-rw-r--r--test/Makefile.in642
-rw-r--r--test/buffer-diff.c150
-rw-r--r--test/buffer-diff.h (renamed from test/buffer_diff.h)22
-rw-r--r--test/buffer_diff.c73
-rw-r--r--test/cairo-test.c579
-rw-r--r--test/cairo-test.h (renamed from test/cairo_test.h)12
-rw-r--r--test/cairo_test.c247
-rw-r--r--test/clip-nesting-ref.pngbin0 -> 1050 bytes
-rw-r--r--test/clip-nesting.c98
-rw-r--r--test/clip-twice-ref.pngbin0 -> 1191 bytes
-rw-r--r--test/clip-twice.c (renamed from test/clip_twice.c)17
-rw-r--r--test/clip_twice-ref.pngbin751 -> 0 bytes
-rw-r--r--test/coverage-ref.pngbin44324 -> 0 bytes
-rw-r--r--test/create-for-png-ref.png (renamed from test/move_to_show_surface-ref.png)bin100 -> 100 bytes
-rw-r--r--test/create-for-png.c69
-rw-r--r--test/fill-and-stroke-ref.pngbin0 -> 279 bytes
-rw-r--r--test/fill-and-stroke.c63
-rw-r--r--test/fill-rule-ref.png (renamed from test/fill_rule-ref.png)bin1979 -> 1979 bytes
-rw-r--r--test/fill-rule.c (renamed from test/fill_rule.c)10
-rw-r--r--test/filter-nearest-offset-ref.pngbin0 -> 254 bytes
-rw-r--r--test/filter-nearest-offset.c107
-rw-r--r--test/get-and-set.c142
-rw-r--r--test/gradient-alpha-ref.pngbin0 -> 153 bytes
-rw-r--r--test/gradient-alpha.c61
-rw-r--r--test/imagediff.c8
-rw-r--r--test/leaky-polygon-ref.png (renamed from test/leaky_polygon-ref.png)bin255 -> 255 bytes
-rw-r--r--test/leaky-polygon.c (renamed from test/leaky_polygon.c)8
-rw-r--r--test/line-width-ref.png (renamed from test/line_width-ref.png)bin171 -> 171 bytes
-rw-r--r--test/line-width.c (renamed from test/line_width.c)10
-rw-r--r--test/linear-gradient-ref.png (renamed from test/linear_gradient-ref.png)bin12724 -> 12724 bytes
-rw-r--r--test/linear-gradient.c (renamed from test/linear_gradient.c)42
-rw-r--r--test/mask-ref.pngbin0 -> 87846 bytes
-rw-r--r--test/mask.c246
-rw-r--r--test/move-to-show-surface-ref.pngbin0 -> 100 bytes
-rw-r--r--test/move-to-show-surface.c (renamed from test/move_to_show_surface.c)30
-rw-r--r--test/paint-ref.pngbin0 -> 116 bytes
-rw-r--r--test/paint-with-alpha-ref.pngbin0 -> 164 bytes
-rw-r--r--test/paint-with-alpha.c64
-rw-r--r--test/paint.c53
-rw-r--r--test/path-data-ref.pngbin0 -> 387 bytes
-rw-r--r--test/path-data.c184
-rw-r--r--test/pdf-clip.c134
-rw-r--r--test/pdf-surface.c115
-rw-r--r--test/pixman-rotate-ref.png (renamed from test/pixman_rotate-ref.png)bin260 -> 260 bytes
-rw-r--r--test/pixman-rotate.c76
-rw-r--r--test/pixman_rotate.c78
-rw-r--r--test/ps-surface.c115
-rw-r--r--test/read-png.c (renamed from test/read_png.c)35
-rw-r--r--test/read-png.h (renamed from test/read_png.h)0
-rw-r--r--test/rel-path-ref.pngbin0 -> 212 bytes
-rw-r--r--test/rel-path.c56
-rw-r--r--test/scale-source-surface-paint-ref.pngbin0 -> 147 bytes
-rw-r--r--test/scale-source-surface-paint.c64
-rw-r--r--test/select-font-no-show-text.c64
-rw-r--r--test/self-copy-ref.pngbin0 -> 291 bytes
-rw-r--r--test/self-copy.c89
-rw-r--r--test/self-intersecting-ref.pngbin0 -> 242 bytes
-rw-r--r--test/self-intersecting.c89
-rw-r--r--test/set-source-ref.pngbin0 -> 120 bytes
-rw-r--r--test/set-source.c87
-rw-r--r--test/source-clip-ref.pngbin0 -> 180 bytes
-rw-r--r--test/source-clip.c84
-rw-r--r--test/source-surface-scale-paint-ref.pngbin0 -> 147 bytes
-rw-r--r--test/source-surface-scale-paint.c64
-rw-r--r--test/surface-finish-twice.c74
-rw-r--r--test/surface-pattern-ref.pngbin0 -> 194 bytes
-rw-r--r--test/surface-pattern.c74
-rw-r--r--test/text-cache-crash.c (renamed from test/text_cache_crash.c)26
-rw-r--r--test/text-rotate.c (renamed from test/text_rotate.c)25
-rw-r--r--test/transforms-ref.pngbin0 -> 302 bytes
-rw-r--r--test/transforms.c111
-rw-r--r--test/translate-show-surface-ref.pngbin0 -> 100 bytes
-rw-r--r--test/translate-show-surface.c83
-rw-r--r--test/trap-clip-ref.pngbin0 -> 71701 bytes
-rw-r--r--test/trap-clip.c (renamed from test/coverage.c)158
-rw-r--r--test/user-data.c82
-rw-r--r--test/write-png.c (renamed from test/write_png.c)4
-rw-r--r--test/write-png.h (renamed from test/write_png.h)2
-rw-r--r--test/xlib-surface.c269
-rw-r--r--test/xmalloc.c5
-rw-r--r--test/xmalloc.h2
82 files changed, 4431 insertions, 791 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 04d42e2..4820419 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,45 +1,103 @@
-# All new test cases go here
-TESTS = \
-fill_rule \
-leaky_polygon \
-line_width \
-linear_gradient \
-move_to_show_surface \
-text_cache_crash \
-text_rotate \
-coverage \
-clip_twice \
-pixman_rotate
+# All test cases go here
+TESTS = \
+clip-nesting \
+clip-twice \
+create-for-png \
+fill-and-stroke \
+fill-rule \
+filter-nearest-offset \
+get-and-set \
+gradient-alpha \
+leaky-polygon \
+line-width \
+linear-gradient \
+mask \
+move-to-show-surface \
+paint \
+paint-with-alpha \
+path-data \
+pixman-rotate \
+scale-source-surface-paint \
+select-font-no-show-text \
+self-copy \
+self-intersecting \
+set-source \
+source-clip \
+source-surface-scale-paint \
+surface-finish-twice \
+surface-pattern \
+text-cache-crash \
+text-rotate \
+transforms \
+translate-show-surface \
+trap-clip \
+user-data \
+rel-path
-# And all new tests go here too. I really don't like having to repeat
-# this list. Anyone know a good way to avoid it? Can I use a wildcard
-# here?
-EXTRA_DIST = \
-fill_rule-ref.png \
-leaky_polygon-ref.png \
-line_width-ref.png \
-linear_gradient-ref.png \
-move_to_show_surface-ref.png \
-coverage-ref.png \
-clip_twice-ref.png \
-pixman_rotate-ref.png \
-romedalen.png
+if CAIRO_HAS_PDF_SURFACE
+TESTS += pdf-surface pdf-clip
+endif
-# Once we can draw the text_rotate.c test case correctly, we should
-# create and add text_rotate-ref.png to the list of reference PNGs.
+if CAIRO_HAS_PS_SURFACE
+TESTS += ps-surface
+endif
-# This list is only for known bugs (not regressions). We do need to
-# fix these before the next release, but they are expected to fail for
-# now, so they don't need to hold up any new code commit.
+if CAIRO_HAS_XLIB_SURFACE
+TESTS += xlib-surface
+endif
+
+# All tests which have a reference image go here.
+# I really don't like having to repeat this list. Anyone know a good
+# way to avoid it? Can I use a wildcard here?
+EXTRA_DIST = \
+clip-nesting-ref.png \
+clip-twice-ref.png \
+create-for-png-ref.png \
+fill-and-stroke-ref.png \
+fill-rule-ref.png \
+filter-nearest-offset-ref.png \
+gradient-alpha-ref.png \
+leaky-polygon-ref.png \
+line-width-ref.png \
+linear-gradient-ref.png \
+mask-ref.png \
+move-to-show-surface-ref.png \
+paint-ref.png \
+paint-with-alpha-ref.png \
+path-data-ref.png \
+pixman-rotate-ref.png \
+romedalen.png \
+self-copy-ref.png \
+self-intersecting-ref.png \
+scale-source-surface-paint-ref.png \
+set-source-ref.png \
+source-clip-ref.png \
+source-surface-scale-paint-ref.png \
+surface-pattern-ref.png \
+transforms-ref.png \
+translate-show-surface-ref.png \
+trap-clip-ref.png \
+rel-path-ref.png
+
+# Any test for which the code committed to CVS is expected to fail
+# should be listed here.
+#
+# This way, we can avoid being bothered by reports of bugs we are
+# aware of, but users can still report when tests start behaving in
+# unexpected ways on their system.
#
-# When new bugs are found in committed code they can be listed
-# here. New failures due to local, uncommitted code changes are
-# regression bugs that should not be listed here. Instead they should
-# be fixed before the code is committed.
-XFAIL_TESTS = \
-move_to_show_surface \
-pixman_rotate \
-text_rotate
+# Of course, before any "release" of cairo we should eliminate
+# everything from this list by fixing the bugs. (We don't necessarily
+# have to be that strict for "snapshots" though.)
+#
+# Also, any test listed here should call cairo_test_expect_failure and
+# provide an explanation for the expected failure.
+XFAIL_TESTS = \
+filter-nearest-offset \
+pixman-rotate \
+self-intersecting \
+source-surface-scale-paint \
+text-rotate
check_PROGRAMS = $(TESTS)
@@ -47,37 +105,77 @@ check_PROGRAMS = $(TESTS)
# not be the most portable approach, but it is pragmatic and I'm
# willing to do something cleaner as soon as it causes someone a
# problem.
-INCLUDES = -D_GNU_SOURCE -I$(srcdir) $(CAIRO_CFLAGS) -I$(srcdir)/../src
+INCLUDES = \
+ -D_GNU_SOURCE \
+ $(CAIRO_CFLAGS) \
+ -I$(srcdir) \
+ -I$(top_srcdir)/src \
+ -I$(top_builddir)/src
-AM_LDFLAGS = $(CAIRO_LIBS) ../src/libcairo.la
+noinst_LTLIBRARIES = libcairotest.la
-cairo_test_lib =\
-buffer_diff.c \
-buffer_diff.h \
-cairo_test.c \
-cairo_test.h \
-read_png.c \
-read_png.h \
-write_png.c \
-write_png.h \
+libcairotest_la_SOURCES =\
+buffer-diff.c \
+buffer-diff.h \
+cairo-test.c \
+cairo-test.h \
+read-png.c \
+read-png.h \
+write-png.c \
+write-png.h \
xmalloc.c \
xmalloc.h
+LDADDS = libcairotest.la $(top_builddir)/src/libcairo.la
+
# ARGH! I have to repeat the list of tests a third time. Maybe it's
# time to break down and auto-generate the Makefile.am or something
# from autogen.sh. My, but this is painful...
-fill_rule_SOURCES = fill_rule.c $(cairo_test_lib)
-leaky_polygon_SOURCES = leaky_polygon.c $(cairo_test_lib)
-line_width_SOURCES = line_width.c $(cairo_test_lib)
-linear_gradient_SOURCES = linear_gradient.c $(cairo_test_lib)
-move_to_show_surface_SOURCES = move_to_show_surface.c $(cairo_test_lib)
-text_cache_crash_SOURCES = text_cache_crash.c $(cairo_test_lib)
-text_rotate_SOURCES = text_rotate.c $(cairo_test_lib)
-coverage_SOURCES = coverage.c $(cairo_test_lib)
-clip_twice_SOURCES = clip_twice.c $(cairo_test_lib)
-pixman_rotate_SOURCES = pixman_rotate.c $(cairo_test_lib)
+clip_nesting_LDADD = $(LDADDS)
+clip_twice_LDADD = $(LDADDS)
+create_for_png_LDADD = $(LDADDS)
+fill_and_stroke_LDADD = $(LDADDS)
+fill_rule_LDADD = $(LDADDS)
+filter_nearest_offset_LDADD = $(LDADDS)
+get_and_set_LDADD = $(LDADDS)
+gradient_alpha_LDADD = $(LDADDS)
+leaky_polygon_LDADD = $(LDADDS)
+line_width_LDADD = $(LDADDS)
+linear_gradient_LDADD = $(LDADDS)
+mask_LDADD = $(LDADDS)
+move_to_show_surface_LDADD = $(LDADDS)
+paint_LDADD = $(LDADDS)
+paint_with_alpha_LDADD = $(LDADDS)
+path_data_LDADD = $(LDADDS)
+pdf_surface_LDADD = $(LDADDS)
+pdf_clip_LDADD = $(LDADDS)
+ps_surface_LDADD = $(LDADDS)
+pixman_rotate_LDADD = $(LDADDS)
+scale_source_surface_paint_LDADD = $(LDADDS)
+select_font_no_show_text_LDADD = $(LDADDS)
+self_copy_LDADD = $(LDADDS)
+self_intersecting_LDADD = $(LDADDS)
+set_source_LDADD = $(LDADDS)
+source_clip_LDADD = $(LDADDS)
+source_surface_scale_paint_LDADD = $(LDADDS)
+surface_finish_twice_LDADD = $(LDADDS)
+surface_pattern_LDADD = $(LDADDS)
+text_cache_crash_LDADD = $(LDADDS)
+text_rotate_LDADD = $(LDADDS)
+transforms_LDADD = $(LDADDS)
+translate_show_surface_LDADD = $(LDADDS)
+trap_clip_LDADD = $(LDADDS)
+user_data_LDADD = $(LDADDS)
+rel_path_LDADD = $(LDADDS)
+xlib_surface_LDADD = $(LDADDS)
noinst_PROGRAMS = imagediff
-imagediff_SOURCES = imagediff.c $(cairo_test_lib)
+imagediff_LDADD = $(LDADDS)
-CLEANFILES = *-out.png *-diff.png *.log
+CLEANFILES = \
+ *-out.png \
+ *-diff.png \
+ *.log \
+ ps-surface.ps \
+ pdf-surface.pdf \
+ pdf-clip.pdf
diff --git a/test/Makefile.in b/test/Makefile.in
index f2bbb66..1fb5658 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -14,7 +14,8 @@
@SET_MAKE@
-SOURCES = $(clip_twice_SOURCES) $(coverage_SOURCES) $(fill_rule_SOURCES) $(imagediff_SOURCES) $(leaky_polygon_SOURCES) $(line_width_SOURCES) $(linear_gradient_SOURCES) $(move_to_show_surface_SOURCES) $(pixman_rotate_SOURCES) $(text_cache_crash_SOURCES) $(text_rotate_SOURCES)
+
+SOURCES = $(libcairotest_la_SOURCES) clip-nesting.c clip-twice.c create-for-png.c fill-and-stroke.c fill-rule.c filter-nearest-offset.c get-and-set.c gradient-alpha.c imagediff.c leaky-polygon.c line-width.c linear-gradient.c mask.c move-to-show-surface.c paint.c paint-with-alpha.c path-data.c pdf-clip.c pdf-surface.c pixman-rotate.c ps-surface.c rel-path.c scale-source-surface-paint.c select-font-no-show-text.c self-copy.c self-intersecting.c set-source.c source-clip.c source-surface-scale-paint.c surface-finish-twice.c surface-pattern.c text-cache-crash.c text-rotate.c transforms.c translate-show-surface.c trap-clip.c user-data.c xlib-surface.c
srcdir = @srcdir@
top_srcdir = @top_srcdir@
@@ -38,7 +39,10 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-check_PROGRAMS = $(am__EXEEXT_1)
+@CAIRO_HAS_PDF_SURFACE_TRUE@am__append_1 = pdf-surface pdf-clip
+@CAIRO_HAS_PS_SURFACE_TRUE@am__append_2 = ps-surface
+@CAIRO_HAS_XLIB_SURFACE_TRUE@am__append_3 = xlib-surface
+check_PROGRAMS = $(am__EXEEXT_4)
noinst_PROGRAMS = imagediff$(EXEEXT)
subdir = test
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
@@ -50,50 +54,150 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
-am__EXEEXT_1 = fill_rule$(EXEEXT) leaky_polygon$(EXEEXT) \
- line_width$(EXEEXT) linear_gradient$(EXEEXT) \
- move_to_show_surface$(EXEEXT) text_cache_crash$(EXEEXT) \
- text_rotate$(EXEEXT) coverage$(EXEEXT) clip_twice$(EXEEXT) \
- pixman_rotate$(EXEEXT)
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libcairotest_la_LIBADD =
+am_libcairotest_la_OBJECTS = buffer-diff.lo cairo-test.lo read-png.lo \
+ write-png.lo xmalloc.lo
+libcairotest_la_OBJECTS = $(am_libcairotest_la_OBJECTS)
+@CAIRO_HAS_PDF_SURFACE_TRUE@am__EXEEXT_1 = pdf-surface$(EXEEXT) \
+@CAIRO_HAS_PDF_SURFACE_TRUE@ pdf-clip$(EXEEXT)
+@CAIRO_HAS_PS_SURFACE_TRUE@am__EXEEXT_2 = ps-surface$(EXEEXT)
+@CAIRO_HAS_XLIB_SURFACE_TRUE@am__EXEEXT_3 = xlib-surface$(EXEEXT)
+am__EXEEXT_4 = clip-nesting$(EXEEXT) clip-twice$(EXEEXT) \
+ create-for-png$(EXEEXT) fill-and-stroke$(EXEEXT) \
+ fill-rule$(EXEEXT) filter-nearest-offset$(EXEEXT) \
+ get-and-set$(EXEEXT) gradient-alpha$(EXEEXT) \
+ leaky-polygon$(EXEEXT) line-width$(EXEEXT) \
+ linear-gradient$(EXEEXT) mask$(EXEEXT) \
+ move-to-show-surface$(EXEEXT) paint$(EXEEXT) \
+ paint-with-alpha$(EXEEXT) path-data$(EXEEXT) \
+ pixman-rotate$(EXEEXT) scale-source-surface-paint$(EXEEXT) \
+ select-font-no-show-text$(EXEEXT) self-copy$(EXEEXT) \
+ self-intersecting$(EXEEXT) set-source$(EXEEXT) \
+ source-clip$(EXEEXT) source-surface-scale-paint$(EXEEXT) \
+ surface-finish-twice$(EXEEXT) surface-pattern$(EXEEXT) \
+ text-cache-crash$(EXEEXT) text-rotate$(EXEEXT) \
+ transforms$(EXEEXT) translate-show-surface$(EXEEXT) \
+ trap-clip$(EXEEXT) user-data$(EXEEXT) rel-path$(EXEEXT) \
+ $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3)
PROGRAMS = $(noinst_PROGRAMS)
-am__objects_1 = buffer_diff.$(OBJEXT) cairo_test.$(OBJEXT) \
- read_png.$(OBJEXT) write_png.$(OBJEXT) xmalloc.$(OBJEXT)
-am_clip_twice_OBJECTS = clip_twice.$(OBJEXT) $(am__objects_1)
-clip_twice_OBJECTS = $(am_clip_twice_OBJECTS)
-clip_twice_LDADD = $(LDADD)
-am_coverage_OBJECTS = coverage.$(OBJEXT) $(am__objects_1)
-coverage_OBJECTS = $(am_coverage_OBJECTS)
-coverage_LDADD = $(LDADD)
-am_fill_rule_OBJECTS = fill_rule.$(OBJEXT) $(am__objects_1)
-fill_rule_OBJECTS = $(am_fill_rule_OBJECTS)
-fill_rule_LDADD = $(LDADD)
-am_imagediff_OBJECTS = imagediff.$(OBJEXT) $(am__objects_1)
-imagediff_OBJECTS = $(am_imagediff_OBJECTS)
-imagediff_LDADD = $(LDADD)
-am_leaky_polygon_OBJECTS = leaky_polygon.$(OBJEXT) $(am__objects_1)
-leaky_polygon_OBJECTS = $(am_leaky_polygon_OBJECTS)
-leaky_polygon_LDADD = $(LDADD)
-am_line_width_OBJECTS = line_width.$(OBJEXT) $(am__objects_1)
-line_width_OBJECTS = $(am_line_width_OBJECTS)
-line_width_LDADD = $(LDADD)
-am_linear_gradient_OBJECTS = linear_gradient.$(OBJEXT) \
- $(am__objects_1)
-linear_gradient_OBJECTS = $(am_linear_gradient_OBJECTS)
-linear_gradient_LDADD = $(LDADD)
-am_move_to_show_surface_OBJECTS = move_to_show_surface.$(OBJEXT) \
- $(am__objects_1)
-move_to_show_surface_OBJECTS = $(am_move_to_show_surface_OBJECTS)
-move_to_show_surface_LDADD = $(LDADD)
-am_pixman_rotate_OBJECTS = pixman_rotate.$(OBJEXT) $(am__objects_1)
-pixman_rotate_OBJECTS = $(am_pixman_rotate_OBJECTS)
-pixman_rotate_LDADD = $(LDADD)
-am_text_cache_crash_OBJECTS = text_cache_crash.$(OBJEXT) \
- $(am__objects_1)
-text_cache_crash_OBJECTS = $(am_text_cache_crash_OBJECTS)
-text_cache_crash_LDADD = $(LDADD)
-am_text_rotate_OBJECTS = text_rotate.$(OBJEXT) $(am__objects_1)
-text_rotate_OBJECTS = $(am_text_rotate_OBJECTS)
-text_rotate_LDADD = $(LDADD)
+clip_nesting_SOURCES = clip-nesting.c
+clip_nesting_OBJECTS = clip-nesting.$(OBJEXT)
+am__DEPENDENCIES_1 = libcairotest.la $(top_builddir)/src/libcairo.la
+clip_nesting_DEPENDENCIES = $(am__DEPENDENCIES_1)
+clip_twice_SOURCES = clip-twice.c
+clip_twice_OBJECTS = clip-twice.$(OBJEXT)
+clip_twice_DEPENDENCIES = $(am__DEPENDENCIES_1)
+create_for_png_SOURCES = create-for-png.c
+create_for_png_OBJECTS = create-for-png.$(OBJEXT)
+create_for_png_DEPENDENCIES = $(am__DEPENDENCIES_1)
+fill_and_stroke_SOURCES = fill-and-stroke.c
+fill_and_stroke_OBJECTS = fill-and-stroke.$(OBJEXT)
+fill_and_stroke_DEPENDENCIES = $(am__DEPENDENCIES_1)
+fill_rule_SOURCES = fill-rule.c
+fill_rule_OBJECTS = fill-rule.$(OBJEXT)
+fill_rule_DEPENDENCIES = $(am__DEPENDENCIES_1)
+filter_nearest_offset_SOURCES = filter-nearest-offset.c
+filter_nearest_offset_OBJECTS = filter-nearest-offset.$(OBJEXT)
+filter_nearest_offset_DEPENDENCIES = $(am__DEPENDENCIES_1)
+get_and_set_SOURCES = get-and-set.c
+get_and_set_OBJECTS = get-and-set.$(OBJEXT)
+get_and_set_DEPENDENCIES = $(am__DEPENDENCIES_1)
+gradient_alpha_SOURCES = gradient-alpha.c
+gradient_alpha_OBJECTS = gradient-alpha.$(OBJEXT)
+gradient_alpha_DEPENDENCIES = $(am__DEPENDENCIES_1)
+imagediff_SOURCES = imagediff.c
+imagediff_OBJECTS = imagediff.$(OBJEXT)
+imagediff_DEPENDENCIES = $(am__DEPENDENCIES_1)
+leaky_polygon_SOURCES = leaky-polygon.c
+leaky_polygon_OBJECTS = leaky-polygon.$(OBJEXT)
+leaky_polygon_DEPENDENCIES = $(am__DEPENDENCIES_1)
+line_width_SOURCES = line-width.c
+line_width_OBJECTS = line-width.$(OBJEXT)
+line_width_DEPENDENCIES = $(am__DEPENDENCIES_1)
+linear_gradient_SOURCES = linear-gradient.c
+linear_gradient_OBJECTS = linear-gradient.$(OBJEXT)
+linear_gradient_DEPENDENCIES = $(am__DEPENDENCIES_1)
+mask_SOURCES = mask.c
+mask_OBJECTS = mask.$(OBJEXT)
+mask_DEPENDENCIES = $(am__DEPENDENCIES_1)
+move_to_show_surface_SOURCES = move-to-show-surface.c
+move_to_show_surface_OBJECTS = move-to-show-surface.$(OBJEXT)
+move_to_show_surface_DEPENDENCIES = $(am__DEPENDENCIES_1)
+paint_SOURCES = paint.c
+paint_OBJECTS = paint.$(OBJEXT)
+paint_DEPENDENCIES = $(am__DEPENDENCIES_1)
+paint_with_alpha_SOURCES = paint-with-alpha.c
+paint_with_alpha_OBJECTS = paint-with-alpha.$(OBJEXT)
+paint_with_alpha_DEPENDENCIES = $(am__DEPENDENCIES_1)
+path_data_SOURCES = path-data.c
+path_data_OBJECTS = path-data.$(OBJEXT)
+path_data_DEPENDENCIES = $(am__DEPENDENCIES_1)
+pdf_clip_SOURCES = pdf-clip.c
+pdf_clip_OBJECTS = pdf-clip.$(OBJEXT)
+pdf_clip_DEPENDENCIES = $(am__DEPENDENCIES_1)
+pdf_surface_SOURCES = pdf-surface.c
+pdf_surface_OBJECTS = pdf-surface.$(OBJEXT)
+pdf_surface_DEPENDENCIES = $(am__DEPENDENCIES_1)
+pixman_rotate_SOURCES = pixman-rotate.c
+pixman_rotate_OBJECTS = pixman-rotate.$(OBJEXT)
+pixman_rotate_DEPENDENCIES = $(am__DEPENDENCIES_1)
+ps_surface_SOURCES = ps-surface.c
+ps_surface_OBJECTS = ps-surface.$(OBJEXT)
+ps_surface_DEPENDENCIES = $(am__DEPENDENCIES_1)
+rel_path_SOURCES = rel-path.c
+rel_path_OBJECTS = rel-path.$(OBJEXT)
+rel_path_DEPENDENCIES = $(am__DEPENDENCIES_1)
+scale_source_surface_paint_SOURCES = scale-source-surface-paint.c
+scale_source_surface_paint_OBJECTS = \
+ scale-source-surface-paint.$(OBJEXT)
+scale_source_surface_paint_DEPENDENCIES = $(am__DEPENDENCIES_1)
+select_font_no_show_text_SOURCES = select-font-no-show-text.c
+select_font_no_show_text_OBJECTS = select-font-no-show-text.$(OBJEXT)
+select_font_no_show_text_DEPENDENCIES = $(am__DEPENDENCIES_1)
+self_copy_SOURCES = self-copy.c
+self_copy_OBJECTS = self-copy.$(OBJEXT)
+self_copy_DEPENDENCIES = $(am__DEPENDENCIES_1)
+self_intersecting_SOURCES = self-intersecting.c
+self_intersecting_OBJECTS = self-intersecting.$(OBJEXT)
+self_intersecting_DEPENDENCIES = $(am__DEPENDENCIES_1)
+set_source_SOURCES = set-source.c
+set_source_OBJECTS = set-source.$(OBJEXT)
+set_source_DEPENDENCIES = $(am__DEPENDENCIES_1)
+source_clip_SOURCES = source-clip.c
+source_clip_OBJECTS = source-clip.$(OBJEXT)
+source_clip_DEPENDENCIES = $(am__DEPENDENCIES_1)
+source_surface_scale_paint_SOURCES = source-surface-scale-paint.c
+source_surface_scale_paint_OBJECTS = \
+ source-surface-scale-paint.$(OBJEXT)
+source_surface_scale_paint_DEPENDENCIES = $(am__DEPENDENCIES_1)
+surface_finish_twice_SOURCES = surface-finish-twice.c
+surface_finish_twice_OBJECTS = surface-finish-twice.$(OBJEXT)
+surface_finish_twice_DEPENDENCIES = $(am__DEPENDENCIES_1)
+surface_pattern_SOURCES = surface-pattern.c
+surface_pattern_OBJECTS = surface-pattern.$(OBJEXT)
+surface_pattern_DEPENDENCIES = $(am__DEPENDENCIES_1)
+text_cache_crash_SOURCES = text-cache-crash.c
+text_cache_crash_OBJECTS = text-cache-crash.$(OBJEXT)
+text_cache_crash_DEPENDENCIES = $(am__DEPENDENCIES_1)
+text_rotate_SOURCES = text-rotate.c
+text_rotate_OBJECTS = text-rotate.$(OBJEXT)
+text_rotate_DEPENDENCIES = $(am__DEPENDENCIES_1)
+transforms_SOURCES = transforms.c
+transforms_OBJECTS = transforms.$(OBJEXT)
+transforms_DEPENDENCIES = $(am__DEPENDENCIES_1)
+translate_show_surface_SOURCES = translate-show-surface.c
+translate_show_surface_OBJECTS = translate-show-surface.$(OBJEXT)
+translate_show_surface_DEPENDENCIES = $(am__DEPENDENCIES_1)
+trap_clip_SOURCES = trap-clip.c
+trap_clip_OBJECTS = trap-clip.$(OBJEXT)
+trap_clip_DEPENDENCIES = $(am__DEPENDENCIES_1)
+user_data_SOURCES = user-data.c
+user_data_OBJECTS = user-data.$(OBJEXT)
+user_data_DEPENDENCIES = $(am__DEPENDENCIES_1)
+xlib_surface_SOURCES = xlib-surface.c
+xlib_surface_OBJECTS = xlib-surface.$(OBJEXT)
+xlib_surface_DEPENDENCIES = $(am__DEPENDENCIES_1)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@@ -105,18 +209,30 @@ LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) \
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link --tag=CC $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = $(clip_twice_SOURCES) $(coverage_SOURCES) \
- $(fill_rule_SOURCES) $(imagediff_SOURCES) \
- $(leaky_polygon_SOURCES) $(line_width_SOURCES) \
- $(linear_gradient_SOURCES) $(move_to_show_surface_SOURCES) \
- $(pixman_rotate_SOURCES) $(text_cache_crash_SOURCES) \
- $(text_rotate_SOURCES)
-DIST_SOURCES = $(clip_twice_SOURCES) $(coverage_SOURCES) \
- $(fill_rule_SOURCES) $(imagediff_SOURCES) \
- $(leaky_polygon_SOURCES) $(line_width_SOURCES) \
- $(linear_gradient_SOURCES) $(move_to_show_surface_SOURCES) \
- $(pixman_rotate_SOURCES) $(text_cache_crash_SOURCES) \
- $(text_rotate_SOURCES)
+SOURCES = $(libcairotest_la_SOURCES) clip-nesting.c clip-twice.c \
+ create-for-png.c fill-and-stroke.c fill-rule.c \
+ filter-nearest-offset.c get-and-set.c gradient-alpha.c \
+ imagediff.c leaky-polygon.c line-width.c linear-gradient.c \
+ mask.c move-to-show-surface.c paint.c paint-with-alpha.c \
+ path-data.c pdf-clip.c pdf-surface.c pixman-rotate.c \
+ ps-surface.c rel-path.c scale-source-surface-paint.c \
+ select-font-no-show-text.c self-copy.c self-intersecting.c \
+ set-source.c source-clip.c source-surface-scale-paint.c \
+ surface-finish-twice.c surface-pattern.c text-cache-crash.c \
+ text-rotate.c transforms.c translate-show-surface.c \
+ trap-clip.c user-data.c xlib-surface.c
+DIST_SOURCES = $(libcairotest_la_SOURCES) clip-nesting.c clip-twice.c \
+ create-for-png.c fill-and-stroke.c fill-rule.c \
+ filter-nearest-offset.c get-and-set.c gradient-alpha.c \
+ imagediff.c leaky-polygon.c line-width.c linear-gradient.c \
+ mask.c move-to-show-surface.c paint.c paint-with-alpha.c \
+ path-data.c pdf-clip.c pdf-surface.c pixman-rotate.c \
+ ps-surface.c rel-path.c scale-source-surface-paint.c \
+ select-font-no-show-text.c self-copy.c self-intersecting.c \
+ set-source.c source-clip.c source-surface-scale-paint.c \
+ surface-finish-twice.c surface-pattern.c text-cache-crash.c \
+ text-rotate.c transforms.c translate-show-surface.c \
+ trap-clip.c user-data.c xlib-surface.c
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -139,8 +255,8 @@ CAIRO_HAS_GLITZ_SURFACE_FALSE = @CAIRO_HAS_GLITZ_SURFACE_FALSE@
CAIRO_HAS_GLITZ_SURFACE_TRUE = @CAIRO_HAS_GLITZ_SURFACE_TRUE@
CAIRO_HAS_PDF_SURFACE_FALSE = @CAIRO_HAS_PDF_SURFACE_FALSE@
CAIRO_HAS_PDF_SURFACE_TRUE = @CAIRO_HAS_PDF_SURFACE_TRUE@
-CAIRO_HAS_PNG_SURFACE_FALSE = @CAIRO_HAS_PNG_SURFACE_FALSE@
-CAIRO_HAS_PNG_SURFACE_TRUE = @CAIRO_HAS_PNG_SURFACE_TRUE@
+CAIRO_HAS_PNG_FUNCTIONS_FALSE = @CAIRO_HAS_PNG_FUNCTIONS_FALSE@
+CAIRO_HAS_PNG_FUNCTIONS_TRUE = @CAIRO_HAS_PNG_FUNCTIONS_TRUE@
CAIRO_HAS_PS_SURFACE_FALSE = @CAIRO_HAS_PS_SURFACE_FALSE@
CAIRO_HAS_PS_SURFACE_TRUE = @CAIRO_HAS_PS_SURFACE_TRUE@
CAIRO_HAS_QUARTZ_SURFACE_FALSE = @CAIRO_HAS_QUARTZ_SURFACE_FALSE@
@@ -218,14 +334,13 @@ PIXMAN_CFLAGS = @PIXMAN_CFLAGS@
PIXMAN_LIBS = @PIXMAN_LIBS@
PKG_CONFIG = @PKG_CONFIG@
PNG_CFLAGS = @PNG_CFLAGS@
+PNG_FUNCTIONS_FEATURE = @PNG_FUNCTIONS_FEATURE@
PNG_LIBS = @PNG_LIBS@
PNG_REQUIRES = @PNG_REQUIRES@
-PNG_SURFACE_FEATURE = @PNG_SURFACE_FEATURE@
PS_LIBS = @PS_LIBS@
PS_SURFACE_FEATURE = @PS_SURFACE_FEATURE@
QUARTZ_SURFACE_FEATURE = @QUARTZ_SURFACE_FEATURE@
RANLIB = @RANLIB@
-SANITY_CHECKING_FEATURE = @SANITY_CHECKING_FEATURE@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
@@ -288,86 +403,149 @@ sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
-# All new test cases go here
-TESTS = \
-fill_rule \
-leaky_polygon \
-line_width \
-linear_gradient \
-move_to_show_surface \
-text_cache_crash \
-text_rotate \
-coverage \
-clip_twice \
-pixman_rotate
-
-
-# And all new tests go here too. I really don't like having to repeat
-# this list. Anyone know a good way to avoid it? Can I use a wildcard
-# here?
+# All test cases go here
+TESTS = clip-nesting clip-twice create-for-png fill-and-stroke \
+ fill-rule filter-nearest-offset get-and-set gradient-alpha \
+ leaky-polygon line-width linear-gradient mask \
+ move-to-show-surface paint paint-with-alpha path-data \
+ pixman-rotate scale-source-surface-paint \
+ select-font-no-show-text self-copy self-intersecting \
+ set-source source-clip source-surface-scale-paint \
+ surface-finish-twice surface-pattern text-cache-crash \
+ text-rotate transforms translate-show-surface trap-clip \
+ user-data rel-path $(am__append_1) $(am__append_2) \
+ $(am__append_3)
+
+# All tests which have a reference image go here.
+# I really don't like having to repeat this list. Anyone know a good
+# way to avoid it? Can I use a wildcard here?
EXTRA_DIST = \
-fill_rule-ref.png \
-leaky_polygon-ref.png \
-line_width-ref.png \
-linear_gradient-ref.png \
-move_to_show_surface-ref.png \
-coverage-ref.png \
-clip_twice-ref.png \
-pixman_rotate-ref.png \
-romedalen.png
-
-
-# Once we can draw the text_rotate.c test case correctly, we should
-# create and add text_rotate-ref.png to the list of reference PNGs.
-
-# This list is only for known bugs (not regressions). We do need to
-# fix these before the next release, but they are expected to fail for
-# now, so they don't need to hold up any new code commit.
+clip-nesting-ref.png \
+clip-twice-ref.png \
+create-for-png-ref.png \
+fill-and-stroke-ref.png \
+fill-rule-ref.png \
+filter-nearest-offset-ref.png \
+gradient-alpha-ref.png \
+leaky-polygon-ref.png \
+line-width-ref.png \
+linear-gradient-ref.png \
+mask-ref.png \
+move-to-show-surface-ref.png \
+paint-ref.png \
+paint-with-alpha-ref.png \
+path-data-ref.png \
+pixman-rotate-ref.png \
+romedalen.png \
+self-copy-ref.png \
+self-intersecting-ref.png \
+scale-source-surface-paint-ref.png \
+set-source-ref.png \
+source-clip-ref.png \
+source-surface-scale-paint-ref.png \
+surface-pattern-ref.png \
+transforms-ref.png \
+translate-show-surface-ref.png \
+trap-clip-ref.png \
+rel-path-ref.png
+
+
+# Any test for which the code committed to CVS is expected to fail
+# should be listed here.
+#
+# This way, we can avoid being bothered by reports of bugs we are
+# aware of, but users can still report when tests start behaving in
+# unexpected ways on their system.
#
-# When new bugs are found in committed code they can be listed
-# here. New failures due to local, uncommitted code changes are
-# regression bugs that should not be listed here. Instead they should
-# be fixed before the code is committed.
+# Of course, before any "release" of cairo we should eliminate
+# everything from this list by fixing the bugs. (We don't necessarily
+# have to be that strict for "snapshots" though.)
+#
+# Also, any test listed here should call cairo_test_expect_failure and
+# provide an explanation for the expected failure.
XFAIL_TESTS = \
-move_to_show_surface \
-pixman_rotate \
-text_rotate
+filter-nearest-offset \
+pixman-rotate \
+self-intersecting \
+source-surface-scale-paint \
+text-rotate
# We're using _GNU_SOURCE to get the prototype for asprintf. This may
# not be the most portable approach, but it is pragmatic and I'm
# willing to do something cleaner as soon as it causes someone a
# problem.
-INCLUDES = -D_GNU_SOURCE -I$(srcdir) $(CAIRO_CFLAGS) -I$(srcdir)/../src
-AM_LDFLAGS = $(CAIRO_LIBS) ../src/libcairo.la
-cairo_test_lib = \
-buffer_diff.c \
-buffer_diff.h \
-cairo_test.c \
-cairo_test.h \
-read_png.c \
-read_png.h \
-write_png.c \
-write_png.h \
+INCLUDES = \
+ -D_GNU_SOURCE \
+ $(CAIRO_CFLAGS) \
+ -I$(srcdir) \
+ -I$(top_srcdir)/src \
+ -I$(top_builddir)/src
+
+noinst_LTLIBRARIES = libcairotest.la
+libcairotest_la_SOURCES = \
+buffer-diff.c \
+buffer-diff.h \
+cairo-test.c \
+cairo-test.h \
+read-png.c \
+read-png.h \
+write-png.c \
+write-png.h \
xmalloc.c \
xmalloc.h
+LDADDS = libcairotest.la $(top_builddir)/src/libcairo.la
# ARGH! I have to repeat the list of tests a third time. Maybe it's
# time to break down and auto-generate the Makefile.am or something
# from autogen.sh. My, but this is painful...
-fill_rule_SOURCES = fill_rule.c $(cairo_test_lib)
-leaky_polygon_SOURCES = leaky_polygon.c $(cairo_test_lib)
-line_width_SOURCES = line_width.c $(cairo_test_lib)
-linear_gradient_SOURCES = linear_gradient.c $(cairo_test_lib)
-move_to_show_surface_SOURCES = move_to_show_surface.c $(cairo_test_lib)
-text_cache_crash_SOURCES = text_cache_crash.c $(cairo_test_lib)
-text_rotate_SOURCES = text_rotate.c $(cairo_test_lib)
-coverage_SOURCES = coverage.c $(cairo_test_lib)
-clip_twice_SOURCES = clip_twice.c $(cairo_test_lib)
-pixman_rotate_SOURCES = pixman_rotate.c $(cairo_test_lib)
-imagediff_SOURCES = imagediff.c $(cairo_test_lib)
-CLEANFILES = *-out.png *-diff.png *.log
+clip_nesting_LDADD = $(LDADDS)
+clip_twice_LDADD = $(LDADDS)
+create_for_png_LDADD = $(LDADDS)
+fill_and_stroke_LDADD = $(LDADDS)
+fill_rule_LDADD = $(LDADDS)
+filter_nearest_offset_LDADD = $(LDADDS)
+get_and_set_LDADD = $(LDADDS)
+gradient_alpha_LDADD = $(LDADDS)
+leaky_polygon_LDADD = $(LDADDS)
+line_width_LDADD = $(LDADDS)
+linear_gradient_LDADD = $(LDADDS)
+mask_LDADD = $(LDADDS)
+move_to_show_surface_LDADD = $(LDADDS)
+paint_LDADD = $(LDADDS)
+paint_with_alpha_LDADD = $(LDADDS)
+path_data_LDADD = $(LDADDS)
+pdf_surface_LDADD = $(LDADDS)
+pdf_clip_LDADD = $(LDADDS)
+ps_surface_LDADD = $(LDADDS)
+pixman_rotate_LDADD = $(LDADDS)
+scale_source_surface_paint_LDADD = $(LDADDS)
+select_font_no_show_text_LDADD = $(LDADDS)
+self_copy_LDADD = $(LDADDS)
+self_intersecting_LDADD = $(LDADDS)
+set_source_LDADD = $(LDADDS)
+source_clip_LDADD = $(LDADDS)
+source_surface_scale_paint_LDADD = $(LDADDS)
+surface_finish_twice_LDADD = $(LDADDS)
+surface_pattern_LDADD = $(LDADDS)
+text_cache_crash_LDADD = $(LDADDS)
+text_rotate_LDADD = $(LDADDS)
+transforms_LDADD = $(LDADDS)
+translate_show_surface_LDADD = $(LDADDS)
+trap_clip_LDADD = $(LDADDS)
+user_data_LDADD = $(LDADDS)
+rel_path_LDADD = $(LDADDS)
+xlib_surface_LDADD = $(LDADDS)
+imagediff_LDADD = $(LDADDS)
+CLEANFILES = \
+ *-out.png \
+ *-diff.png \
+ *.log \
+ ps-surface.ps \
+ pdf-surface.pdf \
+ pdf-clip.pdf
+
all: all-am
.SUFFIXES:
@@ -402,6 +580,17 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libcairotest.la: $(libcairotest_la_OBJECTS) $(libcairotest_la_DEPENDENCIES)
+ $(LINK) $(libcairotest_la_LDFLAGS) $(libcairotest_la_OBJECTS) $(libcairotest_la_LIBADD) $(LIBS)
+
clean-checkPROGRAMS:
@list='$(check_PROGRAMS)'; for p in $$list; do \
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
@@ -415,39 +604,120 @@ clean-noinstPROGRAMS:
echo " rm -f $$p $$f"; \
rm -f $$p $$f ; \
done
-clip_twice$(EXEEXT): $(clip_twice_OBJECTS) $(clip_twice_DEPENDENCIES)
- @rm -f clip_twice$(EXEEXT)
+clip-nesting$(EXEEXT): $(clip_nesting_OBJECTS) $(clip_nesting_DEPENDENCIES)
+ @rm -f clip-nesting$(EXEEXT)
+ $(LINK) $(clip_nesting_LDFLAGS) $(clip_nesting_OBJECTS) $(clip_nesting_LDADD) $(LIBS)
+clip-twice$(EXEEXT): $(clip_twice_OBJECTS) $(clip_twice_DEPENDENCIES)
+ @rm -f clip-twice$(EXEEXT)
$(LINK) $(clip_twice_LDFLAGS) $(clip_twice_OBJECTS) $(clip_twice_LDADD) $(LIBS)
-coverage$(EXEEXT): $(coverage_OBJECTS) $(coverage_DEPENDENCIES)
- @rm -f coverage$(EXEEXT)
- $(LINK) $(coverage_LDFLAGS) $(coverage_OBJECTS) $(coverage_LDADD) $(LIBS)
-fill_rule$(EXEEXT): $(fill_rule_OBJECTS) $(fill_rule_DEPENDENCIES)
- @rm -f fill_rule$(EXEEXT)
+create-for-png$(EXEEXT): $(create_for_png_OBJECTS) $(create_for_png_DEPENDENCIES)
+ @rm -f create-for-png$(EXEEXT)
+ $(LINK) $(create_for_png_LDFLAGS) $(create_for_png_OBJECTS) $(create_for_png_LDADD) $(LIBS)
+fill-and-stroke$(EXEEXT): $(fill_and_stroke_OBJECTS) $(fill_and_stroke_DEPENDENCIES)
+ @rm -f fill-and-stroke$(EXEEXT)
+ $(LINK) $(fill_and_stroke_LDFLAGS) $(fill_and_stroke_OBJECTS) $(fill_and_stroke_LDADD) $(LIBS)
+fill-rule$(EXEEXT): $(fill_rule_OBJECTS) $(fill_rule_DEPENDENCIES)
+ @rm -f fill-rule$(EXEEXT)
$(LINK) $(fill_rule_LDFLAGS) $(fill_rule_OBJECTS) $(fill_rule_LDADD) $(LIBS)
+filter-nearest-offset$(EXEEXT): $(filter_nearest_offset_OBJECTS) $(filter_nearest_offset_DEPENDENCIES)
+ @rm -f filter-nearest-offset$(EXEEXT)
+ $(LINK) $(filter_nearest_offset_LDFLAGS) $(filter_nearest_offset_OBJECTS) $(filter_nearest_offset_LDADD) $(LIBS)
+get-and-set$(EXEEXT): $(get_and_set_OBJECTS) $(get_and_set_DEPENDENCIES)
+ @rm -f get-and-set$(EXEEXT)
+ $(LINK) $(get_and_set_LDFLAGS) $(get_and_set_OBJECTS) $(get_and_set_LDADD) $(LIBS)
+gradient-alpha$(EXEEXT): $(gradient_alpha_OBJECTS) $(gradient_alpha_DEPENDENCIES)
+ @rm -f gradient-alpha$(EXEEXT)
+ $(LINK) $(gradient_alpha_LDFLAGS) $(gradient_alpha_OBJECTS) $(gradient_alpha_LDADD) $(LIBS)
imagediff$(EXEEXT): $(imagediff_OBJECTS) $(imagediff_DEPENDENCIES)
@rm -f imagediff$(EXEEXT)
$(LINK) $(imagediff_LDFLAGS) $(imagediff_OBJECTS) $(imagediff_LDADD) $(LIBS)
-leaky_polygon$(EXEEXT): $(leaky_polygon_OBJECTS) $(leaky_polygon_DEPENDENCIES)
- @rm -f leaky_polygon$(EXEEXT)
+leaky-polygon$(EXEEXT): $(leaky_polygon_OBJECTS) $(leaky_polygon_DEPENDENCIES)
+ @rm -f leaky-polygon$(EXEEXT)
$(LINK) $(leaky_polygon_LDFLAGS) $(leaky_polygon_OBJECTS) $(leaky_polygon_LDADD) $(LIBS)
-line_width$(EXEEXT): $(line_width_OBJECTS) $(line_width_DEPENDENCIES)
- @rm -f line_width$(EXEEXT)
+line-width$(EXEEXT): $(line_width_OBJECTS) $(line_width_DEPENDENCIES)
+ @rm -f line-width$(EXEEXT)
$(LINK) $(line_width_LDFLAGS) $(line_width_OBJECTS) $(line_width_LDADD) $(LIBS)
-linear_gradient$(EXEEXT): $(linear_gradient_OBJECTS) $(linear_gradient_DEPENDENCIES)
- @rm -f linear_gradient$(EXEEXT)
+linear-gradient$(EXEEXT): $(linear_gradient_OBJECTS) $(linear_gradient_DEPENDENCIES)
+ @rm -f linear-gradient$(EXEEXT)
$(LINK) $(linear_gradient_LDFLAGS) $(linear_gradient_OBJECTS) $(linear_gradient_LDADD) $(LIBS)
-move_to_show_surface$(EXEEXT): $(move_to_show_surface_OBJECTS) $(move_to_show_surface_DEPENDENCIES)
- @rm -f move_to_show_surface$(EXEEXT)
+mask$(EXEEXT): $(mask_OBJECTS) $(mask_DEPENDENCIES)
+ @rm -f mask$(EXEEXT)
+ $(LINK) $(mask_LDFLAGS) $(mask_OBJECTS) $(mask_LDADD) $(LIBS)
+move-to-show-surface$(EXEEXT): $(move_to_show_surface_OBJECTS) $(move_to_show_surface_DEPENDENCIES)
+ @rm -f move-to-show-surface$(EXEEXT)
$(LINK) $(move_to_show_surface_LDFLAGS) $(move_to_show_surface_OBJECTS) $(move_to_show_surface_LDADD) $(LIBS)
-pixman_rotate$(EXEEXT): $(pixman_rotate_OBJECTS) $(pixman_rotate_DEPENDENCIES)
- @rm -f pixman_rotate$(EXEEXT)
+paint$(EXEEXT): $(paint_OBJECTS) $(paint_DEPENDENCIES)
+ @rm -f paint$(EXEEXT)
+ $(LINK) $(paint_LDFLAGS) $(paint_OBJECTS) $(paint_LDADD) $(LIBS)
+paint-with-alpha$(EXEEXT): $(paint_with_alpha_OBJECTS) $(paint_with_alpha_DEPENDENCIES)
+ @rm -f paint-with-alpha$(EXEEXT)
+ $(LINK) $(paint_with_alpha_LDFLAGS) $(paint_with_alpha_OBJECTS) $(paint_with_alpha_LDADD) $(LIBS)
+path-data$(EXEEXT): $(path_data_OBJECTS) $(path_data_DEPENDENCIES)
+ @rm -f path-data$(EXEEXT)
+ $(LINK) $(path_data_LDFLAGS) $(path_data_OBJECTS) $(path_data_LDADD) $(LIBS)
+pdf-clip$(EXEEXT): $(pdf_clip_OBJECTS) $(pdf_clip_DEPENDENCIES)
+ @rm -f pdf-clip$(EXEEXT)
+ $(LINK) $(pdf_clip_LDFLAGS) $(pdf_clip_OBJECTS) $(pdf_clip_LDADD) $(LIBS)
+pdf-surface$(EXEEXT): $(pdf_surface_OBJECTS) $(pdf_surface_DEPENDENCIES)
+ @rm -f pdf-surface$(EXEEXT)
+ $(LINK) $(pdf_surface_LDFLAGS) $(pdf_surface_OBJECTS) $(pdf_surface_LDADD) $(LIBS)
+pixman-rotate$(EXEEXT): $(pixman_rotate_OBJECTS) $(pixman_rotate_DEPENDENCIES)
+ @rm -f pixman-rotate$(EXEEXT)
$(LINK) $(pixman_rotate_LDFLAGS) $(pixman_rotate_OBJECTS) $(pixman_rotate_LDADD) $(LIBS)
-text_cache_crash$(EXEEXT): $(text_cache_crash_OBJECTS) $(text_cache_crash_DEPENDENCIES)
- @rm -f text_cache_crash$(EXEEXT)
+ps-surface$(EXEEXT): $(ps_surface_OBJECTS) $(ps_surface_DEPENDENCIES)
+ @rm -f ps-surface$(EXEEXT)
+ $(LINK) $(ps_surface_LDFLAGS) $(ps_surface_OBJECTS) $(ps_surface_LDADD) $(LIBS)
+rel-path$(EXEEXT): $(rel_path_OBJECTS) $(rel_path_DEPENDENCIES)
+ @rm -f rel-path$(EXEEXT)
+ $(LINK) $(rel_path_LDFLAGS) $(rel_path_OBJECTS) $(rel_path_LDADD) $(LIBS)
+scale-source-surface-paint$(EXEEXT): $(scale_source_surface_paint_OBJECTS) $(scale_source_surface_paint_DEPENDENCIES)
+ @rm -f scale-source-surface-paint$(EXEEXT)
+ $(LINK) $(scale_source_surface_paint_LDFLAGS) $(scale_source_surface_paint_OBJECTS) $(scale_source_surface_paint_LDADD) $(LIBS)
+select-font-no-show-text$(EXEEXT): $(select_font_no_show_text_OBJECTS) $(select_font_no_show_text_DEPENDENCIES)
+ @rm -f select-font-no-show-text$(EXEEXT)
+ $(LINK) $(select_font_no_show_text_LDFLAGS) $(select_font_no_show_text_OBJECTS) $(select_font_no_show_text_LDADD) $(LIBS)
+self-copy$(EXEEXT): $(self_copy_OBJECTS) $(self_copy_DEPENDENCIES)
+ @rm -f self-copy$(EXEEXT)
+ $(LINK) $(self_copy_LDFLAGS) $(self_copy_OBJECTS) $(self_copy_LDADD) $(LIBS)
+self-intersecting$(EXEEXT): $(self_intersecting_OBJECTS) $(self_intersecting_DEPENDENCIES)
+ @rm -f self-intersecting$(EXEEXT)
+ $(LINK) $(self_intersecting_LDFLAGS) $(self_intersecting_OBJECTS) $(self_intersecting_LDADD) $(LIBS)
+set-source$(EXEEXT): $(set_source_OBJECTS) $(set_source_DEPENDENCIES)
+ @rm -f set-source$(EXEEXT)
+ $(LINK) $(set_source_LDFLAGS) $(set_source_OBJECTS) $(set_source_LDADD) $(LIBS)
+source-clip$(EXEEXT): $(source_clip_OBJECTS) $(source_clip_DEPENDENCIES)
+ @rm -f source-clip$(EXEEXT)
+ $(LINK) $(source_clip_LDFLAGS) $(source_clip_OBJECTS) $(source_clip_LDADD) $(LIBS)
+source-surface-scale-paint$(EXEEXT): $(source_surface_scale_paint_OBJECTS) $(source_surface_scale_paint_DEPENDENCIES)
+ @rm -f source-surface-scale-paint$(EXEEXT)
+ $(LINK) $(source_surface_scale_paint_LDFLAGS) $(source_surface_scale_paint_OBJECTS) $(source_surface_scale_paint_LDADD) $(LIBS)
+surface-finish-twice$(EXEEXT): $(surface_finish_twice_OBJECTS) $(surface_finish_twice_DEPENDENCIES)
+ @rm -f surface-finish-twice$(EXEEXT)
+ $(LINK) $(surface_finish_twice_LDFLAGS) $(surface_finish_twice_OBJECTS) $(surface_finish_twice_LDADD) $(LIBS)
+surface-pattern$(EXEEXT): $(surface_pattern_OBJECTS) $(surface_pattern_DEPENDENCIES)
+ @rm -f surface-pattern$(EXEEXT)
+ $(LINK) $(surface_pattern_LDFLAGS) $(surface_pattern_OBJECTS) $(surface_pattern_LDADD) $(LIBS)
+text-cache-crash$(EXEEXT): $(text_cache_crash_OBJECTS) $(text_cache_crash_DEPENDENCIES)
+ @rm -f text-cache-crash$(EXEEXT)
$(LINK) $(text_cache_crash_LDFLAGS) $(text_cache_crash_OBJECTS) $(text_cache_crash_LDADD) $(LIBS)
-text_rotate$(EXEEXT): $(text_rotate_OBJECTS) $(text_rotate_DEPENDENCIES)
- @rm -f text_rotate$(EXEEXT)
+text-rotate$(EXEEXT): $(text_rotate_OBJECTS) $(text_rotate_DEPENDENCIES)
+ @rm -f text-rotate$(EXEEXT)
$(LINK) $(text_rotate_LDFLAGS) $(text_rotate_OBJECTS) $(text_rotate_LDADD) $(LIBS)
+transforms$(EXEEXT): $(transforms_OBJECTS) $(transforms_DEPENDENCIES)
+ @rm -f transforms$(EXEEXT)
+ $(LINK) $(transforms_LDFLAGS) $(transforms_OBJECTS) $(transforms_LDADD) $(LIBS)
+translate-show-surface$(EXEEXT): $(translate_show_surface_OBJECTS) $(translate_show_surface_DEPENDENCIES)
+ @rm -f translate-show-surface$(EXEEXT)
+ $(LINK) $(translate_show_surface_LDFLAGS) $(translate_show_surface_OBJECTS) $(translate_show_surface_LDADD) $(LIBS)
+trap-clip$(EXEEXT): $(trap_clip_OBJECTS) $(trap_clip_DEPENDENCIES)
+ @rm -f trap-clip$(EXEEXT)
+ $(LINK) $(trap_clip_LDFLAGS) $(trap_clip_OBJECTS) $(trap_clip_LDADD) $(LIBS)
+user-data$(EXEEXT): $(user_data_OBJECTS) $(user_data_DEPENDENCIES)
+ @rm -f user-data$(EXEEXT)
+ $(LINK) $(user_data_LDFLAGS) $(user_data_OBJECTS) $(user_data_LDADD) $(LIBS)
+xlib-surface$(EXEEXT): $(xlib_surface_OBJECTS) $(xlib_surface_DEPENDENCIES)
+ @rm -f xlib-surface$(EXEEXT)
+ $(LINK) $(xlib_surface_LDFLAGS) $(xlib_surface_OBJECTS) $(xlib_surface_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -455,22 +725,49 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/buffer_diff.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cairo_test.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clip_twice.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coverage.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fill_rule.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/buffer-diff.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cairo-test.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clip-nesting.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clip-twice.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/create-for-png.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fill-and-stroke.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fill-rule.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filter-nearest-offset.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get-and-set.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gradient-alpha.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imagediff.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/leaky_polygon.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line_width.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linear_gradient.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/move_to_show_surface.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pixman_rotate.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read_png.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/text_cache_crash.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/text_rotate.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/write_png.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmalloc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/leaky-polygon.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line-width.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linear-gradient.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mask.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/move-to-show-surface.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/paint-with-alpha.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/paint.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/path-data.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdf-clip.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdf-surface.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pixman-rotate.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ps-surface.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read-png.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rel-path.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scale-source-surface-paint.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/select-font-no-show-text.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/self-copy.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/self-intersecting.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set-source.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/source-clip.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/source-surface-scale-paint.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/surface-finish-twice.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/surface-pattern.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/text-cache-crash.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/text-rotate.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/transforms.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translate-show-surface.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trap-clip.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/user-data.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/write-png.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xlib-surface.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmalloc.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@@ -655,7 +952,7 @@ check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
-all-am: Makefile $(PROGRAMS)
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS)
installdirs:
install: install-am
install-exec: install-exec-am
@@ -685,7 +982,7 @@ maintainer-clean-generic:
clean: clean-am
clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
- clean-noinstPROGRAMS mostlyclean-am
+ clean-noinstLTLIBRARIES clean-noinstPROGRAMS mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
@@ -735,15 +1032,16 @@ uninstall-am: uninstall-info-am
.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
clean-checkPROGRAMS clean-generic clean-libtool \
- clean-noinstPROGRAMS ctags distclean distclean-compile \
- distclean-generic distclean-libtool distclean-tags distdir dvi \
- dvi-am html html-am info info-am install install-am \
- install-data install-data-am install-exec install-exec-am \
- install-info install-info-am install-man install-strip \
- installcheck installcheck-am installdirs maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-compile \
- mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
- tags uninstall uninstall-am uninstall-info-am
+ clean-noinstLTLIBRARIES clean-noinstPROGRAMS ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-exec \
+ install-exec-am install-info install-info-am install-man \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/test/buffer-diff.c b/test/buffer-diff.c
new file mode 100644
index 0000000..e540d2f
--- /dev/null
+++ b/test/buffer-diff.c
@@ -0,0 +1,150 @@
+/* imagediff - Compare two images
+ *
+ * Copyright © 2004 Richard D. Worth
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of Richard Worth
+ * not be used in advertising or publicity pertaining to distribution
+ * of the software without specific, written prior permission.
+ * Richard Worth makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ *
+ * RICHARD WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL RICHARD WORTH BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Richard D. Worth <richard@theworths.org> */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+
+#include "cairo-test.h"
+
+#include "buffer-diff.h"
+#include "read-png.h"
+#include "write-png.h"
+#include "xmalloc.h"
+
+static void
+xunlink (const char *pathname)
+{
+ if (unlink (pathname) < 0 && errno != ENOENT) {
+ cairo_test_log (" Error: Cannot remove %s: %s\n",
+ pathname, strerror (errno));
+ exit (1);
+ }
+}
+
+int
+buffer_diff (unsigned char *buf_a,
+ unsigned char *buf_b,
+ unsigned char *buf_diff,
+ int width,
+ int height,
+ int stride)
+{
+ int x, y;
+ unsigned char *row_a, *row_b, *row;
+ int pixels_changed = 0;
+
+ for (y = 0; y < height; y++)
+ {
+ row_a = buf_a + y * stride;
+ row_b = buf_b + y * stride;
+ row = buf_diff + y * stride;
+ for (x = 0; x < width; x++)
+ {
+ int channel;
+ unsigned char value_a, value_b;
+ int pixel_differs = 0;
+ for (channel = 0; channel < 4; channel++)
+ {
+ double diff;
+ value_a = row_a[x * 4 + channel];
+ value_b = row_b[x * 4 + channel];
+ if (value_a != value_b)
+ pixel_differs = 1;
+ diff = value_a - value_b;
+ row[x * 4 + channel] = 128 + diff / 3.0;
+ }
+ if (pixel_differs) {
+ pixels_changed++;
+ } else {
+ row[x*4+0] = 0;
+ row[x*4+1] = 0;
+ row[x*4+2] = 0;
+ }
+ row[x * 4 + 3] = 0xff; /* Set ALPHA to 100% (opaque) */
+ }
+ }
+
+ return pixels_changed;
+}
+
+/* Image comparison code courtesy of Richard Worth <richard@theworths.org>
+ * Returns number of pixels changed, (or -1 on error).
+ * Also saves a "diff" image intended to visually show where the
+ * images differ.
+ */
+int
+image_diff (const char *filename_a,
+ const char *filename_b,
+ const char *filename_diff)
+{
+ int pixels_changed;
+ unsigned int width_a, height_a, stride_a;
+ unsigned int width_b, height_b, stride_b;
+ unsigned char *buf_a, *buf_b, *buf_diff;
+ read_png_status_t status;
+
+ status = read_png_argb32 (filename_a, &buf_a, &width_a, &height_a, &stride_a);
+ if (status)
+ return -1;
+
+ status = read_png_argb32 (filename_b, &buf_b, &width_b, &height_b, &stride_b);
+ if (status)
+ return -1;
+
+ if (width_a != width_b ||
+ height_a != height_b ||
+ stride_a != stride_b)
+ {
+ cairo_test_log ("Error: Image size mismatch: (%dx%d@%d) vs. (%dx%d@%d)\n"
+ " for %s vs. %s\n",
+ width_a, height_a, stride_a,
+ width_b, height_b, stride_b,
+ filename_a, filename_b);
+ free (buf_a);
+ free (buf_b);
+ return -1;
+ }
+
+ buf_diff = xcalloc (stride_a * height_a, 1);
+
+ pixels_changed = buffer_diff (buf_a, buf_b, buf_diff,
+ width_a, height_a, stride_a);
+
+ if (pixels_changed) {
+ FILE *png_file = fopen (filename_diff, "wb");
+ write_png_argb32 (buf_diff, png_file, width_a, height_a, stride_a);
+ fclose (png_file);
+ } else {
+ xunlink (filename_diff);
+ }
+
+ free (buf_a);
+ free (buf_b);
+ free (buf_diff);
+
+ return pixels_changed;
+}
diff --git a/test/buffer_diff.h b/test/buffer-diff.h
index 9ee51c3..a02834f 100644
--- a/test/buffer_diff.h
+++ b/test/buffer-diff.h
@@ -26,13 +26,25 @@
#ifndef BUFFER_DIFF_H
#define BUFFER_DIFF_H
-/* Image comparison code courttesy of Richard Worth.
- * Returns number of pixels changed.
- * Also fills out a "diff" image intended to visually show where the
+/* Returns number of pixels changed, (or -1 on error).
+ * Also fills in a "diff" buffer intended to visually show where the
* images differ.
*/
int
-buffer_diff (char *buf_a, char *buf_b, char *buf_diff,
- int width, int height, int stride);
+buffer_diff (unsigned char *buf_a,
+ unsigned char *buf_b,
+ unsigned char *buf_diff,
+ int width,
+ int height,
+ int stride);
+
+/* Returns number of pixels changed, (or -1 on error).
+ * Also saves a "diff" image intended to visually show where the
+ * images differ.
+ */
+int
+image_diff (const char *filename_a,
+ const char *filename_b,
+ const char *filename_diff);
#endif
diff --git a/test/buffer_diff.c b/test/buffer_diff.c
deleted file mode 100644
index 07abd62..0000000
--- a/test/buffer_diff.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* imagediff - Compare two images
- *
- * Copyright © 2004 Richard D. Worth
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of Richard Worth
- * not be used in advertising or publicity pertaining to distribution
- * of the software without specific, written prior permission.
- * Richard Worth makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express
- * or implied warranty.
- *
- * RICHARD WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL RICHARD WORTH BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Richard D. Worth <richard@theworths.org> */
-
-#include "buffer_diff.h"
-
-/* Image comparison code courttesy of Richard Worth.
- * Returns number of pixels changed.
- * Also fills out a "diff" image intended to visually show where the
- * images differ.
- */
-int
-buffer_diff (char *buf_a, char *buf_b, char *buf_diff,
- int width, int height, int stride)
-{
- int x, y;
- int total_pixels_changed = 0;
- unsigned char *row_a, *row_b, *row;
-
- for (y = 0; y < height; y++)
- {
- row_a = buf_a + y * stride;
- row_b = buf_b + y * stride;
- row = buf_diff + y * stride;
- for (x = 0; x < width; x++)
- {
- int channel;
- unsigned char value_a, value_b;
- int pixel_changed = 0;
- for (channel = 0; channel < 4; channel++)
- {
- double diff;
- value_a = row_a[x * 4 + channel];
- value_b = row_b[x * 4 + channel];
- if (value_a != value_b)
- pixel_changed = 1;
- diff = value_a - value_b;
- row[x * 4 + channel] = 128 + diff / 3.0;
- }
- if (pixel_changed) {
- total_pixels_changed++;
- } else {
- row[x*4+0] = 0;
- row[x*4+1] = 0;
- row[x*4+2] = 0;
- }
- row[x * 4 + 3] = 0xff; /* Set ALPHA to 100% (opaque) */
- }
- }
-
- return total_pixels_changed;
-}
diff --git a/test/cairo-test.c b/test/cairo-test.c
new file mode 100644
index 0000000..a17cd6f
--- /dev/null
+++ b/test/cairo-test.c
@@ -0,0 +1,579 @@
+/*
+ * Copyright  2004 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+
+#include "cairo-test.h"
+
+#include "buffer-diff.h"
+#include "read-png.h"
+#include "write-png.h"
+#include "xmalloc.h"
+
+#define CAIRO_TEST_LOG_SUFFIX ".log"
+#define CAIRO_TEST_PNG_SUFFIX "-out.png"
+#define CAIRO_TEST_REF_SUFFIX "-ref.png"
+#define CAIRO_TEST_DIFF_SUFFIX "-diff.png"
+
+/* Static data is messy, but we're coding for tests here, not a
+ * general-purpose library, and it keeps the tests cleaner to avoid a
+ * context object there, (though not a whole lot). */
+FILE *cairo_test_log_file;
+
+void
+cairo_test_log (const char *fmt, ...)
+{
+ va_list va;
+
+ va_start (va, fmt);
+ vfprintf (cairo_test_log_file, fmt, va);
+ va_end (va);
+}
+
+void
+xasprintf (char **strp, const char *fmt, ...)
+{
+#ifdef HAVE_VASPRINTF
+ va_list va;
+ int ret;
+
+ va_start (va, fmt);
+ ret = vasprintf (strp, fmt, va);
+ va_end (va);
+
+ if (ret < 0) {
+ cairo_test_log ("Out of memory\n");
+ exit (1);
+ }
+#else /* !HAVE_VASNPRINTF */
+#define BUF_SIZE 1024
+ va_list va;
+ char buffer[BUF_SIZE];
+ int ret;
+
+ va_start (va, fmt);
+ ret = vsnprintf (buffer, sizeof(buffer), fmt, va);
+ va_end (va);
+
+ if (ret < 0) {
+ cairo_test_log ("Failure in vsnprintf\n");
+ exit (1);
+ }
+
+ if (strlen (buffer) == sizeof(buffer) - 1) {
+ cairo_test_log ("Overflowed fixed buffer\n");
+ exit (1);
+ }
+
+ *strp = strdup (buffer);
+ if (!*strp) {
+ cairo_test_log ("Out of memory\n");
+ exit (1);
+ }
+#endif /* !HAVE_VASNPRINTF */
+}
+
+static void
+xunlink (const char *pathname)
+{
+ if (unlink (pathname) < 0 && errno != ENOENT) {
+ cairo_test_log (" Error: Cannot remove %s: %s\n",
+ pathname, strerror (errno));
+ exit (1);
+ }
+}
+
+typedef cairo_surface_t *
+(*cairo_test_create_target_surface_t) (int width, int height, void **closure);
+
+typedef void
+(*cairo_test_cleanup_target_t) (void *closure);
+
+typedef struct _cairo_test_target
+{
+ const char *name;
+ cairo_test_create_target_surface_t create_target_surface;
+ cairo_test_cleanup_target_t cleanup_target;
+ void *closure;
+} cairo_test_target_t;
+
+static cairo_surface_t *
+create_image_surface (int width, int height, void **closure)
+{
+ int stride = 4 * width;
+ unsigned char *buf;
+
+ *closure = buf = xcalloc (stride * height, 1);
+
+ return cairo_image_surface_create_for_data (buf,
+ CAIRO_FORMAT_ARGB32,
+ width, height, stride);
+}
+
+static void
+cleanup_image (void *closure)
+{
+ unsigned char *buf = closure;
+
+ free (buf);
+}
+
+/* XXX: Someone who knows glitz better than I do should fix this up to
+ * work. */
+#if 0 /* #ifdef CAIRO_HAS_GLITZ_SURFACE */
+static cairo_surface_t *
+create_glitz_surface (int width, int height, void **closure)
+{
+#error Not yet implemented
+}
+
+static void
+cleanup_glitz (cairo_t *cr)
+{
+#error Not yet implemented
+}
+#endif
+
+#if CAIRO_HAS_QUARTZ_SURFACE
+static cairo_surface_t *
+create_quartz_surface (int width, int height, void **closure)
+{
+#error Not yet implemented
+}
+
+static void
+cleanup_quartz (void *closure)
+{
+#error Not yet implemented
+}
+#endif
+
+/* Testing the win32 surface isn't interesting, since for
+ * ARGB images it just chains to the image backend
+ */
+#if 0 && CAIRO_HAS_WIN32_SURFACE
+static cairo_surface_t *
+create_win32_surface (int width, int height, void **closure)
+{
+#error Not yet implemented
+}
+
+static void
+cleanup_win32 (void *closure)
+{
+#error Not yet implemented
+}
+#endif
+
+#if CAIRO_HAS_XCB_SURFACE
+#include "cairo-xcb-xrender.h"
+typedef struct _xcb_target_closure
+{
+ XCBConnection *c;
+ XCBDRAWABLE drawable;
+} xcb_target_closure_t;
+
+/* XXX: This is a nasty hack. Something like this should be in XCB's
+ * bindings for Render, not here in this test. */
+static XCBRenderPICTFORMINFO
+_format_from_cairo(XCBConnection *c, cairo_format_t fmt)
+{
+ XCBRenderPICTFORMINFO ret = {{ 0 }};
+ struct tmpl_t {
+ XCBRenderDIRECTFORMAT direct;
+ CARD8 depth;
+ };
+ static const struct tmpl_t templates[] = {
+ /* CAIRO_FORMAT_ARGB32 */
+ {
+ {
+ 16, 0xff,
+ 8, 0xff,
+ 0, 0xff,
+ 24, 0xff
+ },
+ 32
+ },
+ /* CAIRO_FORMAT_RGB24 */
+ {
+ {
+ 16, 0xff,
+ 8, 0xff,
+ 0, 0xff,
+ 0, 0x00
+ },
+ 24
+ },
+ /* CAIRO_FORMAT_A8 */
+ {
+ {
+ 0, 0x00,
+ 0, 0x00,
+ 0, 0x00,
+ 0, 0xff
+ },
+ 8
+ },
+ /* CAIRO_FORMAT_A1 */
+ {
+ {
+ 0, 0x00,
+ 0, 0x00,
+ 0, 0x00,
+ 0, 0x01
+ },
+ 1
+ },
+ };
+ const struct tmpl_t *tmpl;
+ XCBRenderQueryPictFormatsRep *r;
+ XCBRenderPICTFORMINFOIter fi;
+
+ if(fmt < 0 || fmt >= (sizeof(templates) / sizeof(*templates)))
+ return ret;
+ tmpl = templates + fmt;
+
+ r = XCBRenderQueryPictFormatsReply(c, XCBRenderQueryPictFormats(c), 0);
+ if(!r)
+ return ret;
+
+ for(fi = XCBRenderQueryPictFormatsFormatsIter(r); fi.rem; XCBRenderPICTFORMINFONext(&fi))
+ {
+ const XCBRenderDIRECTFORMAT *t, *f;
+ if(fi.data->type != XCBRenderPictTypeDirect)
+ continue;
+ if(fi.data->depth != tmpl->depth)
+ continue;
+ t = &tmpl->direct;
+ f = &fi.data->direct;
+ if(t->red_mask && (t->red_mask != f->red_mask || t->red_shift != f->red_shift))
+ continue;
+ if(t->green_mask && (t->green_mask != f->green_mask || t->green_shift != f->green_shift))
+ continue;
+ if(t->blue_mask && (t->blue_mask != f->blue_mask || t->blue_shift != f->blue_shift))
+ continue;
+ if(t->alpha_mask && (t->alpha_mask != f->alpha_mask || t->alpha_shift != f->alpha_shift))
+ continue;
+
+ ret = *fi.data;
+ }
+
+ free(r);
+ return ret;
+}
+
+static cairo_surface_t *
+create_xcb_surface (int width, int height, void **closure)
+{
+ XCBSCREEN *root;
+ xcb_target_closure_t *xtc;
+ cairo_surface_t *surface;
+ XCBConnection *c;
+ XCBRenderPICTFORMINFO render_format;
+
+ *closure = xtc = xmalloc (sizeof (xcb_target_closure_t));
+
+ if (width == 0)
+ width = 1;
+ if (height == 0)
+ height = 1;
+
+ xtc->c = c = XCBConnectBasic();
+ if (c == NULL) {
+ cairo_test_log ("Failed to connect to X server through XCB\n");
+ return NULL;
+ }
+
+ root = XCBConnSetupSuccessRepRootsIter(XCBGetSetup(c)).data;
+
+ xtc->drawable.pixmap = XCBPIXMAPNew (c);
+ {
+ XCBDRAWABLE root_drawable;
+ root_drawable.window = root->root;
+ XCBCreatePixmap (c, 32, xtc->drawable.pixmap, root_drawable,
+ width, height);
+ }
+
+ render_format = _format_from_cairo (c, CAIRO_FORMAT_ARGB32);
+ if (render_format.id.xid == 0)
+ return NULL;
+ surface = cairo_xcb_surface_create_with_xrender_format (c, xtc->drawable,
+ &render_format,
+ width, height);
+
+ return surface;
+}
+
+static void
+cleanup_xcb (void *closure)
+{
+ xcb_target_closure_t *xtc = closure;
+
+ XCBFreePixmap (xtc->c, xtc->drawable.pixmap);
+ XCBDisconnect (xtc->c);
+}
+#endif
+
+#if CAIRO_HAS_XLIB_SURFACE
+#include "cairo-xlib-xrender.h"
+typedef struct _xlib_target_closure
+{
+ Display *dpy;
+ Pixmap pixmap;
+} xlib_target_closure_t;
+
+static cairo_surface_t *
+create_xlib_surface (int width, int height, void **closure)
+{
+ xlib_target_closure_t *xtc;
+ cairo_surface_t *surface;
+ Display *dpy;
+ XRenderPictFormat *xrender_format;
+
+ *closure = xtc = xmalloc (sizeof (xlib_target_closure_t));
+
+ if (width == 0)
+ width = 1;
+ if (height == 0)
+ height = 1;
+
+ xtc->dpy = dpy = XOpenDisplay (0);
+ if (xtc->dpy == NULL) {
+ cairo_test_log ("Failed to open display: %s\n", XDisplayName(0));
+ return NULL;
+ }
+
+ xrender_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
+
+ xtc->pixmap = XCreatePixmap (dpy, DefaultRootWindow (dpy),
+ width, height, xrender_format->depth);
+
+ surface = cairo_xlib_surface_create_with_xrender_format (dpy, xtc->pixmap,
+ xrender_format,
+ width, height);
+ return surface;
+}
+
+static void
+cleanup_xlib (void *closure)
+{
+ xlib_target_closure_t *xtc = closure;
+
+ XFreePixmap (xtc->dpy, xtc->pixmap);
+ XCloseDisplay (xtc->dpy);
+}
+#endif
+
+static cairo_test_status_t
+cairo_test_for_target (cairo_test_t *test,
+ cairo_test_draw_function_t draw,
+ cairo_test_target_t *target)
+{
+ cairo_test_status_t status;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ char *png_name, *ref_name, *diff_name;
+ char *srcdir;
+ int pixels_changed;
+ cairo_test_status_t ret;
+
+ /* Get the strings ready that we'll need. */
+ srcdir = getenv ("srcdir");
+ if (!srcdir)
+ srcdir = ".";
+ xasprintf (&png_name, "%s-%s%s", test->name,
+ target->name, CAIRO_TEST_PNG_SUFFIX);
+ xasprintf (&ref_name, "%s/%s%s", srcdir, test->name,
+ CAIRO_TEST_REF_SUFFIX);
+ xasprintf (&diff_name, "%s-%s%s", test->name,
+ target->name, CAIRO_TEST_DIFF_SUFFIX);
+
+ /* Run the actual drawing code. */
+ surface = (target->create_target_surface) (test->width, test->height,
+ &target->closure);
+ if (surface == NULL) {
+ cairo_test_log ("Error: Failed to set %s target\n", target->name);
+ return CAIRO_TEST_FAILURE;
+ }
+
+ cr = cairo_create (surface);
+
+ cairo_save (cr);
+ cairo_set_source_rgba (cr, 0, 0, 0, 0);
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ cairo_paint (cr);
+ cairo_restore (cr);
+
+ status = (draw) (cr, test->width, test->height);
+
+ /* Then, check all the different ways it could fail. */
+ if (status) {
+ cairo_test_log ("Error: Function under test failed\n");
+ return status;
+ }
+
+ if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
+ cairo_test_log ("Error: Function under test left cairo status in an error state: %s\n",
+ cairo_status_to_string (cairo_status (cr)));
+ return CAIRO_TEST_FAILURE;
+ }
+
+ /* Skip image check for tests with no image (width,height == 0,0) */
+ if (test->width == 0 || test->height == 0) {
+ cairo_destroy (cr);
+ return CAIRO_TEST_SUCCESS;
+ }
+
+ cairo_surface_write_to_png (surface, png_name);
+
+ cairo_destroy (cr);
+
+ cairo_surface_destroy (surface);
+
+ target->cleanup_target (target->closure);
+
+ pixels_changed = image_diff (png_name, ref_name, diff_name);
+
+ if (pixels_changed) {
+ ret = CAIRO_TEST_FAILURE;
+ if (pixels_changed > 0)
+ cairo_test_log ("Error: %d pixels differ from reference image %s\n",
+ pixels_changed, ref_name);
+ } else {
+ ret = CAIRO_TEST_SUCCESS;
+ }
+
+ free (png_name);
+ free (ref_name);
+ free (diff_name);
+
+ return ret;
+}
+
+static cairo_test_status_t
+cairo_test_real (cairo_test_t *test, cairo_test_draw_function_t draw)
+{
+ int i;
+ cairo_test_status_t status, ret;
+ cairo_test_target_t targets[] =
+ {
+ { "image", create_image_surface, cleanup_image},
+#if 0 /* #ifdef CAIRO_HAS_GLITZ_SURFACE */
+ { "glitz", create_glitz_surface, cleanup_glitz},
+#endif
+#if CAIRO_HAS_QUARTZ_SURFACE
+ { "quartz", create_quartz_surface, cleanup_quartz},
+#endif
+#if 0 && CAIRO_HAS_WIN32_SURFACE
+ { "win32", create_win32_surface, cleanup_win32},
+#endif
+#if CAIRO_HAS_XCB_SURFACE
+ { "xcb", create_xcb_surface, cleanup_xcb},
+#endif
+#if CAIRO_HAS_XLIB_SURFACE
+ { "xlib", create_xlib_surface, cleanup_xlib},
+#endif
+ };
+ char *log_name;
+
+ xasprintf (&log_name, "%s%s", test->name, CAIRO_TEST_LOG_SUFFIX);
+ xunlink (log_name);
+
+ cairo_test_log_file = fopen (log_name, "a");
+ if (cairo_test_log_file == NULL) {
+ fprintf (stderr, "Error opening log file: %s\n", log_name);
+ cairo_test_log_file = stderr;
+ }
+
+ ret = CAIRO_TEST_SUCCESS;
+ for (i=0; i < sizeof(targets)/sizeof(targets[0]); i++) {
+ cairo_test_target_t *target = &targets[i];
+ cairo_test_log ("Testing %s with %s target\n", test->name, target->name);
+ printf ("%s-%s:\t", test->name, target->name);
+ status = cairo_test_for_target (test, draw, target);
+ if (status) {
+ printf ("FAIL\n");
+ ret = status;
+ } else {
+ printf ("PASS\n");
+ }
+ }
+
+ fclose (cairo_test_log_file);
+
+ return ret;
+}
+
+cairo_test_status_t
+cairo_test_expect_failure (cairo_test_t *test,
+ cairo_test_draw_function_t draw,
+ const char *because)
+{
+ printf ("\n%s is expected to fail:\n\t%s\n", test->name, because);
+ return cairo_test_real (test, draw);
+}
+
+cairo_test_status_t
+cairo_test (cairo_test_t *test, cairo_test_draw_function_t draw)
+{
+ printf ("\n");
+ return cairo_test_real (test, draw);
+}
+
+cairo_pattern_t *
+cairo_test_create_png_pattern (cairo_t *cr, const char *filename)
+{
+ cairo_surface_t *image;
+ cairo_pattern_t *pattern;
+ unsigned char *buffer;
+ unsigned int w, h, stride;
+ read_png_status_t status;
+ char *srcdir = getenv ("srcdir");
+
+ status = read_png_argb32 (filename, &buffer, &w,&h, &stride);
+ if (status != READ_PNG_SUCCESS) {
+ if (srcdir) {
+ char *srcdir_filename;
+ xasprintf (&srcdir_filename, "%s/%s", srcdir, filename);
+ status = read_png_argb32 (srcdir_filename, &buffer, &w,&h, &stride);
+ free (srcdir_filename);
+ }
+ }
+ if (status != READ_PNG_SUCCESS)
+ return NULL;
+
+ image = cairo_image_surface_create_for_data (buffer, CAIRO_FORMAT_ARGB32,
+ w, h, stride);
+
+ pattern = cairo_pattern_create_for_surface (image);
+ cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+
+ return pattern;
+}
diff --git a/test/cairo_test.h b/test/cairo-test.h
index 912ce89..6260dae 100644
--- a/test/cairo_test.h
+++ b/test/cairo-test.h
@@ -41,15 +41,25 @@ typedef struct cairo_test {
int height;
} cairo_test_t;
-typedef void (*cairo_test_draw_function_t) (cairo_t *cr, int width, int height);
+typedef cairo_test_status_t (*cairo_test_draw_function_t) (cairo_t *cr, int width, int height);
/* cairo_test.c */
cairo_test_status_t
cairo_test (cairo_test_t *test, cairo_test_draw_function_t draw);
+cairo_test_status_t
+cairo_test_expect_failure (cairo_test_t *test,
+ cairo_test_draw_function_t draw,
+ const char *reason);
+
cairo_pattern_t *
cairo_test_create_png_pattern (cairo_t *cr, const char *filename);
+void
+cairo_test_log (const char *fmt, ...);
+
+void
+xasprintf (char **strp, const char *fmt, ...);
#endif
diff --git a/test/cairo_test.c b/test/cairo_test.c
deleted file mode 100644
index 06f7672..0000000
--- a/test/cairo_test.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright © 2004 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Red Hat, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Red Hat, Inc. makes no representations about the
- * suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth@cworth.org>
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-
-#include "cairo_test.h"
-
-#include "buffer_diff.h"
-#include "read_png.h"
-#include "write_png.h"
-#include "xmalloc.h"
-
-#define CAIRO_TEST_LOG_SUFFIX ".log"
-#define CAIRO_TEST_PNG_SUFFIX "-out.png"
-#define CAIRO_TEST_REF_SUFFIX "-ref.png"
-#define CAIRO_TEST_DIFF_SUFFIX "-diff.png"
-
-static void
-xasprintf (char **strp, const char *fmt, ...)
-{
-#ifdef HAVE_VASPRINTF
- va_list va;
- int ret;
-
- va_start (va, fmt);
- ret = vasprintf (strp, fmt, va);
- va_end (va);
-
- if (ret < 0) {
- fprintf (stderr, "Out of memory\n");
- exit (1);
- }
-#else /* !HAVE_VASNPRINTF */
-#define BUF_SIZE 1024
- va_list va;
- char buffer[BUF_SIZE];
- int ret;
-
- va_start (va, fmt);
- ret = vsnprintf (buffer, sizeof(buffer), fmt, va);
- va_end (va);
-
- if (ret < 0) {
- fprintf (stderr, "Failure in vsnprintf\n");
- exit (1);
- }
-
- if (strlen (buffer) == sizeof(buffer) - 1) {
- fprintf (stderr, "Overflowed fixed buffer\n");
- exit (1);
- }
-
- *strp = strdup (buffer);
- if (!*strp) {
- fprintf (stderr, "Out of memory\n");
- exit (1);
- }
-#endif /* !HAVE_VASNPRINTF */
-}
-
-static void
-xunlink (const char *pathname)
-{
- if (unlink (pathname) < 0 && errno != ENOENT) {
- fprintf (stderr, " Error: Cannot remove %s: %s\n",
- pathname, strerror (errno));
- exit (1);
- }
-}
-
-cairo_test_status_t
-cairo_test (cairo_test_t *test, cairo_test_draw_function_t draw)
-{
- cairo_t *cr;
- int stride;
- unsigned char *png_buf, *ref_buf, *diff_buf;
- char *log_name, *png_name, *ref_name, *diff_name;
- char *srcdir;
- int pixels_changed;
- int ref_width, ref_height, ref_stride;
- read_png_status_t png_status;
- cairo_test_status_t ret;
- FILE *png_file;
- FILE *log_file;
-
- /* The cairo part of the test is the easiest part */
- cr = cairo_create ();
-
- stride = 4 * test->width;
-
- png_buf = xcalloc (stride * test->height, 1);
- diff_buf = xcalloc (stride * test->height, 1);
-
- cairo_set_target_image (cr, png_buf, CAIRO_FORMAT_ARGB32,
- test->width, test->height, stride);
-
- (draw) (cr, test->width, test->height);
-
- cairo_destroy (cr);
-
- /* Skip image check for tests with no image (width,height == 0,0) */
- if (test->width == 0 || test->height == 0) {
- free (png_buf);
- free (diff_buf);
- return CAIRO_TEST_SUCCESS;
- }
-
- /* Then we've got a bunch of string manipulation and file I/O for the check */
- srcdir = getenv ("srcdir");
- if (!srcdir)
- srcdir = ".";
- xasprintf (&log_name, "%s%s", test->name, CAIRO_TEST_LOG_SUFFIX);
- xasprintf (&png_name, "%s%s", test->name, CAIRO_TEST_PNG_SUFFIX);
- xasprintf (&ref_name, "%s/%s%s", srcdir, test->name, CAIRO_TEST_REF_SUFFIX);
- xasprintf (&diff_name, "%s%s", test->name, CAIRO_TEST_DIFF_SUFFIX);
-
- png_file = fopen (png_name, "w");
- write_png_argb32 (png_buf, png_file, test->width, test->height, stride);
- fclose (png_file);
-
- xunlink (log_name);
-
- ref_buf = NULL;
- png_status = (read_png_argb32 (ref_name, &ref_buf, &ref_width, &ref_height, &ref_stride));
- if (png_status) {
- log_file = fopen (log_name, "a");
- switch (png_status)
- {
- case READ_PNG_FILE_NOT_FOUND:
- fprintf (log_file, "Error: No reference image found: %s\n", ref_name);
- break;
- case READ_PNG_FILE_NOT_PNG:
- fprintf (log_file, "Error: %s is not a png image\n", ref_name);
- break;
- default:
- fprintf (log_file, "Error: Failed to read %s\n", ref_name);
- }
- fclose (log_file);
-
- ret = CAIRO_TEST_FAILURE;
- goto BAIL;
- } else {
- }
-
- if (test->width != ref_width || test->height != ref_height) {
- log_file = fopen (log_name, "a");
- fprintf (log_file,
- "Error: Image size mismatch: (%dx%d) vs. (%dx%d)\n"
- " for %s vs %s\n",
- test->width, test->height,
- ref_width, ref_height,
- png_name, ref_name);
- fclose (log_file);
-
- ret = CAIRO_TEST_FAILURE;
- goto BAIL;
- }
-
- pixels_changed = buffer_diff (png_buf, ref_buf, diff_buf,
- test->width, test->height, stride);
- if (pixels_changed) {
- log_file = fopen (log_name, "a");
- fprintf (log_file, "Error: %d pixels differ from reference image %s\n",
- pixels_changed, ref_name);
- png_file = fopen (diff_name, "w");
- write_png_argb32 (diff_buf, png_file, test->width, test->height, stride);
- fclose (png_file);
- fclose (log_file);
-
- ret = CAIRO_TEST_FAILURE;
- goto BAIL;
- } else {
- xunlink (diff_name);
- }
-
- ret = CAIRO_TEST_SUCCESS;
-
-BAIL:
- free (png_buf);
- free (ref_buf);
- free (diff_buf);
- free (log_name);
- free (png_name);
- free (ref_name);
- free (diff_name);
-
- return ret;
-}
-
-cairo_pattern_t *
-cairo_test_create_png_pattern (cairo_t *cr, const char *filename)
-{
- cairo_surface_t *image;
- cairo_pattern_t *pattern;
- unsigned char *buffer;
- int w, h, stride;
- read_png_status_t status;
- char *srcdir = getenv ("srcdir");
-
- status = read_png_argb32 (filename, &buffer, &w,&h, &stride);
- if (status != READ_PNG_SUCCESS) {
- if (srcdir) {
- char *srcdir_filename;
- xasprintf (&srcdir_filename, "%s/%s", srcdir, filename);
- status = read_png_argb32 (srcdir_filename, &buffer, &w,&h, &stride);
- free (srcdir_filename);
- }
- }
- if (status != READ_PNG_SUCCESS)
- return NULL;
-
- image = cairo_surface_create_for_image (buffer, CAIRO_FORMAT_ARGB32,
- w, h, stride);
-
- cairo_surface_set_repeat (image, 1);
-
- pattern = cairo_pattern_create_for_surface (image);
-
- return pattern;
-}
diff --git a/test/clip-nesting-ref.png b/test/clip-nesting-ref.png
new file mode 100644
index 0000000..6b7e1cd
--- /dev/null
+++ b/test/clip-nesting-ref.png
Binary files differ
diff --git a/test/clip-nesting.c b/test/clip-nesting.c
new file mode 100644
index 0000000..8019780
--- /dev/null
+++ b/test/clip-nesting.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Owen Taylor <otaylor@redhat.com>
+ */
+
+#include <math.h>
+#include "cairo-test.h"
+#include <stdio.h>
+
+#define SIZE 100
+#define BORDER 10
+#define LINE_WIDTH 20
+
+cairo_test_t test = {
+ "clip-nesting",
+ "Test clipping with multiple contexts for the same surface",
+ SIZE, SIZE
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_surface_t *target_surface;
+ cairo_t *cr2, *cr3;
+
+ target_surface = cairo_get_target (cr);
+
+ cr2 = cairo_create (target_surface);
+
+ /* Draw a diagonal line and clip to it */
+
+ cairo_move_to (cr2, BORDER, BORDER);
+ cairo_line_to (cr2, BORDER + LINE_WIDTH, BORDER);
+ cairo_line_to (cr2, SIZE - BORDER, SIZE - BORDER);
+ cairo_line_to (cr2, SIZE - BORDER - LINE_WIDTH, SIZE - BORDER);
+
+ cairo_clip (cr2);
+ cairo_set_source_rgb (cr2, 0, 0, 1); /* Blue */
+ cairo_paint (cr2);
+
+ /* Clipping affects this cairo_t */
+
+ cairo_set_source_rgb (cr2, 1, 1, 1); /* White */
+ cairo_rectangle (cr2,
+ SIZE / 2 - LINE_WIDTH / 2, BORDER,
+ LINE_WIDTH, SIZE - 2 * BORDER);
+ cairo_fill (cr2);
+
+ /* But doesn't affect another cairo_t that we create temporarily for
+ * the same surface
+ */
+ cr3 = cairo_create (target_surface);
+ cairo_set_source_rgb (cr3, 1, 1, 1); /* White */
+ cairo_rectangle (cr3,
+ SIZE - BORDER - LINE_WIDTH, BORDER,
+ LINE_WIDTH, SIZE - 2 * BORDER);
+ cairo_fill (cr3);
+
+ cairo_destroy (cr3);
+ cairo_destroy (cr2);
+
+ /* And doesn't affect anything after this cairo_t is destroyed */
+
+ cairo_set_source_rgb (cr, 1, 1, 1); /* White */
+ cairo_rectangle (cr,
+ BORDER, BORDER,
+ LINE_WIDTH, SIZE - 2 * BORDER);
+ cairo_fill (cr);
+
+ return CAIRO_TEST_SUCCESS;
+
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/clip-twice-ref.png b/test/clip-twice-ref.png
new file mode 100644
index 0000000..bd3e3db
--- /dev/null
+++ b/test/clip-twice-ref.png
Binary files differ
diff --git a/test/clip_twice.c b/test/clip-twice.c
index 00215e6..446447c 100644
--- a/test/clip_twice.c
+++ b/test/clip-twice.c
@@ -23,21 +23,20 @@
* Author: Kristian Høgsberg <krh@redhat.com>
*/
-#include "cairo_test.h"
+#include "cairo-test.h"
#define WIDTH 64
#define HEIGHT 64
cairo_test_t test = {
- "clip_twice",
+ "clip-twice",
"Verifies that the clip mask is updated correctly when it constructed by setting the clip path twice.",
WIDTH, HEIGHT
};
-static void
+static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
- cairo_set_alpha (cr, 1.0);
cairo_new_path (cr);
cairo_arc (cr, WIDTH / 2, HEIGHT / 2, WIDTH / 3, 0, 2 * M_PI);
cairo_clip (cr);
@@ -52,7 +51,7 @@ draw (cairo_t *cr, int width, int height)
cairo_close_path (cr);
cairo_clip (cr);
- cairo_set_rgb_color (cr, 0, 0, 0.6);
+ cairo_set_source_rgb (cr, 0, 0, 0.6);
cairo_new_path (cr);
cairo_move_to (cr, 0, 0);
@@ -63,6 +62,14 @@ draw (cairo_t *cr, int width, int height)
cairo_line_to (cr, WIDTH / 2, HEIGHT / 4);
cairo_close_path (cr);
cairo_fill (cr);
+
+ cairo_new_path (cr);
+ cairo_arc (cr, WIDTH / 2, HEIGHT / 2, WIDTH / 5, 0, 2 * M_PI);
+ cairo_clip (cr);
+ cairo_set_source_rgb (cr, 1, 1, 0);
+ cairo_paint (cr);
+
+ return CAIRO_TEST_SUCCESS;
}
int
diff --git a/test/clip_twice-ref.png b/test/clip_twice-ref.png
deleted file mode 100644
index ab0ae1a..0000000
--- a/test/clip_twice-ref.png
+++ /dev/null
Binary files differ
diff --git a/test/coverage-ref.png b/test/coverage-ref.png
deleted file mode 100644
index 9b71040..0000000
--- a/test/coverage-ref.png
+++ /dev/null
Binary files differ
diff --git a/test/move_to_show_surface-ref.png b/test/create-for-png-ref.png
index 765adc4..765adc4 100644
--- a/test/move_to_show_surface-ref.png
+++ b/test/create-for-png-ref.png
Binary files differ
diff --git a/test/create-for-png.c b/test/create-for-png.c
new file mode 100644
index 0000000..ef3b6f6
--- /dev/null
+++ b/test/create-for-png.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl Worth <cworth@cworth.org>
+ */
+
+#include "cairo-test.h"
+
+#include <stdlib.h>
+
+#define WIDTH 2
+#define HEIGHT 2
+
+cairo_test_t test = {
+ "create-for-png",
+ "Tests the creation of an image surface from a PNG file",
+ WIDTH, HEIGHT
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ char *srcdir = getenv ("srcdir");
+ char *filename;
+ cairo_surface_t *surface;
+
+ xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
+ "create-for-png-ref.png");
+
+ surface = cairo_image_surface_create_from_png (filename);
+ free (filename);
+
+ if (surface == NULL) {
+ cairo_test_log ("Error: failed to open file %s\n", filename);
+ return CAIRO_TEST_FAILURE;
+ }
+
+ cairo_set_source_surface (cr, surface, 0, 0);
+ cairo_paint (cr);
+
+ cairo_surface_destroy (surface);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/fill-and-stroke-ref.png b/test/fill-and-stroke-ref.png
new file mode 100644
index 0000000..298f694
--- /dev/null
+++ b/test/fill-and-stroke-ref.png
Binary files differ
diff --git a/test/fill-and-stroke.c b/test/fill-and-stroke.c
new file mode 100644
index 0000000..9893171
--- /dev/null
+++ b/test/fill-and-stroke.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include "cairo-test.h"
+
+#define PAD 2
+#define SIZE 10
+
+cairo_test_t test = {
+ "fill-and-stroke",
+ "Tests calls to various set_source functions",
+ 2 * SIZE + 4 * PAD, SIZE + 2 * PAD
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_rectangle (cr, PAD, PAD, SIZE, SIZE);
+ cairo_set_source_rgb (cr, 0, 0, 1);
+ cairo_fill_preserve (cr);
+ cairo_set_source_rgb (cr, 1, 0, 0);
+ cairo_stroke (cr);
+
+ cairo_translate (cr, SIZE + 2 * PAD, 0);
+
+ cairo_arc (cr,
+ PAD + SIZE / 2, PAD + SIZE / 2,
+ SIZE / 2,
+ 0, 2 * M_PI);
+ cairo_fill_preserve (cr);
+ cairo_set_source_rgb (cr, 0, 0, 1);
+ cairo_stroke (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/fill_rule-ref.png b/test/fill-rule-ref.png
index e2e10d4..e2e10d4 100644
--- a/test/fill_rule-ref.png
+++ b/test/fill-rule-ref.png
Binary files differ
diff --git a/test/fill_rule.c b/test/fill-rule.c
index 037a044..103208c 100644
--- a/test/fill_rule.c
+++ b/test/fill-rule.c
@@ -61,13 +61,13 @@
*
*/
-#include "cairo_test.h"
+#include "cairo-test.h"
#define LITTLE_STAR_SIZE 20
#define BIG_STAR_SIZE 80
cairo_test_t test = {
- "fill_rule",
+ "fill-rule",
"Tests cairo_set_full_rule with some star shapes",
BIG_STAR_SIZE * 2 + 3, BIG_STAR_SIZE + LITTLE_STAR_SIZE + 3
};
@@ -97,10 +97,10 @@ big_star_path (cairo_t *cr)
}
/* Fill the same path twice, once with each fill rule */
-static void
+static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
- cairo_set_rgb_color (cr, 1, 0, 0);
+ cairo_set_source_rgb (cr, 1, 0, 0);
cairo_translate (cr, 1, 1);
little_star_path (cr);
@@ -121,6 +121,8 @@ draw (cairo_t *cr, int width, int height)
big_star_path (cr);
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_fill (cr);
+
+ return CAIRO_TEST_SUCCESS;
}
int
diff --git a/test/filter-nearest-offset-ref.png b/test/filter-nearest-offset-ref.png
new file mode 100644
index 0000000..46092e3
--- /dev/null
+++ b/test/filter-nearest-offset-ref.png
Binary files differ
diff --git a/test/filter-nearest-offset.c b/test/filter-nearest-offset.c
new file mode 100644
index 0000000..74ad476
--- /dev/null
+++ b/test/filter-nearest-offset.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include "cairo-test.h"
+
+#define STAMP_WIDTH 4
+#define STAMP_HEIGHT 4
+#define PAD 1
+
+#define STEPS 10
+
+#define IMAGE_WIDTH (PAD + STEPS * (STAMP_WIDTH + PAD) + PAD)
+#define IMAGE_HEIGHT (PAD + STEPS * (STAMP_HEIGHT + PAD) + PAD)
+
+cairo_test_t test = {
+ "filter-nearest-offset",
+ "Test sampling offset of CAIRO_FILTER_NEAREST",
+ IMAGE_WIDTH, IMAGE_HEIGHT
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_surface_t *surface;
+ unsigned long data[STAMP_WIDTH * STAMP_HEIGHT] = {
+ 0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
+ 0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
+
+ 0xff00ff00, 0xff00ff00, 0xff0000ff, 0xff0000ff,
+ 0xff00ff00, 0xff00ff00, 0xff0000ff, 0xff0000ff
+ };
+ int i, j;
+
+ /* Draw reference lines where the jump should be. */
+ cairo_move_to (cr, PAD + STEPS / 2 * (STAMP_WIDTH + PAD), 0);
+ cairo_rel_line_to (cr, 0, IMAGE_HEIGHT);
+ cairo_move_to (cr, 0, PAD + STEPS / 2 * (STAMP_HEIGHT + PAD));
+ cairo_rel_line_to (cr, IMAGE_WIDTH, 0);
+ cairo_set_line_width (cr, 2.0);
+ cairo_stroke (cr);
+
+ surface = cairo_image_surface_create_for_data ((unsigned char *) data,
+ CAIRO_FORMAT_ARGB32,
+ STAMP_WIDTH,
+ STAMP_HEIGHT,
+ STAMP_WIDTH * 4);
+
+ for (j=0; j < STEPS; j++) {
+ double j_step;
+
+ for (i=0; i < STEPS; i++) {
+ double i_step;
+
+#define GENERATE_REFERENCE_IMAGE 0
+#if GENERATE_REFERENCE_IMAGE
+ i_step = i >= STEPS / 2 ? 1 : 0;
+ j_step = j >= STEPS / 2 ? 1 : 0;
+#else
+ i_step = i * 1.0 / STEPS;
+ j_step = j * 1.0 / STEPS;
+#endif
+
+ cairo_save (cr);
+
+ cairo_set_source_surface (cr, surface,
+ PAD + i * (STAMP_WIDTH + PAD) + i_step,
+ PAD + j * (STAMP_HEIGHT + PAD) + j_step);
+ cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_BEST);
+ cairo_paint (cr);
+
+ cairo_restore (cr);
+ }
+ }
+
+ cairo_surface_destroy (surface);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test_expect_failure (&test, draw,
+ "wrong sampling location for nearest-neighbor filter in libpixman and Render");
+}
diff --git a/test/get-and-set.c b/test/get-and-set.c
new file mode 100644
index 0000000..72d6610
--- /dev/null
+++ b/test/get-and-set.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include "cairo-test.h"
+
+cairo_test_t test = {
+ "get-and-set",
+ "Tests calls to the most trivial cairo_get and cairo_set functions",
+ 0, 0
+};
+
+typedef struct {
+ cairo_operator_t operator;
+ double tolerance;
+ cairo_fill_rule_t fill_rule;
+ double line_width;
+ cairo_line_cap_t line_cap;
+ cairo_line_join_t line_join;
+ double miter_limit;
+ cairo_matrix_t matrix;
+} settings_t;
+
+/* Two sets of settings, no defaults */
+settings_t settings[] = {
+ {
+ CAIRO_OPERATOR_IN,
+ 2.0,
+ CAIRO_FILL_RULE_EVEN_ODD,
+ 7.7,
+ CAIRO_LINE_CAP_SQUARE,
+ CAIRO_LINE_JOIN_ROUND,
+ 3.14,
+ {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}
+ },
+ {
+ CAIRO_OPERATOR_ATOP,
+ 5.25,
+ CAIRO_FILL_RULE_WINDING,
+ 2.17,
+ CAIRO_LINE_CAP_ROUND,
+ CAIRO_LINE_JOIN_BEVEL,
+ 1000.0,
+ {.1, .01, .001, .0001, .00001, .000001}
+ }
+};
+
+static void
+settings_set (cairo_t *cr, settings_t *settings)
+{
+ cairo_set_operator (cr, settings->operator);
+ cairo_set_tolerance (cr, settings->tolerance);
+ cairo_set_fill_rule (cr, settings->fill_rule);
+ cairo_set_line_width (cr, settings->line_width);
+ cairo_set_line_cap (cr, settings->line_cap);
+ cairo_set_line_join (cr, settings->line_join);
+ cairo_set_miter_limit (cr, settings->miter_limit);
+ cairo_set_matrix (cr, &settings->matrix);
+}
+
+static void
+settings_get (cairo_t *cr, settings_t *settings)
+{
+ settings->operator = cairo_get_operator (cr);
+ settings->tolerance = cairo_get_tolerance (cr);
+ settings->fill_rule = cairo_get_fill_rule (cr);
+ settings->line_width = cairo_get_line_width (cr);
+ settings->line_cap = cairo_get_line_cap (cr);
+ settings->line_join = cairo_get_line_join (cr);
+ settings->miter_limit = cairo_get_miter_limit (cr);
+ cairo_get_matrix (cr, &settings->matrix);
+}
+
+static int
+settings_equal (settings_t *a, settings_t *b)
+{
+ return (a->operator == b->operator &&
+ a->tolerance == b->tolerance &&
+ a->fill_rule == b->fill_rule &&
+ a->line_width == b->line_width &&
+ a->line_cap == b->line_cap &&
+ a->line_join == b->line_join &&
+ a->miter_limit == b->miter_limit &&
+ a->matrix.xx == b->matrix.xx &&
+ a->matrix.xy == b->matrix.xy &&
+ a->matrix.x0 == b->matrix.x0 &&
+ a->matrix.yx == b->matrix.yx &&
+ a->matrix.yy == b->matrix.yy &&
+ a->matrix.y0 == b->matrix.y0);
+}
+
+static cairo_test_status_t
+get_and_set (cairo_t *cr, int width, int height)
+{
+ settings_t check;
+
+ settings_set (cr, &settings[0]);
+
+ cairo_save (cr);
+ {
+ settings_set (cr, &settings[1]);
+ settings_get (cr, &check);
+
+ if (!settings_equal (&settings[1], &check))
+ return CAIRO_TEST_FAILURE;
+ }
+ cairo_restore (cr);
+
+ settings_get (cr, &check);
+
+ if (!settings_equal (&settings[0], &check))
+ return CAIRO_TEST_FAILURE;
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, get_and_set);
+}
diff --git a/test/gradient-alpha-ref.png b/test/gradient-alpha-ref.png
new file mode 100644
index 0000000..e75f911
--- /dev/null
+++ b/test/gradient-alpha-ref.png
Binary files differ
diff --git a/test/gradient-alpha.c b/test/gradient-alpha.c
new file mode 100644
index 0000000..3015728
--- /dev/null
+++ b/test/gradient-alpha.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include "cairo-test.h"
+
+cairo_test_t test = {
+ "gradient-alpha",
+ "Tests drawing of a gradient with various alpha values in the color stops",
+ 10, 10
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_pattern_t *gradient;
+
+ gradient = cairo_pattern_create_linear (0, -height,
+ 0, height);
+ cairo_pattern_add_color_stop_rgba (gradient, 0.0,
+ 1.0, 0.0, 0.0,
+ 1.0);
+ cairo_pattern_add_color_stop_rgba (gradient, 1.0,
+ 0.0, 0.0, 1.0,
+ 0.5);
+
+ cairo_set_source (cr, gradient);
+
+ cairo_paint (cr);
+
+ cairo_pattern_destroy (gradient);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/imagediff.c b/test/imagediff.c
index 36962f1..8e13a1f 100644
--- a/test/imagediff.c
+++ b/test/imagediff.c
@@ -26,9 +26,9 @@
#include <stdio.h>
#include <stdlib.h>
-#include "buffer_diff.h"
-#include "read_png.h"
-#include "write_png.h"
+#include "buffer-diff.h"
+#include "read-png.h"
+#include "write-png.h"
#include "xmalloc.h"
int
@@ -77,7 +77,7 @@ main (int argc, char *argv[])
free (buffer);
- return 0;
+ return total_pixels_changed;
}
diff --git a/test/leaky_polygon-ref.png b/test/leaky-polygon-ref.png
index 0daabe1..0daabe1 100644
--- a/test/leaky_polygon-ref.png
+++ b/test/leaky-polygon-ref.png
Binary files differ
diff --git a/test/leaky_polygon.c b/test/leaky-polygon.c
index 39daf4c..575311e 100644
--- a/test/leaky_polygon.c
+++ b/test/leaky-polygon.c
@@ -51,18 +51,18 @@
*
*/
-#include "cairo_test.h"
+#include "cairo-test.h"
#define WIDTH 21
#define HEIGHT 21
cairo_test_t test = {
- "leaky_polygon",
+ "leaky-polygon",
"Exercises a corner case in the trapezoid rasterization in which pixels outside the trapezoids received a non-zero alpha",
WIDTH, HEIGHT
};
-static void
+static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_scale (cr, 1.0/(1<<16), 1.0/(1<<16));
@@ -73,6 +73,8 @@ draw (cairo_t *cr, int width, int height)
cairo_close_path (cr);
cairo_fill (cr);
+
+ return CAIRO_TEST_SUCCESS;
}
int
diff --git a/test/line_width-ref.png b/test/line-width-ref.png
index ddcd929..ddcd929 100644
--- a/test/line_width-ref.png
+++ b/test/line-width-ref.png
Binary files differ
diff --git a/test/line_width.c b/test/line-width.c
index 9c3ed89..ca2d276 100644
--- a/test/line_width.c
+++ b/test/line-width.c
@@ -23,7 +23,7 @@
* Author: Carl D. Worth <cworth@cworth.org>
*/
-#include "cairo_test.h"
+#include "cairo-test.h"
#define LINES 5
#define LINE_LENGTH 10
@@ -31,17 +31,17 @@
#define IMAGE_HEIGHT ((LINES+4)*LINES)/2 + 2
cairo_test_t test = {
- "line_width",
+ "line-width",
"Tests cairo_set_line_width",
IMAGE_WIDTH, IMAGE_HEIGHT
};
-static void
+static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
int i;
- cairo_set_rgb_color (cr, 0, 0, 0);
+ cairo_set_source_rgb (cr, 0, 0, 0);
cairo_translate (cr, 2, 2);
for (i=0; i < LINES; i++) {
@@ -54,6 +54,8 @@ draw (cairo_t *cr, int width, int height)
cairo_stroke (cr);
cairo_translate (cr, 0, i+3);
}
+
+ return CAIRO_TEST_SUCCESS;
}
int
diff --git a/test/linear_gradient-ref.png b/test/linear-gradient-ref.png
index 7790414..7790414 100644
--- a/test/linear_gradient-ref.png
+++ b/test/linear-gradient-ref.png
Binary files differ
diff --git a/test/linear_gradient.c b/test/linear-gradient.c
index 189b500..38ba559 100644
--- a/test/linear_gradient.c
+++ b/test/linear-gradient.c
@@ -23,7 +23,7 @@
* Author: Owen Taylor <otaylor@redhat.com>
*/
-#include "cairo_test.h"
+#include "cairo-test.h"
#include "stdio.h"
/* The test matrix is
@@ -55,7 +55,7 @@ static const int n_stops[] = { 2, 3 };
#define HEIGHT N_N_STOPS * N_ROTATE_ANGLES * UNIT_SIZE + (N_N_STOPS * N_ROTATE_ANGLES + 1) * PAD
cairo_test_t test = {
- "linear_gradient",
+ "linear-gradient",
"Tests the drawing of linear gradients",
WIDTH, HEIGHT
};
@@ -72,7 +72,7 @@ draw_unit (cairo_t *cr,
cairo_clip (cr);
cairo_new_path(cr);
- cairo_set_rgb_color (cr, 0.0, 0.0, 0.0);
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
cairo_rectangle (cr, 0, 0, 1, 1);
cairo_fill (cr);
@@ -84,38 +84,32 @@ draw_unit (cairo_t *cr,
0.5 * cos (gradient_angle), 0.5 * sin (gradient_angle));
if (n_stops == 2) {
- cairo_pattern_add_color_stop (pattern, 0.,
- 0.3, 0.3, 0.3,
- 1.0);
- cairo_pattern_add_color_stop (pattern, 1.,
- 1.0, 1.0, 1.0,
- 1.0);
+ cairo_pattern_add_color_stop_rgb (pattern, 0.,
+ 0.3, 0.3, 0.3);
+ cairo_pattern_add_color_stop_rgb (pattern, 1.,
+ 1.0, 1.0, 1.0);
} else {
- cairo_pattern_add_color_stop (pattern, 0.,
- 1.0, 0.0, 0.0,
- 1.0);
- cairo_pattern_add_color_stop (pattern, 0.5,
- 1.0, 1.0, 1.0,
- 1.0);
- cairo_pattern_add_color_stop (pattern, 1.,
- 0.0, 0.0, 1.0,
- 1.0);
+ cairo_pattern_add_color_stop_rgb (pattern, 0.,
+ 1.0, 0.0, 0.0);
+ cairo_pattern_add_color_stop_rgb (pattern, 0.5,
+ 1.0, 1.0, 1.0);
+ cairo_pattern_add_color_stop_rgb (pattern, 1.,
+ 0.0, 0.0, 1.0);
}
- cairo_set_pattern (cr, pattern);
+ cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_rectangle (cr, -0.5, -0.5, 1, 1);
cairo_fill (cr);
}
-static void
+static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
int i, j, k;
- cairo_set_rgb_color (cr, 0.5, 0.5, 0.5);
- cairo_rectangle (cr, 0, 0, width, height);
- cairo_fill (cr);
+ cairo_set_source_rgb (cr, 0.5, 0.5, 0.5);
+ cairo_paint (cr);
for (i = 0; i < N_GRADIENT_ANGLES; i++)
for (j = 0; j < N_ROTATE_ANGLES; j++)
@@ -132,6 +126,8 @@ draw (cairo_t *cr, int width, int height)
n_stops[k]);
cairo_restore (cr);
}
+
+ return CAIRO_TEST_SUCCESS;
}
int
diff --git a/test/mask-ref.png b/test/mask-ref.png
new file mode 100644
index 0000000..4b357c0
--- /dev/null
+++ b/test/mask-ref.png
Binary files differ
diff --git a/test/mask.c b/test/mask.c
new file mode 100644
index 0000000..ec0322d
--- /dev/null
+++ b/test/mask.c
@@ -0,0 +1,246 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Owen Taylor <otaylor@redhat.com>
+ * Kristian Høgsberg <krh@redhat.com>
+ */
+
+#include <math.h>
+#include "cairo-test.h"
+#include <stdio.h>
+
+#define WIDTH 64
+#define HEIGHT 64
+#define PAD 10
+
+const char png_filename[] = "romedalen.png";
+
+static void
+set_solid_pattern (cairo_t *cr, int x, int y)
+{
+ cairo_set_source_rgb (cr, 0, 0, 0.6);
+}
+
+static void
+set_translucent_pattern (cairo_t *cr, int x, int y)
+{
+ cairo_set_source_rgba (cr, 0, 0, 0.6, 0.5);
+}
+
+static void
+set_gradient_pattern (cairo_t *cr, int x, int y)
+{
+ cairo_pattern_t *pattern;
+
+ pattern =
+ cairo_pattern_create_linear (x, y, x + WIDTH, y + HEIGHT);
+ cairo_pattern_add_color_stop_rgba (pattern, 0, 1, 1, 1, 1);
+ cairo_pattern_add_color_stop_rgba (pattern, 1, 0, 0, 0.4, 1);
+ cairo_set_source (cr, pattern);
+}
+
+static void
+set_image_pattern (cairo_t *cr, int x, int y)
+{
+ cairo_pattern_t *pattern;
+
+ pattern = cairo_test_create_png_pattern (cr, png_filename);
+ cairo_set_source (cr, pattern);
+}
+
+static void
+mask_polygon (cairo_t *cr, int x, int y)
+{
+ cairo_surface_t *mask_surface;
+ cairo_t *cr2;
+
+ mask_surface = cairo_surface_create_similar (cairo_get_target (cr),
+ CAIRO_FORMAT_A8,
+ WIDTH, HEIGHT);
+ cr2 = cairo_create (mask_surface);
+
+ cairo_save (cr2);
+ cairo_set_source_rgba (cr2, 0, 0, 0, 0); /* transparent */
+ cairo_set_operator (cr2, CAIRO_OPERATOR_SOURCE);
+ cairo_paint (cr2);
+ cairo_restore (cr2);
+
+ cairo_set_source_rgb (cr2, 1, 1, 1); /* white */
+
+ cairo_new_path (cr2);
+ cairo_move_to (cr2, 0, 0);
+ cairo_line_to (cr2, 0, HEIGHT);
+ cairo_line_to (cr2, WIDTH / 2, 3 * HEIGHT / 4);
+ cairo_line_to (cr2, WIDTH, HEIGHT);
+ cairo_line_to (cr2, WIDTH, 0);
+ cairo_line_to (cr2, WIDTH / 2, HEIGHT / 4);
+ cairo_close_path (cr2);
+ cairo_fill (cr2);
+
+ cairo_destroy (cr2);
+
+ cairo_mask_surface (cr, mask_surface, x, y);
+
+ cairo_surface_destroy (mask_surface);
+}
+
+static void
+mask_alpha (cairo_t *cr, int x, int y)
+{
+ cairo_paint_with_alpha (cr, 0.75);
+}
+
+static void
+mask_gradient (cairo_t *cr, int x, int y)
+{
+ cairo_pattern_t *pattern;
+
+ pattern = cairo_pattern_create_linear (x, y,
+ x + WIDTH, y + HEIGHT);
+
+ cairo_pattern_add_color_stop_rgba (pattern,
+ 0,
+ 1, 1, 1, 1);
+ cairo_pattern_add_color_stop_rgba (pattern,
+ 1,
+ 1, 1, 1, 0);
+
+ cairo_mask (cr, pattern);
+
+ cairo_pattern_destroy (pattern);
+}
+
+static void
+clip_none (cairo_t *cr, int x, int y)
+{
+}
+
+static void
+clip_rects (cairo_t *cr, int x, int y)
+{
+ int height = HEIGHT / 3;
+
+ cairo_new_path (cr);
+ cairo_rectangle (cr, x, y, WIDTH, height);
+ cairo_rectangle (cr, x, y + 2 * height, WIDTH, height);
+ cairo_clip (cr);
+}
+
+static void
+clip_circle (cairo_t *cr, int x, int y)
+{
+ cairo_new_path (cr);
+ cairo_arc (cr, x + WIDTH / 2, y + HEIGHT / 2,
+ WIDTH / 2, 0, 2 * M_PI);
+ cairo_clip (cr);
+ cairo_new_path (cr);
+}
+
+static void (*pattern_funcs[])(cairo_t *cr, int x, int y) = {
+ set_solid_pattern,
+ set_translucent_pattern,
+ set_gradient_pattern,
+ set_image_pattern,
+};
+
+static void (*mask_funcs[])(cairo_t *cr, int x, int y) = {
+ mask_alpha,
+ mask_gradient,
+ mask_polygon,
+};
+
+static void (*clip_funcs[])(cairo_t *cr, int x, int y) = {
+ clip_none,
+ clip_rects,
+ clip_circle,
+};
+
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
+#define IMAGE_WIDTH (ARRAY_SIZE (pattern_funcs) * (WIDTH + PAD) + PAD)
+#define IMAGE_HEIGHT (ARRAY_SIZE (mask_funcs) * ARRAY_SIZE (clip_funcs) * (HEIGHT + PAD) + PAD)
+
+static cairo_test_t test = {
+ "mask",
+ "Tests of cairo_mask",
+ IMAGE_WIDTH, IMAGE_HEIGHT
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_surface_t *tmp_surface;
+ cairo_pattern_t *tmp_pattern;
+ int i, j, k;
+ cairo_t *cr2;
+
+ /* Some of our drawing is unbounded, so we draw each test to
+ * a temporary surface and copy over.
+ */
+ tmp_surface = cairo_surface_create_similar (cairo_get_target (cr),
+ CAIRO_FORMAT_ARGB32,
+ IMAGE_WIDTH, IMAGE_HEIGHT);
+ cr2 = cairo_create (tmp_surface);
+
+ tmp_pattern = cairo_pattern_create_for_surface (tmp_surface);
+ cairo_set_source (cr, tmp_pattern);
+
+ for (k = 0; k < ARRAY_SIZE (clip_funcs); k++) {
+ for (j = 0; j < ARRAY_SIZE (mask_funcs); j++) {
+ for (i = 0; i < ARRAY_SIZE (pattern_funcs); i++) {
+ int x = i * (WIDTH + PAD) + PAD;
+ int y = (ARRAY_SIZE (mask_funcs) * k + j) * (HEIGHT + PAD) + PAD;
+
+ /* Clear area we are going to be drawing onto */
+ cairo_save (cr2);
+ cairo_set_source_rgba (cr2, 0, 0, 0, 0); /* transparent */
+ cairo_set_operator (cr2, CAIRO_OPERATOR_SOURCE);
+ cairo_rectangle (cr2, x, y, WIDTH, HEIGHT);
+ cairo_fill (cr2);
+ cairo_restore (cr2);
+
+ /* draw */
+ cairo_save (cr2);
+
+ clip_funcs[k] (cr2, x, y);
+ pattern_funcs[i] (cr2, x, y);
+ mask_funcs[j] (cr2, x, y);
+
+ cairo_restore (cr2);
+
+ /* Copy back to the main pixmap */
+ cairo_rectangle (cr, x, y, WIDTH, HEIGHT);
+ cairo_fill (cr);
+ }
+ }
+ }
+
+ cairo_destroy (cr2);
+ cairo_surface_destroy (tmp_surface);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/move-to-show-surface-ref.png b/test/move-to-show-surface-ref.png
new file mode 100644
index 0000000..765adc4
--- /dev/null
+++ b/test/move-to-show-surface-ref.png
Binary files differ
diff --git a/test/move_to_show_surface.c b/test/move-to-show-surface.c
index 6dcda21..c5cc1ae 100644
--- a/test/move_to_show_surface.c
+++ b/test/move-to-show-surface.c
@@ -32,34 +32,46 @@
* bit of poking around suggests this isn't a regression, (at least
* not since the last pixman snapshot).
*
+ * 2005-04-02 Carl Worth <cworth@cworth.org>
+ *
+ * Status: RESOLVED
+ *
+ * Inside cairo_show_surface the current point was being used as
+ * both source and destination offsets. After fixing that to use 0,0
+ * as the source offset and the current point as the destination
+ * offset, the bug seems to be gone.
+ *
*/
-
-#include "cairo_test.h"
+#include "cairo-test.h"
cairo_test_t test = {
- "move_to_show_surface",
+ "move-to-show-surface",
"Tests calls to cairo_show_surface after cairo_move_to",
2, 2
};
-static void
+static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_surface_t *surface;
- uint32_t colors[4] = {
+ unsigned long colors[4] = {
0xffffffff, 0xffff0000,
0xff00ff00, 0xff0000ff
};
int i;
for (i=0; i < 4; i++) {
- surface = cairo_surface_create_for_image ((char *) &colors[i],
- CAIRO_FORMAT_ARGB32, 1, 1, 4);
- cairo_move_to (cr, i % 2, i / 2);
- cairo_show_surface (cr, surface, 1, 1);
+ surface = cairo_image_surface_create_for_data ((unsigned char *) &colors[i],
+ CAIRO_FORMAT_ARGB32,
+ 1, 1, 4);
+ cairo_set_source_surface (cr, surface,
+ i % 2, i / 2);
+ cairo_paint (cr);
cairo_surface_destroy (surface);
}
+
+ return CAIRO_TEST_SUCCESS;
}
int
diff --git a/test/paint-ref.png b/test/paint-ref.png
new file mode 100644
index 0000000..fff03b3
--- /dev/null
+++ b/test/paint-ref.png
Binary files differ
diff --git a/test/paint-with-alpha-ref.png b/test/paint-with-alpha-ref.png
new file mode 100644
index 0000000..d821b5e
--- /dev/null
+++ b/test/paint-with-alpha-ref.png
Binary files differ
diff --git a/test/paint-with-alpha.c b/test/paint-with-alpha.c
new file mode 100644
index 0000000..f4734af
--- /dev/null
+++ b/test/paint-with-alpha.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include "cairo-test.h"
+
+cairo_test_t test = {
+ "paint-with-alpha",
+ "Simple test of cairo_paint_with_alpha",
+ 12, 12
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_surface_t *surface;
+ unsigned long data[16] = {
+ 0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
+ 0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
+
+ 0xff00ff00, 0xff00ff00, 0xff0000ff, 0xff0000ff,
+ 0xff00ff00, 0xff00ff00, 0xff0000ff, 0xff0000ff
+ };
+
+ surface = cairo_image_surface_create_for_data ((unsigned char *) data,
+ CAIRO_FORMAT_ARGB32, 4, 4, 16);
+
+ cairo_scale (cr, 2, 2);
+
+ cairo_set_source_surface (cr, surface, 1 , 1);
+ cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
+ cairo_paint_with_alpha (cr, 0.5);
+
+ cairo_surface_destroy (surface);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/paint.c b/test/paint.c
new file mode 100644
index 0000000..126becc
--- /dev/null
+++ b/test/paint.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include "cairo-test.h"
+
+cairo_test_t test = {
+ "paint",
+ "Test calls to cairo_paint",
+ 8, 8
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_set_source_rgb (cr, 0, 0, 1);
+ cairo_paint (cr);
+
+ cairo_translate (cr, 2, 2);
+ cairo_scale (cr, 0.5, 0.5);
+
+ cairo_set_source_rgb (cr, 1, 0, 0);
+ cairo_paint (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/path-data-ref.png b/test/path-data-ref.png
new file mode 100644
index 0000000..f8bc647
--- /dev/null
+++ b/test/path-data-ref.png
Binary files differ
diff --git a/test/path-data.c b/test/path-data.c
new file mode 100644
index 0000000..b2d7edb
--- /dev/null
+++ b/test/path-data.c
@@ -0,0 +1,184 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include <stdlib.h>
+#include "cairo-test.h"
+
+cairo_test_t test = {
+ "path-data",
+ "Tests calls to path_data functions: cairo_copy_path_data, cairo_copy_path_data_flat, and cairo_append_path_data",
+ 45, 53
+};
+
+static void
+scale_by_two (double *x, double *y)
+{
+ *x = *x * 2.0;
+ *y = *y * 2.0;
+}
+
+typedef void (*munge_func_t) (double *x, double *y);
+
+static void
+munge_and_set_path (cairo_t *cr,
+ cairo_path_t *path,
+ munge_func_t munge)
+{
+ int i;
+ cairo_path_data_t *p;
+ double x1, y1, x2, y2, x3, y3;
+
+ for (i=0; i < path->num_data; i += path->data[i].header.length) {
+ p = &path->data[i];
+ switch (p->header.type) {
+ case CAIRO_PATH_MOVE_TO:
+ x1 = p[1].point.x; y1 = p[1].point.y;
+ (munge) (&x1, &y1);
+ cairo_move_to (cr, x1, y1);
+ break;
+ case CAIRO_PATH_LINE_TO:
+ x1 = p[1].point.x; y1 = p[1].point.y;
+ (munge) (&x1, &y1);
+ cairo_line_to (cr, x1, y1);
+ break;
+ case CAIRO_PATH_CURVE_TO:
+ x1 = p[1].point.x; y1 = p[1].point.y;
+ x2 = p[2].point.x; y2 = p[2].point.y;
+ x3 = p[3].point.x; y3 = p[3].point.y;
+ (munge) (&x1, &y1);
+ (munge) (&x2, &y2);
+ (munge) (&x3, &y3);
+ cairo_curve_to (cr,
+ x1, y1,
+ x2, y2,
+ x3, y3);
+ break;
+ case CAIRO_PATH_CLOSE_PATH:
+ cairo_close_path (cr);
+ break;
+ }
+ }
+}
+
+static void
+make_path (cairo_t *cr)
+{
+ cairo_rectangle (cr, 0, 0, 5, 5);
+ cairo_move_to (cr, 15, 2.5);
+ cairo_arc (cr, 12.5, 2.5, 2.5, 0, 2 * M_PI);
+}
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_path_t *path;
+
+ /* copy path, munge, and fill */
+ cairo_translate (cr, 5, 5);
+ make_path (cr);
+ path = cairo_copy_path (cr);
+
+ cairo_new_path (cr);
+ munge_and_set_path (cr, path, scale_by_two);
+ cairo_path_destroy (path);
+ cairo_fill (cr);
+
+ /* copy flattened path, munge, and fill */
+ cairo_translate (cr, 0, 15);
+ make_path (cr);
+ path = cairo_copy_path_flat (cr);
+
+ cairo_new_path (cr);
+ munge_and_set_path (cr, path, scale_by_two);
+ cairo_path_destroy (path);
+ cairo_fill (cr);
+
+ /* append two copies of path, and fill */
+ cairo_translate (cr, 0, 15);
+ cairo_scale (cr, 2.0, 2.0);
+ make_path (cr);
+ path = cairo_copy_path (cr);
+
+ cairo_new_path (cr);
+ cairo_append_path (cr, path);
+ cairo_translate (cr, 2.5, 2.5);
+ cairo_append_path (cr, path);
+
+ cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+ cairo_fill (cr);
+
+ cairo_path_destroy (path);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ cairo_t *cr;
+ cairo_path_data_t data;
+ cairo_path_t path;
+ cairo_surface_t *surface;
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
+
+ /* Test a few error cases for cairo_append_path_data */
+ cr = cairo_create (surface);
+ cairo_append_path (cr, NULL);
+ if (cairo_status (cr) != CAIRO_STATUS_NULL_POINTER)
+ return 1;
+ cairo_destroy (cr);
+
+ cr = cairo_create (surface);
+ path.data = NULL;
+ path.num_data = 0;
+ cairo_append_path (cr, &path);
+ if (cairo_status (cr) != CAIRO_STATUS_NULL_POINTER)
+ return 1;
+ cairo_destroy (cr);
+
+ cr = cairo_create (surface);
+ /* Intentionally insert bogus header.length value (otherwise would be 2) */
+ data.header.type = CAIRO_PATH_MOVE_TO;
+ data.header.length = 1;
+ path.data = &data;
+ path.num_data = 1;
+ cairo_append_path (cr, &path);
+ if (cairo_status (cr) != CAIRO_STATUS_INVALID_PATH_DATA)
+ return 1;
+ cairo_destroy (cr);
+
+ /* And test the degnerate case */
+ cr = cairo_create (surface);
+ path.num_data = 0;
+ cairo_append_path (cr, &path);
+ if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
+ return 1;
+ cairo_destroy (cr);
+
+ cairo_surface_destroy (surface);
+
+ return cairo_test (&test, draw);
+}
diff --git a/test/pdf-clip.c b/test/pdf-clip.c
new file mode 100644
index 0000000..4d6d75c
--- /dev/null
+++ b/test/pdf-clip.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Kristian Høgsberg <krh@redhat.com>
+ */
+
+#include <stdio.h>
+
+#include <cairo-pdf.h>
+#include "cairo-test.h"
+
+/* Test PDF clipping */
+
+#define WIDTH_IN_POINTS 600
+#define HEIGHT_IN_POINTS 600
+
+static void
+test_clip (cairo_t *cr, double width, double height)
+{
+ cairo_t *cr2;
+
+ /* Basic test; set a square clip and draw a circle to be clipped
+ * against it.*/
+
+ cairo_rectangle (cr, 100, 100, 400, 400);
+ cairo_clip (cr);
+ cairo_arc (cr, 300, 300, 210, 0, 2 * M_PI);
+ cairo_set_source_rgb (cr, 1, 0, 0);
+ cairo_fill (cr);
+
+ /* Add a plus shaped clip path to the square clip and draw a big
+ * green square to test the new clip path. */
+
+ cairo_save (cr);
+
+ cairo_rectangle (cr, 250, 100, 100, 400);
+ cairo_rectangle (cr, 100, 250, 400, 100);
+ cairo_clip (cr);
+
+ cairo_rectangle (cr, 0, 0, 600, 600);
+ cairo_set_source_rgb (cr, 0, 1, 0);
+ cairo_fill (cr);
+
+ cairo_restore (cr);
+
+ /* Set a bezier shape in addition to the rectangle clip set before
+ * the cairo_save() to verify that we successfully removed the
+ * plus shaped clip path and can set a new clip.*/
+
+ cairo_move_to (cr, 600, 0);
+ cairo_curve_to (cr, 300, 600, 0, 300, 600, 0);
+ cairo_clip (cr);
+
+ cairo_rectangle (cr, 0, 0, 600, 600);
+ cairo_set_source_rgb (cr, 0, 0, 1);
+ cairo_fill (cr);
+
+ /* Create a new context for this surface to test overlapped
+ * drawing from two contexts */
+ cr2 = cairo_create (cairo_get_target (cr));
+
+ /* Using the new context, draw a black vertical line, which should
+ * appear unclipped on top of everything drawn so far. */
+ cairo_move_to (cr2, 110, 0);
+ cairo_line_to (cr2, 110, 600);
+ cairo_stroke (cr2);
+
+ /* Using the first context, draw another black vertical line.
+ * This line should be clipped agaist the bezier clipping path set
+ * earlier. */
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_move_to (cr, 400, 0);
+ cairo_line_to (cr, 400, 600);
+ cairo_stroke (cr);
+
+ cairo_destroy (cr2);
+
+ /* Test reset clip. Draw a transparent black circle over
+ * everything. Specifically, make sure the circle extends outside
+ * the square clip set at the top of this function. */
+ cairo_reset_clip (cr);
+ cairo_arc (cr, 300, 300, 220, 0, 2 * M_PI);
+ cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
+ cairo_fill (cr);
+}
+
+int
+main (void)
+{
+ cairo_t *cr;
+ const char *filename = "pdf-clip.pdf";
+ cairo_surface_t *surface;
+
+ printf("\n");
+
+ surface = cairo_pdf_surface_create (filename,
+ WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
+ if (surface == NULL) {
+ fprintf (stderr, "Failed to create pdf surface for file %s\n", filename);
+ return CAIRO_TEST_FAILURE;
+ }
+
+ cr = cairo_create (surface);
+
+ test_clip (cr, WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
+ cairo_show_page (cr);
+
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+
+ printf ("pdf-surface: Please check %s to make sure it looks happy.\n",
+ filename);
+
+ return 0;
+}
diff --git a/test/pdf-surface.c b/test/pdf-surface.c
new file mode 100644
index 0000000..863da53
--- /dev/null
+++ b/test/pdf-surface.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include <stdio.h>
+
+#include <cairo-pdf.h>
+#include "cairo-test.h"
+
+/* Pretty boring test just to make sure things aren't crashing ---
+ * no verification that we're getting good results yet.
+ * But you can manually view the image to make sure it looks happy.
+ */
+
+#define WIDTH_IN_INCHES 3
+#define HEIGHT_IN_INCHES 3
+#define WIDTH_IN_POINTS (WIDTH_IN_INCHES * 72.0)
+#define HEIGHT_IN_POINTS (HEIGHT_IN_INCHES * 72.0)
+
+static void
+draw (cairo_t *cr, double width, double height)
+{
+#define STROKE_WIDTH .04
+
+ double size;
+
+ if (width > height)
+ size = height;
+ else
+ size = width;
+
+ cairo_translate (cr, (width - size) / 2.0, (height - size) / 2.0);
+ cairo_scale (cr, size, size);
+
+ /* Fill face */
+ cairo_arc (cr, 0.5, 0.5, 0.5 - STROKE_WIDTH, 0, 2 * M_PI);
+ cairo_set_source_rgb (cr, 1, 1, 0);
+ cairo_save (cr);
+ {
+ cairo_fill (cr);
+ }
+ cairo_restore (cr);
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+
+ /* Stroke face */
+ cairo_set_line_width (cr, STROKE_WIDTH / 2.0);
+ cairo_stroke (cr);
+
+ /* Eyes */
+ cairo_set_line_width (cr, STROKE_WIDTH);
+ cairo_arc (cr, 0.3, 0.4, STROKE_WIDTH, 0, 2 * M_PI);
+ cairo_fill (cr);
+ cairo_arc (cr, 0.7, 0.4, STROKE_WIDTH, 0, 2 * M_PI);
+ cairo_fill (cr);
+
+ /* Mouth */
+ cairo_move_to (cr, 0.3, 0.7);
+ cairo_curve_to (cr,
+ 0.4, 0.8,
+ 0.6, 0.8,
+ 0.7, 0.7);
+ cairo_stroke (cr);
+}
+
+int
+main (void)
+{
+ cairo_t *cr;
+ const char *filename = "pdf-surface.pdf";
+ cairo_surface_t *surface;
+
+ printf("\n");
+
+ surface = cairo_pdf_surface_create (filename,
+ WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
+ if (surface == NULL) {
+ fprintf (stderr, "Failed to create pdf surface for file %s\n", filename);
+ return CAIRO_TEST_FAILURE;
+ }
+
+ cr = cairo_create (surface);
+
+ draw (cr, WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
+
+ cairo_show_page (cr);
+
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+
+ printf ("pdf-surface: Please check pdf-surface.pdf to make sure it looks happy.\n");
+
+ return 0;
+}
diff --git a/test/pixman_rotate-ref.png b/test/pixman-rotate-ref.png
index 7e47a4d..7e47a4d 100644
--- a/test/pixman_rotate-ref.png
+++ b/test/pixman-rotate-ref.png
Binary files differ
diff --git a/test/pixman-rotate.c b/test/pixman-rotate.c
new file mode 100644
index 0000000..5c6fe41
--- /dev/null
+++ b/test/pixman-rotate.c
@@ -0,0 +1,76 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include <cairo.h>
+#include <cairo-pdf.h>
+
+#include "cairo-test.h"
+
+#define WIDTH 32
+#define HEIGHT WIDTH
+
+#define IMAGE_WIDTH (3 * WIDTH)
+#define IMAGE_HEIGHT IMAGE_WIDTH
+
+cairo_test_t test = {
+ "pixman-rotate",
+ "Exposes pixman off-by-one error when rotating",
+ IMAGE_WIDTH, IMAGE_HEIGHT
+};
+
+/* Draw the word cairo at NUM_TEXT different angles */
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_surface_t *stamp;
+ cairo_t *cr2;
+
+ stamp = cairo_surface_create_similar (cairo_get_target (cr),
+ CAIRO_FORMAT_ARGB32,
+ WIDTH, HEIGHT);
+ cr2 = cairo_create (stamp);
+ {
+ cairo_new_path (cr2);
+ cairo_rectangle (cr2, WIDTH / 4, HEIGHT / 4, WIDTH / 2, HEIGHT / 2);
+ cairo_set_source_rgba (cr2, 1, 0, 0, 0.8);
+ cairo_fill (cr2);
+
+ cairo_rectangle (cr2, 0, 0, WIDTH, HEIGHT);
+ cairo_set_line_width (cr2, 2);
+ cairo_set_source_rgb (cr2, 0, 0, 0);
+ cairo_stroke (cr2);
+ }
+ cairo_destroy (cr2);
+
+ /* Draw a translucent rectangle for reference where the rotated
+ * image should be. */
+ cairo_new_path (cr);
+ cairo_rectangle (cr, WIDTH, HEIGHT, WIDTH, HEIGHT);
+ cairo_set_source_rgba (cr, 1, 1, 0, 0.3);
+ cairo_fill (cr);
+
+#if 1 /* Set to 0 to generate reference image */
+ cairo_translate (cr, 2 * WIDTH, 2 * HEIGHT);
+ cairo_rotate (cr, M_PI);
+#else
+ cairo_translate (cr, WIDTH, HEIGHT);
+#endif
+
+ cairo_set_source_surface (cr, stamp, 0, 0);
+ cairo_paint (cr);
+
+ cairo_show_page (cr);
+
+ cairo_surface_destroy (stamp);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test_expect_failure (&test, draw,
+ "known off-by-one bug when rotating a pixman image");
+}
diff --git a/test/pixman_rotate.c b/test/pixman_rotate.c
deleted file mode 100644
index 6a64a9a..0000000
--- a/test/pixman_rotate.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include <cairo.h>
-#include <cairo-png.h>
-#include <cairo-pdf.h>
-
-#include "cairo_test.h"
-
-#define WIDTH 32
-#define HEIGHT WIDTH
-
-#define IMAGE_WIDTH (3 * WIDTH)
-#define IMAGE_HEIGHT IMAGE_WIDTH
-
-cairo_test_t test = {
- "pixman_rotate",
- "Exposes pixman off-by-one error when rotating",
- IMAGE_WIDTH, IMAGE_HEIGHT
-};
-
-/* Draw the word cairo at NUM_TEXT different angles */
-static void
-draw (cairo_t *cr, int width, int height)
-{
- cairo_surface_t *target, *stamp;
-
- target = cairo_current_target_surface (cr);
- cairo_surface_reference (target);
-
- stamp = cairo_surface_create_similar (target, CAIRO_FORMAT_ARGB32,
- WIDTH, HEIGHT);
- cairo_set_target_surface (cr, stamp);
- cairo_new_path (cr);
- cairo_rectangle (cr, WIDTH / 4, HEIGHT / 4, WIDTH / 2, HEIGHT / 2);
- cairo_set_rgb_color (cr, 1, 0, 0);
- cairo_set_alpha (cr, 0.8);
- cairo_fill (cr);
-
- cairo_rectangle (cr, 0, 0, WIDTH, HEIGHT);
- cairo_set_line_width (cr, 2);
- cairo_set_rgb_color (cr, 0, 0, 0);
- cairo_set_alpha (cr, 1);
- cairo_stroke (cr);
-
- cairo_set_target_surface (cr, target);
-
- /* Draw a translucent rectangle for reference where the rotated
- * image should be. */
- cairo_new_path (cr);
- cairo_rectangle (cr, WIDTH, HEIGHT, WIDTH, HEIGHT);
- cairo_set_rgb_color (cr, 1, 1, 0);
- cairo_set_alpha (cr, 0.3);
- cairo_fill (cr);
-
-#if 1 /* Set to 0 to generate reference image */
- cairo_translate (cr, 2 * WIDTH, 2 * HEIGHT);
- cairo_rotate (cr, M_PI);
-#else
- cairo_translate (cr, WIDTH, HEIGHT);
-#endif
-
- cairo_set_alpha (cr, 1);
- cairo_show_surface (cr, stamp, WIDTH + 2, HEIGHT + 2);
-
- cairo_show_page (cr);
-
- cairo_surface_destroy (stamp);
- cairo_surface_destroy (target);
-}
-
-int
-main (void)
-{
- return cairo_test (&test, draw);
-}
diff --git a/test/ps-surface.c b/test/ps-surface.c
new file mode 100644
index 0000000..5d5bf4e
--- /dev/null
+++ b/test/ps-surface.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include <stdio.h>
+
+#include <cairo-ps.h>
+#include "cairo-test.h"
+
+/* Pretty boring test just to make sure things aren't crashing ---
+ * no verification that we're getting good results yet.
+ * But you can manually view the image to make sure it looks happy.
+ */
+
+#define WIDTH_IN_INCHES 3
+#define HEIGHT_IN_INCHES 3
+#define WIDTH_IN_POINTS (WIDTH_IN_INCHES * 72.0)
+#define HEIGHT_IN_POINTS (HEIGHT_IN_INCHES * 72.0)
+
+static void
+draw (cairo_t *cr, double width, double height)
+{
+#define STROKE_WIDTH .04
+
+ double size;
+
+ if (width > height)
+ size = height;
+ else
+ size = width;
+
+ cairo_translate (cr, (width - size) / 2.0, (height - size) / 2.0);
+ cairo_scale (cr, size, size);
+
+ /* Fill face */
+ cairo_arc (cr, 0.5, 0.5, 0.5 - STROKE_WIDTH, 0, 2 * M_PI);
+ cairo_set_source_rgb (cr, 1, 1, 0);
+ cairo_save (cr);
+ {
+ cairo_fill (cr);
+ }
+ cairo_restore (cr);
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+
+ /* Stroke face */
+ cairo_set_line_width (cr, STROKE_WIDTH / 2.0);
+ cairo_stroke (cr);
+
+ /* Eyes */
+ cairo_set_line_width (cr, STROKE_WIDTH);
+ cairo_arc (cr, 0.3, 0.4, STROKE_WIDTH, 0, 2 * M_PI);
+ cairo_fill (cr);
+ cairo_arc (cr, 0.7, 0.4, STROKE_WIDTH, 0, 2 * M_PI);
+ cairo_fill (cr);
+
+ /* Mouth */
+ cairo_move_to (cr, 0.3, 0.7);
+ cairo_curve_to (cr,
+ 0.4, 0.8,
+ 0.6, 0.8,
+ 0.7, 0.7);
+ cairo_stroke (cr);
+}
+
+int
+main (void)
+{
+ cairo_t *cr;
+ const char *filename = "ps-surface.ps";
+ cairo_surface_t *surface;
+
+ printf("\n");
+
+ surface = cairo_ps_surface_create (filename,
+ WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
+ if (surface == NULL) {
+ cairo_test_log ("Failed to create pdf surface for file %s\n", filename);
+ return CAIRO_TEST_FAILURE;
+ }
+
+ cr = cairo_create (surface);
+
+ draw (cr, WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
+
+ cairo_show_page (cr);
+
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+
+ printf ("ps-surface: Please check ps-surface.ps to make sure it looks happy.\n");
+
+ return 0;
+}
diff --git a/test/read_png.c b/test/read-png.c
index e7e2a92..96259df 100644
--- a/test/read_png.c
+++ b/test/read-png.c
@@ -25,11 +25,26 @@
* Author: Carl D. Worth <cworth@isi.edu>
*/
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if HAVE_STDINT_H
+# include <stdint.h>
+#elif HAVE_INTTYPES_H
+# include <inttypes.h>
+#elif HAVE_SYS_INT_TYPES_H
+# include <sys/int_types.h>
+#else
+#error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, etc.)
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <png.h>
-#include "read_png.h"
+#include "cairo-test.h"
+#include "read-png.h"
#include "xmalloc.h"
static void
@@ -40,18 +55,18 @@ premultiply_data (png_structp png,
int i;
for (i = 0; i < row_info->rowbytes; i += 4) {
- unsigned char *base = &data[i];
- unsigned char blue = base[0];
- unsigned char green = base[1];
- unsigned char red = base[2];
- unsigned char alpha = base[3];
- unsigned long p;
+ uint8_t *base = &data[i];
+ uint8_t blue = base[0];
+ uint8_t green = base[1];
+ uint8_t red = base[2];
+ uint8_t alpha = base[3];
+ uint32_t p;
red = ((unsigned) red * (unsigned) alpha + 127) / 255;
green = ((unsigned) green * (unsigned) alpha + 127) / 255;
blue = ((unsigned) blue * (unsigned) alpha + 127) / 255;
p = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0);
- memcpy (base, &p, sizeof (unsigned long));
+ memcpy (base, &p, sizeof (uint32_t));
}
}
@@ -76,12 +91,14 @@ read_png_argb32 (const char *filename,
file = fopen (filename, "rb");
if (file == NULL) {
+ cairo_test_log ("Error: File not found: %s\n", filename);
return READ_PNG_FILE_NOT_FOUND;
}
sig_bytes = fread (png_sig, 1, PNG_SIG_SIZE, file);
if (png_check_sig (png_sig, sig_bytes) == 0) {
fclose (file);
+ cairo_test_log ("Error: File is not a PNG image: %s\n", filename);
return READ_PNG_FILE_NOT_PNG;
}
@@ -92,6 +109,7 @@ read_png_argb32 (const char *filename,
NULL);
if (png == NULL) {
fclose (file);
+ cairo_test_log ("Error: Out of memory while reading %s\n", filename);
return READ_PNG_NO_MEMORY;
}
@@ -99,6 +117,7 @@ read_png_argb32 (const char *filename,
if (info == NULL) {
fclose (file);
png_destroy_read_struct (&png, NULL, NULL);
+ cairo_test_log ("Error: Out of memory while reading %s\n", filename);
return READ_PNG_NO_MEMORY;
}
diff --git a/test/read_png.h b/test/read-png.h
index 9c9ba43..9c9ba43 100644
--- a/test/read_png.h
+++ b/test/read-png.h
diff --git a/test/rel-path-ref.png b/test/rel-path-ref.png
new file mode 100644
index 0000000..7b7007f
--- /dev/null
+++ b/test/rel-path-ref.png
Binary files differ
diff --git a/test/rel-path.c b/test/rel-path.c
new file mode 100644
index 0000000..0e4c73a
--- /dev/null
+++ b/test/rel-path.c
@@ -0,0 +1,56 @@
+/*
+ * $Id: rel-path.c,v 1.1 2005/05/02 19:36:20 keithp Exp $
+ *
+ * Copyright © 2005 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "cairo-test.h"
+
+#define SIZE 10
+
+cairo_test_t test = {
+ "rel-path",
+ "Tests calls to various relative path functions",
+ SIZE, SIZE
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_move_to (cr, 0, 0);
+ cairo_rel_move_to (cr, SIZE, SIZE/2);
+ cairo_rel_line_to (cr, -SIZE, SIZE/2);
+ cairo_rel_curve_to (cr,
+ SIZE/2, -SIZE/2,
+ SIZE*2/3, -SIZE/3,
+ SIZE/2, -SIZE);
+
+ cairo_stroke (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/scale-source-surface-paint-ref.png b/test/scale-source-surface-paint-ref.png
new file mode 100644
index 0000000..ec3c059
--- /dev/null
+++ b/test/scale-source-surface-paint-ref.png
Binary files differ
diff --git a/test/scale-source-surface-paint.c b/test/scale-source-surface-paint.c
new file mode 100644
index 0000000..7b1cc38
--- /dev/null
+++ b/test/scale-source-surface-paint.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include "cairo-test.h"
+
+cairo_test_t test = {
+ "scale-source-surface-paint",
+ "Test call sequence: cairo_scale; cairo_set_source_surface; cairo_paint",
+ 12, 12
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_surface_t *surface;
+ unsigned long data[16] = {
+ 0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
+ 0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
+
+ 0xff00ff00, 0xff00ff00, 0xff0000ff, 0xff0000ff,
+ 0xff00ff00, 0xff00ff00, 0xff0000ff, 0xff0000ff
+ };
+
+ surface = cairo_image_surface_create_for_data ((unsigned char *) data,
+ CAIRO_FORMAT_ARGB32, 4, 4, 16);
+
+ cairo_scale (cr, 2, 2);
+
+ cairo_set_source_surface (cr, surface, 1 , 1);
+ cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
+ cairo_paint (cr);
+
+ cairo_surface_destroy (surface);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/select-font-no-show-text.c b/test/select-font-no-show-text.c
new file mode 100644
index 0000000..b99dfea
--- /dev/null
+++ b/test/select-font-no-show-text.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl Worth <cworth@redhat.com>
+ */
+
+/* Bug history
+ *
+ * 2005-04-12 Carl Worth <cworth@cworth.org>
+ *
+ * I noticed that if we call cairo_select_font_face, but then do a
+ * cairo_destroy before ever drawing any text, then we get:
+ *
+ * *** glibc detected *** double free or corruption (fasttop): 0x083274d0 ***
+ * Aborted
+ *
+ * 2005-04-14 Owen Taylor <otaylor@redhat.com>
+ *
+ * Fixed... just a stray free().
+ */
+
+#include <math.h>
+#include "cairo-test.h"
+
+static cairo_test_t test = {
+ "select-font-no-show-text",
+ "Test calling cairo_select_font_face but never drawing text.",
+ 0, 0
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_select_font_face (cr, "Bitstream Vera Sans",
+ CAIRO_FONT_SLANT_NORMAL,
+ CAIRO_FONT_WEIGHT_BOLD);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/self-copy-ref.png b/test/self-copy-ref.png
new file mode 100644
index 0000000..92a20db
--- /dev/null
+++ b/test/self-copy-ref.png
Binary files differ
diff --git a/test/self-copy.c b/test/self-copy.c
new file mode 100644
index 0000000..5f4398b
--- /dev/null
+++ b/test/self-copy.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Owen Taylor <otaylor@redhat.com>
+ */
+
+#include <math.h>
+#include "cairo-test.h"
+#include <stdio.h>
+
+#define SIZE 40
+
+cairo_test_t test = {
+ "self-copy",
+ "Test copying from a surface to itself with a clip",
+ SIZE, SIZE
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_pattern_t *pattern;
+ cairo_matrix_t matrix;
+
+ /* Paint a diagonal division as a test image */
+ cairo_set_source_rgb (cr, 1, 1, 1); /* White */
+ cairo_paint (cr);
+
+ cairo_move_to (cr, SIZE, 0);
+ cairo_line_to (cr, SIZE, SIZE);
+ cairo_line_to (cr, 0, SIZE);
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_fill (cr);
+
+ /* Create a pattern with the target surface as the source,
+ * offset by SIZE/2
+ */
+ pattern = cairo_pattern_create_for_surface (cairo_get_target (cr));
+
+ cairo_matrix_init_translate (&matrix, - SIZE / 2, - SIZE / 2);
+ cairo_pattern_set_matrix (pattern, &matrix);
+
+ cairo_set_source (cr, pattern);
+ cairo_pattern_destroy (pattern);
+
+ /* Copy two rectangles from the upper-left quarter of the image to
+ * the lower right. It will work if we use cairo_fill(), but the
+ * cairo_clip() cairo_paint() combination fails because the clip
+ * on the surface as a destination affects it as the source as
+ * well.
+ */
+ cairo_rectangle (cr,
+ 2 * SIZE / 4, 2 * SIZE / 4,
+ SIZE / 4, SIZE / 4);
+ cairo_rectangle (cr,
+ 3 * SIZE / 4, 3 * SIZE / 4,
+ SIZE / 4, SIZE / 4);
+ cairo_clip (cr);
+ cairo_paint (cr);
+
+ return CAIRO_TEST_SUCCESS;
+
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/self-intersecting-ref.png b/test/self-intersecting-ref.png
new file mode 100644
index 0000000..384b0ab
--- /dev/null
+++ b/test/self-intersecting-ref.png
Binary files differ
diff --git a/test/self-intersecting.c b/test/self-intersecting.c
new file mode 100644
index 0000000..2dfd796
--- /dev/null
+++ b/test/self-intersecting.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+/* Bug history
+ *
+ * 2005-06-01 Carl Worth <cworth@cworth.org>
+ *
+ * There's a long-standing bug in that self-intersecting paths give
+ * an incorrect result when stroked. The problem is that the
+ * trapezoids are generated incrementally along the stroke and as
+ * such, are not disjoint. The errant intersections of these
+ * trapezoids then leads to overfilled pixels.
+ *
+ * The test belows first creates and fills a path. Then it creates a
+ * second path which has a stroked boundary identical to the first
+ * filled path. But the results of the two operations are
+ * different. The most obvious difference is in the central region
+ * where the entire path intersects itself. But notice that every
+ * time the path turns there are also errors on the inside of the
+ * turn, (since the subsequent trapezoids along the path intersect).
+ */
+
+#include "cairo-test.h"
+
+cairo_test_t test = {
+ "self-intersecting",
+ "Test strokes of self-intersecting paths",
+ 10, 20
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_translate (cr, 1.0, 1.0);
+
+ cairo_set_source_rgb (cr, 1, 0, 0); /* red */
+
+ /* First draw the desired shape with a fill */
+ cairo_rectangle (cr, 0.5, 0.5, 4.0, 4.0);
+ cairo_rectangle (cr, 3.5, 3.5, 4.0, 4.0);
+ cairo_rectangle (cr, 3.5, 1.5, -2.0, 2.0);
+ cairo_rectangle (cr, 6.5, 4.5, -2.0, 2.0);
+
+ cairo_fill (cr);
+
+ /* Then try the same thing with a stroke */
+ cairo_translate (cr, 0, 10);
+ cairo_move_to (cr, 1.0, 1.0);
+ cairo_rel_line_to (cr, 3.0, 0.0);
+ cairo_rel_line_to (cr, 0.0, 6.0);
+ cairo_rel_line_to (cr, 3.0, 0.0);
+ cairo_rel_line_to (cr, 0.0, -3.0);
+ cairo_rel_line_to (cr, -6.0, 0.0);
+ cairo_close_path (cr);
+
+ cairo_set_line_width (cr, 1.0);
+ cairo_stroke (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test_expect_failure (&test, draw,
+ "Self-intersecting strokes are wrong due to incremental trapezoidization.");
+}
diff --git a/test/set-source-ref.png b/test/set-source-ref.png
new file mode 100644
index 0000000..c5d5e92
--- /dev/null
+++ b/test/set-source-ref.png
Binary files differ
diff --git a/test/set-source.c b/test/set-source.c
new file mode 100644
index 0000000..568935d
--- /dev/null
+++ b/test/set-source.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include "cairo-test.h"
+
+cairo_test_t test = {
+ "set-source",
+ "Tests calls to various set_source functions",
+ 5, 5
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ int i;
+ /* This color value might need to change in the future when we fix
+ * the rounding in cairo-color.c */
+ unsigned long color = 0x7f19334C;
+ cairo_surface_t *surface;
+ cairo_pattern_t *pattern;
+
+ surface = cairo_image_surface_create_for_data ((unsigned char *) &color,
+ CAIRO_FORMAT_ARGB32, 1, 1, 4);
+ pattern = cairo_pattern_create_for_surface (surface);
+ cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+
+ /* Several different means of making mostly the same color (though
+ * we can't get anything but alpha==1.0 out of
+ * cairo_set_source_rgb. */
+ for (i=0; i < width; i++) {
+ switch (i) {
+ case 0:
+ cairo_set_source_rgb (cr, .6, .7, .8);
+ break;
+ case 1:
+ cairo_set_source_rgba (cr, .2, .4, .6, 0.5);
+ break;
+ case 2:
+#if WE_HAD_SUPPORT_FOR_PREMULTIPLIED
+ cairo_set_source_rgba_premultiplied (cr, .1, .2, .3, 0.5);
+#else
+ cairo_set_source_rgba (cr, .2, .4, .6, 0.5);
+#endif
+ break;
+ case 3:
+ default:
+ cairo_set_source (cr, pattern);
+ break;
+ }
+
+ cairo_rectangle (cr, i, 0, 1, height);
+ cairo_fill (cr);
+ }
+
+ cairo_pattern_destroy (pattern);
+ cairo_surface_destroy (surface);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/source-clip-ref.png b/test/source-clip-ref.png
new file mode 100644
index 0000000..8df2bff
--- /dev/null
+++ b/test/source-clip-ref.png
Binary files differ
diff --git a/test/source-clip.c b/test/source-clip.c
new file mode 100644
index 0000000..73be6b4
--- /dev/null
+++ b/test/source-clip.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Owen Taylor <otaylor@redhat.com>
+ */
+
+#include <math.h>
+#include "cairo-test.h"
+#include <stdio.h>
+
+#define SIZE 50
+
+cairo_test_t test = {
+ "source-clip",
+ "Test using a surface with an active clip as a source",
+ SIZE, SIZE
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_pattern_t *pattern;
+ cairo_surface_t *source_surface;
+ cairo_t *cr2;
+
+ source_surface = cairo_surface_create_similar (cairo_get_target (cr),
+ CAIRO_FORMAT_ARGB32,
+ SIZE, SIZE);
+
+ cr2 = cairo_create (source_surface);
+
+ /* Fill the source surface with solid black */
+ cairo_set_source_rgb (cr2, 0, 0, 0);
+ cairo_paint (cr2);
+
+ /* Now leave a clip in place */
+ cairo_rectangle (cr2,
+ SIZE / 4, SIZE / 4,
+ SIZE / 2, SIZE / 2);
+ cairo_clip (cr2);
+
+ /* Fill the destination surface with solid white */
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_paint (cr);
+
+ /* Now draw the source surface onto the destination surface */
+ pattern = cairo_pattern_create_for_surface (source_surface);
+ cairo_set_source (cr, pattern);
+ cairo_paint (cr);
+
+ /* As the clip shouldn't matter, the result should be solid black */
+
+ cairo_destroy (cr2);
+ cairo_pattern_destroy (pattern);
+ cairo_surface_destroy (source_surface);
+
+ return CAIRO_TEST_SUCCESS;
+
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/source-surface-scale-paint-ref.png b/test/source-surface-scale-paint-ref.png
new file mode 100644
index 0000000..ec3c059
--- /dev/null
+++ b/test/source-surface-scale-paint-ref.png
Binary files differ
diff --git a/test/source-surface-scale-paint.c b/test/source-surface-scale-paint.c
new file mode 100644
index 0000000..9862ba5
--- /dev/null
+++ b/test/source-surface-scale-paint.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include "cairo-test.h"
+
+cairo_test_t test = {
+ "source-surface-scale-paint",
+ "Test call sequence: cairo_set_source_surface; cairo_scale; cairo_paint",
+ 12, 12
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_surface_t *surface;
+ unsigned long data[16] = {
+ 0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
+ 0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
+
+ 0xff00ff00, 0xff00ff00, 0xff0000ff, 0xff0000ff,
+ 0xff00ff00, 0xff00ff00, 0xff0000ff, 0xff0000ff
+ };
+
+ surface = cairo_image_surface_create_for_data ((unsigned char *) data,
+ CAIRO_FORMAT_ARGB32, 4, 4, 16);
+
+ cairo_set_source_surface (cr, surface, 2, 2);
+ cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
+ cairo_scale (cr, 2, 2);
+ cairo_paint (cr);
+
+ cairo_surface_destroy (surface);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test_expect_failure (&test, draw,
+ "cairo_set_source needs user space locking semantics");
+}
diff --git a/test/surface-finish-twice.c b/test/surface-finish-twice.c
new file mode 100644
index 0000000..3f24e39
--- /dev/null
+++ b/test/surface-finish-twice.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl Worth <cworth@cworth.org>
+ */
+
+/* Bug history
+ *
+ * 2005-04-10 stevech1097@yahoo.com.au
+ *
+ * Subject: [Bug 2950] New: *** glibc detected *** double free or corruption
+ * URL: https://bugs.freedesktop.org/show_bug.cgi?id=2950
+ *
+ * The following short program gives the error message:
+ *
+ * *** glibc detected *** double free or corruption: 0x082a7268 ***
+ * Aborted
+ *
+ * 2005-04-13 Carl Worth <cworth@cworth.org>
+ *
+ * Looks like surface->finished was never being set. Now fixed.
+ */
+
+#include "cairo-test.h"
+
+cairo_test_t test = {
+ "surface-finish-twice",
+ "Test to exercise a crash when calling cairo_surface_finish twice on the same surface.",
+ 0, 0
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_surface_t *surface;
+ cairo_status_t status;
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
+ status = cairo_surface_finish (surface);
+ if (status != CAIRO_STATUS_SUCCESS)
+ return CAIRO_TEST_FAILURE;
+
+ status = cairo_surface_finish (surface);
+ if (status != CAIRO_STATUS_SURFACE_FINISHED)
+ return CAIRO_TEST_FAILURE;
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
+
diff --git a/test/surface-pattern-ref.png b/test/surface-pattern-ref.png
new file mode 100644
index 0000000..1a64106
--- /dev/null
+++ b/test/surface-pattern-ref.png
Binary files differ
diff --git a/test/surface-pattern.c b/test/surface-pattern.c
new file mode 100644
index 0000000..4f91d43
--- /dev/null
+++ b/test/surface-pattern.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include "cairo-test.h"
+
+cairo_test_t test = {
+ "surface-pattern",
+ "Tests use of a surface pattern",
+ 36, 36
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_surface_t *surface;
+ cairo_t *cr2;
+ cairo_pattern_t *pattern;
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ 6, 6);
+
+ cr2 = cairo_create (surface);
+ {
+ cairo_rectangle (cr2, 0, 0, 3, 3);
+ cairo_rectangle (cr2, 3, 3, 3, 3);
+ cairo_set_source_rgb (cr2, 1, 1, 0);
+ cairo_fill (cr2);
+
+ cairo_rectangle (cr2, 3, 0, 3, 3);
+ cairo_rectangle (cr2, 0, 3, 3, 3);
+ cairo_set_source_rgb (cr2, 0, 0, 1);
+ cairo_fill (cr2);
+ }
+ cairo_destroy (cr2);
+
+ pattern = cairo_pattern_create_for_surface (surface);
+ cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+ cairo_set_source (cr, pattern);
+
+ cairo_rectangle (cr, 0, 0, width, height);
+ cairo_fill (cr);
+
+ cairo_pattern_destroy (pattern);
+ cairo_surface_destroy (surface);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/text_cache_crash.c b/test/text-cache-crash.c
index 6ac3245..547e2a3 100644
--- a/test/text_cache_crash.c
+++ b/test/text-cache-crash.c
@@ -60,26 +60,28 @@
* fixed the orginal test case.
*/
-#include "cairo_test.h"
+#include "cairo-test.h"
cairo_test_t test = {
- "text_cache_crash",
+ "text-cache-crash",
"Test case for bug causing an assertion failure in _cairo_cache_lookup",
0, 0,
};
#include <cairo.h>
-static void
+static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
/* Once there was a bug that choked when selecting the same font twice. */
- cairo_select_font(cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
- cairo_scale_font(cr, 40.0);
-
- cairo_select_font(cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
- cairo_scale_font(cr, 40.0);
- cairo_move_to(cr, 10, 50);
- cairo_show_text(cr, "hello");
+ cairo_select_font_face (cr, "sans",
+ CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
+ cairo_set_font_size (cr, 40.0);
+
+ cairo_select_font_face (cr, "sans",
+ CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
+ cairo_set_font_size (cr, 40.0);
+ cairo_move_to (cr, 10, 50);
+ cairo_show_text (cr, "hello");
/* Then there was a bug that choked when selecting a font too big
* for the cache. */
@@ -102,9 +104,11 @@ Aborted
But in the meantime, I need "make check" not to destory work, so
I'm commenting this test out for now.
- cairo_scale_font (cr, 500);
+ cairo_set_font_size (cr, 500);
cairo_show_text (cr, "hello");
*/
+
+ return CAIRO_TEST_SUCCESS;
}
int
diff --git a/test/text_rotate.c b/test/text-rotate.c
index c08c402..6301ad9 100644
--- a/test/text_rotate.c
+++ b/test/text-rotate.c
@@ -57,7 +57,7 @@
* builtin font to cairo for pixel-perfect tests with text.
*/
-#include "cairo_test.h"
+#include "cairo-test.h"
#define WIDTH 150
#define HEIGHT 150
@@ -65,25 +65,25 @@
#define TEXT_SIZE 12
cairo_test_t test = {
- "text_rotate",
+ "text-rotate",
"Tests show_text under various rotations",
WIDTH, HEIGHT
};
/* Draw the word cairo at NUM_TEXT different angles */
-static void
+static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
int i, x_off, y_off;
cairo_text_extents_t extents;
static char text[] = "cairo";
- cairo_select_font (cr, "Bitstream Vera Sans",
- CAIRO_FONT_SLANT_NORMAL,
- CAIRO_FONT_WEIGHT_NORMAL);
- cairo_scale_font (cr, TEXT_SIZE);
+ cairo_select_font_face (cr, "Bitstream Vera Sans",
+ CAIRO_FONT_SLANT_NORMAL,
+ CAIRO_FONT_WEIGHT_NORMAL);
+ cairo_set_font_size (cr, TEXT_SIZE);
- cairo_set_rgb_color (cr, 0,0,0);
+ cairo_set_source_rgb (cr, 0, 0, 0);
cairo_translate (cr, WIDTH/2.0, HEIGHT/2.0);
@@ -101,17 +101,20 @@ draw (cairo_t *cr, int width, int height)
cairo_rotate (cr, 2*M_PI*i/NUM_TEXT);
cairo_set_line_width (cr, 1.0);
cairo_rectangle (cr, x_off - 0.5, y_off - 0.5, extents.width + 1, extents.height + 1);
- cairo_set_rgb_color (cr, 1, 0, 0);
+ cairo_set_source_rgb (cr, 1, 0, 0);
cairo_stroke (cr);
cairo_move_to (cr, x_off - extents.x_bearing, y_off - extents.y_bearing);
- cairo_set_rgb_color (cr, 0, 0, 0);
+ cairo_set_source_rgb (cr, 0, 0, 0);
cairo_show_text (cr, "cairo");
cairo_restore (cr);
}
+
+ return CAIRO_TEST_SUCCESS;
}
int
main (void)
{
- return cairo_test (&test, draw);
+ return cairo_test_expect_failure (&test, draw,
+ "known bugs in positioning rotated glyphs");
}
diff --git a/test/transforms-ref.png b/test/transforms-ref.png
new file mode 100644
index 0000000..ee5bc7c
--- /dev/null
+++ b/test/transforms-ref.png
Binary files differ
diff --git a/test/transforms.c b/test/transforms.c
new file mode 100644
index 0000000..2c7556a
--- /dev/null
+++ b/test/transforms.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl Worth <cworth@cworth.org>
+ */
+
+#include "cairo-test.h"
+
+#define WIDTH 45
+#define HEIGHT 30
+
+cairo_test_t test = {
+ "transforms",
+ "Test various transformations.",
+ WIDTH, HEIGHT
+};
+
+static void
+draw_L_shape (cairo_t *cr)
+{
+ cairo_move_to (cr, 0, 0);
+ cairo_rel_line_to (cr, 0, 10);
+ cairo_rel_line_to (cr, 5, 0);
+
+ cairo_save (cr);
+ cairo_identity_matrix (cr);
+ cairo_set_line_width (cr, 2.0);
+ cairo_stroke (cr);
+ cairo_restore (cr);
+}
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_translate (cr, 5, 5);
+
+ draw_L_shape (cr);
+
+ cairo_translate (cr, 10, 0);
+
+ cairo_save (cr);
+ {
+ cairo_scale (cr, 2, 2);
+ draw_L_shape (cr);
+ }
+ cairo_restore (cr);
+
+ cairo_translate (cr, 15, 0);
+
+ cairo_save (cr);
+ {
+ cairo_rotate (cr, M_PI / 2.0);
+ draw_L_shape (cr);
+ }
+ cairo_restore (cr);
+
+ cairo_translate (cr, 5, 0);
+
+ cairo_save (cr);
+ {
+ cairo_matrix_t skew_y = {
+ 1, -1,
+ 0, 1,
+ 0, 0
+ };
+ cairo_transform (cr, &skew_y);
+ draw_L_shape (cr);
+ }
+ cairo_restore (cr);
+
+ cairo_translate (cr, 5, 10);
+
+ cairo_save (cr);
+ {
+ cairo_matrix_t skew_x = {
+ 1.0, 0.0,
+ -0.5, 1.0,
+ 0.0, 0.0
+ };
+ cairo_transform (cr, &skew_x);
+ draw_L_shape (cr);
+ }
+ cairo_restore (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/translate-show-surface-ref.png b/test/translate-show-surface-ref.png
new file mode 100644
index 0000000..765adc4
--- /dev/null
+++ b/test/translate-show-surface-ref.png
Binary files differ
diff --git a/test/translate-show-surface.c b/test/translate-show-surface.c
new file mode 100644
index 0000000..5a566bc
--- /dev/null
+++ b/test/translate-show-surface.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+/* Bug history
+ *
+ * 2005-04-11 Carl Worth <cworth@cworth.org>
+ *
+ * It appears that calling cairo_show_surface after cairo_translate
+ * somehow applies the translation twice to the surface being
+ * shown. This is pretty easy to demonstrate by bringing up xsvg on
+ * an SVG file with an <image> and panning around a bit with the
+ * arrow keys.
+ *
+ * This is almost certainly a regression, and I suspect there may be
+ * some interaction with the fix for move-to-show-surface.
+ *
+ * 2005-04-12 Carl Worth <cworth@cworth.org>
+ *
+ * I committed a fix for this bug today.
+ */
+
+#include "cairo-test.h"
+
+cairo_test_t test = {
+ "translate-show-surface",
+ "Tests calls to cairo_show_surface after cairo_translate",
+ 2, 2
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_surface_t *surface;
+ unsigned long colors[4] = {
+ 0xffffffff, 0xffff0000,
+ 0xff00ff00, 0xff0000ff
+ };
+ int i;
+
+ for (i=0; i < 4; i++) {
+ surface = cairo_image_surface_create_for_data ((unsigned char *) &colors[i],
+ CAIRO_FORMAT_ARGB32,
+ 1, 1, 4);
+ cairo_save (cr);
+ {
+ cairo_translate (cr, i % 2, i / 2);
+ cairo_set_source_surface (cr, surface, 0, 0);
+ cairo_paint (cr);
+ }
+ cairo_restore (cr);
+ cairo_surface_destroy (surface);
+ }
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/trap-clip-ref.png b/test/trap-clip-ref.png
new file mode 100644
index 0000000..9b5b317
--- /dev/null
+++ b/test/trap-clip-ref.png
Binary files differ
diff --git a/test/coverage.c b/test/trap-clip.c
index 00c86a1..2ad43ea 100644
--- a/test/coverage.c
+++ b/test/trap-clip.c
@@ -24,31 +24,25 @@
*/
#include <math.h>
-#include "cairo_test.h"
+#include "cairo-test.h"
+#include <stdio.h>
#define WIDTH 64
#define HEIGHT 64
#define PAD 10
-/* XXX The test image uses Bitstream Vera Sans as the font - how do we
- * ensure that it's available? Can we ship it with this test? */
-
-const char fontname[] = "Bitstream Vera Sans";
-const int fontsize = 40;
const char png_filename[] = "romedalen.png";
static void
set_solid_pattern (cairo_t *cr, int x, int y)
{
- cairo_set_rgb_color (cr, 0, 0, 0.6);
- cairo_set_alpha (cr, 1.0);
+ cairo_set_source_rgb (cr, 0, 0, 0.6);
}
static void
set_translucent_pattern (cairo_t *cr, int x, int y)
{
- cairo_set_rgb_color (cr, 0, 0, 0.6);
- cairo_set_alpha (cr, 0.5);
+ cairo_set_source_rgba (cr, 0, 0, 0.6, 0.5);
}
static void
@@ -58,10 +52,9 @@ set_gradient_pattern (cairo_t *cr, int x, int y)
pattern =
cairo_pattern_create_linear (x, y, x + WIDTH, y + HEIGHT);
- cairo_pattern_add_color_stop (pattern, 0, 1, 1, 1, 1);
- cairo_pattern_add_color_stop (pattern, 1, 0, 0, 0.4, 1);
- cairo_set_pattern (cr, pattern);
- cairo_set_alpha (cr, 1);
+ cairo_pattern_add_color_stop_rgba (pattern, 0, 1, 1, 1, 1);
+ cairo_pattern_add_color_stop_rgba (pattern, 1, 0, 0, 0.4, 1);
+ cairo_set_source (cr, pattern);
}
static void
@@ -70,25 +63,28 @@ set_image_pattern (cairo_t *cr, int x, int y)
cairo_pattern_t *pattern;
pattern = cairo_test_create_png_pattern (cr, png_filename);
- cairo_set_pattern (cr, pattern);
- cairo_set_alpha (cr, 1);
+ cairo_set_source (cr, pattern);
}
static void
-set_translucent_image_pattern (cairo_t *cr, int x, int y)
+draw_rect (cairo_t *cr, int x, int y)
{
- cairo_pattern_t *pattern;
-
- pattern = cairo_test_create_png_pattern (cr, png_filename);
- cairo_set_pattern (cr, pattern);
- cairo_set_alpha (cr, 0.5);
+ cairo_new_path (cr);
+ cairo_rectangle (cr, x, y, WIDTH, HEIGHT);
+ cairo_fill (cr);
}
static void
-draw_text (cairo_t *cr, int x, int y)
+draw_rects (cairo_t *cr, int x, int y)
{
- cairo_rel_move_to (cr, 0, fontsize);
- cairo_show_text (cr, "Aa");
+ int width = WIDTH / 3;
+ int height = HEIGHT / 2;
+
+ cairo_new_path (cr);
+ cairo_rectangle (cr, x, y, width, height);
+ cairo_rectangle (cr, x + width, y + height, width, height);
+ cairo_rectangle (cr, x + 2 * width, y, width, height);
+ cairo_fill (cr);
}
static void
@@ -105,74 +101,102 @@ draw_polygon (cairo_t *cr, int x, int y)
cairo_fill (cr);
}
+static void
+clip_none (cairo_t *cr, int x, int y)
+{
+}
+
+static void
+clip_rect (cairo_t *cr, int x, int y)
+{
+ cairo_new_path (cr);
+ cairo_rectangle (cr, x + (int)WIDTH / 6, y + (int)HEIGHT / 6,
+ 4 * ((int)WIDTH / 6), 4 * ((int)WIDTH / 6));
+ cairo_clip (cr);
+ cairo_new_path (cr);
+}
+
+static void
+clip_rects (cairo_t *cr, int x, int y)
+{
+ int height = HEIGHT / 3;
+
+ cairo_new_path (cr);
+ cairo_rectangle (cr, x, y, WIDTH, height);
+ cairo_rectangle (cr, x, y + 2 * height, WIDTH, height);
+ cairo_clip (cr);
+ cairo_new_path (cr);
+}
+
+static void
+clip_circle (cairo_t *cr, int x, int y)
+{
+ cairo_new_path (cr);
+ cairo_arc (cr, x + WIDTH / 2, y + HEIGHT / 2,
+ WIDTH / 3, 0, 2 * M_PI);
+ cairo_clip (cr);
+ cairo_new_path (cr);
+}
+
static void (*pattern_funcs[])(cairo_t *cr, int x, int y) = {
set_solid_pattern,
set_translucent_pattern,
set_gradient_pattern,
set_image_pattern,
- set_translucent_image_pattern
};
static void (*draw_funcs[])(cairo_t *cr, int x, int y) = {
- draw_text,
+ draw_rect,
+ draw_rects,
draw_polygon,
};
+static void (*clip_funcs[])(cairo_t *cr, int x, int y) = {
+ clip_none,
+ clip_rect,
+ clip_rects,
+ clip_circle,
+};
+
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
#define IMAGE_WIDTH (ARRAY_SIZE (pattern_funcs) * (WIDTH + PAD) + PAD)
-#define IMAGE_HEIGHT (ARRAY_SIZE (draw_funcs) * (HEIGHT + PAD) * 2 + PAD)
+#define IMAGE_HEIGHT (ARRAY_SIZE (draw_funcs) * ARRAY_SIZE (clip_funcs) * (HEIGHT + PAD) + PAD)
static cairo_test_t test = {
- "coverage",
- "Various coverage test of cairo",
+ "trap-clip",
+ "Trapezoid clipping",
IMAGE_WIDTH, IMAGE_HEIGHT
};
-
-static void
+static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
- /* TODO: pattern fill, gradient fill, clipping, gradient clipping,
- path+solid alpha mask clipping */
-
- int i, j, x, y;
-
- cairo_select_font (cr, fontname,
- CAIRO_FONT_SLANT_NORMAL,
- CAIRO_FONT_WEIGHT_BOLD);
- cairo_scale_font (cr, fontsize);
-
- for (j = 0; j < ARRAY_SIZE (draw_funcs); j++) {
- for (i = 0; i < ARRAY_SIZE (pattern_funcs); i++) {
- x = i * (WIDTH + PAD) + PAD;
- y = j * (HEIGHT + PAD) + PAD;
- cairo_move_to (cr, x, y);
- pattern_funcs[i] (cr, x, y);
- draw_funcs[j] (cr, x, y);
- }
- }
-
- for (j = 0; j < ARRAY_SIZE (draw_funcs); j++) {
- for (i = 0; i < ARRAY_SIZE (pattern_funcs); i++) {
- x = i * (WIDTH + PAD) + PAD;
- y = (ARRAY_SIZE (draw_funcs) + j) * (HEIGHT + PAD) + PAD;
-
- cairo_save (cr);
+ int i, j, k, x, y;
- cairo_set_alpha (cr, 1.0);
- cairo_new_path (cr);
- cairo_arc (cr, x + WIDTH / 2, y + HEIGHT / 2,
- WIDTH / 3, 0, 2 * M_PI);
- cairo_clip (cr);
+ for (k = 0; k < ARRAY_SIZE (clip_funcs); k++) {
+ for (j = 0; j < ARRAY_SIZE (draw_funcs); j++) {
+ for (i = 0; i < ARRAY_SIZE (pattern_funcs); i++) {
+ x = i * (WIDTH + PAD) + PAD;
+ y = (ARRAY_SIZE (draw_funcs) * k + j) * (HEIGHT + PAD) + PAD;
- cairo_move_to (cr, x, y);
- pattern_funcs[i] (cr, x, y);
- draw_funcs[j] (cr, x, y);
+ cairo_save (cr);
- cairo_restore (cr);
+ cairo_move_to (cr, x, y);
+ clip_funcs[k] (cr, x, y);
+ pattern_funcs[i] (cr, x, y);
+ draw_funcs[j] (cr, x, y);
+ if (cairo_status (cr))
+ cairo_test_log ("%d %d HERE!\n", i, j);
+ cairo_restore (cr);
+ }
}
}
+
+ if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
+ cairo_test_log ("%d %d .HERE!\n", i, j);
+
+ return CAIRO_TEST_SUCCESS;
}
int
diff --git a/test/user-data.c b/test/user-data.c
new file mode 100644
index 0000000..d17b933
--- /dev/null
+++ b/test/user-data.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Kristian Høgsberg <krh@redhat.com>
+ */
+
+#include <cairo.h>
+#include <assert.h>
+#include <stdlib.h>
+
+static void
+destroy_data1 (void *p)
+{
+ *(int *) p = 1;
+}
+
+static void
+destroy_data2 (void *p)
+{
+ *(int *) p = 2;
+}
+
+int
+main (void)
+{
+ cairo_surface_t *surface;
+ static const cairo_user_data_key_t key1, key2;
+ int data1, data2;
+
+ data1 = 0;
+ data2 = 0;
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
+ assert (cairo_surface_set_user_data (surface, &key1, &data1, destroy_data1)
+ == CAIRO_STATUS_SUCCESS);
+ assert (cairo_surface_set_user_data (surface, &key2, &data2, destroy_data2)
+ == CAIRO_STATUS_SUCCESS);
+ assert (cairo_surface_get_user_data (surface, &key1) == &data1);
+ assert (cairo_surface_set_user_data (surface, &key1, NULL, NULL)
+ == CAIRO_STATUS_SUCCESS);
+ assert (cairo_surface_get_user_data (surface, &key1) == NULL);
+ assert (data1 == 1);
+ assert (data2 == 0);
+
+ assert (cairo_surface_set_user_data (surface, &key2, NULL, NULL)
+ == CAIRO_STATUS_SUCCESS);
+ assert (data2 == 2);
+
+ data1 = 0;
+ assert (cairo_surface_set_user_data (surface, &key1, &data1, NULL)
+ == CAIRO_STATUS_SUCCESS);
+ assert (cairo_surface_set_user_data (surface, &key1, NULL, NULL)
+ == CAIRO_STATUS_SUCCESS);
+ assert (data1 == 0);
+ assert (cairo_surface_get_user_data (surface, &key1) == NULL);
+
+ assert (cairo_surface_set_user_data (surface, &key1, &data1, destroy_data1)
+ == CAIRO_STATUS_SUCCESS);
+ cairo_surface_destroy (surface);
+ assert (data1 == 1);
+ assert (data2 == 2);
+
+ return 0;
+}
diff --git a/test/write_png.c b/test/write-png.c
index 0ff5bcd..f5a2747 100644
--- a/test/write_png.c
+++ b/test/write-png.c
@@ -29,7 +29,7 @@
#include <stdlib.h>
#include <png.h>
-#include "write_png.h"
+#include "write-png.h"
static void
unpremultiply_data (png_structp png, png_row_infop row_info, png_bytep data)
@@ -55,7 +55,7 @@ unpremultiply_data (png_structp png, png_row_infop row_info, png_bytep data)
}
void
-write_png_argb32 (char *buffer, FILE *file,
+write_png_argb32 (unsigned char *buffer, FILE *file,
int width, int height, int stride)
{
int i;
diff --git a/test/write_png.h b/test/write-png.h
index fe0e92b..8074666 100644
--- a/test/write_png.h
+++ b/test/write-png.h
@@ -29,7 +29,7 @@
#define WRITE_PNG_H
void
-write_png_argb32 (char *buffer, FILE * file,
+write_png_argb32 (unsigned char *buffer, FILE * file,
int width, int height, int stride);
#endif
diff --git a/test/xlib-surface.c b/test/xlib-surface.c
new file mode 100644
index 0000000..d8c241c
--- /dev/null
+++ b/test/xlib-surface.c
@@ -0,0 +1,269 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "cairo.h"
+#include "cairo-xlib.h"
+#include "cairo-xlib-xrender.h"
+#include "cairo-test.h"
+#include "cairo-xlib-test.h"
+
+#include "buffer-diff.h"
+
+#define SIZE 100
+#define OFFSCREEN_OFFSET 50
+
+cairo_bool_t result = 0;
+FILE *log_file = NULL;
+
+static void
+draw_pattern (cairo_surface_t *surface)
+{
+ cairo_t *cr = cairo_create (surface);
+ int i;
+
+ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
+ cairo_paint (cr);
+
+ cairo_set_source_rgba (cr, 0, 0.0, 0.0, 0.50); /* half-alpha-black */
+
+ for (i = 1; i <= 3; i++) {
+ int inset = SIZE / 8 * i;
+
+ cairo_rectangle (cr,
+ inset, inset,
+ SIZE - 2 * inset, SIZE - 2 * inset);
+ cairo_fill (cr);
+ }
+
+ cairo_destroy (cr);
+}
+
+static void
+erase_pattern (cairo_surface_t *surface)
+{
+ cairo_t *cr = cairo_create (surface);
+
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */
+ cairo_paint (cr);
+
+ cairo_destroy (cr);
+}
+
+static cairo_bool_t
+do_test (Display *dpy,
+ unsigned char *reference_data,
+ unsigned char *test_data,
+ unsigned char *diff_data,
+ cairo_bool_t use_render,
+ cairo_bool_t use_pixmap,
+ cairo_bool_t set_size,
+ cairo_bool_t offscreen)
+{
+ cairo_surface_t *surface;
+ cairo_surface_t *test_surface;
+ cairo_t *test_cr;
+ cairo_bool_t result;
+ Drawable drawable;
+ int screen = DefaultScreen (dpy);
+
+ if (use_pixmap && offscreen)
+ return 1;
+
+ if (use_pixmap) {
+ drawable = XCreatePixmap (dpy, DefaultRootWindow (dpy),
+ SIZE, SIZE, DefaultDepth (dpy, screen));
+ } else {
+ XSetWindowAttributes xwa;
+ int x, y;
+
+ xwa.override_redirect = True;
+
+ if (offscreen) {
+ x = - OFFSCREEN_OFFSET;
+ y = - OFFSCREEN_OFFSET;
+ } else {
+ x = 0;
+ y = 0;
+ }
+
+ drawable = XCreateWindow (dpy, DefaultRootWindow (dpy),
+ x, y, SIZE, SIZE, 0,
+ DefaultDepth (dpy, screen), InputOutput,
+ DefaultVisual (dpy, screen),
+ CWOverrideRedirect, &xwa);
+ XMapWindow (dpy, drawable);
+ }
+
+ surface = cairo_xlib_surface_create (dpy,
+ drawable,
+ DefaultVisual (dpy, screen),
+ SIZE, SIZE);
+
+ if (set_size)
+ cairo_xlib_surface_set_size (surface, SIZE, SIZE);
+
+ draw_pattern (surface);
+
+ test_surface = cairo_image_surface_create_for_data (test_data,
+ CAIRO_FORMAT_RGB24,
+ SIZE, SIZE,
+ SIZE * 4);
+
+ test_cr = cairo_create (test_surface);
+ cairo_set_source_surface (test_cr, surface, 0, 0);
+ cairo_paint (test_cr);
+
+ cairo_destroy (test_cr);
+ cairo_surface_destroy (test_surface);
+
+ /* We erase the surface to black in case we get the same
+ * memory back again for the pixmap case.
+ */
+ erase_pattern (surface);
+ cairo_surface_destroy (surface);
+
+ if (use_pixmap)
+ XFreePixmap (dpy, drawable);
+ else
+ XDestroyWindow (dpy, drawable);
+
+ if (offscreen) {
+ size_t offset = 4 * (SIZE * OFFSCREEN_OFFSET + OFFSCREEN_OFFSET);
+
+ result = !buffer_diff (reference_data + offset,
+ test_data + offset,
+ diff_data + offset,
+ SIZE - OFFSCREEN_OFFSET,
+ SIZE - OFFSCREEN_OFFSET,
+ 4 * SIZE);
+ } else {
+ result = !buffer_diff (reference_data,
+ test_data,
+ diff_data,
+ SIZE,
+ SIZE,
+ 4 * SIZE);
+ }
+
+ fprintf (log_file, "xlib-surface: %s, %s, %s%s: %s\n",
+ use_render ? " render" : "no-render",
+ set_size ? " size" : "no-size",
+ use_pixmap ? "pixmap" : "window",
+ use_pixmap ?
+ " " :
+ (offscreen ? ", offscreen" : ", onscreen"),
+ result ? "PASS" : "FAIL");
+
+ return result;
+}
+
+static cairo_bool_t
+check_visual (Display *dpy)
+{
+ Visual *visual = DefaultVisual (dpy, DefaultScreen (dpy));
+
+ if ((visual->red_mask == 0xff0000 &&
+ visual->green_mask == 0x00ff00 &&
+ visual->blue_mask == 0x0000ff) ||
+ (visual->red_mask == 0x0000ff &&
+ visual->green_mask == 0x00ff00 &&
+ visual->blue_mask == 0xff0000))
+ return 1;
+ else
+ return 0;
+}
+
+int
+main (void)
+{
+ Display *dpy;
+ unsigned char *reference_data;
+ unsigned char *test_data;
+ unsigned char *diff_data;
+ cairo_surface_t *reference_surface;
+ cairo_bool_t use_pixmap;
+ cairo_bool_t set_size;
+ cairo_bool_t offscreen;
+ result = 0;
+
+ printf("\n");
+ log_file = fopen ("xlib-surface.log", "w");
+ if (log_file == NULL) {
+ fprintf (stderr, "Error opening log file: %s\n", "xlib-surface.log");
+ log_file = stderr;
+ }
+
+ dpy = XOpenDisplay (NULL);
+ if (!dpy) {
+ fprintf (log_file, "xlib-surface: Cannot open display, skipping\n");
+ return 0;
+ }
+
+ if (!check_visual (dpy)) {
+ fprintf (log_file, "xlib-surface: default visual is not RGB24 or BGR24, skipping\n");
+ return 0;
+ }
+
+ reference_data = malloc (SIZE * SIZE * 4);
+ test_data = malloc (SIZE * SIZE * 4);
+ diff_data = malloc (SIZE * SIZE * 4);
+
+ reference_surface = cairo_image_surface_create_for_data (reference_data,
+ CAIRO_FORMAT_RGB24,
+ SIZE, SIZE,
+ SIZE * 4);
+
+ draw_pattern (reference_surface);
+ cairo_surface_destroy (reference_surface);
+
+ for (set_size = 0; set_size <= 1; set_size++)
+ for (use_pixmap = 0; use_pixmap <= 1; use_pixmap++)
+ for (offscreen = 0; offscreen <= 1; offscreen++)
+ if (!do_test (dpy,
+ reference_data, test_data, diff_data,
+ 1, use_pixmap, set_size, offscreen))
+ result = 1;
+
+ cairo_test_xlib_disable_render ();
+
+ for (set_size = 0; set_size <= 1; set_size++)
+ for (use_pixmap = 0; use_pixmap <= 1; use_pixmap++)
+ for (offscreen = 0; offscreen <= 1; offscreen++)
+ if (!do_test (dpy,
+ reference_data, test_data, diff_data,
+ 0, use_pixmap, set_size, offscreen))
+ result = 1;
+
+ free (reference_data);
+ free (test_data);
+ free (diff_data);
+
+ XCloseDisplay (dpy);
+
+ return result;
+}
diff --git a/test/xmalloc.c b/test/xmalloc.c
index 04ed38a..f5721c5 100644
--- a/test/xmalloc.c
+++ b/test/xmalloc.c
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "cairo-test.h"
#include "xmalloc.h"
void *
@@ -35,7 +36,7 @@ xmalloc (size_t size)
buf = malloc (size);
if (!buf) {
- fprintf (stderr, "Error: Out of memory. Exiting.\n");
+ cairo_test_log ("Error: Out of memory. Exiting.\n");
exit (1);
}
@@ -49,7 +50,7 @@ xcalloc (size_t nmemb, size_t size)
buf = calloc (nmemb, size);
if (!buf) {
- fprintf (stderr, "Error: Out of memory. Exiting\n");
+ cairo_test_log ("Error: Out of memory. Exiting\n");
exit (1);
}
diff --git a/test/xmalloc.h b/test/xmalloc.h
index a4ba24b..bc1ab69 100644
--- a/test/xmalloc.h
+++ b/test/xmalloc.h
@@ -26,6 +26,8 @@
#ifndef _XMALLOC_H_
#define _XMALLOC_H_
+#include <stdlib.h>
+
void *
xmalloc (size_t size);