SPICE Protocol definition-display channel (1), spice ----

Source: Internet
Author: User
Tags image line

SPICE Protocol definition-display channel (1), spice ----
I have already participated in the 2014 "blog Star" selection. I think my article is helpful to you. please vote for your valuable vote and click vote 1 to display the channel definition.

SPICE Protocol defines a set of Message sets that support remote display in the client. The protocol supports Image Rendering (line, image) and video streams. The Protocol also allows you to cache images and colors on the client. The display channel supports multiple image compression methods to reduce network traffic.

1.1 server --- client messages

enum {    SPICE_MSG_DISPLAY_MODE = 101,    SPICE_MSG_DISPLAY_MARK,    SPICE_MSG_DISPLAY_RESET,    SPICE_MSG_DISPLAY_COPY_BITS,    SPICE_MSG_DISPLAY_INVAL_LIST,    SPICE_MSG_DISPLAY_INVAL_ALL_PIXMAPS,    SPICE_MSG_DISPLAY_INVAL_PALETTE,    SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES,    SPICE_MSG_DISPLAY_STREAM_CREATE = 122,    SPICE_MSG_DISPLAY_STREAM_DATA,    SPICE_MSG_DISPLAY_STREAM_CLIP,    SPICE_MSG_DISPLAY_STREAM_DESTROY,    SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL,    SPICE_MSG_DISPLAY_DRAW_FILL = 302,    SPICE_MSG_DISPLAY_DRAW_OPAQUE,    SPICE_MSG_DISPLAY_DRAW_COPY,    SPICE_MSG_DISPLAY_DRAW_BLEND,    SPICE_MSG_DISPLAY_DRAW_BLACKNESS,    SPICE_MSG_DISPLAY_DRAW_WHITENESS,    SPICE_MSG_DISPLAY_DRAW_INVERS,    SPICE_MSG_DISPLAY_DRAW_ROP3,    SPICE_MSG_DISPLAY_DRAW_STROKE,    SPICE_MSG_DISPLAY_DRAW_TEXT,    SPICE_MSG_DISPLAY_DRAW_TRANSPARENT,    SPICE_MSG_DISPLAY_DRAW_ALPHA_BLEND,    SPICE_MSG_DISPLAY_SURFACE_CREATE,    SPICE_MSG_DISPLAY_SURFACE_DESTROY,    SPICE_MSG_DISPLAY_STREAM_DATA_SIZED,    SPICE_MSG_DISPLAY_MONITORS_CONFIG,    SPICE_MSG_DISPLAY_DRAW_COMPOSITE,    SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT,     SPICE_MSG_END_DISPLAY};


1.2 client --- server messages

enum {    SPICE_MSGC_DISPLAY_INIT = 101,    SPICE_MSGC_DISPLAY_STREAM_REPORT,     SPICE_MSGC_END_DISPLAY};


1.3 Procedure

The SPICE server sends the SPICE_MSG_DISPLAY_MODE message to the client to specify the area and format of the current screen. In response, the client creates a display area to display rendering commands sent by all servers, when the client receives the Server Message SPICE_MSG_DISPLAY_MARK, the remote display area is refreshed. The server can use SPICE_MSG_DISPLAY_RESET to notify the client to discard the drawing area and cache. SPICE_MSG_DISPLAY_MODE messages can only be in a drawing area that does not exist on the client. The SPICE_MSG_DISPLAY_RESET message only allows the client to exist in the drawing area.

SPICE_MSG_DISPLAY_MARK can be sent only once between the preceding two messages.

The drawing command, COPY Command, and video stream command can only be sent when the client has a drawing area.

When the display channel is set up, the client sends the SPICE_MSGC_DISPLAY_INIT message to the server in order to use the image cache and glz compression. Messages include the image cache ID and size, and the size of the glz compression window. These dimensions and IDs are determined by the client. Send only once. This size is set by the spice_session_set_caches_hints function when the main channel is created.

The drawing cache is managed by the server. Insert a cache entry is implemented by another set of commands. Cache entries are deleted through SPICE_MSG_DISPLAY_INVAL_LIST and SPICE_MSG_DISPLAY_INVAL_PALETTE. Reset the cache by sending SPICE_MSG_DISPLAY_INVAL_ALL_PIXMAPS and SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES.

1. SpiceMsgDisplayMode

typedef structSpiceMsgDisplayMode {    uint32_t x_res;    uint32_t y_res;    uint32_t bits;} SpiceMsgDisplayMode;


1.4 grating Operator

