diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2013-06-07 17:18:02 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2013-06-07 17:18:02 +0000 |
commit | 05f5801ea23297bb114b9f00d5f4c7d23743b121 (patch) | |
tree | 14dbb55d6b817ce49d2798c9cf00c42bc4011a50 /lib/pixman/demos | |
parent | 6babe96864db98aee21458f0a62425b19818a203 (diff) |
Update to pixman 0.30.0. Tested by several people during t2k13. Thanks.
Diffstat (limited to 'lib/pixman/demos')
-rw-r--r-- | lib/pixman/demos/Makefile.am | 15 | ||||
-rw-r--r-- | lib/pixman/demos/Makefile.in | 137 | ||||
-rw-r--r-- | lib/pixman/demos/conical-test.c | 100 | ||||
-rw-r--r-- | lib/pixman/demos/gtk-utils.c | 119 | ||||
-rw-r--r-- | lib/pixman/demos/gtk-utils.h | 3 | ||||
-rw-r--r-- | lib/pixman/demos/linear-gradient.c | 50 | ||||
-rw-r--r-- | lib/pixman/demos/radial-test.c | 12 | ||||
-rw-r--r-- | lib/pixman/demos/scale.c | 436 | ||||
-rw-r--r-- | lib/pixman/demos/scale.ui | 332 |
9 files changed, 1149 insertions, 55 deletions
diff --git a/lib/pixman/demos/Makefile.am b/lib/pixman/demos/Makefile.am index f324f5f5b..9be9ab670 100644 --- a/lib/pixman/demos/Makefile.am +++ b/lib/pixman/demos/Makefile.am @@ -4,9 +4,10 @@ AM_CFLAGS = $(OPENMP_CFLAGS) AM_LDFLAGS = $(OPENMP_CFLAGS) LDADD = $(top_builddir)/pixman/libpixman-1.la -lm $(GTK_LIBS) $(PNG_LIBS) -INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman $(GTK_CFLAGS) $(PNG_CFLAGS) +AM_CPPFLAGS = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman $(GTK_CFLAGS) $(PNG_CFLAGS) -GTK_UTILS = gtk-utils.c gtk-utils.h ../test/utils.c ../test/utils.h +GTK_UTILS = gtk-utils.c gtk-utils.h ../test/utils.c ../test/utils.h \ + ../test/utils-prng.c ../test/utils-prng.h DEMOS = \ clip-test \ @@ -14,6 +15,8 @@ DEMOS = \ composite-test \ gradient-test \ radial-test \ + linear-gradient \ + conical-test \ alpha-test \ screen-test \ convolution-test \ @@ -22,9 +25,10 @@ DEMOS = \ quad2quad \ checkerboard \ srgb-trap-test \ - srgb-test + srgb-test \ + scale -EXTRA_DIST = parrot.c parrot.jpg +EXTRA_DIST = parrot.c parrot.jpg scale.ui gradient_test_SOURCES = gradient-test.c $(GTK_UTILS) alpha_test_SOURCES = alpha-test.c $(GTK_UTILS) @@ -35,10 +39,13 @@ trap_test_SOURCES = trap-test.c $(GTK_UTILS) screen_test_SOURCES = screen-test.c $(GTK_UTILS) convolution_test_SOURCES = convolution-test.c $(GTK_UTILS) radial_test_SOURCES = radial-test.c $(GTK_UTILS) +linear_gradient_SOURCES = linear-gradient.c $(GTK_UTILS) +conical_test_SOURCES = conical-test.c $(GTK_UTILS) tri_test_SOURCES = tri-test.c $(GTK_UTILS) checkerboard_SOURCES = checkerboard.c $(GTK_UTILS) srgb_test_SOURCES = srgb-test.c $(GTK_UTILS) srgb_trap_test_SOURCES = srgb-trap-test.c $(GTK_UTILS) +scale_SOURCES = scale.c $(GTK_UTILS) noinst_PROGRAMS = $(DEMOS) diff --git a/lib/pixman/demos/Makefile.in b/lib/pixman/demos/Makefile.in index d4aed19b4..277649371 100644 --- a/lib/pixman/demos/Makefile.in +++ b/lib/pixman/demos/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -64,15 +64,19 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @HAVE_GTK_TRUE@am__EXEEXT_1 = clip-test$(EXEEXT) clip-in$(EXEEXT) \ @HAVE_GTK_TRUE@ composite-test$(EXEEXT) gradient-test$(EXEEXT) \ -@HAVE_GTK_TRUE@ radial-test$(EXEEXT) alpha-test$(EXEEXT) \ +@HAVE_GTK_TRUE@ radial-test$(EXEEXT) linear-gradient$(EXEEXT) \ +@HAVE_GTK_TRUE@ conical-test$(EXEEXT) alpha-test$(EXEEXT) \ @HAVE_GTK_TRUE@ screen-test$(EXEEXT) convolution-test$(EXEEXT) \ @HAVE_GTK_TRUE@ trap-test$(EXEEXT) tri-test$(EXEEXT) \ @HAVE_GTK_TRUE@ quad2quad$(EXEEXT) checkerboard$(EXEEXT) \ -@HAVE_GTK_TRUE@ srgb-trap-test$(EXEEXT) srgb-test$(EXEEXT) +@HAVE_GTK_TRUE@ srgb-trap-test$(EXEEXT) srgb-test$(EXEEXT) \ +@HAVE_GTK_TRUE@ scale$(EXEEXT) PROGRAMS = $(noinst_PROGRAMS) am__alpha_test_SOURCES_DIST = alpha-test.c gtk-utils.c gtk-utils.h \ - ../test/utils.c ../test/utils.h -@HAVE_GTK_TRUE@am__objects_1 = gtk-utils.$(OBJEXT) utils.$(OBJEXT) + ../test/utils.c ../test/utils.h ../test/utils-prng.c \ + ../test/utils-prng.h +@HAVE_GTK_TRUE@am__objects_1 = gtk-utils.$(OBJEXT) utils.$(OBJEXT) \ +@HAVE_GTK_TRUE@ utils-prng.$(OBJEXT) @HAVE_GTK_TRUE@am_alpha_test_OBJECTS = alpha-test.$(OBJEXT) \ @HAVE_GTK_TRUE@ $(am__objects_1) alpha_test_OBJECTS = $(am_alpha_test_OBJECTS) @@ -86,7 +90,8 @@ am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am__checkerboard_SOURCES_DIST = checkerboard.c gtk-utils.c gtk-utils.h \ - ../test/utils.c ../test/utils.h + ../test/utils.c ../test/utils.h ../test/utils-prng.c \ + ../test/utils-prng.h @HAVE_GTK_TRUE@am_checkerboard_OBJECTS = checkerboard.$(OBJEXT) \ @HAVE_GTK_TRUE@ $(am__objects_1) checkerboard_OBJECTS = $(am_checkerboard_OBJECTS) @@ -95,7 +100,8 @@ checkerboard_LDADD = $(LDADD) @HAVE_GTK_TRUE@ $(top_builddir)/pixman/libpixman-1.la \ @HAVE_GTK_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am__clip_in_SOURCES_DIST = clip-in.c gtk-utils.c gtk-utils.h \ - ../test/utils.c ../test/utils.h + ../test/utils.c ../test/utils.h ../test/utils-prng.c \ + ../test/utils-prng.h @HAVE_GTK_TRUE@am_clip_in_OBJECTS = clip-in.$(OBJEXT) $(am__objects_1) clip_in_OBJECTS = $(am_clip_in_OBJECTS) clip_in_LDADD = $(LDADD) @@ -103,7 +109,8 @@ clip_in_LDADD = $(LDADD) @HAVE_GTK_TRUE@ $(top_builddir)/pixman/libpixman-1.la \ @HAVE_GTK_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am__clip_test_SOURCES_DIST = clip-test.c gtk-utils.c gtk-utils.h \ - ../test/utils.c ../test/utils.h + ../test/utils.c ../test/utils.h ../test/utils-prng.c \ + ../test/utils-prng.h @HAVE_GTK_TRUE@am_clip_test_OBJECTS = clip-test.$(OBJEXT) \ @HAVE_GTK_TRUE@ $(am__objects_1) clip_test_OBJECTS = $(am_clip_test_OBJECTS) @@ -112,7 +119,8 @@ clip_test_LDADD = $(LDADD) @HAVE_GTK_TRUE@ $(top_builddir)/pixman/libpixman-1.la \ @HAVE_GTK_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am__composite_test_SOURCES_DIST = composite-test.c gtk-utils.c \ - gtk-utils.h ../test/utils.c ../test/utils.h + gtk-utils.h ../test/utils.c ../test/utils.h \ + ../test/utils-prng.c ../test/utils-prng.h @HAVE_GTK_TRUE@am_composite_test_OBJECTS = composite-test.$(OBJEXT) \ @HAVE_GTK_TRUE@ $(am__objects_1) composite_test_OBJECTS = $(am_composite_test_OBJECTS) @@ -120,8 +128,19 @@ composite_test_LDADD = $(LDADD) @HAVE_GTK_TRUE@composite_test_DEPENDENCIES = \ @HAVE_GTK_TRUE@ $(top_builddir)/pixman/libpixman-1.la \ @HAVE_GTK_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +am__conical_test_SOURCES_DIST = conical-test.c gtk-utils.c gtk-utils.h \ + ../test/utils.c ../test/utils.h ../test/utils-prng.c \ + ../test/utils-prng.h +@HAVE_GTK_TRUE@am_conical_test_OBJECTS = conical-test.$(OBJEXT) \ +@HAVE_GTK_TRUE@ $(am__objects_1) +conical_test_OBJECTS = $(am_conical_test_OBJECTS) +conical_test_LDADD = $(LDADD) +@HAVE_GTK_TRUE@conical_test_DEPENDENCIES = \ +@HAVE_GTK_TRUE@ $(top_builddir)/pixman/libpixman-1.la \ +@HAVE_GTK_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am__convolution_test_SOURCES_DIST = convolution-test.c gtk-utils.c \ - gtk-utils.h ../test/utils.c ../test/utils.h + gtk-utils.h ../test/utils.c ../test/utils.h \ + ../test/utils-prng.c ../test/utils-prng.h @HAVE_GTK_TRUE@am_convolution_test_OBJECTS = \ @HAVE_GTK_TRUE@ convolution-test.$(OBJEXT) $(am__objects_1) convolution_test_OBJECTS = $(am_convolution_test_OBJECTS) @@ -130,7 +149,8 @@ convolution_test_LDADD = $(LDADD) @HAVE_GTK_TRUE@ $(top_builddir)/pixman/libpixman-1.la \ @HAVE_GTK_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am__gradient_test_SOURCES_DIST = gradient-test.c gtk-utils.c \ - gtk-utils.h ../test/utils.c ../test/utils.h + gtk-utils.h ../test/utils.c ../test/utils.h \ + ../test/utils-prng.c ../test/utils-prng.h @HAVE_GTK_TRUE@am_gradient_test_OBJECTS = gradient-test.$(OBJEXT) \ @HAVE_GTK_TRUE@ $(am__objects_1) gradient_test_OBJECTS = $(am_gradient_test_OBJECTS) @@ -138,6 +158,16 @@ gradient_test_LDADD = $(LDADD) @HAVE_GTK_TRUE@gradient_test_DEPENDENCIES = \ @HAVE_GTK_TRUE@ $(top_builddir)/pixman/libpixman-1.la \ @HAVE_GTK_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +am__linear_gradient_SOURCES_DIST = linear-gradient.c gtk-utils.c \ + gtk-utils.h ../test/utils.c ../test/utils.h \ + ../test/utils-prng.c ../test/utils-prng.h +@HAVE_GTK_TRUE@am_linear_gradient_OBJECTS = linear-gradient.$(OBJEXT) \ +@HAVE_GTK_TRUE@ $(am__objects_1) +linear_gradient_OBJECTS = $(am_linear_gradient_OBJECTS) +linear_gradient_LDADD = $(LDADD) +@HAVE_GTK_TRUE@linear_gradient_DEPENDENCIES = \ +@HAVE_GTK_TRUE@ $(top_builddir)/pixman/libpixman-1.la \ +@HAVE_GTK_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) quad2quad_SOURCES = quad2quad.c quad2quad_OBJECTS = quad2quad.$(OBJEXT) quad2quad_LDADD = $(LDADD) @@ -145,7 +175,8 @@ quad2quad_LDADD = $(LDADD) @HAVE_GTK_TRUE@ $(top_builddir)/pixman/libpixman-1.la \ @HAVE_GTK_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am__radial_test_SOURCES_DIST = radial-test.c gtk-utils.c gtk-utils.h \ - ../test/utils.c ../test/utils.h + ../test/utils.c ../test/utils.h ../test/utils-prng.c \ + ../test/utils-prng.h @HAVE_GTK_TRUE@am_radial_test_OBJECTS = radial-test.$(OBJEXT) \ @HAVE_GTK_TRUE@ $(am__objects_1) radial_test_OBJECTS = $(am_radial_test_OBJECTS) @@ -153,8 +184,18 @@ radial_test_LDADD = $(LDADD) @HAVE_GTK_TRUE@radial_test_DEPENDENCIES = \ @HAVE_GTK_TRUE@ $(top_builddir)/pixman/libpixman-1.la \ @HAVE_GTK_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +am__scale_SOURCES_DIST = scale.c gtk-utils.c gtk-utils.h \ + ../test/utils.c ../test/utils.h ../test/utils-prng.c \ + ../test/utils-prng.h +@HAVE_GTK_TRUE@am_scale_OBJECTS = scale.$(OBJEXT) $(am__objects_1) +scale_OBJECTS = $(am_scale_OBJECTS) +scale_LDADD = $(LDADD) +@HAVE_GTK_TRUE@scale_DEPENDENCIES = \ +@HAVE_GTK_TRUE@ $(top_builddir)/pixman/libpixman-1.la \ +@HAVE_GTK_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am__screen_test_SOURCES_DIST = screen-test.c gtk-utils.c gtk-utils.h \ - ../test/utils.c ../test/utils.h + ../test/utils.c ../test/utils.h ../test/utils-prng.c \ + ../test/utils-prng.h @HAVE_GTK_TRUE@am_screen_test_OBJECTS = screen-test.$(OBJEXT) \ @HAVE_GTK_TRUE@ $(am__objects_1) screen_test_OBJECTS = $(am_screen_test_OBJECTS) @@ -163,7 +204,8 @@ screen_test_LDADD = $(LDADD) @HAVE_GTK_TRUE@ $(top_builddir)/pixman/libpixman-1.la \ @HAVE_GTK_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am__srgb_test_SOURCES_DIST = srgb-test.c gtk-utils.c gtk-utils.h \ - ../test/utils.c ../test/utils.h + ../test/utils.c ../test/utils.h ../test/utils-prng.c \ + ../test/utils-prng.h @HAVE_GTK_TRUE@am_srgb_test_OBJECTS = srgb-test.$(OBJEXT) \ @HAVE_GTK_TRUE@ $(am__objects_1) srgb_test_OBJECTS = $(am_srgb_test_OBJECTS) @@ -172,7 +214,8 @@ srgb_test_LDADD = $(LDADD) @HAVE_GTK_TRUE@ $(top_builddir)/pixman/libpixman-1.la \ @HAVE_GTK_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am__srgb_trap_test_SOURCES_DIST = srgb-trap-test.c gtk-utils.c \ - gtk-utils.h ../test/utils.c ../test/utils.h + gtk-utils.h ../test/utils.c ../test/utils.h \ + ../test/utils-prng.c ../test/utils-prng.h @HAVE_GTK_TRUE@am_srgb_trap_test_OBJECTS = srgb-trap-test.$(OBJEXT) \ @HAVE_GTK_TRUE@ $(am__objects_1) srgb_trap_test_OBJECTS = $(am_srgb_trap_test_OBJECTS) @@ -181,7 +224,8 @@ srgb_trap_test_LDADD = $(LDADD) @HAVE_GTK_TRUE@ $(top_builddir)/pixman/libpixman-1.la \ @HAVE_GTK_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am__trap_test_SOURCES_DIST = trap-test.c gtk-utils.c gtk-utils.h \ - ../test/utils.c ../test/utils.h + ../test/utils.c ../test/utils.h ../test/utils-prng.c \ + ../test/utils-prng.h @HAVE_GTK_TRUE@am_trap_test_OBJECTS = trap-test.$(OBJEXT) \ @HAVE_GTK_TRUE@ $(am__objects_1) trap_test_OBJECTS = $(am_trap_test_OBJECTS) @@ -190,7 +234,8 @@ trap_test_LDADD = $(LDADD) @HAVE_GTK_TRUE@ $(top_builddir)/pixman/libpixman-1.la \ @HAVE_GTK_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am__tri_test_SOURCES_DIST = tri-test.c gtk-utils.c gtk-utils.h \ - ../test/utils.c ../test/utils.h + ../test/utils.c ../test/utils.h ../test/utils-prng.c \ + ../test/utils-prng.h @HAVE_GTK_TRUE@am_tri_test_OBJECTS = tri-test.$(OBJEXT) \ @HAVE_GTK_TRUE@ $(am__objects_1) tri_test_OBJECTS = $(am_tri_test_OBJECTS) @@ -234,18 +279,21 @@ am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(alpha_test_SOURCES) $(checkerboard_SOURCES) \ $(clip_in_SOURCES) $(clip_test_SOURCES) \ - $(composite_test_SOURCES) $(convolution_test_SOURCES) \ - $(gradient_test_SOURCES) quad2quad.c $(radial_test_SOURCES) \ - $(screen_test_SOURCES) $(srgb_test_SOURCES) \ + $(composite_test_SOURCES) $(conical_test_SOURCES) \ + $(convolution_test_SOURCES) $(gradient_test_SOURCES) \ + $(linear_gradient_SOURCES) quad2quad.c $(radial_test_SOURCES) \ + $(scale_SOURCES) $(screen_test_SOURCES) $(srgb_test_SOURCES) \ $(srgb_trap_test_SOURCES) $(trap_test_SOURCES) \ $(tri_test_SOURCES) DIST_SOURCES = $(am__alpha_test_SOURCES_DIST) \ $(am__checkerboard_SOURCES_DIST) $(am__clip_in_SOURCES_DIST) \ $(am__clip_test_SOURCES_DIST) \ $(am__composite_test_SOURCES_DIST) \ + $(am__conical_test_SOURCES_DIST) \ $(am__convolution_test_SOURCES_DIST) \ - $(am__gradient_test_SOURCES_DIST) quad2quad.c \ - $(am__radial_test_SOURCES_DIST) \ + $(am__gradient_test_SOURCES_DIST) \ + $(am__linear_gradient_SOURCES_DIST) quad2quad.c \ + $(am__radial_test_SOURCES_DIST) $(am__scale_SOURCES_DIST) \ $(am__screen_test_SOURCES_DIST) $(am__srgb_test_SOURCES_DIST) \ $(am__srgb_trap_test_SOURCES_DIST) \ $(am__trap_test_SOURCES_DIST) $(am__tri_test_SOURCES_DIST) @@ -331,6 +379,8 @@ PIXMAN_VERSION_MAJOR = @PIXMAN_VERSION_MAJOR@ PIXMAN_VERSION_MICRO = @PIXMAN_VERSION_MICRO@ PIXMAN_VERSION_MINOR = @PIXMAN_VERSION_MINOR@ PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PNG_CFLAGS = @PNG_CFLAGS@ PNG_LIBS = @PNG_LIBS@ PTHREAD_LDFLAGS = @PTHREAD_LDFLAGS@ @@ -402,14 +452,18 @@ top_srcdir = @top_srcdir@ @HAVE_GTK_TRUE@AM_CFLAGS = $(OPENMP_CFLAGS) @HAVE_GTK_TRUE@AM_LDFLAGS = $(OPENMP_CFLAGS) @HAVE_GTK_TRUE@LDADD = $(top_builddir)/pixman/libpixman-1.la -lm $(GTK_LIBS) $(PNG_LIBS) -@HAVE_GTK_TRUE@INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman $(GTK_CFLAGS) $(PNG_CFLAGS) -@HAVE_GTK_TRUE@GTK_UTILS = gtk-utils.c gtk-utils.h ../test/utils.c ../test/utils.h +@HAVE_GTK_TRUE@AM_CPPFLAGS = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman $(GTK_CFLAGS) $(PNG_CFLAGS) +@HAVE_GTK_TRUE@GTK_UTILS = gtk-utils.c gtk-utils.h ../test/utils.c ../test/utils.h \ +@HAVE_GTK_TRUE@ ../test/utils-prng.c ../test/utils-prng.h + @HAVE_GTK_TRUE@DEMOS = \ @HAVE_GTK_TRUE@ clip-test \ @HAVE_GTK_TRUE@ clip-in \ @HAVE_GTK_TRUE@ composite-test \ @HAVE_GTK_TRUE@ gradient-test \ @HAVE_GTK_TRUE@ radial-test \ +@HAVE_GTK_TRUE@ linear-gradient \ +@HAVE_GTK_TRUE@ conical-test \ @HAVE_GTK_TRUE@ alpha-test \ @HAVE_GTK_TRUE@ screen-test \ @HAVE_GTK_TRUE@ convolution-test \ @@ -418,9 +472,10 @@ top_srcdir = @top_srcdir@ @HAVE_GTK_TRUE@ quad2quad \ @HAVE_GTK_TRUE@ checkerboard \ @HAVE_GTK_TRUE@ srgb-trap-test \ -@HAVE_GTK_TRUE@ srgb-test +@HAVE_GTK_TRUE@ srgb-test \ +@HAVE_GTK_TRUE@ scale -@HAVE_GTK_TRUE@EXTRA_DIST = parrot.c parrot.jpg +@HAVE_GTK_TRUE@EXTRA_DIST = parrot.c parrot.jpg scale.ui @HAVE_GTK_TRUE@gradient_test_SOURCES = gradient-test.c $(GTK_UTILS) @HAVE_GTK_TRUE@alpha_test_SOURCES = alpha-test.c $(GTK_UTILS) @HAVE_GTK_TRUE@composite_test_SOURCES = composite-test.c $(GTK_UTILS) @@ -430,10 +485,13 @@ top_srcdir = @top_srcdir@ @HAVE_GTK_TRUE@screen_test_SOURCES = screen-test.c $(GTK_UTILS) @HAVE_GTK_TRUE@convolution_test_SOURCES = convolution-test.c $(GTK_UTILS) @HAVE_GTK_TRUE@radial_test_SOURCES = radial-test.c $(GTK_UTILS) +@HAVE_GTK_TRUE@linear_gradient_SOURCES = linear-gradient.c $(GTK_UTILS) +@HAVE_GTK_TRUE@conical_test_SOURCES = conical-test.c $(GTK_UTILS) @HAVE_GTK_TRUE@tri_test_SOURCES = tri-test.c $(GTK_UTILS) @HAVE_GTK_TRUE@checkerboard_SOURCES = checkerboard.c $(GTK_UTILS) @HAVE_GTK_TRUE@srgb_test_SOURCES = srgb-test.c $(GTK_UTILS) @HAVE_GTK_TRUE@srgb_trap_test_SOURCES = srgb-trap-test.c $(GTK_UTILS) +@HAVE_GTK_TRUE@scale_SOURCES = scale.c $(GTK_UTILS) all: all-am .SUFFIXES: @@ -492,18 +550,27 @@ clip-test$(EXEEXT): $(clip_test_OBJECTS) $(clip_test_DEPENDENCIES) $(EXTRA_clip_ composite-test$(EXEEXT): $(composite_test_OBJECTS) $(composite_test_DEPENDENCIES) $(EXTRA_composite_test_DEPENDENCIES) @rm -f composite-test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(composite_test_OBJECTS) $(composite_test_LDADD) $(LIBS) +conical-test$(EXEEXT): $(conical_test_OBJECTS) $(conical_test_DEPENDENCIES) $(EXTRA_conical_test_DEPENDENCIES) + @rm -f conical-test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(conical_test_OBJECTS) $(conical_test_LDADD) $(LIBS) convolution-test$(EXEEXT): $(convolution_test_OBJECTS) $(convolution_test_DEPENDENCIES) $(EXTRA_convolution_test_DEPENDENCIES) @rm -f convolution-test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(convolution_test_OBJECTS) $(convolution_test_LDADD) $(LIBS) gradient-test$(EXEEXT): $(gradient_test_OBJECTS) $(gradient_test_DEPENDENCIES) $(EXTRA_gradient_test_DEPENDENCIES) @rm -f gradient-test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(gradient_test_OBJECTS) $(gradient_test_LDADD) $(LIBS) +linear-gradient$(EXEEXT): $(linear_gradient_OBJECTS) $(linear_gradient_DEPENDENCIES) $(EXTRA_linear_gradient_DEPENDENCIES) + @rm -f linear-gradient$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(linear_gradient_OBJECTS) $(linear_gradient_LDADD) $(LIBS) quad2quad$(EXEEXT): $(quad2quad_OBJECTS) $(quad2quad_DEPENDENCIES) $(EXTRA_quad2quad_DEPENDENCIES) @rm -f quad2quad$(EXEEXT) $(AM_V_CCLD)$(LINK) $(quad2quad_OBJECTS) $(quad2quad_LDADD) $(LIBS) radial-test$(EXEEXT): $(radial_test_OBJECTS) $(radial_test_DEPENDENCIES) $(EXTRA_radial_test_DEPENDENCIES) @rm -f radial-test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(radial_test_OBJECTS) $(radial_test_LDADD) $(LIBS) +scale$(EXEEXT): $(scale_OBJECTS) $(scale_DEPENDENCIES) $(EXTRA_scale_DEPENDENCIES) + @rm -f scale$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(scale_OBJECTS) $(scale_LDADD) $(LIBS) screen-test$(EXEEXT): $(screen_test_OBJECTS) $(screen_test_DEPENDENCIES) $(EXTRA_screen_test_DEPENDENCIES) @rm -f screen-test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(screen_test_OBJECTS) $(screen_test_LDADD) $(LIBS) @@ -531,16 +598,20 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clip-in.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clip-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/composite-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conical-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/convolution-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gradient-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtk-utils.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linear-gradient.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/quad2quad.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/radial-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scale.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/screen-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/srgb-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/srgb-trap-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trap-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tri-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils-prng.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@ .c.o: @@ -578,6 +649,20 @@ utils.obj: ../test/utils.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o utils.obj `if test -f '../test/utils.c'; then $(CYGPATH_W) '../test/utils.c'; else $(CYGPATH_W) '$(srcdir)/../test/utils.c'; fi` +utils-prng.o: ../test/utils-prng.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT utils-prng.o -MD -MP -MF $(DEPDIR)/utils-prng.Tpo -c -o utils-prng.o `test -f '../test/utils-prng.c' || echo '$(srcdir)/'`../test/utils-prng.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utils-prng.Tpo $(DEPDIR)/utils-prng.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../test/utils-prng.c' object='utils-prng.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o utils-prng.o `test -f '../test/utils-prng.c' || echo '$(srcdir)/'`../test/utils-prng.c + +utils-prng.obj: ../test/utils-prng.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT utils-prng.obj -MD -MP -MF $(DEPDIR)/utils-prng.Tpo -c -o utils-prng.obj `if test -f '../test/utils-prng.c'; then $(CYGPATH_W) '../test/utils-prng.c'; else $(CYGPATH_W) '$(srcdir)/../test/utils-prng.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utils-prng.Tpo $(DEPDIR)/utils-prng.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../test/utils-prng.c' object='utils-prng.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o utils-prng.obj `if test -f '../test/utils-prng.c'; then $(CYGPATH_W) '../test/utils-prng.c'; else $(CYGPATH_W) '$(srcdir)/../test/utils-prng.c'; fi` + mostlyclean-libtool: -rm -f *.lo diff --git a/lib/pixman/demos/conical-test.c b/lib/pixman/demos/conical-test.c new file mode 100644 index 000000000..6b3243016 --- /dev/null +++ b/lib/pixman/demos/conical-test.c @@ -0,0 +1,100 @@ +#include "../test/utils.h" +#include "gtk-utils.h" + +#define SIZE 128 +#define GRADIENTS_PER_ROW 7 +#define NUM_ROWS ((NUM_GRADIENTS + GRADIENTS_PER_ROW - 1) / GRADIENTS_PER_ROW) +#define WIDTH (SIZE * GRADIENTS_PER_ROW) +#define HEIGHT (SIZE * NUM_ROWS) +#define NUM_GRADIENTS 35 + +#define double_to_color(x) \ + (((uint32_t) ((x)*65536)) - (((uint32_t) ((x)*65536)) >> 16)) + +#define PIXMAN_STOP(offset,r,g,b,a) \ + { pixman_double_to_fixed (offset), \ + { \ + double_to_color (r), \ + double_to_color (g), \ + double_to_color (b), \ + double_to_color (a) \ + } \ + } + + +static const pixman_gradient_stop_t stops[] = { + PIXMAN_STOP (0.25, 1, 0, 0, 0.7), + PIXMAN_STOP (0.5, 1, 1, 0, 0.7), + PIXMAN_STOP (0.75, 0, 1, 0, 0.7), + PIXMAN_STOP (1.0, 0, 0, 1, 0.7) +}; + +#define NUM_STOPS (sizeof (stops) / sizeof (stops[0])) + +static pixman_image_t * +create_conical (int index) +{ + pixman_point_fixed_t c; + double angle; + + c.x = pixman_double_to_fixed (0); + c.y = pixman_double_to_fixed (0); + + angle = (0.5 / NUM_GRADIENTS + index / (double)NUM_GRADIENTS) * 720 - 180; + + return pixman_image_create_conical_gradient ( + &c, pixman_double_to_fixed (angle), stops, NUM_STOPS); +} + +int +main (int argc, char **argv) +{ + pixman_transform_t transform; + pixman_image_t *src_img, *dest_img; + int i; + + enable_divbyzero_exceptions (); + + dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8, + WIDTH, HEIGHT, + NULL, 0); + + draw_checkerboard (dest_img, 25, 0xffaaaaaa, 0xff888888); + + pixman_transform_init_identity (&transform); + + pixman_transform_translate (NULL, &transform, + pixman_double_to_fixed (0.5), + pixman_double_to_fixed (0.5)); + + pixman_transform_scale (NULL, &transform, + pixman_double_to_fixed (SIZE), + pixman_double_to_fixed (SIZE)); + pixman_transform_translate (NULL, &transform, + pixman_double_to_fixed (0.5), + pixman_double_to_fixed (0.5)); + + for (i = 0; i < NUM_GRADIENTS; i++) + { + int column = i % GRADIENTS_PER_ROW; + int row = i / GRADIENTS_PER_ROW; + + src_img = create_conical (i); + pixman_image_set_repeat (src_img, PIXMAN_REPEAT_NORMAL); + + pixman_image_set_transform (src_img, &transform); + + pixman_image_composite32 ( + PIXMAN_OP_OVER, src_img, NULL,dest_img, + 0, 0, 0, 0, column * SIZE, row * SIZE, + SIZE, SIZE); + + pixman_image_unref (src_img); + } + + show_image (dest_img); + + pixman_image_unref (dest_img); + + return 0; +} diff --git a/lib/pixman/demos/gtk-utils.c b/lib/pixman/demos/gtk-utils.c index 8291a1ed2..32d4aecc7 100644 --- a/lib/pixman/demos/gtk-utils.c +++ b/lib/pixman/demos/gtk-utils.c @@ -3,6 +3,72 @@ #include "../test/utils.h" #include "gtk-utils.h" +pixman_image_t * +pixman_image_from_file (const char *filename, pixman_format_code_t format) +{ + GdkPixbuf *pixbuf; + pixman_image_t *image; + int width, height; + uint32_t *data, *d; + uint8_t *gdk_data; + int n_channels; + int j, i; + int stride; + + if (!(pixbuf = gdk_pixbuf_new_from_file (filename, NULL))) + return NULL; + + image = NULL; + + width = gdk_pixbuf_get_width (pixbuf); + height = gdk_pixbuf_get_height (pixbuf); + n_channels = gdk_pixbuf_get_n_channels (pixbuf); + gdk_data = gdk_pixbuf_get_pixels (pixbuf); + stride = gdk_pixbuf_get_rowstride (pixbuf); + + if (!(data = malloc (width * height * sizeof (uint32_t)))) + goto out; + + d = data; + for (j = 0; j < height; ++j) + { + uint8_t *gdk_line = gdk_data; + + for (i = 0; i < width; ++i) + { + int r, g, b, a; + uint32_t pixel; + + r = gdk_line[0]; + g = gdk_line[1]; + b = gdk_line[2]; + + if (n_channels == 4) + a = gdk_line[3]; + else + a = 0xff; + + r = (r * a + 127) / 255; + g = (g * a + 127) / 255; + b = (b * a + 127) / 255; + + pixel = (a << 24) | (r << 16) | (g << 8) | b; + + *d++ = pixel; + gdk_line += n_channels; + } + + gdk_data += stride; + } + + image = pixman_image_create_bits ( + format, width, height, data, width * 4); + +out: + g_object_unref (pixbuf); + return image; +} + GdkPixbuf * pixbuf_from_argb32 (uint32_t *bits, int width, @@ -29,14 +95,31 @@ pixbuf_from_argb32 (uint32_t *bits, static gboolean on_expose (GtkWidget *widget, GdkEventExpose *expose, gpointer data) { - GdkPixbuf *pixbuf = data; + pixman_image_t *pimage = data; + int width = pixman_image_get_width (pimage); + int height = pixman_image_get_height (pimage); + int stride = pixman_image_get_stride (pimage); + cairo_surface_t *cimage; + cairo_format_t format; + cairo_t *cr; + + if (pixman_image_get_format (pimage) == PIXMAN_x8r8g8b8) + format = CAIRO_FORMAT_RGB24; + else + format = CAIRO_FORMAT_ARGB32; + + cimage = cairo_image_surface_create_for_data ( + (uint8_t *)pixman_image_get_data (pimage), + format, width, height, stride); - gdk_draw_pixbuf (widget->window, NULL, - pixbuf, 0, 0, 0, 0, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - GDK_RGB_DITHER_NONE, - 0, 0); + cr = gdk_cairo_create (widget->window); + + cairo_rectangle (cr, 0, 0, width, height); + cairo_set_source_surface (cr, cimage, 0, 0); + cairo_fill (cr); + + cairo_destroy (cr); + cairo_surface_destroy (cimage); return TRUE; } @@ -45,7 +128,6 @@ void show_image (pixman_image_t *image) { GtkWidget *window; - GdkPixbuf *pixbuf; int width, height; int argc; char **argv; @@ -66,22 +148,15 @@ show_image (pixman_image_t *image) format = pixman_image_get_format (image); - /* Three cases: - * - * - image is a8r8g8b8_sRGB: we will display without modification - * under the assumption that the monitor is sRGB - * - * - image is a8r8g8b8: we will display without modification - * under the assumption that whoever created the image - * probably did it wrong by using sRGB inputs - * - * - other: we will convert to a8r8g8b8 under the assumption that - * whoever created the image probably did it wrong. + /* We always display the image as if it contains sRGB data. That + * means that no conversion should take place when the image + * has the a8r8g8b8_sRGB format. */ switch (format) { case PIXMAN_a8r8g8b8_sRGB: case PIXMAN_a8r8g8b8: + case PIXMAN_x8r8g8b8: copy = pixman_image_ref (image); break; @@ -95,11 +170,7 @@ show_image (pixman_image_t *image) break; } - pixbuf = pixbuf_from_argb32 (pixman_image_get_data (copy), - width, height, - pixman_image_get_stride (copy)); - - g_signal_connect (window, "expose_event", G_CALLBACK (on_expose), pixbuf); + g_signal_connect (window, "expose_event", G_CALLBACK (on_expose), copy); g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_show (window); diff --git a/lib/pixman/demos/gtk-utils.h b/lib/pixman/demos/gtk-utils.h index 55cb7018a..36be4def6 100644 --- a/lib/pixman/demos/gtk-utils.h +++ b/lib/pixman/demos/gtk-utils.h @@ -6,6 +6,9 @@ void show_image (pixman_image_t *image); +pixman_image_t * +pixman_image_from_file (const char *filename, pixman_format_code_t format); + GdkPixbuf *pixbuf_from_argb32 (uint32_t *bits, int width, int height, diff --git a/lib/pixman/demos/linear-gradient.c b/lib/pixman/demos/linear-gradient.c new file mode 100644 index 000000000..46433a6e5 --- /dev/null +++ b/lib/pixman/demos/linear-gradient.c @@ -0,0 +1,50 @@ +#include "../test/utils.h" +#include "gtk-utils.h" + +#define WIDTH 1024 +#define HEIGHT 640 + +int +main (int argc, char **argv) +{ + pixman_image_t *src_img, *dest_img; + pixman_gradient_stop_t stops[] = { + { 0x00000, { 0x0000, 0x0000, 0x4444, 0xdddd } }, + { 0x10000, { 0xeeee, 0xeeee, 0x8888, 0xdddd } }, +#if 0 + /* These colors make it very obvious that dithering + * is useful even for 8-bit gradients + */ + { 0x00000, { 0x6666, 0x3333, 0x3333, 0xffff } }, + { 0x10000, { 0x3333, 0x6666, 0x6666, 0xffff } }, +#endif + }; + pixman_point_fixed_t p1, p2; + + enable_divbyzero_exceptions (); + + dest_img = pixman_image_create_bits (PIXMAN_x8r8g8b8, + WIDTH, HEIGHT, + NULL, 0); + + p1.x = p1.y = 0x0000; + p2.x = WIDTH << 16; + p2.y = HEIGHT << 16; + + src_img = pixman_image_create_linear_gradient (&p1, &p2, stops, ARRAY_LENGTH (stops)); + + pixman_image_composite32 (PIXMAN_OP_OVER, + src_img, + NULL, + dest_img, + 0, 0, + 0, 0, + 0, 0, + WIDTH, HEIGHT); + + show_image (dest_img); + + pixman_image_unref (dest_img); + + return 0; +} diff --git a/lib/pixman/demos/radial-test.c b/lib/pixman/demos/radial-test.c index e64f3577f..08a367cd2 100644 --- a/lib/pixman/demos/radial-test.c +++ b/lib/pixman/demos/radial-test.c @@ -1,7 +1,7 @@ #include "../test/utils.h" #include "gtk-utils.h" -#define NUM_GRADIENTS 7 +#define NUM_GRADIENTS 9 #define NUM_STOPS 3 #define NUM_REPEAT 4 #define SIZE 128 @@ -28,6 +28,9 @@ * centers (0, 0) and (1, 0), but with different radiuses. From left * to right: * + * - Degenerate start circle completely inside the end circle + * 0.00 -> 1.75; dr = 1.75 > 0; a = 1 - 1.75^2 < 0 + * * - Small start circle completely inside the end circle * 0.25 -> 1.75; dr = 1.5 > 0; a = 1 - 1.50^2 < 0 * @@ -49,15 +52,20 @@ * - Small end circle completely inside the start circle * 1.75 -> 0.25; dr = -1.5 > 0; a = 1 - 1.50^2 < 0 * + * - Degenerate end circle completely inside the start circle + * 0.00 -> 1.75; dr = 1.75 > 0; a = 1 - 1.75^2 < 0 + * */ const static double radiuses[NUM_GRADIENTS] = { + 0.00, 0.25, 0.50, 0.50, 1.00, 1.00, 1.50, + 1.75, 1.75 }; @@ -139,6 +147,8 @@ main (int argc, char **argv) WIDTH, HEIGHT, NULL, 0); + draw_checkerboard (dest_img, 25, 0xffaaaaaa, 0xffbbbbbb); + pixman_transform_init_identity (&transform); /* diff --git a/lib/pixman/demos/scale.c b/lib/pixman/demos/scale.c new file mode 100644 index 000000000..869ada12b --- /dev/null +++ b/lib/pixman/demos/scale.c @@ -0,0 +1,436 @@ +/* + * Copyright 2012, Red Hat, Inc. + * Copyright 2012, Soren Sandmann + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Author: Soren Sandmann <soren.sandmann@gmail.com> + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include <math.h> +#include <gtk/gtk.h> +#include <pixman.h> +#include <stdlib.h> +#include "gtk-utils.h" + +typedef struct +{ + GtkBuilder * builder; + pixman_image_t * original; + GtkAdjustment * scale_x_adjustment; + GtkAdjustment * scale_y_adjustment; + GtkAdjustment * rotate_adjustment; + GtkAdjustment * subsample_adjustment; + int scaled_width; + int scaled_height; +} app_t; + +static GtkWidget * +get_widget (app_t *app, const char *name) +{ + GtkWidget *widget = GTK_WIDGET (gtk_builder_get_object (app->builder, name)); + + if (!widget) + g_error ("Widget %s not found\n", name); + + return widget; +} + +static double +min4 (double a, double b, double c, double d) +{ + double m1, m2; + + m1 = MIN (a, b); + m2 = MIN (c, d); + return MIN (m1, m2); +} + +static double +max4 (double a, double b, double c, double d) +{ + double m1, m2; + + m1 = MAX (a, b); + m2 = MAX (c, d); + return MAX (m1, m2); +} + +static void +compute_extents (pixman_f_transform_t *trans, double *sx, double *sy) +{ + double min_x, max_x, min_y, max_y; + pixman_f_vector_t v[4] = + { + { { 1, 1, 1 } }, + { { -1, 1, 1 } }, + { { -1, -1, 1 } }, + { { 1, -1, 1 } }, + }; + + pixman_f_transform_point (trans, &v[0]); + pixman_f_transform_point (trans, &v[1]); + pixman_f_transform_point (trans, &v[2]); + pixman_f_transform_point (trans, &v[3]); + + min_x = min4 (v[0].v[0], v[1].v[0], v[2].v[0], v[3].v[0]); + max_x = max4 (v[0].v[0], v[1].v[0], v[2].v[0], v[3].v[0]); + min_y = min4 (v[0].v[1], v[1].v[1], v[2].v[1], v[3].v[1]); + max_y = max4 (v[0].v[1], v[1].v[1], v[2].v[1], v[3].v[1]); + + *sx = (max_x - min_x) / 2.0; + *sy = (max_y - min_y) / 2.0; +} + +typedef struct +{ + char name [20]; + pixman_kernel_t value; +} named_int_t; + +static const named_int_t filters[] = +{ + { "Box", PIXMAN_KERNEL_BOX }, + { "Impulse", PIXMAN_KERNEL_IMPULSE }, + { "Linear", PIXMAN_KERNEL_LINEAR }, + { "Cubic", PIXMAN_KERNEL_CUBIC }, + { "Lanczos2", PIXMAN_KERNEL_LANCZOS2 }, + { "Lanczos3", PIXMAN_KERNEL_LANCZOS3 }, + { "Lanczos3 Stretched", PIXMAN_KERNEL_LANCZOS3_STRETCHED }, + { "Gaussian", PIXMAN_KERNEL_GAUSSIAN }, +}; + +static const named_int_t repeats[] = +{ + { "None", PIXMAN_REPEAT_NONE }, + { "Normal", PIXMAN_REPEAT_NORMAL }, + { "Reflect", PIXMAN_REPEAT_REFLECT }, + { "Pad", PIXMAN_REPEAT_PAD }, +}; + +static pixman_kernel_t +get_value (app_t *app, const named_int_t table[], const char *box_name) +{ + GtkComboBox *box = GTK_COMBO_BOX (get_widget (app, box_name)); + + return table[gtk_combo_box_get_active (box)].value; +} + +static void +copy_to_counterpart (app_t *app, GObject *object) +{ + static const char *xy_map[] = + { + "reconstruct_x_combo_box", "reconstruct_y_combo_box", + "sample_x_combo_box", "sample_y_combo_box", + "scale_x_adjustment", "scale_y_adjustment", + }; + GObject *counterpart = NULL; + int i; + + for (i = 0; i < G_N_ELEMENTS (xy_map); i += 2) + { + GObject *x = gtk_builder_get_object (app->builder, xy_map[i]); + GObject *y = gtk_builder_get_object (app->builder, xy_map[i + 1]); + + if (object == x) + counterpart = y; + if (object == y) + counterpart = x; + } + + if (!counterpart) + return; + + if (GTK_IS_COMBO_BOX (counterpart)) + { + gtk_combo_box_set_active ( + GTK_COMBO_BOX (counterpart), + gtk_combo_box_get_active ( + GTK_COMBO_BOX (object))); + } + else if (GTK_IS_ADJUSTMENT (counterpart)) + { + gtk_adjustment_set_value ( + GTK_ADJUSTMENT (counterpart), + gtk_adjustment_get_value ( + GTK_ADJUSTMENT (object))); + } +} + +static double +to_scale (double v) +{ + return pow (1.15, v); +} + +static void +rescale (GtkWidget *may_be_null, app_t *app) +{ + pixman_f_transform_t ftransform; + pixman_transform_t transform; + double new_width, new_height; + double fscale_x, fscale_y; + double rotation; + pixman_fixed_t *params; + int n_params; + double sx, sy; + + pixman_f_transform_init_identity (&ftransform); + + if (may_be_null && gtk_toggle_button_get_active ( + GTK_TOGGLE_BUTTON (get_widget (app, "lock_checkbutton")))) + { + copy_to_counterpart (app, G_OBJECT (may_be_null)); + } + + fscale_x = gtk_adjustment_get_value (app->scale_x_adjustment); + fscale_y = gtk_adjustment_get_value (app->scale_y_adjustment); + rotation = gtk_adjustment_get_value (app->rotate_adjustment); + + fscale_x = to_scale (fscale_x); + fscale_y = to_scale (fscale_y); + + new_width = pixman_image_get_width (app->original) * fscale_x; + new_height = pixman_image_get_height (app->original) * fscale_y; + + pixman_f_transform_scale (&ftransform, NULL, fscale_x, fscale_y); + + pixman_f_transform_translate (&ftransform, NULL, - new_width / 2.0, - new_height / 2.0); + + rotation = (rotation / 360.0) * 2 * M_PI; + pixman_f_transform_rotate (&ftransform, NULL, cos (rotation), sin (rotation)); + + pixman_f_transform_translate (&ftransform, NULL, new_width / 2.0, new_height / 2.0); + + pixman_f_transform_invert (&ftransform, &ftransform); + + compute_extents (&ftransform, &sx, &sy); + + pixman_transform_from_pixman_f_transform (&transform, &ftransform); + pixman_image_set_transform (app->original, &transform); + + params = pixman_filter_create_separable_convolution ( + &n_params, + sx * 65536.0 + 0.5, + sy * 65536.0 + 0.5, + get_value (app, filters, "reconstruct_x_combo_box"), + get_value (app, filters, "reconstruct_y_combo_box"), + get_value (app, filters, "sample_x_combo_box"), + get_value (app, filters, "sample_y_combo_box"), + gtk_adjustment_get_value (app->subsample_adjustment), + gtk_adjustment_get_value (app->subsample_adjustment)); + + pixman_image_set_filter (app->original, PIXMAN_FILTER_SEPARABLE_CONVOLUTION, params, n_params); + + pixman_image_set_repeat ( + app->original, get_value (app, repeats, "repeat_combo_box")); + + free (params); + + app->scaled_width = ceil (new_width); + app->scaled_height = ceil (new_height); + + gtk_widget_set_size_request ( + get_widget (app, "drawing_area"), new_width + 0.5, new_height + 0.5); + + gtk_widget_queue_draw ( + get_widget (app, "drawing_area")); +} + +static gboolean +on_expose (GtkWidget *da, GdkEvent *event, gpointer data) +{ + app_t *app = data; + GdkRectangle *area = &event->expose.area; + cairo_surface_t *surface; + pixman_image_t *tmp; + cairo_t *cr; + uint32_t *pixels; + + pixels = calloc (1, area->width * area->height * 4); + tmp = pixman_image_create_bits ( + PIXMAN_a8r8g8b8, area->width, area->height, pixels, area->width * 4); + + if (area->x < app->scaled_width && area->y < app->scaled_height) + { + pixman_image_composite ( + PIXMAN_OP_SRC, + app->original, NULL, tmp, + area->x, area->y, 0, 0, 0, 0, + app->scaled_width - area->x, app->scaled_height - area->y); + } + + surface = cairo_image_surface_create_for_data ( + (uint8_t *)pixels, CAIRO_FORMAT_ARGB32, + area->width, area->height, area->width * 4); + + cr = gdk_cairo_create (da->window); + + cairo_set_source_surface (cr, surface, area->x, area->y); + + cairo_paint (cr); + + cairo_destroy (cr); + cairo_surface_destroy (surface); + free (pixels); + pixman_image_unref (tmp); + + return TRUE; +} + +static void +set_up_combo_box (app_t *app, const char *box_name, + int n_entries, const named_int_t table[]) +{ + GtkWidget *widget = get_widget (app, box_name); + GtkListStore *model; + GtkCellRenderer *cell; + int i; + + model = gtk_list_store_new (1, G_TYPE_STRING); + + cell = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget), cell, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), cell, + "text", 0, + NULL); + + gtk_combo_box_set_model (GTK_COMBO_BOX (widget), GTK_TREE_MODEL (model)); + + for (i = 0; i < n_entries; ++i) + { + const named_int_t *info = &(table[i]); + GtkTreeIter iter; + + gtk_list_store_append (model, &iter); + gtk_list_store_set (model, &iter, 0, info->name, -1); + } + + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); + + g_signal_connect (widget, "changed", G_CALLBACK (rescale), app); +} + +static void +set_up_filter_box (app_t *app, const char *box_name) +{ + set_up_combo_box (app, box_name, G_N_ELEMENTS (filters), filters); +} + +static char * +format_value (GtkWidget *widget, double value) +{ + return g_strdup_printf ("%.4f", to_scale (value)); +} + +static app_t * +app_new (pixman_image_t *original) +{ + GtkWidget *widget; + app_t *app = g_malloc (sizeof *app); + GError *err = NULL; + + app->builder = gtk_builder_new (); + app->original = original; + + if (!gtk_builder_add_from_file (app->builder, "scale.ui", &err)) + g_error ("Could not read file scale.ui: %s", err->message); + + app->scale_x_adjustment = + GTK_ADJUSTMENT (gtk_builder_get_object (app->builder, "scale_x_adjustment")); + app->scale_y_adjustment = + GTK_ADJUSTMENT (gtk_builder_get_object (app->builder, "scale_y_adjustment")); + app->rotate_adjustment = + GTK_ADJUSTMENT (gtk_builder_get_object (app->builder, "rotate_adjustment")); + app->subsample_adjustment = + GTK_ADJUSTMENT (gtk_builder_get_object (app->builder, "subsample_adjustment")); + + g_signal_connect (app->scale_x_adjustment, "value_changed", G_CALLBACK (rescale), app); + g_signal_connect (app->scale_y_adjustment, "value_changed", G_CALLBACK (rescale), app); + g_signal_connect (app->rotate_adjustment, "value_changed", G_CALLBACK (rescale), app); + g_signal_connect (app->subsample_adjustment, "value_changed", G_CALLBACK (rescale), app); + + widget = get_widget (app, "scale_x_scale"); + gtk_scale_add_mark (GTK_SCALE (widget), 0.0, GTK_POS_LEFT, NULL); + g_signal_connect (widget, "format_value", G_CALLBACK (format_value), app); + widget = get_widget (app, "scale_y_scale"); + gtk_scale_add_mark (GTK_SCALE (widget), 0.0, GTK_POS_LEFT, NULL); + g_signal_connect (widget, "format_value", G_CALLBACK (format_value), app); + widget = get_widget (app, "rotate_scale"); + gtk_scale_add_mark (GTK_SCALE (widget), 0.0, GTK_POS_LEFT, NULL); + + widget = get_widget (app, "drawing_area"); + g_signal_connect (widget, "expose_event", G_CALLBACK (on_expose), app); + + set_up_filter_box (app, "reconstruct_x_combo_box"); + set_up_filter_box (app, "reconstruct_y_combo_box"); + set_up_filter_box (app, "sample_x_combo_box"); + set_up_filter_box (app, "sample_y_combo_box"); + + set_up_combo_box ( + app, "repeat_combo_box", G_N_ELEMENTS (repeats), repeats); + + g_signal_connect ( + gtk_builder_get_object (app->builder, "lock_checkbutton"), + "toggled", G_CALLBACK (rescale), app); + + rescale (NULL, app); + + return app; +} + +int +main (int argc, char **argv) +{ + GtkWidget *window; + pixman_image_t *image; + app_t *app; + + gtk_init (&argc, &argv); + + if (argc < 2) + { + printf ("%s <image file>\n", argv[0]); + return -1; + } + + if (!(image = pixman_image_from_file (argv[1], PIXMAN_a8r8g8b8))) + { + printf ("Could not load image \"%s\"\n", argv[1]); + return -1; + } + + app = app_new (image); + + window = get_widget (app, "main"); + + g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL); + + gtk_window_set_default_size (GTK_WINDOW (window), 1024, 768); + + gtk_widget_show_all (window); + + gtk_main (); + + return 0; +} diff --git a/lib/pixman/demos/scale.ui b/lib/pixman/demos/scale.ui new file mode 100644 index 000000000..b3450d34d --- /dev/null +++ b/lib/pixman/demos/scale.ui @@ -0,0 +1,332 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 2.12 --> + <!-- interface-naming-policy toplevel-contextual --> + <object class="GtkAdjustment" id="rotate_adjustment"> + <property name="lower">-180</property> + <property name="upper">190</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + <property name="page_size">10</property> + </object> + <object class="GtkAdjustment" id="scale_y_adjustment"> + <property name="lower">-32</property> + <property name="upper">42</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + <property name="page_size">10</property> + </object> + <object class="GtkAdjustment" id="scale_x_adjustment"> + <property name="lower">-32</property> + <property name="upper">42</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + <property name="page_size">10</property> + </object> + <object class="GtkAdjustment" id="subsample_adjustment"> + <property name="lower">1</property> + <property name="upper">12</property> + <property name="step_increment">1</property> + <property name="page_increment">1</property> + <property name="page_size">0</property> + <property name="value">4</property> + </object> + <object class="GtkWindow" id="main"> + <child> + <object class="GtkHBox" id="u"> + <property name="visible">True</property> + <property name="spacing">12</property> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkViewport" id="viewport1"> + <property name="visible">True</property> + <child> + <object class="GtkDrawingArea" id="drawing_area"> + <property name="visible">True</property> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="box1"> + <property name="visible">True</property> + <property name="spacing">12</property> + <child> + <object class="GtkHBox" id="box2"> + <property name="visible">True</property> + <property name="homogeneous">True</property> + <child> + <object class="GtkVBox" id="box3"> + <property name="visible">True</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Scale X</b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVScale" id="scale_x_scale"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">scale_x_adjustment</property> + <property name="fill_level">32</property> + <property name="value_pos">right</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="box4"> + <property name="visible">True</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Scale Y</b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVScale" id="scale_y_scale"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">scale_y_adjustment</property> + <property name="fill_level">32</property> + <property name="value_pos">right</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="box5"> + <property name="visible">True</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Rotate</b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVScale" id="rotate_scale"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">rotate_adjustment</property> + <property name="fill_level">180</property> + <property name="value_pos">right</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="padding">6</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="box6"> + <property name="visible">True</property> + <child> + <object class="GtkCheckButton" + id="lock_checkbutton"> + <property name="label" translatable="yes">Lock X and Y Dimensions</property> + <property name="xalign">0.0</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="padding">6</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkTable" id="grid1"> + <property name="visible">True</property> + <property name="column_spacing">8</property> + <property name="row_spacing">6</property> + <child> + <object class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes"><b>Reconstruct X:</b></property> + <property name="use_markup">True</property> + </object> + </child> + <child> + <object class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes"><b>Reconstruct Y:</b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label6"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes"><b>Sample X:</b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes"><b>Sample Y:</b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label8"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes"><b>Repeat:</b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="top_attach">4</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label9"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes"><b>Subsample:</b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="top_attach">5</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="reconstruct_x_combo_box"> + <property name="visible">True</property> + </object> + <packing> + <property name="left_attach">1</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="reconstruct_y_combo_box"> + <property name="visible">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="sample_x_combo_box"> + <property name="visible">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="sample_y_combo_box"> + <property name="visible">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="repeat_combo_box"> + <property name="visible">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">4</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="subsample_spin_button"> + <property name="visible">True</property> + <property name="adjustment">subsample_adjustment</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">5</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="padding">6</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> +</interface> |