Fix #4299: gdi_CRgnToRect

The coordinates from RDP ROP commands do not (always) have
0,0 as the origin of the drawing operation.
Adjust the coordinates to our local coordinate system.
This commit is contained in:
Armin Novak 2017-12-22 13:43:37 +01:00
parent c60c355a9d
commit cf899eb5ba
2 changed files with 27 additions and 26 deletions

View File

@ -26,43 +26,43 @@
#include <freerdp/gdi/gdi.h>
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif
FREERDP_API HGDI_RGN gdi_CreateRectRgn(UINT32 nLeftRect, UINT32 nTopRect,
UINT32 nRightRect, UINT32 nBottomRect);
UINT32 nRightRect, UINT32 nBottomRect);
FREERDP_API HGDI_RECT gdi_CreateRect(UINT32 xLeft, UINT32 yTop,
UINT32 xRight, UINT32 yBottom);
UINT32 xRight, UINT32 yBottom);
FREERDP_API void gdi_RectToRgn(HGDI_RECT rect, HGDI_RGN rgn);
FREERDP_API void gdi_CRectToRgn(UINT32 left, UINT32 top,
UINT32 right, UINT32 bottom, HGDI_RGN rgn);
FREERDP_API void gdi_RectToCRgn(const HGDI_RECT rect, UINT32 *x, UINT32 *y,
UINT32 *w, UINT32 *h);
UINT32 right, UINT32 bottom, HGDI_RGN rgn);
FREERDP_API void gdi_RectToCRgn(const HGDI_RECT rect, UINT32* x, UINT32* y,
UINT32* w, UINT32* h);
FREERDP_API void gdi_CRectToCRgn(UINT32 left, UINT32 top,
UINT32 right, UINT32 bottom,
UINT32 *x, UINT32 *y, UINT32 *w, UINT32 *h);
UINT32 right, UINT32 bottom,
UINT32* x, UINT32* y, UINT32* w, UINT32* h);
FREERDP_API void gdi_RgnToRect(HGDI_RGN rgn, HGDI_RECT rect);
FREERDP_API void gdi_CRgnToRect(UINT32 x, UINT32 y, UINT32 w, UINT32 h, HGDI_RECT rect);
FREERDP_API void gdi_RgnToCRect(HGDI_RGN rgn, UINT32 *left,
UINT32 *top, UINT32 *right, UINT32 *bottom);
FREERDP_API void gdi_CRgnToRect(INT64 x, INT64 y, UINT32 w, UINT32 h, HGDI_RECT rect);
FREERDP_API void gdi_RgnToCRect(HGDI_RGN rgn, UINT32* left,
UINT32* top, UINT32* right, UINT32* bottom);
FREERDP_API void gdi_CRgnToCRect(UINT32 x, UINT32 y, UINT32 w, UINT32 h,
UINT32 *left, UINT32 *top, UINT32 *right, UINT32 *bottom);
UINT32* left, UINT32* top, UINT32* right, UINT32* bottom);
FREERDP_API BOOL gdi_CopyOverlap(UINT32 x, UINT32 y, UINT32 width, UINT32 height,
UINT32 srcx, UINT32 srcy);
UINT32 srcx, UINT32 srcy);
FREERDP_API BOOL gdi_SetRect(HGDI_RECT rc, UINT32 xLeft, UINT32 yTop,
UINT32 xRight, UINT32 yBottom);
UINT32 xRight, UINT32 yBottom);
FREERDP_API BOOL gdi_SetRgn(HGDI_RGN hRgn, UINT32 nXLeft, UINT32 nYLeft,
UINT32 nWidth, UINT32 nHeight);
UINT32 nWidth, UINT32 nHeight);
FREERDP_API BOOL gdi_SetRectRgn(HGDI_RGN hRgn, UINT32 nLeftRect, UINT32 nTopRect,
UINT32 nRightRect, UINT32 nBottomRect);
UINT32 nRightRect, UINT32 nBottomRect);
FREERDP_API BOOL gdi_EqualRgn(HGDI_RGN hSrcRgn1, HGDI_RGN hSrcRgn2);
FREERDP_API BOOL gdi_CopyRect(HGDI_RECT dst, HGDI_RECT src);
FREERDP_API BOOL gdi_PtInRect(HGDI_RECT rc, UINT32 x, UINT32 y);
FREERDP_API BOOL gdi_InvalidateRegion(HGDI_DC hdc, UINT32 x, UINT32 y,
UINT32 w, UINT32 h);
UINT32 w, UINT32 h);
#ifdef __cplusplus
}
}
#endif
#endif /* FREERDP_GDI_REGION_H */

View File

@ -184,20 +184,21 @@ INLINE void gdi_RgnToRect(HGDI_RGN rgn, HGDI_RECT rect)
* @param rect destination rectangle
*/
INLINE void gdi_CRgnToRect(UINT32 x, UINT32 y, UINT32 w, UINT32 h,
INLINE void gdi_CRgnToRect(INT64 x, INT64 y, UINT32 w, UINT32 h,
HGDI_RECT rect)
{
memset(rect, 0, sizeof(GDI_RECT));
rect->left = x;
rect->top = y;
const INT64 r = x + w - 1;
const INT64 b = y + h - 1;
rect->left = (x > 0) ? x : 0;
rect->top = (y > 0) ? y : 0;
if (w > 0)
rect->right = x + w - 1;
if (r > 0)
rect->right = r;
else
WLog_ERR(TAG, "Invalid width");
if (h > 0)
rect->bottom = y + h - 1;
if (b > 0)
rect->bottom = b;
else
WLog_ERR(TAG, "Invalid height");
}