[05/37,v2] composite flags: Early detection of fully opaque 1x1 repeating source images

Submitted by Ben Avison on April 22, 2015, 2:12 p.m.

Details

Message ID 1429711956-19702-1-git-send-email-bavison@riscosopen.org
State New
Headers show

Commit Message

Ben Avison April 22, 2015, 2:12 p.m.
Doesn't handle every pixel format, but for those that it does, enables early
conversion of OVER to SRC, for example.
---
 pixman/pixman.c |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/pixman/pixman.c b/pixman/pixman.c
index 9555cea..08293c8 100644
--- a/pixman/pixman.c
+++ b/pixman/pixman.c
@@ -325,6 +325,27 @@  _pixman_compute_composite_region32 (pixman_region32_t * region,
     return TRUE;
 }
 
+static uint32_t
+check_for_single_pixel_opaque_image (pixman_image_t *image)
+{
+    if (image->type == BITS &&
+        image->common.extended_format_code == PIXMAN_solid &&
+        (image->common.flags & FAST_PATH_NO_ACCESSORS) != 0 &&
+        (((image->bits.format == PIXMAN_a8) &&
+                *(uint8_t *)image->bits.bits == 0xFF) ||
+         ((image->bits.format == PIXMAN_b8g8r8a8 || image->bits.format == PIXMAN_r8g8b8a8) &&
+                (0xff &~ image->bits.bits[0]) == 0) ||
+         ((image->bits.format == PIXMAN_a8r8g8b8 || image->bits.format == PIXMAN_a8b8g8r8 || image->bits.format == PIXMAN_a8r8g8b8_sRGB) &&
+                (0xff000000 &~ image->bits.bits[0]) == 0)) &&
+         !image->common.alpha_map &&
+         image->common.filter != PIXMAN_FILTER_CONVOLUTION &&
+         image->common.filter != PIXMAN_FILTER_SEPARABLE_CONVOLUTION &&
+         !image->common.component_alpha)
+        return FAST_PATH_SAMPLES_OPAQUE | FAST_PATH_IS_OPAQUE;
+    else
+        return 0;
+}
+
 typedef struct
 {
     pixman_fixed_48_16_t	x1;
@@ -595,12 +616,13 @@  pixman_image_composite32 (pixman_op_t      op,
     _pixman_image_validate (dest);
 
     src_format = src->common.extended_format_code;
-    info.src_flags = src->common.flags;
+    info.src_flags = src->common.flags | check_for_single_pixel_opaque_image (src);
 
-    if (mask && !(mask->common.flags & FAST_PATH_IS_OPAQUE))
+    if (mask)
+        info.mask_flags = mask->common.flags | check_for_single_pixel_opaque_image (mask);
+    if (mask && !(info.mask_flags & FAST_PATH_IS_OPAQUE))
     {
 	mask_format = mask->common.extended_format_code;
-	info.mask_flags = mask->common.flags;
     }
     else
     {