Merge pull request #2141 from zhangzl2013/polyline

fix polyline.
This commit is contained in:
Hardening 2014-10-31 22:15:13 +01:00
commit 7b108f1aa8
6 changed files with 32 additions and 29 deletions

View 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 *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);
}

View File

@ -733,6 +733,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;
@ -745,16 +746,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);

View File

@ -244,7 +244,7 @@ struct _POLYLINE_ORDER
INT32 yStart;
UINT32 bRop2;
UINT32 penColor;
UINT32 numPoints;
UINT32 numDeltaEntries;
UINT32 cbData;
DELTA_POINT* points;
};

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

View 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;

View File

@ -764,7 +764,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;