Mobile/DFBPorting: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(→‎libIDL: correct path for libIDL-0.8.5.tar.bz2. Linkrot is bad...)
Line 310: Line 310:


* '''Package Name: ''' libIDL-0.8.5.tar.bz2
* '''Package Name: ''' libIDL-0.8.5.tar.bz2
* '''Download URL: ''' http://ftp.gnome.org/pub/GNOM/sources/libIDL/0.8/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: '''
* '''Installation: '''
** tar jxvf libIDL-0.8.5.tar.bz2
** tar jxvf libIDL-0.8.5.tar.bz2

Revision as of 18:57, 23 May 2008

Porting Goals

  • Firefox running with full functionality (including SVG) on DirectFB 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);
  • 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.

Miscellaneous

There are other places (widget and toolkit) in Mozilla where X11 calls are used. Currently all these X11 calls are being ported to GDK.

We are planning to use earlier work done on Mozilla-DFB by Tata Elxsi for the miscellaneous porting.

DirectFB Build and Test Environment setup

Prepare installation directory

We are going to install under /usr/local/dfb to avoid confusion when X and DFB apps are run 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

GTK-DFB package installation

jpeg

  • Package Name: jpegsrc.v6b.tar.gz
  • Download URL: ftp://ftp.gtk.org/pub/gtk/v2.10/dependencies/
  • 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

libpng

  • Package Name: libpng-1.2.22.tar.bz2
  • Download URL: http://www.libpng.org/pub/png/libpng.html
  • Installation:
    • tar jxvf libpnag-1.2.22.tar.bz2
    • cd libpng-1.2.22
    • cp ./scripts/makefile.linux ./Makefile
    • Change “prefix=/usr/local” to “prefix=/usr/local/dfb” (line no 31) in Makefile manually
    • make
    • make install

pkg-config

  • Package Name: pkg-config-0.22.tar.gz
  • Download URL: http://pkgconfig.freedesktop.org/wiki/
  • 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/
  • Installation:
    • tar zxvf gettext-0.17.tar.gz
    • cd gettext-0.17
    • ./configure --prefix=/usr/local/dfb
    • make
    • make install

glib

  • Package Name: glib-2.12.9.tar.gz
  • Download URL: ftp://ftp.gtk.org/pub/glib/2.12/
  • Installation:
    • tar zxvf glib-2.12.9.tar.gz
    • cd glib-2.12.9
    • ./configure --prefix=/usr/local/dfb
    • make
    • make install

atk


DirectFB

  • Package Name: DirectFB-1.0.1.tar.gz
  • Download URL: http://www.directfb.org/index.php?path=Main%2FDownloads
  • Installation:
    • apt-get install libsdl1.2-dev
    • tar zxvf DirectFB-1.0.1.tar.gz
    • cd DirectFB-1.0.1
    • ./configure --prefix=/usr/local/dfb --enable-x11=no --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

freetype

  • Package Name: freetype-2.3.5.tar.gz
  • Download URL: http://www.freetype.org/download.html#stable
  • Installation:
    • tar zxvf freetype-2.3.5.tar.gz
    • cd freetype-2.3.5
    • ./configure --prefix=/usr/local/dfb --without-x --enable-directfb --disable-xlib --disable-win32
    • make
    • make install

fontconfig

  • Package Name: fontconfig-2.4.91.tar.gz
  • Download URL: http://fontconfig.org/release/
  • Installation:
    • tar 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.9.6.tar.gz
  • Download URL: http://cairographics.org/snapshots/
  • Installation:
    • tar -zxvf pixman-0.9.6.tar.gz
    • cd pixman-0.9.6
    • ./configure --prefix=/usr/local/dfb
    • make
    • make install


cairo

  • Package Name: cairo-1.5.10.tar.gz
  • Download URL: http://cairographics.org/snapshots/
  • Installation:
    • tar -zxvf cairo-1.5.10.tar.gz
    • cd cairo-1.5.10
    • ./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.16.4.tar.gz
  • Download URL: ftp://ftp.gtk.org/pub/pango/1.16/
  • Installation:
    • tar zxvf pango-1.16.4.tar.gz
    • cd pango-1.16.4
    • ./configure --prefix=/usr/local/dfb --enable-cairo --without-x --disable-xlib --disable-win32
    • make
    • make install

gtk

  • Package Name: gtk+-2.10.1.tar.bz2
  • Download URL: ftp://ftp.gtk.org/pub/gtk/v2.10/
  • Installation:
    • tar jxvf gtk+-2.10.1.tar.bz2
    • gtk+-2.10.1
    • ./configure --prefix=/usr/local/dfb --with-gdktarget=directfb --without-x
    • make
    • make install

libIDL

libexpat

  • Package Name: expat-2.0.1.tar.gz
  • Download URL: http://expat.sourceforge.net/
  • Installation:
    • tar zxvf expat-2.0.1.tar.gz
    • cd expat-2.0.1
    • ./configure --prefix=/usr/local/dfb
    • make
    • make install

Building and testing GTK-DirectFB applications

  • 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: hell_world.c and compile it
    • gcc `pkg-config --cflags –libs hello_world.c –o hello_world
  • Run hello_world
    • A DirectFB window with hello_world widget inside should pop-up

Building and testing firefox-DirectFB

  • .mozconfig for DirectFB build
    • . $topsrcdir/browser/config/mozconfig
    • mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-dfb
    • #disable main static library build - libxul=20MB
    • ac_add_options --disable-libxul
    • ac_add_options --disable-plugins
    • ac_add_options --enable-debug
    • ac_add_options --enable-optimize
    • ac_add_options --enable-static
    • ac_add_options --disable-shared
    • ac_add_options --disable-tests
    • #ac_add_options --enable-tests
    • ac_add_options --disable-crashreporter
    • ac_add_options --disable-installer
    • ac_add_options --disable-javaxpcom
    • #ac_add_options --enable-codesighs
    • #ac_add_options --enable-jprof
    • ac_add_options --enable-system-cairo
    • # Taken from Tata-Elxsi porting
    • ac_add_options --without-x
    • ac_add_options --enable-directfb
    • ac_add_options --disable-pedantic
    • ac_add_options --disable-gtktest
    • ac_add_options --enable-pango
    • ac_add_options --disable-xft
    • ac_add_options --enable-extensions=default,spatialnavigation
    • ac_add_options --disable-xinerama
    • ac_add_options --without-system-nspr
    • ac_add_options --disable-mailnews
    • ac_add_options --disable-composer
    • ac_add_options --disable-ldap
    • ac_add_options --disable-xprint
    • ac_add_options --disable-dbus
  • Setup pkg-config and library paths
    • export LD_LIBRARY_PATH=/usr/local/dfb/lib
    • export PKG_CONFIG_PATH=/usr/local/dfb/lib/pkgconfig
  • Follow the usual steps for building and running firefox

Bugs