[cairo-commit] src/cairo-image-surface.c

Carl Worth cworth at kemper.freedesktop.org
Thu Jun 15 14:20:29 PDT 2006


 src/cairo-image-surface.c |   64 ++++++++++++++++++++++++++--------------------
 1 files changed, 37 insertions(+), 27 deletions(-)

New commits:
diff-tree 82496a6f7c5b0a9f91db6abc9e34202b8ffa77c4 (from dedc51ba51eaa61e4b11f274fac06c6f0acd8a87)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Jun 15 14:15:42 2006 -0700

    _cairo_format_from_pixman_format: Add useful error mesage and assertion when failing.

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 4490fa5..c4f0cc4 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -90,34 +90,44 @@ _cairo_format_from_pixman_format (pixman
 
     pixman_format_get_masks (pixman_format, &bpp, &am, &rm, &gm, &bm);
 
-    if (bpp == 32 &&
-	am == 0xff000000 &&
-	rm == 0x00ff0000 &&
-	gm == 0x0000ff00 &&
-	bm == 0x000000ff)
-	return CAIRO_FORMAT_ARGB32;
-
-    if (bpp == 32 &&
-	am == 0x0 &&
-	rm == 0x00ff0000 &&
-	gm == 0x0000ff00 &&
-	bm == 0x000000ff)
-	return CAIRO_FORMAT_RGB24;
-
-    if (bpp == 8 &&
-	am == 0xff &&
-	rm == 0x0 &&
-	gm == 0x0 &&
-	bm == 0x0)
-	return CAIRO_FORMAT_A8;
-
-    if (bpp == 1 &&
-	am == 0x1 &&
-	rm == 0x0 &&
-	gm == 0x0 &&
-	bm == 0x0)
-	return CAIRO_FORMAT_A1;
+    switch (bpp) {
+    case 32:
+	if (am == 0xff000000 &&
+	    rm == 0x00ff0000 &&
+	    gm == 0x0000ff00 &&
+	    bm == 0x000000ff)
+	    return CAIRO_FORMAT_ARGB32;
+	if (am == 0x0 &&
+	    rm == 0x00ff0000 &&
+	    gm == 0x0000ff00 &&
+	    bm == 0x000000ff)
+	    return CAIRO_FORMAT_RGB24;
+    case 8:
+	if (am == 0xff &&
+	    rm == 0x0 &&
+	    gm == 0x0 &&
+	    bm == 0x0)
+	    return CAIRO_FORMAT_A8;
+    case 1:
+	if (am == 0x1 &&
+	    rm == 0x0 &&
+	    gm == 0x0 &&
+	    bm == 0x0)
+	    return CAIRO_FORMAT_A1;
+    }
+
+    fprintf (stderr,
+	     "Error: Cairo does not yet support the requested image format:\n"
+	     "\tDepth: %d\n"
+	     "\tAlpha mask: 0x%08x\n"
+	     "\tRed   mask: 0x%08x\n"
+	     "\tBlue  mask: 0x%08x\n"
+	     "\tGreen mask: 0x%08x\n"
+	     "Please file an enhacement request (quoting the above) at:\n"
+	     PACKAGE_BUGREPORT "\n",
+	     bpp, am, rm, gm, bm);
 
+    ASSERT_NOT_REACHED;
     return (cairo_format_t) -1;
 }
 


More information about the cairo-commit mailing list