diff options
author | Alexander Larsson <alexl@redhat.com> | 2019-03-22 13:42:26 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2019-03-26 17:07:47 +0100 |
commit | 890b7590914581ed7da12c4e9c8f64ef65434ce0 (patch) | |
tree | 9c1e6bb9211f7f79ea6ef47b7cc1d1360e7534ab | |
parent | d997903d29bbbf6f3a25f04f1f539b35861e9c6b (diff) | |
download | gtk+-890b7590914581ed7da12c4e9c8f64ef65434ce0.tar.gz |
broadway: Send actual float32, not some hack
-rw-r--r-- | gdk/broadway/broadway.js | 10 | ||||
-rw-r--r-- | 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) { @@ -97,14 +110,6 @@ add_rgba (GArray *nodes, const GdkRGBA *rgba) } 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) { add_float (nodes, x - offset_x); |