From: Samuel Thibault <samuel.thibault@eu.citrix.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH2] ioemu: fix xenfb slow case update
Date: Fri, 29 Feb 2008 17:37:01 +0000 [thread overview]
Message-ID: <20080229173701.GD8268@implementation.uk.xensource.com> (raw)
In-Reply-To: <20080229152622.GC8268@implementation.uk.xensource.com>
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@eu.citrix.com>
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);
}
}
}
prev parent reply other threads:[~2008-02-29 17:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-29 15:26 [PATCH] ioemu: fix xenfb slow case update Samuel Thibault
2008-02-29 17:37 ` Samuel Thibault [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080229173701.GD8268@implementation.uk.xensource.com \
--to=samuel.thibault@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.