[cairo-commit] 3 commits - src/cairo-directfb-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Sun Oct 19 14:40:26 PDT 2008


 src/cairo-directfb-surface.c |   52 +++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 28 deletions(-)

New commits:
commit eab37f76b0f26a7b007dd51debf4d4901310c8b0
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Oct 19 22:12:18 2008 +0100

    [directfb] Return an error surface on create() failure.
    
    Do not return NULL but an NO_MEMORY error surface if we fail to allocate
    the surface during creation.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 78e5183..368ecac 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -1848,31 +1848,30 @@ cairo_directfb_surface_backend_init (IDirectFB *dfb)
 
 
 cairo_surface_t *
-cairo_directfb_surface_create (IDirectFB *dfb, IDirectFBSurface *dfbsurface) 
+cairo_directfb_surface_create (IDirectFB *dfb, IDirectFBSurface *dfbsurface)
 {
     cairo_directfb_surface_t *surface;
     DFBSurfacePixelFormat     format;
-   
+
     D_ASSERT (dfb != NULL);
     D_ASSERT (dfbsurface != NULL);
 
     cairo_directfb_surface_backend_init (dfb);
-        
+
     surface = calloc (1, sizeof(cairo_directfb_surface_t));
-    if (!surface)
-        return NULL;
-     
-    dfbsurface->AddRef (dfbsurface);   
+    if (surface == NULL)
+        return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
+
+    dfbsurface->AddRef (dfbsurface);
     dfbsurface->GetPixelFormat (dfbsurface, &format);
     dfbsurface->GetSize (dfbsurface, &surface->width, &surface->height);
     surface->dfb = dfb;
-    surface->dfbsurface = dfbsurface;  
+    surface->dfbsurface = dfbsurface;
     surface->format = _directfb_to_cairo_format (format);
     surface->content = _directfb_format_to_content (format);
 
-    _cairo_surface_init (&surface->base, 
-                         &cairo_directfb_surface_backend, surface->content);  
+    _cairo_surface_init (&surface->base,
+                         &cairo_directfb_surface_backend, surface->content);
 
     return &surface->base;
 }
-
commit 6a02f53dd191605986b15e4757b16f599fe8de5f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Oct 19 14:21:15 2008 +0100

    [directfb] Simplifiy ADD_TRI
    
    Simplify the ADD_TRI macro to make the code more readable.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index d8ca9b8..78e5183 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -1180,12 +1180,15 @@ _cairo_directfb_surface_composite_trapezoids (cairo_operator_t   op,
         DFBVertex *v = &vertex[0];
         int        n = 0;
 
-#define ADD_TRI(id, x1, y1, s1, t1, x2, y2, s2, t2, x3, y3, s3, t3) {\
+#define ADD_TRI_V(V, X, Y) do { \
+    (V)->x = (X); (V)->y = (Y); (V)->w = 1; (V)->z = (V)->s = (V)->t = 0; \
+} while (0)
+#define ADD_TRI(id, x1, y1, x2, y2, x3, y3) do {\
     const int p = (id)*3;\
-    v[p+0].x=(x1); v[p+0].y=(y1); v[p+0].z=0; v[p+0].w=1; v[p+0].s=(s1); v[p+0].t=(t1);\
-    v[p+1].x=(x2); v[p+1].y=(y2); v[p+1].z=0; v[p+1].w=1; v[p+1].s=(s2); v[p+1].t=(t2);\
-    v[p+2].x=(x3); v[p+2].y=(y3); v[p+2].z=0; v[p+2].w=1; v[p+2].s=(s3); v[p+2].t=(t3);\
-}
+    ADD_TRI_V (v+p+0, x1, y1); \
+    ADD_TRI_V (v+p+1, x2, y2); \
+    ADD_TRI_V (v+p+2, x3, y3); \
+} while (0)
 	while (num_traps--) {
             double lx1, ly1, lx2, ly2;
             double rx1, ry1, rx2, ry2;
@@ -1226,24 +1229,16 @@ _cairo_directfb_surface_composite_trapezoids (cairo_operator_t   op,
             }
 
             if (lx1 == rx1 && ly1 == ry1) {
-                ADD_TRI (0, lx2, ly2, 0, 0,
-                            lx1, ly1, 0, 0,
-                            rx2, ry2, 0, 0 );
+                ADD_TRI (0, lx2, ly2, lx1, ly1, rx2, ry2);
                 v += 3;
                 n += 3;
             } else if (lx2 == rx2 && ly2 == ry2) {
-                ADD_TRI (0, lx1, ly1, 0, 0,
-                            lx2, ly2, 0, 0,
-                            rx1, ry1, 0, 0 );
+                ADD_TRI (0, lx1, ly1, lx2, ly2, rx1, ry1);
                 v += 3;
                 n += 3;
             } else {
-                ADD_TRI (0, lx1, ly1, 0, 0,
-                            rx1, ry1, 0, 0,
-                            lx2, ly2, 0, 0);
-                ADD_TRI (1, lx2, ly2, 0, 0,
-                            rx1, ry1, 0, 0,
-                            rx2, ry2, 0, 0);
+                ADD_TRI (0, lx1, ly1, rx1, ry1, lx2, ly2);
+                ADD_TRI (1, lx2, ly2, rx1, ry1, rx2, ry2);
                 v += 6;
                 n += 6;
             }
@@ -1251,6 +1246,7 @@ _cairo_directfb_surface_composite_trapezoids (cairo_operator_t   op,
             traps++;
         }
 #undef ADD_TRI
+#undef ADD_TRI_V
 
         D_DEBUG_AT (CairoDFB_Render, "Running TextureTriangles().\n");
 
commit aba457fe64f12598043b11ae076f0a93fe05eba7
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Oct 19 14:03:24 2008 +0100

    [directfb] Add missing error status
    
    We jumped to the ERROR path without setting an error status - assume
    NO_MEMORY.

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 6807589..d8ca9b8 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -405,6 +405,7 @@ _directfb_acquire_surface (cairo_directfb_surface_t  *surface,
 
     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);
         goto ERROR;
     }
 


More information about the cairo-commit mailing list