Beginning of pluggable implementations
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Wed, 13 May 2009 07:31:11 +0000 (03:31 -0400)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Sat, 23 May 2009 15:51:28 +0000 (11:51 -0400)
pixman/Makefile.am
pixman/pixman-implementation.c [new file with mode: 0644]
pixman/pixman-private.h
pixman/pixman.h

index b55daa0..21503b6 100644 (file)
@@ -12,6 +12,7 @@ libpixman_1_la_SOURCES =                      \
        pixman-region32.c                       \
        pixman-private.h                        \
        pixman-image.c                          \
+       pixman-implementation.c                 \
        pixman-combine32.c                      \
        pixman-combine32.h                      \
        pixman-combine64.c                      \
diff --git a/pixman/pixman-implementation.c b/pixman/pixman-implementation.c
new file mode 100644 (file)
index 0000000..c8c09ad
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * Copyright © 2009 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Red Hat not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  Red Hat makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include <config.h>
+#include <stdlib.h>
+#include "pixman-private.h"
+
+static void
+delegate_composite (pixman_implementation_t *  imp,
+                   pixman_op_t                 op,
+                   pixman_image_t *            src,
+                   pixman_image_t *            mask,
+                   pixman_image_t *            dest,
+                   int32_t                     src_x,
+                   int32_t                     src_y,
+                   int32_t                     mask_x,
+                   int32_t                     mask_y,
+                   int32_t                     dest_x,
+                   int32_t                     dest_y,
+                   int32_t                     width,
+                   int32_t                     height)
+{
+    _pixman_implementation_composite (imp->delegate,
+                                     op,
+                                     src, mask, dest,
+                                     src_x, src_y,
+                                     mask_x, mask_y,
+                                     dest_x, dest_y,
+                                     width, height);
+}
+
+static void
+delegate_combine_32 (pixman_implementation_t * imp,
+                    pixman_op_t                op,
+                    uint32_t *                 dest,
+                    const uint32_t *           src,
+                    const uint32_t *           mask,
+                    int                        width)
+{
+    _pixman_implementation_combine_32 (imp->delegate,
+                                      op, dest, src, mask, width);
+}
+
+static void
+delegate_combine_64 (pixman_implementation_t * imp,
+                    pixman_op_t                op,
+                    uint64_t *                 dest,
+                    const uint64_t *           src,
+                    const uint64_t *           mask,
+                    int                        width)
+{
+    _pixman_implementation_combine_64 (imp->delegate,
+                                      op, dest, src, mask, width);
+}
+
+pixman_implementation_t *
+_pixman_implementation_create (pixman_implementation_t *toplevel,
+                              pixman_implementation_t *delegate)
+{
+    pixman_implementation_t *imp = malloc (sizeof (pixman_implementation_t));
+    int i;
+    
+    if (!imp)
+       return NULL;
+    
+    if (toplevel)
+       imp->toplevel = toplevel;
+    else
+       imp->toplevel = imp;
+    
+    if (delegate)
+       delegate->toplevel = imp->toplevel;
+    
+    imp->delegate = delegate;
+
+    /* Fill out function pointers with ones that just delegate
+     */
+    imp->composite = delegate_composite;
+    
+    for (i = 0; i < PIXMAN_OP_LAST; ++i)
+    {
+       imp->combine_32[i] = delegate_combine_32;
+       imp->combine_64[i] = delegate_combine_64;
+    }
+    
+    return imp;
+}
+
+void
+_pixman_implementation_combine_32 (pixman_implementation_t *   imp,
+                                  pixman_op_t                  op,
+                                  uint32_t *                   dest,
+                                  const uint32_t *             src,
+                                  const uint32_t *             mask,
+                                  int                          width)
+{
+    (* imp->delegate->combine_32[op]) (imp, op, dest, src, mask, width);
+}
+
+void
+_pixman_implementation_combine_64 (pixman_implementation_t *   imp,
+                                  pixman_op_t                  op,
+                                  uint64_t *                   dest,
+                                  const uint64_t *             src,
+                                  const uint64_t *             mask,
+                                  int                          width)
+{
+    (* imp->delegate->combine_64[op]) (imp, op, dest, src, mask, width);
+}
+
+void
+_pixman_implementation_composite (pixman_implementation_t *    imp,
+                                 pixman_op_t                   op,
+                                 pixman_image_t *              src,
+                                 pixman_image_t *              mask,
+                                 pixman_image_t *              dest,
+                                 int32_t                       src_x,
+                                 int32_t                       src_y,
+                                 int32_t                       mask_x,
+                                 int32_t                       mask_y,
+                                 int32_t                       dest_x,
+                                 int32_t                       dest_y,
+                                 int32_t                       width,
+                                 int32_t                       height)
+{
+    (* imp->delegate->composite) (imp, op,
+                                 src, mask, dest,
+                                 src_x, src_y, mask_x, mask_y, dest_x, dest_y,
+                                 width, height);
+}
index 7432e97..e4e77f7 100644 (file)
@@ -894,4 +894,74 @@ void pixman_timer_register (PixmanTimer *timer);
 
 #endif /* PIXMAN_TIMING */
 
