@@ -2717,8 +2717,9 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
break;
}
y = offset / VNC_DIRTY_BPL(&vd->guest);
-
- server_ptr = server_row0 + y * server_stride;
+ x = offset % VNC_DIRTY_BPL(&vd->guest);
+
+ server_ptr = server_row0 + y * server_stride + x * cmp_bytes;
if (vd->guest.format != VNC_SERVER_FB_FORMAT) {
qemu_pixman_linebuf_fill(tmpbuf, vd->guest.fb, width, 0, y);
@@ -2726,13 +2727,11 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
} else {
guest_ptr = guest_row0 + y * guest_stride;
}
+ guest_ptr += x * cmp_bytes;
- for (x = offset % VNC_DIRTY_BPL(&vd->guest);
- x + VNC_DIRTY_PIXELS_PER_BIT - 1 < width;
- x += VNC_DIRTY_PIXELS_PER_BIT, guest_ptr += cmp_bytes,
- server_ptr += cmp_bytes) {
- if (!test_and_clear_bit((x / VNC_DIRTY_PIXELS_PER_BIT),
- vd->guest.dirty[y])) {
+ for (;x < DIV_ROUND_UP(width, VNC_DIRTY_PIXELS_PER_BIT);
+ x++, guest_ptr += cmp_bytes, server_ptr += cmp_bytes) {
+ if (!test_and_clear_bit(x, vd->guest.dirty[y])) {
continue;
}
if (memcmp(server_ptr, guest_ptr, cmp_bytes) == 0) {
@@ -2740,10 +2739,11 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
}
memcpy(server_ptr, guest_ptr, cmp_bytes);
if (!vd->non_adaptive) {
- vnc_rect_updated(vd, x, y, &tv);
+ vnc_rect_updated(vd, x * VNC_DIRTY_PIXELS_PER_BIT,
+ y, &tv);
}
QTAILQ_FOREACH(vs, &vd->clients, next) {
- set_bit((x / VNC_DIRTY_PIXELS_PER_BIT), vs->dirty[y]);
+ set_bit(x, vs->dirty[y]);
}
has_dirty++;
}