ia64/xen-unstable

changeset 17170:be143a3a90c6

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@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Mar 03 11:05:18 2008 +0000 (2008-03-03)
parents 56a7feb9de14
children 69bb0c4af952
files tools/ioemu/hw/xenfb.c
line diff
     1.1 --- a/tools/ioemu/hw/xenfb.c	Mon Mar 03 11:04:53 2008 +0000
     1.2 +++ b/tools/ioemu/hw/xenfb.c	Mon Mar 03 11:05:18 2008 +0000
     1.3 @@ -1071,8 +1071,8 @@ static void xenfb_mouse_event(void *opaq
     1.4  }
     1.5  
     1.6  /* A convenient function for munging pixels between different depths */
     1.7 -#define BLT(SRC_T,DST_T,RLS,GLS,BLS,RRS,GRS,BRS,RM,GM,BM)               \
     1.8 -    for (line = y ; line < h ; line++) {                                \
     1.9 +#define BLT(SRC_T,DST_T,RSB,GSB,BSB,RDB,GDB,BDB)                        \
    1.10 +    for (line = y ; line < (y+h) ; line++) {                            \
    1.11          SRC_T *src = (SRC_T *)(xenfb->pixels                            \
    1.12                                 + (line * xenfb->row_stride)             \
    1.13                                 + (x * xenfb->depth / 8));               \
    1.14 @@ -1080,12 +1080,25 @@ static void xenfb_mouse_event(void *opaq
    1.15                                 + (line * xenfb->ds->linesize)                  \
    1.16                                 + (x * xenfb->ds->depth / 8));                  \
    1.17          int col;                                                        \
    1.18 -        for (col = x ; col < w ; col++) {                               \
    1.19 -            *dst = (((*src >> RRS) & RM) << RLS) |                      \
    1.20 -                (((*src >> GRS) & GM) << GLS) |                         \
    1.21 -                (((*src >> GRS) & BM) << BLS);                          \
    1.22 -            src++;                                                      \
    1.23 -            dst++;                                                      \
    1.24 +        const int RSS = 32 - (RSB + GSB + BSB);                         \
    1.25 +        const int GSS = 32 - (GSB + BSB);                               \
    1.26 +        const int BSS = 32 - (BSB);                                     \
    1.27 +        const uint32_t RSM = (~0U) << (32 - RSB);                       \
    1.28 +        const uint32_t GSM = (~0U) << (32 - GSB);                       \
    1.29 +        const uint32_t BSM = (~0U) << (32 - BSB);                       \
    1.30 +        const int RDS = 32 - (RDB + GDB + BDB);                         \
    1.31 +        const int GDS = 32 - (GDB + BDB);                               \
    1.32 +        const int BDS = 32 - (BDB);                                     \
    1.33 +        const uint32_t RDM = (~0U) << (32 - RDB);                       \
    1.34 +        const uint32_t GDM = (~0U) << (32 - GDB);                       \
    1.35 +        const uint32_t BDM = (~0U) << (32 - BDB);                       \
    1.36 +        for (col = x ; col < (x+w) ; col++) {                           \
    1.37 +            uint32_t spix = *src;                                       \
    1.38 +            *dst = (((spix << RSS) & RSM & RDM) >> RDS) |               \
    1.39 +                   (((spix << GSS) & GSM & GDM) >> GDS) |               \
    1.40 +                   (((spix << BSS) & BSM & BDM) >> BDS);                \
    1.41 +            src = (SRC_T *) ((unsigned long) src + xenfb->depth / 8);   \
    1.42 +            dst = (DST_T *) ((unsigned long) dst + xenfb->ds->depth / 8); \
    1.43          }                                                               \
    1.44      }
    1.45  
    1.46 @@ -1106,26 +1119,29 @@ static void xenfb_guest_copy(struct xenf
    1.47                     w * xenfb->depth / 8);
    1.48          }
    1.49      } else { /* Mismatch requires slow pixel munging */
    1.50 +        /* 8 bit == r:3 g:3 b:2 */
    1.51 +        /* 16 bit == r:5 g:6 b:5 */
    1.52 +        /* 24 bit == r:8 g:8 b:8 */
    1.53 +        /* 32 bit == r:8 g:8 b:8 (padding:8) */
    1.54          if (xenfb->depth == 8) {
    1.55 -            /* 8 bit source == r:3 g:3 b:2 */
    1.56              if (xenfb->ds->depth == 16) {
    1.57 -                BLT(uint8_t, uint16_t,   5, 2, 0,   11, 5, 0,   7, 7, 3);
    1.58 +                BLT(uint8_t, uint16_t,   3, 3, 2,   5, 6, 5);
    1.59              } else if (xenfb->ds->depth == 32) {
    1.60 -                BLT(uint8_t, uint32_t,   5, 2, 0,   16, 8, 0,   7, 7, 3);
    1.61 +                BLT(uint8_t, uint32_t,   3, 3, 2,   8, 8, 8);
    1.62              }
    1.63          } else if (xenfb->depth == 16) {
    1.64 -            /* 16 bit source == r:5 g:6 b:5 */
    1.65              if (xenfb->ds->depth == 8) {
    1.66 -                BLT(uint16_t, uint8_t,    11, 5, 0,   5, 2, 0,    31, 63, 31);
    1.67 +                BLT(uint16_t, uint8_t,   5, 6, 5,   3, 3, 2);
    1.68              } else if (xenfb->ds->depth == 32) {
    1.69 -                BLT(uint16_t, uint32_t,   11, 5, 0,   16, 8, 0,   31, 63, 31);
    1.70 +                BLT(uint16_t, uint32_t,  5, 6, 5,   8, 8, 8);
    1.71              }
    1.72 -        } else if (xenfb->depth == 32) {
    1.73 -            /* 32 bit source == r:8 g:8 b:8 (padding:8) */
    1.74 +        } else if (xenfb->depth == 24 || xenfb->depth == 32) {
    1.75              if (xenfb->ds->depth == 8) {
    1.76 -                BLT(uint32_t, uint8_t,    16, 8, 0,   5, 2, 0,    255, 255, 255);
    1.77 +                BLT(uint32_t, uint8_t,   8, 8, 8,   3, 3, 2);
    1.78              } else if (xenfb->ds->depth == 16) {
    1.79 -                BLT(uint32_t, uint16_t,   16, 8, 0,   11, 5, 0,   255, 255, 255);
    1.80 +                BLT(uint32_t, uint16_t,  8, 8, 8,   5, 6, 5);
    1.81 +            } else if (xenfb->ds->depth == 32) {
    1.82 +                BLT(uint32_t, uint32_t,  8, 8, 8,   8, 8, 8);
    1.83              }
    1.84          }
    1.85      }