[Spice-devel] [PATCH 2/2] Add support for QXLComposite to the Spice protocol headers

Søren Sandmann Pedersen sandmann at cs.au.dk
Sun Aug 19 13:56:46 PDT 2012


From: Søren Sandmann Pedersen <ssp at redhat.com>

This new command is intended to be used for implementing the Composite
request from the Render X extension. See

   http://www.x.org/releases/current/doc/renderproto/renderproto.txt

for a description of the Render extension.

Composite has three fields: src, mask and destination, of which mask
is optional (can be NULL). There are also two pointers to
transformations, one for each of src and mask.

The command also has 32 bits of flags which indicates

- which compositing operator to use
- which filters to apply when sampling source and mask
- which repeat mode to apply when sampling source and mask
- whether the mask should be considered to have 'component alpha'
- whether the alpha channel of any of the images should be ignored.

The last one of these features is necessary because in the X protocol
an offscreen surface is simply a collection of bits with no visual
interpretation. In order for Render to use these bits, a wrapper
object is used that contains the pixel format. Since one offscreen
surface can be wrapped by multple objects, there is not a one-to-one
correspondence between pixel formats and surfaces.

In SPICE surfaces do have an associated pixel format, which means the
above feature of Render cannot be supported without adding a similar
concept to the wrapper object to the SPICE protocol. However, the most
common use for having multiple wrappers for one offscreen surface is
to interpret an alpha surface as not having an alpha channel or vice
versa.
---
 spice/enums.h    | 31 ++++++++++++++++++++++++
 spice/protocol.h |  1 +
 spice/qxl_dev.h  | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 106 insertions(+)

diff --git a/spice/enums.h b/spice/enums.h
index 7cdea0f..7691dd3 100644
--- a/spice/enums.h
+++ b/spice/enums.h
@@ -38,6 +38,36 @@ typedef enum SpiceMigrateFlags {
     SPICE_MIGRATE_FLAGS_MASK = 0x3
 } SpiceMigrateFlags;
 
