From: Fabrice Bellard <fabrice@bellard.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] qemu vnc.c
Date: Tue, 13 Jun 2006 16:35:24 +0000 [thread overview]
Message-ID: <E1FqBrQ-0005He-6e@savannah.gnu.org> (raw)
CVSROOT: /sources/qemu
Module name: qemu
Changes by: Fabrice Bellard <bellard> 06/06/13 16:35:24
Modified files:
. : vnc.c
Log message:
support for higher resolutions
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemu/vnc.c?cvsroot=qemu&r1=1.6&r2=1.7
Patches:
Index: vnc.c
===================================================================
RCS file: /sources/qemu/qemu/vnc.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- vnc.c 14 May 2006 18:11:49 -0000 1.6
+++ vnc.c 13 Jun 2006 16:35:24 -0000 1.7
@@ -50,6 +50,10 @@
uint32_t *last_fg,
int *has_bg, int *has_fg);
+#define VNC_MAX_WIDTH 2048
+#define VNC_MAX_HEIGHT 2048
+#define VNC_DIRTY_WORDS (VNC_MAX_WIDTH / (16 * 32))
+
struct VncState
{
QEMUTimer *timer;
@@ -59,7 +63,7 @@
int need_update;
int width;
int height;
- uint64_t dirty_row[768];
+ uint32_t dirty_row[VNC_MAX_HEIGHT][VNC_DIRTY_WORDS];
char *old_data;
int depth; /* internal VNC frame buffer byte per pixel */
int has_resize;
@@ -95,6 +99,47 @@
static void vnc_update_client(void *opaque);
static void vnc_client_read(void *opaque);
+static inline void vnc_set_bit(uint32_t *d, int k)
+{
+ d[k >> 5] |= 1 << (k & 0x1f);
+}
+
+static inline void vnc_clear_bit(uint32_t *d, int k)
+{
+ d[k >> 5] &= ~(1 << (k & 0x1f));
+}
+
+static inline void vnc_set_bits(uint32_t *d, int n, int nb_words)
+{
+ int j;
+
+ j = 0;
+ while (n >= 32) {
+ d[j++] = -1;
+ n -= 32;
+ }
+ if (n > 0)
+ d[j++] = (1 << n) - 1;
+ while (j < nb_words)
+ d[j++] = 0;
+}
+
+static inline int vnc_get_bit(const uint32_t *d, int k)
+{
+ return (d[k >> 5] >> (k & 0x1f)) & 1;
+}
+
+static inline int vnc_and_bits(const uint32_t *d1, const uint32_t *d2,
+ int nb_words)
+{
+ int i;
+ for(i = 0; i < nb_words; i++) {
+ if ((d1[i] & d2[i]) != 0)
+ return 1;
+ }
+ return 0;
+}
+
static void vnc_dpy_update(DisplayState *ds, int x, int y, int w, int h)
{
VncState *vs = ds->opaque;
@@ -104,7 +149,7 @@
for (; y < h; y++)
for (i = 0; i < w; i += 16)
- vs->dirty_row[y] |= (1ULL << ((x + i) / 16));
+ vnc_set_bit(vs->dirty_row[y], (x + i) / 16);
}
static void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h,
@@ -316,10 +361,10 @@
for (h = 1; h < (vs->height - y); h++) {
int tmp_x;
- if (!(vs->dirty_row[y + h] & (1ULL << last_x)))
+ if (!vnc_get_bit(vs->dirty_row[y + h], last_x))
break;
for (tmp_x = last_x; tmp_x < x; tmp_x++)
- vs->dirty_row[y + h] &= ~(1ULL << tmp_x);
+ vnc_clear_bit(vs->dirty_row[y + h], tmp_x);
}
return h;
@@ -333,15 +378,12 @@
int y;
char *row;
char *old_row;
- uint64_t width_mask;
+ uint32_t width_mask[VNC_DIRTY_WORDS];
int n_rectangles;
int saved_offset;
int has_dirty = 0;
- width_mask = (1ULL << (vs->width / 16)) - 1;
-
- if (vs->width == 1024)
- width_mask = ~(0ULL);
+ vnc_set_bits(width_mask, (vs->width / 16), VNC_DIRTY_WORDS);
/* Walk through the dirty map and eliminate tiles that
really aren't dirty */
@@ -349,7 +391,7 @@
old_row = vs->old_data;
for (y = 0; y < vs->height; y++) {
- if (vs->dirty_row[y] & width_mask) {
+ if (vnc_and_bits(vs->dirty_row[y], width_mask, VNC_DIRTY_WORDS)) {
int x;
char *ptr, *old_ptr;
@@ -358,7 +400,7 @@
for (x = 0; x < vs->ds->width; x += 16) {
if (memcmp(old_ptr, ptr, 16 * vs->depth) == 0) {
- vs->dirty_row[y] &= ~(1ULL << (x / 16));
+ vnc_clear_bit(vs->dirty_row[y], (x / 16));
} else {
has_dirty = 1;
memcpy(old_ptr, ptr, 16 * vs->depth);
@@ -389,11 +431,11 @@
int x;
int last_x = -1;
for (x = 0; x < vs->width / 16; x++) {
- if (vs->dirty_row[y] & (1ULL << x)) {
+ if (vnc_get_bit(vs->dirty_row[y], x)) {
if (last_x == -1) {
last_x = x;
}
- vs->dirty_row[y] &= ~(1ULL << x);
+ vnc_clear_bit(vs->dirty_row[y], x);
} else {
if (last_x != -1) {
int h = find_dirty_height(vs, y, last_x, x);
@@ -688,10 +730,8 @@
char *old_row = vs->old_data + y_position * vs->ds->linesize;
for (i = 0; i < h; i++) {
- vs->dirty_row[y_position + i] = (1ULL << (vs->ds->width / 16)) - 1;
- if (vs->ds->width == 1024) {
- vs->dirty_row[y_position + i] = ~(0ULL);
- }
+ vnc_set_bits(vs->dirty_row[y_position + i],
+ (vs->ds->width / 16), VNC_DIRTY_WORDS);
memset(old_row, 42, vs->ds->width * vs->depth);
old_row += vs->ds->linesize;
}
next reply other threads:[~2006-06-13 16:35 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-13 16:35 Fabrice Bellard [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-01-14 21:45 [Qemu-devel] qemu vnc.c Andrzej Zaborowski
2008-01-13 23:51 Andrzej Zaborowski
2008-01-14 20:05 ` Anders Melchiorsen
2008-01-14 20:19 ` Johannes Schindelin
2008-01-14 20:38 ` Anders Melchiorsen
2008-01-14 21:06 ` Johannes Schindelin
2008-01-14 22:19 ` Anders Melchiorsen
2008-01-15 11:03 ` Johannes Schindelin
2008-01-16 20:18 ` Anders Melchiorsen
2007-12-11 22:31 Andrzej Zaborowski
2007-10-31 1:58 Andrzej Zaborowski
2007-09-30 13:01 Thiemo Seufer
2007-09-13 12:41 Thiemo Seufer
2007-09-14 21:26 ` Matthew Kent
2007-09-17 17:43 ` Matthew Kent
2007-08-25 1:39 Thiemo Seufer
2007-08-25 1:39 Thiemo Seufer
2007-08-25 1:38 Thiemo Seufer
2007-04-29 1:53 Thiemo Seufer
2007-02-05 20:14 Fabrice Bellard
2006-12-14 13:36 Thiemo Seufer
2006-08-24 20:36 Fabrice Bellard
2006-05-03 21:18 Fabrice Bellard
2006-05-01 21:44 Fabrice Bellard
2006-05-01 10:38 Fabrice Bellard
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=E1FqBrQ-0005He-6e@savannah.gnu.org \
--to=fabrice@bellard.org \
--cc=qemu-devel@nongnu.org \
/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.