Mobile/DFBPorting: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(fixed typo)
Line 32: Line 32:


* Clone gfxXlibSurface for DirectFB as gfxDfbSurface
* Clone gfxXlibSurface for DirectFB as gfxDfbSurface
* Callers of gfxSlibSurface will not call gfxDfbSurface for DFB case and gfxXlibSurface for X11 case, under appropriate compiler switches.
* Callers of gfxSlibSurface will call gfxDfbSurface for DFB case and gfxXlibSurface for X11 case, under appropriate compiler switches.
* Use cairo_directfb_surface_create() to create cairo surfaces. DFB Native surface associated with the GdkDrawable will be used to create cairo surface. Following is the code:
* Use cairo_directfb_surface_create() to create cairo surfaces. DFB Native surface associated with the GdkDrawable will be used to create cairo surface. Following is the code:



Revision as of 16:20, 3 March 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 for DirectFB as gfxDfbSurface
  • Callers of gfxSlibSurface will call gfxDfbSurface for DFB case and gfxXlibSurface for X11 case, under appropriate compiler switches.
  • Use cairo_directfb_surface_create() to create cairo surfaces. DFB Native surface associated with the GdkDrawable will be used to create cairo surface. Following is the code:
   #include "gdk/gdkprivate-directfb.h"
   gfxDfbSurface::gfxDfbSurface (GdkDrawable * drawable)
   {
       /* TODO */
   }

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.h
    • All callers of gfxXlibNativeRenderer
    • widget/src/gtk2/nsNativeThemeGTK.cpp
    • layout/generic/nsObjectFrame.cpp

Proposed Porting Approach

  • All the users of gfxXlibNativeRenderer will use gfxGdkNativeRenderer now
  • gfxXlibNativeRenderer will be cloned as something like gfxGdkNativeRenderer
    • GdkDrawable will replace (Display, Visual, Drawable) touple
  • 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.