Revision f0875536 ui/gtk.c
b/ui/gtk.c | ||
---|---|---|
147 | 147 |
GtkWidget *notebook; |
148 | 148 |
GtkWidget *drawing_area; |
149 | 149 |
cairo_surface_t *surface; |
150 |
pixman_image_t *convert; |
|
150 | 151 |
DisplayChangeListener dcl; |
151 | 152 |
DisplaySurface *ds; |
152 | 153 |
int button_mask; |
... | ... | |
303 | 304 |
|
304 | 305 |
DPRINTF("update(x=%d, y=%d, w=%d, h=%d)\n", x, y, w, h); |
305 | 306 |
|
307 |
if (s->convert) { |
|
308 |
pixman_image_composite(PIXMAN_OP_SRC, s->ds->image, NULL, s->convert, |
|
309 |
x, y, 0, 0, x, y, w, h); |
|
310 |
} |
|
311 |
|
|
306 | 312 |
x1 = floor(x * s->scale_x); |
307 | 313 |
y1 = floor(y * s->scale_y); |
308 | 314 |
|
... | ... | |
388 | 394 |
DisplaySurface *surface) |
389 | 395 |
{ |
390 | 396 |
GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl); |
391 |
cairo_format_t kind; |
|
392 | 397 |
bool resized = true; |
393 |
int stride; |
|
394 | 398 |
|
395 | 399 |
DPRINTF("resize(width=%d, height=%d)\n", |
396 | 400 |
surface_width(surface), surface_height(surface)); |
... | ... | |
405 | 409 |
resized = false; |
406 | 410 |
} |
407 | 411 |
s->ds = surface; |
408 |
switch (surface_bits_per_pixel(surface)) { |
|
409 |
case 8: |
|
410 |
kind = CAIRO_FORMAT_A8; |
|
411 |
break; |
|
412 |
case 16: |
|
413 |
kind = CAIRO_FORMAT_RGB16_565; |
|
414 |
break; |
|
415 |
case 32: |
|
416 |
kind = CAIRO_FORMAT_RGB24; |
|
417 |
break; |
|
418 |
default: |
|
419 |
g_assert_not_reached(); |
|
420 |
break; |
|
421 |
} |
|
422 | 412 |
|
423 |
stride = cairo_format_stride_for_width(kind, surface_width(surface)); |
|
424 |
g_assert(surface_stride(surface) == stride); |
|
413 |
if (s->convert) { |
|
414 |
pixman_image_unref(s->convert); |
|
415 |
s->convert = NULL; |
|
416 |
} |
|
425 | 417 |
|
426 |
s->surface = cairo_image_surface_create_for_data(surface_data(surface), |
|
427 |
kind, |
|
428 |
surface_width(surface), |
|
429 |
surface_height(surface), |
|
430 |
surface_stride(surface)); |
|
418 |
if (surface->format == PIXMAN_x8r8g8b8) { |
|
419 |
/* |
|
420 |
* PIXMAN_x8r8g8b8 == CAIRO_FORMAT_RGB24 |
|
421 |
* |
|
422 |
* No need to convert, use surface directly. Should be the |
|
423 |
* common case as this is qemu_default_pixelformat(32) too. |
|
424 |
*/ |
|
425 |
s->surface = cairo_image_surface_create_for_data |
|
426 |
(surface_data(surface), |
|
427 |
CAIRO_FORMAT_RGB24, |
|
428 |
surface_width(surface), |
|
429 |
surface_height(surface), |
|
430 |
surface_stride(surface)); |
|
431 |
} else { |
|
432 |
/* Must convert surface, use pixman to do it. */ |
|
433 |
s->convert = pixman_image_create_bits(PIXMAN_x8r8g8b8, |
|
434 |
surface_width(surface), |
|
435 |
surface_height(surface), |
|
436 |
NULL, 0); |
|
437 |
s->surface = cairo_image_surface_create_for_data |
|
438 |
((void *)pixman_image_get_data(s->convert), |
|
439 |
CAIRO_FORMAT_RGB24, |
|
440 |
pixman_image_get_width(s->convert), |
|
441 |
pixman_image_get_height(s->convert), |
|
442 |
pixman_image_get_stride(s->convert)); |
|
443 |
pixman_image_composite(PIXMAN_OP_SRC, s->ds->image, NULL, s->convert, |
|
444 |
0, 0, 0, 0, 0, 0, |
|
445 |
pixman_image_get_width(s->convert), |
|
446 |
pixman_image_get_height(s->convert)); |
|
447 |
} |
|
431 | 448 |
|
432 | 449 |
if (resized) { |
433 | 450 |
gd_update_windowsize(s); |
Also available in: Unified diff