On Fri, Jul 15, 2011 at 9:53 PM, Tristan Schmelcher
<[email protected]> wrote:
> I have a Cairo application that is using Pixman to composite a
> semantically opaque image by scaling a bunch of source images in RGB24
> format. If the target surface is also RGB24 format, then it is very
> fast and usesĀ fast_composite_scaled_nearest_8888_8888_cover_SRC. But
> if the target surface is the ARGB32 format, then it takes almost three
> times as long and uses just fast_composite_scaled_nearest.
>
> If I had a choice, I would always make the destination surface in
> RGB24 format, but unfortunately it is being created as ARGB32 by
> another library which I don't control, so my application is taking the
> slow path. I want to improve it so that the performance in the RGB24
> -> ARGB32 case is approximately as good as the RGB24 -> RGB24 case, if
> possible.

Have you tried alternatively converting your opaque source images to
ARGB32 format? This approach may have some advantages.

> My idea for how to go about this is to add a x888_8888 fast-path to
> Pixman for RGB24 -> ARGB32 that does the same thing as the 8888_8888
> path but sets all the destination alpha bytes to 0xFF. But before I
> try coding it I wanted to ask here if anyone has any other suggestions
> or knows of any "gotchas" with this approach.
>
> Comments?

Yes, this is how pixman development is done at the moment. One finds
something that is slow and adds new special fast paths for it. I have
also attached a patch which should add the needed entries to the fast
path tables. Probably this is what you are intending to get.

-- 
Best regards,
Siarhei Siamashka
From cf9290826d83e03b0c466e470eca9b81646af17f Mon Sep 17 00:00:00 2001
From: Siarhei Siamashka <[email protected]>
Date: Fri, 15 Jul 2011 23:35:21 +0300
Subject: [PATCH] C fast path for scaled src_x888_8888 with nearest filter

The necessity is justified by a message in the pixman mailing list:
  http://lists.freedesktop.org/archives/pixman/2011-July/001330.html

NONE repeat is not supported, but could be added by tweaking
the interpretation and making use of 'fully_transparent_src'
scanline function argument.
---
 pixman/pixman-fast-path.c |   10 ++++++++++
 pixman/pixman-fast-path.h |    1 +
 pixman/pixman-private.h   |    1 +
 3 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/pixman/pixman-fast-path.c b/pixman/pixman-fast-path.c
index 3c05383..9a6919e 100644
--- a/pixman/pixman-fast-path.c
+++ b/pixman/pixman-fast-path.c
@@ -1174,6 +1174,9 @@ FAST_NEAREST (8888_8888_cover, 8888, 8888, uint32_t, uint32_t, SRC, COVER)
 FAST_NEAREST (8888_8888_none, 8888, 8888, uint32_t, uint32_t, SRC, NONE)
 FAST_NEAREST (8888_8888_pad, 8888, 8888, uint32_t, uint32_t, SRC, PAD)
 FAST_NEAREST (8888_8888_normal, 8888, 8888, uint32_t, uint32_t, SRC, NORMAL)
+FAST_NEAREST (x888_8888_cover, x888, 8888, uint32_t, uint32_t, SRC, COVER)
+FAST_NEAREST (x888_8888_pad, x888, 8888, uint32_t, uint32_t, SRC, PAD)
+FAST_NEAREST (x888_8888_normal, x888, 8888, uint32_t, uint32_t, SRC, NORMAL)
 FAST_NEAREST (8888_8888_cover, 8888, 8888, uint32_t, uint32_t, OVER, COVER)
 FAST_NEAREST (8888_8888_none, 8888, 8888, uint32_t, uint32_t, OVER, NONE)
 FAST_NEAREST (8888_8888_pad, 8888, 8888, uint32_t, uint32_t, OVER, PAD)
@@ -1716,6 +1719,13 @@ static const pixman_fast_path_t c_fast_paths[] =
 
     SIMPLE_NEAREST_FAST_PATH (SRC, r5g6b5, r5g6b5, 565_565),
 
+    SIMPLE_NEAREST_FAST_PATH_COVER (SRC, x8r8g8b8, a8r8g8b8, x888_8888),
+    SIMPLE_NEAREST_FAST_PATH_COVER (SRC, x8b8g8r8, a8b8g8r8, x888_8888),
+    SIMPLE_NEAREST_FAST_PATH_PAD (SRC, x8r8g8b8, a8r8g8b8, x888_8888),
+    SIMPLE_NEAREST_FAST_PATH_PAD (SRC, x8b8g8r8, a8b8g8r8, x888_8888),
+    SIMPLE_NEAREST_FAST_PATH_NORMAL (SRC, x8r8g8b8, a8r8g8b8, x888_8888),
+    SIMPLE_NEAREST_FAST_PATH_NORMAL (SRC, x8b8g8r8, a8b8g8r8, x888_8888),
+
     SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8, 8888_8888),
     SIMPLE_NEAREST_FAST_PATH (OVER, a8b8g8r8, x8b8g8r8, 8888_8888),
     SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, 8888_8888),
diff --git a/pixman/pixman-fast-path.h b/pixman/pixman-fast-path.h
index e94591a..2b55c2e 100644
--- a/pixman/pixman-fast-path.h
+++ b/pixman/pixman-fast-path.h
@@ -157,6 +157,7 @@ pad_repeat_get_scanline_bounds (int32_t         source_image_width,
  /* This is not actually used since we don't have an OVER with
     565 source, but it is needed to build. */
 #define GET_0565_ALPHA(s) 0xff
+#define GET_x888_ALPHA(s) 0xff
 
 #define FAST_NEAREST_SCANLINE(scanline_func_name, SRC_FORMAT, DST_FORMAT,			\
 			      src_type_t, dst_type_t, OP, repeat_mode)				\
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 65494c9..6a3935e 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -763,6 +763,7 @@ pixman_region16_copy_from_region32 (pixman_region16_t *dst,
 
 /* Trivial versions that are useful in macros */
 #define CONVERT_8888_TO_8888(s) (s)
+#define CONVERT_x888_TO_8888(s) ((s) | 0xff000000)
 #define CONVERT_0565_TO_0565(s) (s)
 
 #define PIXMAN_FORMAT_IS_WIDE(f)					\
-- 
1.7.3.4

_______________________________________________
Pixman mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pixman

Reply via email to