summaryrefslogtreecommitdiff
path: root/Source/DirectFB/tests
diff options
context:
space:
mode:
Diffstat (limited to 'Source/DirectFB/tests')
-rwxr-xr-xSource/DirectFB/tests/Makefile.am58
-rwxr-xr-xSource/DirectFB/tests/Makefile.in612
-rwxr-xr-xSource/DirectFB/tests/dfbtest_blit.c316
-rwxr-xr-xSource/DirectFB/tests/dfbtest_font.c206
-rwxr-xr-xSource/DirectFB/tests/dfbtest_reinit.c72
-rwxr-xr-xSource/DirectFB/tests/dfbtest_scale.c156
-rwxr-xr-xSource/DirectFB/tests/dfbtest_window.c1241
-rwxr-xr-xSource/DirectFB/tests/dfbtest_windows_watcher.c227
-rwxr-xr-xSource/DirectFB/tests/dfbtest_write.c162
-rwxr-xr-xSource/DirectFB/tests/direct_stream.c139
-rwxr-xr-xSource/DirectFB/tests/direct_test.c119
-rwxr-xr-xSource/DirectFB/tests/fusion_fork.c172
-rwxr-xr-xSource/DirectFB/tests/fusion_reactor.c199
-rwxr-xr-xSource/DirectFB/tests/fusion_skirmish.c131
-rwxr-xr-xSource/DirectFB/tests/fusion_stream.c545
-rwxr-xr-xSource/DirectFB/tests/smiley_test.c215
16 files changed, 4570 insertions, 0 deletions
diff --git a/Source/DirectFB/tests/Makefile.am b/Source/DirectFB/tests/Makefile.am
new file mode 100755
index 0000000..ce41711
--- /dev/null
+++ b/Source/DirectFB/tests/Makefile.am
@@ -0,0 +1,58 @@
+## Makefile.am for DirectFB/tests
+
+INCLUDES = \
+ -I$(top_builddir)/lib \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/src \
+ -DLINUX_2_6
+
+
+noinst_PROGRAMS = \
+ dfbtest_blit \
+ dfbtest_reinit \
+ dfbtest_scale \
+ dfbtest_window \
+ direct_stream \
+ direct_test \
+ fusion_fork \
+ fusion_reactor \
+ fusion_skirmish \
+ fusion_stream
+
+libdirectfb = $(top_builddir)/src/libdirectfb.la
+libfusion = $(top_builddir)/lib/fusion/libfusion.la
+libdirect = $(top_builddir)/lib/direct/libdirect.la
+
+dfbtest_blit_SOURCES = dfbtest_blit.c
+dfbtest_blit_LDADD = $(libdirectfb) $(libfusion) $(libdirect)
+
+dfbtest_reinit_SOURCES = dfbtest_reinit.c
+dfbtest_reinit_LDADD = $(libdirectfb) $(libfusion) $(libdirect)
+
+dfbtest_scale_SOURCES = dfbtest_scale.c
+dfbtest_scale_LDADD = $(libdirectfb) $(libfusion) $(libdirect)
+
+dfbtest_window_SOURCES = dfbtest_window.c
+dfbtest_window_LDADD = $(libdirectfb) $(libfusion) $(libdirect)
+
+
+direct_stream_SOURCES = direct_stream.c
+direct_stream_LDADD = $(libdirect)
+
+direct_test_SOURCES = direct_test.c
+direct_test_LDADD = $(libdirect)
+
+
+fusion_fork_SOURCES = fusion_fork.c
+fusion_fork_LDADD = $(libdirectfb) $(libfusion) $(libdirect)
+
+fusion_reactor_SOURCES = fusion_reactor.c
+fusion_reactor_LDADD = $(libdirectfb) $(libfusion) $(libdirect)
+
+fusion_skirmish_SOURCES = fusion_skirmish.c
+fusion_skirmish_LDADD = $(libdirectfb) $(libfusion) $(libdirect)
+
+fusion_stream_SOURCES = fusion_stream.c
+fusion_stream_LDADD = $(libdirectfb) $(libfusion) $(libdirect)
diff --git a/Source/DirectFB/tests/Makefile.in b/Source/DirectFB/tests/Makefile.in
new file mode 100755
index 0000000..a64dd81
--- /dev/null
+++ b/Source/DirectFB/tests/Makefile.in
@@ -0,0 +1,612 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+noinst_PROGRAMS = dfbtest_blit$(EXEEXT) dfbtest_reinit$(EXEEXT) \
+ dfbtest_scale$(EXEEXT) dfbtest_window$(EXEEXT) \
+ direct_stream$(EXEEXT) direct_test$(EXEEXT) \
+ fusion_fork$(EXEEXT) fusion_reactor$(EXEEXT) \
+ fusion_skirmish$(EXEEXT) fusion_stream$(EXEEXT)
+subdir = tests
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+PROGRAMS = $(noinst_PROGRAMS)
+am_dfbtest_blit_OBJECTS = dfbtest_blit.$(OBJEXT)
+dfbtest_blit_OBJECTS = $(am_dfbtest_blit_OBJECTS)
+dfbtest_blit_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libdirect)
+am_dfbtest_reinit_OBJECTS = dfbtest_reinit.$(OBJEXT)
+dfbtest_reinit_OBJECTS = $(am_dfbtest_reinit_OBJECTS)
+dfbtest_reinit_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libdirect)
+am_dfbtest_scale_OBJECTS = dfbtest_scale.$(OBJEXT)
+dfbtest_scale_OBJECTS = $(am_dfbtest_scale_OBJECTS)
+dfbtest_scale_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libdirect)
+am_dfbtest_window_OBJECTS = dfbtest_window.$(OBJEXT)
+dfbtest_window_OBJECTS = $(am_dfbtest_window_OBJECTS)
+dfbtest_window_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libdirect)
+am_direct_stream_OBJECTS = direct_stream.$(OBJEXT)
+direct_stream_OBJECTS = $(am_direct_stream_OBJECTS)
+direct_stream_DEPENDENCIES = $(libdirect)
+am_direct_test_OBJECTS = direct_test.$(OBJEXT)
+direct_test_OBJECTS = $(am_direct_test_OBJECTS)
+direct_test_DEPENDENCIES = $(libdirect)
+am_fusion_fork_OBJECTS = fusion_fork.$(OBJEXT)
+fusion_fork_OBJECTS = $(am_fusion_fork_OBJECTS)
+fusion_fork_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libdirect)
+am_fusion_reactor_OBJECTS = fusion_reactor.$(OBJEXT)
+fusion_reactor_OBJECTS = $(am_fusion_reactor_OBJECTS)
+fusion_reactor_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libdirect)
+am_fusion_skirmish_OBJECTS = fusion_skirmish.$(OBJEXT)
+fusion_skirmish_OBJECTS = $(am_fusion_skirmish_OBJECTS)
+fusion_skirmish_DEPENDENCIES = $(libdirectfb) $(libfusion) \
+ $(libdirect)
+am_fusion_stream_OBJECTS = fusion_stream.$(OBJEXT)
+fusion_stream_OBJECTS = $(am_fusion_stream_OBJECTS)
+fusion_stream_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libdirect)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(dfbtest_blit_SOURCES) $(dfbtest_reinit_SOURCES) \
+ $(dfbtest_scale_SOURCES) $(dfbtest_window_SOURCES) \
+ $(direct_stream_SOURCES) $(direct_test_SOURCES) \
+ $(fusion_fork_SOURCES) $(fusion_reactor_SOURCES) \
+ $(fusion_skirmish_SOURCES) $(fusion_stream_SOURCES)
+DIST_SOURCES = $(dfbtest_blit_SOURCES) $(dfbtest_reinit_SOURCES) \
+ $(dfbtest_scale_SOURCES) $(dfbtest_window_SOURCES) \
+ $(direct_stream_SOURCES) $(direct_test_SOURCES) \
+ $(fusion_fork_SOURCES) $(fusion_reactor_SOURCES) \
+ $(fusion_skirmish_SOURCES) $(fusion_stream_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+ASFLAGS = @ASFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATADIR = @DATADIR@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DFB_CFLAGS_OMIT_FRAME_POINTER = @DFB_CFLAGS_OMIT_FRAME_POINTER@
+DFB_INTERNAL_CFLAGS = @DFB_INTERNAL_CFLAGS@
+DFB_LDFLAGS = @DFB_LDFLAGS@
+DFB_SMOOTH_SCALING = @DFB_SMOOTH_SCALING@
+DIRECTFB_BINARY_AGE = @DIRECTFB_BINARY_AGE@
+DIRECTFB_CSOURCE = @DIRECTFB_CSOURCE@
+DIRECTFB_INTERFACE_AGE = @DIRECTFB_INTERFACE_AGE@
+DIRECTFB_MAJOR_VERSION = @DIRECTFB_MAJOR_VERSION@
+DIRECTFB_MICRO_VERSION = @DIRECTFB_MICRO_VERSION@
+DIRECTFB_MINOR_VERSION = @DIRECTFB_MINOR_VERSION@
+DIRECTFB_VERSION = @DIRECTFB_VERSION@
+DIRECT_BUILD_DEBUG = @DIRECT_BUILD_DEBUG@
+DIRECT_BUILD_DEBUGS = @DIRECT_BUILD_DEBUGS@
+DIRECT_BUILD_GETTID = @DIRECT_BUILD_GETTID@
+DIRECT_BUILD_NETWORK = @DIRECT_BUILD_NETWORK@
+DIRECT_BUILD_STDBOOL = @DIRECT_BUILD_STDBOOL@
+DIRECT_BUILD_TEXT = @DIRECT_BUILD_TEXT@
+DIRECT_BUILD_TRACE = @DIRECT_BUILD_TRACE@
+DSYMUTIL = @DSYMUTIL@
+DYNLIB = @DYNLIB@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+FREETYPE_PROVIDER = @FREETYPE_PROVIDER@
+FUSION_BUILD_KERNEL = @FUSION_BUILD_KERNEL@
+FUSION_BUILD_MULTI = @FUSION_BUILD_MULTI@
+FUSION_MESSAGE_SIZE = @FUSION_MESSAGE_SIZE@
+GIF_PROVIDER = @GIF_PROVIDER@
+GREP = @GREP@
+HAVE_LINUX = @HAVE_LINUX@
+INCLUDEDIR = @INCLUDEDIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTERNALINCLUDEDIR = @INTERNALINCLUDEDIR@
+JPEG_PROVIDER = @JPEG_PROVIDER@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBJPEG = @LIBJPEG@
+LIBOBJS = @LIBOBJS@
+LIBPNG = @LIBPNG@
+LIBPNG_CONFIG = @LIBPNG_CONFIG@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LT_AGE = @LT_AGE@
+LT_BINARY = @LT_BINARY@
+LT_CURRENT = @LT_CURRENT@
+LT_RELEASE = @LT_RELEASE@
+LT_REVISION = @LT_REVISION@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAN2HTML = @MAN2HTML@
+MKDIR_P = @MKDIR_P@
+MODULEDIR = @MODULEDIR@
+MODULEDIRNAME = @MODULEDIRNAME@
+NMEDIT = @NMEDIT@
+OBJEXT = @OBJEXT@
+OSX_LIBS = @OSX_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PNG_PROVIDER = @PNG_PROVIDER@
+RANLIB = @RANLIB@
+RUNTIME_SYSROOT = @RUNTIME_SYSROOT@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOPATH = @SOPATH@
+STRIP = @STRIP@
+SYSCONFDIR = @SYSCONFDIR@
+SYSFS_LIBS = @SYSFS_LIBS@
+THREADFLAGS = @THREADFLAGS@
+THREADLIB = @THREADLIB@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+VERSION = @VERSION@
+VNC_CFLAGS = @VNC_CFLAGS@
+VNC_CONFIG = @VNC_CONFIG@
+VNC_LIBS = @VNC_LIBS@
+X11_CFLAGS = @X11_CFLAGS@
+X11_LIBS = @X11_LIBS@
+ZLIB_LIBS = @ZLIB_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = \
+ -I$(top_builddir)/lib \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/src \
+ -DLINUX_2_6
+
+libdirectfb = $(top_builddir)/src/libdirectfb.la
+libfusion = $(top_builddir)/lib/fusion/libfusion.la
+libdirect = $(top_builddir)/lib/direct/libdirect.la
+dfbtest_blit_SOURCES = dfbtest_blit.c
+dfbtest_blit_LDADD = $(libdirectfb) $(libfusion) $(libdirect)
+dfbtest_reinit_SOURCES = dfbtest_reinit.c
+dfbtest_reinit_LDADD = $(libdirectfb) $(libfusion) $(libdirect)
+dfbtest_scale_SOURCES = dfbtest_scale.c
+dfbtest_scale_LDADD = $(libdirectfb) $(libfusion) $(libdirect)
+dfbtest_window_SOURCES = dfbtest_window.c
+dfbtest_window_LDADD = $(libdirectfb) $(libfusion) $(libdirect)
+direct_stream_SOURCES = direct_stream.c
+direct_stream_LDADD = $(libdirect)
+direct_test_SOURCES = direct_test.c
+direct_test_LDADD = $(libdirect)
+fusion_fork_SOURCES = fusion_fork.c
+fusion_fork_LDADD = $(libdirectfb) $(libfusion) $(libdirect)
+fusion_reactor_SOURCES = fusion_reactor.c
+fusion_reactor_LDADD = $(libdirectfb) $(libfusion) $(libdirect)
+fusion_skirmish_SOURCES = fusion_skirmish.c
+fusion_skirmish_LDADD = $(libdirectfb) $(libfusion) $(libdirect)
+fusion_stream_SOURCES = fusion_stream.c
+fusion_stream_LDADD = $(libdirectfb) $(libfusion) $(libdirect)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu tests/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+dfbtest_blit$(EXEEXT): $(dfbtest_blit_OBJECTS) $(dfbtest_blit_DEPENDENCIES)
+ @rm -f dfbtest_blit$(EXEEXT)
+ $(LINK) $(dfbtest_blit_OBJECTS) $(dfbtest_blit_LDADD) $(LIBS)
+dfbtest_reinit$(EXEEXT): $(dfbtest_reinit_OBJECTS) $(dfbtest_reinit_DEPENDENCIES)
+ @rm -f dfbtest_reinit$(EXEEXT)
+ $(LINK) $(dfbtest_reinit_OBJECTS) $(dfbtest_reinit_LDADD) $(LIBS)
+dfbtest_scale$(EXEEXT): $(dfbtest_scale_OBJECTS) $(dfbtest_scale_DEPENDENCIES)
+ @rm -f dfbtest_scale$(EXEEXT)
+ $(LINK) $(dfbtest_scale_OBJECTS) $(dfbtest_scale_LDADD) $(LIBS)
+dfbtest_window$(EXEEXT): $(dfbtest_window_OBJECTS) $(dfbtest_window_DEPENDENCIES)
+ @rm -f dfbtest_window$(EXEEXT)
+ $(LINK) $(dfbtest_window_OBJECTS) $(dfbtest_window_LDADD) $(LIBS)
+direct_stream$(EXEEXT): $(direct_stream_OBJECTS) $(direct_stream_DEPENDENCIES)
+ @rm -f direct_stream$(EXEEXT)
+ $(LINK) $(direct_stream_OBJECTS) $(direct_stream_LDADD) $(LIBS)
+direct_test$(EXEEXT): $(direct_test_OBJECTS) $(direct_test_DEPENDENCIES)
+ @rm -f direct_test$(EXEEXT)
+ $(LINK) $(direct_test_OBJECTS) $(direct_test_LDADD) $(LIBS)
+fusion_fork$(EXEEXT): $(fusion_fork_OBJECTS) $(fusion_fork_DEPENDENCIES)
+ @rm -f fusion_fork$(EXEEXT)
+ $(LINK) $(fusion_fork_OBJECTS) $(fusion_fork_LDADD) $(LIBS)
+fusion_reactor$(EXEEXT): $(fusion_reactor_OBJECTS) $(fusion_reactor_DEPENDENCIES)
+ @rm -f fusion_reactor$(EXEEXT)
+ $(LINK) $(fusion_reactor_OBJECTS) $(fusion_reactor_LDADD) $(LIBS)
+fusion_skirmish$(EXEEXT): $(fusion_skirmish_OBJECTS) $(fusion_skirmish_DEPENDENCIES)
+ @rm -f fusion_skirmish$(EXEEXT)
+ $(LINK) $(fusion_skirmish_OBJECTS) $(fusion_skirmish_LDADD) $(LIBS)
+fusion_stream$(EXEEXT): $(fusion_stream_OBJECTS) $(fusion_stream_DEPENDENCIES)
+ @rm -f fusion_stream$(EXEEXT)
+ $(LINK) $(fusion_stream_OBJECTS) $(fusion_stream_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfbtest_blit.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfbtest_reinit.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfbtest_scale.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfbtest_window.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/direct_stream.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/direct_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fusion_fork.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fusion_reactor.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fusion_skirmish.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fusion_stream.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean 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-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ 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
+
+# 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.
+.NOEXPORT:
diff --git a/Source/DirectFB/tests/dfbtest_blit.c b/Source/DirectFB/tests/dfbtest_blit.c
new file mode 100755
index 0000000..7a9235f
--- /dev/null
+++ b/Source/DirectFB/tests/dfbtest_blit.c
@@ -0,0 +1,316 @@
+/*
+ (c) Copyright 2008 Denis Oliver Kropp
+
+ All rights reserved.
+
+ This file is subject to the terms and conditions of the MIT License:
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <direct/messages.h>
+
+#include <directfb.h>
+#include <directfb_strings.h>
+#include <directfb_util.h>
+
+static const DirectFBPixelFormatNames( format_names );
+
+/**********************************************************************************************************************/
+
+static DFBBoolean
+parse_format( const char *arg, DFBSurfacePixelFormat *_f )
+{
+ int i = 0;
+
+ while (format_names[i].format != DSPF_UNKNOWN) {
+ if (!strcasecmp( arg, format_names[i].name )) {
+ *_f = format_names[i].format;
+ return DFB_TRUE;
+ }
+
+ ++i;
+ }
+
+ fprintf (stderr, "\nInvalid format specified!\n\n" );
+
+ return DFB_FALSE;
+}
+
+static int
+print_usage( const char *prg )
+{
+ int i = 0;
+
+ fprintf (stderr, "\n");
+ fprintf (stderr, "== DirectFB Blitting Test (version %s) ==\n", DIRECTFB_VERSION);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Known pixel formats:\n");
+
+ while (format_names[i].format != DSPF_UNKNOWN) {
+ DFBSurfacePixelFormat format = format_names[i].format;
+
+ fprintf (stderr, " %-10s %2d bits, %d bytes",
+ format_names[i].name, DFB_BITS_PER_PIXEL(format),
+ DFB_BYTES_PER_PIXEL(format));
+
+ if (DFB_PIXELFORMAT_HAS_ALPHA(format))
+ fprintf (stderr, " ALPHA");
+
+ if (DFB_PIXELFORMAT_IS_INDEXED(format))
+ fprintf (stderr, " INDEXED");
+
+ if (DFB_PLANAR_PIXELFORMAT(format)) {
+ int planes = DFB_PLANE_MULTIPLY(format, 1000);
+
+ fprintf (stderr, " PLANAR (x%d.%03d)",
+ planes / 1000, planes % 1000);
+ }
+
+ fprintf (stderr, "\n");
+
+ ++i;
+ }
+
+ fprintf (stderr, "\n");
+
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Usage: %s [options]\n", prg);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Options:\n");
+ fprintf (stderr, " -h, --help Show this help message\n");
+ fprintf (stderr, " -v, --version Print version information\n");
+ fprintf (stderr, " -s, --source <pixelformat> Source pixel format\n");
+ fprintf (stderr, " -d, --dest <pixelformat> Destination pixel format\n");
+ fprintf (stderr, " -r, --resize Set destination from source size\n");
+ fprintf (stderr, " -b, --benchmark Enable benchmarking mode\n");
+ fprintf (stderr, " -R, --rerender Rerender before every blit (benchmark)\n");
+
+ return -1;
+}
+
+/**********************************************************************************************************************/
+
+int
+main( int argc, char *argv[] )
+{
+ int i;
+ DFBResult ret;
+ DFBSurfaceDescription desc;
+ IDirectFB *dfb;
+ IDirectFBImageProvider *provider = NULL;
+ IDirectFBSurface *source = NULL;
+ IDirectFBSurface *dest = NULL;
+ const char *url = NULL;
+ DFBSurfacePixelFormat source_format = DSPF_UNKNOWN;
+ DFBSurfacePixelFormat dest_format = DSPF_UNKNOWN;
+ bool dest_resize = false;
+ bool benchmark = false;
+ bool rerender = false;
+
+ /* Initialize DirectFB. */
+ ret = DirectFBInit( &argc, &argv );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Blit: DirectFBInit() failed!\n" );
+ return ret;
+ }
+
+ /* Parse arguments. */
+ for (i=1; i<argc; i++) {
+ const char *arg = argv[i];
+
+ if (strcmp( arg, "-h" ) == 0 || strcmp (arg, "--help") == 0)
+ return print_usage( argv[0] );
+ else if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
+ fprintf (stderr, "dfbtest_blit version %s\n", DIRECTFB_VERSION);
+ return false;
+ }
+ else if (strcmp (arg, "-s") == 0 || strcmp (arg, "--source") == 0) {
+ if (++i == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_format( argv[i], &source_format ))
+ return false;
+ }
+ else if (strcmp (arg, "-d") == 0 || strcmp (arg, "--dest") == 0) {
+ if (++i == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_format( argv[i], &dest_format ))
+ return false;
+ }
+ else if (strcmp (arg, "-r") == 0 || strcmp (arg, "--resize") == 0)
+ dest_resize = true;
+ else if (strcmp (arg, "-b") == 0 || strcmp (arg, "--benchmark") == 0)
+ benchmark = true;
+ else if (strcmp (arg, "-R") == 0 || strcmp (arg, "--rerender") == 0)
+ rerender = true;
+ else if (!url)
+ url = arg;
+ else
+ return print_usage( argv[0] );
+ }
+
+ /* Check if we got an URL. */
+ if (!url)
+ return print_usage( argv[0] );
+
+ /* Create super interface. */
+ ret = DirectFBCreate( &dfb );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Blit: DirectFBCreate() failed!\n" );
+ return ret;
+ }
+
+ /* Create an image provider for the image to be loaded. */
+ ret = dfb->CreateImageProvider( dfb, url, &provider );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Blit: IDirectFB::CreateImageProvider( '%s' ) failed!\n", url );
+ goto out;
+ }
+
+ /* Get the surface description. */
+ ret = provider->GetSurfaceDescription( provider, &desc );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Blit: IDirectFBImageProvider::GetSurfaceDescription() failed!\n" );
+ goto out;
+ }
+
+ if (source_format != DSPF_UNKNOWN)
+ desc.pixelformat = source_format;
+
+ D_INFO( "DFBTest/Blit: Source is %dx%d using %s\n",
+ desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
+
+ /* Create a surface for the image. */
+ ret = dfb->CreateSurface( dfb, &desc, &source );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Blit: IDirectFB::CreateSurface() failed!\n" );
+ goto out;
+ }
+
+ ret = provider->RenderTo( provider, source, NULL );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Blit: IDirectFBImageProvider::RenderTo() failed!\n" );
+ goto out;
+ }
+
+ /* Fill description for a primary surface. */
+ desc.flags = DSDESC_CAPS;
+ desc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
+
+ if (dest_format != DSPF_UNKNOWN) {
+ desc.flags |= DSDESC_PIXELFORMAT;
+ desc.pixelformat = dest_format;
+ }
+
+ if (dest_resize)
+ desc.flags |= DSDESC_WIDTH | DSDESC_HEIGHT;
+
+ dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
+
+ /* Create a primary surface. */
+ ret = dfb->CreateSurface( dfb, &desc, &dest );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Blit: IDirectFB::CreateSurface() failed!\n" );
+ goto out;
+ }
+
+ dest->GetSize( dest, &desc.width, &desc.height );
+ dest->GetPixelFormat( dest, &desc.pixelformat );
+
+ D_INFO( "DFBTest/Blit: Destination is %dx%d using %s\n",
+ desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
+
+ dest->StretchBlit( dest, source, NULL, NULL );
+ dest->Flip( dest, NULL, DSFLIP_NONE );
+
+ if (benchmark) {
+ int num = 0;
+ long long start, diff = 0, speed;
+
+ sync();
+
+ sleep( 1 );
+
+ dest->StretchBlit( dest, source, NULL, NULL );
+
+ D_INFO( "DFBTest/Blit: Benchmarking...\n" );
+
+ dfb->WaitIdle( dfb );
+
+ start = direct_clock_get_millis();
+
+ do {
+ if (rerender) {
+ ret = provider->RenderTo( provider, source, NULL );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Blit: IDirectFBImageProvider::RenderTo() failed!\n" );
+ goto out;
+ }
+ }
+
+ dest->StretchBlit( dest, source, NULL, NULL );
+
+ if ((num & 7) == 7)
+ diff = direct_clock_get_millis() - start;
+
+ num++;
+ } while (diff < 2300);
+
+ dfb->WaitIdle( dfb );
+
+ diff = direct_clock_get_millis() - start;
+
+ speed = (long long) num * desc.width * desc.height / diff;
+
+ D_INFO( "DFBTest/Blit: Speed is %lld.%03lld MPixel/sec (%dx%d x %d in %lld.%03lld sec)\n",
+ speed / 1000LL, speed % 1000LL, desc.width, desc.height, num, diff / 1000LL, diff % 1000LL );
+ }
+ else
+ sleep( 2 );
+
+
+out:
+ if (dest)
+ dest->Release( dest );
+
+ if (source)
+ source->Release( source );
+
+ if (provider)
+ provider->Release( provider );
+
+ /* Shutdown DirectFB. */
+ dfb->Release( dfb );
+
+ return ret;
+}
+
diff --git a/Source/DirectFB/tests/dfbtest_font.c b/Source/DirectFB/tests/dfbtest_font.c
new file mode 100755
index 0000000..1876a1d
--- /dev/null
+++ b/Source/DirectFB/tests/dfbtest_font.c
@@ -0,0 +1,206 @@
+/*
+ (c) Copyright 2008 Denis Oliver Kropp
+
+ All rights reserved.
+
+ This file is subject to the terms and conditions of the MIT License:
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <direct/messages.h>
+
+#include <directfb.h>
+#include <directfb_strings.h>
+#include <directfb_util.h>
+
+static const DirectFBPixelFormatNames( format_names );
+
+/**********************************************************************************************************************/
+
+static int
+print_usage( const char *prg )
+{
+ int i = 0;
+
+ fprintf (stderr, "\n");
+ fprintf (stderr, "== DirectFB Font Test (version %s) ==\n", DIRECTFB_VERSION);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Known pixel formats:\n");
+
+ while (format_names[i].format != DSPF_UNKNOWN) {
+ DFBSurfacePixelFormat format = format_names[i].format;
+
+ fprintf (stderr, " %-10s %2d bits, %d bytes",
+ format_names[i].name, DFB_BITS_PER_PIXEL(format),
+ DFB_BYTES_PER_PIXEL(format));
+
+ if (DFB_PIXELFORMAT_HAS_ALPHA(format))
+ fprintf (stderr, " ALPHA");
+
+ if (DFB_PIXELFORMAT_IS_INDEXED(format))
+ fprintf (stderr, " INDEXED");
+
+ if (DFB_PLANAR_PIXELFORMAT(format)) {
+ int planes = DFB_PLANE_MULTIPLY(format, 1000);
+
+ fprintf (stderr, " PLANAR (x%d.%03d)",
+ planes / 1000, planes % 1000);
+ }
+
+ fprintf (stderr, "\n");
+
+ ++i;
+ }
+
+ fprintf (stderr, "\n");
+
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Usage: %s [options] <file>\n", prg);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Options:\n");
+ fprintf (stderr, " -h, --help Show this help message\n");
+ fprintf (stderr, " -v, --version Print version information\n");
+
+ return -1;
+}
+
+/**********************************************************************************************************************/
+
+static IDirectFBFont *
+CreateFont( IDirectFB *dfb, const char *url, int size )
+{
+ DFBResult ret;
+ DFBFontDescription fdesc;
+ IDirectFBFont *font;
+
+ /* Create the font. */
+ fdesc.flags = DFDESC_HEIGHT;
+ fdesc.height = size;
+
+ ret = dfb->CreateFont( dfb, url, &fdesc, &font );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Font: IDirectFB::CreateFont( '%s' ) failed!\n", url );
+ return NULL;
+ }
+
+ return font;
+}
+
+int
+main( int argc, char *argv[] )
+{
+ int i;
+ DFBResult ret;
+ DFBSurfaceDescription desc;
+ IDirectFB *dfb;
+ IDirectFBSurface *dest = NULL;
+ const char *url = NULL;
+
+ /* Initialize DirectFB. */
+ ret = DirectFBInit( &argc, &argv );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Font: DirectFBInit() failed!\n" );
+ return ret;
+ }
+
+ /* Parse arguments. */
+ for (i=1; i<argc; i++) {
+ const char *arg = argv[i];
+
+ if (strcmp( arg, "-h" ) == 0 || strcmp (arg, "--help") == 0)
+ return print_usage( argv[0] );
+ else if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
+ fprintf (stderr, "dfbtest_blit version %s\n", DIRECTFB_VERSION);
+ return false;
+ }
+ else if (!url)
+ url = arg;
+ else
+ return print_usage( argv[0] );
+ }
+
+ /* Check if we got an URL. */
+ if (!url)
+ return print_usage( argv[0] );
+
+ /* Create super interface. */
+ ret = DirectFBCreate( &dfb );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Font: DirectFBCreate() failed!\n" );
+ return ret;
+ }
+
+ /* Fill description for a primary surface. */
+ desc.flags = DSDESC_CAPS;
+ desc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
+
+ dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
+
+ /* Create a primary surface. */
+ ret = dfb->CreateSurface( dfb, &desc, &dest );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Font: IDirectFB::CreateSurface() failed!\n" );
+ goto out;
+ }
+
+ dest->GetSize( dest, &desc.width, &desc.height );
+ dest->GetPixelFormat( dest, &desc.pixelformat );
+
+ D_INFO( "DFBTest/Font: Destination is %dx%d using %s\n",
+ desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
+
+ dest->SetColor( dest, 0xff, 0xff, 0xff, 0xff );
+
+
+ IDirectFBFont *font;
+
+ font = CreateFont( dfb, url, 20 );
+
+ for (i=10; i<50; i++) {
+ dest->Clear( dest, 0, 0, 0, 0 );
+
+ dest->SetFont( dest, font );
+ dest->DrawString( dest, "Test string with lots of characters", -1, 100, 100, DSTF_TOPLEFT );
+
+ dest->Flip( dest, NULL, DSFLIP_NONE );
+
+ sleep( 1 );
+ }
+
+ font->Release( font );
+
+
+out:
+ if (dest)
+ dest->Release( dest );
+
+ /* Shutdown DirectFB. */
+ dfb->Release( dfb );
+
+ return ret;
+}
+
diff --git a/Source/DirectFB/tests/dfbtest_reinit.c b/Source/DirectFB/tests/dfbtest_reinit.c
new file mode 100755
index 0000000..2c443c1
--- /dev/null
+++ b/Source/DirectFB/tests/dfbtest_reinit.c
@@ -0,0 +1,72 @@
+/*
+ (c) Copyright 2008 Denis Oliver Kropp
+
+ All rights reserved.
+
+ This file is subject to the terms and conditions of the MIT License:
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <config.h>
+
+#include <direct/messages.h>
+
+#include <directfb.h>
+
+
+int
+main( int argc, char *argv[] )
+{
+ DFBResult ret;
+ IDirectFB *dfb;
+
+ /* Initialize DirectFB. */
+ ret = DirectFBInit( &argc, &argv );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Reinit: DirectFBInit() failed!\n" );
+ return ret;
+ }
+
+
+ /* Create super interface. */
+ ret = DirectFBCreate( &dfb );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Reinit: 1st DirectFBCreate() failed!\n" );
+ return ret;
+ }
+
+ /* Shutdown DirectFB. */
+ dfb->Release( dfb );
+
+
+ /* Create super interface. */
+ ret = DirectFBCreate( &dfb );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Reinit: 2nd DirectFBCreate() failed!\n" );
+ return ret;
+ }
+
+ /* Shutdown DirectFB. */
+ dfb->Release( dfb );
+
+ return ret;
+}
+
diff --git a/Source/DirectFB/tests/dfbtest_scale.c b/Source/DirectFB/tests/dfbtest_scale.c
new file mode 100755
index 0000000..2d4e090
--- /dev/null
+++ b/Source/DirectFB/tests/dfbtest_scale.c
@@ -0,0 +1,156 @@
+/*
+ (c) Copyright 2008 Denis Oliver Kropp
+
+ All rights reserved.
+
+ This file is subject to the terms and conditions of the MIT License:
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include <direct/messages.h>
+
+#include <directfb.h>
+#include <directfb_util.h>
+
+
+static int
+show_usage( const char *prg )
+{
+ fprintf( stderr, "Usage: %s <url>\n", prg );
+
+ return -1;
+}
+
+int
+main( int argc, char *argv[] )
+{
+ int i;
+ DFBResult ret;
+ DFBSurfaceDescription desc;
+ IDirectFB *dfb;
+ IDirectFBImageProvider *provider = NULL;
+ IDirectFBSurface *source = NULL;
+ IDirectFBSurface *dest = NULL;
+ const char *url = NULL;
+
+ /* Parse arguments. */
+ for (i=1; i<argc; i++) {
+ if (!strcmp( argv[i], "-h" ))
+ return show_usage( argv[0] );
+ else if (!url)
+ url = argv[i];
+ else
+ return show_usage( argv[0] );
+ }
+
+ /* Check if we got an URL. */
+ if (!url)
+ return show_usage( argv[0] );
+
+ /* Initialize DirectFB. */
+ ret = DirectFBInit( &argc, &argv );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Scale: DirectFBInit() failed!\n" );
+ return ret;
+ }
+
+ /* Create super interface. */
+ ret = DirectFBCreate( &dfb );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Scale: DirectFBCreate() failed!\n" );
+ return ret;
+ }
+
+ /* Create an image provider for the image to be loaded. */
+ ret = dfb->CreateImageProvider( dfb, url, &provider );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Scale: IDirectFB::CreateImageProvider( '%s' ) failed!\n", url );
+ goto out;
+ }
+
+ /* Get the surface description. */
+ ret = provider->GetSurfaceDescription( provider, &desc );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Scale: IDirectFBImageProvider::GetSurfaceDescription() failed!\n" );
+ goto out;
+ }
+
+ desc.pixelformat = DSPF_LUT8;
+
+ D_INFO( "DFBTest/Scale: Source is %dx%d using %s\n",
+ desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
+
+ /* Create a surface for the image. */
+ ret = dfb->CreateSurface( dfb, &desc, &source );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Scale: IDirectFB::CreateSurface() failed!\n" );
+ goto out;
+ }
+
+ ret = provider->RenderTo( provider, source, NULL );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Scale: IDirectFBImageProvider::RenderTo() failed!\n" );
+ goto out;
+ }
+
+ desc.width = desc.width * 3 / 4;
+ desc.height = desc.height * 3 / 4;
+
+ if (DFB_PIXELFORMAT_IS_INDEXED( desc.pixelformat ))
+ desc.pixelformat = DSPF_ARGB;
+
+ D_INFO( "DFBTest/Scale: Destination is %dx%d using %s\n",
+ desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
+
+ /* Create a surface for the image. */
+ ret = dfb->CreateSurface( dfb, &desc, &dest );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Scale: IDirectFB::CreateSurface() failed!\n" );
+ goto out;
+ }
+
+ dest->SetBlittingFlags( dest, DSBLIT_SRC_PREMULTIPLY );
+ dest->StretchBlit( dest, source, NULL, NULL );
+
+ dest->Dump( dest, "dfbtest_scale", NULL );
+
+
+out:
+ if (dest)
+ dest->Release( dest );
+
+ if (source)
+ source->Release( source );
+
+ if (provider)
+ provider->Release( provider );
+
+ /* Shutdown DirectFB. */
+ dfb->Release( dfb );
+
+ return ret;
+}
+
diff --git a/Source/DirectFB/tests/dfbtest_window.c b/Source/DirectFB/tests/dfbtest_window.c
new file mode 100755
index 0000000..ab9f28b
--- /dev/null
+++ b/Source/DirectFB/tests/dfbtest_window.c
@@ -0,0 +1,1241 @@
+/*
+ (c) Copyright 2001-2009 The DirectFB Organization (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This file is subject to the terms and conditions of the MIT License:
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#define DIRECT_ENABLE_DEBUG
+
+#include <config.h>
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <direct/messages.h>
+#include <direct/util.h>
+
+#include <directfb.h>
+#include <directfb_strings.h>
+#include <directfb_util.h>
+
+static const DirectFBPixelFormatNames( format_names );
+static const DirectFBWindowCapabilitiesNames( caps_names );
+static const DirectFBWindowOptionsNames( options_names );
+
+/**********************************************************************************************************************/
+
+static DFBWindowDescription m_desc_top = {
+ .flags = DWDESC_CAPS | DWDESC_POSX | DWDESC_POSY |
+ DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_PIXELFORMAT | DWDESC_OPTIONS,
+ .posx = 100,
+ .posy = 100,
+ .width = 200,
+ .height = 200,
+};
+
+static DFBWindowDescription m_desc_sub = {
+ .flags = DWDESC_CAPS | DWDESC_POSX | DWDESC_POSY |
+ DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_PIXELFORMAT | DWDESC_OPTIONS | DWDESC_TOPLEVEL_ID,
+ .posx = 40,
+ .posy = 40,
+ .width = 120,
+ .height = 120,
+};
+
+static DFBColor m_topcolor;
+static DFBColor m_subcolor;
+
+static IDirectFBWindow *m_toplevel = NULL;
+static DFBWindowID m_toplevel_id = 0;
+
+static IDirectFBWindow *m_subwindow = NULL;
+static DFBWindowID m_subwindow_id = 0;
+
+static DFBBoolean m_wait_at_end = DFB_FALSE;
+
+/**********************************************************************************************************************/
+
+typedef DFBResult (*TestFunc)( IDirectFBDisplayLayer *layer, void *arg );
+
+/**********************************************************************************************************************/
+
+static DFBResult Test_CreateWindow( IDirectFBDisplayLayer *layer, void *arg );
+static DFBResult Test_CreateSubWindow( IDirectFBDisplayLayer *layer, void *arg );
+
+/**********************************************************************************************************************/
+
+static DFBResult Test_MoveWindow( IDirectFBDisplayLayer *layer, void *arg );
+static DFBResult Test_ScaleWindow( IDirectFBDisplayLayer *layer, void *arg );
+
+/**********************************************************************************************************************/
+
+static DFBResult Test_RestackWindow( IDirectFBDisplayLayer *layer, void *arg );
+
+/**********************************************************************************************************************/
+
+static DFBResult Test_SrcGeometry( IDirectFBDisplayLayer *layer, void *arg );
+static DFBResult Test_DstGeometry( IDirectFBDisplayLayer *layer, void *arg );
+
+/**********************************************************************************************************************/
+
+static DFBResult Test_HideWindow( IDirectFBDisplayLayer *layer, void *arg );
+static DFBResult Test_DestroyWindow( IDirectFBDisplayLayer *layer, void *arg );
+
+/**********************************************************************************************************************/
+
+typedef struct {
+ const char *name;
+ TestFunc func;
+
+ bool run_top;
+ bool run_sub;
+} Test;
+
+static Test m_tests[] = {
+ { "Restack", Test_RestackWindow },
+ { "Move", Test_MoveWindow },
+ { "Scale", Test_ScaleWindow },
+ { "SrcGeometry", Test_SrcGeometry },
+ { "DstGeometry", Test_DstGeometry },
+ { "Hide", Test_HideWindow },
+ { "Destroy", Test_DestroyWindow },
+};
+
+/**********************************************************************************************************************/
+
+static DFBResult RunTest( TestFunc func, const char *func_name, IDirectFBDisplayLayer *layer, void *arg );
+
+/**********************************************************************************************************************/
+
+static void ShowMessage( unsigned int ms, const char *name,
+ const char *prefix, const char *format, ... ) D_FORMAT_PRINTF(4);
+
+#define SHOW_TEST(msg...) ShowMessage( 2000, __FUNCTION__, \
+ "===============================================================\n\n", msg )
+#define SHOW_INFO(msg...) ShowMessage( 500, __FUNCTION__, "", msg )
+#define SHOW_RESULT(msg...) ShowMessage( 3000, __FUNCTION__, "", msg )
+
+/**********************************************************************************************************************/
+
+static bool parse_command_line( int argc, char *argv[] );
+
+/**********************************************************************************************************************/
+
+int
+main( int argc, char *argv[] )
+{
+ DFBResult ret;
+ int i;
+ IDirectFB *dfb;
+ IDirectFBDisplayLayer *layer;
+
+ /* Initialize DirectFB including command line parsing. */
+ ret = DirectFBInit( &argc, &argv );
+ if (ret) {
+ DirectFBError( "DirectFBInit() failed", ret );
+ return -1;
+ }
+
+ /* Parse the command line. */
+ if (!parse_command_line( argc, argv ))
+ return -2;
+
+ SHOW_INFO( "Starting up..." );
+
+ /* Create the super interface. */
+ ret = DirectFBCreate( &dfb );
+ if (ret) {
+ DirectFBError( "DirectFBCreate() failed", ret );
+ return -3;
+ }
+
+ /* Get the primary layer interface. */
+ ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer );
+ if (ret) {
+ D_DERROR( ret, "IDirectFB::GetDisplayLayer() failed!\n" );
+ dfb->Release( dfb );
+ return -4;
+ }
+
+
+ if (!m_toplevel_id)
+ RunTest( Test_CreateWindow, "CreateWindow", layer, NULL );
+
+ RunTest( Test_CreateSubWindow, "CreateSubWindow", layer, NULL );
+
+
+ for (i=0; i<D_ARRAY_SIZE(m_tests); i++) {
+ if (m_tests[i].run_top)
+ RunTest( m_tests[i].func, m_tests[i].name, layer, NULL );
+
+ if (m_tests[i].run_sub)
+ RunTest( m_tests[i].func, m_tests[i].name, layer, (void*) (unsigned long) m_subwindow_id );
+ }
+
+ if (m_wait_at_end) {
+ sigset_t block;
+
+ sigemptyset( &block );
+
+ sigsuspend( &block );
+ }
+
+ SHOW_INFO( "Shutting down..." );
+
+ /* Release the sub window. */
+ if (m_subwindow)
+ m_subwindow->Release( m_subwindow );
+
+ /* Release the top level. */
+ if (m_toplevel)
+ m_toplevel->Release( m_toplevel );
+
+ /* Release the layer. */
+ layer->Release( layer );
+
+ /* Release the super interface. */
+ dfb->Release( dfb );
+
+ return EXIT_SUCCESS;
+}
+
+/**********************************************************************************************************************/
+
+static void
+print_usage (const char *prg_name)
+{
+ int i = 0;
+
+ fprintf (stderr, "\n");
+ fprintf (stderr, "== DirectFB Window Test (version %s) ==\n", DIRECTFB_VERSION);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Known pixel formats:\n");
+
+ while (format_names[i].format != DSPF_UNKNOWN) {
+ DFBSurfacePixelFormat format = format_names[i].format;
+
+ fprintf (stderr, " %-10s %2d bits, %d bytes",
+ format_names[i].name, DFB_BITS_PER_PIXEL(format),
+ DFB_BYTES_PER_PIXEL(format));
+
+ if (DFB_PIXELFORMAT_HAS_ALPHA(format))
+ fprintf (stderr, " ALPHA");
+
+ if (DFB_PIXELFORMAT_IS_INDEXED(format))
+ fprintf (stderr, " INDEXED");
+
+ if (DFB_PLANAR_PIXELFORMAT(format)) {
+ int planes = DFB_PLANE_MULTIPLY(format, 1000);
+
+ fprintf (stderr, " PLANAR (x%d.%03d)",
+ planes / 1000, planes % 1000);
+ }
+
+ fprintf (stderr, "\n");
+
+ ++i;
+ }
+
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Known window capabilities:\n");
+
+ for (i=0; caps_names[i].capability != DWCAPS_NONE; i++)
+ fprintf (stderr, " %s\n", caps_names[i].name);
+
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Known window options:\n");
+
+ for (i=0; options_names[i].option != DWOP_NONE; i++)
+ fprintf (stderr, " %s\n", options_names[i].name);
+
+ fprintf (stderr, "\n");
+
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Usage: %s [options]\n", prg_name);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Options:\n");
+ fprintf (stderr, " -h, --help Show this help message\n");
+ fprintf (stderr, " -v, --version Print version information\n");
+ fprintf (stderr, " -T, --top-level <toplevel_id> WindowID (skips top creation)\n");
+ fprintf (stderr, " -W, --wait-at-end Wait at the end (don't exit)\n");
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Top window:\n");
+ fprintf (stderr, " -r, --run <test> Run test (see list below)\n");
+ fprintf (stderr, " -p, --pos <posx>,<posy> Position (%d,%d)\n", m_desc_top.posx, m_desc_top.posy);
+ fprintf (stderr, " -s, --size <width>x<height> Size (%dx%d)\n", m_desc_top.width, m_desc_top.height);
+ fprintf (stderr, " -f, --format <pixelformat> Pixel Format (%s)\n", dfb_pixelformat_name(m_desc_top.pixelformat));
+ fprintf (stderr, " -c, --caps <window_caps> Capabilities (NONE)\n");
+ fprintf (stderr, " -l, --color <aarrggbb> Fixed Color (NONE)\n");
+ fprintf (stderr, " -o, --option <window_option> Options (NONE)\n");
+ fprintf (stderr, " -a, --associate <parent_id> Association (N/A)\n");
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Sub window:\n");
+ fprintf (stderr, " -R, --sub-run <test> Run test (see list below)\n");
+ fprintf (stderr, " -P, --sub-pos <posx>,<posy> Position (%d,%d)\n", m_desc_sub.posx, m_desc_sub.posy);
+ fprintf (stderr, " -S, --sub-size <width>x<height> Size (%dx%d)\n", m_desc_sub.width, m_desc_sub.height);
+ fprintf (stderr, " -F, --sub-format <pixelformat> Format (%s)\n", dfb_pixelformat_name(m_desc_sub.pixelformat));
+ fprintf (stderr, " -C, --sub-caps <window_caps> Capabilities (NONE)\n");
+ fprintf (stderr, " -L, --sub-color <aarrggbb> Fixed Color (NONE)\n");
+ fprintf (stderr, " -O, --sub-option <window_option> Options (NONE)\n");
+ fprintf (stderr, " -A, --sub-associate <parent_id> Association (N/A)\n");
+ fprintf (stderr, "\n");
+
+ fprintf (stderr, "Available tests:\n");
+
+ for (i=0; i<D_ARRAY_SIZE(m_tests); i++)
+ fprintf (stderr, " %s\n", m_tests[i].name);
+
+ fprintf (stderr, "\n");
+}
+
+static DFBBoolean
+parse_test( const char *arg, bool sub )
+{
+ int i;
+
+ for (i=0; i<D_ARRAY_SIZE(m_tests); i++) {
+ if (!strncasecmp( arg, m_tests[i].name, strlen(arg) )) {
+ if (sub)
+ m_tests[i].run_sub = true;
+ else
+ m_tests[i].run_top = true;
+
+ return DFB_TRUE;
+ }
+ }
+
+ fprintf (stderr, "\nInvalid test specified!\n\n" );
+
+ return DFB_FALSE;
+}
+
+static DFBBoolean
+parse_position( const char *arg, int *_x, int *_y )
+{
+ if (sscanf( arg, "%d,%d", _x, _y ) != 2) {
+ fprintf (stderr, "\nInvalid position specified!\n\n" );
+ return DFB_FALSE;
+ }
+
+ return DFB_TRUE;
+}
+
+static DFBBoolean
+parse_size( const char *arg, int *_w, int *_h )
+{
+ if (sscanf( arg, "%dx%d", _w, _h ) != 2 || *_w < 1 || *_h < 1) {
+ fprintf (stderr, "\nInvalid size specified!\n\n" );
+ return DFB_FALSE;
+ }
+
+ return DFB_TRUE;
+}
+
+static DFBBoolean
+parse_format( const char *arg, DFBSurfacePixelFormat *_f )
+{
+ int i = 0;
+
+ while (format_names[i].format != DSPF_UNKNOWN) {
+ if (!strcasecmp( arg, format_names[i].name )) {
+ *_f = format_names[i].format;
+ return DFB_TRUE;
+ }
+
+ ++i;
+ }
+
+ fprintf (stderr, "\nInvalid format specified!\n\n" );
+
+ return DFB_FALSE;
+}
+
+static DFBBoolean
+parse_caps( const char *arg, DFBWindowCapabilities *_c )
+{
+ int i = 0;
+
+ while (caps_names[i].capability != DWCAPS_NONE) {
+ if (!strncasecmp( arg, caps_names[i].name, strlen(arg) )) {
+ *_c |= caps_names[i].capability;
+ return DFB_TRUE;
+ }
+
+ ++i;
+ }
+
+ fprintf (stderr, "\nInvalid caps specified!\n\n" );
+
+ return DFB_FALSE;
+}
+
+static DFBBoolean
+parse_color( const char *arg, DFBColor *_c )
+{
+ long int l = 0;
+ char *end = 0;
+ DFBColor c;
+
+ l = strtol( arg, &end, 16 );
+
+ if( strlen(arg)>8 || (end && *end!=0) ) {
+ fprintf (stderr, "\nInvalid color specified!\n\n" );
+ return DFB_FALSE;
+ }
+
+ c.a = (l >> 24) ;
+ c.r = (l >> 16) & 0xff;
+ c.g = (l >> 8) & 0xff;
+ c.b = (l ) & 0xff;
+
+ *_c = c;
+
+ return DFB_TRUE;
+}
+
+static DFBBoolean
+parse_option( const char *arg, DFBWindowOptions *_o )
+{
+ int i = 0;
+
+ while (options_names[i].option != DWOP_NONE) {
+ if (!strncasecmp( arg, options_names[i].name, strlen(arg) )) {
+ *_o |= options_names[i].option;
+ return DFB_TRUE;
+ }
+
+ ++i;
+ }
+
+ fprintf (stderr, "\nInvalid options specified!\n\n" );
+
+ return DFB_FALSE;
+}
+
+static DFBBoolean
+parse_id( const char *arg, unsigned int *_id )
+{
+ if (sscanf( arg, "%u", _id ) != 1) {
+ fprintf (stderr, "\nInvalid ID specified!\n\n" );
+ return DFB_FALSE;
+ }
+
+ return DFB_TRUE;
+}
+
+static bool
+parse_command_line( int argc, char *argv[] )
+{
+ int n;
+
+ for (n = 1; n < argc; n++) {
+ const char *arg = argv[n];
+
+ if (strcmp (arg, "-h") == 0 || strcmp (arg, "--help") == 0) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
+ fprintf (stderr, "dfbg version %s\n", DIRECTFB_VERSION);
+ return false;
+ }
+
+ if (strcmp (arg, "-T") == 0 || strcmp (arg, "--top-level") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_id( argv[n], &m_toplevel_id ))
+ return false;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-W") == 0 || strcmp (arg, "--wait-at-end") == 0) {
+ m_wait_at_end = DFB_TRUE;
+ continue;
+ }
+
+ if (strcmp (arg, "-r") == 0 || strcmp (arg, "--run") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_test( argv[n], false ))
+ return false;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-p") == 0 || strcmp (arg, "--pos") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_position( argv[n], &m_desc_top.posx, &m_desc_top.posy ))
+ return false;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-s") == 0 || strcmp (arg, "--size") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_size( argv[n], &m_desc_top.width, &m_desc_top.height ))
+ return false;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-f") == 0 || strcmp (arg, "--format") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_format( argv[n], &m_desc_top.pixelformat ))
+ return false;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-c") == 0 || strcmp (arg, "--caps") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_caps( argv[n], &m_desc_top.caps ))
+ return false;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-l") == 0 || strcmp (arg, "--color") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_color( argv[n], &m_topcolor ))
+ return false;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-o") == 0 || strcmp (arg, "--option") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_option( argv[n], &m_desc_top.options ))
+ return false;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-a") == 0 || strcmp (arg, "--associate") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_id( argv[n], &m_desc_top.parent_id ))
+ return false;
+
+// m_desc_top.flags |= DWDESC_PARENT;
+ m_desc_top.options |= DWOP_FOLLOW_BOUNDS;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-R") == 0 || strcmp (arg, "--sub-run") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_test( argv[n], true ))
+ return false;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-P") == 0 || strcmp (arg, "--sub-pos") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_position( argv[n], &m_desc_sub.posx, &m_desc_sub.posy ))
+ return false;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-S") == 0 || strcmp (arg, "--sub-size") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_size( argv[n], &m_desc_sub.width, &m_desc_sub.height ))
+ return false;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-F") == 0 || strcmp (arg, "--sub-format") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_format( argv[n], &m_desc_sub.pixelformat ))
+ return false;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-C") == 0 || strcmp (arg, "--sub-caps") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_caps( argv[n], &m_desc_sub.caps ))
+ return false;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-L") == 0 || strcmp (arg, "--sub-color") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_color( argv[n], &m_subcolor ))
+ return false;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-O") == 0 || strcmp (arg, "--sub-option") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_option( argv[n], &m_desc_sub.options ))
+ return false;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-A") == 0 || strcmp (arg, "--sub-associate") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_id( argv[n], &m_desc_sub.parent_id ))
+ return false;
+
+// m_desc_sub.flags |= DWDESC_PARENT;
+ m_desc_sub.options |= DWOP_FOLLOW_BOUNDS;
+
+ continue;
+ }
+
+ print_usage (argv[0]);
+
+ return false;
+ }
+
+ return true;
+}
+
+/**********************************************************************************************************************/
+
+static DFBResult
+RunTest( TestFunc func,
+ const char *test_name,
+ IDirectFBDisplayLayer *layer,
+ void *arg )
+{
+ DFBResult ret;
+
+ /* Run the actual test... */
+ ret = func( layer, arg );
+ if (ret)
+ D_DERROR( ret, "RunTest: '%s' failed!\n", test_name );
+
+ return ret;
+}
+
+/**********************************************************************************************************************/
+
+static void
+ShowMessage( unsigned int ms, const char *name, const char *prefix, const char *format, ... )
+{
+ char buf[512];
+
+ va_list ap;
+
+ va_start( ap, format );
+
+ vsnprintf( buf, sizeof(buf), format, ap );
+
+ va_end( ap );
+
+ direct_log_printf( NULL, "%s [[ %-30s ]] %s\n", prefix, name, buf );
+
+ usleep( ms * 1000 );
+}
+
+/**********************************************************************************************************************/
+
+#define _T(x...) \
+ do { \
+ DFBResult ret = x; \
+ \
+ if (ret) { \
+ D_DERROR( ret, "Tests/Window: '%s' failed!\n", #x ); \
+ return ret; \
+ } \
+ } while (0)
+
+/**********************************************************************************************************************/
+
+static DFBResult
+Test_CreateWindow( IDirectFBDisplayLayer *layer, void *arg )
+{
+ IDirectFBSurface *surface = NULL;
+ IDirectFBWindow *window;
+ DFBWindowID window_id;
+ DFBDimension size = { m_desc_top.width, m_desc_top.height };
+
+ D_ASSERT( m_toplevel_id == 0 );
+
+ /*
+ * Create a new top level window
+ */
+ SHOW_TEST( "CreateWindow( %d,%d - %dx%d %s )...",
+ m_desc_top.posx, m_desc_top.posy, m_desc_top.width, m_desc_top.height,
+ dfb_pixelformat_name( m_desc_top.pixelformat ) );
+
+ _T( layer->CreateWindow( layer, &m_desc_top, &window ) );
+
+ if (m_desc_top.caps & DWCAPS_COLOR) {
+ DFBColor c = m_topcolor;
+
+ SHOW_INFO( " - SetColor( 0x%02x, 0x%02x, 0x%02x, 0x%02x )...", c.r, c.g, c.b, c.a );
+
+ _T( window->SetColor( window, c.r, c.g, c.b, c.a ) );
+ }
+
+ /*
+ * Query its surface and clear it with light blue (if not input or color only)
+ */
+ if (!(m_desc_top.caps & (DWCAPS_INPUTONLY | DWCAPS_COLOR) )) {
+ SHOW_INFO( " - GetSurface()..." );
+
+ _T( window->GetSurface( window, &surface ) );
+
+ SHOW_INFO( " - Clear( 0x20, 0x50, 0xC0, 0xFF )..." );
+
+ _T( surface->Clear( surface, 0x20, 0x50, 0xC0, 0xFF ) );
+
+ _T( surface->SetColor( surface, 0x90, 0xF0, 0xC0, 0xFF ) );
+
+ _T( surface->DrawRectangle( surface, 0, 0, size.w, size.h ) );
+
+ _T( surface->FillRectangle( surface, size.w / 2, 1, 1, size.h - 2 ) );
+ _T( surface->FillRectangle( surface, 1, size.h / 2, size.w - 2, 1 ) );
+ }
+
+ /*
+ * Show the window
+ */
+ SHOW_INFO( " - SetOpacity( 255 )..." );
+
+ _T( window->SetOpacity( window, 0xff ) );
+
+ /*
+ * Query and print ID of new window
+ */
+ SHOW_INFO( " - GetID()..." );
+
+ _T( window->GetID( window, &window_id ) );
+
+ /*
+ * Set association of new window
+ */
+ if (m_desc_top.parent_id) {
+ SHOW_INFO( " - SetAssociation( %u )...", m_desc_top.parent_id );
+
+ _T( window->SetAssociation( window, m_desc_top.parent_id ) );
+ }
+
+ /*
+ * Set top level window ID (user hasn't specified one)
+ */
+ m_toplevel_id = window_id;
+ m_toplevel = window;
+
+ SHOW_RESULT( "...CreateWindow( %d,%d - %dx%d %s ) done. => Top Window ID %u",
+ m_desc_top.posx, m_desc_top.posy, m_desc_top.width, m_desc_top.height,
+ dfb_pixelformat_name( m_desc_top.pixelformat ), window_id );
+
+ if (surface)
+ surface->Release( surface );
+
+ return DFB_OK;
+}
+
+static DFBResult
+Test_CreateSubWindow( IDirectFBDisplayLayer *layer, void *arg )
+{
+ IDirectFBWindow *window;
+ DFBWindowID window_id;
+ DFBDimension size = { m_desc_sub.width, m_desc_sub.height };
+
+ D_ASSERT( m_toplevel_id != 0 );
+
+ /* Write window ID of top level into description */
+ m_desc_sub.toplevel_id = m_toplevel_id;
+
+ /*
+ * Create a new sub window with 75% width/height and positioned at 20,20 within top level window
+ */
+ SHOW_TEST( "CreateWindow( %d,%d - %dx%d %s + toplevel ID %u )...",
+ m_desc_sub.posx, m_desc_sub.posy, m_desc_sub.width, m_desc_sub.height,
+ dfb_pixelformat_name( m_desc_sub.pixelformat ), m_desc_sub.toplevel_id );
+
+ _T( layer->CreateWindow( layer, &m_desc_sub, &window ) );
+
+ if (m_desc_sub.caps & DWCAPS_COLOR) {
+ DFBColor c = m_subcolor;
+
+ SHOW_INFO( " - SetColor( 0x%02x, 0x%02x, 0x%02x, 0x%02x )...", c.r, c.g, c.b, c.a );
+
+ _T( window->SetColor( window, c.r, c.g, c.b, c.a ) );
+ }
+
+ /*
+ * Query its surface and clear it with light gray (if not input or color only)
+ */
+ if (!(m_desc_sub.caps & (DWCAPS_INPUTONLY | DWCAPS_COLOR) )) {
+ IDirectFBSurface *surface;
+
+ SHOW_INFO( " - GetSurface()..." );
+
+ _T( window->GetSurface( window, &surface ) );
+
+ SHOW_INFO( " - Clear( 0xC0, 0xC0, 0xC0, 0xFF )..." );
+
+ _T( surface->Clear( surface, 0xC0, 0xC0, 0xC0, 0xFF ) );
+
+ _T( surface->DrawRectangle( surface, 0, 0, size.w, size.h ) );
+
+ _T( surface->FillRectangle( surface, size.w / 2, 1, 1, size.h - 2 ) );
+ _T( surface->FillRectangle( surface, 1, size.h / 2, size.w - 2, 1 ) );
+
+ surface->Release( surface );
+ }
+
+ /*
+ * Show the window
+ */
+ SHOW_INFO( " - SetOpacity( 255 )..." );
+
+ _T( window->SetOpacity( window, 0xff ) );
+
+ /*
+ * Query and print ID of new window
+ */
+ SHOW_INFO( " - GetID()..." );
+
+ _T( window->GetID( window, &window_id ) );
+
+ /*
+ * Set association of new window
+ */
+ if (m_desc_sub.parent_id) {
+ SHOW_INFO( " - SetAssociation( %u )...", m_desc_sub.parent_id );
+
+ _T( window->SetAssociation( window, m_desc_sub.parent_id ) );
+ }
+
+ /*
+ * Set top level window ID (user hasn't specified one)
+ */
+ m_subwindow_id = window_id;
+ m_subwindow = window;
+
+ SHOW_RESULT( "...CreateWindow( %d,%d - %dx%d %s + toplevel ID %u ) done. => Sub Window ID %u",
+ m_desc_sub.posx, m_desc_sub.posy, m_desc_sub.width, m_desc_sub.height,
+ dfb_pixelformat_name( m_desc_sub.pixelformat ), m_desc_sub.toplevel_id, window_id );
+
+ return DFB_OK;
+}
+
+static DFBResult
+Test_MoveWindow( IDirectFBDisplayLayer *layer, void *arg )
+{
+ int i;
+ DFBPoint pos;
+ IDirectFBWindow *window;
+
+ D_ASSERT( m_toplevel_id != 0 );
+
+ /*
+ * Get the top level window
+ */
+ _T( layer->GetWindow( layer, arg ? (unsigned long) arg : m_toplevel_id, &window ) );
+
+ window->GetPosition( window, &pos.x, &pos.y );
+
+ /*
+ * Move the window
+ */
+ {
+ DFBPoint poss[] = { { pos.x - 40, pos.y - 40 },
+ { pos.x + 40, pos.y - 40 },
+ { pos.x + 40, pos.y + 40 },
+ { pos.x - 40, pos.y + 40 },
+ { pos.x , pos.y } };
+
+ for (i=0; i<D_ARRAY_SIZE(poss); i++) {
+ SHOW_TEST( "MoveTo( %4d,%4d - [%02d] )...", poss[i].x, poss[i].y, i );
+
+ _T( window->MoveTo( window, poss[i].x, poss[i].y ) );
+
+ SHOW_RESULT( "...MoveTo( %4d,%4d - [%02d] ) done.", poss[i].x, poss[i].y, i );
+ }
+ }
+
+ window->Release( window );
+
+ return DFB_OK;
+}
+
+static DFBResult
+Test_ScaleWindow( IDirectFBDisplayLayer *layer, void *arg )
+{
+ int i;
+ IDirectFBWindow *window;
+ DFBWindowOptions opts;
+ DFBDimension size;
+
+ D_ASSERT( m_toplevel_id != 0 );
+
+ /*
+ * Get the top level window
+ */
+ _T( layer->GetWindow( layer, arg ? (unsigned long) arg : m_toplevel_id, &window ) );
+
+ window->GetSize( window, &size.w, &size.h );
+
+ /*
+ * Enable scaling
+ */
+ _T( window->GetOptions( window, &opts ) );
+ _T( window->SetOptions( window, opts | DWOP_SCALE ) );
+
+ /*
+ * Scale the window
+ */
+ {
+ DFBDimension sizes[] = { { size.w + 40, size.h },
+ { size.w + 40, size.h + 40 },
+ { size.w, size.h + 40 },
+ { size.w + 40, size.h - 40 },
+ { size.w - 40, size.h + 40 },
+ { size.w, size.h } };
+
+ for (i=0; i<D_ARRAY_SIZE(sizes); i++) {
+ SHOW_TEST( "Resize( %4d,%4d - [%02d] )...", sizes[i].w, sizes[i].h, i );
+
+ _T( window->Resize( window, sizes[i].w, sizes[i].h ) );
+
+ SHOW_RESULT( "...Resize( %4d,%4d - [%02d] ) done.", sizes[i].w, sizes[i].h, i );
+ }
+ }
+
+ /*
+ * Restore options
+ */
+ _T( window->SetOptions( window, opts ) );
+
+ window->Release( window );
+
+ return DFB_OK;
+}
+
+static DFBResult
+Test_RestackWindow( IDirectFBDisplayLayer *layer, void *arg )
+{
+ int i;
+ IDirectFBWindow *window;
+
+ D_ASSERT( m_toplevel_id != 0 );
+
+ /*
+ * Get the top level window
+ */
+ _T( layer->GetWindow( layer, arg ? (unsigned long) arg : m_toplevel_id, &window ) );
+
+ /*
+ * Lower it a few times
+ */
+ for (i=0; i<2; i++) {
+ SHOW_TEST( "Lower() #%d...", i+1 );
+
+ _T( window->Lower( window ) );
+
+ SHOW_RESULT( "...Lower() #%d done.", i+1 );
+ }
+
+ /*
+ * Raise it a few times
+ */
+ for (i=0; i<2; i++) {
+ SHOW_TEST( "Raise() #%d...", i+1 );
+
+ _T( window->Raise( window ) );
+
+ SHOW_RESULT( "...Raise() #%d done.", i+1 );
+ }
+
+ /*
+ * Lower it to the bottom
+ */
+ SHOW_TEST( "LowerToBottom()..." );
+
+ _T( window->LowerToBottom( window ) );
+
+ SHOW_RESULT( "...LowerToBottom() done." );
+
+ /*
+ * Raise it to the top
+ */
+ SHOW_TEST( "RaiseToTop()..." );
+
+ _T( window->RaiseToTop( window ) );
+
+ SHOW_RESULT( "...RaiseToTop() done." );
+
+
+ window->Release( window );
+
+ return DFB_OK;
+}
+
+static DFBResult
+Test_SrcGeometry( IDirectFBDisplayLayer *layer, void *arg )
+{
+ int i;
+ IDirectFBWindow *window;
+ DFBWindowGeometry geometry;
+ DFBDimension size;
+
+ D_ASSERT( m_toplevel_id != 0 );
+
+ /*
+ * Get the top level window
+ */
+ _T( layer->GetWindow( layer, arg ? (unsigned long) arg : m_toplevel_id, &window ) );
+
+ window->GetSize( window, &size.w, &size.h );
+
+ /*
+ * Change source geometry
+ */
+ {
+ DFBRectangle rects[] = { { 0, 0, size.w / 2, size.h / 2 },
+ { size.w / 2, 0, size.w / 2, size.h / 2 },
+ { size.w / 2, size.h / 2, size.w / 2, size.h / 2 },
+ { 0, size.h / 2, size.w / 2, size.h / 2 } };
+
+ for (i=0; i<D_ARRAY_SIZE(rects); i++) {
+ SHOW_TEST( "SetSrcGeometry( %4d,%4d-%4dx%4d - [%02d] )...", DFB_RECTANGLE_VALS(&rects[i]), i );
+
+ geometry.mode = DWGM_RECTANGLE;
+ geometry.rectangle = rects[i];
+
+ _T( window->SetSrcGeometry( window, &geometry ) );
+
+ SHOW_RESULT( "...SetSrcGeometry( %4d,%4d-%4dx%4d - [%02d] ) done.", DFB_RECTANGLE_VALS(&rects[i]), i );
+ }
+ }
+
+
+ SHOW_TEST( "SetSrcGeometry( DEFAULT )..." );
+
+ geometry.mode = DWGM_DEFAULT;
+
+ _T( window->SetSrcGeometry( window, &geometry ) );
+
+ SHOW_RESULT( "...SetSrcGeometry( DEFAULT ) done." );
+
+
+ window->Release( window );
+
+ return DFB_OK;
+}
+
+static DFBResult
+Test_DstGeometry( IDirectFBDisplayLayer *layer, void *arg )
+{
+ int i;
+ IDirectFBWindow *window;
+ DFBWindowGeometry geometry;
+ DFBDimension size;
+
+ D_ASSERT( m_toplevel_id != 0 );
+
+ /*
+ * Get the top level window
+ */
+ _T( layer->GetWindow( layer, arg ? (unsigned long) arg : m_toplevel_id, &window ) );
+
+ window->GetSize( window, &size.w, &size.h );
+
+ /*
+ * Change destination geometry
+ */
+ {
+ DFBRectangle rects[] = { { 0, 0, size.w / 2, size.h / 2 },
+ { size.w / 2, 0, size.w / 2, size.h / 2 },
+ { size.w / 2, size.h / 2, size.w / 2, size.h / 2 },
+ { 0, size.h / 2, size.w / 2, size.h / 2 } };
+
+ for (i=0; i<D_ARRAY_SIZE(rects); i++) {
+ SHOW_TEST( "SetDstGeometry( %4d,%4d-%4dx%4d - [%02d] )...", DFB_RECTANGLE_VALS(&rects[i]), i );
+
+ geometry.mode = DWGM_RECTANGLE;
+ geometry.rectangle = rects[i];
+
+ _T( window->SetDstGeometry( window, &geometry ) );
+
+ SHOW_RESULT( "...SetDstGeometry( %4d,%4d-%4dx%4d - [%02d] ) done.", DFB_RECTANGLE_VALS(&rects[i]), i );
+ }
+ }
+
+
+ SHOW_TEST( "SetDstGeometry( DEFAULT )..." );
+
+ geometry.mode = DWGM_DEFAULT;
+
+ _T( window->SetDstGeometry( window, &geometry ) );
+
+ SHOW_RESULT( "...SetDstGeometry( DEFAULT ) done." );
+
+
+ window->Release( window );
+
+ return DFB_OK;
+}
+
+static DFBResult
+Test_HideWindow( IDirectFBDisplayLayer *layer, void *arg )
+{
+ IDirectFBWindow *window;
+
+ D_ASSERT( m_toplevel_id != 0 );
+
+ /*
+ * Get the top level window
+ */
+ _T( layer->GetWindow( layer, arg ? (unsigned long) arg : m_toplevel_id, &window ) );
+
+ /*
+ * Hide it
+ */
+ SHOW_TEST( "SetOpacity( 0 )..." );
+
+ _T( window->SetOpacity( window, 0 ) );
+
+ SHOW_RESULT( "...SetOpacity( 0 ) done." );
+
+ /*
+ * Show it again
+ */
+ SHOW_TEST( "SetOpacity( 0xff )..." );
+
+ _T( window->SetOpacity( window, 0xff ) );
+
+ SHOW_RESULT( "...SetOpacity( 0xff ) done." );
+
+ window->Release( window );
+
+ return DFB_OK;
+}
+
+static DFBResult
+Test_DestroyWindow( IDirectFBDisplayLayer *layer, void *arg )
+{
+ IDirectFBWindow *window;
+
+ D_ASSERT( m_toplevel_id != 0 );
+
+ /*
+ * Get the top level window
+ */
+ _T( layer->GetWindow( layer, arg ? (unsigned long) arg : m_toplevel_id, &window ) );
+
+ /*
+ * Destroy it
+ */
+ SHOW_TEST( "Destroy()..." );
+
+ _T( window->Destroy( window ) );
+
+ SHOW_RESULT( "...Destroy() done." );
+
+ window->Release( window );
+
+ return DFB_OK;
+}
+
diff --git a/Source/DirectFB/tests/dfbtest_windows_watcher.c b/Source/DirectFB/tests/dfbtest_windows_watcher.c
new file mode 100755
index 0000000..89bb140
--- /dev/null
+++ b/Source/DirectFB/tests/dfbtest_windows_watcher.c
@@ -0,0 +1,227 @@
+/*
+ (c) Copyright 2001-2009 The DirectFB Organization (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This file is subject to the terms and conditions of the MIT License:
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+//#define DIRECT_ENABLE_DEBUG
+
+#include <config.h>
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <direct/messages.h>
+#include <direct/util.h>
+
+#include <directfb.h>
+#include <directfb_strings.h>
+#include <directfb_util.h>
+#include <directfb_windows.h>
+
+static const DirectFBPixelFormatNames( format_names );
+static const DirectFBWindowCapabilitiesNames( caps_names );
+static const DirectFBWindowOptionsNames( options_names );
+
+/**********************************************************************************************************************/
+
+static bool parse_command_line( int argc, char *argv[] );
+
+/**********************************************************************************************************************/
+
+static void
+dump_config( const DFBWindowConfig *config )
+{
+ D_INFO( " -> bounds %d,%d-%dx%d\n", DFB_RECTANGLE_VALS( &config->bounds ) );
+ D_INFO( " -> opacity %d\n", config->opacity );
+}
+
+/**********************************************************************************************************************/
+
+static void
+Test_Watcher_WindowAdd( void *context,
+ const DFBWindowInfo *info )
+{
+ D_INFO( "%s( ID %u )\n", __FUNCTION__, info->window_id );
+ D_INFO( " -> caps 0x%08x\n", info->caps );
+ D_INFO( " -> resource id 0x%016llx\n", (unsigned long long) info->resource_id );
+
+ dump_config( &info->config );
+}
+
+static void
+Test_Watcher_WindowRemove( void *context,
+ DFBWindowID window_id )
+{
+ D_INFO( "%s( ID %u )\n", __FUNCTION__, window_id );
+}
+
+static void
+Test_Watcher_WindowConfig( void *context,
+ DFBWindowID window_id,
+ const DFBWindowConfig *config,
+ DFBWindowConfigFlags flags )
+{
+ D_INFO( "%s( ID %u )\n", __FUNCTION__, window_id );
+ D_INFO( " -> flags 0x%08x\n", flags );
+
+ dump_config( config );
+}
+
+static void
+Test_Watcher_WindowState( void *context,
+ DFBWindowID window_id,
+ const DFBWindowState *state )
+{
+ D_INFO( "%s( ID %u )\n", __FUNCTION__, window_id );
+ D_INFO( " -> flags 0x%08x\n", state->flags );
+}
+
+static void
+Test_Watcher_WindowRestack( void *context,
+ DFBWindowID window_id,
+ unsigned int index )
+{
+ D_INFO( "%s( ID %u )\n", __FUNCTION__, window_id );
+ D_INFO( " -> index %u\n", index );
+}
+
+static void
+Test_Watcher_WindowFocus( void *context,
+ DFBWindowID window_id )
+{
+ D_INFO( "%s( ID %u )\n", __FUNCTION__, window_id );
+}
+
+static DFBWindowsWatcher watcher = {
+ .WindowAdd = Test_Watcher_WindowAdd,
+ .WindowRemove = Test_Watcher_WindowRemove,
+ .WindowConfig = Test_Watcher_WindowConfig,
+ .WindowState = Test_Watcher_WindowState,
+ .WindowRestack = Test_Watcher_WindowRestack,
+ .WindowFocus = Test_Watcher_WindowFocus,
+};
+
+/**********************************************************************************************************************/
+
+int
+main( int argc, char *argv[] )
+{
+ DFBResult ret;
+ IDirectFB *dfb;
+ IDirectFBWindows *windows;
+
+ /* Initialize DirectFB including command line parsing. */
+ ret = DirectFBInit( &argc, &argv );
+ if (ret) {
+ DirectFBError( "DirectFBInit() failed", ret );
+ return -1;
+ }
+
+ /* Parse the command line. */
+ if (!parse_command_line( argc, argv ))
+ return -2;
+
+ /* Create the super interface. */
+ ret = DirectFBCreate( &dfb );
+ if (ret) {
+ DirectFBError( "DirectFBCreate() failed", ret );
+ return -3;
+ }
+
+ ret = dfb->GetInterface( dfb, "IDirectFBWindows", NULL, NULL, (void**) &windows );
+ if (ret) {
+ D_DERROR( ret, "IDirectFB::GetInterface( 'IDirectFBWindows' ) failed!\n" );
+ return -4;
+ }
+
+ ret = windows->RegisterWatcher( windows, &watcher, NULL );
+ if (ret) {
+ D_DERROR( ret, "IDirectFBWindows::RegisterWatcher() failed!\n" );
+ return -5;
+ }
+
+ pause();
+
+ /* Release the windows interface. */
+ windows->Release( windows );
+
+ /* Release the super interface. */
+ dfb->Release( dfb );
+
+ return EXIT_SUCCESS;
+}
+
+/**********************************************************************************************************************/
+
+static void
+print_usage (const char *prg_name)
+{
+ fprintf (stderr, "\n");
+ fprintf (stderr, "== DirectFB Windows Watcher Test (version %s) ==\n", DIRECTFB_VERSION);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Usage: %s [options]\n", prg_name);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Options:\n");
+ fprintf (stderr, " -h, --help Show this help message\n");
+ fprintf (stderr, " -v, --version Print version information\n");
+ fprintf (stderr, "\n");
+}
+
+static bool
+parse_command_line( int argc, char *argv[] )
+{
+ int n;
+
+ for (n = 1; n < argc; n++) {
+ const char *arg = argv[n];
+
+ if (strcmp (arg, "-h") == 0 || strcmp (arg, "--help") == 0) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
+ fprintf (stderr, "dfbg version %s\n", DIRECTFB_VERSION);
+ return false;
+ }
+
+ print_usage (argv[0]);
+
+ return false;
+ }
+
+ return true;
+}
+
diff --git a/Source/DirectFB/tests/dfbtest_write.c b/Source/DirectFB/tests/dfbtest_write.c
new file mode 100755
index 0000000..c43f4be
--- /dev/null
+++ b/Source/DirectFB/tests/dfbtest_write.c
@@ -0,0 +1,162 @@
+/*
+ (c) Copyright 2008 Denis Oliver Kropp
+
+ All rights reserved.
+
+ This file is subject to the terms and conditions of the MIT License:
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <direct/messages.h>
+
+#include <directfb.h>
+#include <directfb_util.h>
+
+
+static void
+write_data( void *ptr,
+ int size )
+{
+ int i;
+ u16 *p = ptr;
+
+ for (i=0; i<size/2; i++) {
+ p[i] = i%64;
+ }
+}
+
+int
+main( int argc, char *argv[] )
+{
+ DFBResult ret;
+ int w;
+ IDirectFB *dfb;
+
+ /* Initialize DirectFB. */
+ ret = DirectFBInit( &argc, &argv );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Write: DirectFBInit() failed!\n" );
+ return ret;
+ }
+
+ /* Create super interface. */
+ ret = DirectFBCreate( &dfb );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Write: DirectFBCreate() failed!\n" );
+ return ret;
+ }
+
+ IDirectFBDisplayLayer *layer;
+ IDirectFBWindow *window;
+ IDirectFBSurface *dest;
+ IDirectFBSurface *temp;
+
+ dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer );
+
+ /* Fill description for a primary surface. */
+ DFBSurfaceDescription sdesc;
+ sdesc.flags = DSDESC_CAPS | DSDESC_RESOURCE_ID;
+ sdesc.caps = DSCAPS_VIDEOONLY;
+ sdesc.resource_id = 1100;
+
+ sdesc.flags |= DSDESC_PIXELFORMAT;
+ sdesc.pixelformat = DSPF_ARGB;
+
+ sdesc.flags |= DSDESC_WIDTH | DSDESC_HEIGHT;
+ sdesc.width = 320;
+ sdesc.height = 200;
+
+ /* Create a primary surface. */
+ ret = dfb->CreateSurface( dfb, &sdesc, &temp );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Write: IDirectFB::CreateSurface() failed!\n" );
+ return ret;
+ }
+
+
+ DFBWindowDescription desc;
+
+ desc.flags = DWDESC_RESOURCE_ID;
+ desc.resource_id = 1100;
+
+ desc.flags |= DWDESC_PIXELFORMAT;
+ desc.pixelformat = DSPF_ARGB;
+
+ desc.flags |= DWDESC_WIDTH | DWDESC_HEIGHT;
+ desc.width = 320;
+ desc.height = 200;
+
+ /* Create a primary surface. */
+ ret = layer->CreateWindow( layer, &desc, &window );
+ if (ret) {
+ D_DERROR( ret, "DFBTest/Write: IDirectFB::CreateWindow() failed!\n" );
+ return ret;
+ }
+
+ window->GetSurface( window, &dest );
+
+ window->SetOpacity( window, 0xff );
+
+ dest->GetSize( dest, &desc.width, &desc.height );
+ dest->GetPixelFormat( dest, &desc.pixelformat );
+
+ D_INFO( "DFBTest/Write: Destination is %dx%d using %s\n",
+ desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );
+
+
+ int pitch = DFB_BYTES_PER_LINE( desc.pixelformat, desc.width );
+ void *buf = malloc( pitch * desc.height );
+
+ for (w=0; w<10; w++) {
+ memset( buf, w * 0x55, pitch * desc.height );
+
+
+ DFBRectangle rect = { 0, 0, desc.width, desc.height };
+
+ temp->Write( temp, &rect, buf, pitch );
+
+ dest->SetBlittingFlags( dest, DSBLIT_BLEND_ALPHACHANNEL );
+ dest->Blit( dest, temp, NULL, 0, 0 );
+ dest->Blit( dest, temp, NULL, 0, 0 );
+ dest->Blit( dest, temp, NULL, 0, 0 );
+ dest->Blit( dest, temp, NULL, 0, 0 );
+ dest->Flip( dest, NULL, DSFLIP_NONE );
+
+ dfb->WaitIdle( dfb );
+
+// sleep( 1 );
+ }
+
+ temp->Release( temp );
+ dest->Release( dest );
+
+ /* Shutdown DirectFB. */
+ dfb->Release( dfb );
+
+ return ret;
+}
+
diff --git a/Source/DirectFB/tests/direct_stream.c b/Source/DirectFB/tests/direct_stream.c
new file mode 100755
index 0000000..ca66f00
--- /dev/null
+++ b/Source/DirectFB/tests/direct_stream.c
@@ -0,0 +1,139 @@
+/*
+ (c) Copyright 2008 Denis Oliver Kropp
+
+ All rights reserved.
+
+ This file is subject to the terms and conditions of the MIT License:
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <config.h>
+
+#include <string.h>
+#include <unistd.h>
+
+#include <direct/debug.h>
+#include <direct/direct.h>
+#include <direct/messages.h>
+#include <direct/stream.h>
+#include <direct/util.h>
+
+
+D_DEBUG_DOMAIN( Direct_Cat, "Direct/Cat", "libdirect cat" );
+
+
+static int
+show_usage( const char *prg )
+{
+ fprintf( stderr, "Usage: %s <url>\n", prg );
+
+ return -1;
+}
+
+int
+main( int argc, char *argv[] )
+{
+ DirectResult ret;
+ int i, fdo;
+ DirectStream *stream;
+ const char *url = NULL;
+
+ /* Parse arguments. */
+ for (i=1; i<argc; i++) {
+ if (!strcmp( argv[i], "-h" ))
+ return show_usage( argv[0] );
+ else if (!url)
+ url = argv[i];
+ else
+ return show_usage( argv[0] );
+ }
+
+ /* Check if we got an URL. */
+ if (!url)
+ return show_usage( argv[0] );
+
+ /* Initialize libdirect. */
+ direct_initialize();
+
+ D_INFO( "Direct/Cat: Start from '%s'...\n", url );
+
+ /* Open input. */
+ ret = direct_stream_create( url, &stream );
+ if (ret) {
+ D_DERROR( ret, "Direct/Cat: Opening '%s' failed!\n", url );
+ goto out;
+ }
+
+ /* Open output. */
+ fdo = dup( fileno(stdout) );
+ if (fdo < 0) {
+ ret = errno2result( errno );
+ D_PERROR( "Direct/Cat: Duplicating stdout (%d) failed!\n", fileno(stdout) );
+ goto close_in;
+ }
+
+ /* Copy loop. */
+ while (true) {
+ char buf[16384];
+ unsigned int length;
+
+ /* Wait for full buffer, if supported, otherwise waits for any data. */
+ ret = direct_stream_wait( stream, sizeof(buf), NULL );
+ if (ret) {
+ D_DERROR( ret, "Direct/Cat: Waiting for data from '%s' failed!\n", url );
+ goto close_both;
+ }
+
+ /* Read buffer. */
+ ret = direct_stream_read( stream, sizeof(buf), buf, &length );
+ if (ret) {
+ D_DERROR( ret, "Direct/Cat: Reading from '%s' failed!\n", url );
+ goto close_both;
+ }
+
+ D_DEBUG_AT( Direct_Cat, "Read %5u bytes\n", length );
+
+ /* Write buffer. */
+ length = write( fdo, buf, length );
+ if (length < 0) {
+ ret = errno2result( errno );
+ D_PERROR( "Direct/Cat: Writing to stdout (%d) failed!\n", fileno(stdout) );
+ goto close_both;
+ }
+
+ D_DEBUG_AT( Direct_Cat, "Wrote %5u bytes\n", length );
+ }
+
+close_both:
+ /* Close output. */
+ close( fdo );
+
+close_in:
+ /* Close input. */
+ direct_stream_destroy( stream );
+
+out:
+ /* Shutdown libdirect. */
+ direct_shutdown();
+
+ return ret;
+}
+
diff --git a/Source/DirectFB/tests/direct_test.c b/Source/DirectFB/tests/direct_test.c
new file mode 100755
index 0000000..4c82c91
--- /dev/null
+++ b/Source/DirectFB/tests/direct_test.c
@@ -0,0 +1,119 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This file is subject to the terms and conditions of the MIT License:
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <config.h>
+
+#include <direct/debug.h>
+#include <direct/direct.h>
+#include <direct/log.h>
+#include <direct/mem.h>
+#include <direct/memcpy.h>
+#include <direct/messages.h>
+#include <direct/trace.h>
+
+static int
+show_usage( const char *name )
+{
+ fprintf( stderr, "Usage: %s [-f <file>] [-u <host>:<port>]\n", name );
+
+ return -1;
+}
+
+int
+main( int argc, char *argv[] )
+{
+ int i;
+ DirectResult ret;
+ DirectLogType log_type = DLT_STDERR;
+ const char *log_param = NULL;
+ DirectLog *log;
+
+
+ for (i=1; i<argc; i++) {
+ if (!strcmp( argv[i], "-f" )) {
+ if (++i < argc) {
+ log_type = DLT_FILE;
+ log_param = argv[i];
+ }
+ else
+ return show_usage(argv[0]);
+ }
+ else if (!strcmp( argv[i], "-u" )) {
+ if (++i < argc) {
+ log_type = DLT_UDP;
+ log_param = argv[i];
+ }
+ else
+ return show_usage(argv[0]);
+ }
+ else
+ return show_usage(argv[0]);
+ }
+
+ /* Initialize logging. */
+ ret = direct_log_create( log_type, log_param, &log );
+ if (ret)
+ return -1;
+
+ /* Set default log to use. */
+ direct_log_set_default( log );
+
+
+ /* Test memory leak detector by not freeing this one. */
+ D_MALLOC( 1351 );
+
+ D_INFO( "Direct/Test: Application starting...\n" );
+
+
+ /* Initialize libdirect. */
+ direct_initialize();
+
+
+ D_INFO( "Direct/Test: Application stopping...\n" );
+
+ /* Shutdown libdirect. */
+ direct_shutdown();
+
+
+ D_INFO( "Direct/Test: You should see a leak message with debug-mem turned on...\n" );
+
+ /* Shutdown logging. */
+ direct_log_destroy( log );
+
+ direct_config->debug = true;
+ direct_print_memleaks();
+
+ return 0;
+}
+
diff --git a/Source/DirectFB/tests/fusion_fork.c b/Source/DirectFB/tests/fusion_fork.c
new file mode 100755
index 0000000..f6cb2ae
--- /dev/null
+++ b/Source/DirectFB/tests/fusion_fork.c
@@ -0,0 +1,172 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ All rights reserved.
+
+ This file is subject to the terms and conditions of the MIT License:
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <config.h>
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <stddef.h>
+
+#include <directfb.h>
+
+#include <direct/log.h>
+#include <direct/messages.h>
+
+#include <fusion/fusion.h>
+#include <fusion/reactor.h>
+#include <fusion/ref.h>
+
+
+#define MSG(x...) \
+do { \
+ direct_log_printf( NULL, "- " x ); \
+} while (0)
+
+
+typedef struct {
+ unsigned int foo;
+} TestMessage;
+
+
+static FusionWorld *m_world;
+static FusionRef m_ref;
+static FusionReactor *m_reactor;
+static Reaction m_reaction;
+
+
+static ReactionResult
+reaction_callback( const void *msg_data,
+ void *ctx )
+{
+ MSG( "Received message (FusionID %lu, pid %d)!\n", fusion_id( m_world ), getpid() );
+
+ return RS_OK;
+}
+
+
+int
+main( int argc, char *argv[] )
+{
+ DirectResult ret;
+ pid_t child_pid;
+ TestMessage message = {0};
+
+ DirectFBInit( &argc, &argv );
+
+ ret = fusion_enter( -1, 0, FER_MASTER, &m_world );
+ if (ret) {
+ D_DERROR( ret, "fusion_enter() failed" );
+ return ret;
+ }
+
+ MSG( "Entered world %d as master (FusionID %lu, pid %d)\n",
+ fusion_world_index( m_world ), fusion_id( m_world ), getpid() );
+
+
+ ret = fusion_ref_init( &m_ref, "Test", m_world );
+ if (ret) {
+ D_DERROR( ret, "fusion_ref_init() failed" );
+ return -1;
+ }
+
+
+ MSG( "Adding local reference...\n" );
+
+ fusion_ref_up( &m_ref, false );
+
+
+ m_reactor = fusion_reactor_new( sizeof(TestMessage), "Test", m_world );
+ if (!m_reactor) {
+ D_ERROR( "fusion_reactor_new() failed\n" );
+ return -1;
+ }
+
+
+ MSG( "Attaching to reactor...\n" );
+
+ ret = fusion_reactor_attach( m_reactor, reaction_callback, NULL, &m_reaction );
+ if (ret) {
+ D_DERROR( ret, "fusion_reactor_attach() failed" );
+ return ret;
+ }
+
+
+ MSG( ".........FORKING NOW.........\n" );
+
+ fusion_world_set_fork_action( m_world, FFA_FORK );
+ child_pid = fork();
+ fusion_world_set_fork_action( m_world, FFA_CLOSE );
+
+ switch (child_pid) {
+ case -1:
+ D_PERROR( "fork() failed" );
+ break;
+
+ case 0:
+ setsid();
+ MSG( "...arrived after fork() in child (pid %d)..\n", getpid() );
+ MSG( "..child (FusionID %lu).\n", fusion_id( m_world ) );
+ break;
+
+ default:
+ usleep( 200000 );
+ MSG( "...returned from fork() in parent, child pid %d.\n", child_pid );
+ break;
+ }
+
+
+ MSG( "Sending message via reactor...\n" );
+
+ fusion_reactor_dispatch( m_reactor, &message, true, NULL );
+
+ usleep( 200000 );
+
+
+ MSG( "Removing local reference...\n" );
+
+ fusion_ref_down( &m_ref, false );
+
+ usleep( 200000 );
+
+
+ MSG( "Exiting from world %d (FusionID %lu, pid %d)...\n",
+ fusion_world_index( m_world ), fusion_id( m_world ), getpid() );
+
+ fusion_exit( m_world, false );
+
+ return 0;
+}
+
diff --git a/Source/DirectFB/tests/fusion_reactor.c b/Source/DirectFB/tests/fusion_reactor.c
new file mode 100755
index 0000000..28d4ce1
--- /dev/null
+++ b/Source/DirectFB/tests/fusion_reactor.c
@@ -0,0 +1,199 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ All rights reserved.
+
+ This file is subject to the terms and conditions of the MIT License:
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <config.h>
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <stddef.h>
+
+#include <directfb.h>
+
+#include <direct/build.h>
+#include <direct/debug.h>
+#include <direct/log.h>
+#include <direct/messages.h>
+
+#include <fusion/fusion.h>
+#include <fusion/reactor.h>
+#include <fusion/ref.h>
+
+
+#if DIRECT_BUILD_DEBUGS
+#define MSG(x...) \
+do { \
+ direct_debug( x ); \
+} while (0)
+#else
+#define MSG(x...) \
+do { \
+} while (0)
+#endif
+
+
+typedef struct {
+ unsigned int foo;
+} TestMessage;
+
+static FusionWorld *m_world;
+
+static ReactionResult
+reaction_callback( const void *msg_data,
+ void *ctx )
+{
+ MSG( "Received message (FusionID %lu, pid %d)!\n", fusion_id( m_world ), getpid() );
+
+ return RS_REMOVE;
+}
+
+static FusionCallHandlerResult
+dispatch_callback (int caller,
+ int call_arg,
+ void *call_ptr,
+ void *ctx,
+ unsigned int serial,
+ int *ret_val )
+{
+ MSG( "Got dispatch callback (FusionID %lu, pid %d)!\n", fusion_id( m_world ), getpid() );
+
+ return FCHR_RETURN;
+}
+
+int
+main( int argc, char *argv[] )
+{
+ DirectResult ret;
+ pid_t child_pid;
+ TestMessage message = {0};
+ FusionReactor *reactor;
+ Reaction reaction;
+ FusionCall call;
+
+ DirectFBInit( &argc, &argv );
+
+ ret = fusion_enter( -1, 0, FER_MASTER, &m_world );
+ if (ret) {
+ D_DERROR( ret, "fusion_enter() failed" );
+ return ret;
+ }
+
+ MSG( "Entered world %d as master (FusionID %lu, pid %d)\n",
+ fusion_world_index( m_world ), fusion_id( m_world ), getpid() );
+
+
+ reactor = fusion_reactor_new( sizeof(TestMessage), "Test", m_world );
+ if (!reactor) {
+ D_ERROR( "fusion_reactor_new() failed\n" );
+ return -1;
+ }
+
+
+ MSG( "Attaching to reactor...\n" );
+
+ ret = fusion_reactor_attach( reactor, reaction_callback, NULL, &reaction );
+ if (ret) {
+ D_DERROR( ret, "fusion_reactor_attach() failed" );
+ return ret;
+ }
+
+
+ MSG( ".........FORKING NOW.........\n" );
+
+ fusion_world_set_fork_action( m_world, FFA_FORK );
+ child_pid = fork();
+ fusion_world_set_fork_action( m_world, FFA_CLOSE );
+
+ switch (child_pid) {
+ case -1:
+ D_PERROR( "fork() failed" );
+ break;
+
+ case 0:
+ setsid();
+ MSG( "...arrived after fork() in child (pid %d)..\n", getpid() );
+ MSG( "..child (FusionID %lu).\n", fusion_id( m_world ) );
+ usleep( 400000 );
+ break;
+
+ default:
+ usleep( 100000 );
+ MSG( "...returned from fork() in parent, child pid %d.\n", child_pid );
+
+ MSG( "Initializing dispatch callback...\n" );
+
+ ret = fusion_call_init( &call, dispatch_callback, NULL, m_world );
+ if (ret) {
+ D_DERROR( ret, "fusion_call_init() failed" );
+ return ret;
+ }
+
+ MSG( "Setting dispatch callback...\n" );
+
+ ret = fusion_reactor_set_dispatch_callback( reactor, &call, NULL );
+ if (ret) {
+ D_DERROR( ret, "fusion_reactor_set_dispatch_callback() failed" );
+ return ret;
+ }
+
+
+ MSG( "Sending message via reactor...\n" );
+ fusion_reactor_dispatch( reactor, &message, true, NULL );
+
+ usleep( 100000 );
+
+ MSG( "Destroying reactor...\n" );
+ fusion_reactor_destroy( reactor );
+ MSG( "...destroyed reactor!\n" );
+
+ usleep( 400000 );
+
+ MSG( "Freeing reactor...\n" );
+ fusion_reactor_free( reactor );
+ MSG( "...freed reactor!\n" );
+
+ break;
+ }
+
+
+
+ MSG( "Exiting from world %d (FusionID %lu, pid %d)...\n",
+ fusion_world_index( m_world ), fusion_id( m_world ), getpid() );
+
+ fusion_exit( m_world, false );
+
+ return 0;
+}
+
diff --git a/Source/DirectFB/tests/fusion_skirmish.c b/Source/DirectFB/tests/fusion_skirmish.c
new file mode 100755
index 0000000..d12cca8
--- /dev/null
+++ b/Source/DirectFB/tests/fusion_skirmish.c
@@ -0,0 +1,131 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ All rights reserved.
+
+ This file is subject to the terms and conditions of the MIT License:
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <config.h>
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <stddef.h>
+
+#include <directfb.h>
+
+#include <direct/build.h>
+#include <direct/debug.h>
+#include <direct/log.h>
+#include <direct/messages.h>
+
+#include <fusion/fusion.h>
+#include <fusion/reactor.h>
+#include <fusion/ref.h>
+
+
+#if DIRECT_BUILD_DEBUGS
+#define MSG(x...) \
+do { \
+ direct_debug( x ); \
+} while (0)
+#else
+#define MSG(x...) \
+do { \
+} while (0)
+#endif
+
+
+static FusionWorld *m_world;
+
+
+int
+main( int argc, char *argv[] )
+{
+ DirectResult ret;
+ FusionSkirmish skirmish;
+
+ DirectFBInit( &argc, &argv );
+
+ ret = fusion_enter( -1, 0, FER_MASTER, &m_world );
+ if (ret) {
+ D_DERROR( ret, "fusion_enter() failed" );
+ return ret;
+ }
+
+ MSG( "Entered world %d as master (FusionID %lu, pid %d)\n",
+ fusion_world_index( m_world ), fusion_id( m_world ), getpid() );
+
+
+ MSG( "Initializing skirmish...\n" );
+
+ ret = fusion_skirmish_init( &skirmish, "Test", m_world );
+ if (ret) {
+ D_DERROR( ret, "fusion_skirmish_init() failed\n" );
+ return -1;
+ }
+
+
+ MSG( "Locking skirmish...\n" );
+
+ ret = fusion_skirmish_prevail( &skirmish );
+ if (ret) {
+ D_DERROR( ret, "fusion_skirmish_prevail() failed!\n" );
+ return -2;
+ }
+
+
+ MSG( "Waiting at skirmish...\n" );
+
+ ret = fusion_skirmish_wait( &skirmish, 10 );
+ if (ret != DFB_TIMEOUT) {
+ D_DERROR( ret, "fusion_skirmish_wait() did not timeout!\n" );
+ return -3;
+ }
+
+
+ MSG( "Unlocking skirmish...\n" );
+
+ ret = fusion_skirmish_dismiss( &skirmish );
+ if (ret) {
+ D_DERROR( ret, "fusion_skirmish_dismiss() failed!\n" );
+ return -4;
+ }
+
+
+ MSG( "Exiting from world %d (FusionID %lu, pid %d)...\n",
+ fusion_world_index( m_world ), fusion_id( m_world ), getpid() );
+
+ fusion_exit( m_world, false );
+
+ return 0;
+}
+
diff --git a/Source/DirectFB/tests/fusion_stream.c b/Source/DirectFB/tests/fusion_stream.c
new file mode 100755
index 0000000..dd86e05
--- /dev/null
+++ b/Source/DirectFB/tests/fusion_stream.c
@@ -0,0 +1,545 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This file is subject to the terms and conditions of the MIT License:
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <errno.h>
+#include <netdb.h>
+#include <pthread.h>
+
+#include <sys/types.h>
+#include <sys/resource.h>
+#include <sys/time.h>
+
+#include <direct/messages.h>
+
+#include <fusion/call.h>
+#include <fusion/fusion.h>
+#include <fusion/shm/pool.h>
+
+#define MAX_NUM_BLOCKS 10000
+
+#define SIZE_ALIGNMASK 0x3
+#define ALIGN_SIZE(s) (((s) + SIZE_ALIGNMASK) & ~SIZE_ALIGNMASK)
+
+/**********************************************************************************************************************/
+
+static int parse_cmdline ( int argc,
+ char *argv[] );
+static int show_usage ( void );
+
+/**********************************************************************************************************************/
+
+static inline unsigned long
+get_millis( void )
+{
+ struct timeval tv;
+
+ gettimeofday( &tv, NULL );
+
+ return tv.tv_sec * 1000 + tv.tv_usec / 1000;
+}
+
+/**********************************************************************************************************************/
+
+static unsigned int bit_rate;
+static bool run_busy;
+static bool do_fork;
+static bool do_thread;
+
+/**********************************************************************************************************************/
+
+static long block_size = 184;
+static long num_blocks = 16;
+
+/**********************************************************************************************************************/
+
+static int fuser, fnice, fsystem, fidle, ftotal;
+static int cuser, cnice, csystem, cidle, ctotal;
+static int puser, pnice, psystem, pidle, ptotal;
+static int duser, dnice, dsystem, didle, dtotal;
+
+static int
+read_stat( void )
+{
+ char dummy[4];
+ int wa = 0, hi = 0, si = 0;
+ FILE *file;
+
+ puser = cuser;
+ pnice = cnice;
+ psystem = csystem;
+ pidle = cidle;
+ ptotal = ctotal;
+
+ file = fopen( "/proc/stat", "r" );
+ if (!file) {
+ perror( "Could not open '/proc/stat'" );
+ return 0;
+ }
+
+ if (fscanf( file, "%3s %d %d %d %d %d %d %d", dummy, &cuser, &cnice, &csystem, &cidle, &wa, &hi, &si ) < 4) {
+ fprintf( stderr, "Parsing '/proc/stat' failed!\n" );
+ return 0;
+ }
+
+ fclose( file );
+
+ /* Compatibility with 2.6 split up idle times. */
+ cidle += wa + hi + si;
+
+ /* Count nice as idle. */
+ cidle += cnice;
+ cnice = 0;
+
+ ctotal = cuser + cnice + csystem + cidle;
+
+ duser = cuser - puser;
+ dnice = cnice - pnice;
+ dsystem = csystem - psystem;
+ didle = cidle - pidle;
+ dtotal = ctotal - ptotal;
+
+ if (!ftotal) {
+ fuser = cuser;
+ fnice = cnice;
+ fsystem = csystem;
+ fidle = cidle;
+ ftotal = ctotal;
+ }
+
+ return 1;
+}
+
+/**********************************************************************************************************************/
+
+static pthread_t busy_thread;
+static pthread_mutex_t busy_lock = PTHREAD_MUTEX_INITIALIZER;
+static unsigned int busy_alive = 1;
+static unsigned int busy_count;
+
+static void *
+busy_loop( void *arg )
+{
+ setpriority( PRIO_PROCESS, 0, 19 );
+
+ while (busy_alive) {
+ int i;
+
+ for (i=0; i<100000; i++);
+
+ pthread_mutex_lock( &busy_lock );
+
+ busy_count++;
+
+ pthread_mutex_unlock( &busy_lock );
+ }
+
+ return NULL;
+}
+
+/**********************************************************************************************************************/
+
+static FusionCallHandlerResult
+call_handler( int caller,
+ int call_arg,
+ void *call_ptr,
+ void *ctx,
+ unsigned int serial,
+ int *ret_val )
+{
+ static u32 checksum = 0;
+
+ int i;
+ const u32 *values = call_ptr;
+
+
+ for (i=0; i<block_size/4; i++)
+ checksum += values[i];
+
+ *ret_val = checksum;
+
+ return FCHR_RETURN;
+}
+
+/**********************************************************************************************************************/
+
+int
+main( int argc, char *argv[] )
+{
+ DirectResult ret;
+ FusionWorld *world;
+ FusionCall call = {0};
+ FusionSHMPoolShared *pool;
+ void *buffer;
+ int i, max_busy = 0, active = 1;
+ long long t1 = 0, t2;
+ long long start = 0;
+ long long bytes = 0;
+ long long last_bytes = 0;
+ unsigned long blocks = 0;
+ unsigned long last_blocks = 0;
+ unsigned long last_busy = 0;
+ u32 checksum = 0;
+ bool produce = true;
+ int delay = 66000;
+
+ if (parse_cmdline( argc, argv ))
+ return -1;
+
+ if (bit_rate) {
+ int blocks_per_sec = (bit_rate * 1024 / 8) / block_size;
+
+ if (blocks_per_sec < 100)
+ delay = 900000 / blocks_per_sec - 2000;
+ else
+ delay = 300000 * 100 / blocks_per_sec;
+
+ num_blocks = bit_rate * 1024 / 8 / block_size * delay / 900000;
+
+ if (num_blocks > MAX_NUM_BLOCKS)
+ num_blocks = MAX_NUM_BLOCKS;
+
+ if (!num_blocks) {
+ num_blocks = 1;
+ delay = 970 * block_size / (bit_rate * 1024 / 8) * 1000 - 2000;
+ }
+ }
+
+ sync();
+
+ if (run_busy) {
+ pthread_create( &busy_thread, NULL, busy_loop, NULL );
+
+ printf( "Calibrating...\n" );
+
+ pthread_mutex_lock( &busy_lock );
+
+ for (i=0; i<7; i++) {
+ int busy_rate;
+
+ busy_count = 0;
+
+ t1 = get_millis();
+ pthread_mutex_unlock( &busy_lock );
+
+ usleep( 300000 );
+
+ pthread_mutex_lock( &busy_lock );
+ t2 = get_millis();
+
+ busy_rate = busy_count * 1000 / (t2 - t1);
+
+ if (busy_rate > max_busy)
+ max_busy = busy_rate;
+ }
+
+ printf( "Calibrating done. (%d busy counts/sec)\n", max_busy );
+ }
+
+ ret = fusion_enter( -1, 23, FER_MASTER, &world );
+ if (ret)
+ return ret;
+
+ ret = fusion_call_init( &call, call_handler, NULL, world );
+ if (ret)
+ return ret;
+
+ ret = fusion_shm_pool_create( world, "Stream Buffer", block_size + 8192, false, &pool );
+ if (ret)
+ return ret;
+
+ ret = fusion_shm_pool_allocate( pool, block_size, false, true, &buffer );
+ if (ret)
+ return ret;
+
+
+
+ /*
+ * Do the fork() magic!
+ */
+ if (do_fork) {
+ fusion_world_set_fork_action( world, FFA_FORK );
+
+ switch (fork()) {
+ case -1:
+ D_PERROR( "fork() failed!\n" );
+ return -1;
+
+ case 0:
+ /* child continues as the producer */
+ run_busy = false;
+ break;
+
+ default:
+ /* parent is the consumer (callback in Fusion Dispatch thread) */
+ produce = false;
+
+ usleep( 50000 );
+ }
+
+ fusion_world_set_fork_action( world, FFA_CLOSE );
+ }
+
+
+ start = t1 = get_millis();
+
+ if (run_busy) {
+ busy_count = 0;
+ pthread_mutex_unlock( &busy_lock );
+ }
+
+#ifdef LINUX_2_4
+ delay -= 10000;
+#endif
+
+ do {
+ if (bit_rate || !produce) {
+ if (delay > 10)
+ usleep( delay );
+ }
+
+ if (produce) {
+ for (i=0; i<num_blocks; i++) {
+ int n;
+ u32 retsum;
+ u32 *values = buffer;
+
+ for (n=0; n<block_size/4; n++) {
+ values[n] = n;
+ checksum += n;
+ }
+
+ bytes += block_size;
+
+ fusion_call_execute( &call, do_thread ? FCEF_NODIRECT : FCEF_NONE,
+ 0, buffer, (int*) &retsum );
+
+ if (retsum != checksum)
+ D_ERROR( "Checksum returned by consumer (0x%08x) does not match 0x%08x!\n", retsum, checksum );
+ }
+
+ blocks += num_blocks;
+ }
+
+
+ t2 = get_millis();
+ if (t2 - t1 > 2000) {
+ if (produce) {
+ long long kbits = 0, avgkbits, total_time, diff_time, diff_bytes;
+
+ printf( "\n\n\n" );
+
+ total_time = t2 - start;
+ diff_time = t2 - t1;
+ diff_bytes = bytes - last_bytes;
+
+ avgkbits = (long long)bytes * 8LL * 1000LL / (long long)total_time / 1024LL;
+
+ if (diff_time)
+ kbits = (long long)diff_bytes * 8LL * 1000LL / (long long)diff_time / 1024LL;
+
+ printf( "Total Time: %7lld ms\n", total_time );
+ printf( "Stream Size: %7lld kb\n", bytes / 1024 );
+ printf( "Stream Rate: %7lld kb/sec -> %lld.%03lld MBit (avg. %lld.%03lld MBit)\n",
+ kbits / 8,
+ (kbits * 1000 / 1024) / 1000, (kbits * 1000 / 1024) % 1000,
+ (avgkbits * 1000 / 1024) / 1000, (avgkbits * 1000 / 1024) % 1000 );
+ printf( "\n" );
+
+
+ if (last_bytes && bit_rate) {
+ long long diff_bytes = (bytes - last_bytes) * 1000 / (t2 - t1);
+ long long need_bytes = bit_rate * 1024 / 8;
+
+ if (diff_bytes) {
+ int new_blocks = (num_blocks * need_bytes + diff_bytes/2) / diff_bytes;
+
+ num_blocks = (new_blocks + num_blocks + 1) / 2;
+
+ if (num_blocks > MAX_NUM_BLOCKS)
+ num_blocks = MAX_NUM_BLOCKS;
+ }
+ }
+
+
+ read_stat();
+
+ if (ftotal != ctotal && dtotal) {
+ int load, aload;
+
+ load = 1000 - didle * 1000 / dtotal;
+ aload = 1000 - (cidle - fidle) * 1000 / (ctotal - ftotal);
+
+ printf( "Overall Stats\n" );
+ printf( " Total Time: %7lld ms\n", t2 - start );
+ printf( " Block Size: %7ld\n", block_size );
+ printf( " Blocks/cycle: %7ld\n", num_blocks );
+ printf( " Blocks/second: %7lld\n", (blocks - last_blocks) * 1000 / diff_time );
+ printf( " Delay: %7d\n", delay );
+ printf( " CPU Load: %5d.%d %% (avg. %d.%d %%)\n",
+ load / 10, load % 10, aload / 10, aload % 10 );
+ }
+
+
+ last_bytes = bytes;
+ last_blocks = blocks;
+ }
+
+ if (run_busy) {
+ pthread_mutex_lock( &busy_lock );
+
+ if (last_busy) {
+ int busy_diff;
+ int busy_rate, busy_load;
+ int abusy_rate, abusy_load;
+
+ busy_diff = busy_count - last_busy;
+ busy_rate = max_busy - (busy_diff * 1000 / (t2 - t1));
+ busy_load = busy_rate * 1000 / max_busy;
+ abusy_rate = max_busy - (busy_count * 1000 / (t2 - start));
+ abusy_load = abusy_rate * 1000 / max_busy;
+
+ printf( " Real CPU Load: %5d.%d %% (avg. %d.%d %%)\n",
+ busy_load / 10, busy_load % 10,
+ abusy_load / 10, abusy_load % 10 );
+ }
+
+ last_busy = busy_count;
+
+ pthread_mutex_unlock( &busy_lock );
+ }
+
+ t1 = t2;
+ }
+ } while (active > 0);
+
+
+ if (run_busy) {
+ busy_alive = 0;
+
+ pthread_join( busy_thread, NULL );
+ }
+
+ return -1;
+}
+
+/**********************************************************************************************************************/
+
+static int
+parse_cmdline( int argc, char *argv[] )
+{
+ int i;
+ char *end;
+
+ for (i=1; i<argc; i++) {
+ if (!strcmp( argv[i], "-s" )) {
+ if (++i < argc) {
+ block_size = strtoul( argv[i], &end, 10 );
+
+ if (end && *end) {
+ D_ERROR( "Parse error in number '%s'!\n", argv[i] );
+ return -1;
+ }
+
+ if (block_size < 1)
+ return show_usage();
+ }
+ else
+ return show_usage();
+ }
+ else if (!strcmp( argv[i], "-b" )) {
+ if (++i < argc) {
+ bit_rate = strtoul( argv[i], &end, 10 );
+
+ if (end && *end) {
+ D_ERROR( "Parse error in number '%s'!\n", argv[i] );
+ return -1;
+ }
+ }
+ else
+ return show_usage();
+ }
+ else if (!strcmp( argv[i], "-B" )) {
+ if (++i < argc) {
+ bit_rate = strtoul( argv[i], &end, 10 ) * 1024;
+
+ if (end && *end) {
+ D_ERROR( "Parse error in number '%s'!\n", argv[i] );
+ return -1;
+ }
+ }
+ else
+ return show_usage();
+ }
+ else if (!strcmp( argv[i], "-c" )) {
+ run_busy = 1;
+ }
+ else if (!strcmp( argv[i], "-f" )) {
+ do_fork = 1;
+ }
+ else if (!strcmp( argv[i], "-t" )) {
+ do_thread = 1;
+ }
+ else
+ return show_usage();
+ }
+
+ return 0;
+}
+
+static int
+show_usage( void )
+{
+ fprintf( stderr, "\n"
+ "Usage:\n"
+ " fusion_stream [options]\n"
+ "\n"
+ "Options:\n"
+ " -s <1-n> Size of each block of data\n"
+ " -b <0-n> Designated bit rate in kbit (0 = unlimited)\n"
+ " -B <0-n> Designated bit rate in Mbit (0 = unlimited)\n"
+ " -c Run busy loop counting spare CPU cycles to get real CPU load\n"
+ " -f Fork to have the producer in a separate process\n"
+ " -t Force calls to be handled in a separate thread\n"
+ "\n"
+ );
+
+ return -1;
+}
+
diff --git a/Source/DirectFB/tests/smiley_test.c b/Source/DirectFB/tests/smiley_test.c
new file mode 100755
index 0000000..aab7993
--- /dev/null
+++ b/Source/DirectFB/tests/smiley_test.c
@@ -0,0 +1,215 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <direct/types.h>
+
+#include <directfb.h>
+
+
+/* macro for a safe call to DirectFB functions */
+#define DFBCHECK(x...) \
+do { \
+ int err = x; \
+ if (err != DFB_OK) { \
+ fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
+ DirectFBErrorFatal( #x, err ); \
+ } \
+} while (0)
+
+
+#define ERROR(x...) \
+do { \
+ fprintf (stderr, "%s <%i>: ", __FILE__, __LINE__); \
+ fprintf (stderr, x); \
+ fprintf (stderr, "\n"); \
+ exit (-1); \
+} while (0)
+
+
+static char **fontname_list;
+static int fontname_count;
+
+static IDirectFB *dfb;
+static IDirectFBEventBuffer *keybuffer;
+static IDirectFBDisplayLayer *layer;
+static IDirectFBSurface *surface;
+
+static int show_help = 0;
+static int show_ascender = 0;
+static int show_descender = 0;
+static int show_baseline = 0;
+static int show_glyphrect = 0;
+static int show_glyphadvance = 0;
+static int show_glyphorigin = 0;
+
+static int antialias = 1;
+static int unicode_mode = 1;
+
+static DFBEnumerationResult
+encoding_callback( DFBTextEncodingID id,
+ const char *name,
+ void *context )
+{
+ printf( " (%02d) %s\n", id, name );
+
+ return DFENUM_OK;
+}
+
+static void
+render_font_page (IDirectFBSurface *surface,
+ const char *fontname1,
+ const char *fontname2)
+{
+ DFBFontDescription fontdesc;
+ IDirectFBFont *font1, *font2;
+ int width, height;
+ int bwidth, bheight;
+ int xborder, yborder;
+ int baseoffset;
+ int ascender, descender;
+ char label[32];
+ int i, j;
+
+ surface->GetSize (surface, &width, &height);
+
+ bwidth = width * 7 / 8;
+ bheight = height * 7 / 8;
+
+ xborder = (width - bwidth) / 2;
+ yborder = (height - bheight) / 2;
+
+ fontdesc.flags = DFDESC_ATTRIBUTES;
+ fontdesc.attributes = antialias ? 0 : DFFA_MONOCHROME;
+
+// DFBCHECK(dfb->CreateFont (dfb, NULL, NULL, &fixedfont));
+// surface->SetFont (surface, fixedfont);
+
+ fontdesc.flags = DFDESC_HEIGHT | DFDESC_ATTRIBUTES;
+ fontdesc.height = 56;//9 * bheight / glyphs_per_yline / 16;
+ fontdesc.attributes = antialias ? 0 : DFFA_MONOCHROME;
+ fontdesc.attributes |= unicode_mode ? 0 : DFFA_NOCHARMAP;
+
+ if (dfb->CreateFont (dfb, fontname1, &fontdesc, &font1) != DFB_OK) {
+
+ static const char *msg = "failed opening '";
+ char text [strlen(msg) + strlen(fontname1) + 2];
+
+ strcpy (text, msg);
+ strcpy (text + strlen(msg), fontname1);
+ strcpy (text + strlen(msg) + strlen(fontname1), "'");
+ printf("GEG: %s\n", text);
+ surface->SetColor (surface, 0xff, 0x00, 0x00, 0xff);
+ surface->DrawString (surface,
+ text, -1, width/2, 10, DSTF_TOPCENTER);
+ return;
+ }
+
+ if (dfb->CreateFont (dfb, fontname2, &fontdesc, &font2) != DFB_OK) {
+
+ static const char *msg = "failed opening '";
+ char text [strlen(msg) + strlen(fontname2) + 2];
+
+ strcpy (text, msg);
+ strcpy (text + strlen(msg), fontname2);
+ strcpy (text + strlen(msg) + strlen(fontname2), "'");
+ printf("GEG: %s\n", text);
+ surface->SetColor (surface, 0xff, 0x00, 0x00, 0xff);
+ surface->DrawString (surface,
+ text, -1, width/2, 10, DSTF_TOPCENTER);
+ return;
+ }
+
+ {
+ static bool done = false;
+
+ if (!done) {
+ printf( "\nEncodings %s\n", fontname1 );
+ font1->EnumEncodings( font1, encoding_callback, NULL );
+ done = true;
+ }
+ }
+
+ {
+ static bool done = false;
+
+ if (!done) {
+ printf( "\nEncodings %s\n", fontname2 );
+ font2->EnumEncodings( font2, encoding_callback, NULL );
+ done = true;
+ }
+ }
+
+ surface->SetFont(surface, font1);
+ surface->DrawString(surface, "Hello", -1, 100, 100, DSTF_LEFT);
+ surface->SetFont(surface, font2);
+ surface->DrawString(surface, "AB", -1, 100, 100, DSTF_LEFT);
+
+ font1->Release (font1);
+ font2->Release (font2);
+}
+
+static void
+cleanup( void )
+{
+ if (keybuffer) keybuffer->Release (keybuffer);
+ if (surface) surface->Release (surface);
+ if (layer) layer->Release (layer);
+ if (dfb) dfb->Release (dfb);
+}
+
+static void
+print_usage( void )
+{
+ printf ("DirectFB Font Viewer version " VERSION "\n\n");
+ printf ("Usage: df_fonts <fontfile> ... <fontfile>\n\n");
+}
+
+int
+main( int argc, char *argv[] )
+{
+ DFBSurfaceDescription surface_desc;
+ DFBInputEvent evt;
+ int first_glyph = 0;
+ int current_font = 0;
+ int update = 1;
+
+ if (argc < 2 || strcmp(argv[1], "--help") == 0) {
+ print_usage();
+ return EXIT_FAILURE;
+ }
+
+ fontname_count = argc - 1;
+ fontname_list = argv + 1;
+
+ DFBCHECK(DirectFBInit(&argc, &argv));
+ DFBCHECK(DirectFBSetOption("bg-none", NULL));
+ DFBCHECK(DirectFBCreate(&dfb));
+
+ atexit (cleanup);
+
+ //dfb->SetCooperativeLevel(dfb, DFSCL_FULLSCREEN);
+
+ surface_desc.flags = DSDESC_CAPS;
+ surface_desc.caps = DSCAPS_PRIMARY /*| DSCAPS_DOUBLE*/;
+
+ DFBCHECK(dfb->CreateSurface(dfb, &surface_desc, &surface));
+
+ DFBCHECK(dfb->CreateInputEventBuffer(dfb, DICAPS_KEYS,
+ DFB_FALSE, &keybuffer));
+
+ while (1) {
+ surface->Clear (surface, 0xff, 0xff, 0xff, 0xff);
+ render_font_page (surface, argv[1], argv[2]);
+ surface->Flip (surface, NULL, DSFLIP_WAITFORSYNC);
+
+ keybuffer->WaitForEvent(keybuffer);
+
+ while (keybuffer->GetEvent(keybuffer, DFB_EVENT(&evt)) == DFB_OK) {
+
+ }
+ }
+
+ return EXIT_SUCCESS;
+}