[Spice-commits] 3 commits - server/red_parse_qxl.c server/red_parse_qxl.h server/red_worker.c

Gerd Hoffmann kraxel at kemper.freedesktop.org
Tue Sep 14 06:36:25 PDT 2010


 server/red_parse_qxl.c |  178 +++++++++++++++++++++++++++++--------------------
 server/red_parse_qxl.h |    4 -
 server/red_worker.c    |   10 --
 3 files changed, 112 insertions(+), 80 deletions(-)

New commits:
commit 69bad628cc004e242d9add44781c1d6d4896d071
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Tue Sep 7 11:17:35 2010 +0200

    fix palette handling for 0.4 compat
    
    spice 0.4 guests pass 16bpp palette colors when running in
    a 16bpp video mode.  Convert them to 32bpp.

diff --git a/server/red_parse_qxl.c b/server/red_parse_qxl.c
index 93d95d1..5b32f6b 100644
--- a/server/red_parse_qxl.c
+++ b/server/red_parse_qxl.c
@@ -302,7 +302,7 @@ static SpiceChunks *red_get_image_data_chunked(RedMemSlotInfo *slots, int group_
 }
 
 static SpiceImage *red_get_image(RedMemSlotInfo *slots, int group_id,
-                                 QXLPHYSICAL addr)
+                                 QXLPHYSICAL addr, uint32_t flags)
 {
     RedDataChunk chunks;
     QXLImage *qxl;
@@ -351,8 +351,14 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int group_id,
             rp = spice_malloc_n_m(num_ents, sizeof(rp->ents[0]), sizeof(*rp));
             rp->unique   = qp->unique;
             rp->num_ents = num_ents;
-            for (i = 0; i < num_ents; i++) {
-                rp->ents[i] = qp->ents[i];
+            if (flags & QXL_COMMAND_FLAG_COMPAT_16BPP) {
+                for (i = 0; i < num_ents; i++) {
+                    rp->ents[i] = color_16_to_32(qp->ents[i]);
+                }
+            } else {
+                for (i = 0; i < num_ents; i++) {
+                    rp->ents[i] = qp->ents[i];
+                }
             }
             red->u.bitmap.palette = rp;
             red->u.bitmap.palette_id = rp->unique;
@@ -423,7 +429,7 @@ static void red_get_brush_ptr(RedMemSlotInfo *slots, int group_id,
         }
         break;
     case SPICE_BRUSH_TYPE_PATTERN:
-        red->u.pattern.pat = red_get_image(slots, group_id, qxl->u.pattern.pat);
+        red->u.pattern.pat = red_get_image(slots, group_id, qxl->u.pattern.pat, flags);
         red_get_point_ptr(&red->u.pattern.pos, &qxl->u.pattern.pos);
         break;
     }
@@ -439,11 +445,11 @@ static void red_put_brush(SpiceBrush *red)
 }
 
 static void red_get_qmask_ptr(RedMemSlotInfo *slots, int group_id,
-                              SpiceQMask *red, QXLQMask *qxl)
+                              SpiceQMask *red, QXLQMask *qxl, uint32_t flags)
 {
     red->flags  = qxl->flags;
     red_get_point_ptr(&red->pos, &qxl->pos);
-    red->bitmap = red_get_image(slots, group_id, qxl->bitmap);
+    red->bitmap = red_get_image(slots, group_id, qxl->bitmap, flags);
 }
 
 static void red_put_qmask(SpiceQMask *red)
@@ -456,7 +462,7 @@ static void red_get_fill_ptr(RedMemSlotInfo *slots, int group_id,
 {
     red_get_brush_ptr(slots, group_id, &red->brush, &qxl->brush, flags);
     red->rop_descriptor = qxl->rop_descriptor;
-    red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask);
+    red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask, flags);
 }
 
 static void red_put_fill(SpiceFill *red)
@@ -468,12 +474,12 @@ static void red_put_fill(SpiceFill *red)
 static void red_get_opaque_ptr(RedMemSlotInfo *slots, int group_id,
                                SpiceOpaque *red, QXLOpaque *qxl, uint32_t flags)
 {
-   red->src_bitmap     = red_get_image(slots, group_id, qxl->src_bitmap);
+    red->src_bitmap     = red_get_image(slots, group_id, qxl->src_bitmap, flags);
    red_get_rect_ptr(&red->src_area, &qxl->src_area);
    red_get_brush_ptr(slots, group_id, &red->brush, &qxl->brush, flags);
    red->rop_descriptor = qxl->rop_descriptor;
    red->scale_mode     = qxl->scale_mode;
-   red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask);
+   red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask, flags);
 }
 
 static void red_put_opaque(SpiceOpaque *red)
