[gtk/wip/alexl/broadway5: 1/13] broadway: Don't fall back for translation transform nodes



commit 23ca5edaace9dae9e88cd9c61b9eee8a2fe912bf
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Mar 22 10:02:18 2019 +0100

    broadway: Don't fall back for translation transform nodes
    
    These are trivial anyway

 gdk/broadway/broadway-protocol.h |  2 ++
 gdk/broadway/broadway.js         | 16 ++++++++++++++++
 gdk/broadway/broadwayd.c         |  4 ++++
 gsk/gskbroadwayrenderer.c        | 36 +++++++++++++++++++++++++++++++++---
 4 files changed, 55 insertions(+), 3 deletions(-)
---
diff --git a/gdk/broadway/broadway-protocol.h b/gdk/broadway/broadway-protocol.h
index 68911add81..b397195521 100644
--- a/gdk/broadway/broadway-protocol.h
+++ b/gdk/broadway/broadway-protocol.h
@@ -22,6 +22,7 @@ typedef enum { /* Sync changes with broadway.js */
   BROADWAY_NODE_CLIP = 10,
   BROADWAY_NODE_KEEP_ALL = 11,
   BROADWAY_NODE_KEEP_THIS = 12,
+  BROADWAY_NODE_TRANSLATE = 13,
 } BroadwayNodeType;
 
 static const char *broadway_node_type_names[] G_GNUC_UNUSED =  {
@@ -38,6 +39,7 @@ static const char *broadway_node_type_names[] G_GNUC_UNUSED =  {
   "CLIP",
   "KEEP_ALL",
   "KEEP_THIS",
+  "TRANSLATE",
 };
 
 typedef enum {
diff --git a/gdk/broadway/broadway.js b/gdk/broadway/broadway.js
index 24859f1b15..d7a6a0d446 100644
--- a/gdk/broadway/broadway.js
+++ b/gdk/broadway/broadway.js
@@ -400,6 +400,11 @@ function px(x) {
     return x + "px";
 }
 
+function set_point_style (div, point) {
+    div.style["left"] = px(point.x);
+    div.style["top"] = px(point.y);
+}
+
 function set_rect_style (div, rect) {
     div.style["left"] = px(rect.x);
     div.style["top"] = px(rect.y);
@@ -569,6 +574,17 @@ SwapNodes.prototype.insertNode = function(parent, posInParent, oldNode)
 
     /* Bin nodes */
 
+    case 13:  // TRANSLATE
+        {
+            var point = this.decode_point();
+            var div = document.createElement('div');
+            div.style["position"] = "absolute";
+            set_point_style(div, point);
+            this.insertNode(div, -1, oldChildren[0]);
+            newNode = div;
+        }
+        break;
+
     case 10:  // CLIP
         {
             var rect = this.decode_rect();
diff --git a/gdk/broadway/broadwayd.c b/gdk/broadway/broadwayd.c
index e453af463c..13d5675633 100644
--- a/gdk/broadway/broadwayd.c
+++ b/gdk/broadway/broadwayd.c
@@ -277,6 +277,10 @@ decode_nodes (BroadwayClient *client,
     size = NODE_SIZE_RECT;
     n_children = 1;
     break;
+  case BROADWAY_NODE_TRANSLATE:
+    size = NODE_SIZE_POINT;
+    n_children = 1;
+    break;
   case BROADWAY_NODE_LINEAR_GRADIENT:
     size = NODE_SIZE_RECT + 2 * NODE_SIZE_POINT;
     n_stops = data[*pos + size++];
diff --git a/gsk/gskbroadwayrenderer.c b/gsk/gskbroadwayrenderer.c
index 84b948d676..c90ccbeab5 100644
--- a/gsk/gskbroadwayrenderer.c
+++ b/gsk/gskbroadwayrenderer.c
@@ -4,6 +4,7 @@
 #include "broadway/gdkprivate-broadway.h"
 
 #include "gskdebugprivate.h"
+#include "gsktransformprivate.h"
 #include "gskrendererprivate.h"
 #include "gskrendernodeprivate.h"
 #include "gdk/gdktextureprivate.h"
@@ -103,11 +104,17 @@ add_float (GArray *nodes, float f)
   g_array_append_val (nodes, u);
 }
 
+static void
+add_xy (GArray *nodes, float x, float y, float offset_x, float offset_y)
+{
+  add_float (nodes, x - offset_x);
+  add_float (nodes, y - offset_y);
+}
+
 static void
 add_point (GArray *nodes, const graphene_point_t *point, float offset_x, float offset_y)
 {
-  add_float (nodes, point->x - offset_x);
-  add_float (nodes, point->y - offset_y);
+  add_xy (nodes, point->x, point->y, offset_x, offset_y);
 }
 
 static void
@@ -633,6 +640,30 @@ gsk_broadway_renderer_add_node (GskRenderer *renderer,
       }
       return;
 
+    case GSK_TRANSFORM_NODE:
+      {
+        GskTransform *transform = gsk_transform_node_get_transform (node);
+        GskTransformCategory category = gsk_transform_get_category (transform);
+        float dx, dy;
+
+        if (category >= GSK_TRANSFORM_CATEGORY_2D_TRANSLATE)
+          {
+            gsk_transform_to_translate (transform, &dx, &dy);
+            add_uint32 (nodes, BROADWAY_NODE_TRANSLATE);
+            add_xy (nodes, dx, dy, offset_x, offset_y);
+            gsk_broadway_renderer_add_node (renderer, nodes, node_textures,
+                                            gsk_transform_node_get_child (node),
+                                            0, 0);
+          }
+        else
+          {
+            /* Fallback to texture for now */
+            break;
+          }
+
+      }
+      return;
+
       /* Generic nodes */
 
     case GSK_CONTAINER_NODE:
@@ -656,7 +687,6 @@ gsk_broadway_renderer_add_node (GskRenderer *renderer,
     case GSK_COLOR_MATRIX_NODE:
     case GSK_TEXT_NODE:
     case GSK_REPEATING_LINEAR_GRADIENT_NODE:
-    case GSK_TRANSFORM_NODE:
     case GSK_REPEAT_NODE:
     case GSK_BLEND_NODE:
     case GSK_CROSS_FADE_NODE:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]