+typedef struct pixman_implementation_t pixman_implementation_t;
+
+typedef void (* pixman_combine_32_func_t) (pixman_implementation_t *   imp,
+                                          pixman_op_t                  op,
+                                          uint32_t *                   dest,
+                                          const uint32_t *             src,
+                                          const uint32_t *             mask,
+                                          int                          width);
+
+typedef void (* pixman_combine_64_func_t) (pixman_implementation_t *   imp,
+                                          pixman_op_t                  op,
+                                          uint64_t *                   dest,
+                                          const uint64_t *             src,
+                                          const uint64_t *             mask,
+                                          int                          width);
+
+typedef void (* pixman_composite_func_t)  (pixman_implementation_t *   imp,
+                                          pixman_op_t                  op,
+                                          pixman_image_t *             src,
+                                          pixman_image_t *             mask,
+                                          pixman_image_t *             dest,
+                                          int32_t                      src_x,
+                                          int32_t                      src_y,
+                                          int32_t                      mask_x,
+                                          int32_t                      mask_y,
+                                          int32_t                      dest_x,
+                                          int32_t                      dest_y,
+                                          int32_t                      width,
+                                          int32_t                      height);
+
+struct pixman_implementation_t
+{
+    pixman_implementation_t *  toplevel;
+    pixman_implementation_t *  delegate;
+
+    pixman_composite_func_t    composite;
+    
+    pixman_combine_32_func_t   combine_32[PIXMAN_OP_LAST];
+    pixman_combine_64_func_t   combine_64[PIXMAN_OP_LAST];
+};
+
+void
+_pixman_implementation_combine_32 (pixman_implementation_t *   imp,
+                                  pixman_op_t                  op,
+                                  uint32_t *                   dest,
+                                  const uint32_t *             src,
+                                  const uint32_t *             mask,
+                                  int                          width);
+void
+_pixman_implementation_combine_64 (pixman_implementation_t *   imp,
+                                  pixman_op_t                  op,
+                                  uint64_t *                   dest,
+                                  const uint64_t *             src,
+                                  const uint64_t *             mask,
+                                  int                          width);
+void
+_pixman_implementation_composite (pixman_implementation_t *    imp,
+                                 pixman_op_t                   op,
+                                 pixman_image_t *              src,
+                                 pixman_image_t *              mask,
+                                 pixman_image_t *              dest,
+                                 int32_t                       src_x,
+                                 int32_t                       src_y,
+                                 int32_t                       mask_x,
+                                 int32_t                       mask_y,
+                                 int32_t                       dest_x,
+                                 int32_t                       dest_y,
+                                 int32_t                       width,
+                                 int32_t                       height);
+
 #endif /* PIXMAN_PRIVATE_H */
index 7ae425c..29c054a 100644 (file)
@@ -368,7 +368,8 @@ typedef enum
     PIXMAN_OP_CONJOINT_ATOP_REVERSE    = 0x2a,
     PIXMAN_OP_CONJOINT_XOR             = 0x2b,
 
-    PIXMAN_OP_NONE
+    PIXMAN_OP_NONE,
+    PIXMAN_OP_LAST = PIXMAN_OP_NONE
 } pixman_op_t;
 
 /*