Add #defines etc to compile pixman-compose.c twice
authorSøren Sandmann <sandmann@redhat.com>
Sun, 17 Jun 2007 01:19:51 +0000 (21:19 -0400)
committerSøren Sandmann <sandmann@redhat.com>
Sun, 17 Jun 2007 01:19:51 +0000 (21:19 -0400)
TODO
pixman/Makefile.am
pixman/pixman-compose.c
pixman/pixman-mmx.c
pixman/pixman-pict.c
pixman/pixman-private.h

diff --git a/TODO b/TODO
index 7bbb7d0..3151843 100644 (file)
--- a/TODO
+++ b/TODO
@@ -32,6 +32,8 @@
 
 - Add non-mmx solid fill
 
+- make the wrapper functions global instead of image specific
+
 done:
 
 - Make sure the endian-ness macros are defined correctly.
index f08ec23..6e9c75f 100644 (file)
@@ -1,7 +1,5 @@
 lib_LTLIBRARIES = libpixman.la
-
-libpixman_la_LIBADD = @DEP_LIBS@ -lm
-
+libpixman_la_LIBADD = @DEP_LIBS@ -lm libpixmanwrapper.la
 libpixman_la_SOURCES =         \
        pixman.h                \
        pixman-region.c         \
@@ -15,8 +13,20 @@ libpixman_la_SOURCES =               \
        pixman-trap.c           \
        pixman-compute-region.c
 
+libpixmanincludedir = $(includedir)/pixman
+libpixmaninclude_HEADERS = pixman.h
+
+# wrapper library
+noinst_LTLIBRARIES = libpixmanwrapper.la
+libpixmanwrapper_la_SOURCES =  \
+       pixman-compose.c
+libpixmanwrapper_la_CFLAGS = $(DEP_CFLAGS) -DPIXMAN_FB_ACCESSORS
+
+
+
+# mmx code
 if USE_MMX
-noinst_LTLIBRARIES = libpixman-mmx.la
+noinst_LTLIBRARIES += libpixman-mmx.la
 libpixman_mmx_la_SOURCES = \
        pixman-mmx.c \
        pixman-mmx.h
@@ -24,6 +34,3 @@ libpixman_mmx_la_CFLAGS = $(DEP_CFLAGS) $(MMX_CFLAGS)
 libpixman_mmx_la_LIBADD = $(DEP_LIBS)
 libpixman_la_LIBADD += libpixman-mmx.la
 endif
-
-libpixmanincludedir = $(includedir)/pixman
-libpixmaninclude_HEADERS = pixman.h
index bff67f0..c2f2278 100644 (file)
@@ -2992,13 +2992,6 @@ static CombineFuncC pixman_fbCombineFuncC[] = {
 };
 
 
-FbComposeFunctions pixman_composeFunctions = {
-    pixman_fbCombineFuncU,
-    pixman_fbCombineFuncC,
-    pixman_fbCombineMaskU
-};
-
-
 static void fbFetchSolid(bits_image_t * pict, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits)
 {
     uint32_t *bits;
@@ -3032,6 +3025,24 @@ static void fbFetch(bits_image_t * pict, int x, int y, int width, uint32_t *buff
     fetch((pixman_image_t *)pict, bits, x, width, buffer, indexed);
 }
 
+#ifdef PIXMAN_FB_ACCESSORS
+#define PIXMAN_COMPOSITE_RECT_GENERAL pixman_composite_rect_general_accessors
+#define PIXMAN_COMPOSE_FUNCTIONS pixman_composeFunctions_accessors
+static const FbComposeFunctions pixman_composeFunctions_accessors = {
+    pixman_fbCombineFuncU,
+    pixman_fbCombineFuncC,
+    pixman_fbCombineMaskU
+};
+#else
+#define PIXMAN_COMPOSITE_RECT_GENERAL pixman_composite_rect_general_no_accessors
+#define PIXMAN_COMPOSE_FUNCTIONS pixman_composeFunctions
+FbComposeFunctions pixman_composeFunctions = {
+    pixman_fbCombineFuncU,
+    pixman_fbCombineFuncC,
+    pixman_fbCombineMaskU
+};
+#endif
+
 typedef struct
 {
     uint32_t        left_ag;
@@ -4271,8 +4282,12 @@ typedef void (*scanStoreProc)(pixman_image_t *, int, int, int, uint32_t *);
 typedef void (*scanFetchProc)(pixman_image_t *, int, int, int, uint32_t *,
                              uint32_t *, uint32_t);
 
+#ifndef PIXMAN_FB_ACCESSORS
+static
+#endif
 void
-pixmanCompositeRect (const FbComposeData *data, uint32_t *scanline_buffer)
+PIXMAN_COMPOSITE_RECT_GENERAL (const FbComposeData *data,
+                              uint32_t *scanline_buffer)
 {
     uint32_t *src_buffer = scanline_buffer;
     uint32_t *dest_buffer = src_buffer + data->width;
@@ -4407,7 +4422,7 @@ pixmanCompositeRect (const FbComposeData *data, uint32_t *scanline_buffer)
        PIXMAN_FORMAT_RGB (data->mask->bits.format))
     {
        uint32_t *mask_buffer = dest_buffer + data->width;
-       CombineFuncC compose = pixman_composeFunctions.combineC[data->op];
+       CombineFuncC compose = PIXMAN_COMPOSE_FUNCTIONS.combineC[data->op];
        if (!compose)
            return;
        
@@ -4471,7 +4486,7 @@ pixmanCompositeRect (const FbComposeData *data, uint32_t *scanline_buffer)
     else
     {
        uint32_t *src_mask_buffer = 0, *mask_buffer = 0;
-       CombineFuncU compose = pixman_composeFunctions.combineU[data->op];
+       CombineFuncU compose = PIXMAN_COMPOSE_FUNCTIONS.combineU[data->op];
        if (!compose)
            return;
        
@@ -4515,9 +4530,9 @@ pixmanCompositeRect (const FbComposeData *data, uint32_t *scanline_buffer)
                              0xff000000);
                    
                    if (mask_buffer)
-                       pixman_composeFunctions.combineMaskU (src_buffer,
-                                                             mask_buffer,
-                                                             data->width);
+                       PIXMAN_COMPOSE_FUNCTIONS.combineMaskU (src_buffer,
+                                                              mask_buffer,
+                                                              data->width);
                    
                    src_mask_buffer = src_buffer;
                }
@@ -4559,3 +4574,26 @@ pixmanCompositeRect (const FbComposeData *data, uint32_t *scanline_buffer)
     if (!store)
        fbFinishAccess (data->dest->pDrawable);
 }
+
+#ifndef PIXMAN_FB_ACCESSORS
+
+void
+pixman_composite_rect_general (const FbComposeData *data,
+                              uint32_t *scanline_buffer)
+{
+    if (data->src->common.read_func                    ||
+       data->src->common.write_func                    ||
+       (data->mask && data->mask->common.read_func)    ||
+       (data->mask && data->mask->common.write_func)   ||
+       data->dest->common.read_func                    ||
+       data->dest->common.write_func)
+    {
+       return pixman_composite_rect_general_accessors (data, scanline_buffer);
+    }
+    else
+    {
+       return pixman_composite_rect_general_no_accessors (data, scanline_buffer);
+    }
+}
+
+#endif
index 41c565b..1001cff 100644 (file)
@@ -884,13 +884,11 @@ mmxCombineAddC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
     _mm_empty();
 }
 
