[gtk+/broadway: 11/71] Track last_surface properly
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/broadway: 11/71] Track last_surface properly
- Date: Thu, 25 Nov 2010 21:16:11 +0000 (UTC)
commit 60cf2d53eb15904b790ab760d8b2265ff57333e2
Author: Alexander Larsson <alexl redhat com>
Date: Tue Nov 16 13:09:37 2010 +0100
Track last_surface properly
gdk/broadway/gdkwindow-broadway.c | 108 ++++++++++++++++++++++++++++++++----
gdk/broadway/gdkwindow-broadway.h | 2 +-
2 files changed, 97 insertions(+), 13 deletions(-)
---
diff --git a/gdk/broadway/gdkwindow-broadway.c b/gdk/broadway/gdkwindow-broadway.c
index 994f1ba..f809570 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
diff --git a/gdk/broadway/gdkwindow-broadway.h b/gdk/broadway/gdkwindow-broadway.h
index 78faf15..0871f29 100644
--- a/gdk/broadway/gdkwindow-broadway.h
+++ b/gdk/broadway/gdkwindow-broadway.h
@@ -54,7 +54,7 @@ struct _GdkWindowImplBroadway
gint8 toplevel_window_type;
gboolean dirty;
-
+ gboolean last_synced;
};
struct _GdkWindowImplBroadwayClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]