The following is a set of tags to describe the grating operation. It can be applied to source images, source brushes, purposes, and results. Combine these tags to define the necessary steps. Pre-rendering is required.

 

Typedef enumSpiceRopd {SPICE_ROPD_INVERS_SRC = (1 <0), // The Source image needs to be flipped before rendering SPICE_ROPD_INVERS_BRUSH = (1 <1 ), // The paint brush needs to flip SPICE_ROPD_INVERS_DEST = (1 <2) Before rendering, // the target area needs to flip SPICE_ROPD_OP_PUT = (1 <3) before rendering ), // use the copy operation SPICE_ROPD_OP_OR = (1 <4), // use or operate SPICE_ROPD_OP_AND = (1 <5 ), // use and operate SPICE_ROPD_OP_XOR = (1 <6), // use an exclusive or operation SPICE_ROPD_OP_BLACKNESS = (1 <7 ), // The target pixel should be black to replace SPICE_ROPD_OP_WHITENESS = (1 <8), // The target pixel should be white to replace SPICE_ROPD_OP_INVERS = (1 <9 ), // The target pixel should be flipped SPICE_ROPD_INVERS_RES = (1 <10), // The operation result must be flipped SPICE_ROPD_MASK = 0x7ff} SpiceRopd;


OP_PUT, OP_OR, OP_AND, OP_XOR, OP_BLACKNESS, OP_WHITENESS, and

OP_INVERS are mutually exclusive.

OP_BLACKNESS, OP_WHITENESS, and OP_INVERS are unique.

 

1.5Raw raster image

The following section describes the SPICE image, which is one of the methods used to transmit images using the SPICE protocol.

1.5.1SpiceBitmapFlags macro

Typedef enumSpiceBitmapFlags {SPICE_BITMAP_FLAGS_PAL_CACHE_ME = (1 <0), // instructs the client to add this canvas to the cache SPICE_BITMAP_FLAGS_PAL_FROM_CACHE = (1 <1 ), // instruct the client to retrieve the canvas SPICE_BITMAP_FLAGS_TOP_DOWN = (1 <2) from the cache, // The image line command is from top to bottom SPICE_BITMAP_FLAGS_MASK = 0x7} SpiceBitmapFlags;


1.5.2SpiceBitmapFmt format

Typedef enumSpiceBitmapFmt {SPICE_BITMAP_FMT_INVALID, SPICE_BITMAP_FMT_1BIT_LE, // 1bit per pixel, and Small-end bytes are stored. The value of each pixel is the index of the color table. The size of the color table is 2. SPICE_BITMAP_FMT_1BIT_BE, // 1bit per pixel, which is stored in large-end byte sequence. The value of each pixel is the index of the color table. The size of the color table is 2. SPICE_BITMAP_FMT_4BIT_LE, // 4 bits per pixel, and the size is half-byte. The value of each pixel is the index of the color table. The size of the color table is 16SPICE_BITMAP_FMT_4BIT_BE, // 4 bits per pixel, and the size is half-byte. The value of each pixel is the index of the color table. The size of the color table is 16SPICE_BITMAP_FMT_8BIT, // 8 bits per pixel. The value of each pixel is the index of the color table. The size of the color table is 256SPICE_BITMAP_FMT_16BIT. // The pixel format is 16-bit RGB555SPICE_BITMAP_FMT_24BIT. // The pixel format is 24-bit pixel. // The pixel format is 32-bit pixel, // The pixel format is 32-bit ARGB8888SPICE_BITMAP_FMT_8BIT_A, // it is not clear that SPICE_BITMAP_FMT_ENUM_END} SpiceBitmapFmt;


1.5.3 SpiceBitmap struct

Typedef structSpiceBitmap {uint8_t format; // custom format uint8_t flags; // SpiceBitmapFlags macro uint32_t x; // The bitmap width uint32_t y; // The height of the bitmap uint32_t stride; // The number of bytes added from N rows to N + 1 rows. (For example, stride * y + x * format) SpicePalette * palette; // the address of the color palette. If there is no color table, the required format must be 0; uint64_t palette_id; // the color palette ID, if SPICE_BITMAP_FLAGS_PAL_FROM_CACHE is set to SpiceChunks * data; // data} SpiceBitmap;


1.5.4SpicePalette struct

Typedef structSpicePalette {uint64_t unique; // the unique ID uint16_t num_ents of the palette; // number of entries in the color table uint32_t ents [0]; // The color of each entry RGB555 or RGB888 varies according to the current display area mode. If the displayed area mode color depth is 32 years old, the valid format is RGB888. If the color depth of the display area mode is valid, the format is RGB555 16 .} SpicePalette;


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.