Mobile/DFBPorting
Contents
Porting Goals
- Firefox running with full functionality (including SVG) on DirectFB (web site, Wikipedia) -based platforms
- Use GDK as much as possible so that the backend (X, DFB etc) dependencies are abstracted out
- Use DirectFB calls only if absolutely necessary
- Functionality not mappable to GDK
- Any other compelling reasons related to performance
Porting Items
Native Surface Creation
Current State
cairo_xlib_* functions are used for creating surfaces on X. These cairo_xlib_* funtions are implemented in cairo and are specific to X backend.
Related files
- gfx/thebes/public/gfxXlibSurface.h
- gfx/thebes/public/gfxXlibSurface.cpp
- All callers of gfxXlibSurface
- widget/src/gtk2/nsWindow.cpp
- gfx/thebes/src/gfxPlatformGtk.cpp
- gfx/thebes/src/gfxASurface.cpp
- layout/generic/nsObjectFrame.cpp
Proposed Porting Approach
- Clone gfxXlibSurface to gfxGdkCairoSurface
- Callers of gfxXlibSurface will now call gfxGdkCairoSurface.
- gfxGdkCairoSurface implementation calls Xlib specific functions under MOZ_X11 switch and calls DirectFB specific functions under MOZ_DFB switch.
- This approach will abstract out all backend specific functions and move them to a single place
- Users of gfxXlibSurface to create cairo surface for a GdkWindow will simply call gfxGdkCairoSurface with GdkDrawable
- Users of gfxXlibSurface to create cairo surface for an offscreen buffer (pixmap) will undergo some changes:
- A gdk pixmap of required depth will be created and corresponding GdkDrawable will be passed to gfxGdkCairoSurface for creating cairo surface
- All other x11 dependent code (checking for xrender extension etc) will be removed as gfxGdkCairoSurface will take care of all required functionality .
- The actual cairo-xlib surface creation will use GdkDrawable's depth to call correct cairo_xlib functions:
- cairo_xlib_surface_create() will be called if the GdkDrawable has non-NULL visual
- else: cairo_xlib_surface_create_for_bitmap() will be called if the depth is 1
- else : cairo_xlib_surface_create_with_xrender_format() will be called
- The actual cairo-dfb surface creation will use type of GdkDrawable (Window or pixmap) to call correct cairo-dfb functions
- cairo_directfb_surface_create() will be called with the DFB Surface returned from gdk_directfb_surface_lookup (), if the GdkDrawable is a Window
- cairo_directfb_surface_create() will be called with a newly created DFB Surface. The new DFB Surface will be created using CreateSurface() with the GdkDrawable's depth mapped to DFB pixel format.
NativeRenderer
Current State
NativeRenderer's Draw function is called for drawing a GTK widget composited with cairo state. NativeRenderer calls cairo_draw_with_xlib that has lot of dependencies on cairo_xlib*. cairo_draw_with_xlib does all the fancy stuff (complex transforms) and finally calls NativeDraw with the Drawable associated with the cairo surface. cairo_xlib provides API to obtain Drawable associated with a given Cairo surface.
According to Vlad (on irc), cairo_draw_with_xlib is really there for supporting complex transforms (rotation, affine-transformations etc) that gfx natively doesn't support but depends on cairo. Effect of disabling cairo_draw_with_xlib is that the SVG and Canvas will not work; but native theming will work fine.
Related files
- gfx/thebes/public/gfxXlibNativeRenderer.h
- gfx/thebes/src/gfxXlibNativeRenderer.cpp
- All callers of gfxXlibNativeRenderer
- widget/src/gtk2/nsNativeThemeGTK.cpp
- layout/generic/nsObjectFrame.cpp
Proposed Porting Approach
- gfxXlibNativeRenderer will be cloned to gfxGdkNativeRenderer
- GdkDrawable will replace (Display, Visual, Drawable) touple
- All the users of gfxXlibNativeRenderer will use gfxGdkNativeRenderer
- Getting GdkDrawable from cairo surface
- A new static const field will be added to gfxASurface class
- static const cairo_user_data_key_t backendRenderingContext;
- During the surface creation time, gfxGdkCairoSurface.cpp will store the GdkDrawable as user data in cairo surface
- SetData (&gfxASurface::backendRenderingContext, (void *) mDrawable, nsnull);
- Draw function in gfxGdknativeRenderer.cpp will obtain the GdkDrawable by calling GetData() function
- (GdkDrawable *) ctx->OriginalSurface()->GetData(&gfxASurface::backendRenderingContext);
- A new static const field will be added to gfxASurface class
- cairo-xlib-utils.c and cairo-xlib-utils.h will be taken out from the build
- cairo_draw_with_xlib call in Draw function inside gfxGdkNativeRenderer.cpp will be replaced with the following code snippet.
double device_offset_x, device_offset_y; short offset_x = 0, offset_y = 0; cairo_surface_t * target = cairo_get_target (cr); cairo_matrix_t matrix;
cairo_surface_get_device_offset (target, &device_offset_x, &device_offset_y); cairo_get_matrix (cr, &matrix);
_convert_coord_to_short (matrix.x0 + device_offset_x, &offset_x); _convert_coord_to_short (matrix.y0 + device_offset_y, &offset_y);
cairo_surface_flush (target); NativeDraw ((GdkDrawable *) ctx->OriginalSurface()->GetData(&gfxASurface::backendRenderingContext), offset_x, offset_y, NULL, 0); cairo_surface_mark_dirty (target);
TODO
In the current proposal we are ignoring cairo_draw_with_xlib; i.e., it will be disabled in the beginning phases of the porting. After the basic functionality is working on DFB, then we will work on this. Meanwhile, any input to port cairo_draw_with_xlib to GDK will be greatly appreciated.
Previous Work
GTK-DFB Package Installation
Using script
Note: This has been tested on Fedora Core 8 and a Mandrake 9.1.
- Download and unpack Install-gtk-cross-20081106.tar.zip ( or this previous version Install_gtk_101708.zip doesn't support --html option and not optimized to cross compilation)
- Edit your install.sh or install-cross.sh to adjust parameters to your needs. You can use the --html option to check what will be executed by the script before installation.
- When you are ready, suppress the --html option in install.sh then run it, that downloads all source packages and patchs, applies cairo and gtk patches, builds and installs. If you want to change parametrers, try install_gtk.py --help for usage instructions then modify install.sh
- Copy this .directfbrc to ~/.directfbrc then edit it to ajust parameters to your needs
Note: Installation might fail if the packages are not available from the download link mentioned in config.py.
Manual Installation
We are going to install under /usr/local/dfb to avoid confusion when X and DFB apps are running simultaneously.
Create installation directories under /usr/local/dfb:
- mkdir /usr/local/dfb
- mkdir -p /usr/local/dfb/man/man1
- mkdir /usr/local/dfb/bin
- mkdir /usr/local/dfb/lib
- mkdir /usr/local/dfb/etc
- mkdir /usr/local/dfb/include
- mkdir /usr/local/dfb/info
- mkdir /usr/local/dfb/sbin
- mkdir /usr/local/dfb/share
- mkdir /usr/local/dfb/src
Set the following environment variables in the build terminal
- export LD_LIBRARY_PATH=/usr/local/dfb/lib
- export PATH=/usr/local/dfb/bin/:$PATH
- export PKG_CONFIG=/usr/local/dfb/bin/pkg-config
- export PKG_CONFIG_PATH=/usr/local/dfb/lib/pkgconfig
- export CPPFLAGS=-I/usr/local/dfb/include
- export LDFLAGS=-L/usr/local/dfb/lib
jpeg
- Package Name: jpegsrc.v6b.tar.gz
- Download URL: ftp://ftp.gtk.org/pub/gtk/v2.10/dependencies/jpegsrc.v6b.tar.gz
- Installation:
- tar xzvf jpegsrc.v6b.tar.gz
- cd jpeg-6b
- ./configure --prefix=/usr/local/dfb --without-x --enable-shared --without-libjasper
- make
- make install
tiff
- Package Name: tiff-3.7.4.tar.gz
- Download URL: ftp://ftp.gtk.org/pub/gtk/v2.10/dependencies/tiff-3.7.4.tar.gz
- Installation:
- tar zxvf tiff-3.7.4.tar.gz
- cd tiff-3.7.4
- ./configure --prefix=/usr/local/dfb --without-x
- make
- make install
zlib
- Package Name: zlib-1.2.3.tar.gz
- Download URL: http://internap.dl.sourceforge.net/sourceforge/libpng/zlib-1.2.3.tar.gz
- Installation:
- tar zxvf zlib-1.2.3.tar.gz
- cd zlib-1.2.3
- ./configure --prefix=/usr/local/dfb
- make
- make install
libpng
- Package Name: libpng-1.2.34.tar.bz2
- Download URL: http://internap.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.34.tar.bz2
- Installation:
- tar jxvf libpng-1.2.34.tar.bz2
- cd libpng-1.2.34
- make
- make install
pkg-config
- Package Name: pkg-config-0.22.tar.gz
- Download URL: http://pkgconfig.freedesktop.org/releases/pkg-config-0.22.tar.gz
- Installation:
- tar zxvf pkg-config-0.22.tar.gz
- cd pkg-config-0.22
- ./configure --prefix=/usr/local/dfb --without-x
- make
- make install
gettext
- Package Name: gettext-0.17.tar.gz
- Download URL: http://ftp.gnu.org/gnu/gettext/gettext-0.17.tar.gz
- Installation:
- tar zxvf gettext-0.17.tar.gz
- cd gettext-0.17
- ./configure --prefix=/usr/local/dfb
- make
- make install
Note: This package might not be required.
glib
- Package Name: glib-2.16.3.tar.bz2
- Download URL: http://ftp.gnome.org/pub/gnome/sources/glib/2.16/glib-2.16.3.tar.bz2
- Installation:
- tar jxvf glib-2.16.3.tar.bz2
- cd glib-2.16.3
- ./configure --prefix=/usr/local/dfb
- make
- make install
atk
- Package Name: atk-1.13.2.tar.bz2
- Download URL: http://ftp.gnome.org/pub/gnome/sources/atk/1.13/atk-1.13.2.tar.bz2
- Installation
- tar jxvf atk-1.13.2.tar.bz2
- cd atk-1.13.2
- ./configure --prefix=/usr/local/dfb
- make
- make install
freetype
- Package Name: freetype-2.3.5.tar.bz2
- Download URL: http://superb-east.dl.sourceforge.net/sourceforge/freetype/freetype-2.3.5.tar.bz2
- Installation:
- tar jxvf freetype-2.3.5.tar.bz2
- cd freetype-2.3.5
- ./configure --prefix=/usr/local/dfb --without-x --enable-directfb --disable-xlib --disable-win32
- make
- make install
DirectFB
- Package Name: DirectFB-1.2.0.tar.gz
- Download URL: http://www.directfb.org/downloads/Old/DirectFB-1.2.0.tar.gz
- Installation:
- apt-get install libsdl1.2-dev
- tar zxvf DirectFB-1.2.0.tar.gz
- cd DirectFB-1.2.0
- ./configure --prefix=/usr/local/dfb --enable-sdl
- make
- make install
After installing DirectFB, set it up to run over SDL on X11.
- Create .directfbrc under home directory.
- Add following lines to .directfbrc
- wm=default
- mode=800x600
- depth=32
- system=sdl
- As root user, run the following command
- touch /usr/local/dfb/lib/libgdk-x11-2.0.so.0
libexpat
- Package Name: expat-2.0.1.tar.gz
- Download URL: http://internap.dl.sourceforge.net/sourceforge/expat/expat-2.0.1.tar.gz
- Installation:
- tar zxvf expat-2.0.1.tar.gz
- cd expat-2.0.1
- ./configure --prefix=/usr/local/dfb
- make
- make install
fontconfig
- Package Name: fontconfig-2.4.91.tar.gz
- Download URL: http://www.fontconfig.org/release/fontconfig-2.4.91.tar.gz
- Installation:
- tar zxvf fontconfig-2.4.91.tar.gz
- cd fontconfig-2.4.91
- ./configure --prefix=/usr/local/dfb --without-x --enable-directfb --disable-xlib --disable-win32
- make
- make install
pixman
- Package Name: pixman-0.12.0.tar.gz
- Download URL: http://www.cairographics.org/releases/pixman-0.12.0.tar.gz
- Installation:
- tar zxvf pixman-0.12.0.tar.gz
- cd pixman-0.12.0
- ./configure --prefix=/usr/local/dfb
- make
- make install
cairo
- Package Name: cairo-1.6.4.tar.gz
- Download URL: http://www.cairographics.org/releases/cairo-1.6.4.tar.gz
- Patches: Download following patches and apply to the source.
- Installation:
- tar zxvf cairo-1.6.4.tar.gz
- cd cairo-1.6.4
- ./configure --prefix=/usr/local/dfb --enable-directfb=yes --enable-xlib=no --enable-xlib-xrender=no --enable-xcb=no --without-x --disable-win32
- make
- make install
pango
- Package Name: pango-1.20.2.tar.bz2
- Download URL: http://ftp.gnome.org/pub/gnome/sources/pango/1.20/pango-1.20.2.tar.bz2
- Installation:
- tar jxvf pango-1.20.2.tar.bz2
- cd pango-1.20.2
- ./configure --prefix=/usr/local/dfb --enable-cairo --without-x --disable-xlib --disable-win32
- make
- make install
gtk
- Package Name: gtk+-2.12.9.tar.bz2
- Download URL: http://ftp.gnome.org/pub/gnome/sources/gtk+/2.12/gtk+-2.12.9.tar.bz2
- Patches: Download the following patch and apply to the source.
- Installation:
- tar jxvf gtk+-2.12.9.tar.bz2
- cd gtk+-2.12.9
- ./configure --prefix=/usr/local/dfb --with-gdktarget=directfb --without-x
- make
- make install
libIDL
- Package Name: libIDL-0.8.5.tar.bz2
- Download URL: http://ftp.gnome.org/pub/gnome/sources/libIDL/0.8/libIDL-0.8.5.tar.bz2
- Installation:
- tar jxvf libIDL-0.8.5.tar.bz2
- cd libIDL-0.8.5
- apt-get install flex
- apt-get install bison
- ./configure --prefix=/usr/local/dfb
- make
- make install
Test
- Existing examples
- Try running test applications under gtk+-2.12.9/tests directory
- New Examples
- Setup pkg-config and library paths
- export LD_LIBRARY_PATH=/usr/local/dfb/lib
- export PKG_CONFIG_PATH=/usr/local/dfb/lib/pkgconfig
- Write a “Hello world” GTK application: hello_world.c and compile it
- gcc `pkg-config --cflags --libs gtk+-2.0` hello_world.c –o hello_world
- Run hello_world
- A DirectFB window with hello_world widget inside should pop-up
- Setup pkg-config and library paths
Building and testing Firefox-DFB
Getting mozilla-dfb sources from hg
- hg clone http://hg.mozilla.org/users/pavlov_mozilla.com/mozilla-dfb mozilla-dfb-src
- cd mozilla-dfb-src
- python client.py --skip-tamarin checkout
- (on Mac OS X 10.4, perhaps) python client.py --cvs ocvs --skip-tamarin checkout
Build mozilla-dfb
- Copy this .mozconfig to mozilla-dfb-src/.mozconfig
- set LD_LIBRARY_PATH and PKG_CONFIG_PATH to installed gtk-dfb packages
- make -f client.mk build in the mozilla-dfb-src directory
Issues
Bugs
A good bug search term is [dfb].
As of November 2010, all these bugs were marked fixed in 2008 or 2009.
- Port Mozilla to Gtk-DirectFB : bug 422221
- Some parts of content area not painted when scrolled : bug 435471
- Toolbar icons disappear randomly when other toolbar buttons are clicked : bug 435492
- Entire browser flickers when mouse is hovered over a toolbar menu popup : bug 435494
- Menu items are not selectable using mouse in toolbar menu popup : bug 435499
Comments
A "how to report a bug" section is needed.