[gtk+/wip/alexl/broadway4: 61/62] broadway: Prepare for implementing diff
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/alexl/broadway4: 61/62] broadway: Prepare for implementing diff
- Date: Thu, 30 Nov 2017 07:35:49 +0000 (UTC)
commit 226507120e04d02d8919190000432d71cea137ed
Author: Alexander Larsson <alexl redhat com>
Date: Wed Nov 29 20:05:02 2017 +0100
broadway: Prepare for implementing diff
gdk/broadway/broadway-output.c | 38 +++++++++++++++++++++++---------------
gdk/broadway/broadway-output.h | 3 ++-
gdk/broadway/broadway-server.c | 10 +++++-----
3 files changed, 30 insertions(+), 21 deletions(-)
---
diff --git a/gdk/broadway/broadway-output.c b/gdk/broadway/broadway-output.c
index e679923..9389de4 100644
--- a/gdk/broadway/broadway-output.c
+++ b/gdk/broadway/broadway-output.c
@@ -155,6 +155,19 @@ append_uint32 (BroadwayOutput *output, guint32 v)
}
static void
+patch_uint32 (BroadwayOutput *output, guint32 v, gsize offset)
+{
+ guint8 *buf;
+
+ buf = (guint8 *)output->buf->str + offset;
+ buf[0] = (v >> 0) & 0xff;
+ buf[1] = (v >> 8) & 0xff;
+ buf[2] = (v >> 16) & 0xff;
+ buf[3] = (v >> 24) & 0xff;
+}
+
+
+static void
write_header(BroadwayOutput *output, char op)
{
append_char (output, op);
@@ -309,29 +322,24 @@ append_node (BroadwayOutput *output,
append_node (output, node->children[i]);
}
-guint32
-get_node_size (BroadwayNode *node)
-{
- guint32 size = 1 + node->n_data;
- guint32 i;
-
- for (i = 0; i < node->n_children; i++)
- size += get_node_size (node->children[i]);
-
- return size;
-}
-
-
void
broadway_output_window_set_nodes (BroadwayOutput *output,
int id,
- BroadwayNode *root)
+ BroadwayNode *root,
+ BroadwayNode *old_root)
{
+ gsize size_pos, start, end;
write_header (output, BROADWAY_OP_SET_NODES);
append_uint16 (output, id);
- append_uint32 (output, get_node_size (root));
+
+ size_pos = output->buf->len;
+ append_uint32 (output, 0);
+
+ start = output->buf->len;
append_node (output, root);
+ end = output->buf->len;
+ patch_uint32 (output, (end - start) / 4, size_pos);
}
void
diff --git a/gdk/broadway/broadway-output.h b/gdk/broadway/broadway-output.h
index db1ba94..4f18b6e 100644
--- a/gdk/broadway/broadway-output.h
+++ b/gdk/broadway/broadway-output.h
@@ -59,7 +59,8 @@ void broadway_output_set_transient_for (BroadwayOutput *output,
int parent_id);
void broadway_output_window_set_nodes (BroadwayOutput *output,
int id,
- BroadwayNode *root);
+ BroadwayNode *root,
+ BroadwayNode *old_root);
void broadway_output_upload_texture (BroadwayOutput *output,
guint32 id,
GBytes *texture);
diff --git a/gdk/broadway/broadway-server.c b/gdk/broadway/broadway-server.c
index a6b3114..3cbd214 100644
--- a/gdk/broadway/broadway-server.c
+++ b/gdk/broadway/broadway-server.c
@@ -1635,13 +1635,13 @@ broadway_server_window_set_nodes (BroadwayServer *server,
if (window == NULL)
return;
+ if (server->output != NULL)
+ broadway_output_window_set_nodes (server->output, window->id,
+ root, window->nodes);
+
if (window->nodes)
broadway_node_free (window->nodes);
window->nodes = root;
-
- if (server->output != NULL)
- broadway_output_window_set_nodes (server->output, window->id,
- window->nodes);
}
guint32
@@ -1888,7 +1888,7 @@ broadway_server_resync_windows (BroadwayServer *server)
if (window->nodes)
broadway_output_window_set_nodes (server->output, window->id,
- window->nodes);
+ window->nodes, NULL);
if (window->visible)
broadway_output_show_surface (server->output, window->id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]