New API: pixman_format_supported_destination and pixman_format_supported_source
authorCarl Worth <cworth@cworth.org>
Tue, 25 Mar 2008 20:12:29 +0000 (13:12 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 25 Mar 2008 20:12:29 +0000 (13:12 -0700)
These functions allow for callers to use the PIXMAN_FORMAT macro to
construct a format code and to then determine if the resulting code
is supported by pixman for either destination or source surfaces.

pixman/pixman-utils.c
pixman/pixman.h

index 73c1cde..d4e4c77 100644 (file)
@@ -407,3 +407,132 @@ pixman_malloc_abc (unsigned int a,
     else
        return malloc (a * b * c);
 }
+
+/**
+ * pixman_format_supported_destination:
+ * @format: A pixman_format_code_t format
+ * 
+ * Return value: whether the provided format code is a supported
+ * format for a pixman surface used as a destination in
+ * rendering.
+ *
+ * Currently, all pixman_format_code_t values are supported
+ * except for the YUV formats.
+ **/
+pixman_bool_t
+pixman_format_supported_destination (pixman_format_code_t format)
+{
+    switch (format) {
+    /* 32 bpp formats */
+    case PIXMAN_a8r8g8b8:
+    case PIXMAN_x8r8g8b8:
+    case PIXMAN_a8b8g8r8:
+    case PIXMAN_x8b8g8r8:
+    case PIXMAN_r8g8b8:
+    case PIXMAN_b8g8r8:
+    case PIXMAN_r5g6b5:
+    case PIXMAN_b5g6r5:
+    /* 16 bpp formats */
+    case PIXMAN_a1r5g5b5:
+    case PIXMAN_x1r5g5b5:
+    case PIXMAN_a1b5g5r5:
+    case PIXMAN_x1b5g5r5:
+    case PIXMAN_a4r4g4b4:
+    case PIXMAN_x4r4g4b4:
+    case PIXMAN_a4b4g4r4:
+    case PIXMAN_x4b4g4r4:
+    /* 8bpp formats */
+    case PIXMAN_a8:
+    case PIXMAN_r3g3b2:
+    case PIXMAN_b2g3r3:
+    case PIXMAN_a2r2g2b2:
+    case PIXMAN_a2b2g2r2:
+    case PIXMAN_c8:
+    case PIXMAN_g8:
+    case PIXMAN_x4a4:
+    case PIXMAN_x4c4:
+    case PIXMAN_x4g4:
+    /* 4bpp formats */
+    case PIXMAN_a4:
+    case PIXMAN_r1g2b1:
+    case PIXMAN_b1g2r1:
+    case PIXMAN_a1r1g1b1:
+    case PIXMAN_a1b1g1r1:
+    case PIXMAN_c4:
+    case PIXMAN_g4:
+    /* 1bpp formats */
+    case PIXMAN_a1:
+    case PIXMAN_g1:
+       return TRUE;
+       
+    /* YUV formats */
+    case PIXMAN_yuy2:
+    case PIXMAN_yv12:
+    default:
+       return FALSE;
+    }
+}
+
+/**
+ * pixman_format_supported_source:
+ * @format: A pixman_format_code_t format
+ * 
+ * Return value: whether the provided format code is a supported
+ * format for a pixman surface used as a source in
+ * rendering.
+ *
+ * Currently, all pixman_format_code_t values are supported.
+ **/
+pixman_bool_t
+pixman_format_supported_source (pixman_format_code_t format)
+{
+    switch (format) {
+    /* 32 bpp formats */
+    case PIXMAN_a8r8g8b8:
+    case PIXMAN_x8r8g8b8:
+    case PIXMAN_a8b8g8r8:
+    case PIXMAN_x8b8g8r8:
+    case PIXMAN_r8g8b8:
+    case PIXMAN_b8g8r8:
+    case PIXMAN_r5g6b5:
+    case PIXMAN_b5g6r5:
+    /* 16 bpp formats */
+    case PIXMAN_a1r5g5b5:
+    case PIXMAN_x1r5g5b5:
+    case PIXMAN_a1b5g5r5:
+    case PIXMAN_x1b5g5r5:
+    case PIXMAN_a4r4g4b4:
+    case PIXMAN_x4r4g4b4:
+    case PIXMAN_a4b4g4r4:
+    case PIXMAN_x4b4g4r4:
+    /* 8bpp formats */
+    case PIXMAN_a8:
+    case PIXMAN_r3g3b2:
+    case PIXMAN_b2g3r3:
+    case PIXMAN_a2r2g2b2:
+    case PIXMAN_a2b2g2r2:
+    case PIXMAN_c8:
+    case PIXMAN_g8:
+    case PIXMAN_x4a4:
+    case PIXMAN_x4c4:
+    case PIXMAN_x4g4:
+    /* 4bpp formats */
+    case PIXMAN_a4:
+    case PIXMAN_r1g2b1:
+    case PIXMAN_b1g2r1:
+    case PIXMAN_a1r1g1b1:
+    case PIXMAN_a1b1g1r1:
+    case PIXMAN_c4:
+    case PIXMAN_g4:
+    /* 1bpp formats */
+    case PIXMAN_a1:
+    case PIXMAN_g1:
+    /* YUV formats */
+    case PIXMAN_yuy2:
+    case PIXMAN_yv12:
+       return TRUE;
+
+    default:
+       return FALSE;
+    }
+}
index c4c5c3b..6a27a3f 100644 (file)
@@ -503,6 +503,13 @@ typedef enum {
     PIXMAN_yv12 =      PIXMAN_FORMAT(12,PIXMAN_TYPE_YV12,0,0,0,0),
 } pixman_format_code_t;
 
+/* Querying supported format values. */
+PIXMAN_EXPORT
+pixman_bool_t  pixman_format_supported_destination (pixman_format_code_t format);
+
+PIXMAN_EXPORT
+pixman_bool_t  pixman_format_supported_source (pixman_format_code_t format);
+
 /* Constructors */
 PIXMAN_EXPORT
 pixman_image_t *pixman_image_create_solid_fill       (pixman_color_t               *color);