diff options
author | Aric Stewart <aric@codeweavers.com> | 2013-09-16 11:11:51 -0500 |
---|---|---|
committer | Jeremy White <jwhite@codeweavers.com> | 2013-09-18 09:06:07 -0500 |
commit | bb746a03de510251924c08725523d700142e26fd (patch) | |
tree | beae2120dbd077baba2307b9473fe1c03e439ee3 | |
parent | 295073a95469e1f8633d5f70e6bad8be367b4635 (diff) |
Implement handling of SPICE_MSG_DISPLAY_INVAL_LIST
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.
-rw-r--r-- | display.js | 16 | ||||
-rw-r--r-- | spicemsg.js | 24 |
2 files changed, 37 insertions, 3 deletions
@@ -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; + } + }, +} |