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
This commit is contained in:
Alexander Larsson 2010-06-29 21:42:59 +02:00 committed by Gerd Hoffmann
parent efe133f71d
commit 03a0b6741a
3 changed files with 13 additions and 23 deletions

View File

@ -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);

View File

@ -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 = s->segments;
int i;
SpicePathSeg* seg = (SpicePathSeg*)(data_size + 1);
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);

View File

@ -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);
}