Move store logic into pixman-image.c
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Thu, 30 Apr 2009 06:50:18 +0000 (02:50 -0400)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Mon, 4 May 2009 22:55:05 +0000 (18:55 -0400)
pixman/pixman-compose.c
pixman/pixman-image.c
pixman/pixman-private.h

index 701edd4..cdb30a2 100644 (file)
 #define PIXMAN_COMPOSITE_RECT_GENERAL pixman_composite_rect_general_no_accessors
 #endif
 
-static void
-fbStore(bits_image_t * pict, int x, int y, int width, uint32_t *buffer)
-{
-    uint32_t *bits;
-    int32_t stride;
-    storeProc32 store = ACCESS(pixman_storeProcForPicture32)(pict);
-    const pixman_indexed_t * indexed = pict->indexed;
-
-    bits = pict->bits;
-    stride = pict->rowstride;
-    bits += y*stride;
-    store((pixman_image_t *)pict, bits, buffer, x, width, indexed);
-}
-
-static void
-fbStore64(bits_image_t * pict, int x, int y, int width, uint64_t *buffer)
-{
-    uint32_t *bits;
-    int32_t stride;
-    storeProc64 store = ACCESS(pixman_storeProcForPicture64)(pict);
-    const pixman_indexed_t * indexed = pict->indexed;
-
-    bits = pict->bits;
-    stride = pict->rowstride;
-    bits += y*stride;
-    store((pixman_image_t *)pict, bits, buffer, x, width, indexed);
-}
-
-static inline scanStoreProc get_store(const int wide)
-{
-    if (wide)
-       return (scanStoreProc)fbStore64;
-    else
-       return (scanStoreProc)fbStore;
-}
-
-static inline scanStoreProc get_store_external_alpha(const int wide)
-{
-    if (wide)
-       return (scanStoreProc)ACCESS(fbStoreExternalAlpha64);
-    else
-       return (scanStoreProc)ACCESS(fbStoreExternalAlpha);
-}
-
 #ifndef PIXMAN_FB_ACCESSORS
 static
 #endif
@@ -129,27 +85,21 @@ PIXMAN_COMPOSITE_RECT_GENERAL (const FbComposeData *data,
     else
        fetchDest = _pixman_image_get_fetcher (data->dest, wide);
 
-    if (data->dest->common.alpha_map)
-    {
-       store = get_store_external_alpha(wide);
-    }
-    else
-    {
-       store = get_store(wide);
+    store = _pixman_image_get_storer (data->dest, wide);
 
 #ifndef PIXMAN_FB_ACCESSORS
-       // Skip the store step and composite directly into the
-       // destination if the output format of the compose func matches
-       // the destination format.
-       if (!wide &&
-           (data->op == PIXMAN_OP_ADD || data->op == PIXMAN_OP_OVER) &&
-           (data->dest->bits.format == PIXMAN_a8r8g8b8 ||
-            data->dest->bits.format == PIXMAN_x8r8g8b8))
-       {
-           store = NULL;
-       }
-#endif
+    // Skip the store step and composite directly into the
+    // destination if the output format of the compose func matches
+    // the destination format.
+    if (!wide &&
+       !data->dest->common.alpha_map &&
+       (data->op == PIXMAN_OP_ADD || data->op == PIXMAN_OP_OVER) &&
+       (data->dest->bits.format == PIXMAN_a8r8g8b8 ||
+        data->dest->bits.format == PIXMAN_x8r8g8b8))
+    {
+       store = NULL;
     }
+#endif
 
     if (!store)
     {
index cecd02c..4bc47dc 100644 (file)
@@ -274,6 +274,56 @@ _pixman_image_get_fetcher (pixman_image_t *image,
     }
 }
 
+#define WRITE_ACCESS(f) ((image->common.write_func)? f##_accessors : f)
+
+static void
+fbStore(bits_image_t * image, int x, int y, int width, uint32_t *buffer)
+{
+    uint32_t *bits;
+    int32_t stride;
+    storeProc32 store = WRITE_ACCESS(pixman_storeProcForPicture32)(image);
+    const pixman_indexed_t * indexed = image->indexed;
+
+    bits = image->bits;
+    stride = image->rowstride;
+    bits += y*stride;
+    store((pixman_image_t *)image, bits, buffer, x, width, indexed);
+}
+
+static void
+fbStore64(bits_image_t * image, int x, int y, int width, uint64_t *buffer)
+{
+    uint32_t *bits;
+    int32_t stride;
+    storeProc64 store = WRITE_ACCESS(pixman_storeProcForPicture64)(image);
+    const pixman_indexed_t * indexed = image->indexed;
+
+    bits = image->bits;
+    stride = image->rowstride;
+    bits += y*stride;
+    store((pixman_image_t *)image, bits, buffer, x, width, indexed);
+}
+
+scanStoreProc
+_pixman_image_get_storer (pixman_image_t *image,
+                         int             wide)
+{
+    if (image->common.alpha_map)
+    {
+       if (wide)
+           return (scanStoreProc)WRITE_ACCESS(fbStoreExternalAlpha64);
+       else
+           return (scanStoreProc)WRITE_ACCESS(fbStoreExternalAlpha);
+    }
+    else
+    {
+       if (wide)
+           return (scanStoreProc)fbStore64;
+       else
+           return (scanStoreProc)fbStore;
+    }
+}
+
 /* Ref Counting */
 PIXMAN_EXPORT pixman_image_t *
 pixman_image_ref (pixman_image_t *image)
index e7fbb58..4ef915d 100644 (file)
@@ -303,7 +303,9 @@ scanFetchProc
 _pixman_image_get_fetcher (pixman_image_t *image,
                           int             wide);
 
-
+scanStoreProc
+_pixman_image_get_storer (pixman_image_t *image,
+                         int             wide);
 
 struct point
 {