From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LRVZL-0005SQ-1i for qemu-devel@nongnu.org; Mon, 26 Jan 2009 12:48:19 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LRVZJ-0005R5-7d for qemu-devel@nongnu.org; Mon, 26 Jan 2009 12:48:17 -0500 Received: from [199.232.76.173] (port=56618 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LRVZJ-0005Qq-2p for qemu-devel@nongnu.org; Mon, 26 Jan 2009 12:48:17 -0500 Received: from mx20.gnu.org ([199.232.41.8]:51774) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LRV2k-0003pp-MO for qemu-devel@nongnu.org; Mon, 26 Jan 2009 12:14:38 -0500 Received: from savannah.gnu.org ([199.232.41.3] helo=sv.gnu.org) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LRTam-0007Q4-CT for qemu-devel@nongnu.org; Mon, 26 Jan 2009 10:41:40 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LRTWl-0003Eq-4q for qemu-devel@nongnu.org; Mon, 26 Jan 2009 15:37:31 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LRTWk-0003El-Tn for qemu-devel@nongnu.org; Mon, 26 Jan 2009 15:37:31 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Mon, 26 Jan 2009 15:37:30 +0000 Subject: [Qemu-devel] [6441] vnc fixes and improvements (Stefano Stabellini) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6441 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6441 Author: aliguori Date: 2009-01-26 15:37:30 +0000 (Mon, 26 Jan 2009) Log Message: ----------- vnc fixes and improvements (Stefano Stabellini) this patch fixes a bug and improves the generic pixel conversion function in vnc.c. The bug is that when a new vnc client connects we need to reset the flag has_WMVi but currently we don't. The generic pixel conversion function is vnc_convert_pixel and currently is not very efficient since uses the division and multiplication operators. To make it more efficient I changed to use bit shift operators instead. Signed-off-by: Stefano Stabellini Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/console.c trunk/console.h trunk/vnc.c Modified: trunk/console.c =================================================================== --- trunk/console.c 2009-01-26 15:22:57 UTC (rev 6440) +++ trunk/console.c 2009-01-26 15:37:30 UTC (rev 6441) @@ -1470,6 +1470,9 @@ pf.rshift = 0; pf.gshift = 8; pf.bshift = 16; + pf.rbits = 8; + pf.gbits = 8; + pf.bbits = 8; break; case 32: pf.rmask = 0x0000FF00; @@ -1484,6 +1487,10 @@ pf.rshift = 8; pf.gshift = 16; pf.bshift = 24; + pf.rbits = 8; + pf.gbits = 8; + pf.bbits = 8; + pf.abits = 8; break; default: break; @@ -1512,6 +1519,9 @@ pf.rshift = 11; pf.gshift = 5; pf.bshift = 0; + pf.rbits = 5; + pf.gbits = 6; + pf.bbits = 5; break; case 24: pf.rmask = 0x00FF0000; @@ -1523,6 +1533,9 @@ pf.rshift = 16; pf.gshift = 8; pf.bshift = 0; + pf.rbits = 8; + pf.gbits = 8; + pf.bbits = 8; case 32: pf.rmask = 0x00FF0000; pf.gmask = 0x0000FF00; @@ -1535,6 +1548,10 @@ pf.rshift = 16; pf.gshift = 8; pf.bshift = 0; + pf.rbits = 8; + pf.gbits = 8; + pf.bbits = 8; + pf.abits = 8; break; default: break; Modified: trunk/console.h =================================================================== --- trunk/console.h 2009-01-26 15:22:57 UTC (rev 6440) +++ trunk/console.h 2009-01-26 15:37:30 UTC (rev 6441) @@ -83,6 +83,7 @@ uint32_t rmask, gmask, bmask, amask; uint8_t rshift, gshift, bshift, ashift; uint8_t rmax, gmax, bmax, amax; + uint8_t rbits, gbits, bbits, abits; }; struct DisplaySurface { Modified: trunk/vnc.c =================================================================== --- trunk/vnc.c 2009-01-26 15:22:57 UTC (rev 6440) +++ trunk/vnc.c 2009-01-26 15:37:30 UTC (rev 6441) @@ -56,6 +56,12 @@ #define VNC_DEBUG(fmt, ...) do { } while (0) #endif +#define count_bits(c, v) { \ + for (c = 0; v; v >>= 1) \ + { \ + c += v & 1; \ + } \ +} typedef struct Buffer { @@ -329,12 +335,12 @@ { uint8_t r, g, b; - r = ((v >> vs->serverds.pf.rshift) & vs->serverds.pf.rmax) * (vs->clientds.pf.rmax + 1) / - (vs->serverds.pf.rmax + 1); - g = ((v >> vs->serverds.pf.gshift) & vs->serverds.pf.gmax) * (vs->clientds.pf.gmax + 1) / - (vs->serverds.pf.gmax + 1); - b = ((v >> vs->serverds.pf.bshift) & vs->serverds.pf.bmax) * (vs->clientds.pf.bmax + 1) / - (vs->serverds.pf.bmax + 1); + r = ((((v & vs->serverds.pf.rmask) >> vs->serverds.pf.rshift) << vs->clientds.pf.rbits) >> + vs->serverds.pf.rbits); + g = ((((v & vs->serverds.pf.gmask) >> vs->serverds.pf.gshift) << vs->clientds.pf.gbits) >> + vs->serverds.pf.gbits); + b = ((((v & vs->serverds.pf.bmask) >> vs->serverds.pf.bshift) << vs->clientds.pf.bbits) >> + vs->serverds.pf.bbits); v = (r << vs->clientds.pf.rshift) | (g << vs->clientds.pf.gshift) | (b << vs->clientds.pf.bshift); @@ -1272,12 +1278,15 @@ vs->clientds = vs->serverds; vs->clientds.pf.rmax = red_max; + count_bits(vs->clientds.pf.rbits, red_max); vs->clientds.pf.rshift = red_shift; vs->clientds.pf.rmask = red_max << red_shift; vs->clientds.pf.gmax = green_max; + count_bits(vs->clientds.pf.gbits, green_max); vs->clientds.pf.gshift = green_shift; vs->clientds.pf.gmask = green_max << green_shift; vs->clientds.pf.bmax = blue_max; + count_bits(vs->clientds.pf.bbits, blue_max); vs->clientds.pf.bshift = blue_shift; vs->clientds.pf.bmask = blue_max << blue_shift; vs->clientds.pf.bits_per_pixel = bits_per_pixel; @@ -2106,6 +2115,7 @@ memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row)); vs->has_resize = 0; vs->has_hextile = 0; + vs->has_WMVi = 0; dcl->dpy_copy = NULL; vnc_update_client(vs); reset_keys(vs);