summaryrefslogtreecommitdiff
path: root/Source/DirectFB/tools
diff options
context:
space:
mode:
Diffstat (limited to 'Source/DirectFB/tools')
-rwxr-xr-xSource/DirectFB/tools/Makefile.am109
-rwxr-xr-xSource/DirectFB/tools/Makefile.in760
-rwxr-xr-xSource/DirectFB/tools/README24
-rwxr-xr-xSource/DirectFB/tools/application.lst15
-rwxr-xr-xSource/DirectFB/tools/dfbdump.c928
-rwxr-xr-xSource/DirectFB/tools/dfbfx.c630
-rwxr-xr-xSource/DirectFB/tools/dfbg.c280
-rwxr-xr-xSource/DirectFB/tools/dfbinfo.c605
-rwxr-xr-xSource/DirectFB/tools/dfbinput.c331
-rwxr-xr-xSource/DirectFB/tools/dfbinspector.c288
-rwxr-xr-xSource/DirectFB/tools/dfblayer.c625
-rwxr-xr-xSource/DirectFB/tools/dfbmaster.c68
-rwxr-xr-xSource/DirectFB/tools/dfbpenmount.c228
-rwxr-xr-xSource/DirectFB/tools/dfbproxy.c162
-rwxr-xr-xSource/DirectFB/tools/dfbscreen.c660
-rwxr-xr-xSource/DirectFB/tools/directfb-csource.c894
-rwxr-xr-xSource/DirectFB/tools/fusion_bench.c537
-rwxr-xr-xSource/DirectFB/tools/gendoc.pl936
-rwxr-xr-xSource/DirectFB/tools/mkdfiff.c444
-rwxr-xr-xSource/DirectFB/tools/mkdgiff.c616
-rwxr-xr-xSource/DirectFB/tools/mkdgifft.cpp1043
-rwxr-xr-xSource/DirectFB/tools/mknames.sh33
-rwxr-xr-xSource/DirectFB/tools/raw15toraw24.c61
-rwxr-xr-xSource/DirectFB/tools/raw16toraw24.c61
-rwxr-xr-xSource/DirectFB/tools/raw32toraw24.c63
-rwxr-xr-xSource/DirectFB/tools/voodooplay.c164
-rwxr-xr-xSource/DirectFB/tools/voodooplay_client.c317
-rwxr-xr-xSource/DirectFB/tools/voodooplay_server.c318
28 files changed, 11200 insertions, 0 deletions
diff --git a/Source/DirectFB/tools/Makefile.am b/Source/DirectFB/tools/Makefile.am
new file mode 100755
index 0000000..f4ddf15
--- /dev/null
+++ b/Source/DirectFB/tools/Makefile.am
@@ -0,0 +1,109 @@
+## Makefile.am for DirectFB/tools
+
+INCLUDES = \
+ -I$(top_builddir)/lib \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/src
+
+AM_CPPFLAGS = -DDATADIR=\"@DATADIR@\"
+
+AM_CFLAGS = $(FREETYPE_CFLAGS)
+
+if BUILD_DIRECTFB_CSOURCE
+DFB_CSOURCE = directfb-csource
+
+directfb_csource_SOURCES = directfb-csource.c
+directfb_csource_LDADD = $(LIBPNG)
+endif
+
+if HAVE_LINUX
+LINUXONLY_TOOLS = \
+ fusion_bench \
+ raw15toraw24 \
+ raw16toraw24 \
+ raw32toraw24
+endif
+
+if ENABLE_VOODOO
+VOODOO_PROGS = dfbproxy
+endif
+
+if PNG_PROVIDER
+PNG_PROGS = mkdfiff mkdgifft
+endif
+
+if FREETYPE_PROVIDER
+FREETYPE_PROGS = mkdgiff
+endif
+
+bin_PROGRAMS = $(DFB_CSOURCE) \
+ dfbdump dfbfx dfbg dfbinfo dfbinput dfbinspector dfblayer \
+ dfbmaster dfbscreen dfbpenmount $(PNG_PROGS) $(FREETYPE_PROGS) $(VOODOO_PROGS)
+
+noinst_PROGRAMS = $(LINUXONLY_TOOLS)
+
+libdirectfb = ../src/libdirectfb.la
+libfusion = ../lib/fusion/libfusion.la
+libdirect = ../lib/direct/libdirect.la
+libvoodoo = ../lib/voodoo/libvoodoo.la
+
+dfbdump_SOURCES = dfbdump.c
+dfbdump_LDADD = $(libdirectfb) $(libfusion) $(libdirect) $(libvoodoo)
+
+dfbg_SOURCES = dfbg.c
+dfbg_LDADD = $(libdirectfb) $(libfusion) $(libdirect) $(libvoodoo) $(OSX_LIBS)
+
+dfbinfo_SOURCES = dfbinfo.c
+dfbinfo_LDADD = $(libdirectfb) $(libfusion) $(libdirect) $(libvoodoo) $(OSX_LIBS)
+
+dfbinput_SOURCES = dfbinput.c
+dfbinput_LDADD = $(libdirectfb) $(libfusion) $(libdirect) $(libvoodoo) $(OSX_LIBS)
+
+dfbinspector_SOURCES = dfbinspector.c
+dfbinspector_LDADD = $(libdirectfb) $(libfusion) $(libdirect) $(libvoodoo) $(OSX_LIBS)
+
+dfblayer_SOURCES = dfblayer.c
+dfblayer_LDADD = $(libdirectfb) $(libfusion) $(libdirect) $(libvoodoo) $(OSX_LIBS)
+
+dfbmaster_SOURCES = dfbmaster.c
+dfbmaster_LDADD = $(libdirectfb) $(libfusion) $(libdirect) $(libvoodoo) $(OSX_LIBS)
+
+dfbproxy_SOURCES = dfbproxy.c
+dfbproxy_LDADD = $(libdirectfb) $(libfusion) $(libdirect) $(libvoodoo)
+
+dfbscreen_SOURCES = dfbscreen.c
+dfbscreen_LDADD = $(libdirectfb) $(libfusion) $(libdirect) $(libvoodoo) $(OSX_LIBS)
+
+#dfbsummon_SOURCES = dfbsummon.c
+#dfbsummon_LDADD = $(libdirectfb) $(libfusion) $(libdirect) $(libvoodoo)
+
+dfbpenmount_SOURCES = dfbpenmount.c
+dfbpenmount_LDADD = $(libdirectfb) $(libfusion) $(libdirect) $(libvoodoo)
+
+mkdfiff_SOURCES = mkdfiff.c
+mkdfiff_LDADD = $(LIBPNG) $(libdirect)
+
+mkdgiff_SOURCES = mkdgiff.c
+mkdgiff_LDADD = $(FREETYPE_LIBS) $(libdirect)
+
+mkdgifft_SOURCES = mkdgifft.cpp
+mkdgifft_LDADD = $(LIBPNG_LIBS) $(libdirectfb) $(libfusion) $(libdirect)
+
+fusion_bench_SOURCES = fusion_bench.c
+fusion_bench_LDADD = $(libdirectfb) $(libfusion) $(libdirect) $(libvoodoo)
+
+dfbfx_SOURCES = dfbfx.c
+dfbfx_LDADD = $(libdirect)
+
+raw15toraw24_SOURCES = raw15toraw24.c
+
+raw16toraw24_SOURCES = raw16toraw24.c
+
+raw32toraw24_SOURCES = raw32toraw24.c
+
+EXTRA_DIST = \
+ README \
+ gendoc.pl \
+ mknames.sh
diff --git a/Source/DirectFB/tools/Makefile.in b/Source/DirectFB/tools/Makefile.in
new file mode 100755
index 0000000..942f516
--- /dev/null
+++ b/Source/DirectFB/tools/Makefile.in
@@ -0,0 +1,760 @@
+# 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@
+bin_PROGRAMS = $(am__EXEEXT_1) dfbdump$(EXEEXT) dfbfx$(EXEEXT) \
+ dfbg$(EXEEXT) dfbinfo$(EXEEXT) dfbinput$(EXEEXT) \
+ dfbinspector$(EXEEXT) dfblayer$(EXEEXT) dfbmaster$(EXEEXT) \
+ dfbscreen$(EXEEXT) dfbpenmount$(EXEEXT) $(am__EXEEXT_2) \
+ $(am__EXEEXT_3) $(am__EXEEXT_4)
+noinst_PROGRAMS = $(am__EXEEXT_5)
+subdir = tools
+DIST_COMMON = README $(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 =
+@BUILD_DIRECTFB_CSOURCE_TRUE@am__EXEEXT_1 = directfb-csource$(EXEEXT)
+@PNG_PROVIDER_TRUE@am__EXEEXT_2 = mkdfiff$(EXEEXT)
+@FREETYPE_PROVIDER_TRUE@am__EXEEXT_3 = mkdgiff$(EXEEXT)
+@ENABLE_VOODOO_TRUE@am__EXEEXT_4 = dfbproxy$(EXEEXT)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+@HAVE_LINUX_TRUE@am__EXEEXT_5 = fusion_bench$(EXEEXT) \
+@HAVE_LINUX_TRUE@ raw15toraw24$(EXEEXT) raw16toraw24$(EXEEXT) \
+@HAVE_LINUX_TRUE@ raw32toraw24$(EXEEXT)
+PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
+am_dfbdump_OBJECTS = dfbdump.$(OBJEXT)
+dfbdump_OBJECTS = $(am_dfbdump_OBJECTS)
+dfbdump_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect)
+am_dfbfx_OBJECTS = dfbfx.$(OBJEXT)
+dfbfx_OBJECTS = $(am_dfbfx_OBJECTS)
+dfbfx_DEPENDENCIES = $(libdirect)
+am_dfbg_OBJECTS = dfbg.$(OBJEXT)
+dfbg_OBJECTS = $(am_dfbg_OBJECTS)
+am__DEPENDENCIES_1 =
+dfbg_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect) \
+ $(am__DEPENDENCIES_1)
+am_dfbinfo_OBJECTS = dfbinfo.$(OBJEXT)
+dfbinfo_OBJECTS = $(am_dfbinfo_OBJECTS)
+dfbinfo_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect) \
+ $(am__DEPENDENCIES_1)
+am_dfbinput_OBJECTS = dfbinput.$(OBJEXT)
+dfbinput_OBJECTS = $(am_dfbinput_OBJECTS)
+dfbinput_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect) \
+ $(am__DEPENDENCIES_1)
+am_dfbinspector_OBJECTS = dfbinspector.$(OBJEXT)
+dfbinspector_OBJECTS = $(am_dfbinspector_OBJECTS)
+dfbinspector_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect) \
+ $(am__DEPENDENCIES_1)
+am_dfblayer_OBJECTS = dfblayer.$(OBJEXT)
+dfblayer_OBJECTS = $(am_dfblayer_OBJECTS)
+dfblayer_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect) \
+ $(am__DEPENDENCIES_1)
+am_dfbmaster_OBJECTS = dfbmaster.$(OBJEXT)
+dfbmaster_OBJECTS = $(am_dfbmaster_OBJECTS)
+dfbmaster_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect) \
+ $(am__DEPENDENCIES_1)
+am_dfbpenmount_OBJECTS = dfbpenmount.$(OBJEXT)
+dfbpenmount_OBJECTS = $(am_dfbpenmount_OBJECTS)
+dfbpenmount_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect)
+am_dfbproxy_OBJECTS = dfbproxy.$(OBJEXT)
+dfbproxy_OBJECTS = $(am_dfbproxy_OBJECTS)
+dfbproxy_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect) \
+ $(libvoodoo)
+am_dfbscreen_OBJECTS = dfbscreen.$(OBJEXT)
+dfbscreen_OBJECTS = $(am_dfbscreen_OBJECTS)
+dfbscreen_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect) \
+ $(am__DEPENDENCIES_1)
+am__directfb_csource_SOURCES_DIST = directfb-csource.c
+@BUILD_DIRECTFB_CSOURCE_TRUE@am_directfb_csource_OBJECTS = \
+@BUILD_DIRECTFB_CSOURCE_TRUE@ directfb-csource.$(OBJEXT)
+directfb_csource_OBJECTS = $(am_directfb_csource_OBJECTS)
+@BUILD_DIRECTFB_CSOURCE_TRUE@directfb_csource_DEPENDENCIES = \
+@BUILD_DIRECTFB_CSOURCE_TRUE@ $(am__DEPENDENCIES_1)
+am_fusion_bench_OBJECTS = fusion_bench.$(OBJEXT)
+fusion_bench_OBJECTS = $(am_fusion_bench_OBJECTS)
+fusion_bench_DEPENDENCIES = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect)
+am_mkdfiff_OBJECTS = mkdfiff.$(OBJEXT)
+mkdfiff_OBJECTS = $(am_mkdfiff_OBJECTS)
+mkdfiff_DEPENDENCIES = $(am__DEPENDENCIES_1) $(libdirect)
+am_mkdgiff_OBJECTS = mkdgiff.$(OBJEXT)
+mkdgiff_OBJECTS = $(am_mkdgiff_OBJECTS)
+mkdgiff_DEPENDENCIES = $(am__DEPENDENCIES_1) $(libdirect)
+am_raw15toraw24_OBJECTS = raw15toraw24.$(OBJEXT)
+raw15toraw24_OBJECTS = $(am_raw15toraw24_OBJECTS)
+raw15toraw24_LDADD = $(LDADD)
+am_raw16toraw24_OBJECTS = raw16toraw24.$(OBJEXT)
+raw16toraw24_OBJECTS = $(am_raw16toraw24_OBJECTS)
+raw16toraw24_LDADD = $(LDADD)
+am_raw32toraw24_OBJECTS = raw32toraw24.$(OBJEXT)
+raw32toraw24_OBJECTS = $(am_raw32toraw24_OBJECTS)
+raw32toraw24_LDADD = $(LDADD)
+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 = $(dfbdump_SOURCES) $(dfbfx_SOURCES) $(dfbg_SOURCES) \
+ $(dfbinfo_SOURCES) $(dfbinput_SOURCES) $(dfbinspector_SOURCES) \
+ $(dfblayer_SOURCES) $(dfbmaster_SOURCES) \
+ $(dfbpenmount_SOURCES) $(dfbproxy_SOURCES) \
+ $(dfbscreen_SOURCES) $(directfb_csource_SOURCES) \
+ $(fusion_bench_SOURCES) $(mkdfiff_SOURCES) $(mkdgiff_SOURCES) \
+ $(raw15toraw24_SOURCES) $(raw16toraw24_SOURCES) \
+ $(raw32toraw24_SOURCES)
+DIST_SOURCES = $(dfbdump_SOURCES) $(dfbfx_SOURCES) $(dfbg_SOURCES) \
+ $(dfbinfo_SOURCES) $(dfbinput_SOURCES) $(dfbinspector_SOURCES) \
+ $(dfblayer_SOURCES) $(dfbmaster_SOURCES) \
+ $(dfbpenmount_SOURCES) $(dfbproxy_SOURCES) \
+ $(dfbscreen_SOURCES) $(am__directfb_csource_SOURCES_DIST) \
+ $(fusion_bench_SOURCES) $(mkdfiff_SOURCES) $(mkdgiff_SOURCES) \
+ $(raw15toraw24_SOURCES) $(raw16toraw24_SOURCES) \
+ $(raw32toraw24_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
+
+AM_CPPFLAGS = -DDATADIR=\"@DATADIR@\"
+AM_CFLAGS = $(FREETYPE_CFLAGS)
+@BUILD_DIRECTFB_CSOURCE_TRUE@DFB_CSOURCE = directfb-csource
+@BUILD_DIRECTFB_CSOURCE_TRUE@directfb_csource_SOURCES = directfb-csource.c
+@BUILD_DIRECTFB_CSOURCE_TRUE@directfb_csource_LDADD = $(LIBPNG)
+@HAVE_LINUX_TRUE@LINUXONLY_TOOLS = \
+@HAVE_LINUX_TRUE@ fusion_bench \
+@HAVE_LINUX_TRUE@ raw15toraw24 \
+@HAVE_LINUX_TRUE@ raw16toraw24 \
+@HAVE_LINUX_TRUE@ raw32toraw24
+
+@ENABLE_VOODOO_TRUE@VOODOO_PROGS = dfbproxy
+@PNG_PROVIDER_TRUE@PNG_PROGS = mkdfiff
+@FREETYPE_PROVIDER_TRUE@FREETYPE_PROGS = mkdgiff
+libdirectfb = ../src/libdirectfb.la
+libfusion = ../lib/fusion/libfusion.la
+libdirect = ../lib/direct/libdirect.la
+libvoodoo = ../lib/voodoo/libvoodoo.la
+dfbdump_SOURCES = dfbdump.c
+dfbdump_LDADD = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect)
+dfbg_SOURCES = dfbg.c
+dfbg_LDADD = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect) $(OSX_LIBS)
+dfbinfo_SOURCES = dfbinfo.c
+dfbinfo_LDADD = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect) $(OSX_LIBS)
+dfbinput_SOURCES = dfbinput.c
+dfbinput_LDADD = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect) $(OSX_LIBS)
+dfbinspector_SOURCES = dfbinspector.c
+dfbinspector_LDADD = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect) $(OSX_LIBS)
+dfblayer_SOURCES = dfblayer.c
+dfblayer_LDADD = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect) $(OSX_LIBS)
+dfbmaster_SOURCES = dfbmaster.c
+dfbmaster_LDADD = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect) $(OSX_LIBS)
+dfbproxy_SOURCES = dfbproxy.c
+dfbproxy_LDADD = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect) $(libvoodoo)
+dfbscreen_SOURCES = dfbscreen.c
+dfbscreen_LDADD = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect) $(OSX_LIBS)
+
+#dfbsummon_SOURCES = dfbsummon.c
+#dfbsummon_LDADD = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect)
+dfbpenmount_SOURCES = dfbpenmount.c
+dfbpenmount_LDADD = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect)
+mkdfiff_SOURCES = mkdfiff.c
+mkdfiff_LDADD = $(LIBPNG) $(libdirect)
+mkdgiff_SOURCES = mkdgiff.c
+mkdgiff_LDADD = $(FREETYPE_LIBS) $(libdirect)
+fusion_bench_SOURCES = fusion_bench.c
+fusion_bench_LDADD = $(libdirectfb) $(libfusion) $(libvoodoo) $(libdirect)
+dfbfx_SOURCES = dfbfx.c
+dfbfx_LDADD = $(libdirect)
+raw15toraw24_SOURCES = raw15toraw24.c
+raw16toraw24_SOURCES = raw16toraw24.c
+raw32toraw24_SOURCES = raw32toraw24.c
+EXTRA_DIST = \
+ README \
+ gendoc.pl \
+ mknames.sh
+
+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 tools/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu tools/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
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+
+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
+dfbdump$(EXEEXT): $(dfbdump_OBJECTS) $(dfbdump_DEPENDENCIES)
+ @rm -f dfbdump$(EXEEXT)
+ $(LINK) $(dfbdump_OBJECTS) $(dfbdump_LDADD) $(LIBS)
+dfbfx$(EXEEXT): $(dfbfx_OBJECTS) $(dfbfx_DEPENDENCIES)
+ @rm -f dfbfx$(EXEEXT)
+ $(LINK) $(dfbfx_OBJECTS) $(dfbfx_LDADD) $(LIBS)
+dfbg$(EXEEXT): $(dfbg_OBJECTS) $(dfbg_DEPENDENCIES)
+ @rm -f dfbg$(EXEEXT)
+ $(LINK) $(dfbg_OBJECTS) $(dfbg_LDADD) $(LIBS)
+dfbinfo$(EXEEXT): $(dfbinfo_OBJECTS) $(dfbinfo_DEPENDENCIES)
+ @rm -f dfbinfo$(EXEEXT)
+ $(LINK) $(dfbinfo_OBJECTS) $(dfbinfo_LDADD) $(LIBS)
+dfbinput$(EXEEXT): $(dfbinput_OBJECTS) $(dfbinput_DEPENDENCIES)
+ @rm -f dfbinput$(EXEEXT)
+ $(LINK) $(dfbinput_OBJECTS) $(dfbinput_LDADD) $(LIBS)
+dfbinspector$(EXEEXT): $(dfbinspector_OBJECTS) $(dfbinspector_DEPENDENCIES)
+ @rm -f dfbinspector$(EXEEXT)
+ $(LINK) $(dfbinspector_OBJECTS) $(dfbinspector_LDADD) $(LIBS)
+dfblayer$(EXEEXT): $(dfblayer_OBJECTS) $(dfblayer_DEPENDENCIES)
+ @rm -f dfblayer$(EXEEXT)
+ $(LINK) $(dfblayer_OBJECTS) $(dfblayer_LDADD) $(LIBS)
+dfbmaster$(EXEEXT): $(dfbmaster_OBJECTS) $(dfbmaster_DEPENDENCIES)
+ @rm -f dfbmaster$(EXEEXT)
+ $(LINK) $(dfbmaster_OBJECTS) $(dfbmaster_LDADD) $(LIBS)
+dfbpenmount$(EXEEXT): $(dfbpenmount_OBJECTS) $(dfbpenmount_DEPENDENCIES)
+ @rm -f dfbpenmount$(EXEEXT)
+ $(LINK) $(dfbpenmount_OBJECTS) $(dfbpenmount_LDADD) $(LIBS)
+dfbproxy$(EXEEXT): $(dfbproxy_OBJECTS) $(dfbproxy_DEPENDENCIES)
+ @rm -f dfbproxy$(EXEEXT)
+ $(LINK) $(dfbproxy_OBJECTS) $(dfbproxy_LDADD) $(LIBS)
+dfbscreen$(EXEEXT): $(dfbscreen_OBJECTS) $(dfbscreen_DEPENDENCIES)
+ @rm -f dfbscreen$(EXEEXT)
+ $(LINK) $(dfbscreen_OBJECTS) $(dfbscreen_LDADD) $(LIBS)
+directfb-csource$(EXEEXT): $(directfb_csource_OBJECTS) $(directfb_csource_DEPENDENCIES)
+ @rm -f directfb-csource$(EXEEXT)
+ $(LINK) $(directfb_csource_OBJECTS) $(directfb_csource_LDADD) $(LIBS)
+fusion_bench$(EXEEXT): $(fusion_bench_OBJECTS) $(fusion_bench_DEPENDENCIES)
+ @rm -f fusion_bench$(EXEEXT)
+ $(LINK) $(fusion_bench_OBJECTS) $(fusion_bench_LDADD) $(LIBS)
+mkdfiff$(EXEEXT): $(mkdfiff_OBJECTS) $(mkdfiff_DEPENDENCIES)
+ @rm -f mkdfiff$(EXEEXT)
+ $(LINK) $(mkdfiff_OBJECTS) $(mkdfiff_LDADD) $(LIBS)
+mkdgiff$(EXEEXT): $(mkdgiff_OBJECTS) $(mkdgiff_DEPENDENCIES)
+ @rm -f mkdgiff$(EXEEXT)
+ $(LINK) $(mkdgiff_OBJECTS) $(mkdgiff_LDADD) $(LIBS)
+raw15toraw24$(EXEEXT): $(raw15toraw24_OBJECTS) $(raw15toraw24_DEPENDENCIES)
+ @rm -f raw15toraw24$(EXEEXT)
+ $(LINK) $(raw15toraw24_OBJECTS) $(raw15toraw24_LDADD) $(LIBS)
+raw16toraw24$(EXEEXT): $(raw16toraw24_OBJECTS) $(raw16toraw24_DEPENDENCIES)
+ @rm -f raw16toraw24$(EXEEXT)
+ $(LINK) $(raw16toraw24_OBJECTS) $(raw16toraw24_LDADD) $(LIBS)
+raw32toraw24$(EXEEXT): $(raw32toraw24_OBJECTS) $(raw32toraw24_DEPENDENCIES)
+ @rm -f raw32toraw24$(EXEEXT)
+ $(LINK) $(raw32toraw24_OBJECTS) $(raw32toraw24_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfbdump.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfbfx.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfbg.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfbinfo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfbinput.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfbinspector.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfblayer.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfbmaster.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfbpenmount.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfbproxy.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfbscreen.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/directfb-csource.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fusion_bench.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mkdfiff.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mkdgiff.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raw15toraw24.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raw16toraw24.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raw32toraw24.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:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+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-binPROGRAMS 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-binPROGRAMS
+
+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: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ 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-binPROGRAMS \
+ 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 uninstall-binPROGRAMS
+
+# 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/tools/README b/Source/DirectFB/tools/README
new file mode 100755
index 0000000..6fc0f32
--- /dev/null
+++ b/Source/DirectFB/tools/README
@@ -0,0 +1,24 @@
+This directory holds some tools that you might find useful ...
+
+ dfb_static_build_example is a shell script that shows how to create
+ a statically linked DirectFB application. Modify the script to
+ adapt it to your needs.
+
+ dfbdump is a simple debugging tool for DirectFB that shows a list of
+ surfaces and windows. It needs the multi-application core.
+
+ dfbg is a utility to configure the background of the DirectFB desktop.
+ It's only useful with the multi-application core. Have a look at
+ the dfbg man-page for more infos.
+
+ directfb-csource creates header files from PNG images. Check the
+ directfb-csource man-page for more details.
+
+ gendoc.pl is a Perl script used to generate HTML documentation from
+ the DirectFB header files.
+
+ raw16toraw24, raw15toraw24 and raw32toraw24 are utilities that help
+ to create screenshots from applications running on the Linux
+ frame buffer. See the file README.screenshots in the toplevel
+ directory to learn how to use them.
+
diff --git a/Source/DirectFB/tools/application.lst b/Source/DirectFB/tools/application.lst
new file mode 100755
index 0000000..0d24fe0
--- /dev/null
+++ b/Source/DirectFB/tools/application.lst
@@ -0,0 +1,15 @@
+# Application Name; executable; arguments
+#PluggIt; ./pluggit; -r 1280x720 -f RGB16 -A 100 -H 20 -F 10
+Doom PIP; ./doom; --destination 0.5,0.0-0.5x0.5
+Doom Full Screen; ./doom
+Emu Odyssey; ./emuodd
+Emu Colecovision; ./emucol
+Emu VCS; ./emuvcs
+Emu Gameboy; ./emugbo
+Emu SMS; ./emusms
+Emu Gamegear; ./emugg
+Emu Genesis; ./emugen
+Emu PCEngine; ./emupce
+Emu MAME; ./emumame
+
+
diff --git a/Source/DirectFB/tools/dfbdump.c b/Source/DirectFB/tools/dfbdump.c
new file mode 100755
index 0000000..c8f89b2
--- /dev/null
+++ b/Source/DirectFB/tools/dfbdump.c
@@ -0,0 +1,928 @@
+/*
+ (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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <directfb.h>
+#include <directfb_strings.h>
+
+#include <direct/clock.h>
+#include <direct/debug.h>
+
+#include <fusion/build.h>
+#include <fusion/fusion.h>
+#include <fusion/object.h>
+#include <fusion/ref.h>
+#include <fusion/shmalloc.h>
+#include <fusion/shm/shm.h>
+#include <fusion/shm/shm_internal.h>
+
+#include <core/core.h>
+#include <core/layer_control.h>
+#include <core/layer_context.h>
+#include <core/layers.h>
+#include <core/layers_internal.h>
+#include <core/surface.h>
+#include <core/surface_buffer.h>
+#include <core/surface_pool.h>
+#include <core/windows.h>
+#include <core/windowstack.h>
+#include <core/windows_internal.h>
+#include <core/wm.h>
+
+static DirectFBPixelFormatNames( format_names );
+
+/**********************************************************************************************************************/
+
+typedef struct {
+ int video;
+ int system;
+ int presys;
+} MemoryUsage;
+
+/**********************************************************************************************************************/
+
+static IDirectFB *dfb;
+
+static MemoryUsage mem;
+
+static bool show_shm;
+static bool show_pools;
+static bool show_allocs;
+static int dump_layer; /* ref or -1 (all) or 0 (none) */
+static int dump_surface; /* ref or -1 (all) or 0 (none) */
+
+/**********************************************************************************************************************/
+
+static DFBBoolean parse_command_line( int argc, char *argv[] );
+
+/**********************************************************************************************************************/
+
+static inline int
+buffer_size( CoreSurface *surface, CoreSurfaceBuffer *buffer, bool video )
+{
+ int i, mem = 0;
+ CoreSurfaceAllocation *allocation;
+
+ fusion_vector_foreach (allocation, i, buffer->allocs) {
+ int size = allocation->size;
+ if (allocation->flags & CSALF_ONEFORALL)
+ size /= surface->num_buffers;
+ if (video) {
+ if (allocation->access[CSAID_GPU])
+ mem += size;
+ }
+ else if (!allocation->access[CSAID_GPU])
+ mem += size;
+ }
+
+ return mem;
+}
+
+static int
+buffer_sizes( CoreSurface *surface, bool video )
+{
+ int i, mem = 0;
+
+ for (i=0; i<surface->num_buffers; i++) {
+ CoreSurfaceBuffer *buffer = surface->buffers[i];
+
+ mem += buffer_size( surface, buffer, video );
+ }
+
+ return mem;
+}
+
+static int
+buffer_locks( CoreSurface *surface, bool video )
+{
+ int i, locks = 0;
+
+ for (i=0; i<surface->num_buffers; i++) {
+ CoreSurfaceBuffer *buffer = surface->buffers[i];
+
+ locks += buffer->locked;
+ }
+
+ return locks;
+}
+
+static bool
+surface_callback( FusionObjectPool *pool,
+ FusionObject *object,
+ void *ctx )
+{
+ DirectResult ret;
+ int i;
+ int refs;
+ CoreSurface *surface = (CoreSurface*) object;
+ MemoryUsage *mem = ctx;
+ int vmem;
+ int smem;
+
+ if (object->state != FOS_ACTIVE)
+ return true;
+
+ ret = fusion_ref_stat( &object->ref, &refs );
+ if (ret) {
+ printf( "Fusion error %d!\n", ret );
+ return false;
+ }
+
+ if (dump_surface && ((dump_surface < 0 && surface->type & CSTF_SHARED) ||
+ (dump_surface == object->ref.multi.id)) && surface->num_buffers)
+ {
+ char buf[32];
+
+ snprintf( buf, sizeof(buf), "dfb_surface_0x%08x", object->ref.multi.id );
+
+ dfb_surface_dump_buffer( surface, CSBR_FRONT, ".", buf );
+ }
+
+#if FUSION_BUILD_MULTI
+ printf( "0x%08x [%3lx] : ", object->ref.multi.id, object->ref.multi.creator );
+#else
+ printf( "N/A : " );
+#endif
+
+ printf( "%3d ", refs );
+
+ printf( "%4d x %4d ", surface->config.size.w, surface->config.size.h );
+
+ for (i=0; format_names[i].format; i++) {
+ if (surface->config.format == format_names[i].format)
+ printf( "%8s ", format_names[i].name );
+ }
+
+ vmem = buffer_sizes( surface, true );
+ smem = buffer_sizes( surface, false );
+
+ mem->video += vmem;
+
+ /* FIXME: assumes all buffers have this flag (or none) */
+ /*if (surface->front_buffer->flags & SBF_FOREIGN_SYSTEM)
+ mem->presys += smem;
+ else*/
+ mem->system += smem;
+
+ if (vmem && vmem < 1024)
+ vmem = 1024;
+
+ if (smem && smem < 1024)
+ smem = 1024;
+
+ printf( "%5dk%c ", vmem >> 10, buffer_locks( surface, true ) ? '*' : ' ' );
+ printf( "%5dk%c ", smem >> 10, buffer_locks( surface, false ) ? '*' : ' ' );
+
+ /* FIXME: assumes all buffers have this flag (or none) */
+// if (surface->front_buffer->flags & SBF_FOREIGN_SYSTEM)
+// printf( "preallocated " );
+
+ if (surface->config.caps & DSCAPS_SYSTEMONLY)
+ printf( "system only " );
+
+ if (surface->config.caps & DSCAPS_VIDEOONLY)
+ printf( "video only " );
+
+ if (surface->config.caps & DSCAPS_INTERLACED)
+ printf( "interlaced " );
+
+ if (surface->config.caps & DSCAPS_DOUBLE)
+ printf( "double " );
+
+ if (surface->config.caps & DSCAPS_TRIPLE)
+ printf( "triple " );
+
+ if (surface->config.caps & DSCAPS_PREMULTIPLIED)
+ printf( "premultiplied" );
+
+ printf( "\n" );
+
+ return true;
+}
+
+static void
+dump_surfaces( void )
+{
+ printf( "\n"
+ "-----------------------------[ Surfaces ]-------------------------------------\n" );
+ printf( "Reference FID . Refs Width Height Format Video System Capabilities\n" );
+ printf( "------------------------------------------------------------------------------\n" );
+
+ dfb_core_enum_surfaces( NULL, surface_callback, &mem );
+
+ printf( " ------ ------\n" );
+ printf( " %6dk %6dk -> %dk total\n",
+ mem.video >> 10, (mem.system + mem.presys) >> 10,
+ (mem.video + mem.system + mem.presys) >> 10);
+}
+
+/**********************************************************************************************************************/
+
+static DFBEnumerationResult
+alloc_callback( CoreSurfaceAllocation *alloc,
+ void *ctx )
+{
+ int i, index;
+ CoreSurface *surface;
+ CoreSurfaceBuffer *buffer;
+
+ D_MAGIC_ASSERT( alloc, CoreSurfaceAllocation );
+
+ buffer = alloc->buffer;
+ D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer );
+
+ surface = buffer->surface;
+ D_MAGIC_ASSERT( surface, CoreSurface );
+
+ printf( "%9lu %8d ", alloc->offset, alloc->size );
+
+ printf( "%4d x %4d ", surface->config.size.w, surface->config.size.h );
+
+ for (i=0; format_names[i].format; i++) {
+ if (surface->config.format == format_names[i].format)
+ printf( "%8s ", format_names[i].name );
+ }
+
+ index = dfb_surface_buffer_index( alloc->buffer );
+
+ printf( " %-5s ",
+ (dfb_surface_get_buffer( surface, CSBR_FRONT ) == buffer) ? "front" :
+ (dfb_surface_get_buffer( surface, CSBR_BACK ) == buffer) ? "back" :
+ (dfb_surface_get_buffer( surface, CSBR_IDLE ) == buffer) ? "idle" : "" );
+
+ printf( direct_serial_check(&alloc->serial, &buffer->serial) ? " * " : " " );
+
+ printf( "%d %2lu ", fusion_vector_size( &buffer->allocs ), surface->resource_id );
+
+ if (surface->type & CSTF_SHARED)
+ printf( "SHARED " );
+ else
+ printf( "PRIVATE " );
+
+ if (surface->type & CSTF_LAYER)
+ printf( "LAYER " );
+
+ if (surface->type & CSTF_WINDOW)
+ printf( "WINDOW " );
+
+ if (surface->type & CSTF_CURSOR)
+ printf( "CURSOR " );
+
+ if (surface->type & CSTF_FONT)
+ printf( "FONT " );
+
+ printf( " " );
+
+ if (surface->type & CSTF_INTERNAL)
+ printf( "INTERNAL " );
+
+ if (surface->type & CSTF_EXTERNAL)
+ printf( "EXTERNAL " );
+
+ printf( " " );
+
+ if (surface->config.caps & DSCAPS_SYSTEMONLY)
+ printf( "system only " );
+
+ if (surface->config.caps & DSCAPS_VIDEOONLY)
+ printf( "video only " );
+
+ if (surface->config.caps & DSCAPS_INTERLACED)
+ printf( "interlaced " );
+
+ if (surface->config.caps & DSCAPS_DOUBLE)
+ printf( "double " );
+
+ if (surface->config.caps & DSCAPS_TRIPLE)
+ printf( "triple " );
+
+ if (surface->config.caps & DSCAPS_PREMULTIPLIED)
+ printf( "premultiplied" );
+
+ printf( "\n" );
+
+ return DFENUM_OK;
+}
+
+static DFBEnumerationResult
+surface_pool_callback( CoreSurfacePool *pool,
+ void *ctx )
+{
+ int length;
+
+ printf( "\n" );
+ printf( "--------------------[ Surface Buffer Allocations in %s ]-------------------%n\n", pool->desc.name, &length );
+ printf( "Offset Length Width Height Format Role Up nA ID Usage Type / Storage / Caps\n" );
+
+ while (length--)
+ putc( '-', stdout );
+
+ printf( "\n" );
+
+ dfb_surface_pool_enumerate( pool, alloc_callback, NULL );
+
+ return DFENUM_OK;
+}
+
+static void
+dump_surface_pools( void )
+{
+ dfb_surface_pools_enumerate( surface_pool_callback, NULL );
+}
+
+/**********************************************************************************************************************/
+
+static DFBEnumerationResult
+surface_pool_info_callback( CoreSurfacePool *pool,
+ void *ctx )
+{
+ int i;
+ unsigned long total = 0;
+ CoreSurfaceAllocation *alloc;
+
+ fusion_vector_foreach (alloc, i, pool->allocs)
+ total += alloc->size;
+
+ printf( "%-20s ", pool->desc.name );
+
+ switch (pool->desc.priority) {
+ case CSPP_DEFAULT:
+ printf( "DEFAULT " );
+ break;
+
+ case CSPP_PREFERED:
+ printf( "PREFERED " );
+ break;
+
+ case CSPP_ULTIMATE:
+ printf( "ULTIMATE " );
+ break;
+
+ default:
+ printf( "unknown " );
+ break;
+ }
+
+ printf( "%6lu/%6luk ", total / 1024, pool->desc.size / 1024 );
+
+ if (pool->desc.types & CSTF_SHARED)
+ printf( "* " );
+ else
+ printf( " " );
+
+
+ if (pool->desc.types & CSTF_INTERNAL)
+ printf( "INT " );
+
+ if (pool->desc.types & CSTF_EXTERNAL)
+ printf( "EXT " );
+
+ if (!(pool->desc.types & (CSTF_INTERNAL | CSTF_EXTERNAL)))
+ printf( " " );
+
+
+ if (pool->desc.types & CSTF_LAYER)
+ printf( "LAYER " );
+ else
+ printf( " " );
+
+ if (pool->desc.types & CSTF_WINDOW)
+ printf( "WINDOW " );
+ else
+ printf( " " );
+
+ if (pool->desc.types & CSTF_CURSOR)
+ printf( "CURSOR " );
+ else
+ printf( " " );
+
+ if (pool->desc.types & CSTF_FONT)
+ printf( "FONT " );
+ else
+ printf( " " );
+
+
+ for (i=CSAID_CPU; i<=CSAID_GPU; i++) {
+ printf( " %c%c%c",
+ (pool->desc.access[i] & CSAF_READ) ? 'r' : '-',
+ (pool->desc.access[i] & CSAF_WRITE) ? 'w' : '-',
+ (pool->desc.access[i] & CSAF_SHARED) ? 's' : '-' );
+ }
+
+ for (i=CSAID_LAYER0; i<=CSAID_LAYER2; i++) {
+ printf( " %c%c%c",
+ (pool->desc.access[i] & CSAF_READ) ? 'r' : '-',
+ (pool->desc.access[i] & CSAF_WRITE) ? 'w' : '-',
+ (pool->desc.access[i] & CSAF_SHARED) ? 's' : '-' );
+ }
+
+ printf( "\n" );
+
+ return DFENUM_OK;
+}
+
+static void
+dump_surface_pool_info( void )
+{
+ printf( "\n" );
+ printf( "-------------------------------------[ Surface Buffer Pools ]------------------------------------\n" );
+ printf( "Name Priority Used/Capacity S I/E Resource Type Support CPU GPU Layer 0 - 2\n" );
+ printf( "-------------------------------------------------------------------------------------------------\n" );
+
+ dfb_surface_pools_enumerate( surface_pool_info_callback, NULL );
+}
+
+/**********************************************************************************************************************/
+
+static bool
+context_callback( FusionObjectPool *pool,
+ FusionObject *object,
+ void *ctx )
+{
+ DirectResult ret;
+ int i;
+ int refs;
+ int level;
+ CoreLayer *layer = (CoreLayer*) ctx;
+ CoreLayerContext *context = (CoreLayerContext*) object;
+ CoreLayerRegion *region = NULL;
+ CoreSurface *surface = NULL;
+
+ if (object->state != FOS_ACTIVE)
+ return true;
+
+ if (context->layer_id != dfb_layer_id( layer ))
+ return true;
+
+ ret = fusion_ref_stat( &object->ref, &refs );
+ if (ret) {
+ printf( "Fusion error %d!\n", ret );
+ return false;
+ }
+
+ if (dump_layer && (dump_layer < 0 || dump_layer == object->ref.multi.id)) {
+ if (dfb_layer_context_get_primary_region( context, false, &region ) == DFB_OK) {
+ if (dfb_layer_region_get_surface( region, &surface ) == DFB_OK) {
+ if (surface->num_buffers) {
+ char buf[32];
+
+ snprintf( buf, sizeof(buf), "dfb_layer_context_0x%08x", object->ref.multi.id );
+
+ dfb_surface_dump_buffer( surface, CSBR_FRONT, ".", buf );
+ }
+
+ dfb_surface_unref( surface );
+ }
+ }
+ }
+
+#if FUSION_BUILD_MULTI
+ printf( "0x%08x [%3lx] : ", object->ref.multi.id, object->ref.multi.creator );
+#else
+ printf( "N/A : " );
+#endif
+
+ printf( "%3d ", refs );
+
+ printf( "%4d x %4d ", context->config.width, context->config.height );
+
+ for (i=0; format_names[i].format; i++) {
+ if (context->config.pixelformat == format_names[i].format) {
+ printf( "%-8s ", format_names[i].name );
+ break;
+ }
+ }
+
+ if (!format_names[i].format)
+ printf( "unknown " );
+
+ printf( "%.1f, %.1f -> %.1f, %.1f ",
+ context->screen.location.x, context->screen.location.y,
+ context->screen.location.x + context->screen.location.w,
+ context->screen.location.y + context->screen.location.h );
+
+ printf( "%2d ", fusion_vector_size( &context->regions ) );
+
+ printf( context->active ? "(*) " : " " );
+
+ if (context == layer->shared->contexts.primary)
+ printf( "SHARED " );
+ else
+ printf( "PRIVATE " );
+
+ if (context->rotation)
+ printf( "ROTATED %d ", context->rotation);
+
+ if (dfb_layer_get_level( layer, &level ))
+ printf( "N/A" );
+ else
+ printf( "%3d", level );
+
+ printf( "\n" );
+
+ return true;
+}
+
+static void
+dump_contexts( CoreLayer *layer )
+{
+ if (fusion_vector_size( &layer->shared->contexts.stack ) == 0)
+ return;
+
+ printf( "\n"
+ "----------------------------------[ Contexts of Layer %d ]----------------------------------------\n", dfb_layer_id( layer ));
+ printf( "Reference FID . Refs Width Height Format Location on screen Regions Active Info Level\n" );
+ printf( "-------------------------------------------------------------------------------------------------\n" );
+
+ dfb_core_enum_layer_contexts( NULL, context_callback, layer );
+}
+
+static DFBEnumerationResult
+window_callback( CoreWindow *window,
+ void *ctx )
+{
+ DirectResult ret;
+ int refs;
+ CoreWindowConfig *config = &window->config;
+ DFBRectangle *bounds = &config->bounds;
+
+ ret = fusion_ref_stat( &window->object.ref, &refs );
+ if (ret) {
+ printf( "Fusion error %d!\n", ret );
+ return DFENUM_OK;
+ }
+
+#if FUSION_BUILD_MULTI
+ printf( "0x%08x [%3lx] : ", window->object.ref.multi.id, window->object.ref.multi.creator );
+#else
+ printf( "N/A : " );
+#endif
+
+ printf( "%3d ", refs );
+
+ printf( "%4d, %4d ", bounds->x, bounds->y );
+
+ printf( "%4d x %4d ", bounds->w, bounds->h );
+
+ printf( "0x%02x ", config->opacity );
+
+ printf( "%5d ", window->id );
+
+ switch (config->stacking) {
+ case DWSC_UPPER:
+ printf( "^ " );
+ break;
+ case DWSC_MIDDLE:
+ printf( "- " );
+ break;
+ case DWSC_LOWER:
+ printf( "v " );
+ break;
+ default:
+ printf( "? " );
+ break;
+ }
+
+ if (window->caps & DWCAPS_ALPHACHANNEL)
+ printf( "alphachannel " );
+
+ if (window->caps & DWCAPS_INPUTONLY)
+ printf( "input only " );
+
+ if (window->caps & DWCAPS_DOUBLEBUFFER)
+ printf( "double buffer " );
+
+ if (config->options & DWOP_GHOST)
+ printf( "GHOST " );
+
+ if (DFB_WINDOW_FOCUSED( window ))
+ printf( "FOCUSED " );
+
+ if (DFB_WINDOW_DESTROYED( window ))
+ printf( "DESTROYED " );
+
+ if (window->config.rotation)
+ printf( "ROTATED %d ", window->config.rotation);
+
+ printf( "\n" );
+
+ return DFENUM_OK;
+}
+
+static void
+dump_windows( CoreLayer *layer )
+{
+ DFBResult ret;
+ CoreLayerShared *shared;
+ CoreLayerContext *context;
+ CoreWindowStack *stack;
+
+ shared = layer->shared;
+
+ ret = fusion_skirmish_prevail( &shared->lock );
+ if (ret) {
+ D_DERROR( ret, "DirectFB/Dump: Could not lock the shared layer data!\n" );
+ return;
+ }
+
+ context = layer->shared->contexts.primary;
+ if (!context) {
+ fusion_skirmish_dismiss( &shared->lock );
+ return;
+ }
+
+ stack = dfb_layer_context_windowstack( context );
+ if (!stack) {
+ fusion_skirmish_dismiss( &shared->lock );
+ return;
+ }
+
+ dfb_windowstack_lock( stack );
+
+ if (stack->num) {
+ printf( "\n"
+ "-----------------------------------[ Windows of Layer %d ]-----------------------------------------\n", dfb_layer_id( layer ) );
+ printf( "Reference FID . Refs X Y Width Height Opacity ID Capabilities State & Options\n" );
+ printf( "--------------------------------------------------------------------------------------------------\n" );
+
+ dfb_wm_enum_windows( stack, window_callback, NULL );
+ }
+
+ dfb_windowstack_unlock( stack );
+
+ fusion_skirmish_dismiss( &shared->lock );
+}
+
+static DFBEnumerationResult
+layer_callback( CoreLayer *layer,
+ void *ctx)
+{
+ dump_windows( layer );
+ dump_contexts( layer );
+
+ return DFENUM_OK;
+}
+
+static void
+dump_layers( void )
+{
+ dfb_layers_enumerate( layer_callback, NULL );
+}
+
+/**********************************************************************************************************************/
+
+#if FUSION_BUILD_MULTI
+static DirectEnumerationResult
+dump_shmpool( FusionSHMPool *pool,
+ void *ctx )
+{
+ DFBResult ret;
+ SHMemDesc *desc;
+ unsigned int total = 0;
+ int length;
+ FusionSHMPoolShared *shared = pool->shared;
+
+ printf( "\n" );
+ printf( "----------------------------[ Shared Memory in %s ]----------------------------%n\n", shared->name, &length );
+ printf( " Size Address Offset Function FusionID\n" );
+
+ while (length--)
+ putc( '-', stdout );
+
+ putc( '\n', stdout );
+
+ ret = fusion_skirmish_prevail( &shared->lock );
+ if (ret) {
+ D_DERROR( ret, "Could not lock shared memory pool!\n" );
+ return DFENUM_OK;
+ }
+
+ if (shared->allocs) {
+ direct_list_foreach (desc, shared->allocs) {
+ printf( " %9zu bytes at %p [%8lu] in %-30s [%3lx] (%s: %u)\n",
+ desc->bytes, desc->mem, (ulong)desc->mem - (ulong)shared->heap,
+ desc->func, desc->fid, desc->file, desc->line );
+
+ total += desc->bytes;
+ }
+
+ printf( " -------\n %7dk total\n", total >> 10 );
+ }
+
+ printf( "\nShared memory file size: %dk\n", shared->heap->size >> 10 );
+
+ fusion_skirmish_dismiss( &shared->lock );
+
+ return DFENUM_OK;
+}
+
+static void
+dump_shmpools( void )
+{
+ fusion_shm_enum_pools( dfb_core_world(NULL), dump_shmpool, NULL );
+}
+#endif
+
+/**********************************************************************************************************************/
+
+int
+main( int argc, char *argv[] )
+{
+ DFBResult ret;
+ long long millis;
+ long int seconds, minutes, hours, days;
+
+ char *buffer = malloc( 0x100000 );
+
+ setvbuf( stdout, buffer, _IOFBF, 0x100000 );
+
+ /* Initialize DirectFB. */
+ ret = DirectFBInit( &argc, &argv );
+ if (ret) {
+ DirectFBError( "DirectFBInit", 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", ret );
+ return -3;
+ }
+
+ millis = direct_clock_get_millis();
+
+ seconds = millis / 1000;
+ millis %= 1000;
+
+ minutes = seconds / 60;
+ seconds %= 60;
+
+ hours = minutes / 60;
+ minutes %= 60;
+
+ days = hours / 24;
+ hours %= 24;
+
+ switch (days) {
+ case 0:
+ printf( "\nDirectFB uptime: %02ld:%02ld:%02ld\n",
+ hours, minutes, seconds );
+ break;
+
+ case 1:
+ printf( "\nDirectFB uptime: %ld day, %02ld:%02ld:%02ld\n",
+ days, hours, minutes, seconds );
+ break;
+
+ default:
+ printf( "\nDirectFB uptime: %ld days, %02ld:%02ld:%02ld\n",
+ days, hours, minutes, seconds );
+ break;
+ }
+
+ dump_surfaces();
+ fflush( stdout );
+
+ dump_layers();
+ fflush( stdout );
+
+#if FUSION_BUILD_MULTI
+ if (show_shm) {
+ printf( "\n" );
+ dump_shmpools();
+ fflush( stdout );
+ }
+#endif
+
+ if (show_pools) {
+ printf( "\n" );
+ dump_surface_pool_info();
+ fflush( stdout );
+ }
+
+ if (show_allocs) {
+ printf( "\n" );
+ dump_surface_pools();
+ fflush( stdout );
+ }
+
+ printf( "\n" );
+
+ /* DirectFB deinitialization. */
+ if (dfb)
+ dfb->Release( dfb );
+
+ return ret;
+}
+
+/**********************************************************************************************************************/
+
+static void
+print_usage (const char *prg_name)
+{
+ fprintf (stderr, "\nDirectFB Dump (version %s)\n\n", DIRECTFB_VERSION);
+ fprintf (stderr, "Usage: %s [options]\n\n", prg_name);
+ fprintf (stderr, "Options:\n");
+ fprintf (stderr, " -s, --shm Show shared memory pool content (if debug enabled)\n");
+ fprintf (stderr, " -p, --pools Show information about surface pools\n");
+ fprintf (stderr, " -a, --allocs Show surface buffer allocations in surface pools\n");
+ fprintf (stderr, " -dl, --dumplayer Dump surfaces of layer contexts into files (dfb_layer_context_REFID...)\n");
+ fprintf (stderr, " -ds, --dumpsurface Dump surfaces (front buffers) into files (dfb_surface_REFID...)\n");
+ fprintf (stderr, " -h, --help Show this help message\n");
+ fprintf (stderr, " -v, --version Print version information\n");
+ fprintf (stderr, "\n");
+}
+
+static DFBBoolean
+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 DFB_FALSE;
+ }
+
+ if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
+ fprintf (stderr, "dfbdump version %s\n", DIRECTFB_VERSION);
+ return DFB_FALSE;
+ }
+
+ if (strcmp (arg, "-s") == 0 || strcmp (arg, "--shm") == 0) {
+ show_shm = true;
+ continue;
+ }
+
+ if (strcmp (arg, "-p") == 0 || strcmp (arg, "--pools") == 0) {
+ show_pools = true;
+ continue;
+ }
+
+ if (strcmp (arg, "-a") == 0 || strcmp (arg, "--allocs") == 0) {
+ show_allocs = true;
+ continue;
+ }
+
+ if (strcmp (arg, "-dl") == 0 || strcmp (arg, "--dumplayer") == 0) {
+ dump_layer = -1;
+ continue;
+ }
+
+ if (strcmp (arg, "-ds") == 0 || strcmp (arg, "--dumpsurface") == 0) {
+ dump_surface = -1;
+ continue;
+ }
+
+ print_usage (argv[0]);
+
+ return DFB_FALSE;
+ }
+
+ return DFB_TRUE;
+}
+
diff --git a/Source/DirectFB/tools/dfbfx.c b/Source/DirectFB/tools/dfbfx.c
new file mode 100755
index 0000000..2d0cf1a
--- /dev/null
+++ b/Source/DirectFB/tools/dfbfx.c
@@ -0,0 +1,630 @@
+/*
+ (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 <unistd.h>
+#include <stdio.h>
+
+#include <directfb.h>
+#include <directfb_strings.h>
+
+#include <core/state.h>
+
+#include <gfx/convert.h>
+
+
+static DirectFBSurfaceBlittingFlagsNames( m_bflags );
+static DirectFBSurfaceBlendFunctionNames( m_bfuncs );
+
+#define MODULATE(a,b) do { (a) = (((int)(a) * ((int)(b) + 1)) >> 8); } while (0)
+
+
+static DFBColor
+blit_pixel( CardState *state, DFBColor src, DFBColor dst )
+{
+ /* Scratch for blending stage. */
+ DFBColor x;
+
+ /*
+ * Input => short circuit to Output? (simple blits)
+ */
+
+ /* Without any flag the source is simply copied. */
+ if (!state->blittingflags)
+ return src;
+
+ /* Source color keying is the 2nd simplest operation. */
+ if (state->blittingflags & DSBLIT_SRC_COLORKEY) {
+ /* If the source matches the color key, keep the destination. */
+ if (PIXEL_RGB32(src.r,src.g,src.b) == state->src_colorkey)
+ return dst;
+ }
+
+ /* Destination color keying already requires reading the destination. */
+ if (state->blittingflags & DSBLIT_DST_COLORKEY) {
+ /* If the destination does not match the color key, keep the destination. */
+ if (PIXEL_RGB32(dst.r,dst.g,dst.b) != state->dst_colorkey)
+ return dst;
+ }
+
+ /*
+ * Modulation stage
+ */
+
+ /* Modulate source alpha value with global alpha factor? */
+ if (state->blittingflags & DSBLIT_BLEND_COLORALPHA) {
+ /* Combine with source alpha value... */
+ if (state->blittingflags & DSBLIT_BLEND_ALPHACHANNEL)
+ MODULATE( src.a, state->color.a );
+ else
+ /* ...or replace it. */
+ src.a = state->color.a;
+ }
+
+ /* Modulate source colors with global color factors? */
+ if (state->blittingflags & DSBLIT_COLORIZE) {
+ MODULATE( src.r, state->color.r );
+ MODULATE( src.g, state->color.g );
+ MODULATE( src.b, state->color.b );
+ }
+
+ /*
+ * Premultiplication stage
+ */
+
+ /* Premultiply source colors with (modulated) source alpha value? */
+ if (state->blittingflags & DSBLIT_SRC_PREMULTIPLY) {
+ MODULATE( src.r, src.a );
+ MODULATE( src.g, src.a );
+ MODULATE( src.b, src.a );
+ }
+
+ /* Premultiply source colors with global alpha factor only? */
+ if (state->blittingflags & DSBLIT_SRC_PREMULTCOLOR) {
+ MODULATE( src.r, state->color.a );
+ MODULATE( src.g, state->color.a );
+ MODULATE( src.b, state->color.a );
+ }
+
+ /* Premultiply destination colors with destination alpha value? */
+ if (state->blittingflags & DSBLIT_DST_PREMULTIPLY) {
+ MODULATE( dst.r, dst.a );
+ MODULATE( dst.g, dst.a );
+ MODULATE( dst.b, dst.a );
+ }
+
+ /*
+ * XOR comes right before blending, after load, modulate and premultiply.
+ */
+ if (state->blittingflags & DSBLIT_XOR) {
+ src.a ^= dst.a;
+ src.r ^= dst.r;
+ src.g ^= dst.g;
+ src.b ^= dst.b;
+ }
+
+ /*
+ * Blending stage
+ */
+
+ /* Initialize scratch with source values, modify the copy according to the source blend function.
+ Could be done better by writing to the scratch only once after the calculation. */
+ x = src;
+
+ /* Blend scratch (source copy) and destination values accordingly. */
+ if (state->blittingflags & (DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_BLEND_COLORALPHA)) {
+ /* Apply the source blend function to the scratch. */
+ switch (state->src_blend) {
+ /* Sargb *= 0.0 */
+ case DSBF_ZERO:
+ x.a = x.r = x.g = x.b = 0;
+ break;
+
+ /* Sargb *= 1.0 */
+ case DSBF_ONE:
+ break;
+
+ /* Sargb *= Sargb */
+ case DSBF_SRCCOLOR:
+ MODULATE( x.a, src.a );
+ MODULATE( x.r, src.r );
+ MODULATE( x.g, src.g );
+ MODULATE( x.b, src.b );
+ break;
+
+ /* Sargb *= 1.0 - Sargb */
+ case DSBF_INVSRCCOLOR:
+ MODULATE( x.a, src.a ^ 0xff );
+ MODULATE( x.r, src.r ^ 0xff );
+ MODULATE( x.g, src.g ^ 0xff );
+ MODULATE( x.b, src.b ^ 0xff );
+ break;
+
+ /* Sargb *= Saaaa */
+ case DSBF_SRCALPHA:
+ MODULATE( x.a, src.a );
+ MODULATE( x.r, src.a );
+ MODULATE( x.g, src.a );
+ MODULATE( x.b, src.a );
+ break;
+
+ /* Sargb *= 1.0 - Saaaa */
+ case DSBF_INVSRCALPHA:
+ MODULATE( x.a, src.a ^ 0xff );
+ MODULATE( x.r, src.a ^ 0xff );
+ MODULATE( x.g, src.a ^ 0xff );
+ MODULATE( x.b, src.a ^ 0xff );
+ break;
+
+ /* Sargb *= Daaaa */
+ case DSBF_DESTALPHA:
+ MODULATE( x.a, dst.a );
+ MODULATE( x.r, dst.a );
+ MODULATE( x.g, dst.a );
+ MODULATE( x.b, dst.a );
+ break;
+
+ /* Sargb *= 1.0 - Daaaa */
+ case DSBF_INVDESTALPHA:
+ MODULATE( x.a, dst.a ^ 0xff );
+ MODULATE( x.r, dst.a ^ 0xff );
+ MODULATE( x.g, dst.a ^ 0xff );
+ MODULATE( x.b, dst.a ^ 0xff );
+ break;
+
+ /* Sargb *= Dargb */
+ case DSBF_DESTCOLOR:
+ MODULATE( x.a, dst.a );
+ MODULATE( x.r, dst.r );
+ MODULATE( x.g, dst.g );
+ MODULATE( x.b, dst.b );
+ break;
+
+ /* Sargb *= 1.0 - Dargb */
+ case DSBF_INVDESTCOLOR:
+ MODULATE( x.a, dst.a ^ 0xff );
+ MODULATE( x.r, dst.r ^ 0xff );
+ MODULATE( x.g, dst.g ^ 0xff );
+ MODULATE( x.b, dst.b ^ 0xff );
+ break;
+
+ /* ??? */
+ case DSBF_SRCALPHASAT:
+ D_UNIMPLEMENTED();
+ break;
+
+ default:
+ D_BUG( "unknown blend function %d", state->src_blend );
+ }
+
+ /* Apply the destination blend function. */
+ switch (state->dst_blend) {
+ /* Dargb *= 0.0 */
+ case DSBF_ZERO:
+ dst.a = dst.r = dst.g = dst.b = 0;
+ break;
+
+ /* Dargb *= 1.0 */
+ case DSBF_ONE:
+ break;
+
+ /* Dargb *= Sargb */
+ case DSBF_SRCCOLOR:
+ MODULATE( dst.a, src.a );
+ MODULATE( dst.r, src.r );
+ MODULATE( dst.g, src.g );
+ MODULATE( dst.b, src.b );
+ break;
+
+ /* Dargb *= 1.0 - Sargb */
+ case DSBF_INVSRCCOLOR:
+ MODULATE( dst.a, src.a ^ 0xff );
+ MODULATE( dst.r, src.r ^ 0xff );
+ MODULATE( dst.g, src.g ^ 0xff );
+ MODULATE( dst.b, src.b ^ 0xff );
+ break;
+
+ /* Dargb *= Saaaa */
+ case DSBF_SRCALPHA:
+ MODULATE( dst.a, src.a );
+ MODULATE( dst.r, src.a );
+ MODULATE( dst.g, src.a );
+ MODULATE( dst.b, src.a );
+ break;
+
+ /* Dargb *= 1.0 - Saaaa */
+ case DSBF_INVSRCALPHA:
+ MODULATE( dst.a, src.a ^ 0xff );
+ MODULATE( dst.r, src.a ^ 0xff );
+ MODULATE( dst.g, src.a ^ 0xff );
+ MODULATE( dst.b, src.a ^ 0xff );
+ break;
+
+ /* Dargb *= Daaaa */
+ case DSBF_DESTALPHA:
+ MODULATE( dst.r, dst.a );
+ MODULATE( dst.g, dst.a );
+ MODULATE( dst.b, dst.a );
+ MODULATE( dst.a, dst.a ); //
+ break;
+
+ /* Dargb *= 1.0 - Daaaa */
+ case DSBF_INVDESTALPHA:
+ MODULATE( dst.r, dst.a ^ 0xff );
+ MODULATE( dst.g, dst.a ^ 0xff );
+ MODULATE( dst.b, dst.a ^ 0xff );
+ MODULATE( dst.a, dst.a ^ 0xff ); //
+ break;
+
+ /* Dargb *= Dargb */
+ case DSBF_DESTCOLOR:
+ MODULATE( dst.r, dst.r );
+ MODULATE( dst.g, dst.g );
+ MODULATE( dst.b, dst.b );
+ MODULATE( dst.a, dst.a ); //
+ break;
+
+ /* Dargb *= 1.0 - Dargb */
+ case DSBF_INVDESTCOLOR:
+ MODULATE( dst.r, dst.r ^ 0xff );
+ MODULATE( dst.g, dst.g ^ 0xff );
+ MODULATE( dst.b, dst.b ^ 0xff );
+ MODULATE( dst.a, dst.a ^ 0xff ); //
+ break;
+
+ /* ??? */
+ case DSBF_SRCALPHASAT:
+ D_UNIMPLEMENTED();
+ break;
+
+ default:
+ D_BUG( "unknown blend function %d", state->dst_blend );
+ }
+
+ /*
+ * Add blended destination values to the scratch.
+ */
+ x.a += dst.a;
+ x.r += dst.r;
+ x.g += dst.g;
+ x.b += dst.b;
+ }
+
+ /* Better not use the conversion from premultiplied to non-premultiplied! */
+ if (state->blittingflags & DSBLIT_DEMULTIPLY) {
+ x.r = ((int)x.r << 8) / ((int)x.a + 1);
+ x.g = ((int)x.g << 8) / ((int)x.a + 1);
+ x.b = ((int)x.b << 8) / ((int)x.a + 1);
+ }
+
+ /*
+ * Output
+ */
+ return x;
+}
+
+/**********************************************************************************************************************/
+
+static const char *
+blend_to_string( DFBSurfaceBlendFunction func )
+{
+ int i;
+
+ for (i=0; i<D_ARRAY_SIZE(m_bfuncs); i++) {
+ if (m_bfuncs[i].function == func)
+ return m_bfuncs[i].name;
+ }
+
+ return "<unknown>";
+}
+
+/**********************************************************************************************************************/
+
+static void
+parse_flags( const char *arg, DFBSurfaceBlittingFlags *ret_flags )
+{
+ int i;
+
+ *ret_flags = DSBLIT_NOFX;
+
+ for (i=0; i<D_ARRAY_SIZE(m_bflags); i++) {
+ if (strcasestr( arg, m_bflags[i].name ))
+ *ret_flags |= m_bflags[i].flag;
+ }
+}
+
+static bool
+parse_color( const char *arg, DFBColor *ret_color )
+{
+ char *error;
+ u32 argb;
+
+ if (arg[0] == '#')
+ arg++;
+
+ if (arg[0] == '0' && arg[1] == 'x')
+ arg+=2;
+
+ argb = strtoul( arg, &error, 16 );
+
+ if (*error) {
+ fprintf( stderr, "Invalid characters in color string: '%s'\n", error );
+ return false;
+ }
+
+ ret_color->a = argb >> 24;
+ ret_color->r = (argb & 0xFF0000) >> 16;
+ ret_color->g = (argb & 0xFF00) >> 8;
+ ret_color->b = argb & 0xFF;
+
+ return true;
+}
+
+static bool
+parse_blend_func( const char *arg, DFBSurfaceBlendFunction *ret_func )
+{
+ int i;
+
+ for (i=0; i<D_ARRAY_SIZE(m_bfuncs); i++) {
+ if (!strcasecmp( arg, m_bfuncs[i].name )) {
+ *ret_func = m_bfuncs[i].function;
+ return true;
+ }
+ }
+
+ fprintf( stderr, "Unknown blend function: '%s'\n", arg );
+
+ return false;
+}
+
+static void
+print_usage (const char *prg_name)
+{
+ int i;
+
+ fprintf( stderr, "\n"
+ "DirectFB Blitting FX Demonstrator (version %s)\n"
+ "\n"
+ "Usage: %s [options]\n"
+ "\n"
+ "Options:\n"
+ " -b, --blittingflags <flag>[,<flag>] Set blitting flags\n"
+ " -D, --destination <0xAARRGGBB> Set destination value (ARGB32 in hex)\n"
+ " -S, --source <0xAARRGGBB> Set source value (ARGB32 in hex)\n"
+ " -c, --color <0xAARRGGBB> Set color (ARGB32 in hex)\n"
+ " -s, --srcblend <func> Set source blend function\n"
+ " -d, --dstblend <func> Set destination blend function\n"
+ "\n"
+ "Blitting flags:\n", DIRECTFB_VERSION, prg_name );
+
+ for (i=0; i<D_ARRAY_SIZE(m_bflags)-1; i++) {
+ fprintf( stderr, " %-20s", m_bflags[i].name );
+
+ if (i % 4 == 3)
+ fprintf( stderr, "\n" );
+ }
+
+ fprintf( stderr, "(any other value means NOFX)\n"
+ "\n"
+ "Blend functions:" );
+
+ for (i=0; i<D_ARRAY_SIZE(m_bfuncs)-1; i++) {
+ if (i % 4 == 0)
+ fprintf( stderr, "\n" );
+
+ fprintf( stderr, " %-20s", m_bfuncs[i].name );
+ }
+
+ fprintf( stderr, "\n" );
+}
+
+static DFBBoolean
+parse_command_line( int argc, char *argv[], CardState *state, DFBColor *dest, DFBColor *source )
+{
+ int i;
+
+ /* Parse command line arguments. */
+ for (i=1; i<argc; i++) {
+ const char *arg = argv[i];
+
+ if (strcmp (arg, "-h") == 0 || strcmp (arg, "--help") == 0) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
+ fprintf (stderr, "dfbfx version %s\n", DIRECTFB_VERSION);
+ return DFB_FALSE;
+ }
+
+ if (strcmp (arg, "-b") == 0 || strcmp (arg, "--blittingflags") == 0) {
+ if (++i == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ parse_flags( argv[i], &state->blittingflags );
+
+ continue;
+ }
+
+ if (strcmp (arg, "-D") == 0 || strcmp (arg, "--destination") == 0) {
+ if (++i == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (parse_color( argv[i], dest ))
+ continue;
+ }
+
+ if (strcmp (arg, "-S") == 0 || strcmp (arg, "--source") == 0) {
+ if (++i == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (parse_color( argv[i], source ))
+ continue;
+ }
+
+ if (strcmp (arg, "-c") == 0 || strcmp (arg, "--color") == 0) {
+ if (++i == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (parse_color( argv[i], &state->color ))
+ continue;
+ }
+
+ if (strcmp (arg, "-s") == 0 || strcmp (arg, "--srcblend") == 0) {
+ if (++i == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (parse_blend_func( argv[i], &state->src_blend ))
+ continue;
+ }
+
+ if (strcmp (arg, "-d") == 0 || strcmp (arg, "--dstblend") == 0) {
+ if (++i == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (parse_blend_func( argv[i], &state->dst_blend ))
+ continue;
+ }
+
+ print_usage (argv[0]);
+
+ return DFB_FALSE;
+ }
+
+ return DFB_TRUE;
+}
+
+/**********************************************************************************************************************/
+
+int
+main( int argc, char *argv[] )
+{
+ int i;
+ CardState state = { .blittingflags = DSBLIT_NOFX };
+ DFBColor result;
+
+ /* Initialize sample source and destination values. */
+ //DFBColor src = { 0x93, 0x93, 0x93, 0x93 };
+ DFBColor dst = { 0xf0, 0xe0, 0xe0, 0xe0 };
+
+#define DRAWSTRING_PREMULT_FONT 1
+
+ /* Initialize default rendering state. */
+#if DRAWSTRING_PREMULT_FONT
+ /* Initialize sample source and destination values. */
+ DFBColor src = { 0x93, 0x93, 0x93, 0x93 };
+
+ state.blittingflags = DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_COLORIZE;
+ state.src_blend = DSBF_ONE;
+ state.dst_blend = DSBF_INVSRCALPHA;
+ state.color.a = 0x81;
+ state.color.r = 0xff;
+ state.color.g = 0x80;
+ state.color.b = 0x23;
+#elif DRAWSTRING_NONPREMULT_ALPHADROP
+ /* Initialize sample source and destination values. */
+ DFBColor src = { 0x93, 0xff, 0xff, 0xff };
+
+ state.blittingflags = DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_COLORIZE;
+ state.src_blend = DSBF_SRCALPHA;
+ state.dst_blend = DSBF_INVSRCALPHA;
+ state.color.a = 0x81;
+ state.color.r = 0xff;
+ state.color.g = 0x80;
+ state.color.b = 0x23;
+#endif
+
+ /* Startup the blitting FX demonstrator. */
+ printf( "\ndfbfx v" DIRECTFB_VERSION "\n\n" );
+
+ if (!parse_command_line( argc, argv, &state, &dst, &src ))
+ return -1;
+
+ /* Show blitting flags being used. */
+ printf( " blit_flags: " );
+ for (i=0; i<D_ARRAY_SIZE(m_bflags); i++) {
+ if (D_FLAGS_IS_SET( state.blittingflags, m_bflags[i].flag ))
+ printf( "%s ", m_bflags[i].name );
+ }
+ printf( "\n" );
+
+ /* Blending needs source and destination blend function. */
+ if (state.blittingflags & (DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_BLEND_COLORALPHA)) {
+ printf( " src_blend: %s\n", blend_to_string( state.src_blend ) );
+ printf( " dst_blend: %s\n", blend_to_string( state.dst_blend ) );
+ }
+
+ /* These require one or more global values via the color (for modulation). */
+ if (state.blittingflags & (DSBLIT_BLEND_COLORALPHA | DSBLIT_SRC_PREMULTCOLOR | DSBLIT_COLORIZE))
+ printf( " color: %02x %02x %02x %02x\n",
+ state.color.a, state.color.r, state.color.g, state.color.b );
+
+ /* Show original source values. */
+ printf( " src: %02x %02x %02x %02x\n", src.a, src.r, src.g, src.b );
+
+ /* Show source color key. */
+ if (state.blittingflags & DSBLIT_SRC_COLORKEY)
+ printf( " src_key: %02x %02x %02x\n",
+ state.src_colorkey >> 16, (state.src_colorkey >> 8) & 0xff, state.src_colorkey & 0xff );
+
+ /* Show original destination values. */
+ printf( " dst: %02x %02x %02x %02x\n", dst.a, dst.r, dst.g, dst.b );
+
+ /* Show destination color key. */
+ if (state.blittingflags & DSBLIT_DST_COLORKEY)
+ printf( " dst_key: %02x %02x %02x\n",
+ state.dst_colorkey >> 16, (state.dst_colorkey >> 8) & 0xff, state.dst_colorkey & 0xff );
+
+ /* Do magic... */
+ result = blit_pixel( &state, src, dst );
+
+ /* Show resulting values. */
+ printf( " result: %02x %02x %02x %02x\n", result.a, result.r, result.g, result.b );
+
+ return 0;
+}
+
diff --git a/Source/DirectFB/tools/dfbg.c b/Source/DirectFB/tools/dfbg.c
new file mode 100755
index 0000000..eee11a4
--- /dev/null
+++ b/Source/DirectFB/tools/dfbg.c
@@ -0,0 +1,280 @@
+/*
+ (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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <directfb.h>
+
+
+/*****************************************************************************/
+
+static IDirectFB *dfb = NULL;
+static IDirectFBDisplayLayer *layer = NULL;
+
+static const char *filename = NULL;
+static DFBBoolean color = DFB_FALSE;
+static DFBBoolean tiled = DFB_FALSE;
+
+
+/*****************************************************************************/
+
+static DFBBoolean parse_command_line ( int argc, char *argv[] );
+static void set_background_color ( void );
+static void set_background_image ( void );
+
+/*****************************************************************************/
+
+int
+main( int argc, char *argv[] )
+{
+ DFBResult ret;
+
+ /* 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;
+
+ DirectFBSetOption( "bg-none", NULL );
+ DirectFBSetOption( "no-cursor", NULL );
+
+ /* Create the super interface. */
+ ret = DirectFBCreate( &dfb );
+ if (ret) {
+ DirectFBError( "DirectFBCreate() failed", ret );
+ return -3;
+ }
+
+ /* Get the primary display layer. */
+ ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer );
+ if (ret) {
+ DirectFBError( "IDirectFB::GetDisplayLayer() failed", ret );
+ dfb->Release( dfb );
+ return -4;
+ }
+
+ /* Acquire administrative cooperative level. */
+ ret = layer->SetCooperativeLevel( layer, DLSCL_ADMINISTRATIVE );
+ if (ret) {
+ DirectFBError( "IDirectFBDisplayLayer::SetCooperativeLevel() failed", ret );
+ layer->Release( layer );
+ dfb->Release( dfb );
+ return -5;
+ }
+
+ /* Set the background according to the users wishes. */
+ if (color)
+ set_background_color();
+ else
+ set_background_image();
+
+ /* Release the display layer. */
+ layer->Release( layer );
+
+ /* Release the super interface. */
+ dfb->Release( dfb );
+
+ return EXIT_SUCCESS;
+}
+
+/*****************************************************************************/
+
+static void
+print_usage (const char *prg_name)
+{
+ fprintf (stderr, "\nDirectFB Desktop Background Configuration (version %s)\n\n", DIRECTFB_VERSION);
+ fprintf (stderr, "Usage: %s [options] <imagefile>|<color>\n\n", prg_name);
+ fprintf (stderr, "Options:\n");
+ fprintf (stderr, " -c, --color Set <color> in AARRGGBB format (hexadecimal).\n");
+ fprintf (stderr, " -t, --tile Set tiled mode.\n");
+ fprintf (stderr, " -h, --help Show this help message\n");
+ fprintf (stderr, " -v, --version Print version information\n");
+ fprintf (stderr, "\n");
+}
+
+static DFBBoolean
+parse_command_line( int argc, char *argv[] )
+{
+ int n;
+
+ for (n = 1; n < argc; n++) {
+ const char *a = argv[n];
+
+ if (*a != '-') {
+ if (!filename) {
+ filename = a;
+ continue;
+ }
+ else {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+ }
+ if (strcmp (a, "-h") == 0 || strcmp (a, "--help") == 0) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+ if (strcmp (a, "-v") == 0 || strcmp (a, "--version") == 0) {
+ fprintf (stderr, "dfbg version %s\n", DIRECTFB_VERSION);
+ return DFB_FALSE;
+ }
+ if (strcmp (a, "-c") == 0 || strcmp (a, "--color") == 0) {
+ color = DFB_TRUE;
+ continue;
+ }
+ if (strcmp (a, "-t") == 0 || strcmp (a, "--tile") == 0) {
+ tiled = DFB_TRUE;
+ continue;
+ }
+ }
+
+ if (!filename) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ return DFB_TRUE;
+}
+
+static void
+set_background_color( void )
+{
+ DFBResult ret;
+ char *error;
+ u32 argb;
+
+ if (*filename == '#')
+ filename++;
+
+ argb = strtoul( filename, &error, 16 );
+
+ if (*error) {
+ fprintf( stderr,
+ "Invalid characters in color string: '%s'\n", error );
+ return;
+ }
+
+ ret = layer->SetBackgroundColor( layer,
+ (argb & 0xFF0000) >> 16,
+ (argb & 0xFF00) >> 8,
+ (argb & 0xFF) >> 0,
+ (argb & 0xFF000000) >> 24 );
+ if (ret) {
+ DirectFBError( "IDirectFBDisplayLayer::SetBackgroundColor() failed", ret );
+ return;
+ }
+
+ ret = layer->SetBackgroundMode( layer, DLBM_COLOR );
+ if (ret)
+ DirectFBError( "IDirectFBDisplayLayer::SetBackgroundMode() failed", ret );
+}
+
+static void
+set_background_image( void )
+{
+ DFBResult ret;
+ DFBSurfaceDescription desc;
+ IDirectFBSurface *surface;
+ IDirectFBImageProvider *provider;
+
+ ret = dfb->CreateImageProvider( dfb, filename, &provider );
+ if (ret) {
+ DirectFBError( "IDirectFB::CreateImageProvider() failed", ret );
+ return;
+ }
+
+ ret = provider->GetSurfaceDescription( provider, &desc );
+ if (ret) {
+ DirectFBError( "IDirectFBImageProvider::GetSurfaceDescription() failed", ret );
+ provider->Release( provider );
+ return;
+ }
+
+ desc.flags |= DSDESC_CAPS;
+ desc.caps = DSCAPS_SHARED;
+
+ if (!tiled) {
+ DFBDisplayLayerConfig config;
+
+ ret = layer->GetConfiguration( layer, &config );
+ if (ret) {
+ DirectFBError( "IDirectFBDisplayLayer::GetConfiguration() failed", ret );
+ provider->Release( provider );
+ return;
+ }
+
+ desc.width = config.width;
+ desc.height = config.height;
+ }
+
+ ret = dfb->CreateSurface( dfb, &desc, &surface );
+ if (ret) {
+ DirectFBError( "IDirectFB::CreateSurface() failed", ret );
+ provider->Release( provider );
+ return;
+ }
+
+ ret = provider->RenderTo( provider, surface, NULL );
+ if (ret) {
+ DirectFBError( "IDirectFBImageProvider::RenderTo() failed", ret );
+ surface->Release( surface );
+ provider->Release( provider );
+ return;
+ }
+
+ ret = layer->SetBackgroundImage( layer, surface );
+ if (ret) {
+ DirectFBError( "IDirectFBDisplayLayer::SetBackgroundImage() failed", ret );
+ surface->Release( surface );
+ provider->Release( provider );
+ return;
+ }
+
+ ret = layer->SetBackgroundMode( layer, tiled ? DLBM_TILE : DLBM_IMAGE );
+ if (ret)
+ DirectFBError( "IDirectFBDisplayLayer::SetBackgroundMode() failed", ret );
+
+ surface->Release( surface );
+ provider->Release( provider );
+}
diff --git a/Source/DirectFB/tools/dfbinfo.c b/Source/DirectFB/tools/dfbinfo.c
new file mode 100755
index 0000000..7cc1591
--- /dev/null
+++ b/Source/DirectFB/tools/dfbinfo.c
@@ -0,0 +1,605 @@
+/*
+ (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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <directfb.h>
+#include <directfb_strings.h>
+
+static const DirectFBInputDeviceTypeFlagsNames(input_types);
+static const DirectFBInputDeviceCapabilitiesNames(input_caps);
+
+static const DirectFBDisplayLayerTypeFlagsNames(layer_types);
+static const DirectFBDisplayLayerCapabilitiesNames(layer_caps);
+
+static const DirectFBScreenCapabilitiesNames(screen_caps);
+static const DirectFBScreenEncoderCapabilitiesNames(encoder_caps);
+static const DirectFBScreenEncoderTypeNames(encoder_type);
+static const DirectFBScreenEncoderTVStandardsNames(tv_standards);
+static const DirectFBScreenOutputCapabilitiesNames(output_caps);
+static const DirectFBScreenOutputConnectorsNames(connectors);
+static const DirectFBScreenOutputResolutionNames(resolutions);
+static const DirectFBScreenOutputSignalsNames(signals);
+static const DirectFBScreenMixerCapabilitiesNames(mixer_caps);
+
+/*****************************************************************************/
+
+static IDirectFB *dfb = NULL;
+
+/*****************************************************************************/
+
+static DFBBoolean parse_command_line ( int argc, char *argv[] );
+static void enum_input_devices ( void );
+static void enum_screens ( void );
+
+/*****************************************************************************/
+
+int
+main( int argc, char *argv[] )
+{
+ DFBResult ret;
+
+ /* 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;
+
+ DirectFBSetOption( "bg-none", NULL );
+ DirectFBSetOption( "no-cursor", NULL );
+
+ /* Create the super interface. */
+ ret = DirectFBCreate( &dfb );
+ if (ret) {
+ DirectFBError( "DirectFBCreate() failed", ret );
+ return -3;
+ }
+
+ printf( "\n" );
+
+ enum_screens();
+
+ while (1) {
+ printf("\n\n\n\n\n");
+ enum_input_devices();
+ sleep(10);
+ }
+
+ /* Release the super interface. */
+ dfb->Release( dfb );
+
+ return EXIT_SUCCESS;
+}
+
+/*****************************************************************************/
+
+static DFBBoolean
+parse_command_line( int argc, char *argv[] )
+{
+ return DFB_TRUE;
+}
+
+/*****************************************************************************/
+
+static DFBEnumerationResult
+input_device_callback( DFBInputDeviceID id,
+ DFBInputDeviceDescription desc,
+ void *arg )
+{
+ int i;
+
+ /* Name */
+ printf( "Input (%02x) %-30s", id, desc.name );
+
+ switch (id) {
+ case DIDID_JOYSTICK:
+ printf( " (primary joystick)" );
+ break;
+ case DIDID_KEYBOARD:
+ printf( " (primary keyboard)" );
+ break;
+ case DIDID_MOUSE:
+ printf( " (primary mouse)" );
+ break;
+ case DIDID_REMOTE:
+ printf( " (primary remote control)" );
+ break;
+ default:
+ break;
+ }
+
+ printf( "\n" );
+
+ /* Type */
+ printf( " Type: " );
+
+ for (i=0; input_types[i].type; i++) {
+ if (desc.type & input_types[i].type)
+ printf( "%s ", input_types[i].name );
+ }
+
+ printf( "\n" );
+
+ /* Caps */
+ printf( " Caps: " );
+
+ for (i=0; input_caps[i].capability; i++) {
+ if (desc.caps & input_caps[i].capability)
+ printf( "%s ", input_caps[i].name );
+ }
+
+ printf( "\n" );
+
+
+ /* Details */
+ if (desc.caps & DICAPS_KEYS)
+ printf( " Min. Keycode: %d\n", desc.min_keycode );
+ if (desc.caps & DICAPS_KEYS)
+ printf( " Max. Keycode: %d\n", desc.max_keycode );
+ if (desc.caps & DICAPS_AXES)
+ printf( " Max. Axis: %d\n", desc.max_axis );
+ if (desc.caps & DICAPS_BUTTONS)
+ printf( " Max. Button: %d\n", desc.max_button );
+
+
+ DFBResult ret;
+ IDirectFBInputDevice *device;
+
+ ret = dfb->GetInputDevice( dfb, id, &device );
+ if (ret == DFB_OK) {
+ DFBInputDeviceState state;
+
+ ret = device->GetState( device, &state );
+ if (ret)
+ D_DERROR( ret, "DFBInfo: IDirectFBInputDevice::GetState() failed!\n" );
+ else {
+ if (state.flags & DISTATE_DISCONNECTED)
+ printf( " - DISCONNECTED -\n" );
+ }
+
+ device->Release( device );
+ }
+
+
+ printf( "\n" );
+
+ return DFB_OK;
+}
+
+static void
+enum_input_devices( void )
+{
+ DFBResult ret;
+
+ printf( "\n" );
+
+ ret = dfb->EnumInputDevices( dfb, input_device_callback, NULL );
+ if (ret)
+ DirectFBError( "IDirectFB::EnumInputDevices", ret );
+}
+
+/*****************************************************************************/
+
+static DFBEnumerationResult
+display_layer_callback( DFBDisplayLayerID id,
+ DFBDisplayLayerDescription desc,
+ void *arg )
+{
+ int i;
+
+ /* Name */
+ printf( " Layer (%02x) %-30s", id, desc.name );
+
+ switch (id) {
+ case DLID_PRIMARY:
+ printf( " (primary layer)" );
+ break;
+ default:
+ break;
+ }
+
+ printf( "\n" );
+
+
+ /* Type */
+ printf( " Type: " );
+
+ for (i=0; layer_types[i].type; i++) {
+ if (desc.type & layer_types[i].type)
+ printf( "%s ", layer_types[i].name );
+ }
+
+ printf( "\n" );
+
+
+ /* Caps */
+ printf( " Caps: " );
+
+ for (i=0; layer_caps[i].capability; i++) {
+ if (desc.caps & layer_caps[i].capability)
+ printf( "%s ", layer_caps[i].name );
+ }
+
+ printf( "\n" );
+
+
+ /* Sources */
+ if (desc.caps & DLCAPS_SOURCES) {
+ DFBResult ret;
+ IDirectFBDisplayLayer *layer;
+ DFBDisplayLayerSourceDescription descs[desc.sources];
+
+ ret = dfb->GetDisplayLayer( dfb, id, &layer );
+ if (ret) {
+ DirectFBError( "DirectFB::GetDisplayLayer() failed", ret );
+ }
+ else {
+ ret = layer->GetSourceDescriptions( layer, descs );
+ if (ret) {
+ DirectFBError( "DirectFBDisplayLayer::GetSourceDescriptions() failed", ret );
+ }
+ else {
+ printf( " Sources: " );
+
+ for (i=0; i<desc.sources; i++) {
+ if (i > 0)
+ printf( ", %s", descs[i].name );
+ else
+ printf( "%s", descs[i].name );
+ }
+
+ printf( "\n" );
+ }
+
+ layer->Release( layer );
+ }
+ }
+
+
+ printf( "\n" );
+
+ return DFB_OK;
+}
+
+static void
+enum_display_layers( IDirectFBScreen *screen )
+{
+ DFBResult ret;
+
+ ret = screen->EnumDisplayLayers( screen, display_layer_callback, NULL );
+ if (ret)
+ DirectFBError( "IDirectFBScreen::EnumDisplayLayers", ret );
+}
+
+/*****************************************************************************/
+
+static void
+dump_mixers( IDirectFBScreen *screen,
+ int num )
+{
+ int i, n;
+ DFBResult ret;
+ DFBScreenMixerDescription descs[num];
+
+ ret = screen->GetMixerDescriptions( screen, descs );
+ if (ret) {
+ DirectFBError( "IDirectFBScreen::GetMixerDescriptions", ret );
+ return;
+ }
+
+ for (i=0; i<num; i++) {
+ printf( " Mixer (%d) %s\n", i, descs[i].name );
+
+ /* Caps */
+ printf( " Caps: " );
+
+ for (n=0; mixer_caps[n].capability; n++) {
+ if (descs[i].caps & mixer_caps[n].capability)
+ printf( "%s ", mixer_caps[n].name );
+ }
+
+ printf( "\n" );
+
+
+ /* Full mode layers */
+ if (descs[i].caps & DSMCAPS_FULL) {
+ printf( " Layers (full mode): " );
+
+ for (n=0; n<DFB_DISPLAYLAYER_IDS_MAX; n++) {
+ if (DFB_DISPLAYLAYER_IDS_HAVE( descs[i].layers, n ))
+ printf( "(%02x) ", n );
+ }
+
+ printf( "\n" );
+ }
+
+
+ /* Sub mode layers */
+ if (descs[i].caps & DSMCAPS_SUB_LAYERS) {
+ printf( " Layers (sub mode): %2d of ", descs[i].sub_num );
+
+ for (n=0; n<DFB_DISPLAYLAYER_IDS_MAX; n++) {
+ if (DFB_DISPLAYLAYER_IDS_HAVE( descs[i].sub_layers, n ))
+ printf( "(%02x) ", n );
+ }
+
+ printf( "\n" );
+ }
+
+ printf( "\n" );
+ }
+
+ printf( "\n" );
+}
+
+static void
+dump_encoders( IDirectFBScreen *screen,
+ int num )
+{
+ int i, n;
+ DFBResult ret;
+ DFBScreenEncoderDescription descs[num];
+
+ ret = screen->GetEncoderDescriptions( screen, descs );
+ if (ret) {
+ DirectFBError( "IDirectFBScreen::GetEncoderDescriptions", ret );
+ return;
+ }
+
+ for (i=0; i<num; i++) {
+ printf( " Encoder (%d) %s\n", i, descs[i].name );
+
+ /* Type */
+ printf( " Type: " );
+
+ for (n=0; encoder_type[n].type; n++) {
+ if (descs[i].type & encoder_type[n].type)
+ printf( "%s ", encoder_type[n].name );
+ }
+
+ printf( "\n" );
+
+
+ /* Caps */
+ printf( " Caps: " );
+
+ for (n=0; encoder_caps[n].capability; n++) {
+ if (descs[i].caps & encoder_caps[n].capability)
+ printf( "%s ", encoder_caps[n].name );
+ }
+
+ printf( "\n" );
+
+
+ /* TV Norms */
+ if (descs[i].caps & DSECAPS_TV_STANDARDS) {
+ printf( " TV Standards: " );
+
+ for (n=0; tv_standards[n].standard; n++) {
+ if (descs[i].tv_standards & tv_standards[n].standard)
+ printf( "%s ", tv_standards[n].name );
+ }
+
+ printf( "\n" );
+ }
+
+
+ /* Output signals */
+ if (descs[i].caps & DSECAPS_OUT_SIGNALS) {
+ printf( " Output Signals: " );
+
+ for (n=0; signals[n].signal; n++) {
+ if (descs[i].out_signals & signals[n].signal)
+ printf( "%s ", signals[n].name );
+ }
+
+ printf( "\n" );
+ }
+
+ /* Output Resolutions */
+ if (descs[i].caps & DSECAPS_RESOLUTION) {
+ printf( " Output Resolutions: " );
+
+ for (n=0; resolutions[n].resolution; n++) {
+ if (descs[i].all_resolutions & resolutions[n].resolution)
+ printf( "%s ", resolutions[n].name );
+ }
+
+ printf( "\n" );
+ }
+
+ /* Output connectors */
+ if (descs[i].caps & DSECAPS_CONNECTORS) {
+ printf( " Output Connectors: " );
+
+ for (n=0; connectors[n].connector; n++) {
+ if (descs[i].all_connectors & connectors[n].connector)
+ printf( "%s ", connectors[n].name );
+ }
+
+ printf( "\n" );
+ }
+
+ printf( "\n" );
+ }
+
+ printf( "\n" );
+}
+
+static void
+dump_outputs( IDirectFBScreen *screen,
+ int num )
+{
+ int i, n;
+ DFBResult ret;
+ DFBScreenOutputDescription descs[num];
+
+ ret = screen->GetOutputDescriptions( screen, descs );
+ if (ret) {
+ DirectFBError( "IDirectFBScreen::GetOutputDescriptions", ret );
+ return;
+ }
+
+ for (i=0; i<num; i++) {
+ printf( " Output (%d) %s\n", i, descs[i].name );
+
+
+ /* Caps */
+ printf( " Caps: " );
+
+ for (n=0; output_caps[n].capability; n++) {
+ if (descs[i].caps & output_caps[n].capability)
+ printf( "%s ", output_caps[n].name );
+ }
+
+ printf( "\n" );
+
+ /* Connectors */
+ if (descs[i].caps & DSOCAPS_CONNECTORS) {
+ printf( " Connectors: " );
+
+ for (n=0; connectors[n].connector; n++) {
+ if (descs[i].all_connectors & connectors[n].connector)
+ printf( "%s ", connectors[n].name );
+ }
+
+ printf( "\n" );
+ }
+
+ /* Output Resolutions */
+ if (descs[i].caps & DSOCAPS_RESOLUTION) {
+ printf( " Resolutions: " );
+
+ for (n=0; resolutions[n].resolution; n++) {
+ if (descs[i].all_resolutions & resolutions[n].resolution)
+ printf( "%s ", resolutions[n].name );
+ }
+
+ printf( "\n" );
+ }
+
+ /* Signals */
+ printf( " Signals: " );
+
+ for (n=0; signals[n].signal; n++) {
+ if (descs[i].all_signals & signals[n].signal)
+ printf( "%s ", signals[n].name );
+ }
+
+ printf( "\n" );
+
+ printf( "\n" );
+ }
+
+ printf( "\n" );
+}
+
+static DFBEnumerationResult
+screen_callback( DFBScreenID id,
+ DFBScreenDescription desc,
+ void *arg )
+{
+ int i;
+ DFBResult ret;
+ IDirectFBScreen *screen;
+
+ ret = dfb->GetScreen( dfb, id, &screen );
+ if (ret)
+ DirectFBErrorFatal( "IDirectFB::GetScreen", ret );
+
+ /* Name */
+ printf( "Screen (%02x) %-30s", id, desc.name );
+
+ switch (id) {
+ case DSCID_PRIMARY:
+ printf( " (primary screen)" );
+ break;
+ default:
+ break;
+ }
+
+ printf( "\n" );
+
+ /* Caps */
+ printf( " Caps: " );
+
+ for (i=0; screen_caps[i].capability; i++) {
+ if (desc.caps & screen_caps[i].capability)
+ printf( "%s ", screen_caps[i].name );
+ }
+
+ printf( "\n\n" );
+
+
+ /* Mixers */
+ if (desc.mixers)
+ dump_mixers( screen, desc.mixers );
+
+ /* Encoders */
+ if (desc.encoders)
+ dump_encoders( screen, desc.encoders );
+
+ /* Outputs */
+ if (desc.outputs)
+ dump_outputs( screen, desc.outputs );
+
+ /* Display layers */
+ enum_display_layers( screen );
+
+ screen->Release( screen );
+
+ return DFB_OK;
+}
+
+static void
+enum_screens( void )
+{
+ DFBResult ret;
+
+ printf( "\n" );
+
+ ret = dfb->EnumScreens( dfb, screen_callback, NULL );
+ if (ret)
+ DirectFBError( "IDirectFB::EnumScreens", ret );
+}
+
diff --git a/Source/DirectFB/tools/dfbinput.c b/Source/DirectFB/tools/dfbinput.c
new file mode 100755
index 0000000..fa8112d
--- /dev/null
+++ b/Source/DirectFB/tools/dfbinput.c
@@ -0,0 +1,331 @@
+/*
+ (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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <direct/messages.h>
+#include <direct/util.h>
+
+#include <core/input.h>
+
+#include <directfb.h>
+#include <directfb_keynames.h>
+#include <directfb_strings.h>
+
+
+/**************************************************************************************************/
+
+static const DirectFBKeySymbolNames( symbol_names );
+
+static const char *
+symbol_name( DFBInputDeviceKeySymbol symbol )
+{
+ int i;
+ static char buf[64];
+
+ for (i=0; i<D_ARRAY_SIZE(symbol_names); i++) {
+ if (symbol_names[i].symbol == symbol)
+ return symbol_names[i].name;
+ }
+
+ snprintf( buf, sizeof(buf), "<0x%08x>", symbol );
+
+ return buf;
+}
+
+/**************************************************************************************************/
+
+static IDirectFB *dfb;
+static IDirectFBInputDevice *device;
+static DFBInputDeviceDescription desc;
+
+/**************************************************************************************************/
+
+static DFBInputDeviceID id = DIDID_KEYBOARD;
+static unsigned int reload = false;
+static unsigned int dump = false;
+static unsigned int sensitivity = 0;
+
+/**************************************************************************************************/
+
+static bool parse_command_line( int argc, char *argv[] );
+
+/**************************************************************************************************/
+
+int
+main( int argc, char *argv[] )
+{
+ DFBResult ret;
+
+ /* Initialize DirectFB including command line parsing. */
+ ret = DirectFBInit( &argc, &argv );
+ if (ret) {
+ D_DERROR( ret, "Tools/Input: DirectFBInit() failed!\n" );
+ goto error;
+ }
+
+ /* Parse the command line. */
+ if (!parse_command_line( argc, argv ))
+ goto error;
+
+ /* Create the super interface. */
+ ret = DirectFBCreate( &dfb );
+ if (ret) {
+ D_DERROR( ret, "Tools/Input: DirectFBCreate() failed!\n" );
+ goto error;
+ }
+
+ dfb->RescanInputDevices( dfb );
+
+ /* Get the input device. */
+ ret = dfb->GetInputDevice( dfb, id, &device );
+ if (ret) {
+ if (ret == DFB_IDNOTFOUND)
+ fprintf (stderr, "\nUnknown device id, check 'dfbinfo' for valid values.\n\n");
+ else
+ D_DERROR( ret, "Tools/Input: IDirectFB::GetInputDevice() failed!\n" );
+
+ goto error;
+ }
+
+ if (sensitivity)
+ device->SetSensitivity( device, sensitivity );
+
+ /* Get a description of the device. */
+ ret = device->GetDescription( device, &desc );
+ if (ret) {
+ D_DERROR( ret, "Tools/Input: IDirectFBInputDevice::GetDescription() failed!\n" );
+ goto error;
+ }
+
+ /* Reload the keymap. FIXME: Make public API? */
+ if (reload) {
+ ret = dfb_input_device_reload_keymap( dfb_input_device_at( id ) );
+ if (ret) {
+ D_DERROR( ret, "Tools/Input: Reloading the keymap failed!\n" );
+ goto error;
+ }
+ }
+
+ /* Dump the keymap. */
+ if (dump) {
+ int i;
+
+ printf( "\n" );
+
+ for (i=desc.min_keycode; i<=desc.max_keycode; i++) {
+ DFBInputDeviceKeymapEntry entry;
+
+ ret = device->GetKeymapEntry( device, i, &entry );
+ if (ret) {
+ D_DERROR( ret, "Tools/Input: IDirectFBInputDevice::GetKeymapEntry( %d ) failed!\n", i );
+ goto error;
+ }
+
+ printf( "%3d: %-16s %-16s %-16s %-16s\n", i,
+ symbol_name(entry.symbols[DIKSI_BASE]),
+ symbol_name(entry.symbols[DIKSI_BASE_SHIFT]),
+ symbol_name(entry.symbols[DIKSI_ALT]),
+ symbol_name(entry.symbols[DIKSI_ALT_SHIFT]) );
+ }
+
+ printf( "\n" );
+ }
+
+error:
+ /* Release the device. */
+ if (device)
+ device->Release( device );
+
+ /* Release the super interface. */
+ if (dfb)
+ dfb->Release( dfb );
+
+ return ret;
+}
+
+/**************************************************************************************************/
+
+typedef struct __AnyOption AnyOption;
+
+
+typedef bool (*ParseFunc)( const AnyOption *option,
+ const char *arg );
+
+struct __AnyOption {
+ const char *short_name;
+ const char *long_name;
+
+ const char *arg_name;
+ const char *arg_desc;
+
+ void *value;
+
+ unsigned int *flags;
+ unsigned int flag;
+
+ ParseFunc parse;
+ const void *data;
+};
+
+typedef struct {
+ int value;
+ const char *name;
+} ValueName;
+
+/**************************************************************************************************/
+
+static bool
+parse_int( const AnyOption *option, const char *arg )
+{
+ int ret;
+ char *end;
+
+ ret = strtoul( arg, &end, option->data ? (unsigned long) option->data : 10 );
+
+ if (*end || ret < 0) {
+ fprintf( stderr, "\nInvalid argument to '%s' or '%s' specified!\n\n",
+ option->short_name, option->long_name );
+
+ return false;
+ }
+
+ *((int*)option->value) = ret;
+
+ return true;
+}
+
+/**************************************************************************************************/
+
+static const AnyOption options[] = {
+ { "-d", "--device", "<id>", "ID of device to use",
+ &id, NULL, 0, parse_int, NULL },
+
+ { "-r", "--reload", "", "Reload the keymap",
+ NULL, &reload, true, NULL, NULL },
+
+ { "-s", "--sensitivity", "<value>", "Set sensitivity of axes (16.16 fixed)",
+ &sensitivity, NULL, 0, parse_int, NULL },
+
+ { "-k", "--keymap", "", "Show the keymap",
+ NULL, &dump, true, NULL, NULL },
+};
+
+/**************************************************************************************************/
+
+static void
+print_usage (const char *prg_name)
+{
+ int i;
+
+ fprintf (stderr, "\nDirectFB Input Device Configuration (version %s)\n\n", DIRECTFB_VERSION);
+ fprintf (stderr, "Usage: %s [options]\n\n", prg_name);
+ fprintf (stderr, "Options:\n");
+ fprintf (stderr, " -h --help Show this help message\n");
+ fprintf (stderr, " -v --version Print version information\n");
+
+ for (i=0; i<D_ARRAY_SIZE(options); i++) {
+ const AnyOption *option = &options[i];
+
+ fprintf( stderr, " %-3s %-16s %-12s %s\n",
+ option->short_name, option->long_name, option->arg_name, option->arg_desc );
+ }
+
+ fprintf (stderr, "\n");
+}
+
+/**************************************************************************************************/
+
+static bool
+parse_option( const AnyOption *option, const char *arg )
+{
+ if (option->parse && !option->parse( option, arg ))
+ return false;
+
+ if (option->flags)
+ *option->flags |= option->flag;
+
+ return true;
+}
+
+static bool
+parse_command_line( int argc, char *argv[] )
+{
+ int i, n;
+
+ for (n = 1; n < argc; n++) {
+ bool ok = false;
+ 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, "dfbinput version %s\n", DIRECTFB_VERSION);
+ return false;
+ }
+
+ for (i=0; i<D_ARRAY_SIZE(options); i++) {
+ const AnyOption *opt = &options[i];
+
+ if (!strcmp (arg, opt->short_name) || !strcmp (arg, opt->long_name)) {
+ if (opt->parse && ++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_option( opt, argv[n] ))
+ return false;
+
+ ok = true;
+
+ break;
+ }
+ }
+
+ if (!ok) {
+ print_usage (argv[0]);
+ return false;
+ }
+ }
+
+ return true;
+}
+
diff --git a/Source/DirectFB/tools/dfbinspector.c b/Source/DirectFB/tools/dfbinspector.c
new file mode 100755
index 0000000..52559aa
--- /dev/null
+++ b/Source/DirectFB/tools/dfbinspector.c
@@ -0,0 +1,288 @@
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#include <direct/messages.h>
+#include <direct/util.h>
+
+#include <directfb.h>
+#include <directfb_strings.h>
+
+/**********************************************************************************************************************/
+
+static const DirectFBPixelFormatNames(format_names);
+static const DirectFBSurfaceBlittingFlagsNames(blittingflags_names);
+static const DirectFBSurfaceDrawingFlagsNames(drawingflags_names);
+static const DirectFBAccelerationMaskNames(accelerationmask_names);
+
+/**********************************************************************************************************************/
+
+typedef enum {
+ NONE = 0x00000000,
+ CREATE_FILES = 0x00000001
+} Options;
+
+typedef struct {
+ IDirectFB *dfb;
+ IDirectFBFont *font;
+
+ Options options;
+ const char *directory;
+
+ struct {
+ FILE *formats;
+ } files;
+
+ bool device_drawstring;
+} Inspector;
+
+/**********************************************************************************************************************/
+
+static DFBResult
+Inspector_Init( Inspector *inspector, int argc, char *argv[] )
+{
+ int i;
+ DFBResult ret;
+ DFBFontDescription desc;
+
+ memset( inspector, 0, sizeof(Inspector) );
+
+ for (i=1; i<argc; i++) {
+ if (!strcmp( argv[i], "-d" )) {
+ if (++i == argc) {
+ D_ERROR( "Inspector/Init: Missing argument to option '-d'!\n" );
+ return DFB_INVARG;
+ }
+
+ inspector->directory = argv[i];
+ inspector->options |= CREATE_FILES;
+ }
+ }
+
+ ret = DirectFBCreate( &inspector->dfb );
+ if (ret) {
+ D_DERROR( ret, "Inspector/Init: DirectFBCreate() failed!\n" );
+ return ret;
+ }
+
+ desc.flags = DFDESC_HEIGHT;
+ desc.height = 24;
+
+ ret = inspector->dfb->CreateFont( inspector->dfb, DATADIR"/decker.ttf", &desc, &inspector->font );
+ if (ret) {
+ D_DERROR( ret, "Inspector/Init: Could not load font '%s'!\n", DATADIR"/decker.ttf" );
+ return ret;
+ }
+
+ return DFB_OK;
+}
+
+static DFBResult
+Inspector_Run( Inspector *inspector )
+{
+ static const DFBSurfacePixelFormat formats[] = {
+ DSPF_LUT8,
+ DSPF_ALUT44,
+ DSPF_RGB332,
+ DSPF_RGB16,
+ DSPF_RGB24,
+ DSPF_RGB32,
+ DSPF_ARGB1555,
+ DSPF_ARGB2554,
+ DSPF_ARGB4444,
+ DSPF_ARGB,
+ DSPF_AiRGB,
+ DSPF_A1,
+ DSPF_A8,
+ DSPF_YUY2,
+ DSPF_UYVY,
+ DSPF_I420,
+ DSPF_YV12,
+ DSPF_NV12,
+ DSPF_NV21,
+ DSPF_NV16,
+ DSPF_AYUV
+ };
+
+ int i, j, n;
+ DFBResult ret;
+ DFBSurfaceDescription desc;
+ IDirectFBSurface *surfaces[D_ARRAY_SIZE(formats)];
+ char buf[strlen( inspector->directory ? : "" ) + 23];
+
+
+ if (inspector->options & CREATE_FILES) {
+ /* Create the directory. */
+ if (mkdir( inspector->directory, 0755 ) < 0 && errno != EEXIST) {
+ D_PERROR( "Inspector/Init: Could not create directory '%s'!\n", inspector->directory );
+ return DFB_INIT;
+ }
+
+ /* Open file for writing supported format conversions (blitting). */
+ snprintf( buf, sizeof(buf), "%s/blit.formats", inspector->directory );
+ inspector->files.formats = fopen( buf, "w" );
+ if (!inspector->files.formats) {
+ D_PERROR( "Inspector/Init: Could not open file '%s' for writing!\n", buf );
+ return DFB_INIT;
+ }
+ }
+
+ desc.flags = (DFBSurfaceDescriptionFlags)(DSDESC_WIDTH |
+ DSDESC_HEIGHT |
+ DSDESC_PIXELFORMAT);
+ desc.width = 64;
+ desc.height = 64;
+
+ for (i=0; i<D_ARRAY_SIZE(formats); i++) {
+ desc.pixelformat = formats[i];
+
+ ret = inspector->dfb->CreateSurface( inspector->dfb, &desc, &surfaces[i] );
+ if (ret) {
+ D_DERROR( ret, "Inspector/Init: Could not create %s surface!\n",
+ format_names[DFB_PIXELFORMAT_INDEX(formats[i])].name );
+ while (i--)
+ surfaces[i]->Release( surfaces[i] );
+ return ret;
+ }
+
+ surfaces[i]->SetFont( surfaces[i], inspector->font );
+
+ if (inspector->files.formats)
+ fprintf( inspector->files.formats, "%s%s", i ? "," : "",
+ format_names[DFB_PIXELFORMAT_INDEX(formats[i])].name );
+ }
+
+ if (inspector->files.formats)
+ fprintf( inspector->files.formats, "\n" );
+
+ printf("\n");
+
+
+
+ printf("source ->");
+
+ for (i=0; i<D_ARRAY_SIZE(formats); i++)
+ printf( "%9s", format_names[DFB_PIXELFORMAT_INDEX(formats[i])].name );
+
+ printf("\n");
+
+
+
+ printf("dest.\n");
+
+ for (i=0; i<D_ARRAY_SIZE(formats); i++) {
+ printf( "%9s", format_names[DFB_PIXELFORMAT_INDEX(formats[i])].name );
+
+ for (j=0; j<D_ARRAY_SIZE(formats); j++) {
+ DFBAccelerationMask mask;
+
+ surfaces[i]->GetAccelerationMask( surfaces[i], surfaces[j], &mask );
+
+ if (mask & DFXL_DRAWSTRING)
+ inspector->device_drawstring = true;
+
+ printf( "%9s", (mask & DFXL_BLIT) ? "X" : "" );
+
+ if (inspector->files.formats)
+ fputc( (mask & DFXL_BLIT) ? '1' : '0', inspector->files.formats );
+ }
+
+ printf( " %s", format_names[DFB_PIXELFORMAT_INDEX(formats[i])].name );
+
+ printf("\n");
+
+ if (inspector->files.formats)
+ fprintf( inspector->files.formats, "\n" );
+ }
+
+ for (i=0; i<D_ARRAY_SIZE(formats); i++)
+ surfaces[i]->Release( surfaces[i] );
+
+ if (inspector->options & CREATE_FILES) {
+ FILE *f;
+ DFBGraphicsDeviceDescription desc;
+
+ if (inspector->files.formats)
+ fclose( inspector->files.formats );
+
+ /* Query device and driver information. */
+ inspector->dfb->GetDeviceDescription( inspector->dfb, &desc );
+
+ if (inspector->device_drawstring)
+ desc.acceleration_mask = (DFBAccelerationMask)(desc.acceleration_mask | DFXL_DRAWSTRING);
+
+ /* Write device info to a file. */
+ snprintf( buf, sizeof(buf), "%s/device.info", inspector->directory );
+ f = fopen( buf, "w" );
+ if (!f) {
+ D_PERROR( "Inspector/Init: Could not open file '%s' for writing!\n", buf );
+ return DFB_FAILURE;
+ }
+
+ fprintf( f, "name = %s\n", desc.name );
+ fprintf( f, "vendor = %s\n", desc.vendor );
+
+ fprintf( f, "acceleration_mask = " );
+ for (i=0, n=0; accelerationmask_names[i].mask; i++) {
+ if (desc.acceleration_mask & accelerationmask_names[i].mask)
+ fprintf( f, "%s%s", n++ ? "," : "", accelerationmask_names[i].name );
+ }
+ fprintf( f, "\n" );
+
+ fprintf( f, "blitting_flags = " );
+ for (i=0, n=0; blittingflags_names[i].flag; i++) {
+ if (desc.blitting_flags & blittingflags_names[i].flag)
+ fprintf( f, "%s%s", n++ ? "," : "", blittingflags_names[i].name );
+ }
+ fprintf( f, "\n" );
+
+ fprintf( f, "drawing_flags = " );
+ for (i=0, n=0; drawingflags_names[i].flag; i++) {
+ if (desc.drawing_flags & drawingflags_names[i].flag)
+ fprintf( f, "%s%s", n++ ? "," : "", drawingflags_names[i].name );
+ }
+ fprintf( f, "\n" );
+
+ fclose( f );
+
+
+ /* Write driver info to a file. */
+ snprintf( buf, sizeof(buf), "%s/driver.info", inspector->directory );
+ f = fopen( buf, "w" );
+ if (!f) {
+ D_PERROR( "Inspector/Init: Could not open file '%s' for writing!\n", buf );
+ return DFB_FAILURE;
+ }
+
+ fprintf( f, "name = %s\n", desc.driver.name );
+ fprintf( f, "vendor = %s\n", desc.driver.vendor );
+ fprintf( f, "version = %d.%d\n", desc.driver.major, desc.driver.minor );
+
+ fclose( f );
+ }
+
+ return DFB_OK;
+}
+
+/**********************************************************************************************************************/
+
+int
+main( int argc, char *argv[] )
+{
+ DFBResult ret;
+ Inspector inspector;
+
+ ret = DirectFBInit( &argc, &argv );
+ if (ret) {
+ D_DERROR( ret, "Inspector/Init: DirectFBInit() failed!\n" );
+ return ret;
+ }
+
+ ret = Inspector_Init( &inspector, argc, argv );
+ if (ret)
+ return ret;
+
+ return Inspector_Run( &inspector );
+}
+
diff --git a/Source/DirectFB/tools/dfblayer.c b/Source/DirectFB/tools/dfblayer.c
new file mode 100755
index 0000000..6519be1
--- /dev/null
+++ b/Source/DirectFB/tools/dfblayer.c
@@ -0,0 +1,625 @@
+/*
+ (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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <directfb.h>
+#include <directfb_strings.h>
+
+static DirectFBPixelFormatNames( format_names );
+
+/*****************************************************************************/
+
+static IDirectFB *dfb;
+static IDirectFBDisplayLayer *layer;
+static DFBDisplayLayerDescription desc;
+
+/*****************************************************************************/
+
+static DFBDisplayLayerID id = DLID_PRIMARY;
+static int width = 0;
+static int height = 0;
+static DFBSurfacePixelFormat format = DSPF_UNKNOWN;
+static DFBDisplayLayerBufferMode buffermode = -1;
+static int opacity = -1;
+static int level = 0;
+static DFBBoolean set_level = DFB_FALSE;
+static int rotation = 0;
+static DFBBoolean set_rotation = DFB_FALSE;
+static DFBSurfaceLockFlags test_lock = 0;
+
+/*****************************************************************************/
+
+static DFBBoolean parse_command_line( int argc, char *argv[] );
+static void set_configuration ( void );
+
+/*****************************************************************************/
+
+int
+main( int argc, char *argv[] )
+{
+ DFBResult ret;
+
+ /* 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;
+ }
+
+ /* Get the primary display layer. */
+ ret = dfb->GetDisplayLayer( dfb, id, &layer );
+ if (ret) {
+ if (ret == DFB_IDNOTFOUND)
+ fprintf (stderr, "\nUnknown layer id, check 'dfbinfo' for valid values.\n\n");
+ else
+ DirectFBError( "IDirectFB::GetDisplayLayer() failed", ret );
+ dfb->Release( dfb );
+ return -4;
+ }
+
+ /* Get a description of the layer. */
+ ret = layer->GetDescription( layer, &desc );
+ if (ret) {
+ DirectFBError( "IDirectFBDisplayLayer::GetDescription() failed", ret );
+ layer->Release( layer );
+ dfb->Release( dfb );
+ return -5;
+ }
+
+ /* Acquire administrative cooperative level. */
+ ret = layer->SetCooperativeLevel( layer, DLSCL_ADMINISTRATIVE );
+ if (ret) {
+ DirectFBError( "IDirectFBDisplayLayer::SetCooperativeLevel() failed", ret );
+ layer->Release( layer );
+ dfb->Release( dfb );
+ return -6;
+ }
+
+ /* Show/change the configuration. */
+ set_configuration();
+
+ /* Test Lock() on layer surface? */
+ if (test_lock) {
+ IDirectFBSurface *surface;
+
+ fprintf( stderr, "\nGetting layer surface...\n" );
+
+ ret = layer->GetSurface( layer, &surface );
+ if (ret)
+ DirectFBError( "IDirectFBDisplayLayer::GetSurface() failed", ret );
+ else {
+ void *data;
+ int pitch;
+
+ fprintf( stderr, "\nTesting Lock( %s ) on layer surface...\n",
+ test_lock == DSLF_READ ? "read only" : test_lock == DSLF_WRITE ? "write only" : "read/write" );
+
+ ret = surface->Lock( surface, test_lock, &data, &pitch );
+ if (ret)
+ DirectFBError( "IDirectFBSurface::Lock() failed", ret );
+ else
+ fprintf( stderr, " => OK\n\n" );
+
+ surface->Release( surface );
+ }
+ }
+
+ /* Release the display 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, "\nDirectFB Layer Configuration (version %s)\n\n", DIRECTFB_VERSION);
+ fprintf (stderr, "Usage: %s [options]\n\n", prg_name);
+ fprintf (stderr, "Options:\n");
+ fprintf (stderr, " -l, --layer <id> Use the specified layer, default is primary\n");
+ fprintf (stderr, " -m, --mode <width>x<height> Change the resolution (pixels)\n");
+ fprintf (stderr, " -f, --format <pixelformat> Change the pixel format\n");
+ fprintf (stderr, " -b, --buffer <buffermode> Change the buffer mode (single/video/system)\n");
+ fprintf (stderr, " -o, --opacity <opacity> Change the layer's opacity (0-255)\n");
+ fprintf (stderr, " -L, --level <level> Change the layer's level\n");
+ fprintf (stderr, " -R, --rotate <degree> Change the layer rotation\n");
+ fprintf (stderr, " -t, --test-lock Get layer surface and Lock() it (read/write)\n");
+ fprintf (stderr, " -tr, --test-lock-read Get layer surface and Lock() it (read only)\n");
+ fprintf (stderr, " -tw, --test-lock-write Get layer surface and Lock() it (write only)\n");
+ fprintf (stderr, " -h, --help Show this help message\n");
+ fprintf (stderr, " -v, --version Print version information\n");
+ 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, "Valid buffer modes:\n");
+ fprintf (stderr, " FRONTONLY or 'single'\n");
+ fprintf (stderr, " BACKVIDEO or 'video'\n");
+ fprintf (stderr, " BACKSYSTEM or 'system'\n");
+ fprintf (stderr, " TRIPLE\n");
+ fprintf (stderr, " WINDOWS\n");
+
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Specifying neither mode nor format just displays the current configuration.\n");
+ fprintf (stderr, "\n");
+}
+
+static DFBBoolean
+parse_layer( const char *arg )
+{
+ if (sscanf( arg, "%d", &id ) != 1 || id < 0) {
+ fprintf (stderr, "\n"
+ "Invalid layer id specified!\n"
+ "Check 'dfbinfo' for valid values.\n\n");
+
+ return DFB_FALSE;
+ }
+
+ return DFB_TRUE;
+}
+
+static DFBBoolean
+parse_mode( const char *arg )
+{
+ if (sscanf( arg, "%dx%d", &width, &height ) != 2 ||
+ width < 1 || height < 1)
+ {
+ fprintf (stderr, "\nInvalid mode specified!\n\n" );
+ return DFB_FALSE;
+ }
+
+ return DFB_TRUE;
+}
+
+static DFBBoolean
+parse_format( const char *arg )
+{
+ int i = 0;
+
+ while (format_names[i].format != DSPF_UNKNOWN) {
+ if (!strcasecmp( arg, format_names[i].name )) {
+ format = format_names[i].format;
+ return DFB_TRUE;
+ }
+
+ ++i;
+ }
+
+ fprintf (stderr, "\nInvalid format specified!\n\n" );
+
+ return DFB_FALSE;
+}
+
+static DFBBoolean
+parse_buffermode( const char *arg )
+{
+ if (!strcasecmp( arg, "single" ) || !strcasecmp( arg, "frontonly" ))
+ buffermode = DLBM_FRONTONLY;
+ else if (!strcasecmp( arg, "system" ) || !strcasecmp( arg, "backsystem" ))
+ buffermode = DLBM_BACKSYSTEM;
+ else if (!strcasecmp( arg, "video" ) || !strcasecmp( arg, "backvideo" ))
+ buffermode = DLBM_BACKVIDEO;
+ else if (!strcasecmp( arg, "triple" ))
+ buffermode = DLBM_TRIPLE;
+ else if (!strcasecmp( arg, "windows" ))
+ buffermode = DLBM_WINDOWS;
+ else {
+ fprintf (stderr, "\nInvalid buffer mode specified!\n\n" );
+ return DFB_FALSE;
+ }
+
+ return DFB_TRUE;
+}
+
+static DFBBoolean
+parse_opacity( const char *arg )
+{
+ if (sscanf( arg, "%d", &opacity ) != 1 || opacity < 0 || opacity > 255) {
+ fprintf (stderr, "\nInvalid opacity value specified!\n\n");
+
+ return DFB_FALSE;
+ }
+
+ return DFB_TRUE;
+}
+
+static DFBBoolean
+parse_level( const char *arg )
+{
+ if (sscanf( arg, "%d", &level ) != 1) {
+ fprintf (stderr, "\nInvalid level specified!\n\n");
+
+ return DFB_FALSE;
+ }
+
+ set_level = DFB_TRUE;
+
+ return DFB_TRUE;
+}
+
+static DFBBoolean
+parse_rotation( const char *arg )
+{
+ if (sscanf( arg, "%d", &rotation ) != 1) {
+ fprintf (stderr, "\nInvalid rotation specified!\n\n");
+
+ return DFB_FALSE;
+ }
+
+ set_rotation = DFB_TRUE;
+
+ return DFB_TRUE;
+}
+
+static DFBBoolean
+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 DFB_FALSE;
+ }
+
+ if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
+ fprintf (stderr, "dfbg version %s\n", DIRECTFB_VERSION);
+ return DFB_FALSE;
+ }
+
+ if (strcmp (arg, "-l") == 0 || strcmp (arg, "--layer") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (!parse_layer( argv[n] ))
+ return DFB_FALSE;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-m") == 0 || strcmp (arg, "--mode") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (!parse_mode( argv[n] ))
+ return DFB_FALSE;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-f") == 0 || strcmp (arg, "--format") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (!parse_format( argv[n] ))
+ return DFB_FALSE;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-b") == 0 || strcmp (arg, "--buffer") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (!parse_buffermode( argv[n] ))
+ return DFB_FALSE;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-o") == 0 || strcmp (arg, "--opacity") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (!parse_opacity( argv[n] ))
+ return DFB_FALSE;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-L") == 0 || strcmp (arg, "--level") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (!parse_level( argv[n] ))
+ return DFB_FALSE;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-R") == 0 || strcmp (arg, "--rotate") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (!parse_rotation( argv[n] ))
+ return DFB_FALSE;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-t") == 0 || strcmp (arg, "--test-lock") == 0) {
+ test_lock = DSLF_READ | DSLF_WRITE;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-tr") == 0 || strcmp (arg, "--test-lock-read") == 0) {
+ test_lock = DSLF_READ;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-tw") == 0 || strcmp (arg, "--test-lock-write") == 0) {
+ test_lock = DSLF_WRITE;
+
+ continue;
+ }
+
+ print_usage (argv[0]);
+
+ return DFB_FALSE;
+ }
+
+ return DFB_TRUE;
+}
+
+static void
+set_configuration( void )
+{
+ DFBResult ret;
+ DFBDisplayLayerConfig config;
+
+ printf( "\n" );
+ printf( "%s\n", desc.name );
+ printf( "\n" );
+
+ config.flags = DLCONF_NONE;
+
+ if (width) {
+ config.flags |= DLCONF_WIDTH;
+ config.width = width;
+ }
+
+ if (height) {
+ config.flags |= DLCONF_HEIGHT;
+ config.height = height;
+ }
+
+ if (format != DSPF_UNKNOWN) {
+ config.flags |= DLCONF_PIXELFORMAT;
+ config.pixelformat = format;
+ }
+
+ if (buffermode != -1) {
+ config.flags |= DLCONF_BUFFERMODE;
+ config.buffermode = buffermode;
+ }
+
+ /* Set the configuration if anything changed. */
+ if (config.flags) {
+ ret = layer->TestConfiguration( layer, &config, NULL );
+ if (ret) {
+ DirectFBError( "IDirectFBDisplayLayer::TestConfiguration() failed", ret );
+ return;
+ }
+
+ ret = layer->SetConfiguration( layer, &config );
+ if (ret) {
+ DirectFBError( "IDirectFBDisplayLayer::SetConfiguration() failed", ret );
+ return;
+ }
+ }
+
+ /* Get and show the current (new) configuration. */
+ ret = layer->GetConfiguration( layer, &config );
+ if (ret) {
+ DirectFBError( "IDirectFBDisplayLayer::GetConfiguration() failed", ret );
+ return;
+ }
+
+ /* Set the opacity if requested. */
+ if (opacity != -1) {
+ ret = layer->SetOpacity( layer, opacity );
+ if (ret == DFB_UNSUPPORTED)
+ fprintf( stderr, "Opacity value (%d) not supported!\n\n", opacity );
+ else if (ret)
+ DirectFBError( "IDirectFBDisplayLayer::SetOpacity() failed", ret );
+ }
+
+ /* Set the level if requested. */
+ if (set_level) {
+ ret = layer->SetLevel( layer, level );
+ if (ret == DFB_UNSUPPORTED)
+ fprintf( stderr, "Level (%d) not supported!\n\n", level );
+ else if (ret)
+ DirectFBError( "IDirectFBDisplayLayer::SetLevel() failed", ret );
+ }
+
+ /* Set the rotation if requested. */
+ if (set_rotation) {
+ ret = layer->SetRotation( layer, rotation );
+ if (ret == DFB_UNSUPPORTED)
+ fprintf( stderr, "Rotation (%d) not supported!\n\n", level );
+ else if (ret)
+ DirectFBError( "IDirectFBDisplayLayer::SetRotation() failed", ret );
+ }
+
+
+ if (config.flags & DLCONF_WIDTH)
+ printf( "Width %d\n", config.width );
+
+ if (config.flags & DLCONF_HEIGHT)
+ printf( "Height %d\n", config.height );
+
+ if (config.flags & DLCONF_PIXELFORMAT)
+ printf( "Format %s\n",
+ format_names[DFB_PIXELFORMAT_INDEX(config.pixelformat)].name );
+
+ if (config.flags & DLCONF_BUFFERMODE) {
+ printf( "Buffermode " );
+
+ switch (config.buffermode) {
+ case DLBM_FRONTONLY:
+ printf( "FRONTONLY\n" );
+ break;
+ case DLBM_BACKVIDEO:
+ printf( "BACKVIDEO\n" );
+ break;
+ case DLBM_BACKSYSTEM:
+ printf( "BACKSYSTEM\n" );
+ break;
+ case DLBM_TRIPLE:
+ printf( "TRIPLE\n" );
+ break;
+ case DLBM_WINDOWS:
+ printf( "WINDOWS\n" );
+ break;
+ default:
+ printf( "unknown!\n" );
+ break;
+ }
+ }
+
+ if (config.flags & DLCONF_OPTIONS) {
+ printf( "Options " );
+
+ if (config.options == DLOP_NONE) {
+ printf( "none\n" );
+ }
+ else {
+ if (config.options & DLOP_ALPHACHANNEL)
+ printf( "ALPHA CHANNEL " );
+
+ if (config.options & DLOP_DEINTERLACING)
+ printf( "DEINTERLACING " );
+
+ if (config.options & DLOP_DST_COLORKEY)
+ printf( "DST COLOR KEY " );
+
+ if (config.options & DLOP_FIELD_PARITY)
+ printf( "FIELD PARITY " );
+
+ if (config.options & DLOP_FLICKER_FILTERING)
+ printf( "FLICKER FILTERING " );
+
+ if (config.options & DLOP_OPACITY)
+ printf( "OPACITY " );
+
+ if (config.options & DLOP_SRC_COLORKEY)
+ printf( "SRC COLOR KEY " );
+
+ printf( "\n" );
+ }
+ }
+
+ /* Query current level. */
+ if (desc.caps & DLCAPS_LEVELS) {
+ int l;
+
+ ret = layer->GetLevel( layer, &l );
+ if (ret)
+ DirectFBError( "IDirectFBDisplayLayer::GetLevel() failed", ret );
+ else
+ printf( "Level %d\n", l );
+ }
+
+ printf( "\n" );
+}
+
diff --git a/Source/DirectFB/tools/dfbmaster.c b/Source/DirectFB/tools/dfbmaster.c
new file mode 100755
index 0000000..8707f0d
--- /dev/null
+++ b/Source/DirectFB/tools/dfbmaster.c
@@ -0,0 +1,68 @@
+/*
+ (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;
+ sigset_t block;
+
+ /* Initialize DirectFB. */
+ ret = DirectFBInit( &argc, &argv );
+ if (ret) {
+ D_DERROR( ret, "DFBMaster: DirectFBInit() failed!\n" );
+ return ret;
+ }
+
+
+ /* Create super interface. */
+ ret = DirectFBCreate( &dfb );
+ if (ret) {
+ D_DERROR( ret, "DFBMaster: DirectFBCreate() failed!\n" );
+ return ret;
+ }
+
+
+ sigemptyset( &block );
+
+ sigsuspend( &block );
+
+
+ /* Shutdown DirectFB. */
+ dfb->Release( dfb );
+
+ return ret;
+}
+
diff --git a/Source/DirectFB/tools/dfbpenmount.c b/Source/DirectFB/tools/dfbpenmount.c
new file mode 100755
index 0000000..ce3100b
--- /dev/null
+++ b/Source/DirectFB/tools/dfbpenmount.c
@@ -0,0 +1,228 @@
+/*
+ (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 Nikita Egorov <nikego@gmail.com>
+
+ Calibration utility for PenMount's touchscreen panel. Run the program
+ and touch to center of left/top cross ( active cross is blinked ).
+ Then touch to right/bottom cross. The program will create four values for
+ penmout's driver. The values will be printed to the console.
+
+ 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 <directfb.h>
+
+#include <time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <string.h>
+
+static IDirectFB *dfb;
+static IDirectFBSurface *primary;
+static IDirectFBEventBuffer *buffer;
+static int sx,sy;
+
+int
+main( int argc, char *argv[] )
+{
+ int quit = 0;
+ DFBResult err;
+ DFBGraphicsDeviceDescription gdesc;
+
+ char init_str[64];
+ const char* dev = "/dev/ttyS0";
+ char buf[4096]={0};
+
+ char *home = getenv( "HOME" );
+ int file;
+
+ int leftx, topy, rightx, bottomy, ofs;
+ int mouse_x, mouse_y, tx1, ty1;
+ int touch, count, color;
+ struct timespec rqtp,rmtp;
+
+ if(home)
+ sprintf(init_str,"%s/.directfbrc",home);
+ else
+ strcpy(init_str,"root/.directfbrc");
+
+ file = open ( init_str, O_RDONLY );
+ if ( file != -1 ){
+ char *pos, *pos2;
+ read(file, buf, sizeof(buf));
+ close(file);
+
+ pos = strstr( buf, "penmount-device" );
+ if(pos){
+ pos = strchr(pos,'=');
+ if(pos){
+ *pos++ = '\0';
+ if( (pos2=strchr(pos,':'))||(pos2=strchr(pos,'\n')) )
+ *pos2 = '\0';
+ dev = pos;
+ }
+ }
+ }
+ printf( "penmount device '%s'\n", dev );
+
+ sprintf( init_str,"--dfb:penmount-device=%s:raw", dev);
+ argv[argc++] = init_str;
+
+ if (DirectFBInit( &argc, &argv ) != DFB_OK)
+ return 1;
+
+ if (DirectFBCreate( &dfb ) != DFB_OK)
+ return 1;
+
+ dfb->GetDeviceDescription( dfb, &gdesc );
+
+ err = dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
+ if (err != DFB_OK)
+ DirectFBError( "Failed requesting exclusive access", err );
+
+ err = dfb->CreateInputEventBuffer( dfb, DICAPS_ALL, DFB_FALSE, &buffer );
+ if (err != DFB_OK) {
+ DirectFBError( "CreateInputEventBuffer failed", err );
+ dfb->Release( dfb );
+ return 1;
+ }
+
+ {
+ DFBSurfaceDescription dsc;
+
+ dsc.flags = DSDESC_CAPS;
+ dsc.caps = (gdesc.drawing_flags & DSDRAW_BLEND) ?
+ DSCAPS_PRIMARY | DSCAPS_FLIPPING :
+ DSCAPS_PRIMARY | DSCAPS_FLIPPING | DSCAPS_SYSTEMONLY;
+
+ err = dfb->CreateSurface( dfb, &dsc, &primary );
+ if (err != DFB_OK) {
+ DirectFBError( "Failed creating primary surface", err );
+ buffer->Release( buffer );
+ dfb->Release( dfb );
+ return 1;
+ }
+
+ primary->GetSize( primary, &sx, &sy );
+ }
+
+ primary->Clear( primary, 0x0, 0x0, 0x0, 0xFF );
+
+ leftx = sx/10;
+ topy = sy/10;
+ rightx = sx*9/10;
+ bottomy = sy*9/10;
+ ofs = 10;
+
+ primary->SetColor( primary,0xFF,0,0,0xFF );
+ primary->DrawLine( primary,rightx-ofs,bottomy,rightx+ofs,bottomy );
+ primary->DrawLine( primary,rightx,bottomy-ofs,rightx,bottomy+ofs );
+
+ err = primary->Flip( primary, NULL, 0 );
+ if (err != DFB_OK) {
+ DirectFBError( "Failed flipping the primary surface", err );
+ primary->Release( primary );
+ buffer->Release( buffer );
+ dfb->Release( dfb );
+ return 1;
+ }
+
+ mouse_x=0,mouse_y=0,tx1=0,ty1=0;
+ touch=0,count=0,color=0;
+
+ while (!quit) {
+ DFBInputEvent evt;
+ rqtp.tv_nsec = 10000;
+ rqtp.tv_sec = 0;
+ nanosleep( &rqtp,&rmtp );
+ if (count++ >= 30){
+ count = 0;
+ color = !color;
+ if (color)
+ primary->SetColor( primary,0x00,0xFF,0,0xFF );
+ else
+ primary->SetColor( primary,0xFF,0x00,0,0xFF );
+
+ switch(touch){
+ case 0:
+ primary->DrawLine( primary,leftx-ofs,topy,leftx+ofs,topy );
+ primary->DrawLine( primary,leftx,topy-ofs,leftx,topy+ofs );
+ break;
+ case 1:
+ primary->DrawLine( primary,rightx-ofs,bottomy,rightx+ofs,bottomy );
+ primary->DrawLine( primary,rightx,bottomy-ofs,rightx,bottomy+ofs );
+ break;
+ }
+ primary->Flip( primary, NULL, 0 );
+ }
+
+ while (buffer->GetEvent( buffer, DFB_EVENT(&evt) ) == DFB_OK) {
+ if ( evt.type == DIET_AXISMOTION){
+ if (evt.flags & DIEF_AXISABS) {
+ switch (evt.axis) {
+ case DIAI_X:
+ mouse_x = evt.axisabs;
+ break;
+ case DIAI_Y:
+ mouse_y = evt.axisabs;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ if ( evt.type == DIET_BUTTONPRESS ){
+ switch(++touch){
+ case 1: //save first touchscreen position
+ tx1=mouse_x;
+ ty1=mouse_y;
+ break;
+ case 2://build new calibration values and quit
+ {
+ float dx = ((float)mouse_x-tx1)/(rightx-leftx);
+ float dy = ((float)mouse_y-ty1)/(bottomy-topy);
+ printf( "Insert followed values into source code of penmount's driver\n'inputdrivers/penmount/penmount.c:96,99' and rebuild:\n" );
+ printf( "min_x=%d min_y=%d\n",(int)(tx1-leftx*dx+.5),(int)(ty1-topy*dy+.5));
+ printf( "max_x=%d max_y=%d\n",(int)(mouse_x+leftx*dx+.5),(int)(mouse_y+topy*dy+.5));
+ quit = 1;
+ break;
+ }
+ }
+ }
+ if (evt.type == DIET_KEYPRESS && evt.key_id == DIKI_ESCAPE)
+ quit = 1;
+ }
+ }
+ primary->Release( primary );
+ buffer->Release( buffer );
+ dfb->Release( dfb );
+
+ return 0;
+}
+
diff --git a/Source/DirectFB/tools/dfbproxy.c b/Source/DirectFB/tools/dfbproxy.c
new file mode 100755
index 0000000..bf48af0
--- /dev/null
+++ b/Source/DirectFB/tools/dfbproxy.c
@@ -0,0 +1,162 @@
+/*
+ (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 <directfb.h>
+
+#include <direct/debug.h>
+#include <direct/interface.h>
+#include <direct/mem.h>
+#include <direct/messages.h>
+
+#include <voodoo/play.h>
+#include <voodoo/server.h>
+
+/*****************************************************************************/
+
+static DFBBoolean parse_command_line( int argc, char *argv[] );
+static DFBResult server_run();
+
+/*****************************************************************************/
+
+int
+main( int argc, char *argv[] )
+{
+ DFBResult ret;
+
+ /* 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;
+
+ /* Run the server. */
+ return server_run();
+}
+
+/*****************************************************************************/
+
+static DirectResult
+ConstructDispatcher( VoodooServer *server,
+ VoodooManager *manager,
+ const char *name,
+ void *ctx,
+ VoodooInstanceID *ret_instance )
+{
+ DirectResult ret;
+ DirectInterfaceFuncs *funcs;
+ void *interface;
+ VoodooInstanceID instance;
+
+ D_ASSERT( server != NULL );
+ D_ASSERT( manager != NULL );
+ D_ASSERT( name != NULL );
+ D_ASSERT( ret_instance != NULL );
+
+ ret = DirectGetInterface( &funcs, name, "Dispatcher", NULL, NULL );
+ if (ret)
+ return ret;
+
+ ret = funcs->Allocate( &interface );
+ if (ret)
+ return ret;
+
+ ret = funcs->Construct( interface, manager, &instance );
+ if (ret)
+ return ret;
+
+ *ret_instance = instance;
+
+ return DFB_OK;
+}
+
+/*****************************************************************************/
+
+static DFBBoolean
+parse_command_line( int argc, char *argv[] )
+{
+ return DFB_TRUE;
+}
+
+static DFBResult
+server_run()
+{
+ DFBResult ret;
+ VoodooPlayer *player = NULL;
+ VoodooServer *server = NULL;
+
+ ret = voodoo_player_create( NULL, &player );
+ if (ret) {
+ D_ERROR( "Voodoo/Proxy: Could not create the player (%s)!\n", DirectFBErrorString(ret) );
+ goto out;
+ }
+
+ ret = voodoo_server_create( &server );
+ if (ret) {
+ D_ERROR( "Voodoo/Proxy: Could not create the server (%s)!\n", DirectFBErrorString(ret) );
+ goto out;
+ }
+
+ ret = voodoo_server_register( server, "IDirectFB", ConstructDispatcher, NULL );
+ if (ret) {
+ D_ERROR( "Voodoo/Proxy: Could not register super interface 'IDirectFB'!\n" );
+ goto out;
+ }
+
+ ret = voodoo_server_register( server, "IDiVine", ConstructDispatcher, NULL );
+ if (ret) {
+ D_ERROR( "Voodoo/Proxy: Could not register super interface 'IDiVine'!\n" );
+ goto out;
+ }
+
+ ret = voodoo_server_run( server, true );
+ if (ret)
+ D_ERROR( "Voodoo/Proxy: Server exiting with error (%s)!\n", DirectFBErrorString(ret) );
+
+out:
+ if (server)
+ voodoo_server_destroy( server );
+
+ if (player)
+ voodoo_player_destroy( player );
+
+ return ret;
+}
+
diff --git a/Source/DirectFB/tools/dfbscreen.c b/Source/DirectFB/tools/dfbscreen.c
new file mode 100755
index 0000000..b961d38
--- /dev/null
+++ b/Source/DirectFB/tools/dfbscreen.c
@@ -0,0 +1,660 @@
+/*
+ (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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <direct/messages.h>
+#include <direct/util.h>
+
+#include <directfb.h>
+#include <directfb_strings.h>
+
+static const DirectFBScreenMixerTreeNames( tree_names );
+static const DirectFBScreenEncoderScanModeNames( scan_mode_names );
+static const DirectFBScreenEncoderTestPictureNames( test_picture_names );
+static const DirectFBScreenEncoderTVStandardsNames( tv_standard_names );
+static const DirectFBScreenOutputSignalsNames( signal_names );
+
+/**************************************************************************************************/
+
+static IDirectFB *dfb;
+static IDirectFBScreen *screen;
+static DFBScreenDescription desc;
+
+/**************************************************************************************************/
+
+static DFBScreenID id = DSCID_PRIMARY;
+static int mixer = 0;
+static int encoder = 0;
+static int output = 0;
+
+/**************************************************************************************************/
+
+static DFBScreenMixerConfig mixer_config;
+static DFBScreenEncoderConfig encoder_config;
+static DFBScreenOutputConfig output_config;
+
+/**************************************************************************************************/
+
+static bool parse_command_line( int argc, char *argv[] );
+
+/**************************************************************************************************/
+
+static void dump_mixer_config ( const DFBScreenMixerConfig *config );
+static void dump_encoder_config( const DFBScreenEncoderConfig *config );
+
+/**************************************************************************************************/
+
+int
+main( int argc, char *argv[] )
+{
+ DFBResult ret;
+
+ /* Initialize DirectFB including command line parsing. */
+ ret = DirectFBInit( &argc, &argv );
+ if (ret) {
+ D_DERROR( ret, "Tools/Screen: DirectFBInit() failed!\n" );
+ goto error;
+ }
+
+ /* Parse the command line. */
+ if (!parse_command_line( argc, argv ))
+ goto error;
+
+ /* Create the super interface. */
+ ret = DirectFBCreate( &dfb );
+ if (ret) {
+ D_DERROR( ret, "Tools/Screen: DirectFBCreate() failed!\n" );
+ goto error;
+ }
+
+ /* Get the primary display screen. */
+ ret = dfb->GetScreen( dfb, id, &screen );
+ if (ret) {
+ if (ret == DFB_IDNOTFOUND)
+ fprintf (stderr, "\nUnknown screen id, check 'dfbinfo' for valid values.\n\n");
+ else
+ D_DERROR( ret, "Tools/Screen: IDirectFB::GetScreen() failed!\n" );
+
+ goto error;
+ }
+
+ /* Get a description of the screen. */
+ ret = screen->GetDescription( screen, &desc );
+ if (ret) {
+ D_DERROR( ret, "Tools/Screen: IDirectFBScreen::GetDescription() failed!\n" );
+ goto error;
+ }
+
+ /* Check arguments. */
+ if (mixer_config.flags && (mixer < 0 || mixer >= desc.mixers)) {
+ fprintf (stderr, "\nUnknown mixer (%d), check 'dfbinfo' for valid values.\n\n", mixer);
+ goto error;
+ }
+
+ if (encoder_config.flags && (encoder < 0 || encoder >= desc.encoders)) {
+ fprintf (stderr, "\nUnknown encoder (%d), check 'dfbinfo' for valid values.\n\n", encoder);
+ goto error;
+ }
+
+ if (output_config.flags && (output < 0 || output >= desc.outputs)) {
+ fprintf (stderr, "\nUnknown output (%d), check 'dfbinfo' for valid values.\n\n", output);
+ goto error;
+ }
+
+ printf( "\n" );
+
+ /* Do mixer. */
+ if (mixer < desc.mixers && mixer >= 0) {
+ DFBScreenMixerConfig config;
+
+ printf( "\nMixer %d\n", mixer );
+
+ if (mixer_config.flags) {
+ ret = screen->SetMixerConfiguration( screen, mixer, &mixer_config );
+ if (ret) {
+ D_DERROR( ret, "Tools/Screen: "
+ "IDirectFBScreen::SetMixerConfiguration(%d) failed!\n", mixer );
+ goto error;
+ }
+ }
+
+ ret = screen->GetMixerConfiguration( screen, mixer, &config );
+ if (ret) {
+ D_DERROR( ret, "Tools/Screen: "
+ "IDirectFBScreen::GetMixerConfiguration(%d) failed!\n", mixer );
+ goto error;
+ }
+
+ dump_mixer_config( &config );
+ }
+
+ /* Do encoder. */
+ if (encoder < desc.encoders && encoder >= 0) {
+ DFBScreenEncoderConfig config;
+
+ printf( "\nEncoder %d\n", encoder );
+
+ if (encoder_config.flags) {
+ ret = screen->SetEncoderConfiguration( screen, encoder, &encoder_config );
+ if (ret) {
+ D_DERROR( ret, "Tools/Screen: "
+ "IDirectFBScreen::SetEncoderConfiguration(%d) failed!\n", encoder );
+ goto error;
+ }
+ }
+
+ ret = screen->GetEncoderConfiguration( screen, encoder, &config );
+ if (ret) {
+ D_DERROR( ret, "Tools/Screen: "
+ "IDirectFBScreen::GetEncoderConfiguration(%d) failed!\n", mixer );
+ goto error;
+ }
+
+ dump_encoder_config( &config );
+ }
+
+error:
+ /* Release the display screen. */
+ if (screen)
+ screen->Release( screen );
+
+ /* Release the super interface. */
+ if (dfb)
+ dfb->Release( dfb );
+
+ return ret;
+}
+
+/**************************************************************************************************/
+
+typedef struct __AnyOption AnyOption;
+
+
+typedef bool (*ParseFunc)( const AnyOption *option,
+ const char *arg );
+
+struct __AnyOption {
+ const char *short_name;
+ const char *long_name;
+
+ const char *arg_name;
+ const char *arg_desc;
+
+ void *value;
+
+ unsigned int *flags;
+ unsigned int flag;
+
+ ParseFunc parse;
+ const void *data;
+};
+
+typedef struct {
+ int value;
+ const char *name;
+} ValueName;
+
+/**************************************************************************************************/
+
+static bool parse_int ( const AnyOption *option,
+ const char *arg );
+
+static bool parse_enum ( const AnyOption *option,
+ const char *arg );
+
+static bool parse_ids ( const AnyOption *option,
+ const char *arg );
+
+static bool parse_color( const AnyOption *option,
+ const char *arg );
+
+/**************************************************************************************************/
+
+static const AnyOption options[] = {
+ { "-s", "--screen", "<id>", "ID of screen to use",
+ &id, NULL, 0, parse_int, NULL },
+
+
+ { "-m", "--mixer", "<index>", "Index of mixer to use",
+ &mixer, NULL, 0, parse_int, NULL },
+
+ { "-mt", "--tree", "<mode>", "Set (sub) tree mode",
+ &mixer_config.tree, &mixer_config.flags,
+ DSMCONF_TREE, parse_enum, tree_names },
+
+ { "-mm", "--max-level", "<level>", "Set maximum level for SUB_LEVEL mode",
+ &mixer_config.level, &mixer_config.flags,
+ DSMCONF_LEVEL, parse_int, NULL },
+
+ { "-ml", "--layers", "<layers>", "Select layers for SUB_LAYERS mode",
+ &mixer_config.layers, &mixer_config.flags,
+ DSMCONF_LAYERS, parse_ids, NULL },
+
+ { "-mb", "--background", "<rgb>", "Set background color (hex)",
+ &mixer_config.background, &mixer_config.flags,
+ DSMCONF_BACKGROUND, parse_color, NULL },
+
+
+ { "-e", "--encoder", "<index>", "Index of encoder to use",
+ &encoder, NULL, 0, parse_int, NULL },
+
+ { "-et", "--tv-standard", "<standard>", "Set TV standard",
+ &encoder_config.tv_standard, &encoder_config.flags,
+ DSECONF_TV_STANDARD, parse_enum, tv_standard_names },
+
+ { "-ep", "--test-picture", "<mode>", "Set test picture mode",
+ &encoder_config.test_picture, &encoder_config.flags,
+ DSECONF_TEST_PICTURE, parse_enum, test_picture_names },
+
+ { "-em", "--sel-mixer", "<index>", "Select mixer for input",
+ &encoder_config.mixer, &encoder_config.flags,
+ DSECONF_MIXER, parse_int, NULL },
+
+ { "-es", "--encode-sigs", "<signals>", "Select signal(s) to encode",
+ &encoder_config.out_signals, &encoder_config.flags,
+ DSECONF_OUT_SIGNALS, parse_enum, signal_names },
+
+ { "-ec", "--scan-mode", "<mode>", "Set scan mode",
+ &encoder_config.scanmode, &encoder_config.flags,
+ DSECONF_SCANMODE, parse_enum, scan_mode_names },
+
+
+ { "-o", "--output", "<index>", "Index of output to use",
+ &output, NULL, 0, parse_int, NULL }
+};
+
+static void
+print_usage (const char *prg_name)
+{
+ int i;
+
+ fprintf (stderr, "\nDirectFB Screen Configuration (version %s)\n\n", DIRECTFB_VERSION);
+ fprintf (stderr, "Usage: %s [options]\n\n", prg_name);
+ fprintf (stderr, "Options:\n");
+ fprintf (stderr, " -h --help Show this help message\n");
+ fprintf (stderr, " -v --version Print version information\n");
+
+ for (i=0; i<D_ARRAY_SIZE(options); i++) {
+ const AnyOption *option = &options[i];
+
+ fprintf( stderr, " %-3s %-16s %-12s %s\n",
+ option->short_name, option->long_name, option->arg_name, option->arg_desc );
+ }
+
+ fprintf (stderr, "\n");
+}
+
+static bool
+parse_int( const AnyOption *option, const char *arg )
+{
+ int ret;
+ char *end;
+
+ ret = strtoul( arg, &end, option->data ? (unsigned long) option->data : 10 );
+
+ if (*end || ret < 0) {
+ fprintf( stderr, "\nInvalid argument to '%s' or '%s' specified!\n\n",
+ option->short_name, option->long_name );
+
+ return false;
+ }
+
+ *((int*)option->value) = ret;
+
+ return true;
+}
+
+static bool
+parse_enum( const AnyOption *option, const char *arg )
+{
+ int val = 0;
+
+ if (! strcasecmp( arg, "help" )) {
+ const ValueName *vn = option->data;
+
+ fprintf( stderr, "\nPossible arguments to '%s' or '%s':\n",
+ option->short_name, option->long_name );
+
+ do {
+ fprintf( stderr, " %s\n", vn->name );
+ } while (vn++->value);
+
+ fprintf (stderr, "\n");
+
+ return false;
+ }
+
+ while (arg[0] == ',')
+ arg++;
+
+ while (arg[0]) {
+ char *p;
+ int len;
+ int vc = 0;
+ bool ok = false;
+ const ValueName *vn = option->data;
+
+ p = strchr( arg, ',' );
+ if (p)
+ len = p - arg;
+ else
+ len = strlen( arg );
+
+ do {
+ int vlen = strlen(vn->name);
+
+ if (strncasecmp( vn->name, arg, len ))
+ continue;
+
+ vc = vn->value;
+ ok = true;
+
+ if (vlen == len)
+ break;
+ } while (vn++->value);
+
+ if (ok)
+ val |= vc;
+ else {
+ fprintf( stderr, "\nInvalid argument to '%s' or '%s' specified, "
+ "pass 'help' for a list!\n\n", option->short_name, option->long_name );
+ return false;
+ }
+
+ arg += len;
+
+ while (arg[0] == ',')
+ arg++;
+ }
+
+ *((int*)option->value) = val;
+
+ return true;
+}
+
+static bool
+parse_ids( const AnyOption *option, const char *arg )
+{
+ u32 val = 0;
+ int alen = strlen( arg );
+ char *abuf = alloca( alen + 1 );
+
+ memcpy( abuf, arg, alen + 1 );
+
+ if (! strcasecmp( arg, "help" )) {
+ fprintf( stderr, "\nCheck 'dfbinfo' for valid values.\n\n" );
+ return false;
+ }
+
+ while (abuf[0] == ',')
+ abuf++;
+
+ while (abuf[0]) {
+ char *p;
+ int len;
+ int ret;
+
+ p = strchr( abuf, ',' );
+ if (p) {
+ len = p - abuf;
+
+ abuf[len++] = 0;
+ }
+ else
+ len = strlen( abuf );
+
+ ret = strtoul( abuf, &p, 10 );
+
+ if (*p || ret < 0) {
+ fprintf( stderr, "\nInvalid argument (%s) to '%s' or '%s' specified!\n\n",
+ p, option->short_name, option->long_name );
+
+ return false;
+ }
+
+ val |= (1 << ret);
+
+ abuf += len;
+
+ while (abuf[0] == ',')
+ abuf++;
+ }
+
+ *((u32*)option->value) = val;
+
+ return true;
+}
+
+static bool
+parse_color( const AnyOption *option, const char *arg )
+{
+ unsigned long ret;
+ char *end;
+ DFBColor *color = option->value;
+
+ ret = strtoul( arg, &end, 16 );
+
+ if (*end) {
+ fprintf( stderr, "\nInvalid argument (%s) to '%s' or '%s' specified!\n\n",
+ end, option->short_name, option->long_name );
+
+ return false;
+ }
+
+ color->a = (ret >> 24) & 0xff;
+ color->r = (ret >> 16) & 0xff;
+ color->g = (ret >> 8) & 0xff;
+ color->b = (ret ) & 0xff;
+
+ return true;
+}
+
+static bool
+parse_option( const AnyOption *option, const char *arg )
+{
+ if (!option->parse( option, arg ))
+ return false;
+
+ if (option->flags)
+ *option->flags |= option->flag;
+
+ return true;
+}
+
+static bool
+parse_command_line( int argc, char *argv[] )
+{
+ int i, n;
+
+ for (n = 1; n < argc; n++) {
+ bool ok = false;
+ 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, "dfbscreen version %s\n", DIRECTFB_VERSION);
+ return false;
+ }
+
+ for (i=0; i<D_ARRAY_SIZE(options); i++) {
+ const AnyOption *opt = &options[i];
+
+ if (!strcmp (arg, opt->short_name) || !strcmp (arg, opt->long_name)) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return false;
+ }
+
+ if (!parse_option( opt, argv[n] ))
+ return false;
+
+ ok = true;
+
+ break;
+ }
+ }
+
+ if (!ok) {
+ print_usage (argv[0]);
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/**************************************************************************************************/
+
+static const char *
+tree_name( DFBScreenMixerTree tree )
+{
+ int i;
+
+ for (i=0; i<D_ARRAY_SIZE(tree_names); i++) {
+ if (tree_names[i].tree == tree)
+ return tree_names[i].name;
+ }
+
+ return "<invalid>";
+}
+
+static void
+dump_mixer_config( const DFBScreenMixerConfig *config )
+{
+ int n;
+
+ printf( "\n" );
+
+ if (config->flags & DSMCONF_TREE)
+ printf( "Tree: %s\n", tree_name( config->tree ) );
+
+ if (config->flags & DSMCONF_LEVEL)
+ printf( "Level: %d\n", config->level );
+
+ if (config->flags & DSMCONF_LAYERS) {
+ printf( "Layers: " );
+
+ for (n=0; n<DFB_DISPLAYLAYER_IDS_MAX; n++) {
+ if (DFB_DISPLAYLAYER_IDS_HAVE( config->layers, n ))
+ printf( "(%02x) ", n );
+ }
+
+ printf( "\n" );
+ }
+
+ if (config->flags & DSMCONF_BACKGROUND)
+ printf( "Background: 0x%02x, 0x%02x, 0x%02x (RGB)\n",
+ config->background.r, config->background.g, config->background.b );
+
+ printf( "\n" );
+}
+
+/**************************************************************************************************/
+
+static const char *
+test_picture_name( DFBScreenEncoderTestPicture test_picture )
+{
+ int i;
+
+ for (i=0; i<D_ARRAY_SIZE(test_picture_names); i++) {
+ if (test_picture_names[i].test_picture == test_picture)
+ return test_picture_names[i].name;
+ }
+
+ return "<invalid>";
+}
+
+static const char *
+scan_mode_name( DFBScreenEncoderTestPicture scan_mode )
+{
+ int i;
+
+ for (i=0; i<D_ARRAY_SIZE(scan_mode_names); i++) {
+ if (scan_mode_names[i].scan_mode == scan_mode)
+ return scan_mode_names[i].name;
+ }
+
+ return "<invalid>";
+}
+
+static void
+dump_encoder_config( const DFBScreenEncoderConfig *config )
+{
+ int i;
+
+ printf( "\n" );
+
+ if (config->flags & DSECONF_TV_STANDARD) {
+ printf( "TV Standard: " );
+
+ for (i=0; i<D_ARRAY_SIZE(tv_standard_names); i++) {
+ if (config->tv_standard & tv_standard_names[i].standard)
+ printf( "%s ", tv_standard_names[i].name );
+ }
+
+ printf( "\n" );
+ }
+
+ if (config->flags & DSECONF_TEST_PICTURE)
+ printf( "Test Picture: %s\n", test_picture_name( config->test_picture ) );
+
+ if (config->flags & DSECONF_MIXER)
+ printf( "Mixer: %d\n", config->mixer );
+
+ if (config->flags & DSECONF_OUT_SIGNALS) {
+ printf( "Signals: " );
+
+ for (i=0; i<D_ARRAY_SIZE(signal_names); i++) {
+ if (config->out_signals & signal_names[i].signal)
+ printf( "%s ", signal_names[i].name );
+ }
+
+ printf( "\n" );
+ }
+
+ if (config->flags & DSECONF_SCANMODE)
+ printf( "Scan Mode: %s\n", scan_mode_name( config->scanmode ) );
+
+ printf( "\n" );
+}
+
diff --git a/Source/DirectFB/tools/directfb-csource.c b/Source/DirectFB/tools/directfb-csource.c
new file mode 100755
index 0000000..027bd83
--- /dev/null
+++ b/Source/DirectFB/tools/directfb-csource.c
@@ -0,0 +1,894 @@
+/*
+ (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>.
+
+ directfb-csource is based on gdk-pixbuf-csource, a GdkPixbuf
+ based image CSource generator Copyright (C) 1999, 2001 Tim Janik
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <assert.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <png.h>
+
+#include <directfb.h>
+
+#include <direct/types.h>
+#include <direct/util.h>
+
+#include <gfx/convert.h>
+
+#define DFB_DITHER565 DFB_DITHER_ADVANCED
+#include <misc/dither565.h>
+
+
+static struct {
+ DFBSurfacePixelFormat format;
+ const char *name;
+} pixelformats[] = {
+ { DSPF_ARGB, "ARGB" },
+ { DSPF_ARGB1555, "ARGB1555" },
+ { DSPF_ARGB2554, "ARGB2554" },
+ { DSPF_ARGB4444, "ARGB4444" },
+ { DSPF_RGB32, "RGB32" },
+ { DSPF_RGB24, "RGB24" },
+ { DSPF_RGB16, "RGB16" },
+ { DSPF_RGB332, "RGB332" },
+ { DSPF_A8, "A8" },
+ { DSPF_LUT8, "LUT8" }
+};
+static int n_pixelformats = D_ARRAY_SIZE( pixelformats );
+
+
+static void print_usage (const char *prg_name);
+static DFBResult load_image (const char *filename,
+ DFBSurfaceDescription *desc,
+ DFBColor *palette,
+ int *palette_size,
+ DFBSurfacePixelFormat rgbformat,
+ bool dither565);
+static void dither_rgb16 (const u32 *src,
+ u16 *dest,
+ int y,
+ int width);
+static DFBResult merge_images (DFBSurfaceDescription *images,
+ int num_images,
+ DFBSurfaceDescription *dest,
+ DFBRectangle *rectangles);
+static DFBResult dump_raw_data (const char *name,
+ const unsigned char *data,
+ unsigned int len);
+static DFBResult dump_image (const char *name,
+ DFBSurfaceDescription *desc,
+ DFBColor *palette,
+ int palette_size);
+static DFBResult dump_rectangles (const char *name,
+ DFBRectangle *rectangles,
+ const char **names,
+ int num_rects);
+static char * variable_name (const char *name);
+static char * base_name (const char *name);
+
+
+int main (int argc,
+ const char *argv[])
+{
+ DFBSurfaceDescription desc = { flags: 0 };
+ DFBSurfacePixelFormat format = DSPF_UNKNOWN;
+ DFBSurfacePixelFormat rgbformat = DSPF_UNKNOWN;
+ DFBColor palette[256];
+
+ const char *filename[argc];
+ const char *name = NULL;
+ int palette_size = 0;
+ int num_images = 0;
+ int i, n;
+ bool rawmode = 0;
+ bool dither565 = 0;
+
+ /* parse command line */
+
+ for (n = 1; n < argc; n++) {
+ if (strncmp (argv[n], "--", 2) == 0) {
+
+ const char *arg = argv[n] + 2;
+
+ if (strcmp (arg, "help") == 0) {
+ print_usage (argv[0]);
+ return EXIT_SUCCESS;
+ }
+ if (strcmp (arg, "version") == 0) {
+ fprintf (stderr, "directfb-csource version %s\n",
+ DIRECTFB_VERSION);
+ return EXIT_SUCCESS;
+ }
+ if (strcmp (arg, "raw") == 0) {
+ rawmode = 1;
+ continue;
+ }
+ if (strcmp (arg, "dither-rgb16") == 0) {
+ dither565 = 1;
+ continue;
+ }
+ if (strncmp (arg, "format=", 7) == 0 && !format) {
+ for (i = 0; i < n_pixelformats && !format; i++)
+ if (!strcasecmp (pixelformats[i].name, arg + 7))
+ format = pixelformats[i].format;
+ if (format)
+ continue;
+ }
+ if (strncmp (arg, "rgbformat=", 10) == 0 && !rgbformat) {
+ for (i = 0; i < n_pixelformats && !rgbformat; i++)
+ if (!strcasecmp (pixelformats[i].name, arg + 10))
+ rgbformat = pixelformats[i].format;
+ if (rgbformat)
+ continue;
+ }
+ if (strncmp (arg, "name=", 5) == 0 && !name) {
+ name = arg + 5;
+ if (*name)
+ continue;
+ }
+
+ print_usage (argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ filename[num_images++] = argv[n];
+ }
+
+ /* check parameters */
+
+ if (! num_images) {
+ print_usage (argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if (num_images > 1 && rawmode) {
+ fprintf (stderr,
+ "Multiple input files not allowed in raw mode.\n");
+ return EXIT_FAILURE;
+ }
+
+ if (num_images > 1 && !name) {
+ fprintf (stderr,
+ "You must specify a variable name when using multiple images.\n");
+ return EXIT_FAILURE;
+ }
+
+ /* load the first image */
+
+ if (rawmode) {
+
+ struct stat statbuf;
+ if (0 == stat(filename[0], &statbuf))
+ {
+ FILE *f;
+ unsigned char *data = alloca(statbuf.st_size);
+ memset(data, 0, statbuf.st_size);
+
+ f = fopen(filename[0], "r");
+ if (f)
+ {
+ fread(data, statbuf.st_size, 1, f);
+ fclose(f);
+ }
+
+ return dump_raw_data(name ? : strrchr (filename[0], '/') ? : filename[0],
+ data, statbuf.st_size);
+ }
+
+ }
+ else {
+ if (format) {
+ desc.flags = DSDESC_PIXELFORMAT;
+ desc.pixelformat = format;
+ }
+
+ if (load_image (filename[0],
+ &desc, palette, &palette_size,
+ rgbformat, dither565) != DFB_OK)
+ return EXIT_FAILURE;
+
+ /* dump it and quit if this is the only image on the command line */
+
+ if (num_images == 1)
+ return dump_image (name ? : strrchr (filename[0], '/') ? : filename[0],
+ &desc, palette, palette_size);
+ }
+
+ /* merge multiple images into one surface */
+ {
+ DFBSurfaceDescription image[num_images];
+ DFBRectangle rect[num_images];
+ DFBColor foo[256];
+ int foo_size;
+
+ image[0] = desc;
+
+ for (i = 1; i < num_images; i++) {
+ image[i].flags = DSDESC_PIXELFORMAT;
+ image[i].pixelformat = desc.pixelformat;
+
+ if (load_image (filename[i],
+ image + i, foo, &foo_size, rgbformat,
+ dither565) != DFB_OK)
+ return EXIT_FAILURE;
+ }
+
+ if (merge_images (image, num_images, &desc, rect) != DFB_OK)
+ return EXIT_FAILURE;
+
+ /* dump the rectangles, then the surface */
+
+ if (dump_rectangles (name, rect, filename, num_images) != DFB_OK)
+ return EXIT_FAILURE;
+
+ return dump_image (name, &desc, palette, palette_size);
+ }
+}
+
+static void print_usage (const char *prg_name)
+{
+ fprintf (stderr, "directfb-csource version %s\n\n", DIRECTFB_VERSION);
+ fprintf (stderr, "Usage: %s [options] <imagefile>\n", prg_name);
+ fprintf (stderr, " --name=<identifer> specifies variable name\n");
+ fprintf (stderr, " --format=<identifer> specifies surface format\n");
+ fprintf (stderr, " --rgbformat=<identifer> specifies format for non-alpha images\n");
+ fprintf (stderr, " --multi multiple images\n");
+ fprintf (stderr, " --raw dump a single file directly to header\n");
+ fprintf (stderr, " --dither-rgb16 dither images rendered to RGB16 surfaces\n");
+ fprintf (stderr, " --help show this help message\n");
+ fprintf (stderr, " --version print version information\n");
+ fprintf (stderr, "\n");
+ fprintf (stderr, "See the directfb-csource(1) man-page for more information.\n");
+ fprintf (stderr, "\n");
+}
+
+static DFBResult load_image (const char *filename,
+ DFBSurfaceDescription *desc,
+ DFBColor *palette,
+ int *palette_size,
+ DFBSurfacePixelFormat rgbformat,
+ bool dither565)
+{
+ DFBSurfacePixelFormat dest_format;
+ DFBSurfacePixelFormat src_format;
+ FILE *fp;
+ png_structp png_ptr = NULL;
+ png_infop info_ptr = NULL;
+ png_uint_32 width, height;
+ unsigned char *data = NULL;
+ int type;
+ char header[8];
+ int bytes, pitch;
+
+ dest_format =
+ (desc->flags & DSDESC_PIXELFORMAT) ? desc->pixelformat : DSPF_UNKNOWN;
+
+ desc->flags = 0;
+ desc->preallocated[0].data = NULL;
+
+ if (!(fp = fopen (filename, "rb"))) {
+ fprintf (stderr, "Failed to open file '%s': %s.\n",
+ filename, strerror (errno));
+ goto cleanup;
+ }
+
+ bytes = fread (header, 1, sizeof(header), fp);
+ if (png_sig_cmp ((unsigned char*) header, 0, bytes)) {
+ fprintf (stderr, "File '%s' doesn't seem to be a PNG image file.\n",
+ filename);
+ goto cleanup;
+ }
+
+ png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,
+ NULL, NULL, NULL);
+ if (!png_ptr)
+ goto cleanup;
+
+ if (setjmp (png_ptr->jmpbuf)) {
+ if (desc->preallocated[0].data) {
+ free (desc->preallocated[0].data);
+ desc->preallocated[0].data = NULL;
+ }
+
+ /* data might have been clobbered,
+ set it to NULL and leak instead of crashing */
+ data = NULL;
+
+ goto cleanup;
+ }
+
+ info_ptr = png_create_info_struct (png_ptr);
+ if (!info_ptr)
+ goto cleanup;
+
+ png_init_io (png_ptr, fp);
+ png_set_sig_bytes (png_ptr, bytes);
+
+ png_read_info (png_ptr, info_ptr);
+
+ png_get_IHDR (png_ptr, info_ptr,
+ &width, &height, &bytes, &type, NULL, NULL, NULL);
+
+ if (bytes == 16)
+ png_set_strip_16 (png_ptr);
+
+#ifdef WORDS_BIGENDIAN
+ png_set_swap_alpha (png_ptr);
+#else
+ png_set_bgr (png_ptr);
+#endif
+
+ src_format = (type & PNG_COLOR_MASK_ALPHA) ? DSPF_ARGB : DSPF_RGB32;
+ switch (type) {
+ case PNG_COLOR_TYPE_GRAY:
+ if (dest_format == DSPF_A8) {
+ src_format = DSPF_A8;
+ break;
+ }
+ /* fallthru */
+ case PNG_COLOR_TYPE_GRAY_ALPHA:
+ png_set_gray_to_rgb (png_ptr);
+ if (rgbformat)
+ dest_format = rgbformat;
+ break;
+
+ case PNG_COLOR_TYPE_PALETTE:
+ if (dest_format == DSPF_LUT8) {
+ src_format = DSPF_LUT8;
+ break;
+ }
+ png_set_palette_to_rgb (png_ptr);
+ /* fallthru */
+ case PNG_COLOR_TYPE_RGB:
+ if (rgbformat)
+ dest_format = rgbformat;
+ case PNG_COLOR_TYPE_RGB_ALPHA:
+ if (dest_format == DSPF_RGB24) {
+ png_set_strip_alpha (png_ptr);
+ src_format = DSPF_RGB24;
+ }
+ break;
+ }
+
+ switch (src_format) {
+ case DSPF_LUT8:
+ if (info_ptr->num_palette) {
+ png_byte *alpha;
+ int i, num;
+
+ *palette_size = MIN (info_ptr->num_palette, 256);
+ for (i = 0; i < *palette_size; i++) {
+ palette[i].a = 0xFF;
+ palette[i].r = info_ptr->palette[i].red;
+ palette[i].g = info_ptr->palette[i].green;
+ palette[i].b = info_ptr->palette[i].blue;
+ }
+ if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) {
+ png_get_tRNS (png_ptr, info_ptr, &alpha, &num, NULL);
+ for (i = 0; i < MIN (num, *palette_size); i++)
+ palette[i].a = alpha[i];
+ }
+ }
+ break;
+ case DSPF_RGB32:
+ png_set_filler (png_ptr, 0xFF,
+#ifdef WORDS_BIGENDIAN
+ PNG_FILLER_BEFORE
+#else
+ PNG_FILLER_AFTER
+#endif
+ );
+ break;
+ case DSPF_ARGB:
+ case DSPF_A8:
+ if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
+ png_set_tRNS_to_alpha (png_ptr);
+ break;
+ default:
+ break;
+ }
+
+ pitch = width * DFB_BYTES_PER_PIXEL (src_format);
+ if (pitch & 3)
+ pitch += 4 - (pitch & 3);
+
+ data = malloc (height * pitch);
+ if (!data) {
+ fprintf (stderr, "Failed to allocate %ld bytes.\n", height * pitch);
+ goto cleanup;
+ }
+
+ {
+ unsigned int i;
+ png_bytep bptrs[height];
+
+ for (i = 0; i < height; i++)
+ bptrs[i] = data + i * pitch;
+
+ png_read_image (png_ptr, bptrs);
+ }
+
+ if (!dest_format)
+ dest_format = src_format;
+
+ if (DFB_BYTES_PER_PIXEL(src_format) != DFB_BYTES_PER_PIXEL(dest_format)) {
+ unsigned char *s, *d, *dest;
+ int d_pitch, h;
+
+ assert (DFB_BYTES_PER_PIXEL (src_format) == 4);
+
+ d_pitch = width * DFB_BYTES_PER_PIXEL (dest_format);
+ if (d_pitch & 3)
+ d_pitch += 4 - (d_pitch & 3);
+
+ dest = malloc (height * d_pitch);
+ if (!dest) {
+ fprintf (stderr, "Failed to allocate %ld bytes.\n",
+ height * d_pitch);
+ goto cleanup;
+ }
+
+ h = height;
+ switch (dest_format) {
+ case DSPF_RGB16:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ if (dither565)
+ dither_rgb16 ((u32 *) s, (u16 *) d, height - h, width);
+ else
+ dfb_argb_to_rgb16 ((u32 *) s, (u16 *) d, width);
+ break;
+ case DSPF_ARGB1555:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_argb1555 ((u32 *) s, (u16 *) d, width);
+ break;
+ case DSPF_ARGB2554:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_argb2554 ((u32 *) s, (u16 *) d, width);
+ break;
+ case DSPF_ARGB4444:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_argb4444 ((u32 *) s, (u16 *) d, width);
+ break;
+ case DSPF_RGB332:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_rgb332 ((u32 *) s, (u8 *) d, width);
+ break;
+ case DSPF_A8:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_a8 ((u32 *) s, (u8 *) d, width);
+ break;
+ default:
+ fprintf (stderr,
+ "Sorry, unsupported format conversion.\n");
+ goto cleanup;
+ }
+
+ free (data);
+ data = dest;
+ pitch = d_pitch;
+ }
+
+ desc->flags = (DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT |
+ DSDESC_PREALLOCATED);
+ desc->width = width;
+ desc->height = height;
+ desc->pixelformat = dest_format;
+ desc->preallocated[0].pitch = pitch;
+ desc->preallocated[0].data = data;
+
+ data = NULL;
+
+ cleanup:
+ if (fp)
+ fclose (fp);
+
+ if (png_ptr)
+ png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
+
+ if (data)
+ free (data);
+
+ return ((desc->flags) ? DFB_OK : DFB_FAILURE);
+}
+
+static DFBResult merge_images (DFBSurfaceDescription *images,
+ int num_images,
+ DFBSurfaceDescription *dest,
+ DFBRectangle *rectangles)
+{
+ DFBSurfaceDescription *image = images;
+ DFBRectangle *rect = rectangles;
+ unsigned char *data;
+ int bpp;
+ int pitch, i;
+
+ rect->x = 0;
+ rect->y = 0;
+ rect->w = image->width;
+ rect->h = image->height;
+
+ dest->flags = (DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT |
+ DSDESC_PREALLOCATED);
+ dest->pixelformat = image->pixelformat;
+
+ bpp = DFB_BYTES_PER_PIXEL (dest->pixelformat);
+
+ if (bpp == 1)
+ dest->width = (rect->w + 3) & ~3;
+ else
+ dest->width = rect->w;
+
+ dest->height = rect->h;
+
+ for (i = 1; i < num_images; i++) {
+ image++;
+ rect++;
+
+ if (image->pixelformat != dest->pixelformat)
+ return DFB_INVARG;
+
+ rect->x = dest->width;
+ rect->y = 0;
+ rect->w = image->width;
+ rect->h = image->height;
+
+ if (bpp == 1)
+ dest->width += (rect->w + 3) & ~3;
+ else
+ dest->width += rect->w;
+
+ if (dest->height < rect->h)
+ dest->height = rect->h;
+ }
+
+ pitch = (dest->width * bpp + 3) &~ 3;
+ data = malloc (dest->height * pitch);
+ if (!data) {
+ fprintf (stderr, "Failed to allocate %ld bytes.\n",
+ (long) dest->height * pitch);
+ return DFB_FAILURE;
+ }
+
+
+ for (i = 0, image = images, rect = rectangles;
+ i < num_images;
+ i++, image++, rect++) {
+
+ unsigned char *dest = data + rect->x * bpp;
+ unsigned char *src = image->preallocated[0].data;
+ int height = rect->h;
+
+ do {
+ memcpy (dest, src, rect->w * bpp);
+ src += image->preallocated[0].pitch;
+ dest += pitch;
+ }
+ while (--height);
+ }
+
+ dest->preallocated[0].pitch = pitch;
+ dest->preallocated[0].data = data;
+
+ return DFB_OK;
+}
+
+static void
+dither_rgb16 (const u32 *src, u16 *dest, int y, int width)
+{
+ const u32 *dm = DM_565 + ((y & (DM_HEIGHT - 1)) << DM_WIDTH_SHIFT);
+ int x;
+
+ for (x = 0; x < width; x++) {
+ u32 rgb = ((src[x] & 0xFF) |
+ (src[x] & 0xFF00) << 2 |
+ (src[x] & 0xFF0000) << 4);
+
+ rgb += dm[x & (DM_WIDTH - 1)];
+ rgb += (0x10040100
+ - ((rgb & 0x1e0001e0) >> 5)
+ - ((rgb & 0x00070000) >> 6));
+
+ dest[x] = (((rgb & 0x0f800000) >> 12) |
+ ((rgb & 0x0003f000) >> 7) |
+ ((rgb & 0x000000f8) >> 3));
+ }
+}
+
+
+typedef struct {
+ FILE *fp;
+ int pos;
+ bool pad;
+} CSourceData;
+
+static inline void save_uchar (CSourceData *csource,
+ unsigned char d)
+{
+ if (csource->pos > 70) {
+ fprintf (csource->fp, "\"\n \"");
+
+ csource->pos = 3;
+ csource->pad = false;
+ }
+ if (d < 33 || d > 126) {
+ fprintf (csource->fp, "\\%o", d);
+ csource->pos += 1 + 1 + (d > 7) + (d > 63);
+ csource->pad = d < 64;
+ return;
+ }
+ if (d == '\\') {
+ fprintf (csource->fp, "\\\\");
+ csource->pos += 2;
+ }
+ else if (d == '"') {
+ fprintf (csource->fp, "\\\"");
+ csource->pos += 2;
+ }
+ else if (csource->pad && d >= '0' && d <= '9') {
+ fprintf (csource->fp, "\"\"%c", d);
+ csource->pos += 3;
+ }
+ else {
+ fputc (d, csource->fp);
+ csource->pos += 1;
+ }
+ csource->pad = false;
+
+ return;
+}
+
+static void dump_data(CSourceData *csource,
+ const char *name,
+ const unsigned char *data,
+ unsigned int len)
+{
+ fprintf (csource->fp,
+ "static const unsigned char %s_data[] =\n", name);
+ fprintf (csource->fp, " \"");
+
+ csource->pos = 3;
+ do
+ save_uchar (csource, *data++);
+ while (--len);
+
+ fprintf (csource->fp, "\";\n\n");
+}
+
+static DFBResult dump_raw_data(const char *name,
+ const unsigned char *data,
+ unsigned int len)
+{
+ CSourceData csource = { stdout, 0, 0 };
+ char *vname = variable_name (name);
+
+ if (!data || !len)
+ return DFB_INVARG;
+
+ fprintf (csource.fp,
+ "/* DirectFB raw data dump created by directfb-csource %s */\n\n",
+ DIRECTFB_VERSION);
+
+ dump_data(&csource, vname, data, len);
+
+ free (vname);
+
+ return DFB_OK;
+}
+
+
+static DFBResult dump_image (const char *name,
+ DFBSurfaceDescription *desc,
+ DFBColor *palette,
+ int palette_size)
+{
+ CSourceData csource = { stdout, 0, 0 };
+ const char *format = NULL;
+ char *vname = variable_name (name);
+ unsigned char *data;
+ unsigned long len;
+ int i;
+
+ if (desc &&
+ desc->flags != (DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT |
+ DSDESC_PREALLOCATED))
+ return DFB_INVARG;
+
+ for (i = 0; i < n_pixelformats && !format; i++)
+ if (pixelformats[i].format == desc->pixelformat)
+ format = pixelformats[i].name;
+
+ if (!format)
+ return DFB_INVARG;
+
+ data = (unsigned char *) desc->preallocated[0].data;
+ len = desc->height * desc->preallocated[0].pitch;
+
+ if (!len)
+ return DFB_INVARG;
+
+ /* dump comment */
+ fprintf (csource.fp,
+ "/* DirectFB surface dump created by directfb-csource %s */\n\n",
+ DIRECTFB_VERSION);
+
+ /* dump data */
+ dump_data(&csource, vname, data, len);
+
+ /* dump palette */
+ if (palette_size > 0) {
+ fprintf (csource.fp,
+ "static const DFBColor %s_palette[%d] = {\n", vname, palette_size);
+ for (i = 0; i < palette_size; i++)
+ fprintf (csource.fp,
+ " { 0x%02x, 0x%02x, 0x%02x, 0x%02x }%c\n",
+ palette[i].a, palette[i].r, palette[i].g, palette[i].b,
+ i+1 < palette_size ? ',' : ' ');
+ fprintf (csource.fp, "};\n\n");
+ }
+
+ /* dump description */
+ fprintf (csource.fp,
+ "static const DFBSurfaceDescription %s_desc = {\n", vname);
+ fprintf (csource.fp,
+ " flags : DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT |\n"
+ " DSDESC_PREALLOCATED");
+ if (palette_size > 0)
+ fprintf (csource.fp, " | DSDESC_PALETTE");
+ fprintf (csource.fp, ",\n");
+ fprintf (csource.fp,
+ " width : %d,\n", desc->width);
+ fprintf (csource.fp,
+ " height : %d,\n", desc->height);
+ fprintf (csource.fp,
+ " pixelformat : DSPF_%s,\n", format);
+ fprintf (csource.fp,
+ " preallocated : {{ data : (void *) %s_data,\n", vname);
+ fprintf (csource.fp,
+ " pitch : %d }}", desc->preallocated[0].pitch);
+ if (palette_size > 0) {
+ fprintf (csource.fp, ",\n");
+ fprintf (csource.fp,
+ " palette : { entries : %s_palette,\n", vname);
+ fprintf (csource.fp,
+ " size : %d }", palette_size);
+ }
+ fprintf (csource.fp, "\n};\n\n");
+
+ free (vname);
+
+ return DFB_OK;
+}
+
+static DFBResult dump_rectangles (const char *name,
+ DFBRectangle *rectangles,
+ const char **names,
+ int num_rects)
+{
+ DFBRectangle *rect;
+ const char *blanks = " ";
+ char *vname = variable_name (name);
+ FILE *fp = stdout;
+ int len, i;
+
+ if (num_rects < 1)
+ return DFB_INVARG;
+
+ fprintf (fp,
+ "/* DirectFB multi-surface dump created by directfb-csource %s */\n\n",
+ DIRECTFB_VERSION);
+
+ fprintf (fp,
+ "static const struct {\n"
+ " const char *name;\n"
+ " DFBRectangle rect;\n"
+ "} %s[] = {\n", vname);
+
+ for (i = 0, len = 0; i < num_rects; i++)
+ len = MAX (len, strlen (names[i]));
+
+ len = len + 4 - strlen (blanks);
+
+ for (i = 0, rect = rectangles; i < num_rects; i++, rect++) {
+
+ char *v = base_name (names[i]);
+
+ if (i)
+ fprintf (fp, ",\n");
+
+ if (len < 0) {
+ int l = fprintf (fp, " { \"%s\", ", v);
+
+ fprintf (fp, blanks - len + l);
+ fprintf (fp, "{ x : %4d, y : %4d, w : %4d, h : %4d } }",
+ rect->x, rect->y, rect->w, rect->h);
+ }
+ else {
+ fprintf (fp,
+ " { \"%s\",\n"
+ " { x : %4d, y : %4d, w : %4d, h : %4d } }",
+ v, rect->x, rect->y, rect->w, rect->h);
+ }
+
+ free (v);
+ }
+ fprintf (fp, "\n};\n\n");
+
+ free (vname);
+
+ return DFB_OK;
+}
+
+static char *
+variable_name (const char *name)
+{
+ char *vname = strdup (name);
+ char *v = vname;
+
+ while (DFB_TRUE) {
+ switch (*v) {
+ case 0:
+ return vname;
+ case 'a'...'z':
+ case 'A'...'Z':
+ case '0'...'9':
+ case '_':
+ break;
+ default:
+ *v = '_';
+ }
+ v++;
+ }
+}
+
+static char *
+base_name (const char *name)
+{
+ char *vname = strdup (name);
+ char *v = vname;
+
+ while (DFB_TRUE) {
+ switch (*v) {
+ case '.':
+ *v = 0;
+ case 0:
+ return vname;
+ default:
+ break;
+ }
+ v++;
+ }
+}
diff --git a/Source/DirectFB/tools/fusion_bench.c b/Source/DirectFB/tools/fusion_bench.c
new file mode 100755
index 0000000..8ea04df
--- /dev/null
+++ b/Source/DirectFB/tools/fusion_bench.c
@@ -0,0 +1,537 @@
+/*
+ (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 <stdio.h>
+#include <unistd.h>
+
+#include <sys/file.h>
+
+#include <pthread.h>
+
+#include <direct/clock.h>
+
+#include <fusion/build.h>
+#include <fusion/fusion.h>
+#include <fusion/lock.h>
+#include <fusion/property.h>
+#include <fusion/reactor.h>
+#include <fusion/ref.h>
+#include <fusion/shmalloc.h>
+
+#include <directfb.h>
+
+#include <core/system.h>
+
+
+static long long t1, t2;
+static unsigned int loops;
+static FusionWorld *world;
+
+#define BENCH_START() do { sync(); usleep(100000); sync(); t1 = direct_clock_get_millis(); loops = 0; } while (0)
+#define BENCH_STOP() do { t2 = direct_clock_get_millis(); } while (0)
+
+#define BENCH_LOOP() while ((++loops & 0xfff) || (direct_clock_get_millis() - t1 < 1000))
+
+#define BENCH_RESULT() (loops / (float)(t2 - t1))
+#define BENCH_RESULT_BY(x) ((loops * x) / (float)(t2 - t1))
+
+
+static ReactionResult
+reaction_callback (const void *msg_data,
+ void *ctx)
+{
+ return RS_OK;
+}
+
+static void
+bench_reactor( void )
+{
+ FusionReactor *reactor;
+ Reaction reaction;
+ Reaction reaction2;
+ GlobalReaction global_reaction;
+
+ reactor = fusion_reactor_new( 16, "Benchmark", world );
+ if (!reactor) {
+ fprintf( stderr, "Fusion Error\n" );
+ return;
+ }
+
+
+ /* reactor attach/detach */
+ BENCH_START();
+
+ BENCH_LOOP() {
+ fusion_reactor_attach( reactor, reaction_callback, NULL, &reaction );
+ fusion_reactor_detach( reactor, &reaction );
+ }
+
+ BENCH_STOP();
+
+ printf( "reactor attach/detach -> %8.2f k/sec\n", BENCH_RESULT() );
+
+
+ /* reactor attach/detach (2nd) */
+ fusion_reactor_attach( reactor, reaction_callback, NULL, &reaction );
+
+ BENCH_START();
+
+ BENCH_LOOP() {
+ fusion_reactor_attach( reactor, reaction_callback, NULL, &reaction2 );
+ fusion_reactor_detach( reactor, &reaction2 );
+ }
+
+ BENCH_STOP();
+
+ fusion_reactor_detach( reactor, &reaction );
+
+ printf( "reactor attach/detach (2nd) -> %8.2f k/sec\n", BENCH_RESULT() );
+
+
+ /* reactor attach/detach (global) */
+ fusion_reactor_attach( reactor, reaction_callback, NULL, &reaction );
+
+ BENCH_START();
+
+ BENCH_LOOP() {
+ fusion_reactor_attach_global( reactor, 0, NULL, &global_reaction );
+ fusion_reactor_detach_global( reactor, &global_reaction );
+ }
+
+ BENCH_STOP();
+
+ fusion_reactor_detach( reactor, &reaction );
+
+ printf( "reactor attach/detach (global) -> %8.2f k/sec\n", BENCH_RESULT() );
+
+
+ /* reactor dispatch */
+ fusion_reactor_attach( reactor, reaction_callback, NULL, &reaction );
+
+ BENCH_START();
+
+ BENCH_LOOP() {
+ char msg[16];
+
+ fusion_reactor_dispatch( reactor, msg, true, NULL );
+ }
+
+ BENCH_STOP();
+
+ printf( "reactor dispatch -> %8.2f k/sec\n", BENCH_RESULT() );
+
+
+ fusion_reactor_detach( reactor, &reaction );
+
+
+ fusion_reactor_free( reactor );
+
+ printf( "\n" );
+}
+
+static void
+bench_ref( void )
+{
+ DirectResult ret;
+ FusionRef ref;
+
+ ret = fusion_ref_init( &ref, "Benchmark", world );
+ if (ret) {
+ fprintf( stderr, "Fusion Error %d\n", ret );
+ return;
+ }
+
+
+ /* ref up/down (local) */
+ BENCH_START();
+
+ BENCH_LOOP() {
+ fusion_ref_up( &ref, false );
+ fusion_ref_down( &ref, false );
+ }
+
+ BENCH_STOP();
+
+ printf( "ref up/down (local) -> %8.2f k/sec\n", BENCH_RESULT() );
+
+
+ /* ref up/down (global) */
+ BENCH_START();
+
+ BENCH_LOOP() {
+ fusion_ref_up( &ref, true );
+ fusion_ref_down( &ref, true );
+ }
+
+ BENCH_STOP();
+
+ printf( "ref up/down (global) -> %8.2f k/sec\n", BENCH_RESULT() );
+
+
+ fusion_ref_destroy( &ref );
+
+ printf( "\n" );
+}
+
+static void
+bench_property( void )
+{
+ DirectResult ret;
+ FusionProperty property;
+
+ ret = fusion_property_init( &property, world );
+ if (ret) {
+ fprintf( stderr, "Fusion Error %d\n", ret );
+ return;
+ }
+
+
+ /* property lease/cede */
+ BENCH_START();
+
+ BENCH_LOOP() {
+ fusion_property_lease( &property );
+ fusion_property_cede( &property );
+ }
+
+ BENCH_STOP();
+
+ printf( "property lease/cede -> %8.2f k/sec\n", BENCH_RESULT() );
+
+
+ fusion_property_destroy( &property );
+
+ printf( "\n" );
+}
+
+static void
+bench_skirmish( void )
+{
+ DirectResult ret;
+ FusionSkirmish skirmish;
+
+ ret = fusion_skirmish_init( &skirmish, "Benchmark", world );
+ if (ret) {
+ fprintf( stderr, "Fusion Error %d\n", ret );
+ return;
+ }
+
+
+ /* skirmish prevail/dismiss */
+ BENCH_START();
+
+ BENCH_LOOP() {
+ fusion_skirmish_prevail( &skirmish );
+ fusion_skirmish_dismiss( &skirmish );
+ }
+
+ BENCH_STOP();
+
+ printf( "skirmish prevail/dismiss -> %8.2f k/sec\n", BENCH_RESULT() );
+
+
+ fusion_skirmish_destroy( &skirmish );
+
+ printf( "\n" );
+}
+
+static void *
+prevail_dismiss_loop( void *arg )
+{
+ FusionSkirmish *skirmish = (FusionSkirmish *) arg;
+
+ BENCH_LOOP() {
+ fusion_skirmish_prevail( skirmish );
+ fusion_skirmish_dismiss( skirmish );
+ }
+
+ return NULL;
+}
+
+static void
+bench_skirmish_threaded( void )
+{
+ int i;
+ DirectResult ret;
+ FusionSkirmish skirmish;
+
+ ret = fusion_skirmish_init( &skirmish, "Threaded Benchmark", world );
+ if (ret) {
+ fprintf( stderr, "Fusion Error %d\n", ret );
+ return;
+ }
+
+
+ /* skirmish prevail/dismiss (2-5 threads) */
+ for (i=2; i<=5; i++) {
+ int t;
+ pthread_t threads[i];
+
+ BENCH_START();
+
+ for (t=0; t<i; t++)
+ pthread_create( &threads[t], NULL, prevail_dismiss_loop, &skirmish );
+
+ for (t=0; t<i; t++)
+ pthread_join( threads[t], NULL );
+
+ BENCH_STOP();
+
+ printf( "skirmish prevail/dismiss (%d threads) -> %8.2f k/sec\n", i, BENCH_RESULT() );
+ }
+
+
+ fusion_skirmish_destroy( &skirmish );
+
+ printf( "\n" );
+}
+
+static void *
+mutex_lock_unlock_loop( void *arg )
+{
+ pthread_mutex_t *lock = (pthread_mutex_t *) arg;
+
+ BENCH_LOOP() {
+ pthread_mutex_lock( lock );
+ pthread_mutex_unlock( lock );
+ }
+
+ return NULL;
+}
+
+static void
+bench_mutex_threaded( void )
+{
+ int i;
+ pthread_mutex_t lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+
+
+ /* mutex lock/unlock (2-5 threads) */
+ for (i=2; i<=5; i++) {
+ int t;
+ pthread_t threads[i];
+
+ BENCH_START();
+
+ for (t=0; t<i; t++)
+ pthread_create( &threads[t], NULL, mutex_lock_unlock_loop, &lock );
+
+ for (t=0; t<i; t++)
+ pthread_join( threads[t], NULL );
+
+ BENCH_STOP();
+
+ printf( "mutex lock/unlock (rec., %d threads) -> %8.2f k/sec\n", i, BENCH_RESULT() );
+ }
+
+
+ pthread_mutex_destroy( &lock );
+
+ printf( "\n" );
+}
+
+static void
+bench_mutex( void )
+{
+ pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+ pthread_mutex_t rmutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+
+
+ /* pthread_mutex lock/unlock */
+ BENCH_START();
+
+ BENCH_LOOP() {
+ pthread_mutex_lock( &mutex );
+ pthread_mutex_unlock( &mutex );
+ }
+
+ BENCH_STOP();
+
+ printf( "mutex lock/unlock -> %8.2f k/sec\n", BENCH_RESULT() );
+
+
+ /* pthread_mutex lock/unlock */
+ BENCH_START();
+
+ BENCH_LOOP() {
+ pthread_mutex_lock( &rmutex );
+ pthread_mutex_unlock( &rmutex );
+ }
+
+ BENCH_STOP();
+
+ printf( "mutex lock/unlock (recursive) -> %8.2f k/sec\n", BENCH_RESULT() );
+
+
+ pthread_mutex_destroy( &mutex );
+ pthread_mutex_destroy( &rmutex );
+
+ printf( "\n" );
+}
+
+static void
+bench_flock( void )
+{
+ int fd;
+ FILE *tmp;
+
+ tmp = tmpfile();
+ if (!tmp) {
+ perror( "tmpfile()" );
+ return;
+ }
+
+ fd = fileno( tmp );
+ if (fd < 0) {
+ perror( "fileno()" );
+ fclose( tmp );
+ return;
+ }
+
+ BENCH_START();
+
+ BENCH_LOOP() {
+ flock( fd, LOCK_EX );
+ flock( fd, LOCK_UN );
+ }
+
+ BENCH_STOP();
+
+ printf( "flock lock/unlock -> %8.2f k/sec\n", BENCH_RESULT() );
+ printf( "\n" );
+
+ fclose( tmp );
+}
+
+static void
+bench_shmpool( bool debug )
+{
+ DirectResult ret;
+ void *mem[256];
+ const int sizes[8] = { 12, 36, 200, 120, 39, 3082, 8, 1040 };
+
+ FusionSHMPoolShared *pool;
+
+ ret = fusion_shm_pool_create( world, "Benchmark Pool", 524288, debug, &pool );
+ if (ret) {
+ DirectFBError( "fusion_shm_pool_create() failed", ret );
+ return;
+ }
+
+ BENCH_START();
+
+ BENCH_LOOP() {
+ int i;
+
+ for (i=0; i<128; i++)
+ mem[i] = SHMALLOC( pool, sizes[i&7] );
+
+ for (i=0; i<64; i++)
+ SHFREE( pool, mem[i] );
+
+ for (i=128; i<192; i++)
+ mem[i] = SHMALLOC( pool, sizes[i&7] );
+
+ for (i=64; i<128; i++)
+ SHFREE( pool, mem[i] );
+
+ for (i=192; i<256; i++)
+ mem[i] = SHMALLOC( pool, sizes[i&7] );
+
+ for (i=128; i<256; i++)
+ SHFREE( pool, mem[i] );
+ }
+
+ BENCH_STOP();
+
+ printf( "shm pool alloc/free %s -> %8.2f k/sec\n",
+ debug ? "(debug)" : " ", BENCH_RESULT_BY(256) );
+
+ fusion_shm_pool_destroy( world, pool );
+}
+
+int
+main( int argc, char *argv[] )
+{
+ DirectResult ret;
+
+ /* Initialize DirectFB. */
+ ret = DirectFBInit( &argc, &argv );
+ if (ret)
+ return DirectFBError( "DirectFBInit()", ret );
+
+ dfb_system_lookup();
+
+ ret = fusion_enter( -1, 0, FER_MASTER, &world );
+ if (ret)
+ return DirectFBError( "fusion_enter()", ret );
+
+ printf( "\n" );
+
+#if FUSION_BUILD_MULTI
+ printf( "Fusion Benchmark (Multi Application Core)\n" );
+#else
+ printf( "Fusion Benchmark (Single Application Core)\n" );
+#endif
+
+ printf( "\n" );
+
+ bench_flock();
+
+ bench_mutex();
+ bench_mutex_threaded();
+
+ bench_skirmish();
+ bench_skirmish_threaded();
+
+ //bench_spinlock_threaded();
+
+ bench_property();
+
+ bench_ref();
+
+ bench_reactor();
+
+ bench_shmpool( false );
+ bench_shmpool( true );
+
+ printf( "\n" );
+
+ fusion_exit( world, false );
+
+ return 0;
+}
+
diff --git a/Source/DirectFB/tools/gendoc.pl b/Source/DirectFB/tools/gendoc.pl
new file mode 100755
index 0000000..a86035a
--- /dev/null
+++ b/Source/DirectFB/tools/gendoc.pl
@@ -0,0 +1,936 @@
+#!/usr/bin/perl
+#
+# (c) Copyright 2001-2007 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 library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+
+##################################
+# TODO: CLEANUP CODE FURTHER !!!
+##################################
+
+#####################################################################################
+# #
+# Documentation generator written by Denis Oliver Kropp <dok@directfb.org> #
+# #
+# - Uses first argument as project name and second as version #
+# - Reads header files from stdin, parsing is tied to the coding style #
+# - Writes HTML 3.x to different files: 'index', 'types', <interfaces>, <methods> #
+# #
+# FIXME: remove all copy'n'waste code, cleanup more, simplify more, ... #
+# #
+#####################################################################################
+
+$COLOR_BG = "#F8F4D8";
+$COLOR_LINK = "#2369E0";
+$COLOR_TEXT = "#232323";
+
+$COLOR_TOP_BG = "#C0B090";
+$COLOR_TOP_LINK = "#203040";
+
+$COLOR_TITLE = "#E09040";
+$COLOR_TITLE_BG = "#284460";
+$COLOR_TITLE_MAIN = "#D0D0D0";
+
+$COLOR_ENTRIES_BG = "#F8F8F0";
+$COLOR_ENTRIES_PTR = "#424242";
+$COLOR_ENTRIES_ID = "#234269";
+$COLOR_ENTRIES_DESC = "#303030";
+
+$COLOR_ENUM_NAME = "#B04223";
+$COLOR_ENUM_ENTRY_ID = "#429023";
+$COLOR_ENUM_ENTRY_VAL = "#234269";
+
+$COLOR_STRUCT_NAME = "#238423";
+
+$COLOR_FUNCTYPE_NAME = "#D06923";
+$COLOR_FUNCTYPE_HEAD = "#232342";
+
+$COLOR_MACRO_NAME = "#2342A0";
+$COLOR_MACRO_PARAMS = "#606080";
+$COLOR_MACRO_VALUE = "#232342";
+
+$COLOR_METHOD_HEAD = "#425469";
+
+$COLOR_COPYRIGHT_BG = "#E0E8F0";
+
+########################################################################################################################
+## Top level just calls main function with args
+#
+
+$PROJECT = shift @ARGV;
+$VERSION = shift @ARGV;
+
+gen_doc( $PROJECT, $VERSION );
+
+########################################################################################################################
+
+########################################################################################################################
+## Utilities
+#
+
+sub trim ($) {
+ local (*str) = @_;
+
+ # remove leading white space
+ $str =~ s/^\s*//g;
+
+ # remove trailing white space and new line
+ $str =~ s/\s*$//g;
+}
+
+sub print_list ($$) {
+ local (*list, $title) = @_;
+
+ print INDEX "<P>\n",
+ " <CENTER>\n",
+ " <H3>$title</H3>\n",
+ " <TABLE width=90% border=0 cellpadding=2>\n";
+
+ foreach $key (sort keys %list)
+ {
+ print INDEX " <TR><TD valign=top>\n",
+ " <A href=\"types.html#$key\">$key</A>\n",
+ " </TD><TD valign=top>\n",
+ " $list{$key}\n",
+ " </TD></TR>\n";
+ }
+
+ print INDEX " </TABLE></CENTER>\n",
+ "</P>\n";
+}
+
+sub substitute_links ($) {
+ local (*str) = @_;
+
+ # Interface Methods
+ $str =~ s/(I\w+)\:\:(\w+)\(\)/\<a\ href=\"\1\_\2\.html\"\>\1\:\:\2\(\)\<\/a\>/g;
+
+ # Automatic type links
+ $str =~ s/(\s)([A-Z][A-Z][A-Z][A-Z]?[a-z][a-z][a-z]?[\w0-9]+)/\1\<a\ href=\"types\.html#\2\"\>\2\<\/a\>/g;
+
+ # Automatic type links
+ $str =~ s/(\s)($PROJECT[\w0-9]+)/\1\<a\ href=\"types\.html#\2\"\>\2\<\/a\>/g;
+
+ # Explicit type links
+ $str =~ s/(\s)\@\_(\w[\w0-9]+)/\1\<a\ href=\"types\.html#\2\"\>\2\<\/a\>/g;
+}
+
+sub type_link ($) {
+ my ($type) = @_;
+
+ trim( \$type );
+
+ if (defined($type_list{$type}))
+ {
+ return "<A href=\"types.html#$type\">$type</A>";
+ }
+ elsif (defined($interfaces{$type}))
+ {
+ return "<A href=\"$type.html\">$type</A>";
+ }
+
+ return "$type";
+}
+
+########################################################################################################################
+## Generic parsers
+#
+
+sub parse_comment ($$$$) {
+ local (*head, *body, *options, $inithead) = @_;
+
+ local $headline_mode = 1;
+ local $list_open = 0;
+
+ $head = "\n";
+ $body = "\n";
+
+ if ($inithead ne "") {
+ $headline_mode = 0;
+
+ $head .= " $inithead\n";
+ }
+
+ %options = ();
+
+ while (<>)
+ {
+ chomp;
+ last if /^\s*\*+\/\s*$/;
+
+ # Prepend asterisk if first non-whitespace isn't an asterisk
+ s/^\s*([^\*\s])/\* $1/;
+
+ # In head line mode append to $head
+ if ($headline_mode == 1)
+ {
+ if (/^\s*\*+\s*$/)
+ {
+ $headline_mode = 0;
+ }
+ elsif (/^\s*\*+\s*@(\w+)\s*=?\s*(.*)$/)
+ {
+ $options{$1} = $2;
+ }
+ elsif (/^\s*\*+\s*(.+)\*\/\s*$/)
+ {
+ $head .= " $1\n";
+ last;
+ }
+ elsif (/^\s*\*+\s*(.+)$/)
+ {
+ $head .= " $1\n";
+ }
+ }
+ else
+ # Otherwise append to $body
+ {
+ if (/^\s*\*+\s*(.+)\*\/\s*$/)
+ {
+ $body .= " $1\n";
+ last;
+ }
+ elsif (/^\s*\*+\s*$/)
+ {
+ $body .= " </P><P>\n";
+ }
+ elsif (/^\s*\*+\s\-\s(.+)$/)
+ {
+ if ($list_open == 0)
+ {
+ $list_open = 1;
+
+ $body .= " <UL><LI>\n";
+ }
+ else
+ {
+ $body .= " </LI><LI>\n";
+ }
+
+ $body .= " $1\n";
+ }
+ elsif (/^\s*\*+\s\s(.+)$/)
+ {
+ $body .= " $1\n";
+ }
+ elsif (/^\s*\*+\s(.+)$/)
+ {
+ if ($list_open == 1)
+ {
+ $list_open = 0;
+
+ $body .= " </LI></UL>\n";
+ }
+
+ $body .= " $1\n";
+ }
+ }
+ }
+
+ if ($list_open == 1)
+ {
+ $body .= " </LI></UL>\n";
+ }
+
+ substitute_links (\$head);
+ substitute_links (\$body);
+}
+
+#
+# Reads stdin until the end of the parameter list is reached.
+# Returns list of parameter records.
+#
+# TODO: Add full comment support and use it for function types as well.
+#
+sub parse_params () {
+ local @entries;
+
+ while (<>)
+ {
+ chomp;
+ last if /^\s*\)\;\s*$/;
+
+ if ( /^\s*(const )?\s*([\w\ ]+)\s+(\**)(\w+,?)\s*$/ )
+ {
+ local $const = $1;
+ local $type = $2;
+ local $ptr = $3;
+ local $name = $4;
+
+ local $rec = {
+ TYPE => $const . type_link( $type ),
+ PTR => $ptr,
+ NAME => $name
+ };
+
+ push (@entries, $rec);
+ }
+ }
+
+ return @entries;
+}
+
+########################################################################################################################
+## Type parsers
+#
+
+#
+# Reads stdin until the end of the interface is reached.
+# Writes formatted HTML to one file for the interface and one file per method.
+# Parameter is the interface name.
+#
+sub parse_interface ($)
+ {
+ local ($interface) = @_;
+
+ local $section;
+
+ trim( \$interface );
+
+ if (!defined ($interfaces{$interface})) {
+ print "WARNING: Interface definition '$interface' has no declaration!\n"
+ }
+
+ html_create( INTERFACE, "$interface.html",
+ "<A href=\"index.html\">" .
+ " <FONT color=$COLOR_TITLE_MAIN>$PROJECT Interfaces</FONT>" .
+ "</A>", $interface, $interface );
+
+ print INTERFACE "<P>\n",
+ " $headline\n",
+ " $detailed\n",
+ "</P>";
+
+ print INTERFACE "<P>\n",
+ " <CENTER><TABLE width=93% border=1 rules=groups cellpadding=4 cellspacing=2>\n";
+
+ print INTERFACE " <THEAD>\n";
+ print INTERFACE " <TR><TH colspan=3>Methods of $interface</TH></TR>\n";
+ print INTERFACE " </THEAD>\n";
+
+ print INTERFACE " <TBODY>\n";
+
+ while (<>)
+ {
+ chomp;
+ last if /^\s*\)\s*$/;
+
+ if ( /^\s*\/\*\*\s*(.+)\s*\*\*\/\s*$/ )
+ {
+ $section = $1;
+ }
+ elsif ( /^\s*(\w+)\s*\(\s*\*\s*(\w+)\s*\)\s*\(?\s*$/ )
+ {
+ print INTERFACE " <TR><TD valign=top>\n",
+ " <B><SMALL>$section</SMALL></B>\n",
+ " </TD><TD valign=top>\n",
+ " <A href=\"${interface}_$2.html\">",
+ " <B>$2</B></A>\n",
+ " </TD><TD valign=top>\n",
+ " $headline\n",
+ " </TD></TR>\n";
+
+ html_create( FUNCTION, "${interface}_$2.html",
+ "<A href=\"$interface.html\">" .
+ " <FONT color=$COLOR_TITLE_MAIN>$interface</FONT>" .
+ "</A>", $2, "$interface - $2" );
+
+ print FUNCTION "<H4>$headline</H4>\n",
+ " <TABLE border=0 cellspacing=4 cellpadding=2 bgcolor=$COLOR_ENTRIES_BG>\n",
+ " <TR><TD colspan=5><I><FONT color=$COLOR_METHOD_HEAD><A href=\"types.html#$1\">$1</A> <b>$2 (</b></FONT></I></TD></TR>\n";
+
+ local @params = parse_params();
+ local $param;
+
+ for $param (@params)
+ {
+ print FUNCTION " <TR><TD width=50>\n",
+ " &nbsp;\n",
+ " </TD><TD valign=top>\n",
+ " $param->{TYPE}\n",
+ " </TD><TD width=20>&nbsp;</TD><TD align=right>\n",
+ " <FONT color=$COLOR_ENTRIES_PTR><B>$param->{PTR}</B></FONT>\n",
+ " </TD><TD valign=top>\n",
+ " <FONT color=$COLOR_ENTRIES_ID><B>$param->{NAME}</B></FONT>\n",
+ " </TD></TR>\n";
+ }
+
+ print FUNCTION " <TR><TD colspan=5><I><FONT color=$COLOR_METHOD_HEAD><b>);</b></FONT></I></TD></TR>\n",
+ " </TABLE>\n",
+ "</P>\n";
+
+ print FUNCTION "<P>$detailed</P>\n";
+
+ $headline = "";
+ $detailed = "";
+ $section = "";
+
+ html_close( FUNCTION );
+ }
+ elsif ( /^\s*\/\*\s*$/ )
+ {
+ parse_comment( \$headline, \$detailed, \$options, "" );
+ }
+ }
+
+ print INTERFACE " </TBODY>\n";
+
+ print INTERFACE " </TABLE></CENTER>\n",
+ "</P>\n";
+
+ html_close( INTERFACE );
+ }
+
+#
+# Reads stdin until the end of the enum is reached.
+# Writes formatted HTML to "types.html".
+#
+sub parse_enum
+ {
+ local %entries;
+ local @list;
+
+ local $pre;
+
+ while (<>)
+ {
+ chomp;
+
+ local $entry;
+
+ # entry with assignment (complete comment)
+ if ( /^\s*(\w+)\s*=\s*([\w\d\(\)\,\|\!\s]+[^\,\s])\s*,?\s*\/\*\s*(.+)\s*\*\/\s*$/ )
+ {
+ $entry = $1;
+ $values{ $entry } = $2;
+ $entries{ $entry } = $3;
+ }
+ # entry with assignment (opening comment)
+ elsif ( /^\s*(\w+)\s*=\s*([\w\d\(\)\,\|\!\s]+[^\,\s])\s*,?\s*\/\*\s*(.+)\s*$/ )
+ {
+ $entry = $1;
+ $values{ $entry } = $2;
+
+ parse_comment( \$t1, \$t2, \$opt, $3 );
+
+ $entries{ $entry } = $t1.$t2;
+ }
+ # entry with assignment (none or preceding comment)
+ elsif ( /^\s*(\w+)\s*=\s*([\w\d\(\)\,\|\!\s]+[^\,\s])\s*,?\s*$/ )
+ {
+ $entry = $1;
+ $values{ $entry } = $2;
+ $entries{ $entry } = $pre;
+ }
+ # entry without assignment (complete comment)
+ elsif ( /^\s*(\w+)\s*,?\s*\/\*\s*(.+)\s*\*\/\s*$/ )
+ {
+ $entry = $1;
+ $entries{ $entry } = $2;
+ }
+ # entry without assignment (opening comment)
+ elsif ( /^\s*(\w+)\s*,?\s*\/\*\s*(.+)\s*$/ )
+ {
+ $entry = $1;
+
+ parse_comment( \$t1, \$t2, \$opt, $2 );
+
+ $entries{ $entry } = $t1.$t2;
+ }
+ # entry without assignment (none or preceding comment)
+ elsif ( /^\s*(\w+)\s*,?\s*$/ )
+ {
+ $entry = $1;
+ $entries{ $entry } = $pre;
+ }
+ # preceding comment (complete)
+ elsif ( /^\s*\/\*\s*(.+)\s*\*\/\s*$/ )
+ {
+ $pre = $1;
+ }
+ # preceding comment (opening)
+ elsif ( /^\s*\/\*\s*(.+)\s*$/ )
+ {
+ parse_comment( \$t1, \$t2, \$opt, $1 );
+
+ $pre = $t1.$t2;
+ }
+ # end of enum
+ elsif ( /^\s*\}\s*(\w+)\s*\;\s*$/ )
+ {
+ $enum = $1;
+
+ trim( \$enum );
+
+ $enum_list{$enum} = $headline;
+ $type_list{$enum} = $headline;
+
+ last;
+ }
+ # blank line?
+ else
+ {
+ $pre = "";
+ }
+
+ if ($entry ne "")
+ {
+ push (@list, $entry);
+ }
+ }
+
+ if (scalar @list > 0)
+ {
+ print TYPES "<p>\n",
+ " <a name=\"$enum\" href=\"#$enum\">\n",
+ " <h3><font color=$COLOR_ENUM_NAME>$enum</font></h3>\n",
+ " </a>\n",
+ " <h4>$headline</h4>\n",
+ " <TABLE border=0 cellspacing=4 cellpadding=2 bgcolor=$COLOR_ENTRIES_BG>\n";
+
+ foreach $key (@list)
+ {
+ substitute_links (\$entries{$key});
+
+ print TYPES " <TR><TD width=32>&nbsp;</TD><TD valign=top>\n",
+ " <font color=$COLOR_ENUM_ENTRY_ID><b>$key</b></font>\n",
+ " </TD><TD width=20>&nbsp;</TD><TD valign=top>\n",
+ " <font color=$COLOR_ENUM_ENTRY_VAL>$values{$key}</font>\n",
+ " </TD><TD width=20>&nbsp;</TD><TD valign=top>\n",
+ " <font color=$COLOR_ENTRIES_DESC>$entries{$key}</font>\n",
+ " </TD></TR>\n";
+ }
+
+ print TYPES " </TABLE>\n",
+ "</p><p>\n",
+ " $detailed\n",
+ "</p><hr>\n";
+ }
+ }
+
+#
+# Reads stdin until the end of the enum is reached.
+# Writes formatted HTML to "types.html".
+#
+sub parse_struct
+ {
+ local @entries;
+ local %entries_params;
+ local %entries_types;
+ local %entries_ptrs;
+
+ while (<>)
+ {
+ chomp;
+
+ local $entry;
+
+ # without comment
+ if ( /^\s*(const )?\s*([\w ]+)\s+(\**)([\w\d\+\[\]]+)(\s*:\s*\d+)?;\s*$/ )
+ {
+ $const = $1;
+ $type = $2;
+ $ptr = $3;
+ $entry = $4.$5;
+ $text = "";
+ }
+ # complete one line entry
+ elsif ( /^\s*(const )?\s*([\w ]+)\s+(\**)([\w\d\+\[\]]+)(\s*:\s*\d+)?;\s*\/\*\s*(.+)\*\/\s*$/ )
+ {
+ $const = $1;
+ $type = $2;
+ $ptr = $3;
+ $entry = $4.$5;
+ $text = $6;
+ }
+ # with comment opening
+ elsif ( /^\s*(const )?\s*([\w ]+)\s+(\**)([\w\d\+\[\]]+)(\s*:\s*\d+)?;\s*\/\*\s*(.+)\s*$/ )
+ {
+ $const = $1;
+ $type = $2;
+ $ptr = $3;
+ $entry = $4.$5;
+
+ parse_comment( \$t1, \$t2, \$opt, $6 );
+
+ $text = $t1.$t2;
+ }
+ elsif ( /^\s*\}\s*(\w+)\s*\;\s*$/ )
+ {
+ $struct = $1;
+
+ trim( \$struct );
+
+ $struct_list{$struct} = $headline;
+ $type_list{$struct} = $headline;
+
+ last;
+ }
+
+ if ($entry ne "")
+ {
+ # TODO: Use structure
+ $entries_types{$entry} = $const . type_link( $type );
+ $entries_ptrs{$entry} = $ptr;
+ $entries_params{$entry} = $text;
+
+ push (@entries, $entry);
+ }
+ }
+
+ if (scalar @entries > 0)
+ {
+ print TYPES "<p>",
+ " <a name=\"$struct\" href=\"#$struct\">\n",
+ " <h3><font color=$COLOR_STRUCT_NAME>$struct</font></h3>\n",
+ " </a>\n",
+ " <h4>$headline</h4>\n",
+ " <TABLE border=0 cellspacing=4 cellpadding=2 bgcolor=$COLOR_ENTRIES_BG>\n";
+
+ foreach $key (@entries)
+ {
+ substitute_links (\$entries_params{$key});
+
+ print TYPES " <TR><TD width=32>&nbsp;</TD><TD valign=top>\n",
+ " $entries_types{$key}\n",
+ " </TD><TD width=20>&nbsp;</TD><TD valign=top align=right>\n",
+ " <FONT color=$COLOR_ENTRIES_PTR>$entries_ptrs{$key}</FONT>\n",
+ " </TD><TD valign=top>\n",
+ " <FONT color=$COLOR_ENTRIES_ID><B>$key</B></FONT>\n",
+ " </TD><TD width=20>&nbsp;</TD><TD valign=top>\n",
+ " <font color=$COLOR_ENTRIES_DESC>$entries_params{$key}</font>\n",
+ " </TD></TR>\n";
+ }
+
+ print TYPES " </TABLE>\n",
+ "</p><p>\n",
+ " $detailed\n",
+ "</p><hr>\n";
+ }
+ }
+
+#
+# Reads stdin until the end of the function type is reached.
+# Writes formatted HTML to "types.html".
+# Parameters are the return type and function type name.
+#
+sub parse_func ($$)
+ {
+ local ($rtype, $name) = @_;
+
+ local @entries;
+ local %entries_params;
+ local %entries_types;
+ local %entries_ptrs;
+
+ trim( \$rtype );
+ trim( \$name );
+
+ while (<>)
+ {
+ chomp;
+
+ local $entry;
+
+ # without comment
+ if ( /^\s*(const )?\s*([\w ]+)\s+(\**)([\w\d\+\[\]]+)(\s*:\s*\d+)?,?\s*$/ )
+ {
+ $const = $1;
+ $type = $2;
+ $ptr = $3;
+ $entry = $4.$5;
+ $text = "";
+ }
+ # complete one line entry
+ elsif ( /^\s*(const )?\s*([\w ]+)\s+(\**)([\w\d\+\[\]]+)(\s*:\s*\d+)?,?\s*\/\*\s*(.+)\*\/\s*$/ )
+ {
+ $const = $1;
+ $type = $2;
+ $ptr = $3;
+ $entry = $4.$5;
+ $text = $6;
+ }
+ # with comment opening
+ elsif ( /^\s*(const )?\s*([\w ]+)\s+(\**)([\w\d\+\[\]]+)(\s*:\s*\d+)?,?\s*\/\*\s*(.+)\s*$/ )
+ {
+ $const = $1;
+ $type = $2;
+ $ptr = $3;
+ $entry = $4.$5;
+
+ parse_comment( \$t1, \$t2, \$opt, $6 );
+
+ $text = $t1.$t2;
+ }
+ elsif ( /^\s*\)\;\s*$/ )
+ {
+ $func_list{$name} = $headline;
+ $type_list{$name} = $headline;
+
+ last;
+ }
+
+ if ($entry ne "")
+ {
+ # TODO: Use structure
+ $entries_types{$entry} = $const . type_link( $type );
+ $entries_ptrs{$entry} = $ptr;
+ $entries_params{$entry} = $text;
+
+ push (@entries, $entry);
+ }
+ }
+
+ $rtype = type_link( $rtype );
+
+ if (scalar @entries > 0)
+ {
+ print TYPES "<p>",
+ " <a name=\"$name\" href=\"#$name\">\n",
+ " <h3><font color=$COLOR_FUNCTYPE_NAME>$name</font></h3>\n",
+ " </a>\n",
+ " <h4>$headline</h4>\n",
+ " <TABLE border=0 cellspacing=4 cellpadding=2 bgcolor=$COLOR_ENTRIES_BG>\n",
+ " <TR><TD colspan=4>\n",
+ " <I>$rtype (*<FONT color=$COLOR_FUNCTYPE_HEAD>$name</FONT>) (</I>\n",
+ " </TD></TR>\n";
+
+ foreach $key (@entries)
+ {
+ print TYPES " <TR><TD width=32>\n",
+ " &nbsp;\n",
+ " </TD><TD valign=top>\n",
+ " $entries_types{$key}\n",
+ " </TD><TD width=20>&nbsp;</TD><TD valign=top align=right>\n",
+ " <FONT color=$COLOR_ENTRIES_PTR>$entries_ptrs{$key}</FONT>\n",
+ " </TD><TD valign=top>\n",
+ " <FONT color=$COLOR_ENTRIES_ID><B>$key</B></FONT>\n",
+ " </TD><TD width=20>&nbsp;</TD><TD valign=top>\n",
+ " <font color=$COLOR_ENTRIES_DESC>$entries_params{$key}</font>\n",
+ " </TD></TR>\n";
+ }
+
+ print TYPES " <TR><TD colspan=4><I>);</I></TD></TR>\n",
+ " </TABLE>\n",
+ "</p><p>\n",
+ " $detailed\n",
+ "</p><hr>\n";
+ }
+ }
+
+#
+# Reads stdin until the end of the macro is reached.
+# Writes formatted HTML to "types.html".
+# Parameters are the macro name, parameters and value.
+#
+sub parse_macro ($$$)
+ {
+ local ($macro, $params, $value) = @_;
+
+ trim( \$macro );
+ trim( \$params );
+ trim( \$value );
+
+ while (<>)
+ {
+ chomp;
+
+ last unless /\\$/;
+ }
+
+ if (!defined ($options{"internal"}) && $value ne "") {
+ $macro_list{$macro} = $headline;
+ $type_list{$macro} = $headline;
+
+ $value =~ s/^\s*\\\s*$//;
+
+ print TYPES "<p>\n",
+ " <a name=\"$macro\" href=\"#$macro\">\n",
+ " <h3>\n",
+ " <font color=$COLOR_MACRO_NAME>$macro</font>\n",
+ " <font color=$COLOR_MACRO_PARAMS>$params</font>\n",
+ " </h3>\n",
+ " </a>\n",
+ " <h4>$headline</h4>\n",
+ " <font color=$COLOR_MACRO_VALUE size=+1><b>$value</b></font>\n",
+ "</p><p>\n",
+ " $detailed\n",
+ "</p><hr>\n";
+ }
+ }
+
+########################################################################################################################
+## HTML Files
+#
+
+sub html_create ($$$$$)
+ {
+ local ($FILE, $filename, $title, $subtitle, $singletitle) = @_;
+
+ open( $FILE, ">$filename" )
+ or die ("*** Can not open '$filename' for writing:\n*** $!");
+
+ print $FILE "<HTML>\n",
+ "<STYLE>\n",
+ " <!--\n",
+ " A{textdecoration:none}\n",
+ " -->\n",
+ "</STYLE>\n",
+ "<STYLE type=\"text/css\">\n",
+ " A:link, A:visited, A:active { text-decoration: none; }\n",
+ "</STYLE>\n",
+ "<HEAD>\n",
+ " <TITLE>$singletitle [$PROJECT Reference Manual]</TITLE>\n",
+ "</HEAD>\n",
+ "<BODY bgcolor=$COLOR_BG link=$COLOR_LINK vlink=$COLOR_LINK text=$COLOR_TEXT>\n",
+ "\n",
+ "<TABLE width=100% bgcolor=$COLOR_TOP_BG border=0 cellspacing=0 cellpadding=5>\n",
+ " <TR><TD width=30%>\n",
+ " <A href=\"http://www.directfb.org\"><IMG border=0 src=\"dfb_logo-alpha.png\"></A>\n",
+ " </TD><TD align=right>\n",
+ " &nbsp;&nbsp;",
+ " <A href=\"index.html\"><FONT size=+3 color=$COLOR_TOP_LINK>Reference Manual - $VERSION</FONT></A>\n",
+ " </TD></TR>\n",
+ " <TR><TD colspan=2 align=center bgcolor=$COLOR_TITLE_BG>\n";
+
+ if ($subtitle)
+ {
+ print $FILE " <TABLE border=0 cellspacing=0 cellpadding=0>\n",
+ " <TR><TD nowrap align=right width=50%>\n",
+ " <BIG><FONT color=$COLOR_TITLE_MAIN>$title&nbsp;</FONT></BIG>\n",
+ " </TD><TD nowrap align=left width=50%>\n",
+ " <BIG><FONT color=$COLOR_TITLE>&nbsp;$subtitle</FONT></BIG>\n",
+ " </TD></TR>\n",
+ " </TABLE>\n";
+ }
+ else
+ {
+ print $FILE " <BIG><FONT color=$COLOR_TITLE_MAIN>$title</FONT></BIG>\n";
+ }
+
+ print $FILE " </TD></TR>\n",
+ "</TABLE>\n",
+ "\n";
+ }
+
+sub html_close ($)
+ {
+ local ($FILE) = @_;
+
+ print $FILE "\n",
+ "<TABLE width=100% bgcolor=$COLOR_COPYRIGHT_BG border=0 cellspacing=1 cellpadding=3>\n",
+ " <TR><TD width=100>\n",
+ " <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/3.0/\">",
+ " <img alt=\"Creative Commons License\" style=\"border-width:0\" border=\"0\" ",
+ " src=\"http://i.creativecommons.org/l/by-sa/3.0/88x31.png\" />",
+ " </a>",
+ " </TD><TD>\n",
+ " This work is licensed under a",
+ " <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/3.0/\">",
+ " Creative Commons Attribution-Share Alike 3.0 License</a>",
+ " </TD></TR>\n",
+ "</TABLE>\n",
+ "</BODY>\n",
+ "</HTML>\n";
+
+ close( $FILE );
+ }
+
+
+########################################################################################################################
+## Main Function
+#
+
+sub gen_doc ($$) {
+ local ($project, $version) = @_;
+
+ trim( \$project );
+ trim( \$version );
+
+ html_create( INDEX, "index.html", "$PROJECT Reference", "API Overview", "Index" );
+ html_create( TYPES, "types.html", "$PROJECT Reference", "Type Definitions", "Types" );
+
+ print INDEX "<P>\n",
+ " <CENTER>\n",
+ " <H3>Interfaces</H3>\n",
+ " <TABLE width=90% border=0 cellpadding=2>\n";
+
+ while (<>) {
+ chomp;
+
+ if ( /^\s*DECLARE_INTERFACE\s*\(\s*(\w+)\s\)\s*$/ ) {
+ $interface = $1;
+
+ trim( \$interface );
+
+ if (!defined ($interfaces{$interface})) {
+ print INDEX " <TR><TD valign=top>\n",
+ " <A href=\"$1.html\">$1</A>\n",
+ " </TD><TD valign=top>\n",
+ " $headline $detailed\n",
+ " </TD></TR>\n";
+
+ $interfaces{$interface} = "$headline $detailed";
+ }
+ }
+ elsif ( /^\s*DEFINE_INTERFACE\s*\(\s*(\w+),\s*$/ ) {
+ parse_interface( $1 );
+ }
+ elsif ( /^\s*typedef\s+enum\s*\{?\s*$/ ) {
+ parse_enum();
+ }
+ elsif ( /^\s*typedef\s+(struct|union)\s*\{?\s*$/ ) {
+ parse_struct();
+ }
+ elsif ( /^\s*typedef\s+(\w+)\s+\(\*(\w+)\)\s*\(\s*$/ ) {
+ parse_func( $1, $2 );
+ }
+ elsif ( /^\s*#define\s+([^\(\s]+)(\([^\)]*\))?\s*(.*)/ ) {
+ parse_macro( $1, $2, $3 );
+ }
+ elsif ( /^\s*\/\*\s*$/ ) {
+ parse_comment( \$headline, \$detailed, \$options, "" );
+ }
+ else {
+ $headline = "";
+ $detailed = "";
+ %options = ();
+ }
+ }
+
+ print INDEX " </TABLE></CENTER>\n",
+ "</P>\n";
+
+ print_list( \%func_list, "Function Types" );
+ print_list( \%enum_list, "Enumerated Types" );
+ print_list( \%struct_list, "Structured Types" );
+ print_list( \%macro_list, "Definitions" );
+
+
+ html_close( INDEX );
+ html_close( TYPES );
+}
+
diff --git a/Source/DirectFB/tools/mkdfiff.c b/Source/DirectFB/tools/mkdfiff.c
new file mode 100755
index 0000000..b2fec18
--- /dev/null
+++ b/Source/DirectFB/tools/mkdfiff.c
@@ -0,0 +1,444 @@
+/*
+ (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 <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <png.h>
+
+#include <directfb.h>
+#include <directfb_strings.h>
+
+#include <direct/debug.h>
+
+#include <gfx/convert.h>
+
+#include <dfiff.h>
+
+static DirectFBPixelFormatNames( format_names );
+
+static const char *filename;
+static DFBSurfacePixelFormat format = DSPF_UNKNOWN;
+static DFBSurfacePixelFormat rgbformat = DSPF_UNKNOWN;
+
+/**********************************************************************************************************************/
+
+static DFBResult
+load_image (const char *filename,
+ DFBSurfaceDescription *desc)
+{
+ DFBSurfacePixelFormat dest_format;
+ DFBSurfacePixelFormat src_format;
+ FILE *fp;
+ png_structp png_ptr = NULL;
+ png_infop info_ptr = NULL;
+ png_uint_32 width, height;
+ unsigned char *data = NULL;
+ int type;
+ char header[8];
+ int bytes, pitch;
+
+ dest_format =
+ (desc->flags & DSDESC_PIXELFORMAT) ? desc->pixelformat : DSPF_UNKNOWN;
+
+ desc->flags = 0;
+ desc->preallocated[0].data = NULL;
+
+ if (!(fp = fopen (filename, "rb"))) {
+ fprintf (stderr, "Failed to open file '%s': %s.\n",
+ filename, strerror (errno));
+ goto cleanup;
+ }
+
+ bytes = fread (header, 1, sizeof(header), fp);
+ if (png_sig_cmp ((unsigned char*) header, 0, bytes)) {
+ fprintf (stderr, "File '%s' doesn't seem to be a PNG image file.\n",
+ filename);
+ goto cleanup;
+ }
+
+ png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,
+ NULL, NULL, NULL);
+ if (!png_ptr)
+ goto cleanup;
+
+ if (setjmp (png_ptr->jmpbuf)) {
+ if (desc->preallocated[0].data) {
+ free (desc->preallocated[0].data);
+ desc->preallocated[0].data = NULL;
+ }
+
+ /* data might have been clobbered,
+ set it to NULL and leak instead of crashing */
+ data = NULL;
+
+ goto cleanup;
+ }
+
+ info_ptr = png_create_info_struct (png_ptr);
+ if (!info_ptr)
+ goto cleanup;
+
+ png_init_io (png_ptr, fp);
+ png_set_sig_bytes (png_ptr, bytes);
+
+ png_read_info (png_ptr, info_ptr);
+
+ png_get_IHDR (png_ptr, info_ptr,
+ &width, &height, &bytes, &type, NULL, NULL, NULL);
+
+ if (bytes == 16)
+ png_set_strip_16 (png_ptr);
+
+#ifdef WORDS_BIGENDIAN
+ png_set_swap_alpha (png_ptr);
+#else
+ png_set_bgr (png_ptr);
+#endif
+
+ src_format = (type & PNG_COLOR_MASK_ALPHA) ? DSPF_ARGB : DSPF_RGB32;
+ switch (type) {
+ case PNG_COLOR_TYPE_GRAY:
+ if (dest_format == DSPF_A8) {
+ src_format = DSPF_A8;
+ break;
+ }
+ /* fallthru */
+ case PNG_COLOR_TYPE_GRAY_ALPHA:
+ png_set_gray_to_rgb (png_ptr);
+ if (rgbformat)
+ dest_format = rgbformat;
+ break;
+
+ case PNG_COLOR_TYPE_PALETTE:
+ png_set_palette_to_rgb (png_ptr);
+ /* fallthru */
+ case PNG_COLOR_TYPE_RGB:
+ if (rgbformat)
+ dest_format = rgbformat;
+ case PNG_COLOR_TYPE_RGB_ALPHA:
+ if (dest_format == DSPF_RGB24) {
+ png_set_strip_alpha (png_ptr);
+ src_format = DSPF_RGB24;
+ }
+ break;
+ }
+
+ switch (src_format) {
+ case DSPF_RGB32:
+ png_set_filler (png_ptr, 0xFF,
+#ifdef WORDS_BIGENDIAN
+ PNG_FILLER_BEFORE
+#else
+ PNG_FILLER_AFTER
+#endif
+ );
+ break;
+ case DSPF_ARGB:
+ case DSPF_A8:
+ if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
+ png_set_tRNS_to_alpha (png_ptr);
+ break;
+ default:
+ break;
+ }
+
+ pitch = (DFB_BYTES_PER_LINE( src_format, width ) + 7) & ~7;
+
+ data = malloc (height * pitch);
+ if (!data) {
+ fprintf (stderr, "Failed to allocate %ld bytes.\n", height * pitch);
+ goto cleanup;
+ }
+
+ {
+ unsigned int i;
+ png_bytep bptrs[height];
+
+ for (i = 0; i < height; i++)
+ bptrs[i] = data + i * pitch;
+
+ png_read_image (png_ptr, bptrs);
+ }
+
+ if (!dest_format)
+ dest_format = src_format;
+
+ if (DFB_BYTES_PER_PIXEL(src_format) != DFB_BYTES_PER_PIXEL(dest_format)) {
+ unsigned char *s, *d, *dest;
+ int d_pitch, h;
+
+ D_ASSERT( DFB_BYTES_PER_PIXEL(src_format) == 4 );
+
+ d_pitch = (DFB_BYTES_PER_LINE(dest_format, width) + 7) & ~7;
+
+ dest = malloc (height * d_pitch);
+ if (!dest) {
+ fprintf (stderr, "Failed to allocate %ld bytes.\n",
+ height * d_pitch);
+ goto cleanup;
+ }
+
+ h = height;
+ switch (dest_format) {
+ case DSPF_RGB16:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_rgb16 ((u32 *) s, (u16 *) d, width);
+ break;
+ case DSPF_ARGB1555:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_argb1555 ((u32 *) s, (u16 *) d, width);
+ break;
+ case DSPF_ARGB2554:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_argb2554 ((u32 *) s, (u16 *) d, width);
+ break;
+ case DSPF_ARGB4444:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_argb4444 ((u32 *) s, (u16 *) d, width);
+ break;
+ case DSPF_RGB332:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_rgb332 ((u32 *) s, (u8 *) d, width);
+ break;
+ case DSPF_A8:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_a8 ((u32 *) s, (u8 *) d, width);
+ break;
+ default:
+ fprintf (stderr,
+ "Sorry, unsupported format conversion.\n");
+ goto cleanup;
+ }
+
+ free (data);
+ data = dest;
+ pitch = d_pitch;
+ }
+
+ desc->flags = (DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT |
+ DSDESC_PREALLOCATED);
+ desc->width = width;
+ desc->height = height;
+ desc->pixelformat = dest_format;
+ desc->preallocated[0].pitch = pitch;
+ desc->preallocated[0].data = data;
+
+ data = NULL;
+
+ cleanup:
+ if (fp)
+ fclose (fp);
+
+ if (png_ptr)
+ png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
+
+ if (data)
+ free (data);
+
+ return ((desc->flags) ? DFB_OK : DFB_FAILURE);
+}
+
+/**********************************************************************************************************************/
+
+static void
+print_usage (const char *prg_name)
+{
+ int i = 0;
+
+ fprintf (stderr, "\nDirectFB Fast Image File Format Tool (version %s)\n\n", DIRECTFB_VERSION);
+ fprintf (stderr, "Usage: %s [options]\n\n", prg_name);
+ fprintf (stderr, "Options:\n");
+ fprintf (stderr, " -f, --format <pixelformat> Choose the pixel format (in all cases)\n");
+ fprintf (stderr, " -r, --rgbformat <pixelformat> Choose the pixel format (in case of RGB)\n");
+ fprintf (stderr, " -h, --help Show this help message\n");
+ fprintf (stderr, " -v, --version Print version information\n");
+ 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");
+}
+
+static DFBBoolean
+parse_format( const char *arg, DFBSurfacePixelFormat *ret_format )
+{
+ int i = 0;
+
+ while (format_names[i].format != DSPF_UNKNOWN) {
+ if (!strcasecmp( arg, format_names[i].name )) {
+ *ret_format = format_names[i].format;
+ return DFB_TRUE;
+ }
+
+ ++i;
+ }
+
+ fprintf (stderr, "\nInvalid format specified!\n\n" );
+
+ return DFB_FALSE;
+}
+
+static DFBBoolean
+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 DFB_FALSE;
+ }
+
+ if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
+ fprintf (stderr, "mkdfiff version %s\n", DIRECTFB_VERSION);
+ return DFB_FALSE;
+ }
+
+ if (strcmp (arg, "-f") == 0 || strcmp (arg, "--format") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (!parse_format( argv[n], &format ))
+ return DFB_FALSE;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-r") == 0 || strcmp (arg, "--rgbformat") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (!parse_format( argv[n], &rgbformat ))
+ return DFB_FALSE;
+
+ continue;
+ }
+
+ if (filename || access( arg, R_OK )) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ filename = arg;
+ }
+
+ if (!filename) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ return DFB_TRUE;
+}
+
+/**********************************************************************************************************************/
+
+static DFIFFHeader header = {
+ magic: { 'D', 'F', 'I', 'F', 'F' },
+ major: 0,
+ minor: 0,
+ flags: DFIFF_FLAG_LITTLE_ENDIAN
+};
+
+int
+main( int argc, char *argv[] )
+{
+ int i;
+ DFBSurfaceDescription desc = { flags: DSDESC_NONE };
+
+ /* Parse the command line. */
+ if (!parse_command_line( argc, argv ))
+ return -1;
+
+ if (format != DSPF_UNKNOWN) {
+ desc.flags |= DSDESC_PIXELFORMAT;
+ desc.pixelformat = format;
+ }
+
+ if (load_image( filename, &desc ))
+ return -2;
+
+ for (i=0; i<D_ARRAY_SIZE(format_names); i++) {
+ if (format_names[i].format == desc.pixelformat) {
+ fprintf( stderr, "Writing %dx%d %s image...\n", desc.width, desc.height,
+ format_names[i].name );
+ break;
+ }
+ }
+
+ header.width = desc.width;
+ header.height = desc.height;
+ header.format = desc.pixelformat;
+ header.pitch = desc.preallocated[0].pitch;
+
+ fwrite( &header, sizeof(header), 1, stdout );
+
+ fwrite( desc.preallocated[0].data, header.pitch, header.height, stdout );
+
+ return 0;
+}
diff --git a/Source/DirectFB/tools/mkdgiff.c b/Source/DirectFB/tools/mkdgiff.c
new file mode 100755
index 0000000..459d2a7
--- /dev/null
+++ b/Source/DirectFB/tools/mkdgiff.c
@@ -0,0 +1,616 @@
+/*
+ (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 <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <directfb.h>
+#include <directfb_strings.h>
+
+#include <direct/debug.h>
+#include <direct/mem.h>
+#include <direct/memcpy.h>
+#include <direct/direct.h>
+
+#include <gfx/convert.h>
+
+#include <dgiff.h>
+
+#undef SIZEOF_LONG
+#include <ft2build.h>
+#include FT_GLYPH_H
+
+#define MAX_SIZE_COUNT 256
+#define MAX_ROW_WIDTH 2047
+
+D_DEBUG_DOMAIN( mkdgiff, "mkdgiff", "DirectFB Glyph Image File Format Tool" );
+
+static DirectFBPixelFormatNames( format_names );
+
+static const char *filename;
+static int face_index;
+static DFBSurfacePixelFormat format = DSPF_A8;
+
+static int size_count;
+static int face_sizes[MAX_SIZE_COUNT];
+
+/**********************************************************************************************************************/
+
+static void
+print_usage (const char *prg_name)
+{
+ int i = 0;
+
+ fprintf (stderr, "\nDirectFB Glyph Image File Format Tool (version %s)\n\n", DIRECTFB_VERSION);
+ fprintf (stderr, "Usage: %s [options]\n\n", prg_name);
+ fprintf (stderr, "Options:\n");
+ fprintf (stderr, " -f, --format <pixelformat> Choose the pixel format (default A8)\n");
+ fprintf (stderr, " -s, --sizes <s1>[,s2...] Choose sizes to generate glyph images for\n");
+ fprintf (stderr, " -h, --help Show this help message\n");
+ fprintf (stderr, " -v, --version Print version information\n");
+ fprintf (stderr, "\n");
+
+ fprintf (stderr, "Known pixel formats with alpha:\n");
+
+ while (format_names[i].format != DSPF_UNKNOWN) {
+ DFBSurfacePixelFormat format = format_names[i].format;
+
+ if (DFB_PIXELFORMAT_HAS_ALPHA(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_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");
+}
+
+static DFBBoolean
+parse_format( const char *arg, DFBSurfacePixelFormat *ret_format )
+{
+ int i = 0;
+
+ while (format_names[i].format != DSPF_UNKNOWN) {
+ if (!strcasecmp( arg, format_names[i].name )) {
+ *ret_format = format_names[i].format;
+ return DFB_TRUE;
+ }
+
+ ++i;
+ }
+
+ fprintf (stderr, "\nInvalid format specified!\n\n" );
+
+ return DFB_FALSE;
+}
+
+static DFBBoolean
+parse_sizes( const char *arg )
+{
+ int i = 0;
+ int size = 0;
+
+ for (i=0; arg[i]; i++) {
+ switch (arg[i]) {
+ case '0' ... '9':
+ if (size_count == MAX_SIZE_COUNT) {
+ fprintf (stderr, "\nMaximum number of sizes (%d) exceeded!\n\n", MAX_SIZE_COUNT );
+ return DFB_FALSE;
+ }
+ size = size * 10 + arg[i] - '0';
+ break;
+
+ case ',':
+ if (size) {
+ face_sizes[size_count++] = size;
+ size = 0;
+ }
+ break;
+
+ default:
+ fprintf (stderr, "\nInvalid character used in sizes argument!\n\n" );
+ return DFB_FALSE;
+ }
+ }
+
+ if (size)
+ face_sizes[size_count++] = size;
+
+ return DFB_TRUE;
+}
+
+static DFBBoolean
+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 DFB_FALSE;
+ }
+
+ if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
+ fprintf (stderr, "mkdgiff version %s\n", DIRECTFB_VERSION);
+ return DFB_FALSE;
+ }
+
+ if (strcmp (arg, "-f") == 0 || strcmp (arg, "--format") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (!parse_format( argv[n], &format ))
+ return DFB_FALSE;
+
+ continue;
+ }
+
+ if (strcmp (arg, "-s") == 0 || strcmp (arg, "--sizes") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (!parse_sizes( argv[n] ))
+ return DFB_FALSE;
+
+ continue;
+ }
+
+ if (filename || access( arg, R_OK )) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ filename = arg;
+ }
+
+ if (!filename) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ return DFB_TRUE;
+}
+
+/**********************************************************************************************************************/
+
+static void
+write_glyph( DGIFFGlyphInfo *glyph, FT_GlyphSlot slot, void *dst, int pitch )
+{
+ int y;
+ u8 *src = slot->bitmap.buffer;
+
+ D_DEBUG_AT( mkdgiff, "%s( %p, %p, %p, %d ) <- width %d\n",
+ __FUNCTION__, glyph, slot, dst, pitch, glyph->width );
+
+ for (y=0; y < glyph->height; y++) {
+ int i, j, n;
+ u8 *dst8 = dst;
+ u16 *dst16 = dst;
+ u32 *dst32 = dst;
+
+ switch (slot->bitmap.pixel_mode) {
+ case ft_pixel_mode_grays:
+ switch (format) {
+ case DSPF_ARGB:
+ if (0){//FIXME thiz->surface_caps & DSCAPS_PREMULTIPLIED) {
+ for (i=0; i<glyph->width; i++)
+ dst32[i] = ((src[i] << 24) |
+ (src[i] << 16) |
+ (src[i] << 8) | src[i]);
+ }
+ else
+ for (i=0; i<glyph->width; i++)
+ dst32[i] = (src[i] << 24) | 0xFFFFFF;
+ break;
+ case DSPF_AiRGB:
+ for (i=0; i<glyph->width; i++)
+ dst32[i] = ((src[i] ^ 0xFF) << 24) | 0xFFFFFF;
+ break;
+ case DSPF_ARGB4444:
+ for (i=0; i<glyph->width; i++)
+ dst16[i] = (src[i] << 8) | 0xFFF;
+ break;
+ case DSPF_ARGB2554:
+ for (i=0; i<glyph->width; i++)
+ dst16[i] = (src[i] << 8) | 0x3FFF;
+ break;
+ case DSPF_ARGB1555:
+ for (i=0; i<glyph->width; i++)
+ dst16[i] = (src[i] << 8) | 0x7FFF;
+ break;
+ case DSPF_A8:
+ direct_memcpy( dst, src, glyph->width );
+ break;
+ case DSPF_A4:
+ for (i=0, j=0; i<glyph->width; i+=2, j++)
+ dst8[j] = (src[i] & 0xF0) | (src[i+1] >> 4);
+ break;
+ case DSPF_A1:
+ for (i=0, j=0; i < glyph->width; ++j) {
+ register u8 p = 0;
+
+ for (n=0; n<8 && i<glyph->width; ++i, ++n)
+ p |= (src[i] & 0x80) >> n;
+
+ dst8[j] = p;
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case ft_pixel_mode_mono:
+ switch (format) {
+ case DSPF_ARGB:
+ for (i=0; i<glyph->width; i++)
+ dst32[i] = (((src[i>>3] & (1<<(7-(i%8)))) ?
+ 0xFF : 0x00) << 24) | 0xFFFFFF;
+ break;
+ case DSPF_AiRGB:
+ for (i=0; i<glyph->width; i++)
+ dst32[i] = (((src[i>>3] & (1<<(7-(i%8)))) ?
+ 0x00 : 0xFF) << 24) | 0xFFFFFF;
+ break;
+ case DSPF_ARGB4444:
+ for (i=0; i<glyph->width; i++)
+ dst16[i] = (((src[i>>3] & (1<<(7-(i%8)))) ?
+ 0xF : 0x0) << 12) | 0xFFF;
+ break;
+ case DSPF_ARGB2554:
+ for (i=0; i<glyph->width; i++)
+ dst16[i] = (((src[i>>3] & (1<<(7-(i%8)))) ?
+ 0x3 : 0x0) << 14) | 0x3FFF;
+ break;
+ case DSPF_ARGB1555:
+ for (i=0; i<glyph->width; i++)
+ dst16[i] = (((src[i>>3] & (1<<(7-(i%8)))) ?
+ 0x1 : 0x0) << 15) | 0x7FFF;
+ break;
+ case DSPF_A8:
+ for (i=0; i<glyph->width; i++)
+ dst8[i] = (src[i>>3] &
+ (1<<(7-(i%8)))) ? 0xFF : 0x00;
+ break;
+ case DSPF_A4:
+ for (i=0, j=0; i<glyph->width; i+=2, j++)
+ dst8[j] = ((src[i>>3] &
+ (1<<(7-(i%8)))) ? 0xF0 : 0x00) |
+ ((src[(i+1)>>3] &
+ (1<<(7-((i+1)%8)))) ? 0x0F : 0x00);
+ break;
+ case DSPF_A1:
+ direct_memcpy( dst, src, DFB_BYTES_PER_LINE(DSPF_A1, glyph->width) );
+ break;
+ default:
+ break;
+ }
+ break;
+
+ default:
+ break;
+
+ }
+
+ src += slot->bitmap.pitch;
+ dst += pitch;
+ }
+}
+
+static int
+do_face( FT_Face face, int size )
+{
+ int i, ret;
+ int align = DFB_PIXELFORMAT_ALIGNMENT( format );
+ int num_glyphs = 0;
+ int num_rows = 1;
+ int row_index = 0;
+ int row_offset = 0;
+ int next_face = sizeof(DGIFFFaceHeader);
+ int total_height = 0;
+ FT_ULong code;
+ FT_UInt index;
+ DGIFFFaceHeader header;
+ DGIFFGlyphInfo *glyphs;
+ DGIFFGlyphRow *rows;
+ void **row_data;
+
+ D_DEBUG_AT( mkdgiff, "%s( %p, %d ) <- %ld glyphs\n", __FUNCTION__, face, size, face->num_glyphs );
+
+ /* Clear to not leak any data into file. */
+ memset( &header, 0, sizeof(header) );
+
+ /* Set the desired size. */
+ ret = FT_Set_Char_Size( face, 0, size << 6, 0, 0 );
+ if (ret) {
+ D_ERROR( "Could not set pixel size to %d!\n", size );
+ return ret;
+ }
+
+ /* Allocate glyph info array. */
+ glyphs = D_CALLOC( face->num_glyphs, sizeof(DGIFFGlyphInfo) );
+ rows = D_CALLOC( face->num_glyphs, sizeof(DGIFFGlyphRow) ); /* WORST case :) */
+ row_data = D_CALLOC( face->num_glyphs, sizeof(void*) ); /* WORST case :) */
+
+ for (code = FT_Get_First_Char( face, &index );
+ index;
+ code = FT_Get_Next_Char( face, code, &index ))
+ {
+ FT_GlyphSlot slot;
+ DGIFFGlyphInfo *glyph = &glyphs[num_glyphs];
+ DGIFFGlyphRow *row = &rows[num_rows - 1];
+
+ D_DEBUG_AT( mkdgiff, " -> code %3lu - index %3u\n", code, index );
+
+ if (num_glyphs == face->num_glyphs) {
+ D_ERROR( "Actual number of characters is bigger than number of glyphs!\n" );
+ break;
+ }
+
+ ret = FT_Load_Glyph( face, index, FT_LOAD_RENDER );
+ if (ret) {
+ D_ERROR( "Could not render glyph for character index %d!\n", index );
+ goto out;
+ }
+
+ slot = face->glyph;
+
+ glyph->unicode = code;
+
+ glyph->width = slot->bitmap.width;
+ glyph->height = slot->bitmap.rows;
+
+ glyph->left = slot->bitmap_left;
+ glyph->top = (face->size->metrics.ascender >> 6) - slot->bitmap_top;
+ glyph->advance = slot->advance.x >> 6;
+
+ num_glyphs++;
+
+ if (row->width > 0 && row->width + glyph->width > MAX_ROW_WIDTH) {
+ num_rows++;
+ row++;
+ }
+
+ row->width += (glyph->width + align) & ~align;
+
+ if (row->height < glyph->height)
+ row->height = glyph->height;
+ }
+
+ for (i=0; i<num_rows; i++) {
+ DGIFFGlyphRow *row = &rows[i];
+
+ D_DEBUG_AT( mkdgiff, " -> row %d, width %d, height %d\n", i, row->width, row->height );
+
+ total_height += row->height;
+
+ row->pitch = (DFB_BYTES_PER_LINE( format, row->width ) + 7) & ~7;
+
+ row_data[i] = D_CALLOC( row->height, row->pitch );
+
+ next_face += row->height * row->pitch;
+ }
+
+ D_DEBUG_AT( mkdgiff, " -> %d glyphs, %d rows, total height %d\n", num_glyphs, num_rows, total_height );
+
+ next_face += num_glyphs * sizeof(DGIFFGlyphInfo);
+ next_face += num_rows * sizeof(DGIFFGlyphRow);
+
+ for (i=0; i<num_glyphs; i++) {
+ DGIFFGlyphInfo *glyph = &glyphs[i];
+
+ D_DEBUG_AT( mkdgiff, " -> reloading character 0x%x (%d)\n", glyph->unicode, i );
+
+ ret = FT_Load_Char( face, glyph->unicode, FT_LOAD_RENDER );
+ if (ret) {
+ D_ERROR( "Could not render glyph for unicode character 0x%x!\n", glyph->unicode );
+ goto out;
+ }
+
+ if (row_offset > 0 && row_offset + glyph->width > MAX_ROW_WIDTH) {
+ row_index++;
+ row_offset = 0;
+ }
+
+
+ D_DEBUG_AT( mkdgiff, " -> row offset %d\n", row_offset );
+
+ write_glyph( glyph, face->glyph,
+ row_data[row_index] + DFB_BYTES_PER_LINE( format, row_offset ),
+ rows[row_index].pitch );
+
+ glyph->row = row_index;
+ glyph->offset = row_offset;
+
+ row_offset += (glyph->width + align) & ~align;
+ }
+
+ D_ASSERT( row_index == num_rows - 1 );
+
+ header.next_face = next_face;
+ header.size = size;
+
+ header.ascender = face->size->metrics.ascender >> 6;
+ header.descender = face->size->metrics.descender >> 6;
+ header.height = header.ascender - header.descender + 1;
+
+ header.max_advance = face->size->metrics.max_advance >> 6;
+
+ header.pixelformat = format;
+
+ header.num_glyphs = num_glyphs;
+ header.num_rows = num_rows;
+
+ D_DEBUG_AT( mkdgiff, " -> ascender %d, descender %d\n", header.ascender, header.descender );
+ D_DEBUG_AT( mkdgiff, " -> height %d, max advance %d\n", header.height, header.max_advance );
+
+ fwrite( &header, sizeof(header), 1, stdout );
+
+ fwrite( glyphs, sizeof(*glyphs), num_glyphs, stdout );
+
+ for (i=0; i<num_rows; i++) {
+ DGIFFGlyphRow *row = &rows[i];
+
+ fwrite( row, sizeof(*row), 1, stdout );
+
+ fwrite( row_data[i], row->pitch, row->height, stdout );
+ }
+
+out:
+ for (i=0; i<num_rows; i++) {
+ if (row_data[i])
+ D_FREE( row_data[i] );
+ }
+
+ D_FREE( row_data );
+ D_FREE( rows );
+ D_FREE( glyphs );
+
+ return ret;
+}
+
+/**********************************************************************************************************************/
+
+static DGIFFHeader header = {
+ magic: { 'D', 'G', 'I', 'F', 'F'},
+ major: 0,
+ minor: 0,
+ flags: DGIFF_FLAG_LITTLE_ENDIAN,
+ num_faces: 0
+};
+
+int
+main( int argc, char *argv[] )
+{
+ int i, ret;
+ FT_Library library = NULL;
+ FT_Face face = NULL;
+
+ direct_initialize();
+
+ direct_config->debug = true;
+ direct_config->debugmem = true;
+
+ /* Parse the command line. */
+ if (!parse_command_line( argc, argv ))
+ return -1;
+
+ if (!size_count) {
+ fprintf( stderr, "\n\nUsing default sizes 8, 10, 12, 16, 22, 32\n" );
+
+ size_count = 6;
+
+ face_sizes[0] = 8;
+ face_sizes[1] = 10;
+ face_sizes[2] = 12;
+ face_sizes[3] = 16;
+ face_sizes[4] = 22;
+ face_sizes[5] = 32;
+ }
+
+ header.num_faces = size_count;
+
+
+ ret = FT_Init_FreeType( &library );
+ if (ret) {
+ D_ERROR( "Initialization of the FreeType2 library failed!\n" );
+ goto out;
+ }
+
+ ret = FT_New_Face( library, filename, face_index, &face );
+ if (ret) {
+ if (ret == FT_Err_Unknown_File_Format)
+ D_ERROR( "Unsupported font format in file `%s'!\n", filename );
+ else
+ D_ERROR( "Failed loading face %d from font file `%s'!\n", face_index, filename );
+
+ goto out;
+ }
+
+ ret = FT_Select_Charmap( face, ft_encoding_unicode );
+ if (ret) {
+ D_ERROR( "Couldn't select Unicode encoding, falling back to Latin1.\n" );
+
+ ret = FT_Select_Charmap( face, ft_encoding_latin_1 );
+ if (ret)
+ D_ERROR( "Couldn't even select Latin1 encoding!\n" );
+ }
+
+ fwrite( &header, sizeof(header), 1, stdout );
+
+ for (i=0; i<size_count; i++) {
+ ret = do_face( face, face_sizes[i] );
+ if (ret)
+ goto out;
+ }
+
+
+out:
+ if (face)
+ FT_Done_Face( face );
+
+ if (library)
+ FT_Done_FreeType( library );
+
+ direct_print_memleaks();
+
+ direct_shutdown();
+
+ return ret;
+}
+
+
diff --git a/Source/DirectFB/tools/mkdgifft.cpp b/Source/DirectFB/tools/mkdgifft.cpp
new file mode 100755
index 0000000..4937558
--- /dev/null
+++ b/Source/DirectFB/tools/mkdgifft.cpp
@@ -0,0 +1,1043 @@
+/*
+ (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.
+*/
+
+#define DIRECT_ENABLE_DEBUG
+
+#include <config.h>
+
+extern "C" {
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+
+#include <png.h>
+
+#include <directfb.h>
+#include <directfb_strings.h>
+
+#include <direct/debug.h>
+#include <direct/list.h>
+#include <direct/mem.h>
+#include <direct/memcpy.h>
+#include <direct/direct.h>
+
+#include <gfx/convert.h>
+
+#include <dgiff.h>
+}
+
+#include <list>
+#include <map>
+#include <string>
+#include <vector>
+
+
+#define MAX_ROW_WIDTH 2047
+
+D_DEBUG_DOMAIN( mkdgiff, "mkdgiff", "DirectFB Glyph Image File Format Tool" );
+
+/**********************************************************************************************************************/
+
+static DirectFBPixelFormatNames( format_names );
+static DirectFBSurfaceBlittingFlagsNames( m_bflags );
+
+static const char *filename;
+static DFBSurfacePixelFormat m_format = DSPF_ARGB;
+
+/**********************************************************************************************************************/
+
+static void
+print_usage (const char *prg_name)
+{
+ int i = 0;
+
+ fprintf (stderr, "\nDirectFB Glyph Image File Format Tool (version %s)\n\n", DIRECTFB_VERSION);
+ fprintf (stderr, "Usage: %s [options]\n\n", prg_name);
+ fprintf (stderr, "Options:\n");
+ fprintf (stderr, " -f, --format <pixelformat> Choose the pixel format (default ARGB)\n");
+ fprintf (stderr, " -s, --sizes <s1>[,s2...] Choose sizes to generate glyph images for\n");
+ fprintf (stderr, " -h, --help Show this help message\n");
+ fprintf (stderr, " -v, --version Print version information\n");
+ fprintf (stderr, "\n");
+
+ fprintf (stderr, "Known pixel formats with alpha:\n");
+
+ while (format_names[i].format != DSPF_UNKNOWN) {
+ DFBSurfacePixelFormat format = format_names[i].format;
+
+ if (DFB_PIXELFORMAT_HAS_ALPHA(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_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");
+}
+
+static DFBBoolean
+parse_format( const char *arg, DFBSurfacePixelFormat *ret_format )
+{
+ int i = 0;
+
+ while (format_names[i].format != DSPF_UNKNOWN) {
+ if (!strcasecmp( arg, format_names[i].name )) {
+ *ret_format = format_names[i].format;
+ return DFB_TRUE;
+ }
+
+ ++i;
+ }
+
+ fprintf (stderr, "\nInvalid format specified!\n\n" );
+
+ return DFB_FALSE;
+}
+
+static void
+parse_flags( const char *arg, DFBSurfaceBlittingFlags *ret_flags )
+{
+ int i;
+
+ *ret_flags = DSBLIT_NOFX;
+
+ for (i=0; i<D_ARRAY_SIZE(m_bflags); i++) {
+ if (strcasestr( arg, m_bflags[i].name ))
+ *ret_flags = (DFBSurfaceBlittingFlags)(*ret_flags | m_bflags[i].flag);
+ }
+}
+
+static DFBBoolean
+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 DFB_FALSE;
+ }
+
+ if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
+ fprintf (stderr, "mkdgiff version %s\n", DIRECTFB_VERSION);
+ return DFB_FALSE;
+ }
+
+ if (strcmp (arg, "-f") == 0 || strcmp (arg, "--format") == 0) {
+ if (++n == argc) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ if (!parse_format( argv[n], &m_format ))
+ return DFB_FALSE;
+
+ continue;
+ }
+
+ if (filename || access( arg, R_OK )) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ filename = arg;
+ }
+
+ if (!filename) {
+ print_usage (argv[0]);
+ return DFB_FALSE;
+ }
+
+ return DFB_TRUE;
+}
+
+/**********************************************************************************************************************/
+
+class Entity
+{
+public:
+ Entity()
+ {
+ }
+
+
+ typedef enum {
+ ENTITY_NONE,
+
+ ENTITY_FACE,
+ ENTITY_GLYPH
+ } Type;
+
+ virtual Type GetType() const = 0;
+
+
+ virtual void Dump() const;
+
+ virtual void SetProperty( const std::string &name, const std::string &value );
+
+
+ const char *buf;
+ size_t length;
+
+
+ typedef std::list<Entity*> list;
+ typedef std::vector<Entity*> vector;
+};
+
+class Face : public Entity
+{
+public:
+ Face()
+ :
+ Entity(),
+ size( 0 ),
+ height( 0 ),
+ ascender( 0 ),
+ descender( 0 ),
+ maxadvance( 0 ),
+ blittingflags( DSBLIT_NOFX )
+ {
+ }
+
+
+ virtual Type GetType() const { return ENTITY_FACE; }
+
+
+ virtual void Dump() const;
+
+ virtual void SetProperty( const std::string &name, const std::string &value );
+
+
+ unsigned int size;
+ unsigned int height;
+ int ascender;
+ int descender;
+ int maxadvance;
+ DFBSurfaceBlittingFlags blittingflags;
+};
+
+class Glyph : public Entity
+{
+public:
+ Glyph()
+ :
+ Entity(),
+ unicode( 0 ),
+ left( 0 ),
+ top( 0 ),
+ advance( 0 )
+ {
+ }
+
+
+ virtual Type GetType() const { return ENTITY_GLYPH; }
+
+
+ virtual void Dump() const;
+
+ virtual void SetProperty( const std::string &name, const std::string &value );
+
+
+ unsigned int unicode;
+ int left;
+ int top;
+ int advance;
+ std::string file;
+};
+
+/**********************************************************************************************************************/
+
+void
+Entity::Dump() const
+{
+ direct_log_printf( NULL, "\n" );
+ direct_log_printf( NULL, "Entity (TYPE %d)\n", GetType() );
+ direct_log_printf( NULL, " Buffer at %p [%zu]\n", buf, length );
+}
+
+void
+Face::Dump() const
+{
+ Entity::Dump();
+
+ direct_log_printf( NULL, " Size %u\n", size );
+ direct_log_printf( NULL, " Height %u\n", height );
+ direct_log_printf( NULL, " Ascender %d\n", ascender );
+ direct_log_printf( NULL, " Descender %d\n", descender );
+ direct_log_printf( NULL, " MaxAdvance %d\n", maxadvance );
+ direct_log_printf( NULL, " BlittingFlags 0x%08x\n", blittingflags );
+}
+
+void
+Glyph::Dump() const
+{
+ Entity::Dump();
+
+ direct_log_printf( NULL, " Unicode 0x%04x\n", unicode );
+ direct_log_printf( NULL, " Left %d\n", left );
+ direct_log_printf( NULL, " Top %d\n", top );
+ direct_log_printf( NULL, " Advance %d\n", advance );
+ direct_log_printf( NULL, " File '%s'\n", file.c_str() );
+}
+
+/**********************************************************************************************************************/
+
+void
+Entity::SetProperty( const std::string &name,
+ const std::string &value )
+{
+}
+
+void
+Face::SetProperty( const std::string &name,
+ const std::string &value )
+{
+ if (name == "size") {
+ sscanf( value.c_str(), "%u", &size );
+ return;
+ }
+
+ if (name == "height") {
+ sscanf( value.c_str(), "%u", &height );
+ return;
+ }
+
+ if (name == "ascender") {
+ sscanf( value.c_str(), "%d", &ascender );
+ return;
+ }
+
+ if (name == "descender") {
+ sscanf( value.c_str(), "%d", &descender );
+ return;
+ }
+
+ if (name == "maxadvance") {
+ sscanf( value.c_str(), "%d", &maxadvance );
+ return;
+ }
+
+ if (name == "blittingflags") {
+ parse_flags( value.c_str(), &blittingflags );
+ return;
+ }
+}
+
+void
+Glyph::SetProperty( const std::string &name,
+ const std::string &value )
+{
+ if (name == "unicode") {
+ sscanf( value.c_str(), "%x", &unicode );
+ return;
+ }
+
+ if (name == "left") {
+ sscanf( value.c_str(), "%d", &left );
+ return;
+ }
+
+ if (name == "top") {
+ sscanf( value.c_str(), "%d", &top );
+ return;
+ }
+
+ if (name == "advance") {
+ sscanf( value.c_str(), "%d", &advance );
+ return;
+ }
+
+ if (name == "file") {
+ file = value;
+ return;
+ }
+}
+
+/**********************************************************************************************************************/
+
+static void
+get_entities( const char *buf,
+ size_t length,
+ Entity::vector &out_vector )
+{
+ size_t i;
+ unsigned int level = 0;
+ bool quote = false;
+
+ std::string name;
+ std::map<unsigned int,std::string> names;
+
+ Entity *entity = NULL;
+
+ D_DEBUG_AT( mkdgiff, "%s( buf %p, length %zu )\n", __func__, buf, length );
+
+ for (i=0; i<length; i++) {
+ D_DEBUG_AT( mkdgiff, "%*s[%u] -> '%c' <-\n", level*2, "", level, buf[i] );
+
+ if (quote) {
+ switch (buf[i]) {
+ case '"':
+ quote = false;
+ break;
+
+ default:
+ name += buf[i];
+ }
+ }
+ else {
+ switch (buf[i]) {
+ case '"':
+ quote = true;
+ break;
+
+ case '-':
+ case '_':
+ case 'a' ... 'z':
+ case 'A' ... 'Z':
+ case '0' ... '9':
+ name += buf[i];
+ break;
+
+ default:
+ if (!name.empty()) {
+ D_DEBUG_AT( mkdgiff, "%*s=-> name = '%s'\n", level*2, "", name.c_str() );
+
+ if (!names[level].empty()) {
+ switch (level) {
+ case 1:
+ D_DEBUG_AT( mkdgiff, "%*s#### setting property '%s' = '%s'\n",
+ level*2, "", names[level].c_str(), name.c_str() );
+
+ D_ASSERT( entity != NULL );
+
+ entity->SetProperty( names[level], name );
+ break;
+
+ default:
+ break;
+ }
+
+ name = "";
+ }
+
+ names[level] = name;
+ name = "";
+ }
+
+ switch (buf[i]) {
+ case '{':
+ case '}':
+ switch (buf[i]) {
+ case '{':
+ switch (level) {
+ case 0:
+ if (names[level] == "face") {
+ D_ASSERT( entity == NULL );
+
+ entity = new Face();
+
+ entity->buf = &buf[i + 1];
+
+ D_DEBUG_AT( mkdgiff, "%*s#### open entity %p (Face)\n", level*2, "", entity );
+ }
+ if (names[level] == "glyph") {
+ D_ASSERT( entity == NULL );
+
+ entity = new Glyph();
+
+ entity->buf = &buf[i + 1];
+
+ D_DEBUG_AT( mkdgiff, "%*s#### open entity %p (Glyph)\n", level*2, "", entity );
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ names[level] = "";
+
+ level++;
+ break;
+
+ case '}':
+ D_ASSERT( names[level].empty() );
+
+ level--;
+
+ switch (level) {
+ case 0:
+ D_DEBUG_AT( mkdgiff, "%*s#### close entity %p\n", level*2, "", entity );
+
+ D_ASSERT( entity != NULL );
+
+ entity->length = &buf[i-1] - entity->buf;
+
+ out_vector.push_back( entity );
+
+ entity = NULL;
+ break;
+
+ case 1:
+ break;
+
+ default:
+ break;
+ }
+ break;
+ }
+
+ D_DEBUG_AT( mkdgiff, "%*s=-> level => %u\n", level*2, "", level );
+ break;
+
+ case ' ':
+ case '\t':
+ case '\n':
+ case '\r':
+ break;
+
+ default:
+ break;
+ }
+ break;
+ }
+ }
+ }
+}
+
+/**********************************************************************************************************************/
+
+static DFBResult
+load_image (const char *filename,
+ DFBSurfaceDescription *desc)
+{
+ DFBSurfacePixelFormat dest_format;
+ DFBSurfacePixelFormat src_format;
+ FILE *fp;
+ png_structp png_ptr = NULL;
+ png_infop info_ptr = NULL;
+ png_uint_32 width, height;
+ unsigned char *data = NULL;
+ int type;
+ char header[8];
+ int bytes, pitch;
+
+ dest_format = (desc->flags & DSDESC_PIXELFORMAT) ? desc->pixelformat : DSPF_UNKNOWN;
+
+ desc->flags = DSDESC_NONE;
+ desc->preallocated[0].data = NULL;
+
+ if (!(fp = fopen (filename, "rb"))) {
+ fprintf (stderr, "Failed to open file '%s': %s.\n",
+ filename, strerror (errno));
+ goto cleanup;
+ }
+
+ bytes = fread (header, 1, sizeof(header), fp);
+ if (png_sig_cmp ((unsigned char*) header, 0, bytes)) {
+ fprintf (stderr, "File '%s' doesn't seem to be a PNG image file.\n",
+ filename);
+ goto cleanup;
+ }
+
+ png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,
+ NULL, NULL, NULL);
+ if (!png_ptr)
+ goto cleanup;
+
+ if (setjmp (png_ptr->jmpbuf)) {
+ if (desc->preallocated[0].data) {
+ free (desc->preallocated[0].data);
+ desc->preallocated[0].data = NULL;
+ }
+
+ /* data might have been clobbered,
+ set it to NULL and leak instead of crashing */
+ data = NULL;
+
+ goto cleanup;
+ }
+
+ info_ptr = png_create_info_struct (png_ptr);
+ if (!info_ptr)
+ goto cleanup;
+
+ png_init_io (png_ptr, fp);
+ png_set_sig_bytes (png_ptr, bytes);
+
+ png_read_info (png_ptr, info_ptr);
+
+ png_get_IHDR (png_ptr, info_ptr,
+ &width, &height, &bytes, &type, NULL, NULL, NULL);
+
+ if (bytes == 16)
+ png_set_strip_16 (png_ptr);
+
+#ifdef WORDS_BIGENDIAN
+ png_set_swap_alpha (png_ptr);
+#else
+ png_set_bgr (png_ptr);
+#endif
+
+ src_format = (type & PNG_COLOR_MASK_ALPHA) ? DSPF_ARGB : DSPF_RGB32;
+ switch (type) {
+ case PNG_COLOR_TYPE_GRAY:
+ if (dest_format == DSPF_A8) {
+ src_format = DSPF_A8;
+ break;
+ }
+ /* fallthru */
+ case PNG_COLOR_TYPE_GRAY_ALPHA:
+ png_set_gray_to_rgb (png_ptr);
+// if (rgbformat)
+// dest_format = rgbformat;
+ break;
+
+ case PNG_COLOR_TYPE_PALETTE:
+ png_set_palette_to_rgb (png_ptr);
+ /* fallthru */
+ case PNG_COLOR_TYPE_RGB:
+// if (rgbformat)
+// dest_format = rgbformat;
+ case PNG_COLOR_TYPE_RGB_ALPHA:
+ if (dest_format == DSPF_RGB24) {
+ png_set_strip_alpha (png_ptr);
+ src_format = DSPF_RGB24;
+ }
+ break;
+ }
+
+ switch (src_format) {
+ case DSPF_RGB32:
+ png_set_filler (png_ptr, 0xFF,
+#ifdef WORDS_BIGENDIAN
+ PNG_FILLER_BEFORE
+#else
+ PNG_FILLER_AFTER
+#endif
+ );
+ break;
+ case DSPF_ARGB:
+ case DSPF_A8:
+ if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
+ png_set_tRNS_to_alpha (png_ptr);
+ break;
+ default:
+ break;
+ }
+
+ pitch = (DFB_BYTES_PER_LINE( src_format, width ) + 7) & ~7;
+
+ data = (unsigned char*) malloc (height * pitch);
+ if (!data) {
+ fprintf (stderr, "Failed to allocate %ld bytes.\n", height * pitch);
+ goto cleanup;
+ }
+
+ {
+ unsigned int i;
+ png_bytep bptrs[height];
+
+ for (i = 0; i < height; i++)
+ bptrs[i] = data + i * pitch;
+
+ png_read_image (png_ptr, bptrs);
+ }
+
+ if (!dest_format)
+ dest_format = src_format;
+
+ if (DFB_BYTES_PER_PIXEL(src_format) != DFB_BYTES_PER_PIXEL(dest_format)) {
+ unsigned char *s, *d, *dest;
+ int d_pitch, h;
+
+ D_ASSERT( DFB_BYTES_PER_PIXEL(src_format) == 4 );
+
+ d_pitch = (DFB_BYTES_PER_LINE(dest_format, width) + 7) & ~7;
+
+ dest = (unsigned char*) malloc (height * d_pitch);
+ if (!dest) {
+ fprintf (stderr, "Failed to allocate %ld bytes.\n",
+ height * d_pitch);
+ goto cleanup;
+ }
+
+ h = height;
+ switch (dest_format) {
+ case DSPF_RGB16:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_rgb16 ((u32 *) s, (u16 *) d, width);
+ break;
+ case DSPF_ARGB1555:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_argb1555 ((u32 *) s, (u16 *) d, width);
+ break;
+ case DSPF_ARGB2554:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_argb2554 ((u32 *) s, (u16 *) d, width);
+ break;
+ case DSPF_ARGB4444:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_argb4444 ((u32 *) s, (u16 *) d, width);
+ break;
+ case DSPF_RGB332:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_rgb332 ((u32 *) s, (u8 *) d, width);
+ break;
+ case DSPF_A8:
+ for (s = data, d = dest; h; h--, s += pitch, d += d_pitch)
+ dfb_argb_to_a8 ((u32 *) s, (u8 *) d, width);
+ break;
+ default:
+ fprintf (stderr,
+ "Sorry, unsupported format conversion.\n");
+ goto cleanup;
+ }
+
+ free (data);
+ data = dest;
+ pitch = d_pitch;
+ }
+
+ desc->flags = (DFBSurfaceDescriptionFlags)(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT |
+ DSDESC_PREALLOCATED);
+ desc->width = width;
+ desc->height = height;
+ desc->pixelformat = dest_format;
+ desc->preallocated[0].pitch = pitch;
+ desc->preallocated[0].data = data;
+
+ data = NULL;
+
+ cleanup:
+ if (fp)
+ fclose (fp);
+
+ if (png_ptr)
+ png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
+
+ if (data)
+ free (data);
+
+ return ((desc->flags) ? DFB_OK : DFB_FAILURE);
+}
+
+/**********************************************************************************************************************/
+
+static void
+write_glyph( DGIFFGlyphInfo *glyph, const DFBSurfaceDescription &desc, void *dst, int pitch )
+{
+ D_DEBUG_AT( mkdgiff, "%s( %p, %p, %d ) <- size %ux%u\n",
+ __FUNCTION__, glyph, dst, pitch, desc.width, desc.height );
+
+ switch (m_format) {
+ case DSPF_ARGB:
+ dfb_convert_to_argb( desc.pixelformat, desc.preallocated[0].data, desc.preallocated[0].pitch,
+ desc.height, (u32*) dst, pitch, desc.width, desc.height );
+ break;
+
+ default:
+ D_UNIMPLEMENTED();
+ break;
+ }
+}
+
+static int
+do_face( const Face *face )
+{
+ int i, ret;
+ int align = DFB_PIXELFORMAT_ALIGNMENT( m_format );
+ int num_glyphs = 0;
+ int num_rows = 1;
+ int row_index = 0;
+ int row_offset = 0;
+ int next_face = sizeof(DGIFFFaceHeader);
+ int total_height = 0;
+
+ Entity::vector glyph_vector;
+ unsigned int glyph_count = 0;
+
+ DGIFFFaceHeader header;
+ DGIFFGlyphInfo *glyphs;
+ DGIFFGlyphRow *rows;
+ void **row_data;
+
+ DFBSurfaceDescription *descs;
+
+ D_DEBUG_AT( mkdgiff, "%s( %p )\n", __FUNCTION__, face );
+
+ get_entities( face->buf, face->length, glyph_vector );
+
+ glyph_count = glyph_vector.size();
+
+
+ /* Clear to not leak any data into file. */
+ memset( &header, 0, sizeof(header) );
+
+
+ /* Allocate glyph info array. */
+ glyphs = (DGIFFGlyphInfo*) D_CALLOC( glyph_count, sizeof(DGIFFGlyphInfo) );
+ rows = (DGIFFGlyphRow*) D_CALLOC( glyph_count, sizeof(DGIFFGlyphRow) ); /* WORST case :) */
+ row_data = (void**) D_CALLOC( glyph_count, sizeof(void*) ); /* WORST case :) */
+ descs = (DFBSurfaceDescription*) D_CALLOC( glyph_count, sizeof(DFBSurfaceDescription) ); /* WORST case :) */
+
+ for (Entity::vector::const_iterator iter = glyph_vector.begin(); iter != glyph_vector.end(); iter++) {
+ const Glyph *glyph = dynamic_cast<const Glyph*>( *iter );
+
+ glyph->Dump();
+
+
+ DGIFFGlyphInfo *info = &glyphs[num_glyphs];
+ DGIFFGlyphRow *row = &rows[num_rows - 1];
+
+ D_DEBUG_AT( mkdgiff, " -> code %3u\n", glyph->unicode );
+
+ ret = load_image( glyph->file.c_str(), &descs[num_glyphs] );
+ if (ret)
+ continue;
+
+ info->unicode = glyph->unicode;
+
+ info->width = descs[num_glyphs].width;
+ info->height = descs[num_glyphs].height;
+
+ info->left = glyph->left;
+ info->top = glyph->top;
+ info->advance = glyph->advance;
+
+ num_glyphs++;
+
+ if (row->width > 0 && row->width + info->width > MAX_ROW_WIDTH) {
+ num_rows++;
+ row++;
+ }
+
+ row->width += (info->width + align) & ~align;
+
+ if (row->height < info->height)
+ row->height = info->height;
+ }
+
+ for (i=0; i<num_rows; i++) {
+ DGIFFGlyphRow *row = &rows[i];
+
+ D_DEBUG_AT( mkdgiff, " -> row %d, width %d, height %d\n", i, row->width, row->height );
+
+ total_height += row->height;
+
+ row->pitch = (DFB_BYTES_PER_LINE( m_format, row->width ) + 7) & ~7;
+
+ row_data[i] = D_CALLOC( row->height, row->pitch );
+
+ next_face += row->height * row->pitch;
+ }
+
+ D_DEBUG_AT( mkdgiff, " -> %d glyphs, %d rows, total height %d\n", num_glyphs, num_rows, total_height );
+
+ next_face += num_glyphs * sizeof(DGIFFGlyphInfo);
+ next_face += num_rows * sizeof(DGIFFGlyphRow);
+
+ for (i=0; i<num_glyphs; i++) {
+ DGIFFGlyphInfo *glyph = &glyphs[i];
+
+ D_DEBUG_AT( mkdgiff, " -> writing character 0x%x (%d)\n", glyph->unicode, i );
+
+ if (row_offset > 0 && row_offset + glyph->width > MAX_ROW_WIDTH) {
+ row_index++;
+ row_offset = 0;
+ }
+
+
+ D_DEBUG_AT( mkdgiff, " -> row offset %d\n", row_offset );
+
+ write_glyph( glyph, descs[i],
+ (char*) row_data[row_index] + DFB_BYTES_PER_LINE( m_format, row_offset ),
+ rows[row_index].pitch );
+
+ glyph->row = row_index;
+ glyph->offset = row_offset;
+
+ row_offset += (glyph->width + align) & ~align;
+ }
+
+ D_ASSERT( row_index == num_rows - 1 );
+
+ header.next_face = next_face;
+ header.size = face->size;
+
+ header.ascender = face->ascender;
+ header.descender = face->descender;
+ header.height = face->height;
+
+ header.max_advance = face->maxadvance;
+
+ header.pixelformat = m_format;
+
+ header.num_glyphs = num_glyphs;
+ header.num_rows = num_rows;
+
+ header.blittingflags = face->blittingflags;
+
+ D_DEBUG_AT( mkdgiff, " -> ascender %d, descender %d\n", header.ascender, header.descender );
+ D_DEBUG_AT( mkdgiff, " -> height %d, max advance %d\n", header.height, header.max_advance );
+
+ fwrite( &header, sizeof(header), 1, stdout );
+
+ fwrite( glyphs, sizeof(*glyphs), num_glyphs, stdout );
+
+ for (i=0; i<num_rows; i++) {
+ DGIFFGlyphRow *row = &rows[i];
+
+ fwrite( row, sizeof(*row), 1, stdout );
+
+ fwrite( row_data[i], row->pitch, row->height, stdout );
+ }
+
+ for (i=0; i<num_rows; i++) {
+ if (row_data[i])
+ D_FREE( row_data[i] );
+ }
+
+ D_FREE( row_data );
+ D_FREE( rows );
+ D_FREE( glyphs );
+
+ return 0;
+}
+
+/**********************************************************************************************************************/
+
+int
+main( int argc, char *argv[] )
+{
+ int ret;
+ int fd;
+ struct stat stat;
+ void *ptr = MAP_FAILED;
+ Entity::vector faces;
+ DGIFFHeader header = {
+ magic: { 'D', 'G', 'I', 'F', 'F' },
+ major: 0,
+ minor: 0,
+ flags: DGIFF_FLAG_LITTLE_ENDIAN,
+ num_faces: 0
+ };
+
+ direct_initialize();
+
+ direct_debug_config_domain( "mkdgiff", true );
+
+ direct_config->debug = true;
+ direct_config->debugmem = true;
+
+ /* Parse the command line. */
+ if (!parse_command_line( argc, argv ))
+ return -1;
+
+
+ /* Open the file. */
+ fd = open( filename, O_RDONLY );
+ if (fd < 0) {
+ ret = errno2result( errno );
+ D_PERROR( "Font/DGIFF: Failure during open() of '%s'!\n", filename );
+ return ret;
+ }
+
+ /* Query file size etc. */
+ if (fstat( fd, &stat ) < 0) {
+ ret = errno2result( errno );
+ D_PERROR( "Font/DGIFF: Failure during fstat() of '%s'!\n", filename );
+ goto out;
+ }
+
+ /* Memory map the file. */
+ ptr = mmap( NULL, stat.st_size, PROT_READ, MAP_SHARED, fd, 0 );
+ if (ptr == MAP_FAILED) {
+ ret = errno2result( errno );
+ D_PERROR( "Font/DGIFF: Failure during mmap() of '%s'!\n", filename );
+ goto out;
+ }
+
+
+ get_entities( (const char*) ptr, stat.st_size, faces );
+
+ header.num_faces = faces.size();
+
+
+
+ fwrite( &header, sizeof(header), 1, stdout );
+
+ for (Entity::vector::const_iterator iter = faces.begin(); iter != faces.end(); iter++) {
+ const Face *face = dynamic_cast<const Face*>( *iter );
+
+ face->Dump();
+
+ ret = do_face( face );
+ if (ret)
+ goto out;
+ }
+
+
+out:
+ if (ptr != MAP_FAILED)
+ munmap( ptr, stat.st_size );
+
+ close( fd );
+
+ direct_print_memleaks();
+
+ direct_shutdown();
+
+ return ret;
+}
+
diff --git a/Source/DirectFB/tools/mknames.sh b/Source/DirectFB/tools/mknames.sh
new file mode 100755
index 0000000..8e4ca2f
--- /dev/null
+++ b/Source/DirectFB/tools/mknames.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+if test -z "$6"; then
+ echo "Usage: $0 <enum> <prefix> <null> <name> <value> <header>"
+ echo "Example: $0 DFBSurfacePixelFormat DSPF UNKNOWN PixelFormat format directfb.h"
+ exit 1
+fi
+
+ENUM=$1
+PREFIX=$2
+NULL=$3
+NAME=$4
+VALUE=$5
+HEADER=$6
+
+
+cat << EOF
+
+
+struct DFB${NAME}Name {
+ ${ENUM} ${VALUE};
+ const char *name;
+};
+
+#define DirectFB${NAME}Names(Identifier) struct DFB${NAME}Name Identifier[] = { \\
+EOF
+
+egrep "^ +${PREFIX}_[0-9A-Za-z_]+[ ,]" $HEADER | grep -v ${PREFIX}_${NULL} | perl -p -e "s/^\\s*(${PREFIX}_)([\\w_]+)[ ,].*/ \\{ \\1\\2, \\\"\\2\\\" \\}, \\\\/"
+
+cat << EOF
+ { ${PREFIX}_${NULL}, "${NULL}" } \\
+};
+EOF
diff --git a/Source/DirectFB/tools/raw15toraw24.c b/Source/DirectFB/tools/raw15toraw24.c
new file mode 100755
index 0000000..56132de
--- /dev/null
+++ b/Source/DirectFB/tools/raw15toraw24.c
@@ -0,0 +1,61 @@
+/*
+ (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 <unistd.h>
+#include <stdio.h>
+
+int main( void )
+{
+ unsigned char byt;
+ unsigned short wrd;
+
+ do {
+ fread (&wrd, 2, 1, stdin);
+
+#ifdef WORDS_BIGENDIAN
+ swab (&wrd, &wrd, 2);
+#endif
+
+ byt = (wrd & 0x7800) >> 7;
+ fwrite (&byt, 1, 1, stdout);
+ byt = (wrd & 0x03E0) >> 2;
+ fwrite (&byt, 1, 1, stdout);
+ byt = (wrd & 0x001F) << 3;
+ fwrite (&byt, 1, 1, stdout);
+ } while (!feof (stdin));
+
+ return 0;
+}
diff --git a/Source/DirectFB/tools/raw16toraw24.c b/Source/DirectFB/tools/raw16toraw24.c
new file mode 100755
index 0000000..b9b89c4
--- /dev/null
+++ b/Source/DirectFB/tools/raw16toraw24.c
@@ -0,0 +1,61 @@
+/*
+ (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 <unistd.h>
+#include <stdio.h>
+
+int main( void )
+{
+ unsigned char byt;
+ unsigned short wrd;
+
+ do {
+ fread (&wrd, 2, 1, stdin);
+
+#ifdef WORDS_BIGENDIAN
+ swab (&wrd, &wrd, 2);
+#endif
+
+ byt = (wrd & 0xf800) >> 8;
+ fwrite (&byt, 1, 1, stdout);
+ byt = (wrd & 0x07E0) >> 3;
+ fwrite (&byt, 1, 1, stdout);
+ byt = (wrd & 0x001F) << 3;
+ fwrite (&byt, 1, 1, stdout);
+ } while (!feof (stdin));
+
+ return 0;
+}
diff --git a/Source/DirectFB/tools/raw32toraw24.c b/Source/DirectFB/tools/raw32toraw24.c
new file mode 100755
index 0000000..df68fe1
--- /dev/null
+++ b/Source/DirectFB/tools/raw32toraw24.c
@@ -0,0 +1,63 @@
+/*
+ (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 <unistd.h>
+#include <stdio.h>
+
+#include "dfb_types.h"
+
+int main( void )
+{
+ u8 byt;
+ u32 pixel32;
+
+ do {
+ fread (&pixel32, 4, 1, stdin);
+
+#ifdef WORDS_BIGENDIAN
+ pixel32 = (pixel32 << 16) | (pixel32 >> 16);
+#endif
+
+ byt = (pixel32 & 0xff0000) >> 16;
+ fwrite (&byt, 1, 1, stdout);
+ byt = (pixel32 & 0x00ff00) >> 8;
+ fwrite (&byt, 1, 1, stdout);
+ byt = (pixel32 & 0x0000ff);
+ fwrite (&byt, 1, 1, stdout);
+ } while (!feof (stdin));
+
+ return 0;
+}
diff --git a/Source/DirectFB/tools/voodooplay.c b/Source/DirectFB/tools/voodooplay.c
new file mode 100755
index 0000000..2d50ddf
--- /dev/null
+++ b/Source/DirectFB/tools/voodooplay.c
@@ -0,0 +1,164 @@
+/*
+ (c) Copyright 2001-2010 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 <stdlib.h>
+#include <unistd.h>
+
+#include <directfb.h>
+
+#include <direct/debug.h>
+#include <direct/interface.h>
+#include <direct/mem.h>
+#include <direct/messages.h>
+#include <direct/util.h>
+
+#include <voodoo/play.h>
+
+static const char *m_name = NULL;
+static bool m_run = false;
+static const char *m_lookup = NULL;
+
+/**********************************************************************************************************************/
+
+static DFBBoolean parse_command_line( int argc, char *argv[] );
+
+/**********************************************************************************************************************/
+
+static DirectEnumerationResult
+player_callback( void *ctx,
+ const VoodooPlayInfo *info,
+ const VoodooPlayVersion *version,
+ const char *address,
+ unsigned int ms_since_last_seen )
+{
+ D_INFO( "Voodoo/Play: <%4ums> [ %-30s ] %s%s (vendor: %s, model: %s)\n",
+ ms_since_last_seen, info->name, address, (info->flags & VPIF_LEVEL2) ? " *" : "",
+ info->vendor, info->model );
+
+ return DENUM_OK;
+}
+
+int
+main( int argc, char *argv[] )
+{
+ DFBResult ret;
+ int i;
+ VoodooPlayInfo info;
+ VoodooPlayer *player = NULL;
+
+ /* 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;
+
+ if (m_name) {
+ direct_snputs( info.name, m_name, VOODOO_PLAYER_NAME_LENGTH );
+ }
+
+ ret = voodoo_player_create( m_name ? &info : NULL, &player );
+ if (ret) {
+ D_ERROR( "Voodoo/Play: Could not create the player (%s)!\n", DirectFBErrorString(ret) );
+ goto out;
+ }
+
+
+ do {
+ voodoo_player_broadcast( player );
+
+ usleep( 100000 );
+
+ voodoo_player_enumerate( player, player_callback, NULL );
+
+ if (m_lookup) {
+ for (i=1; i<argc; i++) {
+ char buf[100];
+
+ if (voodoo_player_lookup( player, argv[i], NULL, buf, sizeof(buf) )) {
+ D_ERROR( "Voodoo/Play: No '%s' found!\n", argv[i] );
+ continue;
+ }
+
+ D_INFO( "Voodoo/Play: Found '%s' with address %s\n", argv[i], buf );
+ }
+ }
+
+ sleep( 2 );
+ } while (m_run);
+
+
+out:
+ if (player)
+ voodoo_player_destroy( player );
+
+ return ret;
+}
+
+/**********************************************************************************************************************/
+
+static DFBBoolean
+print_usage( const char *name )
+{
+ fprintf( stderr, "Usage: %s [-n <name>] [-r]\n", name );
+
+ return DFB_FALSE;
+}
+
+static DFBBoolean
+parse_command_line( int argc, char *argv[] )
+{
+ int i;
+
+ for (i=1; i<argc; i++) {
+ if (!strcmp( argv[i], "-r" )) {
+ m_run = true;
+ }
+ else if (!strcmp( argv[i], "-n" )) {
+ if (++i == argc)
+ return print_usage( argv[0] );
+
+ m_name = argv[i];
+ }
+ }
+
+ return DFB_TRUE;
+}
+
diff --git a/Source/DirectFB/tools/voodooplay_client.c b/Source/DirectFB/tools/voodooplay_client.c
new file mode 100755
index 0000000..6a97309
--- /dev/null
+++ b/Source/DirectFB/tools/voodooplay_client.c
@@ -0,0 +1,317 @@
+/*
+ (c) Copyright 2001-2010 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 <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <directfb.h>
+
+#include <direct/debug.h>
+#include <direct/interface.h>
+#include <direct/mem.h>
+#include <direct/messages.h>
+#include <direct/util.h>
+
+#include <voodoo/play.h>
+#include <voodoo/ivoodooplayer.h>
+
+static const char *m_name;
+static bool m_launch_app;
+static u8 m_launch_app_uuid[16];
+static u8 m_launch_player_uuid[16];
+static bool m_stop_instance;
+static u8 m_stop_instance_uuid[16];
+static bool m_wait_instance;
+static u8 m_wait_instance_uuid[16];
+
+/**********************************************************************************************************************/
+
+static DFBBoolean parse_command_line( int argc, char *argv[] );
+
+/**********************************************************************************************************************/
+
+static DirectEnumerationResult
+player_callback( void *ctx,
+ const VoodooPlayInfo *info,
+ const VoodooPlayVersion *version,
+ const char *address,
+ unsigned int ms_since_last_seen )
+{
+ DirectResult ret;
+ int i;
+ char buf[33];
+ char buf2[33];
+ char buf3[33];
+
+ snprintf( buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ info->uuid[0], info->uuid[1], info->uuid[2], info->uuid[3], info->uuid[4],
+ info->uuid[5], info->uuid[6], info->uuid[7], info->uuid[8], info->uuid[9],
+ info->uuid[10], info->uuid[11], info->uuid[12], info->uuid[13], info->uuid[14],
+ info->uuid[15] );
+
+ D_INFO( "Voodoo/Play: <%4ums> [ %-30s ] { %s } %s%s\n",
+ ms_since_last_seen, info->name, buf, address, (info->flags & VPIF_LEVEL2) ? " *" : "" );
+
+ DirectFBSetOption( "remote", address );
+
+ IVoodooPlayer *player;
+
+ ret = VoodooPlayerCreate( &player );
+ if (ret) {
+ D_DERROR( ret, "Voodoo/Play/Client: VoodooPlayerCreate() failed!\n" );
+ return DENUM_OK;
+ }
+
+
+
+ VoodooAppDescription apps[100];
+ unsigned int num;
+
+ ret = player->GetApps( player, 100, &num, apps );
+ if (ret) {
+ D_DERROR( ret, "Voodoo/Play/Client: IVoodooPlayer::GetApps() failed!\n" );
+ player->Release( player );
+ return DENUM_OK;
+ }
+
+ for (i=0; i<num; i++) {
+ snprintf( buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ apps[i].uuid[0], apps[i].uuid[1], apps[i].uuid[2], apps[i].uuid[3], apps[i].uuid[4],
+ apps[i].uuid[5], apps[i].uuid[6], apps[i].uuid[7], apps[i].uuid[8], apps[i].uuid[9],
+ apps[i].uuid[10], apps[i].uuid[11], apps[i].uuid[12], apps[i].uuid[13], apps[i].uuid[14],
+ apps[i].uuid[15] );
+
+ D_INFO( " [%2d] { %s } %s\n", i, buf, apps[i].name );
+
+ if (m_launch_app && !memcmp( m_launch_app_uuid, apps[i].uuid, 16 )) {
+ u8 instance_uuid[16];
+
+ snprintf( buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ m_launch_player_uuid[0], m_launch_player_uuid[1], m_launch_player_uuid[2], m_launch_player_uuid[3], m_launch_player_uuid[4],
+ m_launch_player_uuid[5], m_launch_player_uuid[6], m_launch_player_uuid[7], m_launch_player_uuid[8], m_launch_player_uuid[9],
+ m_launch_player_uuid[10], m_launch_player_uuid[11], m_launch_player_uuid[12], m_launch_player_uuid[13], m_launch_player_uuid[14],
+ m_launch_player_uuid[15] );
+
+ D_INFO( " -> launching on %s!\n", buf );
+
+ ret = player->LaunchApp( player, m_launch_app_uuid, m_launch_player_uuid, instance_uuid );
+ if (ret)
+ D_DERROR( ret, "Voodoo/Play/Client: IVoodooPlayer::LaunchApp() failed!\n" );
+
+ snprintf( buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ instance_uuid[0], instance_uuid[1], instance_uuid[2], instance_uuid[3], instance_uuid[4],
+ instance_uuid[5], instance_uuid[6], instance_uuid[7], instance_uuid[8], instance_uuid[9],
+ instance_uuid[10], instance_uuid[11], instance_uuid[12], instance_uuid[13], instance_uuid[14],
+ instance_uuid[15] );
+
+ D_INFO( " => instance UUID is %s!\n", buf );
+ }
+ }
+
+
+
+ VoodooAppInstanceDescription instances[100];
+
+ ret = player->GetInstances( player, 100, &num, instances );
+ if (ret) {
+ D_DERROR( ret, "Voodoo/Play/Client: IVoodooPlayer::GetInstances() failed!\n" );
+ player->Release( player );
+ return DENUM_OK;
+ }
+
+ for (i=0; i<num; i++) {
+ snprintf( buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ instances[i].uuid[0], instances[i].uuid[1], instances[i].uuid[2], instances[i].uuid[3], instances[i].uuid[4],
+ instances[i].uuid[5], instances[i].uuid[6], instances[i].uuid[7], instances[i].uuid[8], instances[i].uuid[9],
+ instances[i].uuid[10], instances[i].uuid[11], instances[i].uuid[12], instances[i].uuid[13], instances[i].uuid[14],
+ instances[i].uuid[15] );
+
+ snprintf( buf2, sizeof(buf2), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ instances[i].app.uuid[0], instances[i].app.uuid[1], instances[i].app.uuid[2], instances[i].app.uuid[3], instances[i].app.uuid[4],
+ instances[i].app.uuid[5], instances[i].app.uuid[6], instances[i].app.uuid[7], instances[i].app.uuid[8], instances[i].app.uuid[9],
+ instances[i].app.uuid[10], instances[i].app.uuid[11], instances[i].app.uuid[12], instances[i].app.uuid[13], instances[i].app.uuid[14],
+ instances[i].app.uuid[15] );
+
+ snprintf( buf3, sizeof(buf3), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ instances[i].player_uuid[0], instances[i].player_uuid[1], instances[i].player_uuid[2], instances[i].player_uuid[3], instances[i].player_uuid[4],
+ instances[i].player_uuid[5], instances[i].player_uuid[6], instances[i].player_uuid[7], instances[i].player_uuid[8], instances[i].player_uuid[9],
+ instances[i].player_uuid[10], instances[i].player_uuid[11], instances[i].player_uuid[12], instances[i].player_uuid[13], instances[i].player_uuid[14],
+ instances[i].player_uuid[15] );
+
+ D_INFO( " [%2d] { instance %s } { app %s } { player %s } %s\n", i, buf, buf2, buf3, instances[i].app.name );
+
+ if (m_stop_instance && !memcmp( m_stop_instance_uuid, instances[i].uuid, 16 )) {
+ D_INFO( " -> stopping!\n" );
+
+ ret = player->StopInstance( player, m_stop_instance_uuid );
+ if (ret)
+ D_DERROR( ret, "Voodoo/Play/Client: IVoodooPlayer::StopInstance() failed!\n" );
+ }
+
+ if (m_wait_instance && !memcmp( m_wait_instance_uuid, instances[i].uuid, 16 )) {
+ D_INFO( " -> waiting!\n" );
+
+ ret = player->WaitInstance( player, m_wait_instance_uuid );
+ if (ret)
+ D_DERROR( ret, "Voodoo/Play/Client: IVoodooPlayer::WaitInstance() failed!\n" );
+ }
+ }
+
+
+ player->Release( player );
+
+ return DENUM_OK;
+}
+
+int
+main( int argc, char *argv[] )
+{
+ DFBResult ret;
+ VoodooPlayInfo info;
+ VoodooPlayer *player = NULL;
+
+ /* 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;
+
+ if (m_name) {
+ direct_snputs( info.name, m_name, VOODOO_PLAYER_NAME_LENGTH );
+ }
+
+ ret = voodoo_player_create( m_name ? &info : NULL, &player );
+ if (ret) {
+ D_ERROR( "Voodoo/Play: Could not create the player (%s)!\n", DirectFBErrorString(ret) );
+ goto out;
+ }
+
+
+ voodoo_player_broadcast( player );
+
+ sleep( 1 );
+
+ voodoo_player_enumerate( player, player_callback, NULL );
+
+
+out:
+ if (player)
+ voodoo_player_destroy( player );
+
+ return ret;
+}
+
+/**********************************************************************************************************************/
+
+static DFBBoolean
+print_usage( const char *name )
+{
+ fprintf( stderr, "Usage: %s [-n <name>] [-l app_uuid player_uuid] [-s instance_uuid] [-w instance_uuid]\n", name );
+
+ return DFB_FALSE;
+}
+
+static DFBBoolean
+parse_command_line( int argc, char *argv[] )
+{
+ int i;
+
+ for (i=1; i<argc; i++) {
+ if (!strcmp( argv[i], "-l" )) {
+ if (++i == argc)
+ return print_usage( argv[0] );
+
+ sscanf( argv[i], "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ (unsigned int*)&m_launch_app_uuid[0], (unsigned int*)&m_launch_app_uuid[1], (unsigned int*)&m_launch_app_uuid[2], (unsigned int*)&m_launch_app_uuid[3], (unsigned int*)&m_launch_app_uuid[4],
+ (unsigned int*)&m_launch_app_uuid[5], (unsigned int*)&m_launch_app_uuid[6], (unsigned int*)&m_launch_app_uuid[7], (unsigned int*)&m_launch_app_uuid[8], (unsigned int*)&m_launch_app_uuid[9],
+ (unsigned int*)&m_launch_app_uuid[10], (unsigned int*)&m_launch_app_uuid[11], (unsigned int*)&m_launch_app_uuid[12], (unsigned int*)&m_launch_app_uuid[13], (unsigned int*)&m_launch_app_uuid[14],
+ (unsigned int*)&m_launch_app_uuid[15] );
+
+
+ if (++i == argc)
+ return print_usage( argv[0] );
+
+
+ sscanf( argv[i], "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ (unsigned int*)&m_launch_player_uuid[0], (unsigned int*)&m_launch_player_uuid[1], (unsigned int*)&m_launch_player_uuid[2], (unsigned int*)&m_launch_player_uuid[3], (unsigned int*)&m_launch_player_uuid[4],
+ (unsigned int*)&m_launch_player_uuid[5], (unsigned int*)&m_launch_player_uuid[6], (unsigned int*)&m_launch_player_uuid[7], (unsigned int*)&m_launch_player_uuid[8], (unsigned int*)&m_launch_player_uuid[9],
+ (unsigned int*)&m_launch_player_uuid[10], (unsigned int*)&m_launch_player_uuid[11], (unsigned int*)&m_launch_player_uuid[12], (unsigned int*)&m_launch_player_uuid[13], (unsigned int*)&m_launch_player_uuid[14],
+ (unsigned int*)&m_launch_player_uuid[15] );
+
+
+ m_launch_app = true;
+ }
+ else if (!strcmp( argv[i], "-s" )) {
+ if (++i == argc)
+ return print_usage( argv[0] );
+
+ sscanf( argv[i], "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ (unsigned int*)&m_stop_instance_uuid[0], (unsigned int*)&m_stop_instance_uuid[1], (unsigned int*)&m_stop_instance_uuid[2], (unsigned int*)&m_stop_instance_uuid[3], (unsigned int*)&m_stop_instance_uuid[4],
+ (unsigned int*)&m_stop_instance_uuid[5], (unsigned int*)&m_stop_instance_uuid[6], (unsigned int*)&m_stop_instance_uuid[7], (unsigned int*)&m_stop_instance_uuid[8], (unsigned int*)&m_stop_instance_uuid[9],
+ (unsigned int*)&m_stop_instance_uuid[10], (unsigned int*)&m_stop_instance_uuid[11], (unsigned int*)&m_stop_instance_uuid[12], (unsigned int*)&m_stop_instance_uuid[13], (unsigned int*)&m_stop_instance_uuid[14],
+ (unsigned int*)&m_stop_instance_uuid[15] );
+
+ m_stop_instance = true;
+ }
+ else if (!strcmp( argv[i], "-w" )) {
+ if (++i == argc)
+ return print_usage( argv[0] );
+
+ sscanf( argv[i], "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ (unsigned int*)&m_wait_instance_uuid[0], (unsigned int*)&m_wait_instance_uuid[1], (unsigned int*)&m_wait_instance_uuid[2], (unsigned int*)&m_wait_instance_uuid[3], (unsigned int*)&m_wait_instance_uuid[4],
+ (unsigned int*)&m_wait_instance_uuid[5], (unsigned int*)&m_wait_instance_uuid[6], (unsigned int*)&m_wait_instance_uuid[7], (unsigned int*)&m_wait_instance_uuid[8], (unsigned int*)&m_wait_instance_uuid[9],
+ (unsigned int*)&m_wait_instance_uuid[10], (unsigned int*)&m_wait_instance_uuid[11], (unsigned int*)&m_wait_instance_uuid[12], (unsigned int*)&m_wait_instance_uuid[13], (unsigned int*)&m_wait_instance_uuid[14],
+ (unsigned int*)&m_wait_instance_uuid[15] );
+
+ m_wait_instance = true;
+ }
+ else if (!strcmp( argv[i], "-n" )) {
+ if (++i == argc)
+ return print_usage( argv[0] );
+
+ m_name = argv[i];
+ }
+ }
+
+ return DFB_TRUE;
+}
+
diff --git a/Source/DirectFB/tools/voodooplay_server.c b/Source/DirectFB/tools/voodooplay_server.c
new file mode 100755
index 0000000..76f373c
--- /dev/null
+++ b/Source/DirectFB/tools/voodooplay_server.c
@@ -0,0 +1,318 @@
+/*
+ (c) Copyright 2001-2010 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 <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <directfb.h>
+
+#include <direct/debug.h>
+#include <direct/interface.h>
+#include <direct/mem.h>
+#include <direct/messages.h>
+#include <direct/util.h>
+
+#include <voodoo/app.h>
+#include <voodoo/play.h>
+#include <voodoo/play_server.h>
+
+#define APPFILENAME "./application.lst"
+#define LINE_LENGTH (255)
+#define MAXAPPS (256)
+
+typedef struct
+{
+ char name[VOODOO_APP_DESCRIPTION_NAME_LENGTH];
+ char exe[256];
+ char arg[256];
+} AppInfo;
+
+static AppInfo appstable[MAXAPPS];
+static int nbapps = 0;
+static const char *m_name = NULL;
+static pid_t oldp=-1;
+
+/**********************************************************************************************************************/
+
+static DFBBoolean parse_command_line( int argc, char *argv[] );
+
+/**********************************************************************************************************************/
+
+/*
+ * FIXME
+ */
+static void
+generate_uuid( u8 *buf )
+{
+ int i;
+
+ for (i=0; i<16; i++) {
+ buf[i] = rand();
+ }
+}
+
+static void
+player_exec( const char *prog,
+ const char *arg,
+ const char *addr )
+{
+ char addr_arg[100];
+ char argcopy[256]; // Total argument string < 256 chars
+ char * argv[64]; // Max 64 arguments!
+ int i,j;
+ int argsize;
+
+ snprintf( addr_arg, sizeof(addr_arg), "--dfb:remote=%s", addr );
+
+ i = 0;
+ argv[i++] = (char*)prog;
+ argv[i++] = addr_arg;
+ j = 0;
+ strcpy(argcopy, arg);
+ argsize = strlen(arg);
+ while ( (arg[j]) && (i<64) && (j<argsize) )
+ {
+ argv[i++] = &argcopy[j];
+ while ( (arg[j] != 0 ) && (arg[j] != ' ') )
+ {
+ j++;
+ }
+ argcopy[j++] = 0;
+ }
+ argv[i++] = NULL;
+
+// i=0;
+// while(argv[i])
+// {
+// printf("%s\n", argv[i]);
+// i++;
+// }
+
+
+ execv( prog, argv );
+// execl( prog, prog, addr_arg, arg, NULL );
+
+ D_PERROR( "exec( %s %s ) failed!\n", prog, addr_arg );
+
+ exit( 1 );
+}
+
+static VoodooAppDescription apps[MAXAPPS];
+
+
+static DirectResult
+player_launch( VoodooPlayer *player,
+ void *ctx,
+ const VoodooAppDescription *app,
+ const VoodooPlayInfo *player_info,
+ const char *player_addr,
+ void **ret_data )
+{
+ int i;
+ D_INFO( "Received launch request for '%s' to run on '%s' (%s)!\n",
+ app->name, player_info->name, player_addr );
+
+ pid_t p = fork();
+
+ switch (p) {
+ case 0:
+ for (i=0; i<nbapps; i++)
+ {
+ if (!strcmp( app->name, appstable[i].name ))
+ {
+ if (oldp > 0)
+ {
+ kill( oldp, SIGKILL );
+ }
+ oldp = p;
+ player_exec( appstable[i].exe, appstable[i].arg, player_addr );
+ }
+ }
+
+ D_BUG( "Invalid application" );
+ exit(1);
+
+ break;
+
+ default:
+ D_INFO( "Child process has pid %d\n", p );
+ *ret_data = (void*) p;
+ break;
+ }
+
+ return DR_OK;
+}
+
+static DirectResult
+player_stop( VoodooPlayer *player,
+ void *ctx,
+ void *data )
+{
+ pid_t p = (pid_t) data;
+
+ D_INFO( "Received stop request for pid %d\n", p );
+
+ kill( p, SIGTERM );
+
+ sleep( 1 );
+
+ kill( p, SIGKILL );
+
+ return DR_OK;
+}
+
+static void FindString( char **param, int size, char *result )
+{
+ char *Cptr = NULL;
+
+ Cptr = *param;
+ while( *Cptr == ' ' )
+ {
+ Cptr++;
+ }
+ while( ( *Cptr != ';' ) && ( *Cptr != ':' ) && ( *Cptr != '\0' ) && ( *Cptr != '\n' ) && ( *Cptr != '\r' ) && (size>0) )
+ {
+ *result = *Cptr;
+ result++;
+ Cptr++;
+ size--;
+ }
+ *result = '\0';
+ Cptr++;
+ *param = Cptr;
+}
+
+
+int
+main( int argc, char *argv[] )
+{
+ DFBResult ret;
+ VoodooPlayInfo info = {0};
+ VoodooPlayer *player = NULL;
+ FILE* fd = NULL;
+ char Line[ LINE_LENGTH ];
+ char *Cptr;
+
+ srand( direct_clock_get_abs_micros() );
+
+ /* 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;
+
+ if (m_name) {
+ direct_snputs( info.name, m_name, VOODOO_PLAYER_NAME_LENGTH );
+ }
+
+ ret = voodoo_player_create( m_name ? &info : NULL, &player );
+ if (ret) {
+ D_ERROR( "Voodoo/Play: Could not create the player (%s)!\n", DirectFBErrorString(ret) );
+ goto out;
+ }
+
+ voodoo_player_broadcast( player );
+
+ sleep( 2 );
+
+
+
+ if ( (fd = fopen( APPFILENAME, "r" )) )
+ {
+ nbapps = 0;
+ while( (fgets( Line, LINE_LENGTH - 1, fd ) != NULL) && (nbapps < MAXAPPS) )
+ {
+ Cptr = Line;
+ if( *Cptr != '#' ) // skip comment lines
+ {
+ FindString( &Cptr, VOODOO_APP_DESCRIPTION_NAME_LENGTH, appstable[nbapps].name );
+ if ( !strlen(appstable[nbapps].name) ) continue;
+ FindString( &Cptr, 256, appstable[nbapps].exe );
+ if ( !strlen(appstable[nbapps].exe) ) continue;
+ FindString( &Cptr, 256, appstable[nbapps].arg );
+ printf("%s %s %s\n", appstable[nbapps].name, appstable[nbapps].exe, appstable[nbapps].arg);
+ generate_uuid( apps[nbapps].uuid );
+ apps[nbapps].flags = VADESC_NAME;
+ direct_snputs( apps[nbapps].name, appstable[nbapps].name, VOODOO_APP_DESCRIPTION_NAME_LENGTH );
+ nbapps++;
+ }
+ }
+
+ fclose( fd );
+ }
+
+ voodoo_player_run_server( player, apps, nbapps, player_launch, player_stop, NULL );
+
+out:
+ if (player)
+ voodoo_player_destroy( player );
+
+ return ret;
+}
+
+/**********************************************************************************************************************/
+
+static DFBBoolean
+print_usage( const char *name )
+{
+ fprintf( stderr, "Usage: %s [-n <name>] [-r]\n", name );
+
+ return DFB_FALSE;
+}
+
+static DFBBoolean
+parse_command_line( int argc, char *argv[] )
+{
+ int i;
+
+ for (i=1; i<argc; i++) {
+ if (!strcmp( argv[i], "-n" )) {
+ if (++i == argc)
+ return print_usage( argv[0] );
+
+ m_name = argv[i];
+ }
+ }
+
+ return DFB_TRUE;
+}
+