diff --git a/orders.c b/orders.c index 66f26be..b148776 100644 --- a/orders.c +++ b/orders.c @@ -648,11 +648,10 @@ process_polygon2(STREAM s, POLYGON2_ORDER * os, uint32 present, BOOL delta) static void process_polyline(STREAM s, POLYLINE_ORDER * os, uint32 present, BOOL delta) { - int index, line, data; - int x, y, xfrom, yfrom; + int index, next, data; uint8 flags = 0; PEN pen; - uint8 opcode; + POINT *points; if (present & 0x01) rdp_in_coord(s, &os->x, delta); @@ -691,35 +690,32 @@ process_polyline(STREAM s, POLYLINE_ORDER * os, uint32 present, BOOL delta) return; } - opcode = os->opcode - 1; - x = os->x; - y = os->y; - pen.style = pen.width = 0; - pen.colour = os->fgcolour; + points = (POINT *) xmalloc((os->lines + 1) * sizeof(POINT)); + memset(points, 0, (os->lines + 1) * sizeof(POINT)); + + points[0].x = os->x; + points[0].y = os->y; index = 0; data = ((os->lines - 1) / 4) + 1; - for (line = 0; (line < os->lines) && (data < os->datasize); line++) + for (next = 1; (next < os->lines) && (data < os->datasize); next++) { - xfrom = x; - yfrom = y; - - if (line % 4 == 0) + if ((next - 1) % 4 == 0) flags = os->data[index++]; - if ((flags & 0xc0) == 0) - flags |= 0xc0; /* none = both */ + if (~flags & 0x80) + points[next].x = parse_delta(os->data, &data); - if (flags & 0x40) - x += parse_delta(os->data, &data); - - if (flags & 0x80) - y += parse_delta(os->data, &data); - - ui_line(opcode, xfrom, yfrom, x, y, &pen); + if (~flags & 0x40) + points[next].y = parse_delta(os->data, &data); flags <<= 2; } + + if (next - 1 == os->lines) + ui_polyline(os->opcode - 1, points, os->lines + 1, &pen); + else + error("polyline parse error\n"); } /* Process an ellipse order */ diff --git a/proto.h b/proto.h index 5e5101b..051ce5c 100644 --- a/proto.h +++ b/proto.h @@ -213,6 +213,7 @@ void ui_line(uint8 opcode, int startx, int starty, int endx, int endy, PEN * pen void ui_rect(int x, int y, int cx, int cy, int colour); void ui_polygon(uint8 opcode, uint8 fillmode, POINT * point, int npoints, BRUSH * brush, int bgcolour, int fgcolour); +void ui_polyline(uint8 opcode, POINT * point, int npoints, PEN * pen); void ui_ellipse(uint8 opcode, uint8 fillmode, int x, int y, int cx, int cy, BRUSH * brush, int bgcolour, int fgcolour); void ui_draw_glyph(int mixmode, int x, int y, int cx, int cy, HGLYPH glyph, int srcx, int srcy, diff --git a/xwin.c b/xwin.c index 83e9df2..1baba68 100644 --- a/xwin.c +++ b/xwin.c @@ -2262,6 +2262,21 @@ ui_polygon(uint8 opcode, RESET_FUNCTION(opcode); } +void +ui_polyline(uint8 opcode, + /* dest */ POINT * points, int npoints, + /* pen */ PEN * pen) +{ + /* TODO: set join style */ + SET_FUNCTION(opcode); + SET_FOREGROUND(pen->colour); + XDrawLines(g_display, g_wnd, g_gc, (XPoint *) points, npoints, CoordModePrevious); + if (g_ownbackstore) + XDrawLines(g_display, g_backstore, g_gc, (XPoint *) points, npoints, + CoordModePrevious); + RESET_FUNCTION(opcode); +} + void ui_ellipse(uint8 opcode, /* mode */ uint8 fillmode,