From a24a8ff72ae40432f2ffe246f973057e38b042b0 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 29 Jun 2010 21:42:59 +0200 Subject: Store SpicePath segment count rather than size Internally and in the network protocol (for the new version) we now store the actual number of segments rather than the size of the full segments array in bytes. This change consists of multiple changes to handle this: * Make the qxl parser calculate num_segments * Make the canvas stroke code handle the new SpicePath layout. * Fix up is_equal_path in red_worker.c for the new layout * replace multiple calls to spice_marshall_PathSegment with a single spice_marshall_Path call * Make the byte_size() array size handling do the conversion from network size to number of elements when marshalling/demarshalling. * Update the current spice protocol to send the segment count rather than the size * Update the old spice protocol to use the new byte_size functionallity to calculate the size sent and the number of elements recieved --- common/gdi_canvas.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'common/gdi_canvas.c') diff --git a/common/gdi_canvas.c b/common/gdi_canvas.c index 594eacf4..0c99097e 100644 --- a/common/gdi_canvas.c +++ b/common/gdi_canvas.c @@ -308,19 +308,16 @@ uint32_t raster_ops[] = { 0x00FF0062 // 1 WHITENESS }; -static void set_path(GdiCanvas *canvas, void *addr) +static void set_path(GdiCanvas *canvas, SpicePath *s) { - uint32_t* data_size = (uint32_t*)addr; - uint32_t more = *data_size; - - SpicePathSeg* seg = (SpicePathSeg*)(data_size + 1); + SpicePathSeg* seg = s->segments; + int i; - do { + for (i = 0; i < s->num_segments; i++) { uint32_t flags = seg->flags; SpicePointFix* point = (SpicePointFix*)seg->data; SpicePointFix* end_point = point + seg->count; ASSERT(point < end_point); - more -= ((unsigned long)end_point - (unsigned long)seg); seg = (SpicePathSeg*)end_point; if (flags & SPICE_PATH_BEGIN) { @@ -371,7 +368,7 @@ static void set_path(GdiCanvas *canvas, void *addr) } } - } while (more); + } } static void set_scale_mode(GdiCanvas *canvas, uint8_t scale_mode) @@ -1799,7 +1796,7 @@ static void gdi_canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox, S } prev_hpen = (HPEN)SelectObject(canvas->dc, hpen); - set_path(canvas, SPICE_GET_ADDRESS(stroke->path)); + set_path(canvas, stroke->path); StrokePath(canvas->dc); -- cgit