+typedef enum SpiceCompositeFlags {
+    SPICE_COMPOSITE_OP0 = (1 << 0),
+    SPICE_COMPOSITE_OP1 = (1 << 1),
+    SPICE_COMPOSITE_OP2 = (1 << 2),
+    SPICE_COMPOSITE_OP3 = (1 << 3),
+    SPICE_COMPOSITE_OP4 = (1 << 4),
+    SPICE_COMPOSITE_OP5 = (1 << 5),
+    SPICE_COMPOSITE_OP6 = (1 << 6),
+    SPICE_COMPOSITE_OP7 = (1 << 7),
+    SPICE_COMPOSITE_SRC_FILTER0 = (1 << 8),
+    SPICE_COMPOSITE_SRC_FILTER1 = (1 << 9),
+    SPICE_COMPOSITE_SRC_FILTER2 = (1 << 10),
+    SPICE_COMPOSITE_MASK_FILTER0 = (1 << 11),
+    SPICE_COMPOSITE_MASK_FITLER1 = (1 << 12),
+    SPICE_COMPOSITE_MASK_FILTER2 = (1 << 13),
+    SPICE_COMPOSITE_SRC_REPEAT0 = (1 << 14),
+    SPICE_COMPOSITE_SRC_REPEAT1 = (1 << 15),
+    SPICE_COMPOSITE_MASK_REPEAT0 = (1 << 16),
+    SPICE_COMPOSITE_MASK_REPEAT1 = (1 << 17),
+    SPICE_COMPOSITE_COMPONENT_ALPHA = (1 << 18),
+    SPICE_COMPOSITE_HAS_MASK = (1 << 19),
+    SPICE_COMPOSITE_HAS_SRC_TRANSFORM = (1 << 20),
+    SPICE_COMPOSITE_HAS_MASK_TRANSFORM = (1 << 21),
+    SPICE_COMPOSITE_SOURCE_OPAQUE = (1 << 22),
+    SPICE_COMPOSITE_MASK_OPAQUE = (1 << 23),
+    SPICE_COMPOSITE_DEST_OPAQUE = (1 << 24),
+
+    SPICE_COMPOSITE_FLAGS_MASK = 0x1ffffff
+} SpiceCompositeFlags;
+
 typedef enum SpiceNotifySeverity {
     SPICE_NOTIFY_SEVERITY_INFO,
     SPICE_NOTIFY_SEVERITY_WARN,
@@ -432,6 +462,7 @@ enum {
     SPICE_MSG_DISPLAY_SURFACE_DESTROY,
     SPICE_MSG_DISPLAY_STREAM_DATA_SIZED,
     SPICE_MSG_DISPLAY_MONITORS_CONFIG,
+    SPICE_MSG_DISPLAY_DRAW_COMPOSITE,
 
     SPICE_MSG_END_DISPLAY
 };
diff --git a/spice/protocol.h b/spice/protocol.h
index c0d33e6..a0b3004 100644
--- a/spice/protocol.h
+++ b/spice/protocol.h
@@ -125,6 +125,7 @@ enum {
 enum {
     SPICE_DISPLAY_CAP_SIZED_STREAM,
     SPICE_DISPLAY_CAP_MONITORS_CONFIG,
+    SPICE_DISPLAY_CAP_COMPOSITE,
 };
 
 #include <spice/end-packed.h>
diff --git a/spice/qxl_dev.h b/spice/qxl_dev.h
index 8899403..f195b81 100644
--- a/spice/qxl_dev.h
+++ b/spice/qxl_dev.h
@@ -347,6 +347,7 @@ enum {
     QXL_DRAW_TEXT,
     QXL_DRAW_TRANSPARENT,
     QXL_DRAW_ALPHA_BLEND,
+    QXL_DRAW_COMPOSITE
 };
 
 typedef struct SPICE_ATTR_PACKED QXLRasterGlyph {
@@ -487,6 +488,78 @@ typedef struct SPICE_ATTR_PACKED QXLClip {
     QXLPHYSICAL data;
 } QXLClip;
 
+typedef enum {
+    QXL_OP_CLEAR                     = 0x00,
+    QXL_OP_DST                       = 0x02,
+    QXL_OP_OVER                      = 0x03,
+    QXL_OP_OVER_REVERSE              = 0x04,
+    QXL_OP_IN                        = 0x05,
+    QXL_OP_IN_REVERSE                = 0x06,
+    QXL_OP_OUT                       = 0x07,
+    QXL_OP_OUT_REVERSE               = 0x08,
+    QXL_OP_ATOP                      = 0x09,
+    QXL_OP_ATOP_REVERSE              = 0x0a,
+    QXL_OP_XOR                       = 0x0b,
+    QXL_OP_ADD                       = 0x0c,
+    QXL_OP_SATURATE                  = 0x0d,
+    /* Note the jump here from 0x0d to 0x30 */
+    QXL_OP_MULTIPLY                  = 0x30,
+    QXL_OP_SCREEN                    = 0x31,
+    QXL_OP_OVERLAY                   = 0x32,
+    QXL_OP_DARKEN                    = 0x33,
+    QXL_OP_LIGHTEN                   = 0x34,
+    QXL_OP_COLOR_DODGE               = 0x35,
+    QXL_OP_COLOR_BURN                = 0x36,
+    QXL_OP_HARD_LIGHT                = 0x37,
+    QXL_OP_SOFT_LIGHT                = 0x38,
+    QXL_OP_DIFFERENCE                = 0x39,
+    QXL_OP_EXCLUSION                 = 0x3a,
+    QXL_OP_HSL_HUE                   = 0x3b,
+    QXL_OP_HSL_SATURATION            = 0x3c,
+    QXL_OP_HSL_COLOR                 = 0x3d,
+    QXL_OP_HSL_LUMINOSITY            = 0x3e
+} QXLOperator;
+
+typedef struct {
+    uint32_t	t00;
+    uint32_t	t01;
+    uint32_t	t02;
+    uint32_t	t10;
+    uint32_t	t11;
+    uint32_t	t12;
+} QXLTransform;
+
+/* The flags field has the following bit fields:
+ *
+ *     operator:		[  0 -  7 ]
+ *     src_filter:		[  8 - 10 ]
+ *     mask_filter:		[ 11 - 13 ]
+ *     src_repeat:		[ 14 - 15 ]
+ *     mask_repeat:		[ 16 - 17 ]
+ *     component_alpha:		[ 18 - 18 ]
+ *     reserved:		[ 19 - 31 ]
+ *
+ * The repeat and filter values are those of pixman:
+ *		REPEAT_NONE =		0
+ *              REPEAT_NORMAL =		1
+ *		REPEAT_PAD =		2
+ *		REPEAT_REFLECT =	3
+ *
+ * The filter values are:
+ *		FILTER_NEAREST =	0
+ *		FILTER_BILINEAR	=	1
+ */
+typedef struct SPICE_ATTR_PACKED QXLComposite {
+    uint32_t		flags;
+
+    QXLPHYSICAL		src;
+    QXLPHYSICAL		src_transform;		/* May be NULL */
+    QXLPHYSICAL		mask;			/* May be NULL */
+    QXLPHYSICAL		mask_transform;		/* May be NULL */
+    QXLPoint16		src_origin;
+    QXLPoint16		mask_origin;
+} QXLComposite;
+
 typedef struct SPICE_ATTR_PACKED QXLCompatDrawable {
     QXLReleaseInfo release_info;
     uint8_t effect;
@@ -539,6 +612,7 @@ typedef struct SPICE_ATTR_PACKED QXLDrawable {
         QXLBlackness blackness;
         QXLInvers invers;
         QXLWhiteness whiteness;
+	QXLComposite composite;
     } u;
 } QXLDrawable;
 
-- 
1.7.11.4



More information about the Spice-devel mailing list