@@ -484,13 +490,13 @@ static void red_put_opaque(SpiceOpaque *red)
 }
 
 static void red_get_copy_ptr(RedMemSlotInfo *slots, int group_id,
-                             SpiceCopy *red, QXLCopy *qxl)
+                             SpiceCopy *red, QXLCopy *qxl, uint32_t flags)
 {
-   red->src_bitmap      = red_get_image(slots, group_id, qxl->src_bitmap);
+    red->src_bitmap      = red_get_image(slots, group_id, qxl->src_bitmap, flags);
    red_get_rect_ptr(&red->src_area, &qxl->src_area);
    red->rop_descriptor  = qxl->rop_descriptor;
    red->scale_mode      = qxl->scale_mode;
-   red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask);
+   red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask, flags);
 }
 
 static void red_put_copy(SpiceCopy *red)
@@ -500,13 +506,13 @@ static void red_put_copy(SpiceCopy *red)
 }
 
 static void red_get_blend_ptr(RedMemSlotInfo *slots, int group_id,
-                             SpiceBlend *red, QXLBlend *qxl)
+                             SpiceBlend *red, QXLBlend *qxl, uint32_t flags)
 {
-   red->src_bitmap      = red_get_image(slots, group_id, qxl->src_bitmap);
+    red->src_bitmap      = red_get_image(slots, group_id, qxl->src_bitmap, flags);
    red_get_rect_ptr(&red->src_area, &qxl->src_area);
    red->rop_descriptor  = qxl->rop_descriptor;
    red->scale_mode      = qxl->scale_mode;
-   red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask);
+   red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask, flags);
 }
 
 static void red_put_blend(SpiceBlend *red)
@@ -516,9 +522,10 @@ static void red_put_blend(SpiceBlend *red)
 }
 
 static void red_get_transparent_ptr(RedMemSlotInfo *slots, int group_id,
-                                    SpiceTransparent *red, QXLTransparent *qxl)
+                                    SpiceTransparent *red, QXLTransparent *qxl,
+                                    uint32_t flags)
 {
-   red->src_bitmap      = red_get_image(slots, group_id, qxl->src_bitmap);
+    red->src_bitmap      = red_get_image(slots, group_id, qxl->src_bitmap, flags);
    red_get_rect_ptr(&red->src_area, &qxl->src_area);
    red->src_color       = qxl->src_color;
    red->true_color      = qxl->true_color;
@@ -530,19 +537,21 @@ static void red_put_transparent(SpiceTransparent *red)
 }
 
 static void red_get_alpha_blend_ptr(RedMemSlotInfo *slots, int group_id,
-                                    SpiceAlphaBlend *red, QXLAlphaBlend *qxl)
+                                    SpiceAlphaBlend *red, QXLAlphaBlend *qxl,
+                                    uint32_t flags)
 {
     red->alpha_flags = qxl->alpha_flags;
     red->alpha       = qxl->alpha;
-    red->src_bitmap  = red_get_image(slots, group_id, qxl->src_bitmap);
+    red->src_bitmap  = red_get_image(slots, group_id, qxl->src_bitmap, flags);
     red_get_rect_ptr(&red->src_area, &qxl->src_area);
 }
 
 static void red_get_alpha_blend_ptr_compat(RedMemSlotInfo *slots, int group_id,
-                                           SpiceAlphaBlend *red, QXLCompatAlphaBlend *qxl)
+                                           SpiceAlphaBlend *red, QXLCompatAlphaBlend *qxl,
+                                           uint32_t flags)
 {
     red->alpha       = qxl->alpha;
-    red->src_bitmap  = red_get_image(slots, group_id, qxl->src_bitmap);
+    red->src_bitmap  = red_get_image(slots, group_id, qxl->src_bitmap, flags);
     red_get_rect_ptr(&red->src_area, &qxl->src_area);
 }
 
