[Spice-devel] [PATCH spice-html5 v2 2/4] Display: Implement change preferred compression message

Jeremy White jwhite at codeweavers.com
Mon Sep 18 15:47:25 UTC 2017


Ack, thanks.

Cheers,

Jeremy

On 09/18/2017 06:08 AM, Tomáš Bohdálek wrote:
> ---
>  display.js  | 15 +++++++++++++++
>  enums.js    | 10 ++++++++++
>  spicemsg.js | 20 ++++++++++++++++++++
>  3 files changed, 45 insertions(+)
> 
> diff --git a/display.js b/display.js
> index 7719b23..4649ef2 100644
> --- a/display.js
> +++ b/display.js
> @@ -865,6 +865,21 @@ SpiceDisplayConn.prototype.destroy_surfaces = function()
>      this.surfaces = undefined;
>  }
>  
> +SpiceDisplayConn.prototype.change_preferred_compression = function(compression_id)
> +{
> +    var ch = this.channel_type();
> +    if (!this.channel_test_capability(SPICE_DISPLAY_CAP_PREF_COMPRESSION))
> +    {
> +        this.log_warn(ch + " does not have capability to change the preferred compression");
> +        return;
> +    }
> +
> +    var msg = new SpiceMiniData();
> +    var compression = new SpiceMsgcDisplayPreferredCompression(compression_id);
> +
> +    msg.build_msg(SPICE_MSGC_DISPLAY_PREFERRED_COMPRESSION, compression);
> +    this.send_msg(msg);
> +}
>  
>  function handle_mouseover(e)
>  {
> diff --git a/enums.js b/enums.js
> index b6e013c..b37cb20 100644
> --- a/enums.js
> +++ b/enums.js
> @@ -134,6 +134,7 @@ var SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT = 319;
>  
>  var SPICE_MSGC_DISPLAY_INIT             = 101;
>  var SPICE_MSGC_DISPLAY_STREAM_REPORT    = 102;
> +var SPICE_MSGC_DISPLAY_PREFERRED_COMPRESSION = 103;
>  
>  var SPICE_MSG_INPUTS_INIT               = 101;
>  var SPICE_MSG_INPUTS_KEY_MODIFIERS      = 102;
> @@ -243,6 +244,15 @@ var SPICE_IMAGE_TYPE_FROM_CACHE_LOSSLESS = 106;
>  var SPICE_IMAGE_TYPE_ZLIB_GLZ_RGB   = 107;
>  var SPICE_IMAGE_TYPE_JPEG_ALPHA     = 108;
>  
> +var SPICE_IMAGE_COMPRESSION_INVALID = 0,
> +    SPICE_IMAGE_COMPRESSION_OFF     = 1,
> +    SPICE_IMAGE_COMPRESSION_AUTO_GLZ = 2,
> +    SPICE_IMAGE_COMPRESSION_AUTO_LZ = 3,
> +    SPICE_IMAGE_COMPRESSION_QUIC    = 4,
> +    SPICE_IMAGE_COMPRESSION_GLZ     = 5,
> +    SPICE_IMAGE_COMPRESSION_LZ      = 6,
> +    SPICE_IMAGE_COMPRESSION_LZ4     = 7;
> +
>  var SPICE_IMAGE_FLAGS_CACHE_ME = (1 << 0),
>      SPICE_IMAGE_FLAGS_HIGH_BITS_SET = (1 << 1),
>      SPICE_IMAGE_FLAGS_CACHE_REPLACE_ME = (1 << 2);
> diff --git a/spicemsg.js b/spicemsg.js
> index 3619996..8a9eeed 100644
> --- a/spicemsg.js
> +++ b/spicemsg.js
> @@ -1296,3 +1296,23 @@ SpiceMsgPortInit.prototype =
>          this.name = a.slice(offset, offset + namesize - 1);
>      }
>  }
> +
> +function SpiceMsgcDisplayPreferredCompression(compression)
> +{
> +    this.image_compression = compression;
> +}
> +
> +SpiceMsgcDisplayPreferredCompression.prototype =
> +{
> +    to_buffer: function(a, at)
> +    {
> +        at = at || 0;
> +        var dv = new SpiceDataView(a);
> +        dv.setUint8(at, this.image_compression, true); at += 1;
> +        return at;
> +    },
> +    buffer_size: function()
> +    {
> +        return 1;
> +    }
> +}
> 



More information about the Spice-devel mailing list