summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-06-29 21:42:59 +0200
committerGerd Hoffmann <kraxel@redhat.com>2010-06-30 22:35:17 +0200
commita24a8ff72ae40432f2ffe246f973057e38b042b0 (patch)
tree34fa9ddf1033ec22e3bc113582bef07f7e29c6b5 /common
parent0f5a6f57b70bb7c94e15e908db4627d44c339b9c (diff)
downloadspice-a24a8ff72ae40432f2ffe246f973057e38b042b0.tar.gz
spice-a24a8ff72ae40432f2ffe246f973057e38b042b0.tar.xz
spice-a24a8ff72ae40432f2ffe246f973057e38b042b0.zip
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
Diffstat (limited to 'common')
-rw-r--r--common/canvas_base.c11
-rw-r--r--common/gdi_canvas.c15
-rw-r--r--common/gl_canvas.c10
3 files changed, 13 insertions, 23 deletions
diff --git a/common/canvas_base.c b/common/canvas_base.c
index ba0fb214..b8a42e67 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -3077,8 +3077,6 @@ static void canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox,
stroke_fill_spans,
stroke_fill_rects
};
- uint32_t *data_size;
- uint32_t more;
SpicePathSeg *seg;
StrokeLines lines;
int i;
@@ -3182,18 +3180,15 @@ static void canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox,
CANVAS_ERROR("invalid brush type");
}
- data_size = (uint32_t*)SPICE_GET_ADDRESS(stroke->path);
- more = *data_size;
- seg = (SpicePathSeg*)(data_size + 1);
+ seg = stroke->path->segments;
stroke_lines_init(&lines);
- do {
+ for (i = 0; i < stroke->path->num_segments; i++) {
uint32_t flags = seg->flags;
SpicePointFix* point = seg->points;
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) {
@@ -3223,7 +3218,7 @@ static void canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox,
}
stroke_lines_draw(&lines, (lineGC *)&gc, dashed);
}
- } while (more);
+ }
stroke_lines_draw(&lines, (lineGC *)&gc, dashed);
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);
diff --git a/common/gl_canvas.c b/common/gl_canvas.c
index 59fb1a7a..5a03d155 100644
--- a/common/gl_canvas.c
+++ b/common/gl_canvas.c
@@ -114,15 +114,13 @@ static pixman_image_t *canvas_surf_to_trans_surf(GLCImage *image,
static GLCPath get_path(GLCanvas *canvas, SpicePath *s)
{
GLCPath path = glc_path_create(canvas->glc);
- uint32_t more = s->size;
+ int i;
SpicePathSeg* seg = s->segments;
- do {
+ for (i = 0; i < s->num_segments; i++) {
uint32_t flags = seg->flags;
SpicePointFix* point = seg->points;
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) {
@@ -148,7 +146,7 @@ static GLCPath get_path(GLCanvas *canvas, SpicePath *s)
glc_path_close(path);
}
}
- } while (more);
+ }
return path;
}
@@ -621,7 +619,7 @@ static void gl_canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox, Sp
}
glc_set_line_width(canvas->glc, fix_to_double(stroke->attr.width));
- path = get_path(canvas, SPICE_GET_ADDRESS(stroke->path));
+ path = get_path(canvas, stroke->path);
glc_stroke_path(canvas->glc, path);
glc_path_destroy(path);
}