[gtk+/wip/alexl/broadway4: 88/96] broadway: Add shadow node
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/alexl/broadway4: 88/96] broadway: Add shadow node
- Date: Thu, 23 Nov 2017 09:53:39 +0000 (UTC)
commit 9b1f6acc2bf7b51781772dd5623b8f4701e4e520
Author: Alexander Larsson <alexl redhat com>
Date: Wed Nov 22 16:53:15 2017 +0100
broadway: Add shadow node
gdk/broadway/broadway-protocol.h | 1 +
gdk/broadway/broadway.js | 23 +++++++++++++
gdk/broadway/broadwayd.c | 10 ++++-
gsk/gskbroadwayrenderer.c | 66 ++++++++++++++++++++++++++-----------
4 files changed, 78 insertions(+), 22 deletions(-)
---
diff --git a/gdk/broadway/broadway-protocol.h b/gdk/broadway/broadway-protocol.h
index e4ce21e..f1b1504 100644
--- a/gdk/broadway/broadway-protocol.h
+++ b/gdk/broadway/broadway-protocol.h
@@ -17,6 +17,7 @@ typedef enum { /* Sync changes with broadway.js */
BROADWAY_NODE_INSET_SHADOW = 5,
BROADWAY_NODE_ROUNDED_CLIP = 6,
BROADWAY_NODE_LINEAR_GRADIENT = 7,
+ BROADWAY_NODE_SHADOW = 8,
} BroadwayNodeType;
typedef enum {
diff --git a/gdk/broadway/broadway.js b/gdk/broadway/broadway.js
index dd9ea1c..57565d5 100644
--- a/gdk/broadway/broadway.js
+++ b/gdk/broadway/broadway.js
@@ -592,6 +592,29 @@ SwapNodes.prototype.handle_node = function(parent, offset_x, offset_y)
}
break;
+ case 8: // SHADOW
+ {
+ var len = this.decode_uint32();
+ var filters = "";
+ for (var i = 0; i < len; i++) {
+ var color = this.decode_color();
+ var dx = this.decode_float();
+ var dy = this.decode_float();
+ var blur = this.decode_float();
+ filters = filters + "drop-shadow(" + args (px(dx), px(dy), px(blur), color) + ")";
+ }
+ var div = document.createElement('div');
+ div.style["position"] = "absolute";
+ div.style["left"] = px(0);
+ div.style["top"] = px(0);
+ div.style["filter"] = filters;
+
+ parent.appendChild(div);
+ this.handle_node(div, offset_x, offset_y);
+ }
+ break;
+
+
default:
alert("Unexpected node type " + type);
}
diff --git a/gdk/broadway/broadwayd.c b/gdk/broadway/broadwayd.c
index 693e76c..6314ce9 100644
--- a/gdk/broadway/broadwayd.c
+++ b/gdk/broadway/broadwayd.c
@@ -222,13 +222,14 @@ get_client_serial (BroadwayClient *client, guint32 daemon_serial)
#define NODE_SIZE_RECT (NODE_SIZE_POINT + NODE_SIZE_SIZE)
#define NODE_SIZE_RRECT (NODE_SIZE_RECT + 4 * NODE_SIZE_SIZE)
#define NODE_SIZE_COLOR_STOP (NODE_SIZE_FLOAT + NODE_SIZE_COLOR)
+#define NODE_SIZE_SHADOW (NODE_SIZE_COLOR + 3 * NODE_SIZE_FLOAT)
static int
rewrite_node_textures (BroadwayClient *client,
int len, guint32 data[], int pos)
{
guint32 type;
- guint32 i, n_children, n_stops;
+ guint32 i, n_children, n_stops, n_shadows;
g_assert (pos < len);
@@ -242,7 +243,7 @@ rewrite_node_textures (BroadwayClient *client,
break;
case BROADWAY_NODE_INSET_SHADOW:
case BROADWAY_NODE_OUTSET_SHADOW:
- pos += NODE_SIZE_RRECT + NODE_SIZE_COLOR + 4 * NODE_SIZE_COLOR;
+ pos += NODE_SIZE_RRECT + NODE_SIZE_COLOR + 4 * NODE_SIZE_FLOAT;
break;
case BROADWAY_NODE_TEXTURE:
data[pos+4] = GPOINTER_TO_INT (g_hash_table_lookup (client->textures,
@@ -263,6 +264,11 @@ rewrite_node_textures (BroadwayClient *client,
n_stops = data[pos++];
pos += n_stops * NODE_SIZE_COLOR_STOP;
break;
+ case BROADWAY_NODE_SHADOW:
+ n_shadows = data[pos++];
+ pos += n_shadows * NODE_SIZE_SHADOW;
+ pos = rewrite_node_textures (client, len, data, pos);
+ break;
default:
g_assert_not_reached ();
}
diff --git a/gsk/gskbroadwayrenderer.c b/gsk/gskbroadwayrenderer.c
index 07d8d18..49e4f77 100644
--- a/gsk/gskbroadwayrenderer.c
+++ b/gsk/gskbroadwayrenderer.c
@@ -437,32 +437,58 @@ gsk_broadway_renderer_add_node (GskRenderer *self,
}
return;
- case GSK_TEXT_NODE:
- default:
+ case GSK_SHADOW_NODE:
{
- GdkTexture *texture;
- guint32 texture_id;
- float off_x = 0, off_y = 0;
-
- texture = node_cache_lookup (node, &off_x, &off_y);
-
- if (!texture)
+ gsize i, n_shadows = gsk_shadow_node_get_n_shadows (node);
+ add_uint32 (nodes, BROADWAY_NODE_SHADOW);
+ add_uint32 (nodes, n_shadows);
+ for (i = 0; i < n_shadows; i++)
{
- texture = node_texture_fallback (node, &off_x, &off_y);
- node_cache_store (node, texture, off_x, off_y);
+ const GskShadow *shadow = gsk_shadow_node_peek_shadow (node, i);
+ add_rgba (nodes, &shadow->color);
+ add_float (nodes, shadow->dx);
+ add_float (nodes, shadow->dy);
+ add_float (nodes, shadow->radius);
}
-
- g_ptr_array_add (node_textures, texture); /* Transfers ownership to node_textures */
- texture_id = gdk_broadway_display_ensure_texture (display, texture);
- add_uint32 (nodes, BROADWAY_NODE_TEXTURE);
- add_float (nodes, node->bounds.origin.x + off_x);
- add_float (nodes, node->bounds.origin.y + off_y);
- add_float (nodes, gdk_texture_get_width (texture));
- add_float (nodes, gdk_texture_get_height (texture));
- add_uint32 (nodes, texture_id);
+ gsk_broadway_renderer_add_node (self, nodes, node_textures,
+ gsk_shadow_node_get_child (node));
}
return;
+
+ case GSK_TEXT_NODE:
+ default:
+ break; /* Fallback */
}
+
+ {
+ GdkTexture *texture;
+ guint32 texture_id;
+ float off_x = 0, off_y = 0;
+
+ texture = node_cache_lookup (node, &off_x, &off_y);
+
+ if (!texture)
+ {
+ texture = node_texture_fallback (node, &off_x, &off_y);
+ g_print ("Fallback %p for %s\n", texture, node->node_class->type_name);
+
+ node_cache_store (node, texture, off_x, off_y);
+ }
+ else
+ {
+ g_print ("Cache hit %p for %s\n", texture,
+ node->node_class->type_name);
+ }
+
+ g_ptr_array_add (node_textures, texture); /* Transfers ownership to node_textures */
+ texture_id = gdk_broadway_display_ensure_texture (display, texture);
+ add_uint32 (nodes, BROADWAY_NODE_TEXTURE);
+ add_float (nodes, node->bounds.origin.x + off_x);
+ add_float (nodes, node->bounds.origin.y + off_y);
+ add_float (nodes, gdk_texture_get_width (texture));
+ add_float (nodes, gdk_texture_get_height (texture));
+ add_uint32 (nodes, texture_id);
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]