Change pixman_lookup_fast_path() to actually run the fast path
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Wed, 13 May 2009 13:42:42 +0000 (09:42 -0400)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Sat, 23 May 2009 16:05:01 +0000 (12:05 -0400)
Then just return in the general implementation if we ran a fast path.

pixman/pixman-general.c
pixman/pixman-private.h
pixman/pixman-utils.c

index b3b4fd4..49b6f52 100644 (file)
@@ -392,7 +392,6 @@ general_composite (pixman_implementation_t *        imp,
     pixman_bool_t maskRepeat = FALSE;
     pixman_bool_t srcTransform = src->common.transform != NULL;
     pixman_bool_t maskTransform = FALSE;
-    pixman_composite_func_t func = NULL;
 
 #ifdef USE_MMX
     fbComposeSetupMMX();
@@ -430,61 +429,86 @@ general_composite (pixman_implementation_t *      imp,
     }
     
 #ifdef USE_SSE2
-    if (!func)
-       func = _pixman_lookup_fast_path (sse2_fast_paths, op, src, mask, dest, src_x, src_y, mask_x, mask_y);
+    if (_pixman_run_fast_path (sse2_fast_paths, imp,
+                              op, src, mask, dest,
+                              src_x, src_y,
+                              mask_x, mask_y,
+                              dest_x, dest_y,
+                              width, height))
+       return;
 #endif
 
 #ifdef USE_MMX
-    if (!func)
-       func = _pixman_lookup_fast_path (mmx_fast_paths, op, src, mask, dest, src_x, src_y, mask_x, mask_y);
+    if (_pixman_run_fast_path (mmx_fast_paths, imp,
+                              op, src, mask, dest,
+                              src_x, src_y,
+                              mask_x, mask_y,
+                              dest_x, dest_y,
+                              width, height))
+       return;
 #endif
 
 #ifdef USE_VMX
-    if (!func)
-       func = _pixman_lookup_fast_path (vmx_fast_paths, op, src, mask, dest, src_x, src_y, mask_x, mask_y);
+    if (_pixman_run_fast_path (vmx_fast_paths, imp,
+                              op, src, mask, dest,
+                              src_x, src_y,
+                              mask_x, mask_y,
+                              dest_x, dest_y,
+                              width, height))
+       return;
 #endif
 
 #ifdef USE_ARM_NEON
-    if (!func && pixman_have_arm_neon())
-       func = _pixman_lookup_fast_path (arm_neon_fast_paths, op, src, mask, dest, src_x, src_y, mask_x, mask_y);
+    if (pixman_have_arm_neon() && _pixman_run_fast_path (arm_neon_fast_paths, imp,
+                                                        op, src, mask, dest,
+                                                        src_x, src_y,
+                                                        mask_x, mask_y,
+                                                        dest_x, dest_y,
+                                                        width, height))
+       return;
 #endif
 
 #ifdef USE_ARM_SIMD
-    if (!func && pixman_have_arm_simd())
-       func = _pixman_lookup_fast_path (arm_neon_fast_paths, op, src, mask, dest, src_x, src_y, mask_x, mask_y);
+    if (pixman_have_arm_simd() && _pixman_run_fast_path (arm_simd_fast_paths, imp,
+                                                        op, src, mask, dest,
+                                                        src_x, src_y,
+                                                        mask_x, mask_y,
+                                                        dest_x, dest_y,
+                                                        width, height))
+       return;
 #endif
 
-    if (!func)
-       func = _pixman_lookup_fast_path (c_fast_paths, op, src, mask, dest, src_x, src_y, mask_x, mask_y);
-
-    if (!func)
+    if (pixman_have_arm_simd() && _pixman_run_fast_path (c_fast_paths, imp,
+                                                        op, src, mask, dest,
+                                                        src_x, src_y,
+                                                        mask_x, mask_y,
+                                                        dest_x, dest_y,
+                                                        width, height))
+       return;
+    
+    /* CompositeGeneral optimizes 1x1 repeating images itself */
+    if (src->type == BITS &&
+       src->bits.width == 1 && src->bits.height == 1)
     {
-       func = pixman_image_composite_rect;
-
-       /* CompositeGeneral optimizes 1x1 repeating images itself */
-       if (src->type == BITS &&
-           src->bits.width == 1 && src->bits.height == 1)
-       {
-           srcRepeat = FALSE;
-       }
-
-       if (mask && mask->type == BITS &&
-           mask->bits.width == 1 && mask->bits.height == 1)
-       {
-           maskRepeat = FALSE;
-       }
-
-       /* if we are transforming, repeats are handled in fbFetchTransformed */
-       if (srcTransform)
-           srcRepeat = FALSE;
-
-       if (maskTransform)
-           maskRepeat = FALSE;
+       srcRepeat = FALSE;
     }
+    
+    if (mask && mask->type == BITS &&
+       mask->bits.width == 1 && mask->bits.height == 1)
+    {
+       maskRepeat = FALSE;
+    }
+    
+    /* if we are transforming, repeats are handled in fbFetchTransformed */
+    if (srcTransform)
+       srcRepeat = FALSE;
+    
+    if (maskTransform)
+       maskRepeat = FALSE;
 
     _pixman_walk_composite_region (imp, op, src, mask, dest, src_x, src_y,
-                                 mask_x, mask_y, dest_x, dest_y, width, height,
-                                 srcRepeat, maskRepeat, func);
+                                  mask_x, mask_y, dest_x, dest_y, width, height,
+                                  srcRepeat, maskRepeat, pixman_image_composite_rect);
 }
 
 pixman_implementation_t *
index 8694501..0e46704 100644 (file)
@@ -1010,16 +1010,21 @@ pixman_implementation_t *
 _pixman_implementation_create_sse2 (pixman_implementation_t *toplevel);
 #endif
 
-pixman_composite_func_t
-_pixman_lookup_fast_path (const FastPathInfo *paths,
-                         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);
+pixman_bool_t
+_pixman_run_fast_path (const FastPathInfo *paths,
+                      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_t *
 _pixman_choose_implementation (void);
index afb0c2a..9e9ba7b 100644 (file)
@@ -765,16 +765,21 @@ get_fast_path (const FastPathInfo *fast_paths,
     return NULL;
 }
 
-pixman_composite_func_t
-_pixman_lookup_fast_path (const FastPathInfo *paths,
-                         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)
+pixman_bool_t
+_pixman_run_fast_path (const FastPathInfo *paths,
+                      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_composite_func_t func = NULL;
     pixman_bool_t src_repeat = src->common.repeat == PIXMAN_REPEAT_NORMAL;
@@ -840,5 +845,17 @@ _pixman_lookup_fast_path (const FastPathInfo *paths,
        }
     }
 
-    return func;
+    if (func)
+    {
+       _pixman_walk_composite_region (imp, op,
+                                      src, mask, dest,
+                                      src_x, src_y, mask_x, mask_y,
+                                      dest_x, dest_y,
+                                      width, height,
+                                      src_repeat, mask_repeat,
+                                      func);
+       return TRUE;
+    }
+    
+    return FALSE;
 }