[Spice-devel] [PATCH spice-html5 2/2] Implement handling of SPICE_MSG_DISPLAY_INVAL_LIST

Aric Stewart aric at codeweavers.com
Mon Sep 16 09:13:56 PDT 2013


Also converts the display cache from an array to an object. This is to help enforce proper sparceness of the data as well as make it easier to reliably fully delete a given cache entry without affecting access to the remaining entries.

---
 display.js  | 16 +++++++++++++---
 spicemsg.js | 24 ++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/display.js b/display.js
index d0d0994..6d7dafc 100644
--- a/display.js
+++ b/display.js
@@ -527,6 +527,16 @@ SpiceDisplayConn.prototype.process_channel_message = function(msg)
         this.streams[m.id] = undefined;
         return true;
     }
+    if (msg.type == SPICE_MSG_DISPLAY_INVAL_LIST)
+    {
+        var m = new SpiceMsgDisplayInvalList(msg.data);
+        var i;
+        DEBUG > 1 && console.log(this.type + ": MsgInvalList " + m.count + " items");
+        for (i = 0; i < m.count; i++)
+            if (this.cache[m.resources[i].id] != undefined)
+                delete this.cache[m.resources[i].id];
+        return true;
+    }
 
     return false;
 }
@@ -575,7 +585,7 @@ SpiceDisplayConn.prototype.draw_copy_helper = function(o)
     if (o.descriptor && (o.descriptor.flags & SPICE_IMAGE_FLAGS_CACHE_ME))
     {
         if (! ("cache" in this))
-            this.cache = [];
+            this.cache = {};
         this.cache[o.descriptor.id] = o.image_data;
     }
 
@@ -766,7 +776,7 @@ function handle_draw_jpeg_onload()
             (this.o.descriptor.flags & SPICE_IMAGE_FLAGS_CACHE_ME))
         {
             if (! ("cache" in this.o.sc))
-                this.o.sc.cache = [];
+                this.o.sc.cache = {};
 
             this.o.sc.cache[this.o.descriptor.id] = 
                 t.getImageData(0, 0,
@@ -786,7 +796,7 @@ function handle_draw_jpeg_onload()
             (this.o.descriptor.flags & SPICE_IMAGE_FLAGS_CACHE_ME))
         {
             if (! ("cache" in this.o.sc))
-                this.o.sc.cache = [];
+                this.o.sc.cache = {};
 
             this.o.sc.cache[this.o.descriptor.id] = 
                 context.getImageData(this.o.base.box.left, this.o.base.box.top,
diff --git a/spicemsg.js b/spicemsg.js
index ca69d42..de39aec 100644
--- a/spicemsg.js
+++ b/spicemsg.js
@@ -881,3 +881,27 @@ SpiceMsgDisplayStreamDestroy.prototype =
         this.id = dv.getUint32(at, true); at += 4;
     },
 }
+
+function SpiceMsgDisplayInvalList(a, at)
+{
+    this.count = 0;
+    this.resources = [];
+    this.from_buffer(a,at);
+}
+
+SpiceMsgDisplayInvalList.prototype =
+{
+    from_buffer: function (a, at)
+    {
+        var i;
+        at = at || 0;
+        var dv = new SpiceDataView(a);
+        this.count = dv.getUint16(at, true); at += 2;
+        for (i = 0; i < this.count; i++)
+        {
+            this.resources[i] = {};
+            this.resources[i].type = dv.getUint8(at, true); at++;
+            this.resources[i].id = dv.getUint64(at, true); at += 8;
+        }
+    },
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-Implement-handling-of-SPICE_MSG_DISPLAY_INVAL_LIST.txt
Type: text/x-patch
Size: 2569 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20130916/0bf4305c/attachment.bin>


More information about the Spice-devel mailing list