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) {