@@ -554,12 +563,12 @@ static void red_put_alpha_blend(SpiceAlphaBlend *red)
 static void red_get_rop3_ptr(RedMemSlotInfo *slots, int group_id,
                              SpiceRop3 *red, QXLRop3 *qxl, uint32_t flags)
 {
-   red->src_bitmap = red_get_image(slots, group_id, qxl->src_bitmap);
+    red->src_bitmap = red_get_image(slots, group_id, qxl->src_bitmap, flags);
    red_get_rect_ptr(&red->src_area, &qxl->src_area);
    red_get_brush_ptr(slots, group_id, &red->brush, &qxl->brush, flags);
    red->rop3       = qxl->rop3;
    red->scale_mode = qxl->scale_mode;
-   red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask);
+   red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask, flags);
 }
 
 static void red_put_rop3(SpiceRop3 *red)
@@ -697,9 +706,9 @@ static void red_put_text_ptr(SpiceText *red)
 }
 
 static void red_get_whiteness_ptr(RedMemSlotInfo *slots, int group_id,
-                                  SpiceWhiteness *red, QXLWhiteness *qxl)
+                                  SpiceWhiteness *red, QXLWhiteness *qxl, uint32_t flags)
 {
-    red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask);
+    red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask, flags);
 }
 
 static void red_put_whiteness(SpiceWhiteness *red)
@@ -708,9 +717,9 @@ static void red_put_whiteness(SpiceWhiteness *red)
 }
 
 static void red_get_blackness_ptr(RedMemSlotInfo *slots, int group_id,
-                                  SpiceBlackness *red, QXLBlackness *qxl)
+                                  SpiceBlackness *red, QXLBlackness *qxl, uint32_t flags)
 {
-    red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask);
+    red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask, flags);
 }
 
 static void red_put_blackness(SpiceWhiteness *red)
@@ -719,9 +728,9 @@ static void red_put_blackness(SpiceWhiteness *red)
 }
 
 static void red_get_invers_ptr(RedMemSlotInfo *slots, int group_id,
-                               SpiceInvers *red, QXLInvers *qxl)
+                               SpiceInvers *red, QXLInvers *qxl, uint32_t flags)
 {
-    red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask);
+    red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask, flags);
 }
 
 static void red_put_invers(SpiceWhiteness *red)
