[Spice-devel] [spice-HTML5][PATCH try 2] Handling non-topdown lz_rgb

Vincent Desprez vincent.desprez at gmail.com
Thu Mar 7 06:04:41 PST 2013


Signed-off-by: Vincent Desprez <vincent.desprez at apwise.com>
---
 display.js |    3 ---
 lz.js      |   16 ++++++++++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/display.js b/display.js
index 9f1e3dd..cff964f 100644
--- a/display.js
+++ b/display.js
@@ -284,9 +284,6 @@ SpiceDisplayConn.prototype.process_channel_message = function(msg)
                     return false;
                 }
 
-                if (draw_copy.data.src_bitmap.lz_rgb.top_down != 1)
-                    this.log_warn("FIXME: Implement non top down support for lz_rgb");
-
                 var source_img = convert_spice_lz_to_web(canvas.context,
                                             draw_copy.data.src_bitmap.lz_rgb);
                 if (! source_img)
diff --git a/lz.js b/lz.js
index 4292eac..85c8167 100644
--- a/lz.js
+++ b/lz.js
@@ -141,6 +141,19 @@ function lz_rgb32_decompress(in_buf, at, out_buf, type, default_alpha)
     return encoder - 1;
 }
 
+function flip_image_data(img)
+{
+    var wb = img.width * 4;
+    var h = img.height;
+    var temp_h = h;
+    var buff = new Uint8Array(img.width * img.height * 4);
+    while (temp_h--)
+    {
+        buff.set(img.data.subarray(temp_h * wb, (temp_h + 1) * wb), (h - temp_h - 1) * wb);
+    }
+    img.data.set(buff);
+}
+
 function convert_spice_lz_to_web(context, lz_image)
 {
     var at;
@@ -150,6 +163,9 @@ function convert_spice_lz_to_web(context, lz_image)
         var ret = context.createImageData(lz_image.width, lz_image.height);
 
         at = lz_rgb32_decompress(u8, 0, ret.data, LZ_IMAGE_TYPE_RGB32, lz_image.type != LZ_IMAGE_TYPE_RGBA);
+        if (!lz_rgb.top_down)
+            flip_image_data(ret);
+
         if (lz_image.type == LZ_IMAGE_TYPE_RGBA)
             lz_rgb32_decompress(u8, at, ret.data, LZ_IMAGE_TYPE_RGBA, false);
     }
-- 
1.7.10.4

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Attached Message Part
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20130307/b5af8635/attachment.ksh>


More information about the Spice-devel mailing list