[Spice-commits] 8 commits - common/canvas_base.c common/canvas_utils.c common/pixman_utils.c common/pixman_utils.h

Christophe Fergau teuf at kemper.freedesktop.org
Thu Dec 17 07:19:01 PST 2015


 common/canvas_base.c  |   25 ++++++++++++++-----------
 common/canvas_utils.c |   14 ++++++++++++++
 common/pixman_utils.c |   18 +++---------------
 common/pixman_utils.h |   10 ++++++++++
 4 files changed, 41 insertions(+), 26 deletions(-)

New commits:
commit 1118712c5989f7eeb723e830bd6b7371796b8ba6
Author: Lukas Venhoda <lvenhoda at redhat.com>
Date:   Thu Dec 17 15:45:07 2015 +0100

    ppc: Fix alpha state checking on BE machines
    
    The surface before conversion can be either LE or BE on a BE machine.
    Check against both BE and LE color order on BE machine.

diff --git a/common/canvas_base.c b/common/canvas_base.c
index c30e35d..d918441 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -1264,6 +1264,9 @@ static pixman_image_t *canvas_get_image_internal(CanvasBase *canvas, SpiceImage
            If so we convert here. */
 
         wanted_format = canvas_get_target_format(canvas,
+#ifdef WORDS_BIGENDIAN
+                                                 surface_format == PIXMAN_b8g8r8a8 ||
+#endif
                                                  surface_format == PIXMAN_a8r8g8b8);
 
         if (surface_format != wanted_format) {
commit 2493c60ff70e79b5df91c281dda0e0d19d4408cb
Author: Lukas Venhoda <lvenhoda at redhat.com>
Date:   Wed Nov 25 17:14:34 2015 +0100

    ppc: Fix colors on ppc when using jpeg
    
    Fixes color order on PowerPC when using jpeg compression.

diff --git a/common/canvas_base.c b/common/canvas_base.c
index db4e1a4..c30e35d 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -501,7 +501,7 @@ static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image)
 #ifdef WIN32
                              canvas->dc,
 #endif
-                             PIXMAN_x8r8g8b8,
+                             PIXMAN_LE_x8r8g8b8,
                              width, height, FALSE);
     if (surface == NULL) {
         spice_warning("create surface failed");
@@ -648,7 +648,7 @@ static pixman_image_t *canvas_get_jpeg_alpha(CanvasBase *canvas, SpiceImage *ima
 #ifdef WIN32
     lz_data->decode_data.dc = canvas->dc;
 #endif
-    surface = alloc_lz_image_surface(&lz_data->decode_data, PIXMAN_a8r8g8b8,
+    surface = alloc_lz_image_surface(&lz_data->decode_data, PIXMAN_LE_a8r8g8b8,
                                      width, height, width*height, alpha_top_down);
 
     if (surface == NULL) {
commit 98f9097c49f2688e8a5394e3844f75f01291fa19
Author: Lukas Venhoda <lvenhoda at redhat.com>
Date:   Wed Nov 25 17:14:33 2015 +0100

    ppc: Fix colors on ppc when using LZ4
    
    Fixes color order on PowerPC when using LZ4 image compression.

diff --git a/common/canvas_base.c b/common/canvas_base.c
index 950d869..db4e1a4 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -545,15 +545,15 @@ static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage *image)
             stride_encoded *= 2;
             break;
         case SPICE_BITMAP_FMT_24BIT:
-            format = PIXMAN_r8g8b8;
+            format = PIXMAN_LE_r8g8b8;
             stride_encoded *= 3;
             break;
         case SPICE_BITMAP_FMT_32BIT:
-            format = PIXMAN_x8r8g8b8;
+            format = PIXMAN_LE_x8r8g8b8;
             stride_encoded *= 4;
             break;
         case SPICE_BITMAP_FMT_RGBA:
-            format = PIXMAN_a8r8g8b8;
+            format = PIXMAN_LE_a8r8g8b8;
             stride_encoded *= 4;
             break;
         default:
commit d7719d3e60a2511c0f0f931a299aded478dd0ea2
Author: Lukas Venhoda <lvenhoda at redhat.com>
Date:   Wed Nov 25 17:14:32 2015 +0100

    ppc: Fix colors on ppc when using LZ
    
    Fixes color order on PowerPC when using LZ image compression.

diff --git a/common/canvas_base.c b/common/canvas_base.c
index 81328f4..950d869 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -825,7 +825,7 @@ static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image,
     switch (type) {
     case LZ_IMAGE_TYPE_RGBA:
         as_type = LZ_IMAGE_TYPE_RGBA;
-        pixman_format = PIXMAN_a8r8g8b8;
+        pixman_format = PIXMAN_LE_a8r8g8b8;
         break;
     case LZ_IMAGE_TYPE_RGB32:
     case LZ_IMAGE_TYPE_RGB24:
@@ -835,7 +835,7 @@ static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image,
     case LZ_IMAGE_TYPE_PLT4_BE:
     case LZ_IMAGE_TYPE_PLT8:
         as_type = LZ_IMAGE_TYPE_RGB32;
-        pixman_format = PIXMAN_x8r8g8b8;
+        pixman_format = PIXMAN_LE_x8r8g8b8;
         break;
     case LZ_IMAGE_TYPE_A8:
         as_type = LZ_IMAGE_TYPE_A8;
@@ -846,7 +846,7 @@ static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image,
             (canvas->format == SPICE_SURFACE_FMT_32_xRGB ||
              canvas->format == SPICE_SURFACE_FMT_32_ARGB)) {
             as_type = LZ_IMAGE_TYPE_RGB32;
-            pixman_format = PIXMAN_x8r8g8b8;
+            pixman_format = PIXMAN_LE_x8r8g8b8;
         } else {
             as_type = LZ_IMAGE_TYPE_RGB16;
             pixman_format = PIXMAN_x1r5g5b5;
commit bdc995104941a2f7dba28340499135c6722d8b25
Author: Lukas Venhoda <lvenhoda at redhat.com>
Date:   Wed Nov 25 17:14:31 2015 +0100

    ppc: Fix colors on ppc when using QUIC
    
    Fixes color order on PowerPC when using QUIC image compression.

diff --git a/common/canvas_base.c b/common/canvas_base.c
index 6747465..81328f4 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -406,19 +406,19 @@ static pixman_image_t *canvas_get_quic(CanvasBase *canvas, SpiceImage *image,
     switch (type) {
     case QUIC_IMAGE_TYPE_RGBA:
         as_type = QUIC_IMAGE_TYPE_RGBA;
-        pixman_format = PIXMAN_a8r8g8b8;
+        pixman_format = PIXMAN_LE_a8r8g8b8;
         break;
     case QUIC_IMAGE_TYPE_RGB32:
     case QUIC_IMAGE_TYPE_RGB24:
         as_type = QUIC_IMAGE_TYPE_RGB32;
-        pixman_format = PIXMAN_x8r8g8b8;
+        pixman_format = PIXMAN_LE_x8r8g8b8;
         break;
     case QUIC_IMAGE_TYPE_RGB16:
         if (!want_original &&
             (canvas->format == SPICE_SURFACE_FMT_32_xRGB ||
              canvas->format == SPICE_SURFACE_FMT_32_ARGB)) {
             as_type = QUIC_IMAGE_TYPE_RGB32;
-            pixman_format = PIXMAN_x8r8g8b8;
+            pixman_format = PIXMAN_LE_x8r8g8b8;
         } else {
             as_type = QUIC_IMAGE_TYPE_RGB16;
             pixman_format = PIXMAN_x1r5g5b5;
commit 76a0c2fae8f35eb7c38abe7656f694b436391911
Author: Lukas Venhoda <lvenhoda at redhat.com>
Date:   Wed Nov 25 17:14:30 2015 +0100

    ppc: Add support for bigendian color byte order
    
    On LE machine, color order when creating surface will always be A/XRGB.
    On BE machines the color order will sometimes be ARGB and sometimes BGRA/X.
    
    This is because we actually create the surface two times on BE machines.
    Once with BE order, and then again with LE order. Copying data inbetween
    theese two surfaces will byteswap the colors automatically.
    
    This change introduces cases for BGRA/X color byte orders on BE machines.

diff --git a/common/canvas_utils.c b/common/canvas_utils.c
index 0d1591a..46eb012 100644
--- a/common/canvas_utils.c
+++ b/common/canvas_utils.c
@@ -162,10 +162,17 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig
         switch (format) {
         case PIXMAN_a8r8g8b8:
         case PIXMAN_x8r8g8b8:
+#ifdef WORDS_BIGENDIAN
+        case PIXMAN_b8g8r8a8:
+        case PIXMAN_b8g8r8x8:
+#endif
             bitmap_info.inf.bmiHeader.biBitCount = 32;
             nstride = width * 4;
             break;
         case PIXMAN_r8g8b8:
+#ifdef WORDS_BIGENDIAN
+        case PIXMAN_b8g8r8:
+#endif
             bitmap_info.inf.bmiHeader.biBitCount = 24;
             nstride = SPICE_ALIGN(width * 3, 4);
             break;
@@ -235,9 +242,16 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig
         switch (format) {
         case PIXMAN_a8r8g8b8:
         case PIXMAN_x8r8g8b8:
+#ifdef WORDS_BIGENDIAN
+        case PIXMAN_b8g8r8a8:
+        case PIXMAN_b8g8r8x8:
+#endif
             stride = width * 4;
             break;
         case PIXMAN_r8g8b8:
+#ifdef WORDS_BIGENDIAN
+        case PIXMAN_b8g8r8:
+#endif
             // NOTE: LZ4 also decodes to RGB24
             stride = SPICE_ALIGN(width * 3, 4);
             break;
commit fc1f511bb8beb7e8efd1773a79eb4d09c93c90d5
Author: Lukas Venhoda <lvenhoda at redhat.com>
Date:   Wed Nov 25 17:14:29 2015 +0100

    pixman_utils: Use PIXMAN_LE_ constants in spice_bitmap_try_as_pixman()
    
    After the previous commit, spice_bitmap_try_as_pixman() can be
    simplified as its #ifdef WORDS_BIGENDIAN exactly match what the
    PIXMAN_LE_ constants do.

diff --git a/common/pixman_utils.c b/common/pixman_utils.c
index 27ab155..c2161ca 100644
--- a/common/pixman_utils.c
+++ b/common/pixman_utils.c
@@ -1003,25 +1003,13 @@ pixman_image_t *spice_bitmap_try_as_pixman(int src_format,
 
     switch (src_format) {
     case SPICE_BITMAP_FMT_32BIT:
-#ifdef WORDS_BIGENDIAN
-        pixman_format = PIXMAN_b8g8r8x8;
-#else
-        pixman_format = PIXMAN_x8r8g8b8;
-#endif
+        pixman_format = PIXMAN_LE_x8r8g8b8;
         break;
     case SPICE_BITMAP_FMT_RGBA:
-#ifdef WORDS_BIGENDIAN
-        pixman_format = PIXMAN_b8g8r8a8;
-#else
-        pixman_format = PIXMAN_a8r8g8b8;
-#endif
+        pixman_format = PIXMAN_LE_a8r8g8b8;
         break;
     case SPICE_BITMAP_FMT_24BIT:
-#ifdef WORDS_BIGENDIAN
-        pixman_format = PIXMAN_b8g8r8;
-#else
-        pixman_format = PIXMAN_r8g8b8;
-#endif
+        pixman_format = PIXMAN_LE_r8g8b8;
         break;
     case SPICE_BITMAP_FMT_16BIT:
 #ifdef WORDS_BIGENDIAN
commit 2ee5cb522ee16a756c74ed6e127cf3874a45f3a6
Author: Lukas Venhoda <lvenhoda at redhat.com>
Date:   Wed Nov 25 17:14:28 2015 +0100

    pixman_utils: Add macros for color byte ordering
    
    When using image compression on PowerPC architecture, colors are in
    wrong order ARGB -> BGRA.
    
    This commit introduces macros, that will change the color order
    according to machine endianness.
    
    Theese macros are similar to QEMU macros in qemu-pixman.h

diff --git a/common/pixman_utils.h b/common/pixman_utils.h
index dd565ef..f892777 100644
--- a/common/pixman_utils.h
+++ b/common/pixman_utils.h
@@ -27,6 +27,16 @@
 
 #include "draw.h"
 
+#ifdef WORDS_BIGENDIAN
+# define PIXMAN_LE_x8r8g8b8   PIXMAN_b8g8r8x8
+# define PIXMAN_LE_a8r8g8b8   PIXMAN_b8g8r8a8
+# define PIXMAN_LE_r8g8b8     PIXMAN_b8g8r8
+#else
+# define PIXMAN_LE_x8r8g8b8   PIXMAN_x8r8g8b8
+# define PIXMAN_LE_a8r8g8b8   PIXMAN_a8r8g8b8
+# define PIXMAN_LE_r8g8b8     PIXMAN_r8g8b8
+#endif
+
 SPICE_BEGIN_DECLS
 
 /* This lists all possible 2 argument binary raster ops.


More information about the Spice-commits mailing list