WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH2] ioemu: fix xenfb slow case update

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH2] ioemu: fix xenfb slow case update
From: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
Date: Fri, 29 Feb 2008 17:37:01 +0000
Delivery-date: Fri, 29 Feb 2008 09:38:33 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20080229152622.GC8268@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Mail-followup-to: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
References: <20080229152622.GC8268@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.12-2006-07-14
Samuel Thibault, le Fri 29 Feb 2008 15:26:22 +0000, a écrit :
> ioemu: fix xenfb slow case update

Mmm, actually the whole code was completely bogus, here is an updated
patch.


ioemu: fix xenfb slow case update by shifting to the left before masking
low bits instead of shifting to the right and masking high bits.
Also adds 24bpp support.

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>

diff -r 067d8f19e78a tools/ioemu/hw/xenfb.c
--- a/tools/ioemu/hw/xenfb.c    Thu Feb 28 13:55:37 2008 +0000
+++ b/tools/ioemu/hw/xenfb.c    Fri Feb 29 17:32:23 2008 +0000
@@ -1071,8 +1071,8 @@
 }
 
 /* A convenient function for munging pixels between different depths */
-#define BLT(SRC_T,DST_T,RLS,GLS,BLS,RRS,GRS,BRS,RM,GM,BM)               \
-    for (line = y ; line < h ; line++) {                                \
+#define BLT(SRC_T,DST_T,RSB,GSB,BSB,RDB,GDB,BDB)                        \
+    for (line = y ; line < (y+h) ; line++) {                            \
         SRC_T *src = (SRC_T *)(xenfb->pixels                            \
                                + (line * xenfb->row_stride)             \
                                + (x * xenfb->depth / 8));               \
@@ -1080,12 +1080,25 @@
                                + (line * xenfb->ds->linesize)                  
\
                                + (x * xenfb->ds->depth / 8));                  
\
         int col;                                                        \
-        for (col = x ; col < w ; col++) {                               \
-            *dst = (((*src >> RRS) & RM) << RLS) |                      \
-                (((*src >> GRS) & GM) << GLS) |                         \
-                (((*src >> GRS) & BM) << BLS);                          \
-            src++;                                                      \
-            dst++;                                                      \
+        const int RSS = 32 - (RSB + GSB + BSB);                         \
+        const int GSS = 32 - (GSB + BSB);                               \
+        const int BSS = 32 - (BSB);                                     \
+        const uint32_t RSM = (~0U) << (32 - RSB);                       \
+        const uint32_t GSM = (~0U) << (32 - GSB);                       \
+        const uint32_t BSM = (~0U) << (32 - BSB);                       \
+        const int RDS = 32 - (RDB + GDB + BDB);                         \
+        const int GDS = 32 - (GDB + BDB);                               \
+        const int BDS = 32 - (BDB);                                     \
+        const uint32_t RDM = (~0U) << (32 - RDB);                       \
+        const uint32_t GDM = (~0U) << (32 - GDB);                       \
+        const uint32_t BDM = (~0U) << (32 - BDB);                       \
+        for (col = x ; col < (x+w) ; col++) {                           \
+            uint32_t spix = *src;                                       \
+            *dst = (((spix << RSS) & RSM & RDM) >> RDS) |               \
+                   (((spix << GSS) & GSM & GDM) >> GDS) |               \
+                   (((spix << BSS) & BSM & BDM) >> BDS);                \
+            src = (SRC_T *) ((unsigned long) src + xenfb->depth / 8);   \
+            dst = (DST_T *) ((unsigned long) dst + xenfb->ds->depth / 8); \
         }                                                               \
     }
 
@@ -1106,26 +1119,29 @@
                    w * xenfb->depth / 8);
         }
     } else { /* Mismatch requires slow pixel munging */
+        /* 8 bit == r:3 g:3 b:2 */
+        /* 16 bit == r:5 g:6 b:5 */
+        /* 24 bit == r:8 g:8 b:8 */
+        /* 32 bit == r:8 g:8 b:8 (padding:8) */
         if (xenfb->depth == 8) {
-            /* 8 bit source == r:3 g:3 b:2 */
             if (xenfb->ds->depth == 16) {
-                BLT(uint8_t, uint16_t,   5, 2, 0,   11, 5, 0,   7, 7, 3);
+                BLT(uint8_t, uint16_t,   3, 3, 2,   5, 6, 5);
             } else if (xenfb->ds->depth == 32) {
-                BLT(uint8_t, uint32_t,   5, 2, 0,   16, 8, 0,   7, 7, 3);
+                BLT(uint8_t, uint32_t,   3, 3, 2,   8, 8, 8);
             }
         } else if (xenfb->depth == 16) {
-            /* 16 bit source == r:5 g:6 b:5 */
             if (xenfb->ds->depth == 8) {
-                BLT(uint16_t, uint8_t,    11, 5, 0,   5, 2, 0,    31, 63, 31);
+                BLT(uint16_t, uint8_t,   5, 6, 5,   3, 3, 2);
             } else if (xenfb->ds->depth == 32) {
-                BLT(uint16_t, uint32_t,   11, 5, 0,   16, 8, 0,   31, 63, 31);
+                BLT(uint16_t, uint32_t,  5, 6, 5,   8, 8, 8);
             }
-        } else if (xenfb->depth == 32) {
-            /* 32 bit source == r:8 g:8 b:8 (padding:8) */
+        } else if (xenfb->depth == 24 || xenfb->depth == 32) {
             if (xenfb->ds->depth == 8) {
-                BLT(uint32_t, uint8_t,    16, 8, 0,   5, 2, 0,    255, 255, 
255);
+                BLT(uint32_t, uint8_t,   8, 8, 8,   3, 3, 2);
             } else if (xenfb->ds->depth == 16) {
-                BLT(uint32_t, uint16_t,   16, 8, 0,   11, 5, 0,   255, 255, 
255);
+                BLT(uint32_t, uint16_t,  8, 8, 8,   5, 6, 5);
+            } else if (xenfb->ds->depth == 32) {
+                BLT(uint32_t, uint32_t,  8, 8, 8,   8, 8, 8);
             }
         }
     }

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>