@@ -775,16 +784,17 @@ static void red_get_native_drawable(RedMemSlotInfo *slots, int group_id,
     switch (red->type) {
     case QXL_DRAW_ALPHA_BLEND:
         red_get_alpha_blend_ptr(slots, group_id,
-                                &red->u.alpha_blend, &qxl->u.alpha_blend);
+                                &red->u.alpha_blend, &qxl->u.alpha_blend, flags);
         break;
     case QXL_DRAW_BLACKNESS:
-        red_get_blackness_ptr(slots, group_id, &red->u.blackness, &qxl->u.blackness);
+        red_get_blackness_ptr(slots, group_id,
+                              &red->u.blackness, &qxl->u.blackness, flags);
         break;
     case QXL_DRAW_BLEND:
-        red_get_blend_ptr(slots, group_id, &red->u.blend, &qxl->u.blend);
+        red_get_blend_ptr(slots, group_id, &red->u.blend, &qxl->u.blend, flags);
         break;
     case QXL_DRAW_COPY:
-        red_get_copy_ptr(slots, group_id, &red->u.copy, &qxl->u.copy);
+        red_get_copy_ptr(slots, group_id, &red->u.copy, &qxl->u.copy, flags);
         break;
     case QXL_COPY_BITS:
         red_get_point_ptr(&red->u.copy_bits.src_pos, &qxl->u.copy_bits.src_pos);
@@ -796,7 +806,7 @@ static void red_get_native_drawable(RedMemSlotInfo *slots, int group_id,
         red_get_opaque_ptr(slots, group_id, &red->u.opaque, &qxl->u.opaque, flags);
         break;
     case QXL_DRAW_INVERS:
-        red_get_invers_ptr(slots, group_id, &red->u.invers, &qxl->u.invers);
+        red_get_invers_ptr(slots, group_id, &red->u.invers, &qxl->u.invers, flags);
         break;
     case QXL_DRAW_NOP:
         break;
@@ -811,10 +821,11 @@ static void red_get_native_drawable(RedMemSlotInfo *slots, int group_id,
         break;
     case QXL_DRAW_TRANSPARENT:
         red_get_transparent_ptr(slots, group_id,
-                                &red->u.transparent, &qxl->u.transparent);
+                                &red->u.transparent, &qxl->u.transparent, flags);
         break;
     case QXL_DRAW_WHITENESS:
-        red_get_whiteness_ptr(slots, group_id, &red->u.whiteness, &qxl->u.whiteness);
+        red_get_whiteness_ptr(slots, group_id,
+                              &red->u.whiteness, &qxl->u.whiteness, flags);
         break;
     default:
         red_error("%s: unknown type %d", __FUNCTION__, red->type);
@@ -846,16 +857,17 @@ static void red_get_compat_drawable(RedMemSlotInfo *slots, int group_id,
     switch (red->type) {
     case QXL_DRAW_ALPHA_BLEND:
         red_get_alpha_blend_ptr_compat(slots, group_id,
-                                       &red->u.alpha_blend, &qxl->u.alpha_blend);
+                                       &red->u.alpha_blend, &qxl->u.alpha_blend, flags);
         break;
     case QXL_DRAW_BLACKNESS:
-        red_get_blackness_ptr(slots, group_id, &red->u.blackness, &qxl->u.blackness);
+        red_get_blackness_ptr(slots, group_id,
+                              &red->u.blackness, &qxl->u.blackness, flags);
         break;
     case QXL_DRAW_BLEND:
-        red_get_blend_ptr(slots, group_id, &red->u.blend, &qxl->u.blend);
+        red_get_blend_ptr(slots, group_id, &red->u.blend, &qxl->u.blend, flags);
         break;
     case QXL_DRAW_COPY:
-        red_get_copy_ptr(slots, group_id, &red->u.copy, &qxl->u.copy);
+        red_get_copy_ptr(slots, group_id, &red->u.copy, &qxl->u.copy, flags);
         break;
     case QXL_COPY_BITS:
         red_get_point_ptr(&red->u.copy_bits.src_pos, &qxl->u.copy_bits.src_pos);
@@ -874,7 +886,7 @@ static void red_get_compat_drawable(RedMemSlotInfo *slots, int group_id,
         red_get_opaque_ptr(slots, group_id, &red->u.opaque, &qxl->u.opaque, flags);
         break;
     case QXL_DRAW_INVERS:
-        red_get_invers_ptr(slots, group_id, &red->u.invers, &qxl->u.invers);
+        red_get_invers_ptr(slots, group_id, &red->u.invers, &qxl->u.invers, flags);
         break;
     case QXL_DRAW_NOP:
         break;
@@ -889,10 +901,11 @@ static void red_get_compat_drawable(RedMemSlotInfo *slots, int group_id,
         break;
     case QXL_DRAW_TRANSPARENT:
         red_get_transparent_ptr(slots, group_id,
-                                &red->u.transparent, &qxl->u.transparent);
+                                &red->u.transparent, &qxl->u.transparent, flags);
         break;
     case QXL_DRAW_WHITENESS:
-        red_get_whiteness_ptr(slots, group_id, &red->u.whiteness, &qxl->u.whiteness);
+        red_get_whiteness_ptr(slots, group_id,
+                              &red->u.whiteness, &qxl->u.whiteness, flags);
         break;
     default:
         red_error("%s: unknown type %d", __FUNCTION__, red->type);
commit f7aa863d54e21b805cf749446b4679378b918bd8
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Tue Sep 7 11:08:18 2010 +0200

    fix brush handling for 0.4 compat
    
    spice 0.4 guests pass 16bpp colors for brushes when running in
    a 16bpp video mode.  Convert them to 32bpp.

diff --git a/server/red_parse_qxl.c b/server/red_parse_qxl.c
index adeadd6..93d95d1 100644
--- a/server/red_parse_qxl.c
+++ b/server/red_parse_qxl.c
@@ -45,6 +45,17 @@ static void hexdump_qxl(RedMemSlotInfo *slots, int group_id,
 }
 #endif
 
+static inline uint32_t color_16_to_32(uint32_t color)
+{
+    uint32_t ret;
+
+    ret = ((color & 0x001f) << 3) | ((color & 0x001c) >> 2);
+    ret |= ((color & 0x03e0) << 6) | ((color & 0x0380) << 1);
+    ret |= ((color & 0x7c00) << 9) | ((color & 0x7000) << 4);
+
+    return ret;
+}
+
 static uint8_t *red_linearize_chunk(RedDataChunk *head, size_t size, bool *free_chunk)
 {
     uint8_t *data, *ptr;
@@ -400,12 +411,16 @@ void red_put_image(SpiceImage *red)
 }
 
 static void red_get_brush_ptr(RedMemSlotInfo *slots, int group_id,
-                              SpiceBrush *red, QXLBrush *qxl)
+                              SpiceBrush *red, QXLBrush *qxl, uint32_t flags)
 {
     red->type = qxl->type;
     switch (red->type) {
     case SPICE_BRUSH_TYPE_SOLID:
-        red->u.color = qxl->u.color;
+        if (flags & QXL_COMMAND_FLAG_COMPAT_16BPP) {
+            red->u.color = color_16_to_32(qxl->u.color);
+        } else {
+            red->u.color = qxl->u.color;
+        }
         break;
     case SPICE_BRUSH_TYPE_PATTERN:
         red->u.pattern.pat = red_get_image(slots, group_id, qxl->u.pattern.pat);
@@ -437,9 +452,9 @@ static void red_put_qmask(SpiceQMask *red)
 }
 
 static void red_get_fill_ptr(RedMemSlotInfo *slots, int group_id,
-                             SpiceFill *red, QXLFill *qxl)
+                             SpiceFill *red, QXLFill *qxl, uint32_t flags)
 {
-    red_get_brush_ptr(slots, group_id, &red->brush, &qxl->brush);
+    red_get_brush_ptr(slots, group_id, &red->brush, &qxl->brush, flags);
     red->rop_descriptor = qxl->rop_descriptor;
     red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask);
 }
@@ -451,11 +466,11 @@ static void red_put_fill(SpiceFill *red)
 }
 
 static void red_get_opaque_ptr(RedMemSlotInfo *slots, int group_id,
-                               SpiceOpaque *red, QXLOpaque *qxl)
+                               SpiceOpaque *red, QXLOpaque *qxl, uint32_t flags)
 {
    red->src_bitmap     = red_get_image(slots, group_id, qxl->src_bitmap);
    red_get_rect_ptr(&red->src_area, &qxl->src_area);
-   red_get_brush_ptr(slots, group_id, &red->brush, &qxl->brush);
+   red_get_brush_ptr(slots, group_id, &red->brush, &qxl->brush, flags);
    red->rop_descriptor = qxl->rop_descriptor;
    red->scale_mode     = qxl->scale_mode;
    red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask);
