[cairo-commit] 18 commits - boilerplate/cairo-boilerplate-directfb.c src/cairo-color.c src/cairo-directfb-surface.c src/cairo-mutex-impl-private.h src/cairo-mutex-type-private.h src/cairo-scaled-font.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Oct 20 15:36:05 PDT 2008


 boilerplate/cairo-boilerplate-directfb.c |   23 
 src/cairo-color.c                        |    3 
 src/cairo-directfb-surface.c             | 1819 +++++++++++++++----------------
 src/cairo-mutex-impl-private.h           |    2 
 src/cairo-mutex-type-private.h           |    4 
 src/cairo-scaled-font.c                  |   18 
 6 files changed, 965 insertions(+), 904 deletions(-)

New commits:
commit 6cb2b29434ffd5e718868d90e31cb050904b3ea7
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 23:22:16 2008 +0100

    [mutex] s/HOLDS_MUTEX/MUTEX_IS_LOCKED/
    
    Behdad prefers the latter to keep a clean namespace.

diff --git a/src/cairo-mutex-impl-private.h b/src/cairo-mutex-impl-private.h
index 492d23d..3e19616 100644
--- a/src/cairo-mutex-impl-private.h
+++ b/src/cairo-mutex-impl-private.h
@@ -181,7 +181,7 @@
 # define CAIRO_MUTEX_IMPL_LOCK(mutex) pthread_mutex_lock (&(mutex))
 # define CAIRO_MUTEX_IMPL_UNLOCK(mutex) pthread_mutex_unlock (&(mutex))
 #if HAVE_LOCKDEP
-# define CAIRO_HOLDS_MUTEX(mutex) LOCKDEP_HOLDS_LOCK (&(mutex))
+# define CAIRO_MUTEX_IS_LOCKED(mutex) LOCKDEP_HOLDS_LOCK (&(mutex))
 #endif
 # define CAIRO_MUTEX_IMPL_FINI(mutex) pthread_mutex_destroy (&(mutex))
 #if ! HAVE_LOCKDEP
diff --git a/src/cairo-mutex-type-private.h b/src/cairo-mutex-type-private.h
index 4b11a83..040e99f 100644
--- a/src/cairo-mutex-type-private.h
+++ b/src/cairo-mutex-type-private.h
@@ -168,8 +168,8 @@ typedef cairo_mutex_impl_t cairo_mutex_t;
 #define CAIRO_MUTEX_FINI		CAIRO_MUTEX_IMPL_FINI
 #define CAIRO_MUTEX_NIL_INITIALIZER	CAIRO_MUTEX_IMPL_NIL_INITIALIZER
 
