Revision b021bd29 ui/spice-display.c
b/ui/spice-display.c | ||
---|---|---|
239 | 239 |
|
240 | 240 |
static void qemu_spice_create_update(SimpleSpiceDisplay *ssd) |
241 | 241 |
{ |
242 |
static const int blksize = 32; |
|
243 |
int blocks = (ds_get_width(ssd->ds) + blksize - 1) / blksize; |
|
244 |
int dirty_top[blocks]; |
|
245 |
int y, yoff, x, xoff, blk, bw; |
|
246 |
int bpp = ds_get_bytes_per_pixel(ssd->ds); |
|
247 |
uint8_t *guest, *mirror; |
|
248 |
|
|
242 | 249 |
if (qemu_spice_rect_is_empty(&ssd->dirty)) { |
243 | 250 |
return; |
244 | 251 |
}; |
... | ... | |
253 | 260 |
ssd->ds_mirror = g_malloc0(size); |
254 | 261 |
} |
255 | 262 |
|
256 |
qemu_spice_create_one_update(ssd, &ssd->dirty); |
|
263 |
for (blk = 0; blk < blocks; blk++) { |
|
264 |
dirty_top[blk] = -1; |
|
265 |
} |
|
266 |
|
|
267 |
guest = ds_get_data(ssd->ds); |
|
268 |
mirror = ssd->ds_mirror; |
|
269 |
for (y = ssd->dirty.top; y < ssd->dirty.bottom; y++) { |
|
270 |
yoff = y * ds_get_linesize(ssd->ds); |
|
271 |
for (x = ssd->dirty.left; x < ssd->dirty.right; x += blksize) { |
|
272 |
xoff = x * bpp; |
|
273 |
blk = x / blksize; |
|
274 |
bw = MIN(blksize, ssd->dirty.right - x); |
|
275 |
if (memcmp(guest + yoff + xoff, |
|
276 |
mirror + yoff + xoff, |
|
277 |
bw * bpp) == 0) { |
|
278 |
if (dirty_top[blk] != -1) { |
|
279 |
QXLRect update = { |
|
280 |
.top = dirty_top[blk], |
|
281 |
.bottom = y, |
|
282 |
.left = x, |
|
283 |
.right = x + bw, |
|
284 |
}; |
|
285 |
qemu_spice_create_one_update(ssd, &update); |
|
286 |
dirty_top[blk] = -1; |
|
287 |
} |
|
288 |
} else { |
|
289 |
if (dirty_top[blk] == -1) { |
|
290 |
dirty_top[blk] = y; |
|
291 |
} |
|
292 |
} |
|
293 |
} |
|
294 |
} |
|
295 |
|
|
296 |
for (x = ssd->dirty.left; x < ssd->dirty.right; x += blksize) { |
|
297 |
blk = x / blksize; |
|
298 |
bw = MIN(blksize, ssd->dirty.right - x); |
|
299 |
if (dirty_top[blk] != -1) { |
|
300 |
QXLRect update = { |
|
301 |
.top = dirty_top[blk], |
|
302 |
.bottom = ssd->dirty.bottom, |
|
303 |
.left = x, |
|
304 |
.right = x + bw, |
|
305 |
}; |
|
306 |
qemu_spice_create_one_update(ssd, &update); |
|
307 |
dirty_top[blk] = -1; |
|
308 |
} |
|
309 |
} |
|
310 |
|
|
257 | 311 |
memset(&ssd->dirty, 0, sizeof(ssd->dirty)); |
258 | 312 |
} |
259 | 313 |
|
Also available in: Unified diff