Commit f9492183 authored by Michael David Emmel's avatar Michael David Emmel
Browse files

Added new directfb backend

parent 9bfabba0
......@@ -224,13 +224,13 @@ else
gdktarget=x11
fi
AC_ARG_WITH(gdktarget, [ --with-gdktarget=[[x11/linux-fb/win32/quartz]] select non-default GDK target],
AC_ARG_WITH(gdktarget, [ --with-gdktarget=[[x11/linux-fb/win32/quartz/directfb]] select non-default GDK target],
gdktarget=$with_gdktarget)
AC_SUBST(gdktarget)
case $gdktarget in
x11|linux-fb|win32|quartz) ;;
*) AC_MSG_ERROR([Invalid target for GDK: use x11, linux-fb, quartz or win32.]);;
x11|linux-fb|win32|quartz|directfb) ;;
*) AC_MSG_ERROR([Invalid target for GDK: use x11, linux-fb, quartz, directfb or win32.]);;
esac
gdktargetlib=libgdk-$gdktarget-$GTK_API_VERSION.la
......@@ -1369,6 +1369,27 @@ else
AM_CONDITIONAL(ENABLE_FB_MANAGER, false)
fi
if test "x$gdktarget" = "xdirectfb"; then
DIRECTFB_REQUIRED_VERSION=0.9.21
AC_MSG_CHECKING(for DirectFB)
if $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb ; then
AC_MSG_RESULT(found)
GDK_EXTRA_CFLAGS="`$PKG_CONFIG --cflags directfb` $GDK_EXTRA_CFLAGS"
GDK_EXTRA_LIBS="`$PKG_CONFIG --libs directfb` $GDK_EXTRA_LIBS"
else
AC_MSG_ERROR([
*** DirectFB $DIRECTFB_REQUIRED_VERSION or newer is required. The latest
*** version of DirectFB is always available from http://www.directfb.org/.
])
fi
AM_CONDITIONAL(USE_DIRECTFB, true)
else
AM_CONDITIONAL(USE_DIRECTFB, false)
fi
# Check for Pango flags
if test "x$gdktarget" = "xwin32"; then
......@@ -1589,6 +1610,9 @@ elif test "x$gdktarget" = "xlinux-fb" ; then
elif test "x$gdktarget" = "xquartz" ; then
gdk_windowing='
#define GDK_WINDOWING_QUARTZ'
elif test "x$gdktarget" = "xdirectfb" ; then
gdk_windowing='
#define GDK_WINDOWING_DIRECTFB'
fi
if test x$gdk_wchar_h = xyes; then
......@@ -1646,6 +1670,7 @@ gdk/win32/rc/Makefile
gdk/win32/rc/gdk.rc
gdk/linux-fb/Makefile
gdk/quartz/Makefile
gdk/directfb/Makefile
gtk/Makefile
gtk/makefile.msc
gtk/gtkversion.h
......
## Makefile.am for gtk+/gdk
SUBDIRS = $(gdktarget)
DIST_SUBDIRS = linux-fb win32 x11 quartz
DIST_SUBDIRS = linux-fb win32 x11 quartz directfb
EXTRA_DIST = \
keynames.txt \
......@@ -133,6 +133,11 @@ common_sources = \
gdkenumtypes.c \
gdkmarshalers.h
libgdk_directfb_2_0_la_SOURCES = $(common_sources)
libgdk_directfb_2_0_la_LIBADD = directfb/libgdk-directfb.la $(GDK_DEP_LIBS) \
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la
libgdk_directfb_2_0_la_LDFLAGS = $(LDADD)
libgdk_x11_2_0_la_SOURCES = $(common_sources)
libgdk_x11_2_0_la_LIBADD = x11/libgdk-x11.la $(GDK_DEP_LIBS) \
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la
......@@ -202,7 +207,7 @@ endif
lib_LTLIBRARIES = $(gdktargetlib)
EXTRA_LTLIBRARIES = libgdk-x11-2.0.la libgdk-linux-fb-2.0.la libgdk-win32-2.0.la libgdk-quartz-2.0.la
EXTRA_LTLIBRARIES = libgdk-x11-2.0.la libgdk-linux-fb-2.0.la libgdk-win32-2.0.la libgdk-quartz-2.0.la libgdk-directfb-2.0.la
MAINTAINERCLEANFILES = gdkenumtypes.h stamp-gdkenumtypes.h gdkenumtypes.c \
gdkmarshalers.h gdkmarshalers.c
......
The GDK DirectFB backend was written by
Denis Oliver Kropp <dok@convergence.de>
Sven Neumann <sven@convergence.de>
Large parts of the code are based on other GDK backends
especially the linuxfb backend which was written mainly
by Alex Larsson <alexl@redhat.com>.
The upgrade to gtk 2.8.x was done by
Michael Emmel <mike.emmel@gmail.com>
Extensive help and support and code was recieved from the Debian community especially the Debian installer team who bravely chose to use the gdk directfb port for the graphical debian installer.
In particular
Attilio Fiandrotti <fiandro@tiscalinet.it>
Davide Viti <zinosat@tiscali.it>
for there tireless work bringing the backend from a small project to stability.
And finally thanks to the Extremadura goverment for bringing the directfb developers and debian installer team together for a workshop.
## Makefile.am for gtk+/gdk/gdk-directfb
libgdkincludedir = $(includedir)/gtk-2.0/gdk
libgdkgdk_directfbincludedir = $(includedir)/gtk-2.0/gdk/gdk-directfb
INCLUDES = \
-DG_LOG_DOMAIN=\"Gdk-DirectFB\" \
-I$(top_srcdir) \
-I$(top_srcdir)/gdk \
-I$(top_builddir)/gdk \
-DG_DISABLE_DEPRECATED \
-DGDK_PIXBUF_DISABLE_DEPRECATED \
-DGDK_DISABLE_DEPRECATED \
@GTK_DEBUG_FLAGS@ \
@GDK_DEP_CFLAGS@
LDADDS = \
@GDK_DEP_LIBS@
noinst_LTLIBRARIES = libgdk-directfb.la
libgdk_directfb_la_SOURCES = \
gdkcolor-directfb.c \
gdkcursor-directfb.c \
gdkdnd-directfb.c \
gdkdisplay-directfb.c \
gdkdisplay-directfb.h \
gdkdrawable-directfb.c \
gdkevents-directfb.c \
gdkfont-directfb.c \
gdkgc-directfb.c \
gdkgeometry-directfb.c \
gdkglobals-directfb.c \
gdkim-directfb.c \
gdkimage-directfb.c \
gdkinput-directfb.c \
gdkinput-directfb.h \
gdkkeys-directfb.c \
gdkmain-directfb.c \
gdkpixmap-directfb.c \
gdkprivate-directfb.h \
gdkproperty-directfb.c \
gdkscreen-directfb.c \
gdkselection-directfb.c \
gdkspawn-directfb.c \
gdkvisual-directfb.c \
gdkdirectfb.h \
gdkwindow-directfb.c \
gdkwindowid.c \
x-cursors.xbm
libgdkinclude_HEADERS = \
gdkdirectfb.h \
gdkprivate-directfb.h
EXTRA_DIST = AUTHORS README TODO ChangeLog
README for GDK-DirectFB
------------------------
This is a developers snapshot of a GDK backend based on DirectFB.
It requires GTK+ version 2.0 (see http://www.gtk.org/) and DirectFB
(see http://www.directfb.org/).
Important:
The current code does not pass through directfb passed on the gtk
apps command line on to directfb you need to set the environment variable
DFBARGS.
Example:
export DFBARGS=system=sdl
DirectFB is a hardware abstraction layer on top of the Linux
frame buffer that provides drawing functions, a window stack and
support for input devices. The code you find here is a backend for
GDK, the drawing kit used by GTK+.
To give it a try, you first need DirectFB (at least version 0.9.17)
available from http://www.directfb.org/. Then you need to get your
hands on a recent version of GTK+-2.0. The latest release (gtk+-2.8.10)
should work.
Here are urls for the current for all the source needed to build the current latest gtk release
ftp://ftp.gtk.org/pub/gtk/v2.8/atk-1.10.3.tar.gz
ftp://ftp.gtk.org/pub/gtk/v2.8/glib-2.8.5.tar.gz
ftp://ftp.gtk.org/pub/gtk/v2.8/pango-1.10.2.tar.gz
ftp://ftp.gtk.org/pub/gtk/v2.8/gtk+-2.8.10.tar.gz
If you don't have tiff i.e stock debian is a the url.
ftp://ftp.remotesensing.org/pub/libtiff/tiff-3.8.0.tar.gz
The default build will fail without it.
You also need the latest version of cairo from CVS it contains
support for a DirectFB backend and should be avialable in the next
cairo release.
cvs -d :pserver:anoncvs@cvs.freedesktop.org:/cvs/cairo co cairo
Alternatively checkout GTK+ from CVS. Place this
directory into the gdk subdirectory of your GTK+ tree and rename it
to directfb. Then change to the toplevel GTK+ directory and apply
gtk-directfb.patch there is now a mkpatch shell script which should
correctly automate creating the directfb target via:
./mkpatch apply
cd ../../; make && make install
If this fails the older instructions are still available. Note that several
file must be regenerated with the auto tools.
patch -p0 < gdk/directfb/gtk-directfb.patch
Regenerate the configure script and the Makefiles by calling automake
and autoconf. Then rebuild GTK+ using the '--with-gdktarget=directfb'
configure option.
Alternatively you can download a version of GTK+ that includes the
DirectFB GDK backend and has the patches already applied, see
http://www.directfb.org/download/GTK+-DirectFB/
As DirectFB provides drawing functions, a windowing stack and manages
input devices, this is a lightweight GDK port. Some parts of GDK
require higher level drawing functions that are supported by
cairo on DirectFB.
GDK also uses some feature like bitmaps that do not map well to
modern graphics hardware and are for that reason not yet supported in
this snapshot. See the file TODO for a list of missing features.
If you want GTK+ to draw window decorations for you, edit the file
gtk/gtkwindow-decorate.c and uncomment the line that says
#define DECORATE_WINDOWS.
GTK+ application compiled with this version of GTK+ understand some
additional command-line options special to the DirectFB GDK backend:
--transparent-unfocused Makes unfocused windows translucent.
--argb-font Use ARGB surfaces for fonts, needed for some
broken hardware.
--glyph-surface-cache Lets you tune the size of the glyph cache,
the default is to cache glyphs from 8 faces.
--enable-color-keying This option turns on a hack that does the
following:
(1) It overrides the color used to draw the window background to
gdk_directfb_bg_color as defined in gdkprivate-directfb.h.
Note that the alpha value only takes effect if the window has
an alpha channel.
(2) It also draws all rectangles that are drawn in
gdk_directfb_bg_color_key in this color (gdk_directfb_bg_color).
This feature can be used to create windows with translucent background.
Additionally all DirectFB command-line options as described in the
directfbrc man-page are supported.
This version of GTK+ also introduces two new functions that are special
to the DirectFB version. You need to include gdk/gdkdirectfb.h to be
able to use them.
gdk_directfb_window_set_opacity (GdkWindow *window, guchar opacity));
This function sets the overall opacity for toplevel GDK windows.
gdk_directfb_visual_by_format (DFBSurfacePixelFormat pixel_format);
This function returns a GdkVisual for a DirectFB pixelformat and
thus gives you control over the window surface. If for example
you want to create a window with alpha channel you can use some
code like the following:
visual = gdk_directfb_visual_by_format (DSPF_ARGB);
cmap = gdk_colormap_new (visual, FALSE);
gtk_widget_push_colormap (cmap);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_pop_colormap ();
g_object_unref (cmap);
Don't use these functions if you want to be able to compile your
application against GTK+-X11 or other GTK+ versions.
If you are developing a GTK+ application for GTK+-DirectFB make sure
you use the gtk+-directfb-2.0.pc file when calling pkg-config to get
the correct compiler and linker flags for GTK+-DirectFB:
pkg-config --cflags gtk+-directfb-2.0
pkg-config --libs gtk+-directfb-2.0
See the file TODO for a list of unimplemented features.
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.
For more information check out http://www.directfb.org/.
A list of missing things and known bugs in the DirectFB GDK backend:
- Implement more GDK drawing functions. The most important ones
(including XOR) do work now. Other drawing functions are rarely
used and would need support from DirectFB.
- Implemenent extended input devices. Shouldn't be too hard.
- Look into DND and selections. DND seems to work inside one
application at least.
- Consider using the recently added glyph cache in PangoFT2 to
implement our glyph surface cache. Probably limit the number
of cached glyphs or the size of the surface cache instead of
keeping all glyphs from a number of fonts in the cache.
Some things that will probably never happen:
- Line styles, joining and related stuff. We could use code from the
LinuxFB backend but it seems to be bloat for most applications.
Implementing dashed lines would probably make sense and shouldn't
be too hard.
- Bitmaps (they are partly supported) and masks. This stuff should
be entirely deprecated. Use real alpha channels instead!
This is a simple list of unimplemented function stubs and there file
to see the implementation check the x11 dir.
Its not started yet.
gdkcolor-directfb.c
gdkcursor-directfb.c
gdkdisplay-directfb.c
gdkdnd-directfb.c
gdkdrawable-directfb.c
gdkevents-directfb.c
gdkfont-directfb.c
gdkgc-directfb.c
gdkgeometry-directfb.c
gdkglobals-directfb.c
gdkimage-directfb.c
gdkim-directfb.c
gdkinput-directfb.c
gdkkeys-directfb.c
gdk_keymap_lookup_key
gdk_keyval_convert_case
gdkmain-directfb.c
gdkpixmap-directfb.c
gdkproperty-directfb.c
gdkscreen-directfb.c
gdkselection-directfb.c
gdkspawn-directfb.c
gdkvisual-directfb.c
gdkwindow-directfb.c
gdkwindowid.c
glyphsurfacecache.c
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team.
*/
/*
* GTK+ DirectFB backend
* Copyright (C) 2001-2002 convergence integrated media GmbH
* Copyright (C) 2002 convergence GmbH
* Written by Denis Oliver Kropp <dok@convergence.de> and
* Sven Neumann <sven@convergence.de>
*/
#include "config.h"
#include "gdk.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gdkdirectfb.h"
#include "gdkprivate-directfb.h"
#include "gdkinternals.h"
#include "gdkcolor.h"
#include "gdkalias.h"
typedef struct {
GdkColorInfo *info;
IDirectFBPalette *palette;
} GdkColormapPrivateDirectFB;
static void gdk_colormap_init (GdkColormap *colormap);
static void gdk_colormap_class_init (GdkColormapClass *klass);
static void gdk_colormap_finalize (GObject *object);
static gint gdk_colormap_alloc_pseudocolors (GdkColormap *colormap,
GdkColor *colors,
gint ncolors,
gboolean writeable,
gboolean best_match,
gboolean *success);
static void gdk_directfb_allocate_color_key (GdkColormap *colormap);
static GObjectClass *parent_class = NULL;
GType
gdk_colormap_get_type (void)
{
static GType object_type = 0;
if (!object_type) {
static const GTypeInfo object_info =
{
sizeof (GdkColormapClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gdk_colormap_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GdkColormap),
0, /* n_preallocs */
(GInstanceInitFunc) gdk_colormap_init,
};
object_type = g_type_register_static (G_TYPE_OBJECT,
"GdkColormap",
&object_info, 0);
}
return object_type;
}
static void
gdk_colormap_init (GdkColormap *colormap)
{
colormap->size = 0;
colormap->colors = NULL;
colormap->windowing_data = NULL;
}
static void
gdk_colormap_class_init (GdkColormapClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gdk_colormap_finalize;
}
static void
gdk_colormap_finalize (GObject *object)
{
GdkColormap *colormap = GDK_COLORMAP (object);
GdkColormapPrivateDirectFB *private = colormap->windowing_data;
g_free (colormap->colors);
colormap->colors = NULL;
if (private)
{
g_free (private->info);
if (private->palette)
private->palette->Release (private->palette);
g_free (private);
colormap->windowing_data = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
GdkColormap*
gdk_colormap_new (GdkVisual *visual,
gboolean private_cmap)
{
GdkColormap *colormap;
gint i;
g_return_val_if_fail (visual != NULL, NULL);
colormap = g_object_new (gdk_colormap_get_type (), NULL);
colormap->visual = visual;
colormap->size = visual->colormap_size;
switch (visual->type)
{
case GDK_VISUAL_PSEUDO_COLOR:
{
GdkColormapPrivateDirectFB *private;
DFBPaletteDescription dsc;
colormap->colors = g_new0 (GdkColor, colormap->size);
private = g_new0 (GdkColormapPrivateDirectFB, 1);
private->info = g_new0 (GdkColorInfo, colormap->size);
if (visual == gdk_visual_get_system())
{
/* save the first (transparent) palette entry */
private->info[0].ref_count++;
}
dsc.flags = DPDESC_SIZE;
dsc.size = colormap->size;
_gdk_display->directfb->CreatePalette (
_gdk_display->directfb, &dsc, &private->palette);
colormap->windowing_data = private;
gdk_directfb_allocate_color_key (colormap);
}
break;
case GDK_VISUAL_STATIC_COLOR:
colormap->colors = g_new0 (GdkColor, colormap->size);
for (i = 0; i < colormap->size; i++)
{
GdkColor *color = colormap->colors + i;
color->pixel = i;
color->red = (i & 0xE0) << 8 | (i & 0xE0);
color->green = (i & 0x1C) << 11 | (i & 0x1C) << 3;
color->blue = (i & 0x03) << 14 | (i & 0x03) << 6;
}
break;
default:
break;
}
return colormap;
}
GdkScreen*
gdk_colormap_get_screen (GdkColormap *cmap)
{
return _gdk_screen;
}
GdkColormap*
gdk_screen_get_system_colormap (GdkScreen *screen)
{
static GdkColormap *colormap = NULL;
if (!colormap)
{
GdkVisual *visual = gdk_visual_get_system();
/* special case PSEUDO_COLOR to use the system palette */
if (visual->type == GDK_VISUAL_PSEUDO_COLOR)
{
GdkColormapPrivateDirectFB *private;
IDirectFBSurface *surface;
colormap = g_object_new (gdk_colormap_get_type (), NULL);
colormap->visual = visual;
colormap->size = visual->colormap_size;
colormap->colors = g_new0 (GdkColor, colormap->size);
private = g_new0 (GdkColormapPrivateDirectFB, 1);
private->info = g_new0 (GdkColorInfo, colormap->size);
surface=GDK_WINDOW_IMPL_DIRECTFB (
GDK_WINDOW_OBJECT (_gdk_parent_root)->impl)->drawable.surface;
surface->GetPalette (surface, &private->palette);
colormap->windowing_data = private;
/* save the first (transparent) palette entry */
private->info[0].ref_count++;
gdk_directfb_allocate_color_key (colormap);
}
else
{
colormap = gdk_colormap_new (visual, FALSE);