-/* FIXME: this should be reinstated after adding fbmmx to pixman */
-extern FbComposeFunctions pixman_composeFunctions;
-
 void fbComposeSetupMMX(void)
 {
     /* check if we have MMX support and initialize accordingly */
-    if (pixman_have_mmx()) {
+    if (pixman_have_mmx())
+    {
         pixman_composeFunctions.combineU[PIXMAN_OP_OVER] = mmxCombineOverU;
         pixman_composeFunctions.combineU[PIXMAN_OP_OVER_REVERSE] = mmxCombineOverReverseU;
         pixman_composeFunctions.combineU[PIXMAN_OP_IN] = mmxCombineInU;
index f444713..3986d7d 100644 (file)
@@ -1110,7 +1110,7 @@ pixman_image_composite_rect  (pixman_op_t                   op,
     compose_data.width = width;
     compose_data.height = height;
 
-    pixmanCompositeRect (&compose_data, scanline_buffer);
+    pixman_composite_rect_general (&compose_data, scanline_buffer);
 
     if (scanline_buffer != _scanline_buffer)
        free (scanline_buffer);
index 0dda1a6..9ac871d 100644 (file)
@@ -109,12 +109,6 @@ typedef FASTCALL void (*CombineMaskU) (uint32_t *src, const uint32_t *mask, int
 typedef FASTCALL void (*CombineFuncU) (uint32_t *dest, const uint32_t *src, int width);
 typedef FASTCALL void (*CombineFuncC) (uint32_t *dest, uint32_t *src, uint32_t *mask, int width);
 
-typedef struct _FbComposeFunctions {
-    CombineFuncU *combineU;
-    CombineFuncC *combineC;
-    CombineMaskU combineMaskU;
-} FbComposeFunctions;
-
 typedef struct _FbComposeData {
     uint8_t     op;
     pixman_image_t     *src;
@@ -130,6 +124,20 @@ typedef struct _FbComposeData {
     uint16_t    height;
 } FbComposeData;
 
+typedef struct _FbComposeFunctions {
+    CombineFuncU *combineU;
+    CombineFuncC *combineC;
+    CombineMaskU combineMaskU;
+} FbComposeFunctions;
+
+extern FbComposeFunctions pixman_composeFunctions;
+
+void pixman_composite_rect_general_accessors (const FbComposeData *data,
+                                             uint32_t *scanline_buffer);
+void pixman_composite_rect_general_no_acessors (const FbComposeData *data,
+                                               uint32_t *scanline_buffer);
+void pixman_composite_rect_general (const FbComposeData *data,
+                                   uint32_t *scanline_buffer);
 
 /* end */
 
@@ -255,9 +263,6 @@ union pixman_image
     solid_fill_t               solid;
 };
 
-void pixmanCompositeRect (const FbComposeData *data,
-                         uint32_t *scanline_buffer);
-
 #define LOG2_BITMAP_PAD 5
 #define FB_STIP_SHIFT  LOG2_BITMAP_PAD
 #define FB_STIP_UNIT   (1 << FB_STIP_SHIFT)