summaryrefslogtreecommitdiff
path: root/gdk/broadway/gdkwindow-broadway.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-11-16 13:09:37 +0100
committerAlexander Larsson <alexl@redhat.com>2010-11-25 22:09:29 +0100
commit60cf2d53eb15904b790ab760d8b2265ff57333e2 (patch)
tree42f4430d0593302828ef41b0bba85d370b481abb /gdk/broadway/gdkwindow-broadway.c
parent7f0e43c0fd21dbe220f46cf930ef728a43719736 (diff)
downloadgtk+-60cf2d53eb15904b790ab760d8b2265ff57333e2.tar.gz
Track last_surface properly
Diffstat (limited to 'gdk/broadway/gdkwindow-broadway.c')
-rw-r--r--gdk/broadway/gdkwindow-broadway.c108
1 files changed, 96 insertions, 12 deletions
diff --git a/gdk/broadway/gdkwindow-broadway.c b/gdk/broadway/gdkwindow-broadway.c
index 994f1ba31f..f8095701e6 100644
--- a/gdk/broadway/gdkwindow-broadway.c
+++ b/gdk/broadway/gdkwindow-broadway.c
@@ -993,6 +993,101 @@ _gdk_windowing_window_set_composited (GdkWindow *window,
{
}
+
+static guint dirty_flush_id = 0;
+
+static void
+diff_surfaces (cairo_surface_t *surface,
+ cairo_surface_t *old_surface)
+{
+ guint8 *data, *old_data;
+ guint8 *line, *old_line;
+ int w, h, stride, old_stride;
+ int x, y;
+
+ data = cairo_image_surface_get_data (surface);
+ old_data = cairo_image_surface_get_data (old_surface);
+
+ w = cairo_image_surface_get_width (surface);
+ h = cairo_image_surface_get_height (surface);
+
+ stride = cairo_image_surface_get_stride (surface);
+ old_stride = cairo_image_surface_get_stride (old_surface);
+
+ for (y = 0; y < h; y++)
+ {
+ line = data;
+ old_line = old_data;
+
+ for (x = 0; x < w; x++)
+ {
+ int j;
+ for (j = 0; j < 4; j++)
+ old_line[j] = line[j] - old_line[j];
+ line += 4;
+ old_line += 4;
+ }
+
+ data += stride;
+ old_data += old_stride;
+ }
+}
+
+static gboolean
+dirty_flush_idle (gpointer data)
+{
+ GList *l;
+
+ dirty_flush_id = 0;
+
+ for (l = all_windows; l != NULL; l = l->next)
+ {
+ GdkWindowImplBroadway *impl = l->data;
+ GdkDrawableImplBroadway *drawable_impl = GDK_DRAWABLE_IMPL_BROADWAY (impl);
+ cairo_t *cr;
+
+ if (impl->dirty)
+ {
+ impl->dirty = FALSE;
+
+ if (impl->last_synced)
+ {
+ diff_surfaces (drawable_impl->surface,
+ drawable_impl->last_surface);
+ }
+
+ /* TODO: send data */
+
+ if (1)
+ {
+ static int nr = 0;
+ char *filename;
+ filename = g_strdup_printf ("frame-%d.png", nr++);
+ g_print ("writing window %p surface %p, name %s\n", drawable_impl->wrapper, drawable_impl->surface, filename);
+ cairo_surface_write_to_png (drawable_impl->surface, filename);
+ g_free (filename);
+ filename = g_strdup_printf ("frame-%d-old.png", nr++);
+ g_print ("writing window %p surface %p, name %s\n", drawable_impl->wrapper, drawable_impl->last_surface, filename);
+ cairo_surface_write_to_png (drawable_impl->last_surface, filename);
+ g_free (filename);
+ }
+
+ cr = cairo_create (drawable_impl->last_surface);
+ cairo_set_source_surface (cr, drawable_impl->surface, 0, 0);
+ cairo_paint (cr);
+ cairo_destroy (cr);
+ impl->last_synced = TRUE;
+ }
+ }
+ return FALSE;}
+
+static void
+queue_dirty_flush (void)
+{
+ if (dirty_flush_id == 0)
+ dirty_flush_id = gdk_threads_add_idle (dirty_flush_idle, NULL);
+}
+
void
_gdk_windowing_window_process_updates_recurse (GdkWindow *window,
cairo_region_t *region)
@@ -1005,6 +1100,7 @@ _gdk_windowing_window_process_updates_recurse (GdkWindow *window,
private = (GdkWindowObject *)window;
impl = GDK_WINDOW_IMPL_BROADWAY (private->impl);
impl->dirty = TRUE;
+ queue_dirty_flush ();
}
void
@@ -1015,18 +1111,6 @@ _gdk_windowing_before_process_all_updates (void)
void
_gdk_windowing_after_process_all_updates (void)
{
- GList *l;
-
- for (l = all_windows; l != NULL; l = l->next)
- {
- GdkWindowImplBroadway *impl = l->data;
-
- if (impl->dirty)
- {
- /* TODO: Flush dirty windows */
- impl->dirty = FALSE;
- }
- }
}
gboolean