@@ -537,11 +552,11 @@ static void red_put_alpha_blend(SpiceAlphaBlend *red)
 }
 
 static void red_get_rop3_ptr(RedMemSlotInfo *slots, int group_id,
-                             SpiceRop3 *red, QXLRop3 *qxl)
+                             SpiceRop3 *red, QXLRop3 *qxl, uint32_t flags)
 {
    red->src_bitmap = red_get_image(slots, group_id, qxl->src_bitmap);
    red_get_rect_ptr(&red->src_area, &qxl->src_area);
-   red_get_brush_ptr(slots, group_id, &red->brush, &qxl->brush);
+   red_get_brush_ptr(slots, group_id, &red->brush, &qxl->brush, flags);
    red->rop3       = qxl->rop3;
    red->scale_mode = qxl->scale_mode;
    red_get_qmask_ptr(slots, group_id, &red->mask, &qxl->mask);
@@ -555,7 +570,7 @@ static void red_put_rop3(SpiceRop3 *red)
 }
 
 static void red_get_stroke_ptr(RedMemSlotInfo *slots, int group_id,
-                               SpiceStroke *red, QXLStroke *qxl)
+                               SpiceStroke *red, QXLStroke *qxl, uint32_t flags)
 {
     red->path = red_get_path(slots, group_id, qxl->path);
     red->attr.flags       = qxl->attr.flags;
@@ -574,7 +589,7 @@ static void red_get_stroke_ptr(RedMemSlotInfo *slots, int group_id,
         red->attr.style_nseg  = 0;
         red->attr.style       = NULL;
     }
-    red_get_brush_ptr(slots, group_id, &red->brush, &qxl->brush);
+    red_get_brush_ptr(slots, group_id, &red->brush, &qxl->brush, flags);
     red->fore_mode        = qxl->fore_mode;
     red->back_mode        = qxl->back_mode;
 }
