[gtk/wip/alexl/broadway5: 4/13] broadway: Send actual float32, not some hack
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/alexl/broadway5: 4/13] broadway: Send actual float32, not some hack
- Date: Tue, 26 Mar 2019 15:53:15 +0000 (UTC)
commit 24091e7a205f8785696d360644084b88a5ee89bb
Author: Alexander Larsson <alexl redhat com>
Date: Fri Mar 22 13:42:26 2019 +0100
broadway: Send actual float32, not some hack
gdk/broadway/broadway.js | 10 ++++++----
gsk/gskbroadwayrenderer.c | 21 +++++++++++++--------
2 files changed, 19 insertions(+), 12 deletions(-)
---
diff --git a/gdk/broadway/broadway.js b/gdk/broadway/broadway.js
index fc55f4b59b..86259aa0a5 100644
--- a/gdk/broadway/broadway.js
+++ b/gdk/broadway/broadway.js
@@ -316,6 +316,12 @@ SwapNodes.prototype.decode_int32 = function() {
return v;
}
+SwapNodes.prototype.decode_float = function() {
+ var v = this.node_data.getFloat32(this.data_pos, true);
+ this.data_pos += 4;
+ return v;
+}
+
SwapNodes.prototype.decode_color = function() {
var rgba = this.decode_uint32();
var a = (rgba >> 24) & 0xff;
@@ -330,10 +336,6 @@ SwapNodes.prototype.decode_color = function() {
return c;
}
-SwapNodes.prototype.decode_float = function() {
- return this.decode_int32() / 256.0;
-}
-
SwapNodes.prototype.decode_size = function() {
var s = new Object();
s.width = this.decode_float ();
diff --git a/gsk/gskbroadwayrenderer.c b/gsk/gskbroadwayrenderer.c
index 552c9beafb..9350a2ab1f 100644
--- a/gsk/gskbroadwayrenderer.c
+++ b/gsk/gskbroadwayrenderer.c
@@ -72,12 +72,25 @@ gsk_broadway_renderer_render_texture (GskRenderer *renderer,
return texture;
}
+/* uint32 is sent in native endianness, and then converted to little endian in broadwayd when sending to
browser */
static void
add_uint32 (GArray *nodes, guint32 v)
{
g_array_append_val (nodes, v);
}
+static void
+add_float (GArray *nodes, float f)
+{
+ union {
+ float f;
+ guint32 i;
+ } u;
+
+ u.f = f;
+ g_array_append_val (nodes, u.i);
+}
+
static guint32
rgba_to_uint32 (const GdkRGBA *rgba)
{
@@ -96,14 +109,6 @@ add_rgba (GArray *nodes, const GdkRGBA *rgba)
g_array_append_val (nodes, c);
}
-static void
-add_float (GArray *nodes, float f)
-{
- gint32 i = (gint32) (f * 256.0f);
- guint u = (guint32) i;
- g_array_append_val (nodes, u);
-}
-
static void
add_xy (GArray *nodes, float x, float y, float offset_x, float offset_y)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]