From fadce7ca567790bc7d1ace9607fc3382f58db720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 12 Oct 2011 16:00:10 -0400 Subject: [PATCH 1/2] xfreerdp: fix region invalidation in polyline --- client/X11/xf_gdi.c | 55 +++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/client/X11/xf_gdi.c b/client/X11/xf_gdi.c index 4ab8416f1..77b721747 100644 --- a/client/X11/xf_gdi.c +++ b/client/X11/xf_gdi.c @@ -567,34 +567,6 @@ void xf_gdi_polyline(rdpUpdate* update, POLYLINE_ORDER* polyline) { points[i].x = polyline->points[i].x; points[i].y = polyline->points[i].y; - - if (i > 0) - { - width = points[i].x - points[i - 1].x; - height = points[i].y - points[i - 1].y; - - if (width < 0) - { - width *= (-1); - x = points[i].x; - } - else - { - x = points[i - 1].x; - } - - if (height < 0) - { - height *= (-1); - y = points[i].y; - } - else - { - y = points[i - 1].y; - } - - gdi_InvalidateRegion(xfi->hdc, x, y, width, height); - } } XDrawLines(xfi->display, xfi->drawing, xfi->gc, points, polyline->numPoints, CoordModePrevious); @@ -602,8 +574,33 @@ void xf_gdi_polyline(rdpUpdate* update, POLYLINE_ORDER* polyline) if (xfi->drawing == xfi->primary) { if (xfi->remote_app != True) - { XDrawLines(xfi->display, xfi->drawable, xfi->gc, points, polyline->numPoints, CoordModePrevious); + + for (i = 1; i < polyline->numPoints; i++) + { + if (points[i].x > points[i - 1].x) + { + x = points[i - 1].x; + width = points[i].x - points[i - 1].x; + } + else + { + x = points[i].x; + width = points[i - 1].x - points[i].x; + } + + if (points[i].y > points[i - 1].y) + { + y = points[i - 1].y; + height = points[i].y - points[i - 1].y; + } + else + { + y = points[i].y; + height = points[i - 1].y - points[i].y; + } + + gdi_InvalidateRegion(xfi->hdc, x, y, width, height); } } From a40a971ea3b934866b918c38cc7f6791e89197d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 12 Oct 2011 18:10:54 -0400 Subject: [PATCH 2/2] libfreerdp-core: fix polyline order parsing --- client/X11/xf_gdi.c | 52 ++++++++++++++++++++-------------------- libfreerdp-core/orders.c | 3 --- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/client/X11/xf_gdi.c b/client/X11/xf_gdi.c index 77b721747..90ae884d4 100644 --- a/client/X11/xf_gdi.c +++ b/client/X11/xf_gdi.c @@ -550,6 +550,9 @@ void xf_gdi_polyline(rdpUpdate* update, POLYLINE_ORDER* polyline) { int i; int x, y; + int x1, y1; + int x2, y2; + int npoints; uint32 color; XPoint* points; int width, height; @@ -561,44 +564,41 @@ void xf_gdi_polyline(rdpUpdate* update, POLYLINE_ORDER* polyline) XSetFillStyle(xfi->display, xfi->gc, FillSolid); XSetForeground(xfi->display, xfi->gc, color); - points = xmalloc(sizeof(XPoint) * polyline->numPoints); + npoints = polyline->numPoints + 1; + points = xmalloc(sizeof(XPoint) * npoints); + + points[0].x = polyline->xStart; + points[0].y = polyline->yStart; for (i = 0; i < polyline->numPoints; i++) { - points[i].x = polyline->points[i].x; - points[i].y = polyline->points[i].y; + points[i + 1].x = polyline->points[i].x; + points[i + 1].y = polyline->points[i].y; } - XDrawLines(xfi->display, xfi->drawing, xfi->gc, points, polyline->numPoints, CoordModePrevious); + XDrawLines(xfi->display, xfi->drawing, xfi->gc, points, npoints, CoordModePrevious); if (xfi->drawing == xfi->primary) { if (xfi->remote_app != True) - XDrawLines(xfi->display, xfi->drawable, xfi->gc, points, polyline->numPoints, CoordModePrevious); + XDrawLines(xfi->display, xfi->drawable, xfi->gc, points, npoints, CoordModePrevious); - for (i = 1; i < polyline->numPoints; i++) + x1 = points[0].x; + y1 = points[0].y; + + for (i = 1; i < npoints; i++) { - if (points[i].x > points[i - 1].x) - { - x = points[i - 1].x; - width = points[i].x - points[i - 1].x; - } - else - { - x = points[i].x; - width = points[i - 1].x - points[i].x; - } + x2 = points[i].x + x1; + y2 = points[i].y + y1; - if (points[i].y > points[i - 1].y) - { - y = points[i - 1].y; - height = points[i].y - points[i - 1].y; - } - else - { - y = points[i].y; - height = points[i - 1].y - points[i].y; - } + x = (x2 < x1) ? x2 : x1; + width = (x2 > x1) ? x2 - x1 : x1 - x2; + + y = (y2 < y1) ? y2 : y1; + height = (y2 > y1) ? y2 - y1 : y1 - y2; + + x1 = x2; + y1 = y2; gdi_InvalidateRegion(xfi->hdc, x, y, width, height); } diff --git a/libfreerdp-core/orders.c b/libfreerdp-core/orders.c index c1ba4d27b..3ed869a28 100644 --- a/libfreerdp-core/orders.c +++ b/libfreerdp-core/orders.c @@ -417,9 +417,6 @@ INLINE void update_read_delta_points(STREAM* s, DELTA_POINT* points, int number, if (~flags & 0x40) update_read_delta(s, &points[i].y); - points[i].x += (i > 0 ? points[i - 1].x : x); - points[i].y += (i > 0 ? points[i - 1].y : y); - flags <<= 2; } }