summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2010-12-20 18:14:19 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2010-12-20 18:14:19 +0100
commit512df3a6e0a4623fd401b678894ed9e3409b2659 (patch)
tree36da606c96e95e2ccd92798641a0b1f1fc2a328f
parent83779b9ccfed4e24a3d82f8b6212247f75d4a3dd (diff)
gtk: improve 16bits color code, fix rendering glitches
-rw-r--r--gtk/spice-widget-cairo.c4
-rw-r--r--gtk/spice-widget.c24
2 files changed, 13 insertions, 15 deletions
diff --git a/gtk/spice-widget-cairo.c b/gtk/spice-widget-cairo.c
index e4a2ecf..909ceda 100644
--- a/gtk/spice-widget-cairo.c
+++ b/gtk/spice-widget-cairo.c
@@ -118,7 +118,7 @@ static gboolean draw_event(SpiceDisplay *display, cairo_t *cr)
cairo_fill(cr);
}
- /* Draw the VNC display */
+ /* Draw the display */
if (d->ximage) {
if (d->allow_scaling) {
double sx, sy;
@@ -167,8 +167,6 @@ void spicex_image_invalidate(SpiceDisplay *display,
spice_display *d = SPICE_DISPLAY_GET_PRIVATE(display);
int ww, wh;
- /* FIXME: something goes wrong in 16 bits */
-
gdk_drawable_get_size(gtk_widget_get_window(GTK_WIDGET(display)), &ww, &wh);
/* If we have a pixmap, update the region which changed.
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index b132021..0e3f51e 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -494,21 +494,24 @@ static void recalc_geometry(GtkWidget *widget, gboolean set_display)
#define CONVERT_0555_TO_8888(s) (CONVERT_0555_TO_0888(s) | 0xff000000)
-static gboolean expose_event_convert(GtkWidget *widget, GdkEventExpose *expose)
+static gboolean do_color_convert(SpiceDisplay *display,
+ gint x, gint y, gint w, gint h)
{
- SpiceDisplay *display = SPICE_DISPLAY(widget);
spice_display *d = SPICE_DISPLAY_GET_PRIVATE(display);
int i, j, maxy, maxx, miny, minx;
guint32 *dest = d->data;
guint16 *src = d->data_origin;
+ if (!d->convert)
+ return true;
+
g_return_val_if_fail(d->format == SPICE_SURFACE_FMT_16_555 ||
d->format == SPICE_SURFACE_FMT_16_565, false);
- miny = MAX(expose->area.y - d->my, 0);
- minx = MAX(expose->area.x - d->mx, 0);
- maxy = MIN(expose->area.y - d->my + expose->area.height, d->height);
- maxx = MIN(expose->area.x - d->mx + expose->area.width, d->width);
+ miny = MAX(y, 0);
+ minx = MAX(x, 0);
+ maxy = MIN(y + h, d->height);
+ maxx = MIN(x + w, d->width);
dest += (d->stride / 4) * miny;
src += (d->stride / 2) * miny;
@@ -554,11 +557,6 @@ static gboolean expose_event(GtkWidget *widget, GdkEventExpose *expose)
spicex_image_create(display);
}
- if (d->convert) {
- if (!expose_event_convert(widget, expose))
- return false;
- }
-
spicex_expose_event(display, expose);
return true;
}
@@ -1195,7 +1193,9 @@ static void invalidate(SpiceChannel *channel,
{
SpiceDisplay *display = data;
- /* TODO: do color convert here */
+ if (!do_color_convert(display, x, y, w, h))
+ return;
+
spicex_image_invalidate(display, &x, &y, &w, &h);
gtk_widget_queue_draw_area(GTK_WIDGET(display),
x, y, w, h);