fix polyline.
authorZhang Zhaolong <zhangzl2013@126.com>
Thu, 9 Oct 2014 10:11:38 +0000 (18:11 +0800)
committerZhang Zhaolong <zhangzl2013@126.com>
Thu, 9 Oct 2014 10:11:38 +0000 (18:11 +0800)
client/Windows/wf_gdi.c
client/X11/xf_gdi.c
include/freerdp/primary.h
libfreerdp/core/message.c
libfreerdp/core/orders.c
libfreerdp/gdi/gdi.c

index e08d1fa..bfa4699 100644 (file)
@@ -608,8 +608,6 @@ void wf_gdi_line_to(wfContext* wfc, LINE_TO_ORDER* line_to)
 
 void wf_gdi_polyline(wfContext* wfc, POLYLINE_ORDER* polyline)
 {
-       int i;
-       POINT* pts;
        int org_rop2;
        HPEN hpen;
        HPEN org_hpen;
@@ -621,26 +619,28 @@ void wf_gdi_polyline(wfContext* wfc, POLYLINE_ORDER* polyline)
        org_rop2 = wf_set_rop2(wfc->drawing->hdc, polyline->bRop2);
        org_hpen = (HPEN) SelectObject(wfc->drawing->hdc, hpen);
 
-       if (polyline->numPoints > 0)
+       if (polyline->numDeltaEntries > 0)
        {
-               POINT temp;
+               POINT  *pts;
+               POINT  temp;
+               int    numPoints;
+               int    i;
 
-               temp.x = polyline->xStart;
-               temp.y = polyline->yStart;
-               pts = (POINT*) malloc(sizeof(POINT) * polyline->numPoints);
+               numPoints = polyline->numDeltaEntries + 1;
+               pts = (POINT*) malloc(sizeof(POINT) * numPoints);
+               pts[0].x = temp.x = polyline->xStart;
+               pts[0].y = temp.y = polyline->yStart;
 
-               for (i = 0; i < (int) polyline->numPoints; i++)
+               for (i = 0; i < (int) polyline->numDeltaEntries; i++)
                {
                        temp.x += polyline->points[i].x;
                        temp.y += polyline->points[i].y;
-                       pts[i].x = temp.x;
-                       pts[i].y = temp.y;
-
-                       if (wfc->drawing == wfc->primary)
-                               wf_invalidate_region(wfc, pts[i].x, pts[i].y, pts[i].x + 1, pts[i].y + 1);
+                       pts[i + 1].x = temp.x;
+                       pts[i + 1].y = temp.y;
                }
-
-               Polyline(wfc->drawing->hdc, pts, polyline->numPoints);
+               if (wfc->drawing == wfc->primary)
+                       wf_invalidate_region(wfc, wfc->client_x, wfc->client_y, wfc->client_width, wfc->client_height);
+               Polyline(wfc->drawing->hdc, pts, numPoints);
                free(pts);
        }
 
index fcf4db5..36a1563 100644 (file)
@@ -730,6 +730,7 @@ void xf_gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline)
        int npoints;
        UINT32 color;
        XPoint* points;
+       XPoint tmp;
        int width, height;
        xfContext* xfc = (xfContext*) context;
 
@@ -742,16 +743,18 @@ void xf_gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline)
        XSetFillStyle(xfc->display, xfc->gc, FillSolid);
        XSetForeground(xfc->display, xfc->gc, color);
 
-       npoints = polyline->numPoints + 1;
+       npoints = polyline->numDeltaEntries + 1;
        points = malloc(sizeof(XPoint) * npoints);
 
-       points[0].x = polyline->xStart;
-       points[0].y = polyline->yStart;
+       points[0].x = tmp.x = polyline->xStart;
+       points[0].y = tmp.y = polyline->yStart;
 
-       for (i = 0; i < polyline->numPoints; i++)
+       for (i = 0; i < polyline->numDeltaEntries; i++)
        {
-               points[i + 1].x = polyline->points[i].x;
-               points[i + 1].y = polyline->points[i].y;
+               tmp.x += polyline->points[i].x;
+               tmp.y += polyline->points[i].y;
+               points[i + 1].x = tmp.x;
+               points[i + 1].y = tmp.y;
        }
 
        XDrawLines(xfc->display, xfc->drawing, xfc->gc, points, npoints, CoordModePrevious);
index 8cb1d71..48d9af0 100644 (file)
@@ -244,7 +244,7 @@ struct _POLYLINE_ORDER
        INT32 yStart;
        UINT32 bRop2;
        UINT32 penColor;
-       UINT32 numPoints;
+       UINT32 numDeltaEntries;
        UINT32 cbData;
        DELTA_POINT* points;
 };
index 2eaf34a..3a23674 100644 (file)
@@ -343,8 +343,8 @@ static void update_message_Polyline(rdpContext* context, POLYLINE_ORDER* polylin
        wParam = (POLYLINE_ORDER*) malloc(sizeof(POLYLINE_ORDER));
        CopyMemory(wParam, polyline, sizeof(POLYLINE_ORDER));
 
-       wParam->points = (DELTA_POINT*) malloc(sizeof(DELTA_POINT) * wParam->numPoints);
-       CopyMemory(wParam->points, polyline->points, sizeof(DELTA_POINT) * wParam->numPoints);
+       wParam->points = (DELTA_POINT*) malloc(sizeof(DELTA_POINT) * wParam->numDeltaEntries);
+       CopyMemory(wParam->points, polyline->points, sizeof(DELTA_POINT) * wParam->numDeltaEntries);
 
        MessageQueue_Post(context->update->queue, (void*) context,
                        MakeMessageId(PrimaryUpdate, Polyline), (void*) wParam, NULL);
index 3142aba..7d00b7d 100644 (file)
@@ -1320,7 +1320,7 @@ BOOL update_read_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDE
        ORDER_FIELD_BYTE(3, polyline->bRop2);
        ORDER_FIELD_UINT16(4, word);
        ORDER_FIELD_COLOR(5, polyline->penColor);
-       ORDER_FIELD_BYTE(6, polyline->numPoints);
+       ORDER_FIELD_BYTE(6, polyline->numDeltaEntries);
 
        if (orderInfo->fieldFlags & ORDER_FIELD_07)
        {
@@ -1329,11 +1329,11 @@ BOOL update_read_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDE
                Stream_Read_UINT8(s, polyline->cbData);
 
                if (polyline->points == NULL)
-                       polyline->points = (DELTA_POINT*) malloc(sizeof(DELTA_POINT) * polyline->numPoints);
+                       polyline->points = (DELTA_POINT*) malloc(sizeof(DELTA_POINT) * polyline->numDeltaEntries);
                else
-                       polyline->points = (DELTA_POINT*) realloc(polyline->points, sizeof(DELTA_POINT) * polyline->numPoints);
+                       polyline->points = (DELTA_POINT*) realloc(polyline->points, sizeof(DELTA_POINT) * polyline->numDeltaEntries);
 
-               return update_read_delta_points(s, polyline->points, polyline->numPoints, polyline->xStart, polyline->yStart);
+               return update_read_delta_points(s, polyline->points, polyline->numDeltaEntries, polyline->xStart, polyline->yStart);
        }
 
        return TRUE;
index 72720da..330b56b 100644 (file)
@@ -753,7 +753,7 @@ static void gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline)
        gdi_MoveToEx(gdi->drawing->hdc, x, y, NULL);
 
        points = polyline->points;
-       for (i = 0; i < (int) polyline->numPoints; i++)
+       for (i = 0; i < (int) polyline->numDeltaEntries; i++)
        {
                x += points[i].x;
                y += points[i].y;