@@ -664,12 +679,12 @@ static SpiceString *red_get_string(RedMemSlotInfo *slots, int group_id,
 }
 
 static void red_get_text_ptr(RedMemSlotInfo *slots, int group_id,
-                             SpiceText *red, QXLText *qxl)
+                             SpiceText *red, QXLText *qxl, uint32_t flags)
 {
    red->str = red_get_string(slots, group_id, qxl->str);
    red_get_rect_ptr(&red->back_area, &qxl->back_area);
-   red_get_brush_ptr(slots, group_id, &red->fore_brush, &qxl->fore_brush);
-   red_get_brush_ptr(slots, group_id, &red->back_brush, &qxl->back_brush);
+   red_get_brush_ptr(slots, group_id, &red->fore_brush, &qxl->fore_brush, flags);
+   red_get_brush_ptr(slots, group_id, &red->back_brush, &qxl->back_brush, flags);
    red->fore_mode  = qxl->fore_mode;
    red->back_mode  = qxl->back_mode;
 }
@@ -775,10 +790,10 @@ static void red_get_native_drawable(RedMemSlotInfo *slots, int group_id,
         red_get_point_ptr(&red->u.copy_bits.src_pos, &qxl->u.copy_bits.src_pos);
         break;
     case QXL_DRAW_FILL:
-        red_get_fill_ptr(slots, group_id, &red->u.fill, &qxl->u.fill);
+        red_get_fill_ptr(slots, group_id, &red->u.fill, &qxl->u.fill, flags);
         break;
     case QXL_DRAW_OPAQUE:
-        red_get_opaque_ptr(slots, group_id, &red->u.opaque, &qxl->u.opaque);
+        red_get_opaque_ptr(slots, group_id, &red->u.opaque, &qxl->u.opaque, flags);
         break;
     case QXL_DRAW_INVERS:
         red_get_invers_ptr(slots, group_id, &red->u.invers, &qxl->u.invers);
@@ -786,13 +801,13 @@ static void red_get_native_drawable(RedMemSlotInfo *slots, int group_id,
     case QXL_DRAW_NOP:
         break;
     case QXL_DRAW_ROP3:
-        red_get_rop3_ptr(slots, group_id, &red->u.rop3, &qxl->u.rop3);
+        red_get_rop3_ptr(slots, group_id, &red->u.rop3, &qxl->u.rop3, flags);
         break;
     case QXL_DRAW_STROKE:
-        red_get_stroke_ptr(slots, group_id, &red->u.stroke, &qxl->u.stroke);
+        red_get_stroke_ptr(slots, group_id, &red->u.stroke, &qxl->u.stroke, flags);
         break;
     case QXL_DRAW_TEXT:
-        red_get_text_ptr(slots, group_id, &red->u.text, &qxl->u.text);
+        red_get_text_ptr(slots, group_id, &red->u.text, &qxl->u.text, flags);
         break;
     case QXL_DRAW_TRANSPARENT:
         red_get_transparent_ptr(slots, group_id,
@@ -853,10 +868,10 @@ static void red_get_compat_drawable(RedMemSlotInfo *slots, int group_id,
             (red->bbox.bottom - red->bbox.top);
         break;
     case QXL_DRAW_FILL:
-        red_get_fill_ptr(slots, group_id, &red->u.fill, &qxl->u.fill);
+        red_get_fill_ptr(slots, group_id, &red->u.fill, &qxl->u.fill, flags);
         break;
     case QXL_DRAW_OPAQUE:
-        red_get_opaque_ptr(slots, group_id, &red->u.opaque, &qxl->u.opaque);
+        red_get_opaque_ptr(slots, group_id, &red->u.opaque, &qxl->u.opaque, flags);
         break;
     case QXL_DRAW_INVERS:
         red_get_invers_ptr(slots, group_id, &red->u.invers, &qxl->u.invers);
@@ -864,13 +879,13 @@ static void red_get_compat_drawable(RedMemSlotInfo *slots, int group_id,
     case QXL_DRAW_NOP:
         break;
     case QXL_DRAW_ROP3:
-        red_get_rop3_ptr(slots, group_id, &red->u.rop3, &qxl->u.rop3);
+        red_get_rop3_ptr(slots, group_id, &red->u.rop3, &qxl->u.rop3, flags);
         break;
     case QXL_DRAW_STROKE:
-        red_get_stroke_ptr(slots, group_id, &red->u.stroke, &qxl->u.stroke);
+        red_get_stroke_ptr(slots, group_id, &red->u.stroke, &qxl->u.stroke, flags);
         break;
     case QXL_DRAW_TEXT:
-        red_get_text_ptr(slots, group_id, &red->u.text, &qxl->u.text);
+        red_get_text_ptr(slots, group_id, &red->u.text, &qxl->u.text, flags);
         break;
     case QXL_DRAW_TRANSPARENT:
         red_get_transparent_ptr(slots, group_id,
commit 4207c49fe2a628aaafd2ff7be12b1c6680bfe6d3
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Tue Sep 7 11:00:08 2010 +0200

    move command flags handling to the qxl parser
    
    Pass through command flags to the qxl parser, so we can hide all
    compat bits for spice 0.4 within the qxl parser.

diff --git a/server/red_parse_qxl.c b/server/red_parse_qxl.c
index e0eba20..adeadd6 100644
--- a/server/red_parse_qxl.c
+++ b/server/red_parse_qxl.c
@@ -734,8 +734,8 @@ static void red_put_clip(SpiceClip *red)
     }
 }
 
-void red_get_drawable(RedMemSlotInfo *slots, int group_id,
-                      RedDrawable *red, QXLPHYSICAL addr)
+static void red_get_native_drawable(RedMemSlotInfo *slots, int group_id,
+                                    RedDrawable *red, QXLPHYSICAL addr, uint32_t flags)
 {
     QXLDrawable *qxl;
     int i;
@@ -807,8 +807,8 @@ void red_get_drawable(RedMemSlotInfo *slots, int group_id,
     };
 }
 
-void red_get_compat_drawable(RedMemSlotInfo *slots, int group_id,
-                             RedDrawable *red, QXLPHYSICAL addr)
+static void red_get_compat_drawable(RedMemSlotInfo *slots, int group_id,
+                                    RedDrawable *red, QXLPHYSICAL addr, uint32_t flags)
 {
     QXLCompatDrawable *qxl;
 
@@ -885,6 +885,16 @@ void red_get_compat_drawable(RedMemSlotInfo *slots, int group_id,
     };
 }
 
+void red_get_drawable(RedMemSlotInfo *slots, int group_id,
+                      RedDrawable *red, QXLPHYSICAL addr, uint32_t flags)
+{
+    if (flags & QXL_COMMAND_FLAG_COMPAT) {
+        red_get_compat_drawable(slots, group_id, red, addr, flags);
+    } else {
+        red_get_native_drawable(slots, group_id, red, addr, flags);
+    }
+}
+
 void red_put_drawable(RedDrawable *red)
 {
     red_put_clip(&red->clip);
diff --git a/server/red_parse_qxl.h b/server/red_parse_qxl.h
index 1d97249..5de0325 100644
--- a/server/red_parse_qxl.h
+++ b/server/red_parse_qxl.h
@@ -113,9 +113,7 @@ typedef struct RedCursorCmd {
 void red_get_rect_ptr(SpiceRect *red, QXLRect *qxl);
 
 void red_get_drawable(RedMemSlotInfo *slots, int group_id,
-                      RedDrawable *red, QXLPHYSICAL addr);
-void red_get_compat_drawable(RedMemSlotInfo *slots, int group_id,
-                             RedDrawable *red, QXLPHYSICAL addr);
+                      RedDrawable *red, QXLPHYSICAL addr, uint32_t flags);
 void red_put_drawable(RedDrawable *red);
 void red_put_image(SpiceImage *red);
 
diff --git a/server/red_worker.c b/server/red_worker.c
index 74d26fe..f4e6f7c 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -4350,13 +4350,9 @@ static int red_process_commands(RedWorker *worker, uint32_t max_pipe_size, int *
         switch (ext_cmd.cmd.type) {
         case QXL_CMD_DRAW: {
             RedDrawable *drawable = spice_new0(RedDrawable, 1);
-            if (ext_cmd.flags & QXL_COMMAND_FLAG_COMPAT) {
-                red_get_compat_drawable(&worker->mem_slots, ext_cmd.group_id,
-                                        drawable, ext_cmd.cmd.data);
-            } else {
-                red_get_drawable(&worker->mem_slots, ext_cmd.group_id,
-                                 drawable, ext_cmd.cmd.data);
-            }
+
+            red_get_drawable(&worker->mem_slots, ext_cmd.group_id,
+                             drawable, ext_cmd.cmd.data, ext_cmd.flags);
             red_process_drawable(worker, drawable, ext_cmd.group_id);
             break;
         }


More information about the Spice-commits mailing list