-#ifndef CAIRO_HOLDS_MUTEX
-# define CAIRO_HOLDS_MUTEX(name) 1
+#ifndef CAIRO_MUTEX_IS_LOCKED
+# define CAIRO_MUTEX_IS_LOCKED(name) 1
 #endif
 
 
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index a338860..83a3927 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -418,7 +418,7 @@ _cairo_scaled_font_register_placeholder_and_unlock_font_map (cairo_scaled_font_t
     cairo_status_t status;
     cairo_scaled_font_t *placeholder_scaled_font;
 
-    assert (CAIRO_HOLDS_MUTEX (_cairo_scaled_font_map_mutex));
+    assert (CAIRO_MUTEX_IS_LOCKED (_cairo_scaled_font_map_mutex));
 
     status = scaled_font->status;
     if (status)
@@ -471,7 +471,7 @@ _cairo_scaled_font_unregister_placeholder_and_lock_font_map (cairo_scaled_font_t
 				      (cairo_hash_entry_t**) &placeholder_scaled_font);
     assert (found);
     assert (placeholder_scaled_font->placeholder);
-    assert (CAIRO_HOLDS_MUTEX (placeholder_scaled_font->mutex));
+    assert (CAIRO_MUTEX_IS_LOCKED (placeholder_scaled_font->mutex));
 
     _cairo_hash_table_remove (cairo_scaled_font_map->hash_table,
 			      &scaled_font->hash_entry);
@@ -656,7 +656,7 @@ _cairo_scaled_font_init (cairo_scaled_font_t               *scaled_font,
 void
 _cairo_scaled_font_freeze_cache (cairo_scaled_font_t *scaled_font)
 {
-    assert (CAIRO_HOLDS_MUTEX (scaled_font->mutex));
+    assert (CAIRO_MUTEX_IS_LOCKED (scaled_font->mutex));
 
     _cairo_cache_freeze (scaled_font->glyphs);
 }
@@ -664,7 +664,7 @@ _cairo_scaled_font_freeze_cache (cairo_scaled_font_t *scaled_font)
 void
 _cairo_scaled_font_thaw_cache (cairo_scaled_font_t *scaled_font)
 {
-    assert (CAIRO_HOLDS_MUTEX (scaled_font->mutex));
+    assert (CAIRO_MUTEX_IS_LOCKED (scaled_font->mutex));
 
     _cairo_cache_thaw (scaled_font->glyphs);
 }
@@ -672,7 +672,7 @@ _cairo_scaled_font_thaw_cache (cairo_scaled_font_t *scaled_font)
 void
 _cairo_scaled_font_reset_cache (cairo_scaled_font_t *scaled_font)
 {
-    assert (CAIRO_HOLDS_MUTEX (scaled_font->mutex));
+    assert (CAIRO_MUTEX_IS_LOCKED (scaled_font->mutex));
 
     _cairo_cache_destroy (scaled_font->glyphs);
     scaled_font->glyphs = _cairo_cache_create (_cairo_scaled_glyph_keys_equal,
@@ -1706,7 +1706,7 @@ _cairo_scaled_font_glyph_device_extents (cairo_scaled_font_t	 *scaled_font,
     if (scaled_font->status)
 	return scaled_font->status;
 
-    assert (CAIRO_HOLDS_MUTEX (scaled_font->mutex));
+    assert (CAIRO_MUTEX_IS_LOCKED (scaled_font->mutex));
 
     for (i = 0; i < num_glyphs; i++) {
 	cairo_scaled_glyph_t	*scaled_glyph;
@@ -1779,7 +1779,7 @@ _cairo_scaled_font_show_glyphs (cairo_scaled_font_t    *scaled_font,
     if (!num_glyphs)
 	return CAIRO_STATUS_SUCCESS;
 
-    assert (CAIRO_HOLDS_MUTEX (scaled_font->mutex));
+    assert (CAIRO_MUTEX_IS_LOCKED (scaled_font->mutex));
     if (scaled_font->backend->show_glyphs != NULL) {
 	int remaining_glyphs = num_glyphs;
 	status = scaled_font->backend->show_glyphs (scaled_font,
@@ -2094,7 +2094,7 @@ _cairo_scaled_font_glyph_path (cairo_scaled_font_t *scaled_font,
     if (status)
 	return status;
 
-    assert (CAIRO_HOLDS_MUTEX (scaled_font->mutex));
+    assert (CAIRO_MUTEX_IS_LOCKED (scaled_font->mutex));
 
     closure.path = path;
     _cairo_scaled_font_freeze_cache (scaled_font);
@@ -2306,7 +2306,7 @@ _cairo_scaled_glyph_lookup (cairo_scaled_font_t *scaled_font,
     if (scaled_font->status)
 	return scaled_font->status;
 
-    assert (CAIRO_HOLDS_MUTEX (scaled_font->mutex));
+    assert (CAIRO_MUTEX_IS_LOCKED (scaled_font->mutex));
 
     key.hash = index;
     /*
commit ae9d17c015867002895c8aa4e1c6dd1ef370dd20
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 22:31:17 2008 +0100

    [directfb] Unbounded operators are unsupported.
    
    Currently the emulation of Porter-Duff operators does not correctly
    handle the unbounded operators.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 4f905a6..662448e 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -720,6 +720,10 @@ _directfb_prepare_composite (cairo_directfb_surface_t    *dst,
     DFBSurfaceBlendFunction     dblend;
     const cairo_color_t        *color;
 
+    /* XXX Unbounded operators are not handled correctly */
+    if (! _cairo_operator_bounded_by_source (op))
+        return CAIRO_INT_STATUS_UNSUPPORTED;
+
     if (! _directfb_get_operator (op, &sblend, &dblend))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
@@ -1097,6 +1101,9 @@ _cairo_directfb_surface_fill_rectangles (void                  *abstract_surface
 		"%s( dst=%p, op=%d, color=%p, rects=%p, n_rects=%d ).\n",
 		__FUNCTION__, dst, op, color, rects, n_rects);
 
+    if (! _cairo_operator_bounded_by_source (op))
+        return CAIRO_INT_STATUS_UNSUPPORTED;
+
     if (! _directfb_get_operator (op, &sblend, &dblend))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
@@ -1714,8 +1721,11 @@ _cairo_directfb_surface_show_glyphs (void                *abstract_dst,
         return CAIRO_INT_STATUS_UNSUPPORTED;
     }
 
+    /* XXX Unbounded operators are not handled correctly */
     if (! _cairo_operator_bounded_by_mask (op))
         return CAIRO_INT_STATUS_UNSUPPORTED;
+    if (! _cairo_operator_bounded_by_source (op))
+        return CAIRO_INT_STATUS_UNSUPPORTED;
 
     if (! _directfb_get_operator (op, &sblend, &dblend) ||
 	sblend == DSBF_DESTALPHA || sblend == DSBF_INVDESTALPHA)
commit 1f35f31c4ee50dcc2f7c8616b9bbb5c45b4ed707
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 22:14:41 2008 +0100

    [directfb] Fallback for SATURATE
    
    We're unable to satisfactorily emulate SATURATE using the src/dst blend
    modes, so fallback. (Might just be a bug in libdirectfb...)

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index b211688..4f905a6 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -281,9 +281,12 @@ _directfb_get_operator (cairo_operator_t         operator,
 	dstblend = DSBF_ONE;
 	break;
     case CAIRO_OPERATOR_SATURATE:
+	/* XXX This does not work. */
+#if 0
 	srcblend = DSBF_SRCALPHASAT;
 	dstblend = DSBF_ONE;
 	break;
+#endif
     default:
 	return FALSE;
     }
commit c7951c4a368baaeeadca4e2a18d3ad45225380a0
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 22:04:58 2008 +0100

    [directfb] Perfom text fallback if emulating clip regions.
    
    Fallback if we have a clip that is not a simple region.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index ee0e5de..b211688 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -38,14 +38,13 @@
 #include "cairoint.h"
 #include "cairo-directfb.h"
 
-#include <stdlib.h>
-
 #include <directfb.h>
 #include <direct/types.h>
 #include <direct/debug.h>
 #include <direct/memcpy.h>
 #include <direct/util.h>
 
+#include "cairo-clip-private.h"
 
 /*
  * Rectangle works fine.
@@ -1704,6 +1703,17 @@ _cairo_directfb_surface_show_glyphs (void                *abstract_dst,
     if (pattern->type != CAIRO_PATTERN_TYPE_SOLID)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
+    /* Fallback if we need to emulate clip regions */
+    if (dst->base.clip &&
+        (dst->base.clip->mode != CAIRO_CLIP_MODE_REGION ||
+         dst->base.clip->surface != NULL))
+    {
+        return CAIRO_INT_STATUS_UNSUPPORTED;
+    }
+
+    if (! _cairo_operator_bounded_by_mask (op))
+        return CAIRO_INT_STATUS_UNSUPPORTED;
+
     if (! _directfb_get_operator (op, &sblend, &dblend) ||
 	sblend == DSBF_DESTALPHA || sblend == DSBF_INVDESTALPHA)
     {
commit 98933fd4b8579b68623a8212015769b058db43f5
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 20:59:14 2008 +0100

    [directfb] When blitting check if we need the un-premultiplied color.
    
    When blitting whether we need to use the premultiplied color is dependent
    upon the destination surface capabilities.

diff --git a/src/cairo-color.c b/src/cairo-color.c
index 50a9a1c..7640bf4 100644
--- a/src/cairo-color.c
+++ b/src/cairo-color.c
@@ -165,6 +165,9 @@ cairo_bool_t
 _cairo_color_equal (const cairo_color_t *color_a,
 	            const cairo_color_t *color_b)
 {
+    if (color_a == color_b)
+	return TRUE;
+
     return color_a->red_short   == color_b->red_short   &&
            color_a->green_short == color_b->green_short &&
            color_a->blue_short  == color_b->blue_short  &&
diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 6815eb9..ee0e5de 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -94,7 +94,8 @@ typedef struct _cairo_directfb_surface {
     int                  width;
     int                  height;
 
-    cairo_bool_t         local;
+    unsigned             local : 1;
+    unsigned             blit_premultiplied : 1;
 } cairo_directfb_surface_t;
 
 
@@ -306,6 +307,7 @@ _directfb_buffer_surface_create (IDirectFB             *dfb,
     DFBResult              ret;
 
     dsc.flags       = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
+    dsc.caps        = DSCAPS_PREMULTIPLIED;
     dsc.width       = width;
     dsc.height      = height;
     dsc.pixelformat = format;
@@ -491,7 +493,8 @@ _cairo_directfb_surface_create_similar (void            *abstract_src,
     surface->content = content;
     surface->width   = width;
     surface->height  = height;
-    surface->local   = true;
+    surface->local   = TRUE;
+    surface->blit_premultiplied = TRUE;
 
     return &surface->base;
 }
@@ -713,7 +716,7 @@ _directfb_prepare_composite (cairo_directfb_surface_t    *dst,
     DFBSurfaceBlittingFlags     flags;
     DFBSurfaceBlendFunction     sblend;
     DFBSurfaceBlendFunction     dblend;
-    DFBColor                    color;
+    const cairo_color_t        *color;
 
     if (! _directfb_get_operator (op, &sblend, &dblend))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
@@ -721,6 +724,7 @@ _directfb_prepare_composite (cairo_directfb_surface_t    *dst,
     if (mask_pattern) {
 	cairo_solid_pattern_t *pattern;
 
+		return CAIRO_INT_STATUS_UNSUPPORTED;
 	if (mask_pattern->type != CAIRO_PATTERN_TYPE_SOLID) {
 	    cairo_pattern_t *tmp;
 	    int              tmp_x, tmp_y;
@@ -746,13 +750,9 @@ _directfb_prepare_composite (cairo_directfb_surface_t    *dst,
 	    }
 	}
 
-	pattern = (cairo_solid_pattern_t *)mask_pattern;
-	color.a = pattern->color.alpha_short >> 8;
-	color.r = pattern->color.red_short   >> 8;
-	color.g = pattern->color.green_short >> 8;
-	color.b = pattern->color.blue_short  >> 8;
+	color = &((cairo_solid_pattern_t *) mask_pattern)->color;
     } else {
-	color.a = color.r = color.g = color.b = 0xff;
+	color = _cairo_stock_color (CAIRO_STOCK_WHITE);
     }
 
     /* XXX DirectFB currently does not support filtering, so force NEAREST
@@ -800,9 +800,9 @@ _directfb_prepare_composite (cairo_directfb_surface_t    *dst,
 
     flags = (sblend == DSBF_ONE && dblend == DSBF_ZERO)
 	? DSBLIT_NOFX : DSBLIT_BLEND_ALPHACHANNEL;
-    if (color.a != 0xff)
+    if (! CAIRO_COLOR_IS_OPAQUE (color))
 	flags |= DSBLIT_BLEND_COLORALPHA;
-    if (color.r != 0xff || color.g != 0xff || color.b != 0xff)
+    if (! _cairo_color_equal (color, _cairo_stock_color (CAIRO_STOCK_WHITE)))
 	flags |= DSBLIT_COLORIZE;
 
     dst->dfbsurface->SetBlittingFlags (dst->dfbsurface, flags);
@@ -812,9 +812,21 @@ _directfb_prepare_composite (cairo_directfb_surface_t    *dst,
 	dst->dfbsurface->SetDstBlendFunction (dst->dfbsurface, dblend);
     }
 
-    if (flags & (DSBLIT_BLEND_COLORALPHA | DSBLIT_COLORIZE))
-	dst->dfbsurface->SetColor (dst->dfbsurface, color.r, color.g, color.b, color.a);
-
+    if (flags & (DSBLIT_BLEND_COLORALPHA | DSBLIT_COLORIZE)) {
+	if (dst->blit_premultiplied) {
+	    dst->dfbsurface->SetColor (dst->dfbsurface,
+				       color->red_short >> 8,
+				       color->green_short >> 8,
+				       color->blue_short >> 8,
+				       color->alpha_short >> 8);
+	} else {
+	    dst->dfbsurface->SetColor (dst->dfbsurface,
+				       color->red * 0xff,
+				       color->green * 0xff,
+				       color->blue * 0xff,
+				       color->alpha * 0xff);
+	}
+    }
 
     *ret_src = src;
     *ret_src_attr = src_attr;
@@ -1086,7 +1098,7 @@ _cairo_directfb_surface_fill_rectangles (void                  *abstract_surface
     if (! _directfb_get_operator (op, &sblend, &dblend))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
-    if (color->alpha_short >= 0xff00) {
+    if (CAIRO_COLOR_IS_OPAQUE (color)) {
 	if (sblend == DSBF_SRCALPHA)
 	    sblend = DSBF_ONE;
 	else if (sblend == DSBF_INVSRCALPHA)
@@ -1117,9 +1129,9 @@ _cairo_directfb_surface_fill_rectangles (void                  *abstract_surface
     }
 
     dst->dfbsurface->SetColor (dst->dfbsurface,
-			       color->red_short   >> 8,
+			       color->red_short >> 8,
 			       color->green_short >> 8,
-			       color->blue_short  >> 8,
+			       color->blue_short >> 8,
 			       color->alpha_short >> 8);
 
     for (i = 0; i < n_rects; i++) {
@@ -1679,10 +1691,11 @@ _cairo_directfb_surface_show_glyphs (void                *abstract_dst,
     DFBSurfaceBlittingFlags      flags;
     DFBSurfaceBlendFunction      sblend;
     DFBSurfaceBlendFunction      dblend;
-    DFBColor                     color;
     DFBRectangle                 rects[num_glyphs];
     DFBPoint                     points[num_glyphs];
     int                          num;
+    const cairo_color_t         *color;
+
 
     D_DEBUG_AT (CairoDFB_Font,
 		"%s( dst=%p, op=%d, pattern=%p, glyphs=%p, num_glyphs=%d, scaled_font=%p ).\n",
@@ -1705,13 +1718,10 @@ _cairo_directfb_surface_show_glyphs (void                *abstract_dst,
 	return status;
     }
 
-    color.a = ((cairo_solid_pattern_t *) pattern)->color.alpha_short >> 8;
-    color.r = ((cairo_solid_pattern_t *) pattern)->color.red_short   >> 8;
-    color.g = ((cairo_solid_pattern_t *) pattern)->color.green_short >> 8;
-    color.b = ((cairo_solid_pattern_t *) pattern)->color.blue_short  >> 8;
+    color = &((cairo_solid_pattern_t *) pattern)->color;
 
     flags = DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_COLORIZE;
-    if (color.a != 0xff)
+    if (! CAIRO_COLOR_IS_OPAQUE (color))
 	flags |= DSBLIT_BLEND_COLORALPHA;
 
     if (!_directfb_argb_font) {
@@ -1725,7 +1735,19 @@ _cairo_directfb_surface_show_glyphs (void                *abstract_dst,
     dst->dfbsurface->SetBlittingFlags (dst->dfbsurface, flags);
     dst->dfbsurface->SetSrcBlendFunction (dst->dfbsurface, sblend);
     dst->dfbsurface->SetDstBlendFunction (dst->dfbsurface, dblend);
-    dst->dfbsurface->SetColor (dst->dfbsurface, color.r, color.g, color.b, color.a);
+    if (dst->blit_premultiplied) {
+	dst->dfbsurface->SetColor (dst->dfbsurface,
+				   color->red_short >> 8,
+				   color->green_short >> 8,
+				   color->blue_short >> 8,
+				   color->alpha_short >> 8);
+    } else {
+	dst->dfbsurface->SetColor (dst->dfbsurface,
+				   color->red * 0xff,
+				   color->green * 0xff,
+				   color->blue * 0xff,
+				   color->alpha * 0xff);
+    }
 
     D_DEBUG_AT (CairoDFB_Font, "Running BatchBlit().\n");
 
@@ -1856,6 +1878,7 @@ cairo_directfb_surface_create (IDirectFB *dfb, IDirectFBSurface *dfbsurface)
 {
     cairo_directfb_surface_t *surface;
     DFBSurfacePixelFormat     format;
+    DFBSurfaceCapabilities caps;
 
     D_ASSERT (dfb != NULL);
     D_ASSERT (dfbsurface != NULL);
@@ -1874,6 +1897,10 @@ cairo_directfb_surface_create (IDirectFB *dfb, IDirectFBSurface *dfbsurface)
     surface->format = _directfb_to_cairo_format (format);
     surface->content = _directfb_format_to_content (format);
 
+    dfbsurface->GetCapabilities (dfbsurface, &caps);
+    if (caps & DSCAPS_PREMULTIPLIED)
+	surface->blit_premultiplied = TRUE;
+
     _cairo_surface_init (&surface->base,
                          &_cairo_directfb_surface_backend,
 			 surface->content);
commit 4af8aa5f4d31141a6a4ba914cc860aff5d342d5b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 20:15:12 2008 +0100

    [directfb] Apply clip to release_dest_image()
    
    We need to respect the current clip when copying the fallback image back to
    the target surface.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index b810c72..6815eb9 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -336,7 +336,9 @@ _directfb_acquire_surface (cairo_directfb_surface_t  *surface,
     void *data;
     int   pitch;
 
-    if (surface->format == (cairo_format_t) -1) {
+    if (surface->format == (cairo_format_t) -1 ||
+	(lock_flags & DSLF_WRITE && surface->has_clip))
+    {
         DFBSurfaceCapabilities caps;
 
         if (intrest_rec) {
@@ -389,7 +391,6 @@ _directfb_acquire_surface (cairo_directfb_surface_t  *surface,
         buffer = surface->dfbsurface;
     }
 
-
     if (buffer->Lock (buffer, lock_flags, &data, &pitch)) {
         D_DEBUG_AT (CairoDFB_Acquire, "Couldn't lock surface!\n");
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -591,13 +592,17 @@ _cairo_directfb_surface_release_dest_image (void                  *abstract_surf
     buffer->Unlock (buffer);
 
     if (surface->dfbsurface != buffer) {
-	DFBRegion region = { .x1 = interest_rect->x, .y1 = interest_rect->y,
-	    .x2 = interest_rect->x+interest_rect->width-1,
-	    .y2 = interest_rect->y+interest_rect->height-1 };
-	surface->dfbsurface->SetClip (surface->dfbsurface, &region);
+	DFBRegion region = {
+	    .x1 = interest_rect->x,
+	    .y1 = interest_rect->y,
+	    .x2 = interest_rect->x + interest_rect->width - 1,
+	    .y2 = interest_rect->y + interest_rect->height - 1
+	};
 	surface->dfbsurface->SetBlittingFlags (surface->dfbsurface, DSBLIT_NOFX);
-	surface->dfbsurface->Blit (surface->dfbsurface, buffer,
-				   NULL, image_rect->x, image_rect->y);
+	RUN_CLIPPED (surface, &region,
+		     surface->dfbsurface->Blit (surface->dfbsurface,
+						buffer, NULL,
+						image_rect->x, image_rect->y));
     }
 
     cairo_surface_destroy (&image->base);
@@ -1142,7 +1147,7 @@ _cairo_directfb_surface_composite_trapezoids (cairo_operator_t   op,
                                               unsigned int       width,
                                               unsigned int       height,
                                               cairo_trapezoid_t *traps,
-                                              int                num_traps )
+                                              int                num_traps)
 {
     cairo_directfb_surface_t   *dst = abstract_dst;
     cairo_directfb_surface_t   *src;
commit 0ba5085ba06fd1c0ff1ebc88111d4573675a2e17
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 19:41:20 2008 +0100

    [directfb] Fix OBO in clip.
    
    DirectFB seems to use inclusive upper bounds.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 6e1b5dd..b810c72 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -1307,8 +1307,8 @@ _cairo_directfb_surface_set_clip_region (void           *abstract_surface,
 	for (i = 0; i < n_boxes; i++) {
 	    surface->clips[i].x1 = boxes[i].p1.x;
 	    surface->clips[i].y1 = boxes[i].p1.y;
-	    surface->clips[i].x2 = boxes[i].p2.x;
-	    surface->clips[i].y2 = boxes[i].p2.y;
+	    surface->clips[i].x2 = boxes[i].p2.x - 1;
+	    surface->clips[i].y2 = boxes[i].p2.y - 1;
 	}
 
 	_cairo_region_boxes_fini (region, boxes);
commit 2743e84171fd2a548ac37b1fdd3611d319acded0
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 19:32:21 2008 +0100

    [directfb] Force NEAREST.
    
    The current version of DirectFB does not support any filters, so set
    NEAREST on the source patterns so that we can fully optimize the pattern
    inside core.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 2c53646..6e1b5dd 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -750,6 +750,11 @@ _directfb_prepare_composite (cairo_directfb_surface_t    *dst,
 	color.a = color.r = color.g = color.b = 0xff;
     }
 
+    /* XXX DirectFB currently does not support filtering, so force NEAREST
+     * in order to hit optimisations inside core.
+    */
+    src_pattern->filter = CAIRO_FILTER_NEAREST;
+
     status = _cairo_pattern_acquire_surface (src_pattern, &dst->base,
 					     *src_x, *src_y, width, height,
 					     (cairo_surface_t **) &src,
commit f1669d31c0064b8ffbc7db2527fed85488fb305c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 19:03:33 2008 +0100

    [directfb] Track the empty clip rectangle.
    
    A region with no extents means everything should be clipped out, so we
    need an extra flag to disambiguate when we have 0 clip rectangles.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index cd2ce14..2c53646 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -87,6 +87,7 @@ typedef struct _cairo_directfb_surface {
     IDirectFBSurface    *dfbsurface;
     IDirectFBSurface    *tmpsurface;
 
+    cairo_bool_t         has_clip;
     DFBRegion           *clips;
     int                  n_clips;
 
@@ -119,7 +120,7 @@ static int _directfb_argb_font = 0;
 /*****************************************************************************/
 
 #define RUN_CLIPPED(surface, clip, func) {\
-    if ((surface)->clips) {\
+    if ((surface)->has_clip) {\
         int k;\
         for (k = 0; k < (surface)->n_clips; k++) {\
             if (clip) {\
@@ -1276,6 +1277,8 @@ _cairo_directfb_surface_set_clip_region (void           *abstract_surface,
 	cairo_status_t   status;
 	int              i;
 
+	surface->has_clip = TRUE;
+
 	status = _cairo_region_get_boxes (region, &n_boxes, &boxes);
 	if (n_boxes == 0)
 	    return CAIRO_STATUS_SUCCESS;
@@ -1305,6 +1308,7 @@ _cairo_directfb_surface_set_clip_region (void           *abstract_surface,
 
 	_cairo_region_boxes_fini (region, boxes);
     } else {
+	surface->has_clip = FALSE;
 	if (surface->clips) {
 	    free (surface->clips);
 	    surface->clips = NULL;
commit ebe3048f9b74ff949795a807a7076ec756150ede
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 18:59:03 2008 +0100

    [directfb] Cap the maximum surface size to use for the font cache.
    
    Fallback if we need to create a cache larger than the maximum usable
    surface.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 44e1a03..cd2ce14 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -1382,7 +1382,7 @@ _directfb_acquire_font_cache (cairo_directfb_surface_t     *surface,
                               cairo_directfb_font_cache_t **ret_cache,
                               DFBRectangle                 *rects,
                               DFBPoint                     *points,
-			      int                          *ret_num )
+			      int                          *ret_num)
 {
     cairo_status_t               status;
     cairo_scaled_glyph_t        *chars[num_glyphs];
@@ -1442,8 +1442,6 @@ _directfb_acquire_font_cache (cairo_directfb_surface_t     *surface,
 	    points[n].x+img->width  <= 0   ||
 	    points[n].y+img->height <= 0)
 	{
-	    D_DEBUG_AT (CairoDFB_Font,
-			"  -> Unsupported font format %d!\n", img->format);
 	    continue;
 	}
 
@@ -1496,6 +1494,12 @@ _directfb_acquire_font_cache (cairo_directfb_surface_t     *surface,
     w = MAX (w, 8);
     h = MAX (h, 8);
 
+    /* XXX query maximum surface size */
+    if (w > 2048 || h > 2048) {
+	_cairo_cache_thaw (scaled_font->glyphs);
+	return CAIRO_INT_STATUS_UNSUPPORTED;
+    }
+
     if (cache) {
 	if (cache->width < w || cache->height < h) {
 	    cairo_directfb_font_cache_t *new_cache;
commit 6f35c2d13e4cb736634bf446d3b8ee38cc6a6b9b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 18:39:45 2008 +0100

    [directfb] Only use the pure BLIT for integer translations.
    
    If we have non-integer translation on a source pattern then we need to use
    STRECTHBLIT (the core takes care to optimize NEAREST patterns to integer
    translations so that this will only be used when interpolation is
    required).

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 7efc863..44e1a03 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -804,6 +804,7 @@ _directfb_prepare_composite (cairo_directfb_surface_t    *dst,
     if (flags & (DSBLIT_BLEND_COLORALPHA | DSBLIT_COLORIZE))
 	dst->dfbsurface->SetColor (dst->dfbsurface, color.r, color.g, color.b, color.a);
 
+
     *ret_src = src;
     *ret_src_attr = src_attr;
 
@@ -843,7 +844,15 @@ _directfb_categorize_operation (cairo_surface_attributes_t *src_attr)
     switch (src_attr->extend) {
     case CAIRO_EXTEND_NONE:
     case CAIRO_EXTEND_REPEAT:
-	return DFXL_BLIT;
+	if (_cairo_matrix_is_integer_translation (&src_attr->matrix,
+						  NULL, NULL))
+	{
+	    return DFXL_BLIT;
+	}
+	else
+	{
+	    return DFXL_STRETCHBLIT;
+	}
 
     default:
     case CAIRO_EXTEND_REFLECT:
@@ -866,8 +875,10 @@ _cairo_directfb_surface_composite (cairo_operator_t  op,
     cairo_directfb_surface_t   *dst = abstract_dst;
     cairo_directfb_surface_t   *src;
     cairo_surface_attributes_t  src_attr;
+    cairo_bool_t                is_integer_translation;
     DFBAccelerationMask         accel, mask;
     cairo_int_status_t          status;
+    int                         tx, ty;
 
     D_DEBUG_AT (CairoDFB_Render,
 		"%s( op=%d, src_pattern=%p, mask_pattern=%p, dst=%p,"
@@ -907,8 +918,13 @@ _cairo_directfb_surface_composite (cairo_operator_t  op,
 	{
 	    DFBRectangle sr;
 
-	    sr.x = src_x + _cairo_lround (src_attr.matrix.x0);
-	    sr.y = src_y + _cairo_lround (src_attr.matrix.y0);
+	    is_integer_translation =
+		_cairo_matrix_is_integer_translation (&src_attr.matrix,
+						      &tx, &ty);
+	    assert (is_integer_translation);
+
+	    sr.x = src_x + tx;
+	    sr.y = src_y + ty;
 	    sr.w = width;
 	    sr.h = height;
 
@@ -949,10 +965,10 @@ _cairo_directfb_surface_composite (cairo_operator_t  op,
 	    TRANSFORM_POINT2X (src_attr.matrix,
 			       src_x+width, src_y+height, x2, y2);
 
-	    sr.x = _cairo_lround (x1);
-	    sr.y = _cairo_lround (y1);
-	    sr.w = _cairo_lround (x2-x1);
-	    sr.h = _cairo_lround (y2-y1);
+	    sr.x = floor (x1);
+	    sr.y = floor (y1);
+	    sr.w = ceil (x2) - sr.x;
+	    sr.h = ceil (y2) - sr.y;
 
 	    dr.x = dst_x;
 	    dr.y = dst_y;
commit 55bb7087b0236fe27980efda829f7b72e047b316
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 16:47:41 2008 +0100

    [directfb] Tweak _categorize_operation().
    
    Explicitly list the extend modes that are supported/unsupported and
    immediately check for an unsupported operation.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index ef31ad6..7efc863 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -840,13 +840,16 @@ _directfb_categorize_operation (cairo_surface_attributes_t *src_attr)
 	return DFXL_STRETCHBLIT;
     }
 
-    if (src_attr->extend != CAIRO_EXTEND_NONE &&
-	src_attr->extend != CAIRO_EXTEND_REPEAT)
-    {
+    switch (src_attr->extend) {
+    case CAIRO_EXTEND_NONE:
+    case CAIRO_EXTEND_REPEAT:
+	return DFXL_BLIT;
+
+    default:
+    case CAIRO_EXTEND_REFLECT:
+    case CAIRO_EXTEND_PAD:
 	return DFXL_NONE;
     }
-
-    return DFXL_BLIT;
 }
 
 static cairo_int_status_t
@@ -880,8 +883,14 @@ _cairo_directfb_surface_composite (cairo_operator_t  op,
 	return status;
 
     accel = _directfb_categorize_operation (&src_attr);
+    if (accel == DFXL_NONE) {
+	_directfb_finish_composite (dst, src_pattern, &src->base, &src_attr);
+	return CAIRO_INT_STATUS_UNSUPPORTED;
+    }
 
-    dst->dfbsurface->GetAccelerationMask (dst->dfbsurface, src->dfbsurface, &mask);
+    dst->dfbsurface->GetAccelerationMask (dst->dfbsurface,
+					  src->dfbsurface,
+					  &mask);
     if ((mask & accel) == 0) {
 	D_DEBUG_AT (CairoDFB_Render, "No acceleration (%08x)!\n", accel);
 	if (accel != DFXL_BLIT) {
@@ -908,7 +917,9 @@ _cairo_directfb_surface_composite (cairo_operator_t  op,
 
 		RUN_CLIPPED (dst, NULL,
 			     dst->dfbsurface->Blit (dst->dfbsurface,
-						    src->dfbsurface, &sr, dst_x, dst_y));
+						    src->dfbsurface,
+						    &sr,
+						    dst_x, dst_y));
 	    } else if (src_attr.extend == CAIRO_EXTEND_REPEAT) {
 		DFBRegion clip;
 
@@ -921,7 +932,9 @@ _cairo_directfb_surface_composite (cairo_operator_t  op,
 
 		RUN_CLIPPED (dst, &clip,
 			     dst->dfbsurface->TileBlit (dst->dfbsurface,
-							src->dfbsurface, &sr, dst_x, dst_y));
+							src->dfbsurface,
+							&sr,
+							dst_x, dst_y));
 	    }
 	    break;
 	}
@@ -965,10 +978,10 @@ _cairo_directfb_surface_composite (cairo_operator_t  op,
 	    /* guaranteed by cairo_pattern_set_matrix (); */
 	    assert (status == CAIRO_STATUS_SUCCESS);
 
-	    x1 = src_attr.x_offset;
-	    y1 = src_attr.y_offset;
-	    x2 = src->width  - x1;
-	    y2 = src->height - y1;
+	    x1 = src_x;
+	    y1 = src_y;
+	    x2 = width  + x1;
+	    y2 = height + y1;
 
 	    src->dfbsurface->GetSize (src->dfbsurface, &w, &h);
 
commit edb65213ec975e517165bc3b623f676a12917d0c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 16:46:08 2008 +0100

    [directfb] Support ROI cloning.
    
    Only clone the ROI in order to efficiently handle large sources.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 0f40f06..ef31ad6 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -635,7 +635,7 @@ _cairo_directfb_surface_clone_similar (void             *abstract_surface,
 	clone = (cairo_directfb_surface_t *)
 	    _cairo_directfb_surface_create_similar (surface,
 						    _cairo_content_from_format (image_src->format),
-						    image_src->width, image_src->height);
+						    width, height);
 	if (clone == NULL)
 	    return CAIRO_INT_STATUS_UNSUPPORTED;
 	if (clone->base.status)
@@ -649,11 +649,10 @@ _cairo_directfb_surface_clone_similar (void             *abstract_surface,
 	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	}
 
-	dst += pitch * src_y;
 	src += image_src->stride * src_y;
-
 	if (image_src->format == CAIRO_FORMAT_A1) {
 	    /* A1 -> A8 */
+	    dst -= src_x;
 	    for (i = 0; i < height; i++) {
 		for (j = src_x; j < src_x + width; j++)
 		    dst[j] = (src[j>>3] & (1 << (j&7))) ? 0xff : 0x00;
@@ -664,11 +663,9 @@ _cairo_directfb_surface_clone_similar (void             *abstract_surface,
 	    int len;
 
 	    if (image_src->format == CAIRO_FORMAT_A8) {
-		dst += src_x;
 		src += src_x;
 		len  = width;
 	    } else {
-		dst += src_x * 4;
 		src += src_x * 4;
 		len  = width * 4;
 	    }
@@ -682,8 +679,8 @@ _cairo_directfb_surface_clone_similar (void             *abstract_surface,
 
 	clone->dfbsurface->Unlock (clone->dfbsurface);
 
-	*clone_offset_x = 0;
-	*clone_offset_y = 0;
+	*clone_offset_x = src_x;
+	*clone_offset_y = src_y;
 	*clone_out = &clone->base;
 	return CAIRO_STATUS_SUCCESS;
     }
commit 4006e49ac1e96a983346f97be97bfd850f247ab0
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 16:45:06 2008 +0100

    [directfb] Rename backend structure.
    
    Use _cairo_directfb_surface_backend for consistency with other backends.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 478d204..0f40f06 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -110,7 +110,7 @@ typedef struct _cairo_directfb_font_cache {
     int                  y;
 } cairo_directfb_font_cache_t;
 
-static cairo_surface_backend_t cairo_directfb_surface_backend;
+static cairo_surface_backend_t _cairo_directfb_surface_backend;
 
 /*****************************************************************************/
 
@@ -482,7 +482,9 @@ _cairo_directfb_surface_create_similar (void            *abstract_src,
 	}
     }
 
-    _cairo_surface_init (&surface->base, &cairo_directfb_surface_backend, content);
+    _cairo_surface_init (&surface->base,
+			 &_cairo_directfb_surface_backend,
+			 content);
     surface->format  = format;
     surface->content = content;
     surface->width   = width;
@@ -757,6 +759,13 @@ _directfb_prepare_composite (cairo_directfb_surface_t    *dst,
     if (status)
 	return status;
 
+    if (src->base.backend != &_cairo_directfb_surface_backend ||
+	src->dfb != dst->dfb)
+    {
+	_cairo_pattern_release_surface (src_pattern, &src->base, &src_attr);
+	return CAIRO_INT_STATUS_UNSUPPORTED;
+    }
+
     if (src->content == CAIRO_CONTENT_COLOR) {
 	if (sblend == DSBF_SRCALPHA)
 	    sblend = DSBF_ONE;
@@ -1493,7 +1502,7 @@ _directfb_acquire_font_cache (cairo_directfb_surface_t     *surface,
 	    return status;
 	}
 
-	scaled_font->surface_backend = &cairo_directfb_surface_backend;
+	scaled_font->surface_backend = &_cairo_directfb_surface_backend;
 	scaled_font->surface_private = cache;
     }
 
@@ -1694,7 +1703,8 @@ _cairo_directfb_surface_is_similar (void *surface_a, void *surface_b, cairo_cont
     return a->dfb == b->dfb;
 }
 
-static cairo_surface_backend_t cairo_directfb_surface_backend = {
+static cairo_surface_backend_t
+_cairo_directfb_surface_backend = {
          CAIRO_SURFACE_TYPE_DIRECTFB, /*type*/
         _cairo_directfb_surface_create_similar,/*create_similar*/
         _cairo_directfb_surface_finish, /*finish*/
@@ -1759,18 +1769,18 @@ cairo_directfb_surface_backend_init (IDirectFB *dfb)
 
     if (getenv ("CAIRO_DIRECTFB_NO_ACCEL")) {
 #if DFB_RECTANGLES
-	cairo_directfb_surface_backend.fill_rectangles = NULL;
+	_cairo_directfb_surface_backend.fill_rectangles = NULL;
 #endif
 #if DFB_COMPOSITE
-	cairo_directfb_surface_backend.composite = NULL;
+	_cairo_directfb_surface_backend.composite = NULL;
 #endif
 #if DFB_COMPOSITE_TRAPEZOIDS
-	cairo_directfb_surface_backend.composite_trapezoids = NULL;
+	_cairo_directfb_surface_backend.composite_trapezoids = NULL;
 #endif
 #if DFB_SHOW_GLYPHS
-	cairo_directfb_surface_backend.scaled_font_fini = NULL;
-	cairo_directfb_surface_backend.scaled_glyph_fini = NULL;
-	cairo_directfb_surface_backend.show_glyphs = NULL;
+	_cairo_directfb_surface_backend.scaled_font_fini = NULL;
+	_cairo_directfb_surface_backend.scaled_glyph_fini = NULL;
+	_cairo_directfb_surface_backend.show_glyphs = NULL;
 #endif
 	D_DEBUG_AT (CairoDFB_Surface, "Acceleration disabled.\n");
     } else {
@@ -1780,12 +1790,12 @@ cairo_directfb_surface_backend_init (IDirectFB *dfb)
 
 #if DFB_COMPOSITE
 	//        if (!(dsc.acceleration_mask & DFXL_BLIT))
-	//            cairo_directfb_surface_backend.composite = NULL;
+	//            _cairo_directfb_surface_backend.composite = NULL;
 #endif
 
 #if DFB_COMPOSITE_TRAPEZOIDS
 	//        if (!(dsc.acceleration_mask & DFXL_TEXTRIANGLES))
-	//            cairo_directfb_surface_backend.composite_trapezoids = NULL;
+	//            _cairo_directfb_surface_backend.composite_trapezoids = NULL;
 #endif
     }
 
@@ -1821,7 +1831,8 @@ cairo_directfb_surface_create (IDirectFB *dfb, IDirectFBSurface *dfbsurface)
     surface->content = _directfb_format_to_content (format);
 
     _cairo_surface_init (&surface->base,
-                         &cairo_directfb_surface_backend, surface->content);
+                         &_cairo_directfb_surface_backend,
+			 surface->content);
 
     return &surface->base;
 }
commit 7e31ddbb08a6a7cf1db06c950c3768e54a5f4cfa
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 13:04:20 2008 +0100

    [directfb] Whitespace.
    
    Trim lots of trailing whitespace and fix up according to CODING_STYLE.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 887e72e..478d204 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -34,7 +34,6 @@
  *    Michael Emmel <mike.emmel at gmail.com>
  *    Claudio Ciccani <klan at users.sf.net>
  */
- 
 
 #include "cairoint.h"
 #include "cairo-directfb.h"
@@ -58,7 +57,7 @@
 /*
  * Composite works fine.
  */
-#define DFB_COMPOSITE 1 
+#define DFB_COMPOSITE 1
 
 /*
  * CompositeTrapezoids works (without antialiasing).
@@ -71,15 +70,14 @@
 #define DFB_SHOW_GLYPHS 1
 
 
-D_DEBUG_DOMAIN( CairoDFB_Acquire, "CairoDFB/Acquire", "Cairo DirectFB Acquire" );
-D_DEBUG_DOMAIN( CairoDFB_Clip,    "CairoDFB/Clip",    "Cairo DirectFB Clipping" );
-D_DEBUG_DOMAIN( CairoDFB_Font,    "CairoDFB/Font",    "Cairo DirectFB Font Rendering" );
-D_DEBUG_DOMAIN( CairoDFB_Render,  "CairoDFB/Render",  "Cairo DirectFB Rendering" );
-D_DEBUG_DOMAIN( CairoDFB_Surface, "CairoDFB/Surface", "Cairo DirectFB Surface" );
+D_DEBUG_DOMAIN (CairoDFB_Acquire, "CairoDFB/Acquire", "Cairo DirectFB Acquire");
+D_DEBUG_DOMAIN (CairoDFB_Clip,    "CairoDFB/Clip",    "Cairo DirectFB Clipping");
+D_DEBUG_DOMAIN (CairoDFB_Font,    "CairoDFB/Font",    "Cairo DirectFB Font Rendering");
+D_DEBUG_DOMAIN (CairoDFB_Render,  "CairoDFB/Render",  "Cairo DirectFB Rendering");
+D_DEBUG_DOMAIN (CairoDFB_Surface, "CairoDFB/Surface", "Cairo DirectFB Surface");
 
 /*****************************************************************************/
 
-
 typedef struct _cairo_directfb_surface {
     cairo_surface_t      base;
     cairo_format_t       format;
@@ -106,12 +104,11 @@ typedef struct _cairo_directfb_font_cache {
     int                  width;
     int                  height;
 
-    /* coordinates within the surface 
+    /* coordinates within the surface
      * of the last loaded glyph */
     int                  x;
     int                  y;
 } cairo_directfb_font_cache_t;
-    
 
 static cairo_surface_backend_t cairo_directfb_surface_backend;
 
@@ -121,8 +118,7 @@ static int _directfb_argb_font = 0;
 
 /*****************************************************************************/
 
-
-#define RUN_CLIPPED( surface, clip, func ) {\
+#define RUN_CLIPPED(surface, clip, func) {\
     if ((surface)->clips) {\
         int k;\
         for (k = 0; k < (surface)->n_clips; k++) {\
@@ -141,28 +137,26 @@ static int _directfb_argb_font = 0;
                 if (reg.y2 > cli->y2)\
                     reg.y2 = cli->y2;\
                 (surface)->dfbsurface->SetClip ((surface)->dfbsurface, &reg);\
-            }\
-            else {\
+            } else {\
                 (surface)->dfbsurface->SetClip ((surface)->dfbsurface,\
                                            &(surface)->clips[k]);\
             }\
             func;\
         }\
-    }\
-    else {\
+    } else {\
         (surface)->dfbsurface->SetClip ((surface)->dfbsurface, clip);\
         func;\
     }\
 }
 
-#define TRANSFORM_POINT2X( m, x, y, ret_x, ret_y ) {\
+#define TRANSFORM_POINT2X(m, x, y, ret_x, ret_y) {\
     double _x = (x);\
     double _y = (y);\
     (ret_x) = (_x * (m).xx + (m).x0);\
     (ret_y) = (_y * (m).yy + (m).y0);\
 }
 
-#define TRANSFORM_POINT3X( m, x, y, ret_x, ret_y ) {\
+#define TRANSFORM_POINT3X(m, x, y, ret_x, ret_y) {\
     double _x = (x);\
     double _y = (y);\
     (ret_x) = (_x * (m).xx + _y * (m).xy + (m).x0);\
@@ -173,36 +167,35 @@ static int _directfb_argb_font = 0;
  *      Probably we should drop it.
  */
 
-static cairo_content_t 
+static cairo_content_t
 _directfb_format_to_content (DFBSurfacePixelFormat format)
 {
-    if (DFB_PIXELFORMAT_HAS_ALPHA(format)) {
-        if (DFB_COLOR_BITS_PER_PIXEL(format))
+    if (DFB_PIXELFORMAT_HAS_ALPHA (format)) {
+        if (DFB_COLOR_BITS_PER_PIXEL (format))
             return CAIRO_CONTENT_COLOR_ALPHA;
-            
+
         return CAIRO_CONTENT_ALPHA;
     }
-    
+
     return CAIRO_CONTENT_COLOR;
 }
 
-                                                           
-static inline DFBSurfacePixelFormat 
+static inline DFBSurfacePixelFormat
 _cairo_to_directfb_format (cairo_format_t format)
 {
     switch (format) {
-        case CAIRO_FORMAT_RGB24:
-            return DSPF_RGB32;
-        case CAIRO_FORMAT_ARGB32:
-            return DSPF_ARGB; 
-        case CAIRO_FORMAT_A8:
-            return DSPF_A8; 
-        case CAIRO_FORMAT_A1:
-            return DSPF_A1; 
-        default:
-            break;
+    case CAIRO_FORMAT_RGB24:
+	return DSPF_RGB32;
+    case CAIRO_FORMAT_ARGB32:
+	return DSPF_ARGB;
+    case CAIRO_FORMAT_A8:
+	return DSPF_A8;
+    case CAIRO_FORMAT_A1:
+	return DSPF_A1;
+    default:
+	break;
     }
-    
+
     return -1;
 }
 
@@ -210,22 +203,21 @@ static inline cairo_format_t
 _directfb_to_cairo_format (DFBSurfacePixelFormat format)
 {
     switch (format) {
-        case DSPF_RGB32:
-            return CAIRO_FORMAT_RGB24;
-        case DSPF_ARGB:
-            return CAIRO_FORMAT_ARGB32;
-        case DSPF_A8:
-            return CAIRO_FORMAT_A8;
-        case DSPF_A1:
-            return CAIRO_FORMAT_A1;
-        default:
-            break;
+    case DSPF_RGB32:
+	return CAIRO_FORMAT_RGB24;
+    case DSPF_ARGB:
+	return CAIRO_FORMAT_ARGB32;
+    case DSPF_A8:
+	return CAIRO_FORMAT_A8;
+    case DSPF_A1:
+	return CAIRO_FORMAT_A1;
+    default:
+	break;
     }
-    
+
     return -1;
 }
 
-
 static cairo_bool_t
 _directfb_get_operator (cairo_operator_t         operator,
                         DFBSurfaceBlendFunction *ret_srcblend,
@@ -383,14 +375,13 @@ _directfb_acquire_surface (cairo_directfb_surface_t  *surface,
 
 /*        surface->dfbsurface->GetCapabilities (surface->dfbsurface, &caps);
         if (caps & DSCAPS_FLIPPING) {
-            DFBRegion region = { .x1 = source_rect.x, .y1 = source_rect.y, 
+            DFBRegion region = { .x1 = source_rect.x, .y1 = source_rect.y,
                                  .x2 = source_rect.x + source_rect.w - 1,
                                  .y2 = source_rect.y + source_rect.h - 1 };
             surface->dfbsurface->Flip (surface->dfbsurface, &region, DSFLIP_BLIT);
         } */
         buffer->Blit (buffer, surface->dfbsurface, &source_rect, 0, 0);
-    }
-    else {
+    } else {
         /*might be a subsurface get the offset*/
         surface->dfbsurface->GetVisibleRectangle (surface->dfbsurface, &source_rect);
         cairo_format = surface->format;
@@ -457,7 +448,7 @@ _cairo_directfb_surface_create_similar (void            *abstract_src,
     height = (height<= 0) ? 1 : height;
 
     format = _cairo_format_from_content (content);
-    surface = calloc (1, sizeof(cairo_directfb_surface_t));
+    surface = calloc (1, sizeof (cairo_directfb_surface_t));
     if (surface == NULL)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
 
@@ -479,8 +470,7 @@ _cairo_directfb_surface_create_similar (void            *abstract_src,
 
 	tmp->GetSubSurface (tmp, &rect, &surface->dfbsurface);
 	tmp->Release (tmp);
-    }
-    else {
+    } else {
 	status =
 	    _directfb_buffer_surface_create (surface->dfb,
 					     _cairo_to_directfb_format (format),
@@ -537,12 +527,12 @@ _cairo_directfb_surface_acquire_source_image (void                   *abstract_s
                                               void                  **image_extra)
 {
     cairo_directfb_surface_t *surface = abstract_surface;
-    
-    D_DEBUG_AT (CairoDFB_Acquire, 
-                "%s( surface=%p ).\n", __FUNCTION__, surface);
-    
-    return _directfb_acquire_surface (surface, NULL, image_out, 
-                                      NULL, image_extra, DSLF_READ);
+
+    D_DEBUG_AT (CairoDFB_Acquire,
+		"%s( surface=%p ).\n", __FUNCTION__, surface);
+
+    return _directfb_acquire_surface (surface, NULL, image_out,
+				      NULL, image_extra, DSLF_READ);
 }
 
 static void
@@ -568,17 +558,18 @@ _cairo_directfb_surface_acquire_dest_image (void                     *abstract_s
                                             void                    **image_extra)
 {
     cairo_directfb_surface_t *surface = abstract_surface;
-    
-    D_DEBUG_AT (CairoDFB_Acquire, 
-                "%s( surface=%p (%dx%d), interest_rect={ %u %u %u %u } ).\n", 
-                __FUNCTION__, surface, surface->width, surface->height,
-                interest_rect ? interest_rect->x : 0,
-                interest_rect ? interest_rect->y : 0,
-                interest_rect ? interest_rect->width  : (unsigned) surface->width,
-                interest_rect ? interest_rect->height : (unsigned) surface->height);
-    
-    return _directfb_acquire_surface (surface, interest_rect, image_out, 
-                                      image_rect_out, image_extra, DSLF_READ | DSLF_WRITE);
+
+    D_DEBUG_AT (CairoDFB_Acquire,
+		"%s( surface=%p (%dx%d), interest_rect={ %u %u %u %u } ).\n",
+		__FUNCTION__, surface, surface->width, surface->height,
+		interest_rect ? interest_rect->x : 0,
+		interest_rect ? interest_rect->y : 0,
+		interest_rect ? interest_rect->width  : (unsigned) surface->width,
+		interest_rect ? interest_rect->height : (unsigned) surface->height);
+
+    return _directfb_acquire_surface (surface, interest_rect, image_out,
+				      image_rect_out, image_extra,
+				      DSLF_READ | DSLF_WRITE);
 }
 
 static void
@@ -589,23 +580,23 @@ _cairo_directfb_surface_release_dest_image (void                  *abstract_surf
                                             void                  *image_extra)
 {
     cairo_directfb_surface_t *surface = abstract_surface;
-    IDirectFBSurface *buffer = image_extra; 
-    
-    D_DEBUG_AT (CairoDFB_Acquire, 
-                "%s( surface=%p ).\n", __FUNCTION__, surface);
-    
+    IDirectFBSurface *buffer = image_extra;
+
+    D_DEBUG_AT (CairoDFB_Acquire,
+		"%s( surface=%p ).\n", __FUNCTION__, surface);
+
     buffer->Unlock (buffer);
 
     if (surface->dfbsurface != buffer) {
-        DFBRegion region = { .x1 = interest_rect->x, .y1 = interest_rect->y,
-                             .x2 = interest_rect->x+interest_rect->width-1,
-                             .y2 = interest_rect->y+interest_rect->height-1 };
-        surface->dfbsurface->SetClip (surface->dfbsurface, &region);
-        surface->dfbsurface->SetBlittingFlags (surface->dfbsurface, DSBLIT_NOFX);
-        surface->dfbsurface->Blit (surface->dfbsurface, buffer,
-                                   NULL, image_rect->x, image_rect->y);
+	DFBRegion region = { .x1 = interest_rect->x, .y1 = interest_rect->y,
+	    .x2 = interest_rect->x+interest_rect->width-1,
+	    .y2 = interest_rect->y+interest_rect->height-1 };
+	surface->dfbsurface->SetClip (surface->dfbsurface, &region);
+	surface->dfbsurface->SetBlittingFlags (surface->dfbsurface, DSBLIT_NOFX);
+	surface->dfbsurface->Blit (surface->dfbsurface, buffer,
+				   NULL, image_rect->x, image_rect->y);
     }
-    
+
     cairo_surface_destroy (&image->base);
 }
 
@@ -622,81 +613,79 @@ _cairo_directfb_surface_clone_similar (void             *abstract_surface,
 {
     cairo_directfb_surface_t *surface = abstract_surface;
     cairo_directfb_surface_t *clone;
-    
-    D_DEBUG_AT (CairoDFB_Surface, 
-                "%s( surface=%p, src=%p ).\n", __FUNCTION__, surface, src);
+
+    D_DEBUG_AT (CairoDFB_Surface,
+		"%s( surface=%p, src=%p ).\n", __FUNCTION__, surface, src);
 
     if (src->backend == surface->base.backend) {
 	*clone_offset_x = 0;
 	*clone_offset_y = 0;
 	*clone_out = cairo_surface_reference (src);
 
-        return CAIRO_STATUS_SUCCESS;
-    }
-    else if (_cairo_surface_is_image (src)) {
-        cairo_image_surface_t *image_src = (cairo_image_surface_t *) src;
-        unsigned char         *dst, *src = image_src->data;
-        int                    pitch;
-        int                    i, j;
-        DFBResult              ret;
-        
-        clone = (cairo_directfb_surface_t *)
-                _cairo_directfb_surface_create_similar (surface, 
-                            _cairo_content_from_format (image_src->format),
-                            image_src->width, image_src->height);
-        if (clone == NULL)
+	return CAIRO_STATUS_SUCCESS;
+    } else if (_cairo_surface_is_image (src)) {
+	cairo_image_surface_t *image_src = (cairo_image_surface_t *) src;
+	unsigned char         *dst, *src = image_src->data;
+	int                    pitch;
+	int                    i, j;
+	DFBResult              ret;
+
+	clone = (cairo_directfb_surface_t *)
+	    _cairo_directfb_surface_create_similar (surface,
+						    _cairo_content_from_format (image_src->format),
+						    image_src->width, image_src->height);
+	if (clone == NULL)
 	    return CAIRO_INT_STATUS_UNSUPPORTED;
 	if (clone->base.status)
 	    return clone->base.status;
-            
-        ret = clone->dfbsurface->Lock (clone->dfbsurface, 
-                                   DSLF_WRITE, (void *)&dst, &pitch);
-        if (ret) {
-            DirectFBError ("IDirectFBSurface::Lock()", ret);
-            cairo_surface_destroy ((cairo_surface_t *)clone);
-            return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-        }
 
-        dst += pitch * src_y;
-        src += image_src->stride * src_y;
-        
-        if (image_src->format == CAIRO_FORMAT_A1) {
-            /* A1 -> A8 */
-            for (i = 0; i < height; i++) {
-                for (j = src_x; j < src_x + width; j++)
-                    dst[j] = (src[j>>3] & (1 << (j&7))) ? 0xff : 0x00;
-                dst += pitch;
-                src += image_src->stride;
-            }
-        }
-        else {
-            int len;
-            
-            if (image_src->format == CAIRO_FORMAT_A8) {
-                dst += src_x;
-                src += src_x;
-                len  = width;
-            } else {
-                dst += src_x * 4;
-                src += src_x * 4;
-                len  = width * 4;
-            }
-            
-            for (i = 0; i < height; i++) {
-                direct_memcpy (dst, src, len);
-                dst += pitch;
-                src += image_src->stride;
-            }
-        }
-        
-        clone->dfbsurface->Unlock (clone->dfbsurface);
+	ret = clone->dfbsurface->Lock (clone->dfbsurface,
+				       DSLF_WRITE, (void *)&dst, &pitch);
+	if (ret) {
+	    DirectFBError ("IDirectFBSurface::Lock()", ret);
+	    cairo_surface_destroy (&clone->base);
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	}
+
+	dst += pitch * src_y;
+	src += image_src->stride * src_y;
+
+	if (image_src->format == CAIRO_FORMAT_A1) {
+	    /* A1 -> A8 */
+	    for (i = 0; i < height; i++) {
+		for (j = src_x; j < src_x + width; j++)
+		    dst[j] = (src[j>>3] & (1 << (j&7))) ? 0xff : 0x00;
+		dst += pitch;
+		src += image_src->stride;
+	    }
+	} else {
+	    int len;
+
+	    if (image_src->format == CAIRO_FORMAT_A8) {
+		dst += src_x;
+		src += src_x;
+		len  = width;
+	    } else {
+		dst += src_x * 4;
+		src += src_x * 4;
+		len  = width * 4;
+	    }
+
+	    for (i = 0; i < height; i++) {
+		direct_memcpy (dst, src, len);
+		dst += pitch;
+		src += image_src->stride;
+	    }
+	}
+
+	clone->dfbsurface->Unlock (clone->dfbsurface);
 
 	*clone_offset_x = 0;
 	*clone_offset_y = 0;
-        *clone_out = &clone->base;
-        return CAIRO_STATUS_SUCCESS;
+	*clone_out = &clone->base;
+	return CAIRO_STATUS_SUCCESS;
     }
-    
+
     return CAIRO_INT_STATUS_UNSUPPORTED;
 }
 
@@ -709,108 +698,109 @@ _directfb_prepare_composite (cairo_directfb_surface_t    *dst,
                              int *src_x,             int *src_y,
                              int *mask_x,            int *mask_y,
                              unsigned int                 width,
-                             unsigned int                 height,                        
+                             unsigned int                 height,
                              cairo_directfb_surface_t   **ret_src,
                              cairo_surface_attributes_t  *ret_src_attr)
 {
     cairo_directfb_surface_t   *src;
     cairo_surface_attributes_t  src_attr;
-    cairo_status_t              ret;
+    cairo_status_t              status;
     DFBSurfaceBlittingFlags     flags;
     DFBSurfaceBlendFunction     sblend;
     DFBSurfaceBlendFunction     dblend;
     DFBColor                    color;
-    
+
     if (! _directfb_get_operator (op, &sblend, &dblend))
-        return CAIRO_INT_STATUS_UNSUPPORTED;
-     
+	return CAIRO_INT_STATUS_UNSUPPORTED;
+
     if (mask_pattern) {
-        cairo_solid_pattern_t *pattern;
-        
-        if (mask_pattern->type != CAIRO_PATTERN_TYPE_SOLID) {
-            cairo_pattern_t *tmp;
-            int              tmp_x, tmp_y;
-            
-            if (src_pattern->type != CAIRO_PATTERN_TYPE_SOLID ||
-                sblend == DSBF_INVDESTALPHA) /* Doesn't work correctly */
-                return CAIRO_INT_STATUS_UNSUPPORTED;
-                
-            D_DEBUG_AT (CairoDFB_Render, "Replacing src pattern by mask pattern.\n");
-                
-            tmp = src_pattern;
-            tmp_x = *src_x; tmp_y = *src_y;
-            
-            src_pattern = mask_pattern;
-            *src_x = *mask_x; *src_y = *mask_y;
-            
-            mask_pattern = tmp;
-            *mask_x = tmp_x; *mask_y = tmp_y;
-            
-            if (sblend == DSBF_ONE) {                  
-                sblend = DSBF_SRCALPHA;
-                /*dblend = DSBF_INVSRCALPHA;*/
-            }
-        }
-            
-        pattern = (cairo_solid_pattern_t *)mask_pattern;
-        color.a = pattern->color.alpha_short >> 8;
-        color.r = pattern->color.red_short   >> 8;
-        color.g = pattern->color.green_short >> 8;
-        color.b = pattern->color.blue_short  >> 8;
-    } 
-    else {
-        color.a = color.r = color.g = color.b = 0xff;
+	cairo_solid_pattern_t *pattern;
+
+	if (mask_pattern->type != CAIRO_PATTERN_TYPE_SOLID) {
+	    cairo_pattern_t *tmp;
+	    int              tmp_x, tmp_y;
+
+	    if (src_pattern->type != CAIRO_PATTERN_TYPE_SOLID ||
+		sblend == DSBF_INVDESTALPHA) /* Doesn't work correctly */
+		return CAIRO_INT_STATUS_UNSUPPORTED;
+
+	    D_DEBUG_AT (CairoDFB_Render, "Replacing src pattern by mask pattern.\n");
+
+	    tmp = src_pattern;
+	    tmp_x = *src_x; tmp_y = *src_y;
+
+	    src_pattern = mask_pattern;
+	    *src_x = *mask_x; *src_y = *mask_y;
+
+	    mask_pattern = tmp;
+	    *mask_x = tmp_x; *mask_y = tmp_y;
+
+	    if (sblend == DSBF_ONE) {
+		sblend = DSBF_SRCALPHA;
+		/*dblend = DSBF_INVSRCALPHA;*/
+	    }
+	}
+
+	pattern = (cairo_solid_pattern_t *)mask_pattern;
+	color.a = pattern->color.alpha_short >> 8;
+	color.r = pattern->color.red_short   >> 8;
+	color.g = pattern->color.green_short >> 8;
+	color.b = pattern->color.blue_short  >> 8;
+    } else {
+	color.a = color.r = color.g = color.b = 0xff;
     }
 
-    ret = _cairo_pattern_acquire_surface (src_pattern, &dst->base,
-					  *src_x, *src_y, width, height,
-					  (cairo_surface_t **)&src, &src_attr);
-    if (ret)
-	return ret;
+    status = _cairo_pattern_acquire_surface (src_pattern, &dst->base,
+					     *src_x, *src_y, width, height,
+					     (cairo_surface_t **) &src,
+					     &src_attr);
+    if (status)
+	return status;
 
     if (src->content == CAIRO_CONTENT_COLOR) {
-        if (sblend == DSBF_SRCALPHA)
-            sblend = DSBF_ONE;
-        else if (sblend == DSBF_INVSRCALPHA)
-            sblend = DSBF_ZERO;
-            
-        if (dblend == DSBF_SRCALPHA)
-            dblend = DSBF_ONE;
-        else if (dblend == DSBF_INVSRCALPHA)
-            dblend = DSBF_ZERO;
+	if (sblend == DSBF_SRCALPHA)
+	    sblend = DSBF_ONE;
+	else if (sblend == DSBF_INVSRCALPHA)
+	    sblend = DSBF_ZERO;
+
+	if (dblend == DSBF_SRCALPHA)
+	    dblend = DSBF_ONE;
+	else if (dblend == DSBF_INVSRCALPHA)
+	    dblend = DSBF_ZERO;
     }
+
     if (dst->content == CAIRO_CONTENT_COLOR) {
-        if (sblend == DSBF_DESTALPHA)
-            sblend = DSBF_ONE;
-        else if (sblend == DSBF_INVDESTALPHA)
-            sblend = DSBF_ZERO;
-         
-        if (dblend == DSBF_DESTALPHA)
-            dblend = DSBF_ONE;
-        else if (dblend == DSBF_INVDESTALPHA)
-            dblend = DSBF_ZERO;   
+	if (sblend == DSBF_DESTALPHA)
+	    sblend = DSBF_ONE;
+	else if (sblend == DSBF_INVDESTALPHA)
+	    sblend = DSBF_ZERO;
+
+	if (dblend == DSBF_DESTALPHA)
+	    dblend = DSBF_ONE;
+	else if (dblend == DSBF_INVDESTALPHA)
+	    dblend = DSBF_ZERO;
     }
 
-    flags = (sblend == DSBF_ONE && dblend == DSBF_ZERO) 
-            ? DSBLIT_NOFX : DSBLIT_BLEND_ALPHACHANNEL; 
+    flags = (sblend == DSBF_ONE && dblend == DSBF_ZERO)
+	? DSBLIT_NOFX : DSBLIT_BLEND_ALPHACHANNEL;
     if (color.a != 0xff)
-        flags |= DSBLIT_BLEND_COLORALPHA;
+	flags |= DSBLIT_BLEND_COLORALPHA;
     if (color.r != 0xff || color.g != 0xff || color.b != 0xff)
-        flags |= DSBLIT_COLORIZE;
-            
+	flags |= DSBLIT_COLORIZE;
+
     dst->dfbsurface->SetBlittingFlags (dst->dfbsurface, flags);
-    
+
     if (flags & (DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_BLEND_COLORALPHA)) {
-        dst->dfbsurface->SetSrcBlendFunction (dst->dfbsurface, sblend);
-        dst->dfbsurface->SetDstBlendFunction (dst->dfbsurface, dblend);
+	dst->dfbsurface->SetSrcBlendFunction (dst->dfbsurface, sblend);
+	dst->dfbsurface->SetDstBlendFunction (dst->dfbsurface, dblend);
     }
-    
-    if (flags & (DSBLIT_BLEND_COLORALPHA | DSBLIT_COLORIZE))    
-        dst->dfbsurface->SetColor (dst->dfbsurface, color.r, color.g, color.b, color.a); 
-        
+
+    if (flags & (DSBLIT_BLEND_COLORALPHA | DSBLIT_COLORIZE))
+	dst->dfbsurface->SetColor (dst->dfbsurface, color.r, color.g, color.b, color.a);
+
     *ret_src = src;
     *ret_src_attr = src_attr;
-    
+
     return CAIRO_STATUS_SUCCESS;
 }
 
@@ -822,30 +812,34 @@ _directfb_finish_composite (cairo_directfb_surface_t   *dst,
 {
     _cairo_pattern_release_surface (src_pattern, src, src_attr);
 }
-#endif /* DFB_COMPOSITE || DFB_COMPOSITE_TRAPEZOIDS */        
+#endif /* DFB_COMPOSITE || DFB_COMPOSITE_TRAPEZOIDS */
 
 #if DFB_COMPOSITE
 static DFBAccelerationMask
 _directfb_categorize_operation (cairo_surface_attributes_t *src_attr)
 {
     cairo_matrix_t *m = &src_attr->matrix;
-    
+
     if (m->xy != 0 || m->yx != 0 || m->xx < 0 || m->yy < 0) {
-        if (src_attr->extend != CAIRO_EXTEND_NONE)
-            return DFXL_NONE;
-        return DFXL_TEXTRIANGLES;
+	if (src_attr->extend != CAIRO_EXTEND_NONE)
+	    return DFXL_NONE;
+
+	return DFXL_TEXTRIANGLES;
     }
-        
+
     if (m->xx != 1 || m->yy != 1) {
-        if (src_attr->extend != CAIRO_EXTEND_NONE)
-            return DFXL_NONE;
-        return DFXL_STRETCHBLIT;
+	if (src_attr->extend != CAIRO_EXTEND_NONE)
+	    return DFXL_NONE;
+
+	return DFXL_STRETCHBLIT;
     }
-     
+
     if (src_attr->extend != CAIRO_EXTEND_NONE &&
-        src_attr->extend != CAIRO_EXTEND_REPEAT)
-        return DFXL_NONE;
-           
+	src_attr->extend != CAIRO_EXTEND_REPEAT)
+    {
+	return DFXL_NONE;
+    }
+
     return DFXL_BLIT;
 }
 
@@ -864,159 +858,163 @@ _cairo_directfb_surface_composite (cairo_operator_t  op,
     cairo_directfb_surface_t   *src;
     cairo_surface_attributes_t  src_attr;
     DFBAccelerationMask         accel, mask;
-    cairo_int_status_t          ret;
-    
+    cairo_int_status_t          status;
+
     D_DEBUG_AT (CairoDFB_Render,
-                "%s( op=%d, src_pattern=%p, mask_pattern=%p, dst=%p,"
-                   " src_x=%d, src_y=%d, mask_x=%d, mask_y=%d, dst_x=%d,"
-                   " dst_y=%d, width=%u, height=%u ).\n",
-                __FUNCTION__, op, src_pattern, mask_pattern, dst, 
-                src_x, src_y, mask_x, mask_y, dst_x, dst_y, width, height);
-    
-    ret = _directfb_prepare_composite (dst, src_pattern, mask_pattern, op,
-                                       &src_x, &src_y, &mask_x, &mask_y, 
-                                       width, height, &src, &src_attr);
-    if (ret)
-        return ret;
-        
+		"%s( op=%d, src_pattern=%p, mask_pattern=%p, dst=%p,"
+		" src_x=%d, src_y=%d, mask_x=%d, mask_y=%d, dst_x=%d,"
+		" dst_y=%d, width=%u, height=%u ).\n",
+		__FUNCTION__, op, src_pattern, mask_pattern, dst,
+		src_x, src_y, mask_x, mask_y, dst_x, dst_y, width, height);
+
+    status = _directfb_prepare_composite (dst, src_pattern, mask_pattern, op,
+					  &src_x, &src_y, &mask_x, &mask_y,
+					  width, height, &src, &src_attr);
+    if (status)
+	return status;
+
     accel = _directfb_categorize_operation (&src_attr);
-    
+
     dst->dfbsurface->GetAccelerationMask (dst->dfbsurface, src->dfbsurface, &mask);
-    if (!(mask & accel)) {
-        D_DEBUG_AT (CairoDFB_Render, "No acceleration (%08x)!\n", accel);
-        if (accel != DFXL_BLIT) {
-            _directfb_finish_composite (dst, src_pattern, &src->base, &src_attr);
-            return CAIRO_INT_STATUS_UNSUPPORTED;
-        }
+    if ((mask & accel) == 0) {
+	D_DEBUG_AT (CairoDFB_Render, "No acceleration (%08x)!\n", accel);
+	if (accel != DFXL_BLIT) {
+	    _directfb_finish_composite (dst, src_pattern, &src->base, &src_attr);
+	    return CAIRO_INT_STATUS_UNSUPPORTED;
+	}
     }
-    
+
     src_x += src_attr.x_offset;
     src_y += src_attr.y_offset;
-    
+
     switch (accel) {
-        case DFXL_BLIT: {
-            DFBRectangle sr;
-        
-            sr.x = src_x + _cairo_lround (src_attr.matrix.x0);
-            sr.y = src_y + _cairo_lround (src_attr.matrix.y0);
-            sr.w = width;
-            sr.h = height;
-        
-            if (src_attr.extend == CAIRO_EXTEND_NONE) {
-                D_DEBUG_AT (CairoDFB_Render, "Running Blit().\n");
-        
-                RUN_CLIPPED( dst, NULL,
-                             dst->dfbsurface->Blit (dst->dfbsurface,
-                                            src->dfbsurface, &sr, dst_x, dst_y));
-            }
-            else if (src_attr.extend == CAIRO_EXTEND_REPEAT) {
-                DFBRegion clip;
-            
-                clip.x1 = dst_x;
-                clip.y1 = dst_y;
-                clip.x2 = dst_x + width  - 1;
-                clip.y2 = dst_y + height - 1;
-            
-                D_DEBUG_AT (CairoDFB_Render, "Running TileBlit().\n");
-            
-                RUN_CLIPPED( dst, &clip,
-                             dst->dfbsurface->TileBlit (dst->dfbsurface, 
-                                            src->dfbsurface, &sr, dst_x, dst_y));
-            }
-        }   break;
-        
-        case DFXL_STRETCHBLIT: {
-            DFBRectangle sr, dr;
-            double       x1, y1, x2, y2;
-            
-            TRANSFORM_POINT2X (src_attr.matrix, 
-                               src_x, src_y, x1, y1);
-            TRANSFORM_POINT2X (src_attr.matrix, 
-                               src_x+width, src_y+height, x2, y2);
-                               
-            sr.x = _cairo_lround (x1);
-            sr.y = _cairo_lround (y1);
-            sr.w = _cairo_lround (x2-x1);
-            sr.h = _cairo_lround (y2-y1);
-            
-            dr.x = dst_x;
-            dr.y = dst_y;
-            dr.w = width;
-            dr.h = height;
-            
-            D_DEBUG_AT (CairoDFB_Render, "Running StretchBlit().\n");
-
-            RUN_CLIPPED (dst, NULL,
-                         dst->dfbsurface->StretchBlit (dst->dfbsurface, 
-                                                       src->dfbsurface, &sr, &dr));
-        }   break;
-        
-        case DFXL_TEXTRIANGLES: {
-            DFBRegion clip;
-            DFBVertex v[4];
-            float     x1, y1, x2, y2;
-            int       w, h;
-            
-            if (cairo_matrix_invert (&src_attr.matrix) != CAIRO_STATUS_SUCCESS) {
-                ret = CAIRO_INT_STATUS_UNSUPPORTED;
-                break;
-            }
-            
-            x1 = src_attr.x_offset;
-            y1 = src_attr.y_offset;
-            x2 = src->width  - x1;
-            y2 = src->height - y1;
-            
-            src->dfbsurface->GetSize (src->dfbsurface, &w, &h);
-            
-            TRANSFORM_POINT3X (src_attr.matrix, 
-                               x1, y1, v[0].x, v[0].y);
-            v[0].z = 0;
-            v[0].w = 1;
-            v[0].s = x1 / w;
-            v[0].t = y1 / h;
-        
-            TRANSFORM_POINT3X (src_attr.matrix, 
-                               x2, y1, v[1].x, v[1].y);
-            v[1].z = 0;
-            v[1].w = 1;
-            v[1].s = x2 / w;
-            v[1].t = y1 / h;
-        
-            TRANSFORM_POINT3X (src_attr.matrix,
-                               x2, y2, v[2].x, v[2].y);
-            v[2].z = 0;
-            v[2].w = 1;
-            v[2].s = x2 / w;
-            v[2].t = y2 / h;
-        
-            TRANSFORM_POINT3X (src_attr.matrix, 
-                               x1, y2, v[3].x, v[3].y);
-            v[3].z = 0;
-            v[3].w = 1;
-            v[3].s = x1 / w;
-            v[3].t = y2 / h;
-            
-            clip.x1 = dst_x;
-            clip.y1 = dst_y;
-            clip.x2 = dst_x + width  - 1;
-            clip.y2 = dst_y + height - 1;
-        
-            D_DEBUG_AT (CairoDFB_Render, "Running TextureTriangles().\n");
-            
-            RUN_CLIPPED (dst, &clip,
-                         dst->dfbsurface->TextureTriangles (dst->dfbsurface, 
-                                            src->dfbsurface, v, NULL, 4, DTTF_FAN));
-        }   break;
-        
-        default:
-            D_BUG ("Unexpected operation");
-            break;
+    case DFXL_BLIT:
+	{
+	    DFBRectangle sr;
+
+	    sr.x = src_x + _cairo_lround (src_attr.matrix.x0);
+	    sr.y = src_y + _cairo_lround (src_attr.matrix.y0);
+	    sr.w = width;
+	    sr.h = height;
+
+	    if (src_attr.extend == CAIRO_EXTEND_NONE) {
+		D_DEBUG_AT (CairoDFB_Render, "Running Blit().\n");
+
+		RUN_CLIPPED (dst, NULL,
+			     dst->dfbsurface->Blit (dst->dfbsurface,
+						    src->dfbsurface, &sr, dst_x, dst_y));
+	    } else if (src_attr.extend == CAIRO_EXTEND_REPEAT) {
+		DFBRegion clip;
+
+		clip.x1 = dst_x;
+		clip.y1 = dst_y;
+		clip.x2 = dst_x + width  - 1;
+		clip.y2 = dst_y + height - 1;
+
+		D_DEBUG_AT (CairoDFB_Render, "Running TileBlit().\n");
+
+		RUN_CLIPPED (dst, &clip,
+			     dst->dfbsurface->TileBlit (dst->dfbsurface,
+							src->dfbsurface, &sr, dst_x, dst_y));
+	    }
+	    break;
+	}
+
+    case DFXL_STRETCHBLIT:
+	{
+	    DFBRectangle sr, dr;
+	    double       x1, y1, x2, y2;
+
+	    TRANSFORM_POINT2X (src_attr.matrix,
+			       src_x, src_y, x1, y1);
+	    TRANSFORM_POINT2X (src_attr.matrix,
+			       src_x+width, src_y+height, x2, y2);
+
+	    sr.x = _cairo_lround (x1);
+	    sr.y = _cairo_lround (y1);
+	    sr.w = _cairo_lround (x2-x1);
+	    sr.h = _cairo_lround (y2-y1);
+
+	    dr.x = dst_x;
+	    dr.y = dst_y;
+	    dr.w = width;
+	    dr.h = height;
+
+	    D_DEBUG_AT (CairoDFB_Render, "Running StretchBlit().\n");
+
+	    RUN_CLIPPED (dst, NULL,
+			 dst->dfbsurface->StretchBlit (dst->dfbsurface,
+						       src->dfbsurface, &sr, &dr));
+	    break;
+	}
+
+    case DFXL_TEXTRIANGLES:
+	{
+	    DFBRegion clip;
+	    DFBVertex v[4];
+	    float     x1, y1, x2, y2;
+	    int       w, h;
+
+	    status = cairo_matrix_invert (&src_attr.matrix);
+	    /* guaranteed by cairo_pattern_set_matrix (); */
+	    assert (status == CAIRO_STATUS_SUCCESS);
+
+	    x1 = src_attr.x_offset;
+	    y1 = src_attr.y_offset;
+	    x2 = src->width  - x1;
+	    y2 = src->height - y1;
+
+	    src->dfbsurface->GetSize (src->dfbsurface, &w, &h);
+
+	    TRANSFORM_POINT3X (src_attr.matrix,
+			       x1, y1, v[0].x, v[0].y);
+	    v[0].z = 0;
+	    v[0].w = 1;
+	    v[0].s = x1 / w;
+	    v[0].t = y1 / h;
+
+	    TRANSFORM_POINT3X (src_attr.matrix,
+			       x2, y1, v[1].x, v[1].y);
+	    v[1].z = 0;
+	    v[1].w = 1;
+	    v[1].s = x2 / w;
+	    v[1].t = y1 / h;
+
+	    TRANSFORM_POINT3X (src_attr.matrix,
+			       x2, y2, v[2].x, v[2].y);
+	    v[2].z = 0;
+	    v[2].w = 1;
+	    v[2].s = x2 / w;
+	    v[2].t = y2 / h;
+
+	    TRANSFORM_POINT3X (src_attr.matrix,
+			       x1, y2, v[3].x, v[3].y);
+	    v[3].z = 0;
+	    v[3].w = 1;
+	    v[3].s = x1 / w;
+	    v[3].t = y2 / h;
+
+	    clip.x1 = dst_x;
+	    clip.y1 = dst_y;
+	    clip.x2 = dst_x + width  - 1;
+	    clip.y2 = dst_y + height - 1;
+
+	    D_DEBUG_AT (CairoDFB_Render, "Running TextureTriangles().\n");
+
+	    RUN_CLIPPED (dst, &clip,
+			 dst->dfbsurface->TextureTriangles (dst->dfbsurface,
+							    src->dfbsurface, v, NULL, 4, DTTF_FAN));
+	    break;
+	}
+
+    default:
+	D_BUG ("Unexpected operation");
+	break;
     }
 
     _directfb_finish_composite (dst, src_pattern, &src->base, &src_attr);
-    
-    return ret;
+
+    return status;
 }
 #endif /* DFB_COMPOSITE */
 
@@ -1034,60 +1032,60 @@ _cairo_directfb_surface_fill_rectangles (void                  *abstract_surface
     DFBSurfaceBlendFunction   dblend;
     DFBRectangle              r[n_rects];
     int                       i;
-    
-    D_DEBUG_AT (CairoDFB_Render, 
-                "%s( dst=%p, op=%d, color=%p, rects=%p, n_rects=%d ).\n",
-                __FUNCTION__, dst, op, color, rects, n_rects);
+
+    D_DEBUG_AT (CairoDFB_Render,
+		"%s( dst=%p, op=%d, color=%p, rects=%p, n_rects=%d ).\n",
+		__FUNCTION__, dst, op, color, rects, n_rects);
 
     if (! _directfb_get_operator (op, &sblend, &dblend))
-        return CAIRO_INT_STATUS_UNSUPPORTED;
-        
+	return CAIRO_INT_STATUS_UNSUPPORTED;
+
     if (color->alpha_short >= 0xff00) {
-        if (sblend == DSBF_SRCALPHA)
-            sblend = DSBF_ONE;
-        else if (sblend == DSBF_INVSRCALPHA)
-            sblend = DSBF_ZERO;
-            
-        if (dblend == DSBF_SRCALPHA)
-            dblend = DSBF_ONE;
-        else if (dblend == DSBF_INVSRCALPHA)
-            dblend = DSBF_ZERO;
+	if (sblend == DSBF_SRCALPHA)
+	    sblend = DSBF_ONE;
+	else if (sblend == DSBF_INVSRCALPHA)
+	    sblend = DSBF_ZERO;
+
+	if (dblend == DSBF_SRCALPHA)
+	    dblend = DSBF_ONE;
+	else if (dblend == DSBF_INVSRCALPHA)
+	    dblend = DSBF_ZERO;
     }
     if (dst->content == CAIRO_CONTENT_COLOR) {
-        if (sblend == DSBF_DESTALPHA)
-            sblend = DSBF_ONE;
-        else if (sblend == DSBF_INVDESTALPHA)
-            sblend = DSBF_ZERO;
-         
-        if (dblend == DSBF_DESTALPHA)
-            dblend = DSBF_ONE;
-        else if (dblend == DSBF_INVDESTALPHA)
-            dblend = DSBF_ZERO;   
+	if (sblend == DSBF_DESTALPHA)
+	    sblend = DSBF_ONE;
+	else if (sblend == DSBF_INVDESTALPHA)
+	    sblend = DSBF_ZERO;
+
+	if (dblend == DSBF_DESTALPHA)
+	    dblend = DSBF_ONE;
+	else if (dblend == DSBF_INVDESTALPHA)
+	    dblend = DSBF_ZERO;
     }
-    
+
     flags = (sblend == DSBF_ONE && dblend == DSBF_ZERO) ? DSDRAW_NOFX : DSDRAW_BLEND;
     dst->dfbsurface->SetDrawingFlags (dst->dfbsurface, flags);
     if (flags & DSDRAW_BLEND) {
-        dst->dfbsurface->SetSrcBlendFunction (dst->dfbsurface, sblend);
-        dst->dfbsurface->SetDstBlendFunction (dst->dfbsurface, dblend);
-    }    
-    
-    dst->dfbsurface->SetColor (dst->dfbsurface, 
-                               color->red_short   >> 8,
-                               color->green_short >> 8, 
-                               color->blue_short  >> 8, 
-                               color->alpha_short >> 8 );
-       
+	dst->dfbsurface->SetSrcBlendFunction (dst->dfbsurface, sblend);
+	dst->dfbsurface->SetDstBlendFunction (dst->dfbsurface, dblend);
+    }
+
+    dst->dfbsurface->SetColor (dst->dfbsurface,
+			       color->red_short   >> 8,
+			       color->green_short >> 8,
+			       color->blue_short  >> 8,
+			       color->alpha_short >> 8);
+
     for (i = 0; i < n_rects; i++) {
-        r[i].x = rects[i].x;
-        r[i].y = rects[i].y;
-        r[i].w = rects[i].width;
-        r[i].h = rects[i].height;
+	r[i].x = rects[i].x;
+	r[i].y = rects[i].y;
+	r[i].w = rects[i].width;
+	r[i].h = rects[i].height;
     }
-     
+
     RUN_CLIPPED (dst, NULL,
-                 dst->dfbsurface->FillRectangles (dst->dfbsurface, r, n_rects));
-    
+		 dst->dfbsurface->FillRectangles (dst->dfbsurface, r, n_rects));
+
     return CAIRO_STATUS_SUCCESS;
 }
 #endif
@@ -1232,52 +1230,51 @@ _cairo_directfb_surface_set_clip_region (void           *abstract_surface,
                                          cairo_region_t *region)
 {
     cairo_directfb_surface_t *surface = abstract_surface;
-    
-    D_DEBUG_AT (CairoDFB_Clip, 
-                "%s( surface=%p, region=%p ).\n",
-                __FUNCTION__, surface, region);
-    
+
+    D_DEBUG_AT (CairoDFB_Clip,
+		"%s( surface=%p, region=%p ).\n",
+		__FUNCTION__, surface, region);
+
     if (region) {
-        cairo_box_int_t *boxes;
-        int              n_boxes;
-        cairo_status_t   status;
-        int              i;
-
-        status = _cairo_region_get_boxes (region, &n_boxes, &boxes);
-        if (n_boxes == 0)
-            return CAIRO_STATUS_SUCCESS;
-        if (status)
-            return status;
-        
-        if (surface->n_clips != n_boxes) {
-            if (surface->clips)
-                free (surface->clips);
-            
-            surface->clips = _cairo_malloc_ab (n_boxes, sizeof(DFBRegion));
-            if (!surface->clips) {
-                surface->n_clips = 0;
-                _cairo_region_boxes_fini (region, boxes);
-                return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-            }
-        
-            surface->n_clips = n_boxes;
-        }
-        
-        for (i = 0; i < n_boxes; i++) {
-            surface->clips[i].x1 = boxes[i].p1.x;
-            surface->clips[i].y1 = boxes[i].p1.y;
-            surface->clips[i].x2 = boxes[i].p2.x;
-            surface->clips[i].y2 = boxes[i].p2.y;
-        }
+	cairo_box_int_t *boxes;
+	int              n_boxes;
+	cairo_status_t   status;
+	int              i;
+
+	status = _cairo_region_get_boxes (region, &n_boxes, &boxes);
+	if (n_boxes == 0)
+	    return CAIRO_STATUS_SUCCESS;
+	if (status)
+	    return status;
+
+	if (surface->n_clips != n_boxes) {
+	    if (surface->clips)
+		free (surface->clips);
+
+	    surface->clips = _cairo_malloc_ab (n_boxes, sizeof (DFBRegion));
+	    if (!surface->clips) {
+		surface->n_clips = 0;
+		_cairo_region_boxes_fini (region, boxes);
+		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	    }
+
+	    surface->n_clips = n_boxes;
+	}
 
-        _cairo_region_boxes_fini (region, boxes);
-    }
-    else {
-        if (surface->clips) {
-            free (surface->clips);
-            surface->clips = NULL;
-            surface->n_clips = 0;
-        }
+	for (i = 0; i < n_boxes; i++) {
+	    surface->clips[i].x1 = boxes[i].p1.x;
+	    surface->clips[i].y1 = boxes[i].p1.y;
+	    surface->clips[i].x2 = boxes[i].p2.x;
+	    surface->clips[i].y2 = boxes[i].p2.y;
+	}
+
+	_cairo_region_boxes_fini (region, boxes);
+    } else {
+	if (surface->clips) {
+	    free (surface->clips);
+	    surface->clips = NULL;
+	    surface->n_clips = 0;
+	}
     }
 
     return CAIRO_STATUS_SUCCESS;
@@ -1288,22 +1285,21 @@ _cairo_directfb_abstract_surface_get_extents (void                  *abstract_su
                                               cairo_rectangle_int_t *rectangle)
 {
     cairo_directfb_surface_t *surface = abstract_surface;
-    
+
     D_DEBUG_AT (CairoDFB_Surface,
-                "%s( surface=%p, rectangle=%p ).\n",
-                __FUNCTION__, surface, rectangle);
-    
-    if (rectangle) {
-        if (!surface->local) {
-            surface->dfbsurface->GetSize (surface->dfbsurface,
-                                          &surface->width, &surface->height);
-        }   
-        rectangle->x = 0;
-        rectangle->y = 0;
-        rectangle->width  = surface->width;
-        rectangle->height = surface->height;
+		"%s( surface=%p, rectangle=%p ).\n",
+		__FUNCTION__, surface, rectangle);
+
+    if (!surface->local) {
+	surface->dfbsurface->GetSize (surface->dfbsurface,
+				      &surface->width, &surface->height);
     }
-    
+
+    rectangle->x = 0;
+    rectangle->y = 0;
+    rectangle->width  = surface->width;
+    rectangle->height = surface->height;
+
     return CAIRO_STATUS_SUCCESS;
 }
 
@@ -1316,7 +1312,7 @@ _directfb_allocate_font_cache (IDirectFB *dfb,
     cairo_directfb_font_cache_t *cache;
     cairo_status_t status;
 
-    cache = calloc (1, sizeof(cairo_directfb_font_cache_t));
+    cache = calloc (1, sizeof (cairo_directfb_font_cache_t));
     if (cache == NULL)
         return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -1351,242 +1347,234 @@ _directfb_acquire_font_cache (cairo_directfb_surface_t     *surface,
                               cairo_directfb_font_cache_t **ret_cache,
                               DFBRectangle                 *rects,
                               DFBPoint                     *points,
-                              int                          *ret_num )
+			      int                          *ret_num )
 {
-    cairo_status_t               ret;
+    cairo_status_t               status;
     cairo_scaled_glyph_t        *chars[num_glyphs];
     int                          num_chars = 0;
-    cairo_directfb_font_cache_t *cache     = NULL; 
+    cairo_directfb_font_cache_t *cache     = NULL;
     int                          n         = 0;
     int                          x         = 0;
     int                          y         = 0;
     int                          w         = 8;
     int                          h         = 8;
     int                          i;
-    cairo_status_t               status;
 
     D_DEBUG_AT (CairoDFB_Font, "%s( %p [%d] )\n", __FUNCTION__, glyphs, num_glyphs );
 
     if (scaled_font->surface_private) {
-        cache = scaled_font->surface_private;
-        x = cache->x;
-        y = cache->y;
+	cache = scaled_font->surface_private;
+	x = cache->x;
+	y = cache->y;
     }
 
-    _cairo_cache_freeze( scaled_font->glyphs );
+    _cairo_cache_freeze (scaled_font->glyphs);
 
     for (i = 0; i < num_glyphs; i++) {
-        cairo_scaled_glyph_t  *scaled_glyph;
-        cairo_image_surface_t *img;
-        
-        D_DEBUG_AT (CairoDFB_Font, "  -> [%2d] = %4lu\n", i, glyphs[i].index );
-
-        ret = _cairo_scaled_glyph_lookup (scaled_font, glyphs[i].index,
-                                          CAIRO_SCALED_GLYPH_INFO_SURFACE,
-                                          &scaled_glyph);
-        if (ret) {
-            _cairo_cache_thaw( scaled_font->glyphs );
-            return ret;
-        }
-        
-        img = scaled_glyph->surface;
-        switch (img->format) {
-            case CAIRO_FORMAT_A1:
-            case CAIRO_FORMAT_A8:
-            case CAIRO_FORMAT_ARGB32:
-                break;
-            default:
-                D_DEBUG_AT (CairoDFB_Font,
-                            "  -> Unsupported font format %d!\n", img->format);
-                _cairo_cache_thaw( scaled_font->glyphs );
-                return CAIRO_INT_STATUS_UNSUPPORTED;
-        }
-        
-        points[n].x = _cairo_lround (glyphs[i].x - img->base.device_transform.x0);
-        points[n].y = _cairo_lround (glyphs[i].y - img->base.device_transform.y0);
-        
-//        D_DEBUG_AT (CairoDFB_Font, "            (%4d,%4d) [%2d]\n", points[n].x, points[n].y, n );
-
-        if (points[n].x >= surface->width  ||
-            points[n].y >= surface->height ||
-            points[n].x+img->width  <= 0   ||
-            points[n].y+img->height <= 0)
-        {
-             D_DEBUG_AT (CairoDFB_Font,
-                         "  -> Unsupported font format %d!\n", img->format);
-             continue;
-        }
-        
-        if (!scaled_glyph->surface_private) {
-            DFBRectangle *rect;
-            
-            if (x+img->width > 2048) {
-                x = 0;
-                y = h;
-                h = 0;
-            }
-        
-            rects[n].x = x;
-            rects[n].y = y;
-            rects[n].w = img->width;
-            rects[n].h = img->height;
- 
-            x += img->width;
-            h  = MAX (h, img->height);
-            w  = MAX (w, x);
-            
-            /* Remember glyph location */ 
-            rect = malloc (sizeof(DFBRectangle));
-            if (!rect) {
-                _cairo_cache_thaw( scaled_font->glyphs );
-                return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-            }
-            *rect = rects[n];
-            
-            scaled_glyph->surface_private = rect;
-            chars[num_chars++] = scaled_glyph;
-            
-            D_DEBUG_AT (CairoDFB_Font, "  -> loading at %4d,%2d <- rect %p, img %p, entry %p\n",
-                        rects[n].x, rects[n].y, rect, scaled_glyph->surface, scaled_glyph);
-        }
-        else {
-            rects[n] = *((DFBRectangle *)scaled_glyph->surface_private);
-            
-            D_DEBUG_AT (CairoDFB_Font, "  -> exists at  %4d,%2d\n", rects[n].x, rects[n].y);
-        }
-            
-        n++;
+	cairo_scaled_glyph_t  *scaled_glyph;
+	cairo_image_surface_t *img;
+
+	D_DEBUG_AT (CairoDFB_Font, "  -> [%2d] = %4lu\n", i, glyphs[i].index );
+
+	status = _cairo_scaled_glyph_lookup (scaled_font, glyphs[i].index,
+					  CAIRO_SCALED_GLYPH_INFO_SURFACE,
+					  &scaled_glyph);
+	if (status) {
+	    _cairo_cache_thaw (scaled_font->glyphs);
+	    return status;
+	}
+
+	img = scaled_glyph->surface;
+	switch (img->format) {
+	case CAIRO_FORMAT_A1:
+	case CAIRO_FORMAT_A8:
+	case CAIRO_FORMAT_ARGB32:
+	    break;
+	default:
+	    D_DEBUG_AT (CairoDFB_Font,
+			"  -> Unsupported font format %d!\n", img->format);
+	    _cairo_cache_thaw (scaled_font->glyphs);
+	    return CAIRO_INT_STATUS_UNSUPPORTED;
+	}
+
+	points[n].x = _cairo_lround (glyphs[i].x - img->base.device_transform.x0);
+	points[n].y = _cairo_lround (glyphs[i].y - img->base.device_transform.y0);
+
+	//        D_DEBUG_AT (CairoDFB_Font, "            (%4d,%4d) [%2d]\n", points[n].x, points[n].y, n );
+
+	if (points[n].x >= surface->width  ||
+	    points[n].y >= surface->height ||
+	    points[n].x+img->width  <= 0   ||
+	    points[n].y+img->height <= 0)
+	{
+	    D_DEBUG_AT (CairoDFB_Font,
+			"  -> Unsupported font format %d!\n", img->format);
+	    continue;
+	}
+
+	if (scaled_glyph->surface_private == NULL) {
+	    DFBRectangle *rect;
+
+	    if (x+img->width > 2048) {
+		x = 0;
+		y = h;
+		h = 0;
+	    }
+
+	    rects[n].x = x;
+	    rects[n].y = y;
+	    rects[n].w = img->width;
+	    rects[n].h = img->height;
+
+	    x += img->width;
+	    h  = MAX (h, img->height);
+	    w  = MAX (w, x);
+
+	    /* Remember glyph location */
+	    rect = malloc (sizeof (DFBRectangle));
+	    if (rect == NULL) {
+		_cairo_cache_thaw (scaled_font->glyphs);
+		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	    }
+	    *rect = rects[n];
+
+	    scaled_glyph->surface_private = rect;
+	    chars[num_chars++] = scaled_glyph;
+
+	    D_DEBUG_AT (CairoDFB_Font, "  -> loading at %4d,%2d <- rect %p, img %p, entry %p\n",
+			rects[n].x, rects[n].y, rect, scaled_glyph->surface, scaled_glyph);
+	} else {
+	    rects[n] = *(DFBRectangle *) scaled_glyph->surface_private;
+
+	    D_DEBUG_AT (CairoDFB_Font, "  -> exists at  %4d,%2d\n", rects[n].x, rects[n].y);
+	}
+
+	n++;
     }
-    
-    if (!n) {
-        _cairo_cache_thaw( scaled_font->glyphs );
-        return CAIRO_INT_STATUS_NOTHING_TO_DO;
+
+    if (n == 0) {
+	_cairo_cache_thaw (scaled_font->glyphs);
+	return CAIRO_INT_STATUS_NOTHING_TO_DO;
     }
-    
+
     h += y;
     w = MAX (w, 8);
     h = MAX (h, 8);
-     
+
     if (cache) {
-        if (cache->width < w || cache->height < h) {
-            cairo_directfb_font_cache_t *new_cache;
+	if (cache->width < w || cache->height < h) {
+	    cairo_directfb_font_cache_t *new_cache;
 
-            w = MAX (w, cache->width);
-            h = MAX (h, cache->height);
+	    w = MAX (w, cache->width);
+	    h = MAX (h, cache->height);
 
-            D_DEBUG_AT (CairoDFB_Font, "  -> Reallocating font cache (%dx%d).\n", w, h);
+	    D_DEBUG_AT (CairoDFB_Font, "  -> Reallocating font cache (%dx%d).\n", w, h);
 
-            status = _directfb_allocate_font_cache (surface->dfb,
+	    status = _directfb_allocate_font_cache (surface->dfb,
 						    w, h,
 						    &new_cache);
-            if (status) {
-                _cairo_cache_thaw (scaled_font->glyphs);
-                return status;
-            }
+	    if (status) {
+		_cairo_cache_thaw (scaled_font->glyphs);
+		return status;
+	    }
 
-            new_cache->dfbsurface->Blit (new_cache->dfbsurface,
-                                         cache->dfbsurface, NULL, 0, 0);
+	    new_cache->dfbsurface->Blit (new_cache->dfbsurface,
+					 cache->dfbsurface, NULL, 0, 0);
 
-            _directfb_destroy_font_cache (cache);
-            scaled_font->surface_private = cache = new_cache;
-        }
-    }
-    else {
-        D_DEBUG_AT (CairoDFB_Font, "  -> Allocating font cache (%dx%d).\n", w, h);
+	    _directfb_destroy_font_cache (cache);
+	    scaled_font->surface_private = cache = new_cache;
+	}
+    } else {
+	D_DEBUG_AT (CairoDFB_Font, "  -> Allocating font cache (%dx%d).\n", w, h);
 
-        status = _directfb_allocate_font_cache (surface->dfb, w, h, &cache);
-        if (status) {
-            _cairo_cache_thaw (scaled_font->glyphs);
-            return status;
-        }
+	status = _directfb_allocate_font_cache (surface->dfb, w, h, &cache);
+	if (status) {
+	    _cairo_cache_thaw (scaled_font->glyphs);
+	    return status;
+	}
 
-        scaled_font->surface_backend = &cairo_directfb_surface_backend;
-        scaled_font->surface_private = cache;
+	scaled_font->surface_backend = &cairo_directfb_surface_backend;
+	scaled_font->surface_private = cache;
     }
-    
+
     if (num_chars) {
-        unsigned char *data;
-        int            pitch;
-    
-        if (cache->dfbsurface->Lock (cache->dfbsurface, 
-                                     DSLF_WRITE, (void *)&data, &pitch))
-        {
-            _cairo_cache_thaw( scaled_font->glyphs );
-            return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-        }
-            
-        D_DEBUG_AT (CairoDFB_Font, "  => %d chars to load, cache %dx%d\n", num_chars, cache->width, cache->height);
-
-        for (i = 0; i < num_chars; i++) {
-            cairo_image_surface_t *img  = chars[i]->surface;
-            DFBRectangle          *rect = chars[i]->surface_private;
-            unsigned char         *dst  = data;
-            unsigned char         *src;
-            int                    j;
-            
-            D_DEBUG_AT (CairoDFB_Font, "  -> loading [%2d] <- rect %p, img %p, entry %p\n", i, rect, img, chars[i]);
-
-            src = img->data;
-
-            D_DEBUG_AT (CairoDFB_Font, "     from %p\n", src);
-
-            dst += rect->y * pitch + (_directfb_argb_font ? (rect->x<<2) : rect->x);
-                        
-            D_DEBUG_AT (CairoDFB_Font, "     to %4d,%2d (%p)\n", rect->x, rect->y, dst);
-
-            if (img->format == CAIRO_FORMAT_A1) {
-                for (h = rect->h; h; h--) {
-                    if (_directfb_argb_font) {
-                        for (j = 0; j < rect->w; j++)
-                            ((uint32_t *)dst)[j] = (src[j>>3] & (1 << (j&7))) ? 0xffffffff : 0;
-                    }
-                    else {
-                        for (j = 0; j < rect->w; j++)
-                            dst[j] = (src[j>>3] & (1 << (j&7))) ? 0xff : 0;
-                    }
-                    
-                    dst += pitch;
-                    src += img->stride;
-                }
-            }
-            else if (img->format == CAIRO_FORMAT_A8) {
-                for (h = rect->h; h; h--) {
-                    if (_directfb_argb_font) {
-                        for (j = 0; j < rect->w; j++)
-                            ((uint32_t *)dst)[j] = src[j] * 0x01010101;
-                    }
-                    else {
-                        direct_memcpy (dst, src, rect->w);
-                    }
-                    
-                    dst += pitch;
-                    src += img->stride;
-                }
-            }
-            else { /* ARGB32 */
-                for (h = rect->h; h; h--) {
-                    if (_directfb_argb_font) {
-                        direct_memcpy (dst, src, rect->w<<2);
-                    }
-                    else {
-                        for (j = 0; j < rect->w; j++)
-                            dst[j] = ((uint32_t *)src)[j] >> 24;
-                    }
-                    
-                    dst += pitch;
-                    src += img->stride;
-                }
-            }
-        }
-        
-        cache->dfbsurface->Unlock (cache->dfbsurface);
+	unsigned char *data;
+	int            pitch;
+
+	if (cache->dfbsurface->Lock (cache->dfbsurface,
+				     DSLF_WRITE, (void *)&data, &pitch))
+	{
+	    _cairo_cache_thaw (scaled_font->glyphs);
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	}
+
+	D_DEBUG_AT (CairoDFB_Font, "  => %d chars to load, cache %dx%d\n", num_chars, cache->width, cache->height);
+
+	for (i = 0; i < num_chars; i++) {
+	    cairo_image_surface_t *img  = chars[i]->surface;
+	    DFBRectangle          *rect = chars[i]->surface_private;
+	    unsigned char         *dst  = data;
+	    unsigned char         *src;
+	    int                    j;
+
+	    D_DEBUG_AT (CairoDFB_Font, "  -> loading [%2d] <- rect %p, img %p, entry %p\n", i, rect, img, chars[i]);
+
+	    src = img->data;
+
+	    D_DEBUG_AT (CairoDFB_Font, "     from %p\n", src);
+
+	    dst += rect->y * pitch + (_directfb_argb_font ? (rect->x<<2) : rect->x);
+
+	    D_DEBUG_AT (CairoDFB_Font, "     to %4d,%2d (%p)\n", rect->x, rect->y, dst);
+
+	    if (img->format == CAIRO_FORMAT_A1) {
+		for (h = rect->h; h; h--) {
+		    if (_directfb_argb_font) {
+			for (j = 0; j < rect->w; j++)
+			    ((uint32_t *) dst)[j] = (src[j>>3] & (1 << (j&7))) ? 0xffffffff : 0;
+		    } else {
+			for (j = 0; j < rect->w; j++)
+			    dst[j] = (src[j>>3] & (1 << (j&7))) ? 0xff : 0;
+		    }
+
+		    dst += pitch;
+		    src += img->stride;
+		}
+	    } else if (img->format == CAIRO_FORMAT_A8) {
+		for (h = rect->h; h; h--) {
+		    if (_directfb_argb_font) {
+			for (j = 0; j < rect->w; j++)
+			    ((uint32_t *) dst)[j] = src[j] * 0x01010101;
+		    } else {
+			direct_memcpy (dst, src, rect->w);
+		    }
+
+		    dst += pitch;
+		    src += img->stride;
+		}
+	    } else { /* ARGB32 */
+		for (h = rect->h; h; h--) {
+		    if (_directfb_argb_font) {
+			direct_memcpy (dst, src, rect->w<<2);
+		    } else {
+			for (j = 0; j < rect->w; j++)
+			    dst[j] = ((uint32_t *) src)[j] >> 24;
+		    }
+
+		    dst += pitch;
+		    src += img->stride;
+		}
+	    }
+	}
+
+	cache->dfbsurface->Unlock (cache->dfbsurface);
     }
 
-    _cairo_cache_thaw( scaled_font->glyphs );
+    _cairo_cache_thaw (scaled_font->glyphs);
 
     cache->x = x;
     cache->y = y;
-    
+
     D_DEBUG_AT (CairoDFB_Font, "  => cache %d,%d, %p [%d]\n", x, y, cache, n);
 
     *ret_cache = cache;
@@ -1599,13 +1587,13 @@ static void
 _cairo_directfb_surface_scaled_font_fini (cairo_scaled_font_t *scaled_font)
 {
     cairo_directfb_font_cache_t *cache = scaled_font->surface_private;
-    
+
     D_DEBUG_AT (CairoDFB_Font,
-                "%s( scaled_font=%p ).\n", __FUNCTION__, scaled_font);
-    
-    if (cache) {
-        _directfb_destroy_font_cache (cache);
-        scaled_font->surface_private = NULL;
+		"%s( scaled_font=%p ).\n", __FUNCTION__, scaled_font);
+
+    if (cache != NULL) {
+	_directfb_destroy_font_cache (cache);
+	scaled_font->surface_private = NULL;
     }
 }
 
@@ -1617,7 +1605,7 @@ _cairo_directfb_surface_scaled_glyph_fini (cairo_scaled_glyph_t *scaled_glyph,
                  "%s( scaled_glyph=%p, scaled_font=%p ).\n",
                  __FUNCTION__, scaled_glyph, scaled_font);
 
-     if (scaled_glyph->surface_private) {
+     if (scaled_glyph->surface_private != NULL) {
           free (scaled_glyph->surface_private);
           scaled_glyph->surface_private = NULL;
      }
@@ -1634,7 +1622,7 @@ _cairo_directfb_surface_show_glyphs (void                *abstract_dst,
 {
     cairo_directfb_surface_t    *dst = abstract_dst;
     cairo_directfb_font_cache_t *cache;
-    cairo_status_t               ret;
+    cairo_status_t               status;
     DFBSurfaceBlittingFlags      flags;
     DFBSurfaceBlendFunction      sblend;
     DFBSurfaceBlendFunction      dblend;
@@ -1642,54 +1630,56 @@ _cairo_directfb_surface_show_glyphs (void                *abstract_dst,
     DFBRectangle                 rects[num_glyphs];
     DFBPoint                     points[num_glyphs];
     int                          num;
-    
+
     D_DEBUG_AT (CairoDFB_Font,
-                "%s( dst=%p, op=%d, pattern=%p, glyphs=%p, num_glyphs=%d, scaled_font=%p ).\n",
-                __FUNCTION__, dst, op, pattern, glyphs, num_glyphs, scaled_font);
-                            
+		"%s( dst=%p, op=%d, pattern=%p, glyphs=%p, num_glyphs=%d, scaled_font=%p ).\n",
+		__FUNCTION__, dst, op, pattern, glyphs, num_glyphs, scaled_font);
+
     if (pattern->type != CAIRO_PATTERN_TYPE_SOLID)
-        return CAIRO_INT_STATUS_UNSUPPORTED;
-        
+	return CAIRO_INT_STATUS_UNSUPPORTED;
+
     if (! _directfb_get_operator (op, &sblend, &dblend) ||
-        sblend == DSBF_DESTALPHA || sblend == DSBF_INVDESTALPHA) 
-        return CAIRO_INT_STATUS_UNSUPPORTED;
-        
-    ret = _directfb_acquire_font_cache (dst, scaled_font, glyphs, num_glyphs,
-                                        &cache, &rects[0], &points[0], &num);
-    if (ret) {
-        if (ret == CAIRO_INT_STATUS_NOTHING_TO_DO)
-            ret = CAIRO_STATUS_SUCCESS;
-        return ret;
+	sblend == DSBF_DESTALPHA || sblend == DSBF_INVDESTALPHA)
+    {
+	return CAIRO_INT_STATUS_UNSUPPORTED;
+    }
+
+    status = _directfb_acquire_font_cache (dst, scaled_font, glyphs, num_glyphs,
+					   &cache, &rects[0], &points[0], &num);
+    if (status) {
+	if (status == CAIRO_INT_STATUS_NOTHING_TO_DO)
+	    status = CAIRO_STATUS_SUCCESS;
+	return status;
     }
-        
-    color.a = ((cairo_solid_pattern_t *)pattern)->color.alpha_short >> 8;
-    color.r = ((cairo_solid_pattern_t *)pattern)->color.red_short   >> 8;
-    color.g = ((cairo_solid_pattern_t *)pattern)->color.green_short >> 8;
-    color.b = ((cairo_solid_pattern_t *)pattern)->color.blue_short  >> 8;
-    
+
+    color.a = ((cairo_solid_pattern_t *) pattern)->color.alpha_short >> 8;
+    color.r = ((cairo_solid_pattern_t *) pattern)->color.red_short   >> 8;
+    color.g = ((cairo_solid_pattern_t *) pattern)->color.green_short >> 8;
+    color.b = ((cairo_solid_pattern_t *) pattern)->color.blue_short  >> 8;
+
     flags = DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_COLORIZE;
     if (color.a != 0xff)
-        flags |= DSBLIT_BLEND_COLORALPHA;
-        
+	flags |= DSBLIT_BLEND_COLORALPHA;
+
     if (!_directfb_argb_font) {
-        if (sblend == DSBF_ONE) {
-            sblend = DSBF_SRCALPHA;
-            if (dblend == DSBF_ZERO)
-                dblend = DSBF_INVSRCALPHA;
-        }
-    } 
-        
+	if (sblend == DSBF_ONE) {
+	    sblend = DSBF_SRCALPHA;
+	    if (dblend == DSBF_ZERO)
+		dblend = DSBF_INVSRCALPHA;
+	}
+    }
+
     dst->dfbsurface->SetBlittingFlags (dst->dfbsurface, flags);
     dst->dfbsurface->SetSrcBlendFunction (dst->dfbsurface, sblend);
     dst->dfbsurface->SetDstBlendFunction (dst->dfbsurface, dblend);
     dst->dfbsurface->SetColor (dst->dfbsurface, color.r, color.g, color.b, color.a);
-    
+
     D_DEBUG_AT (CairoDFB_Font, "Running BatchBlit().\n");
-        
+
     RUN_CLIPPED (dst, NULL,
-                 dst->dfbsurface->BatchBlit (dst->dfbsurface,
-                                         cache->dfbsurface, rects, points, num));
-        
+		 dst->dfbsurface->BatchBlit (dst->dfbsurface,
+					     cache->dfbsurface, rects, points, num));
+
     return CAIRO_STATUS_SUCCESS;
 }
 #endif /* DFB_SHOW_GLYPHS */
@@ -1711,7 +1701,7 @@ static cairo_surface_backend_t cairo_directfb_surface_backend = {
         _cairo_directfb_surface_acquire_source_image,/*acquire_source_image*/
         _cairo_directfb_surface_release_source_image,/*release_source_image*/
         _cairo_directfb_surface_acquire_dest_image,/*acquire_dest_image*/
-        _cairo_directfb_surface_release_dest_image,/*release_dest_image*/ 
+        _cairo_directfb_surface_release_dest_image,/*release_dest_image*/
         _cairo_directfb_surface_clone_similar,/*clone_similar*/
 #if DFB_COMPOSITE
         _cairo_directfb_surface_composite,/*composite*/
@@ -1763,51 +1753,49 @@ static void
 cairo_directfb_surface_backend_init (IDirectFB *dfb)
 {
     static int done = 0;
-    
+
     if (done)
-        return;
-        
+	return;
+
     if (getenv ("CAIRO_DIRECTFB_NO_ACCEL")) {
 #if DFB_RECTANGLES
-        cairo_directfb_surface_backend.fill_rectangles = NULL;
+	cairo_directfb_surface_backend.fill_rectangles = NULL;
 #endif
 #if DFB_COMPOSITE
-        cairo_directfb_surface_backend.composite = NULL;
+	cairo_directfb_surface_backend.composite = NULL;
 #endif
 #if DFB_COMPOSITE_TRAPEZOIDS
-        cairo_directfb_surface_backend.composite_trapezoids = NULL;
+	cairo_directfb_surface_backend.composite_trapezoids = NULL;
 #endif
 #if DFB_SHOW_GLYPHS
-        cairo_directfb_surface_backend.scaled_font_fini = NULL;
-        cairo_directfb_surface_backend.scaled_glyph_fini = NULL;
-        cairo_directfb_surface_backend.show_glyphs = NULL;
+	cairo_directfb_surface_backend.scaled_font_fini = NULL;
+	cairo_directfb_surface_backend.scaled_glyph_fini = NULL;
+	cairo_directfb_surface_backend.show_glyphs = NULL;
 #endif
-        D_DEBUG_AT (CairoDFB_Surface, "Acceleration disabled.\n");
-    }
-    else {
-        DFBGraphicsDeviceDescription dsc;
-        
-        dfb->GetDeviceDescription (dfb, &dsc);
-    
+	D_DEBUG_AT (CairoDFB_Surface, "Acceleration disabled.\n");
+    } else {
+	DFBGraphicsDeviceDescription dsc;
+
+	dfb->GetDeviceDescription (dfb, &dsc);
+
 #if DFB_COMPOSITE
-//        if (!(dsc.acceleration_mask & DFXL_BLIT))
-//            cairo_directfb_surface_backend.composite = NULL;
+	//        if (!(dsc.acceleration_mask & DFXL_BLIT))
+	//            cairo_directfb_surface_backend.composite = NULL;
 #endif
 
 #if DFB_COMPOSITE_TRAPEZOIDS
-//        if (!(dsc.acceleration_mask & DFXL_TEXTRIANGLES))
-//            cairo_directfb_surface_backend.composite_trapezoids = NULL;
+	//        if (!(dsc.acceleration_mask & DFXL_TEXTRIANGLES))
+	//            cairo_directfb_surface_backend.composite_trapezoids = NULL;
 #endif
     }
-    
+
     if (getenv ("CAIRO_DIRECTFB_ARGB_FONT")) {
-        _directfb_argb_font = 1;
-        D_DEBUG_AT (CairoDFB_Surface, "Using ARGB fonts.\n");
+	_directfb_argb_font = 1;
+	D_DEBUG_AT (CairoDFB_Surface, "Using ARGB fonts.\n");
     }
 
     done = 1;
-}   
-
+}
 
 cairo_surface_t *
 cairo_directfb_surface_create (IDirectFB *dfb, IDirectFBSurface *dfbsurface)
@@ -1820,7 +1808,7 @@ cairo_directfb_surface_create (IDirectFB *dfb, IDirectFBSurface *dfbsurface)
 
     cairo_directfb_surface_backend_init (dfb);
 
-    surface = calloc (1, sizeof(cairo_directfb_surface_t));
+    surface = calloc (1, sizeof (cairo_directfb_surface_t));
     if (surface == NULL)
         return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
 
commit d49563280b80dd85275057b6442d2f4ece8d724c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 12:49:52 2008 +0100

    [directfb] Simplify return from _directfb_get_operator().
    
    Used only as a predicate, so simply return a boolean.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 5bcd62a..887e72e 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -226,81 +226,79 @@ _directfb_to_cairo_format (DFBSurfacePixelFormat format)
 }
 
 
-static cairo_status_t
+static cairo_bool_t
 _directfb_get_operator (cairo_operator_t         operator,
                         DFBSurfaceBlendFunction *ret_srcblend,
-                        DFBSurfaceBlendFunction *ret_dstblend )
+                        DFBSurfaceBlendFunction *ret_dstblend)
 {
     DFBSurfaceBlendFunction srcblend = DSBF_ONE;
     DFBSurfaceBlendFunction dstblend = DSBF_ZERO;
-    
+
     switch (operator) {
-        case CAIRO_OPERATOR_CLEAR:
-            srcblend = DSBF_ZERO;
-            dstblend = DSBF_ZERO;
-            break;
-        case CAIRO_OPERATOR_SOURCE:
-            srcblend = DSBF_ONE;
-            dstblend = DSBF_ZERO;
-            break;
-        case CAIRO_OPERATOR_OVER:
-            srcblend = DSBF_ONE;
-            dstblend = DSBF_INVSRCALPHA;
-            break;
-        case CAIRO_OPERATOR_IN:
-            srcblend = DSBF_DESTALPHA;
-            dstblend = DSBF_ZERO;
-            break;
-        case CAIRO_OPERATOR_OUT:
-            srcblend = DSBF_INVDESTALPHA;
-            dstblend = DSBF_ZERO;
-            break;
-        case CAIRO_OPERATOR_ATOP:
-            srcblend = DSBF_DESTALPHA;
-            dstblend = DSBF_INVSRCALPHA;
-            break;
-        case CAIRO_OPERATOR_DEST:
-            srcblend = DSBF_ZERO;
-            dstblend = DSBF_ONE;
-            break;
-        case CAIRO_OPERATOR_DEST_OVER:
-            srcblend = DSBF_INVDESTALPHA;
-            dstblend = DSBF_ONE;
-            break;
-        case CAIRO_OPERATOR_DEST_IN:
-            srcblend = DSBF_ZERO;
-            dstblend = DSBF_SRCALPHA;
-            break;
-        case CAIRO_OPERATOR_DEST_OUT:
-            srcblend = DSBF_ZERO;
-            dstblend = DSBF_INVSRCALPHA;
-            break;
-        case CAIRO_OPERATOR_DEST_ATOP:
-            srcblend = DSBF_INVDESTALPHA;
-            dstblend = DSBF_SRCALPHA;
-            break;                        
-        case CAIRO_OPERATOR_XOR:
-            srcblend = DSBF_INVDESTALPHA;
-            dstblend = DSBF_INVSRCALPHA;
-            break;
-        case CAIRO_OPERATOR_ADD:
-            srcblend = DSBF_ONE;
-            dstblend = DSBF_ONE;
-            break;
-        case CAIRO_OPERATOR_SATURATE:
-            srcblend = DSBF_SRCALPHASAT;
-            dstblend = DSBF_ONE;
-            break;
-        default:
-            return CAIRO_INT_STATUS_UNSUPPORTED;
+    case CAIRO_OPERATOR_CLEAR:
+	srcblend = DSBF_ZERO;
+	dstblend = DSBF_ZERO;
+	break;
+    case CAIRO_OPERATOR_SOURCE:
+	srcblend = DSBF_ONE;
+	dstblend = DSBF_ZERO;
+	break;
+    case CAIRO_OPERATOR_OVER:
+	srcblend = DSBF_ONE;
+	dstblend = DSBF_INVSRCALPHA;
+	break;
+    case CAIRO_OPERATOR_IN:
+	srcblend = DSBF_DESTALPHA;
+	dstblend = DSBF_ZERO;
+	break;
+    case CAIRO_OPERATOR_OUT:
+	srcblend = DSBF_INVDESTALPHA;
+	dstblend = DSBF_ZERO;
+	break;
+    case CAIRO_OPERATOR_ATOP:
+	srcblend = DSBF_DESTALPHA;
+	dstblend = DSBF_INVSRCALPHA;
+	break;
+    case CAIRO_OPERATOR_DEST:
+	srcblend = DSBF_ZERO;
+	dstblend = DSBF_ONE;
+	break;
+    case CAIRO_OPERATOR_DEST_OVER:
+	srcblend = DSBF_INVDESTALPHA;
+	dstblend = DSBF_ONE;
+	break;
+    case CAIRO_OPERATOR_DEST_IN:
+	srcblend = DSBF_ZERO;
+	dstblend = DSBF_SRCALPHA;
+	break;
+    case CAIRO_OPERATOR_DEST_OUT:
+	srcblend = DSBF_ZERO;
+	dstblend = DSBF_INVSRCALPHA;
+	break;
+    case CAIRO_OPERATOR_DEST_ATOP:
+	srcblend = DSBF_INVDESTALPHA;
+	dstblend = DSBF_SRCALPHA;
+	break;
+    case CAIRO_OPERATOR_XOR:
+	srcblend = DSBF_INVDESTALPHA;
+	dstblend = DSBF_INVSRCALPHA;
+	break;
+    case CAIRO_OPERATOR_ADD:
+	srcblend = DSBF_ONE;
+	dstblend = DSBF_ONE;
+	break;
+    case CAIRO_OPERATOR_SATURATE:
+	srcblend = DSBF_SRCALPHASAT;
+	dstblend = DSBF_ONE;
+	break;
+    default:
+	return FALSE;
     }
 
-    if (ret_srcblend)
-        *ret_srcblend = srcblend;
-    if (ret_dstblend)
-        *ret_dstblend = dstblend;
-    
-    return CAIRO_STATUS_SUCCESS;
+    *ret_srcblend = srcblend;
+    *ret_dstblend = dstblend;
+
+    return TRUE;
 }
 
 static cairo_status_t
@@ -723,7 +721,7 @@ _directfb_prepare_composite (cairo_directfb_surface_t    *dst,
     DFBSurfaceBlendFunction     dblend;
     DFBColor                    color;
     
-    if (_directfb_get_operator (op, &sblend, &dblend))
+    if (! _directfb_get_operator (op, &sblend, &dblend))
         return CAIRO_INT_STATUS_UNSUPPORTED;
      
     if (mask_pattern) {
@@ -1041,7 +1039,7 @@ _cairo_directfb_surface_fill_rectangles (void                  *abstract_surface
                 "%s( dst=%p, op=%d, color=%p, rects=%p, n_rects=%d ).\n",
                 __FUNCTION__, dst, op, color, rects, n_rects);
 
-    if (_directfb_get_operator (op, &sblend, &dblend))
+    if (! _directfb_get_operator (op, &sblend, &dblend))
         return CAIRO_INT_STATUS_UNSUPPORTED;
         
     if (color->alpha_short >= 0xff00) {
@@ -1652,7 +1650,7 @@ _cairo_directfb_surface_show_glyphs (void                *abstract_dst,
     if (pattern->type != CAIRO_PATTERN_TYPE_SOLID)
         return CAIRO_INT_STATUS_UNSUPPORTED;
         
-    if (_directfb_get_operator (op, &sblend, &dblend) ||
+    if (! _directfb_get_operator (op, &sblend, &dblend) ||
         sblend == DSBF_DESTALPHA || sblend == DSBF_INVDESTALPHA) 
         return CAIRO_INT_STATUS_UNSUPPORTED;
         
commit b17d0ded8cd42d84e97ca2c1fbd4aefedd570b8e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 12:48:02 2008 +0100

    [directfb] Use the solid pattern cache.
    
    The dfb backend recreated a solid color surface for every colour,
    completely bypassing the solid pattern cache.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 368ecac..5bcd62a 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -84,26 +84,23 @@ typedef struct _cairo_directfb_surface {
     cairo_surface_t      base;
     cairo_format_t       format;
     cairo_content_t      content;
-    
+
     IDirectFB           *dfb;
     IDirectFBSurface    *dfbsurface;
     IDirectFBSurface    *tmpsurface;
-    
-    /* color buffer */
-    cairo_surface_t     *color;
-        
+
     DFBRegion           *clips;
     int                  n_clips;
-    
+
     int                  width;
     int                  height;
-    
+
     cairo_bool_t         local;
 } cairo_directfb_surface_t;
 
 
 typedef struct _cairo_directfb_font_cache {
-    IDirectFB           *dfb; 
+    IDirectFB           *dfb;
     IDirectFBSurface    *dfbsurface;
 
     int                  width;
@@ -511,20 +508,15 @@ static cairo_status_t
 _cairo_directfb_surface_finish (void *data)
 {
     cairo_directfb_surface_t *surface = (cairo_directfb_surface_t *)data;
-    
+
     D_DEBUG_AT (CairoDFB_Surface, "%s( surface=%p ).\n", __FUNCTION__, surface);
-        
+
     if (surface->clips) {
         free (surface->clips);
         surface->clips   = NULL;
         surface->n_clips = 0;
     }
-    
-    if (surface->color) {
-        cairo_surface_destroy (surface->color);
-        surface->color = NULL;
-    }
-    
+
     if (surface->tmpsurface) {
         surface->tmpsurface->Release (surface->tmpsurface);
         surface->tmpsurface = NULL;
@@ -534,10 +526,10 @@ _cairo_directfb_surface_finish (void *data)
         surface->dfbsurface->Release (surface->dfbsurface);
         surface->dfbsurface = NULL;
     }
-    
+
     if (surface->dfb)
         surface->dfb = NULL;
-        
+
     return CAIRO_STATUS_SUCCESS;
 }
 
@@ -771,40 +763,13 @@ _directfb_prepare_composite (cairo_directfb_surface_t    *dst,
     else {
         color.a = color.r = color.g = color.b = 0xff;
     }
-        
-    if (src_pattern->type == CAIRO_PATTERN_TYPE_SOLID) {
-        cairo_solid_pattern_t *pattern = (cairo_solid_pattern_t *)src_pattern;
-         
-        if (!dst->color) {
-            dst->color = _cairo_directfb_surface_create_similar (dst,
-                                                CAIRO_CONTENT_COLOR_ALPHA, 1, 1);
-            if (dst->color == NULL)
-		return CAIRO_INT_STATUS_UNSUPPORTED;
-	    if (dst->color->status)
-		return dst->color->status;
-        }
-        
-        src = (cairo_directfb_surface_t *)dst->color;
-        src->dfbsurface->Clear (src->dfbsurface,
-                                pattern->color.red_short   >> 8,
-                                pattern->color.green_short >> 8,
-                                pattern->color.blue_short  >> 8,
-                                pattern->color.alpha_short >> 8);
-                                  
-        src_attr.matrix   = src_pattern->matrix;
-        src_attr.extend   = CAIRO_EXTEND_NONE;
-        src_attr.filter   = CAIRO_FILTER_NEAREST;
-        src_attr.x_offset =
-        src_attr.y_offset = 0;
-    }
-    else {
-        ret = _cairo_pattern_acquire_surface (src_pattern, &dst->base,
-                                              *src_x, *src_y, width, height,
-                                              (cairo_surface_t **)&src, &src_attr);
-        if (ret)
-            return ret;
-    }
-    
+
+    ret = _cairo_pattern_acquire_surface (src_pattern, &dst->base,
+					  *src_x, *src_y, width, height,
+					  (cairo_surface_t **)&src, &src_attr);
+    if (ret)
+	return ret;
+
     if (src->content == CAIRO_CONTENT_COLOR) {
         if (sblend == DSBF_SRCALPHA)
             sblend = DSBF_ONE;
@@ -857,8 +822,7 @@ _directfb_finish_composite (cairo_directfb_surface_t   *dst,
                             cairo_surface_t            *src,
                             cairo_surface_attributes_t *src_attr)
 {
-    if (src != dst->color)
-         _cairo_pattern_release_surface (src_pattern, src, src_attr);
+    _cairo_pattern_release_surface (src_pattern, src, src_attr);
 }
 #endif /* DFB_COMPOSITE || DFB_COMPOSITE_TRAPEZOIDS */        
 
commit 786bea48df0dc6d76b2ad00409804a803fe2f4b6
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Oct 20 12:19:50 2008 +0100

    [boilerplate/directfb] Create ARGB surfaces on demand.
    
    Create an RGB or ARGB surface depending upon the content type of the test
    target, with the result that the directfb rgb24 target no longer
    unconditionally fails.

diff --git a/boilerplate/cairo-boilerplate-directfb.c b/boilerplate/cairo-boilerplate-directfb.c
index f0c96a0..7a6462f 100644
--- a/boilerplate/cairo-boilerplate-directfb.c
+++ b/boilerplate/cairo-boilerplate-directfb.c
@@ -109,18 +109,18 @@ _cairo_boilerplate_directfb_window_create_surface (DFBInfo		*info,
 		content == CAIRO_CONTENT_COLOR_ALPHA ? "ARGB"  : "unknown content!",
 		width, height);
 
-    desc.flags = DWDESC_POSX | DWDESC_POSY |
-	         DWDESC_WIDTH | DWDESC_HEIGHT
-		 /*| DWDESC_CAPS|DSDESC_PIXELFORMAT*/;
+    desc.flags  = DWDESC_POSX | DWDESC_POSY |
+	          DWDESC_WIDTH | DWDESC_HEIGHT;
+    desc.caps   = DSCAPS_NONE;
     desc.posx   = 0;
     desc.posy   = 0;
     desc.width  = width;
     desc.height = height;
-#if 0 /*Test using native format by default*/
-    desc.caps =  DWCAPS_DOUBLEBUFFER;
-    desc.caps |= DWCAPS_ALPHACHANNEL;
-    desc.pixelformat = DSPF_ARGB;
-#endif
+    if (content == CAIRO_CONTENT_COLOR_ALPHA) {
+	desc.flags |= DWDESC_CAPS | DSDESC_PIXELFORMAT;
+	desc.caps  |= DWCAPS_DOUBLEBUFFER | DWCAPS_ALPHACHANNEL;
+	desc.pixelformat = DSPF_ARGB;
+    }
 
     DFBCHECK (info->layer->CreateWindow (info->layer, &desc, &info->window));
     info->window->SetOpacity (info->window, 0xFF);
@@ -151,11 +151,14 @@ _cairo_boilerplate_directfb_bitmap_create_surface (DFBInfo		*info,
 		content == CAIRO_CONTENT_COLOR_ALPHA ? "ARGB"  : "unknown content!",
 		width, height);
 
-    desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
+    desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT;
     desc.caps = DSCAPS_NONE;
     desc.width  = width;
     desc.height = height;
-    desc.pixelformat = DSPF_ARGB;
+    if (content == CAIRO_CONTENT_COLOR_ALPHA) {
+	desc.flags |= DSDESC_PIXELFORMAT;
+	desc.pixelformat = DSPF_ARGB;
+    }
     DFBCHECK (info->dfb->CreateSurface (info->dfb, &desc, &info->surface));
 
     return cairo_directfb_surface_create (info->dfb, info->surface);


More information about the cairo-commit mailing list