Merge pull request #4953 from akallabeth/region_signed

signed gdi regions to adjust negative coordinates
This commit is contained in:
Bernhard Miklautz 2018-11-20 10:07:30 +00:00 committed by GitHub
commit ef0c7e81a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 348 additions and 594 deletions

View File

@ -144,12 +144,12 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
xbitmap->image = XCreateImage(xfc->display, xfc->visual, xfc->depth,
ZPixmap, 0, (char*) bitmap->data, bitmap->width, bitmap->height,
xfc->scanline_pad, 0);
if (!xbitmap->image)
goto unlock;
xbitmap->image->byte_order = LSBFirst;
xbitmap->image->bitmap_bit_order = LSBFirst;
XPutImage(xfc->display, xbitmap->pixmap, xfc->gc, xbitmap->image, 0, 0, 0, 0, bitmap->width,
bitmap->height);
}
@ -425,8 +425,8 @@ static void xf_Glyph_Free(rdpContext* context, rdpGlyph* glyph)
free(glyph);
}
static BOOL xf_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, UINT32 x,
UINT32 y, UINT32 w, UINT32 h, UINT32 sx, UINT32 sy,
static BOOL xf_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, INT32 x,
INT32 y, INT32 w, INT32 h, INT32 sx, INT32 sy,
BOOL fOpRedundant)
{
xfGlyph* xf_glyph;
@ -453,8 +453,8 @@ static BOOL xf_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, UINT32 x,
return TRUE;
}
static BOOL xf_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y,
UINT32 width, UINT32 height, UINT32 bgcolor,
static BOOL xf_Glyph_BeginDraw(rdpContext* context, INT32 x, INT32 y,
INT32 width, INT32 height, UINT32 bgcolor,
UINT32 fgcolor, BOOL fOpRedundant)
{
xfContext* xfc = (xfContext*) context;
@ -487,8 +487,8 @@ static BOOL xf_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y,
return TRUE;
}
static BOOL xf_Glyph_EndDraw(rdpContext* context, UINT32 x, UINT32 y,
UINT32 width, UINT32 height,
static BOOL xf_Glyph_EndDraw(rdpContext* context, INT32 x, INT32 y,
INT32 width, INT32 height,
UINT32 bgcolor, UINT32 fgcolor)
{
xfContext* xfc = (xfContext*) context;

View File

@ -42,14 +42,14 @@ FREERDP_API HGDI_BITMAP gdi_CreateBitmapEx(UINT32 nWidth, UINT32 nHeight,
FREERDP_API HGDI_BITMAP gdi_CreateCompatibleBitmap(HGDI_DC hdc,
UINT32 nWidth, UINT32 nHeight);
FREERDP_API BOOL gdi_BitBlt(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc, DWORD rop,
FREERDP_API BOOL gdi_BitBlt(HGDI_DC hdcDest, INT32 nXDest, INT32 nYDest,
INT32 nWidth, INT32 nHeight, HGDI_DC hdcSrc,
INT32 nXSrc, INT32 nYSrc, DWORD rop,
const gdiPalette* palette);
typedef BOOL (*p_BitBlt)(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc, DWORD rop);
typedef BOOL (*p_BitBlt)(HGDI_DC hdcDest, INT32 nXDest, INT32 nYDest,
INT32 nWidth, INT32 nHeight, HGDI_DC hdcSrc,
INT32 nXSrc, INT32 nYSrc, DWORD rop);
#ifdef __cplusplus
}

View File

@ -367,10 +367,10 @@ typedef GDIOBJECT* HGDIOBJECT;
struct _GDI_RECT
{
BYTE objectType;
UINT32 left;
UINT32 top;
UINT32 right;
UINT32 bottom;
INT32 left;
INT32 top;
INT32 right;
INT32 bottom;
};
typedef struct _GDI_RECT GDI_RECT;
typedef GDI_RECT* HGDI_RECT;
@ -378,10 +378,10 @@ typedef GDI_RECT* HGDI_RECT;
struct _GDI_RGN
{
BYTE objectType;
UINT32 x; /* left */
UINT32 y; /* top */
UINT32 w; /* width */
UINT32 h; /* height */
INT32 x; /* left */
INT32 y; /* top */
INT32 w; /* width */
INT32 h; /* height */
BOOL null; /* null region */
};
typedef struct _GDI_RGN GDI_RGN;
@ -391,8 +391,8 @@ struct _GDI_BITMAP
{
BYTE objectType;
UINT32 format;
UINT32 width;
UINT32 height;
INT32 width;
INT32 height;
UINT32 scanline;
BYTE* data;
void (*free)(void*);
@ -404,9 +404,9 @@ struct _GDI_PEN
{
BYTE objectType;
UINT32 style;
UINT32 width;
UINT32 posX;
UINT32 posY;
INT32 width;
INT32 posX;
INT32 posY;
UINT32 color;
UINT32 format;
const gdiPalette* palette;
@ -432,8 +432,8 @@ typedef GDI_PALETTE* HGDI_PALETTE;
struct _GDI_POINT
{
UINT32 x;
UINT32 y;
INT32 x;
INT32 y;
};
typedef struct _GDI_POINT GDI_POINT;
typedef GDI_POINT* HGDI_POINT;
@ -444,8 +444,8 @@ struct _GDI_BRUSH
int style;
HGDI_BITMAP pattern;
UINT32 color;
UINT32 nXOrg;
UINT32 nYOrg;
INT32 nXOrg;
INT32 nYOrg;
};
typedef struct _GDI_BRUSH GDI_BRUSH;
typedef GDI_BRUSH* HGDI_BRUSH;
@ -470,8 +470,8 @@ struct _GDI_DC
HGDI_RGN clip;
HGDI_PEN pen;
HGDI_WND hwnd;
UINT32 drawMode;
UINT32 bkMode;
INT32 drawMode;
INT32 bkMode;
};
typedef struct _GDI_DC GDI_DC;
typedef GDI_DC* HGDI_DC;
@ -500,8 +500,8 @@ struct rdp_gdi
{
rdpContext* context;
UINT32 width;
UINT32 height;
INT32 width;
INT32 height;
UINT32 stride;
UINT32 dstFormat;
UINT32 cursor_x;

View File

@ -29,37 +29,37 @@
extern "C" {
#endif
FREERDP_API HGDI_RGN gdi_CreateRectRgn(UINT32 nLeftRect, UINT32 nTopRect,
UINT32 nRightRect, UINT32 nBottomRect);
FREERDP_API HGDI_RECT gdi_CreateRect(UINT32 xLeft, UINT32 yTop,
UINT32 xRight, UINT32 yBottom);
FREERDP_API HGDI_RGN gdi_CreateRectRgn(INT32 nLeftRect, INT32 nTopRect,
INT32 nRightRect, INT32 nBottomRect);
FREERDP_API HGDI_RECT gdi_CreateRect(INT32 xLeft, INT32 yTop,
INT32 xRight, INT32 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);
FREERDP_API void gdi_CRectToCRgn(UINT32 left, UINT32 top,
UINT32 right, UINT32 bottom,
UINT32* x, UINT32* y, UINT32* w, UINT32* h);
FREERDP_API void gdi_CRectToRgn(INT32 left, INT32 top,
INT32 right, INT32 bottom, HGDI_RGN rgn);
FREERDP_API void gdi_RectToCRgn(const HGDI_RECT rect, INT32* x, INT32* y,
INT32* w, INT32* h);
FREERDP_API void gdi_CRectToCRgn(INT32 left, INT32 top,
INT32 right, INT32 bottom,
INT32* x, INT32* y, INT32* w, INT32* h);
FREERDP_API void gdi_RgnToRect(HGDI_RGN rgn, HGDI_RECT rect);
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);
FREERDP_API BOOL gdi_CopyOverlap(UINT32 x, UINT32 y, UINT32 width, UINT32 height,
UINT32 srcx, UINT32 srcy);
FREERDP_API BOOL gdi_SetRect(HGDI_RECT rc, UINT32 xLeft, UINT32 yTop,
UINT32 xRight, UINT32 yBottom);
FREERDP_API BOOL gdi_SetRgn(HGDI_RGN hRgn, UINT32 nXLeft, UINT32 nYLeft,
UINT32 nWidth, UINT32 nHeight);
FREERDP_API BOOL gdi_SetRectRgn(HGDI_RGN hRgn, UINT32 nLeftRect, UINT32 nTopRect,
UINT32 nRightRect, UINT32 nBottomRect);
FREERDP_API void gdi_CRgnToRect(INT64 x, INT64 y, INT32 w, INT32 h, HGDI_RECT rect);
FREERDP_API void gdi_RgnToCRect(HGDI_RGN rgn, INT32* left,
INT32* top, INT32* right, INT32* bottom);
FREERDP_API void gdi_CRgnToCRect(INT32 x, INT32 y, INT32 w, INT32 h,
INT32* left, INT32* top, INT32* right, INT32* bottom);
FREERDP_API BOOL gdi_CopyOverlap(INT32 x, INT32 y, INT32 width, INT32 height,
INT32 srcx, INT32 srcy);
FREERDP_API BOOL gdi_SetRect(HGDI_RECT rc, INT32 xLeft, INT32 yTop,
INT32 xRight, INT32 yBottom);
FREERDP_API BOOL gdi_SetRgn(HGDI_RGN hRgn, INT32 nXLeft, INT32 nYLeft,
INT32 nWidth, INT32 nHeight);
FREERDP_API BOOL gdi_SetRectRgn(HGDI_RGN hRgn, INT32 nLeftRect, INT32 nTopRect,
INT32 nRightRect, INT32 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);
FREERDP_API BOOL gdi_PtInRect(HGDI_RECT rc, INT32 x, INT32 y);
FREERDP_API BOOL gdi_InvalidateRegion(HGDI_DC hdc, INT32 x, INT32 y,
INT32 w, INT32 h);
#ifdef __cplusplus
}

View File

@ -34,8 +34,8 @@ FREERDP_API BOOL gdi_FillRect(HGDI_DC hdc, const HGDI_RECT rect,
FREERDP_API BOOL gdi_Polygon(HGDI_DC hdc, GDI_POINT* lpPoints, int nCount);
FREERDP_API BOOL gdi_PolyPolygon(HGDI_DC hdc, GDI_POINT* lpPoints,
int* lpPolyCounts, int nCount);
FREERDP_API BOOL gdi_Rectangle(HGDI_DC hdc, UINT32 nXDst, UINT32 nYDst,
UINT32 nWidth, UINT32 nHeight);
FREERDP_API BOOL gdi_Rectangle(HGDI_DC hdc, INT32 nXDst, INT32 nYDst,
INT32 nWidth, INT32 nHeight);
#ifdef __cplusplus
}

View File

@ -119,13 +119,15 @@ FREERDP_API rdpPointer* Pointer_Alloc(rdpContext* context);
typedef BOOL (*pGlyph_New)(rdpContext* context, const rdpGlyph* glyph);
typedef void (*pGlyph_Free)(rdpContext* context, rdpGlyph* glyph);
typedef BOOL (*pGlyph_Draw)(rdpContext* context, const rdpGlyph* glyph,
UINT32 x, UINT32 y, UINT32 w, UINT32 h,
UINT32 sx, UINT32 sy, BOOL fOpRedundant);
typedef BOOL (*pGlyph_BeginDraw)(rdpContext* context, UINT32 x, UINT32 y,
UINT32 width, UINT32 height, UINT32 bgcolor,
INT32 x, INT32 y, INT32 w, INT32 h,
INT32 sx, INT32 sy, BOOL fOpRedundant);
typedef BOOL (*pGlyph_BeginDraw)(rdpContext* context, INT32 x, INT32 y,
INT32 width, INT32 height, UINT32 bgcolor,
UINT32 fgcolor, BOOL fOpRedundant);
typedef BOOL (*pGlyph_EndDraw)(rdpContext* context, UINT32 x, UINT32 y,
UINT32 width, UINT32 height, UINT32 bgcolor, UINT32 fgcolor);
typedef BOOL (*pGlyph_EndDraw)(rdpContext* context, INT32 x, INT32 y,
INT32 width, INT32 height, UINT32 bgcolor, UINT32 fgcolor);
typedef BOOL (*pGlyph_SetBounds)(rdpContext* context, INT32 x, INT32 y,
INT32 width, INT32 height);
struct rdp_glyph
{
@ -135,7 +137,8 @@ struct rdp_glyph
pGlyph_Draw Draw; /* 3 */
pGlyph_BeginDraw BeginDraw; /* 4 */
pGlyph_EndDraw EndDraw; /* 5 */
UINT32 paddingA[16 - 6]; /* 6 */
pGlyph_SetBounds SetBounds; /* 6 */
UINT32 paddingA[16 - 7]; /* 7 */
INT32 x; /* 16 */
INT32 y; /* 17 */

View File

@ -235,6 +235,9 @@ static BOOL update_process_glyph_fragments(rdpContext* context,
fOpRedundant))
return FALSE;
if (!IFCALLRESULT(TRUE, glyph->SetBounds, context, bkX, bkY, bkWidth, bkHeight))
return FALSE;
while (index < length)
{
const UINT32 op = data[index++];

View File

@ -439,240 +439,7 @@ static const char* altsec_order_string(BYTE orderType)
sprintf_s(buffer, ARRAYSIZE(buffer), fmt, orderType);
return buffer;
}
static BOOL freerdp_primary_adjust_bound(wLog* log, const char* order, rdpContext* context,
INT32* pLeft, INT32* pTop,
INT32* pRight,
INT32* pBottom)
{
UINT32 dw, dh;
INT32 left = *pLeft;
INT32 top = *pTop;
INT32 right = *pRight;
INT32 bottom = *pBottom;
if (!context || !context->settings)
return FALSE;
dw = context->settings->DesktopWidth;
dh = context->settings->DesktopHeight;
if (left < 0)
left = 0;
if (top < 0)
top = 0;
if (right < 0)
right = 0;
if (bottom < 0)
bottom = 0;
if (right > dw)
right = dw;
if (left > right)
left = right;
if (top > dh)
top = dh;
if (bottom > dh)
bottom = dh;
if (top > bottom)
top = bottom;
if (*pLeft != left)
WLog_Print(log, WLOG_WARN, "[%s] Adjusted left from %"PRId32" to %"PRId32, order, *pLeft, left);
if (*pTop != top)
WLog_Print(log, WLOG_WARN, "[%s] Adjusted top from %"PRId32" to %"PRId32, order, *pTop, top);
if (*pRight != right)
WLog_Print(log, WLOG_WARN, "[%s] Adjusted right from %"PRId32" to %"PRId32, order, *pRight, right);
if (*pBottom != bottom)
WLog_Print(log, WLOG_WARN, "[%s] Adjusted bottom from %"PRId32" to %"PRId32, order, *pBottom,
bottom);
*pLeft = left;
*pTop = top;
*pRight = right;
*pBottom = bottom;
return TRUE;
}
static BOOL freerdp_primary_adjust_bounds(wLog* log, const char* order, rdpContext* context,
rdpBounds* bounds)
{
if (!context || !context->settings || !bounds)
return FALSE;
return freerdp_primary_adjust_bound(log, order, context, &bounds->left, &bounds->top,
&bounds->right,
&bounds->bottom);
}
static BOOL freerdp_primary_adjust_rect(wLog* log, const char* order, rdpContext* context,
INT32* pLeft, INT32* pTop,
INT32* pWidth,
INT32* pHeight)
{
UINT32 dw, dh;
INT32 left = *pLeft;
INT32 top = *pTop;
INT32 width = *pWidth;
INT32 height = *pHeight;
if (!context || !context->settings)
return FALSE;
dw = context->settings->DesktopWidth;
dh = context->settings->DesktopHeight;
if (left < 0)
left = 0;
if (top < 0)
top = 0;
if (width < 0)
width = 0;
if (height < 0)
height = 0;
if (left > dw)
left = dw;
if (left + width > dw)
width = dw - left;
if (top > dh)
top = dh;
if (top + height > dh)
height = dh - top;
if (*pLeft != left)
WLog_Print(log, WLOG_WARN, "[%s] Adjusted left from %"PRId32" to %"PRId32, order, *pLeft, left);
if (*pTop != top)
WLog_Print(log, WLOG_WARN, "[%s] Adjusted top from %"PRId32" to %"PRId32, order, *pTop, top);
if (*pWidth != width)
WLog_Print(log, WLOG_WARN, "[%s] Adjusted width from %"PRId32" to %"PRId32, order, *pWidth, width);
if (*pHeight != height)
WLog_Print(log, WLOG_WARN, "[%s] Adjusted height from %"PRId32" to %"PRId32, order, *pHeight,
height);
*pLeft = left;
*pTop = top;
*pWidth = width;
*pHeight = height;
return TRUE;
}
static BOOL freerdp_adjust_point(wLog* log, const char* order, rdpContext* context, INT32* pX,
INT32* pY)
{
UINT32 dw, dh;
INT32 x = *pX;
INT32 y = *pY;
if (!context || !context->settings)
return FALSE;
dw = context->settings->DesktopWidth;
dh = context->settings->DesktopHeight;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
if (x > dw)
x = dw;
if (y > dh)
y = dh;
if (x != *pX)
WLog_Print(log, WLOG_WARN, "[%s] adjusted x from %"PRId32" to %"PRId32, order, *pX, x);
if (y != *pY)
WLog_Print(log, WLOG_WARN, "[%s] adjusted y from %"PRId32" to %"PRId32, order, *pY, y);
*pX = x;
*pY = y;
return TRUE;
}
static BOOL adjust_point(rdpContext* context, INT32* px, INT32* py)
{
INT32 x, y;
UINT32 dw, dh;
if (!context || !context->settings || !px || !py)
return FALSE;
x = *px;
y = *py;
dw = context->settings->DesktopWidth;
dh = context->settings->DesktopHeight;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
if (x > dw)
x = dw;
if (y > dh)
y = dh;
*px = x;
*py = y;
return TRUE;;
}
static BOOL freerdp_adjust_delta_rect(wLog* log, const char* order, rdpContext* context,
UINT32 count, DELTA_RECT* data)
{
UINT32 i;
if (!context || !data)
goto fail;
if (count > 45)
goto fail;
for (i = 0; i < count; i++)
{
DELTA_RECT* delta = &data[i];
if (!freerdp_primary_adjust_rect(log, order, context, &delta->left, &delta->top, &delta->width,
&delta->height))
goto fail;
}
return TRUE;
fail:
WLog_ERR(TAG, "invalid delta rectangles");
return FALSE;
}
static BOOL freerdp_check_glyph_op_bound(wLog* log, const char* order, rdpContext* context,
INT32 left, INT32 top, INT32 right,
INT32 bottom)
{
if (right == -32768)
right = left;
if (bottom == -32768)
bottom = top;
return freerdp_primary_adjust_bound(log, order, context, &left, &top, &right, &bottom);
}
static INLINE BOOL update_read_coord(wStream* s, INT32* coord, BOOL delta)
{
INT8 lsi8;
@ -3616,9 +3383,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
}
}
if (!freerdp_primary_adjust_bounds(update->log, orderName, context, &orderInfo->bounds))
return FALSE;
rc = IFCALLRESULT(FALSE, update->SetBounds, context, &orderInfo->bounds);
if (!rc)
@ -3638,14 +3402,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
"Primary Drawing Order %s rop=%s [0x%08"PRIx32"]",
orderName,
gdi_rop3_code_string(primary->dstblt.bRop), gdi_rop3_code(primary->dstblt.bRop));
if (!freerdp_primary_adjust_rect(update->log, orderName, context,
&primary->dstblt.nLeftRect,
&primary->dstblt.nTopRect,
&primary->dstblt.nWidth,
&primary->dstblt.nHeight))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->DstBlt, context, &primary->dstblt);
}
break;
@ -3655,14 +3411,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
WLog_Print(update->log, WLOG_DEBUG,
"Primary Drawing Order %s rop=%s [0x%08"PRIx32"]", orderName,
gdi_rop3_code_string(primary->patblt.bRop), gdi_rop3_code(primary->patblt.bRop));
if (!freerdp_primary_adjust_rect(update->log, orderName, context,
&primary->patblt.nLeftRect,
&primary->patblt.nTopRect,
&primary->patblt.nWidth,
&primary->patblt.nHeight))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->PatBlt, context, &primary->patblt);
}
break;
@ -3672,14 +3420,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
WLog_Print(update->log, WLOG_DEBUG,
"Primary Drawing Order %s rop=%s [0x%08"PRIx32"]", orderName,
gdi_rop3_code_string(primary->scrblt.bRop), gdi_rop3_code(primary->scrblt.bRop));
if (!freerdp_primary_adjust_rect(update->log, orderName, context,
&primary->scrblt.nLeftRect,
&primary->scrblt.nTopRect,
&primary->scrblt.nWidth,
&primary->scrblt.nHeight))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->ScrBlt, context, &primary->scrblt);
}
break;
@ -3687,13 +3427,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
case ORDER_TYPE_OPAQUE_RECT:
{
WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName);
if (!freerdp_primary_adjust_rect(update->log, orderName, context, &primary->opaque_rect.nLeftRect,
&primary->opaque_rect.nTopRect,
&primary->opaque_rect.nWidth,
&primary->opaque_rect.nHeight))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->OpaqueRect, context, &primary->opaque_rect);
}
break;
@ -3701,12 +3434,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
case ORDER_TYPE_DRAW_NINE_GRID:
{
WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName);
if (!freerdp_primary_adjust_bound(update->log, orderName, context, &primary->draw_nine_grid.srcLeft,
&primary->draw_nine_grid.srcTop, &primary->draw_nine_grid.srcRight,
&primary->draw_nine_grid.srcBottom))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->DrawNineGrid, context, &primary->draw_nine_grid);
}
break;
@ -3716,18 +3443,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
WLog_Print(update->log, WLOG_DEBUG,
"Primary Drawing Order %s rop=%s [0x%08"PRIx32"]", orderName,
gdi_rop3_code_string(primary->multi_dstblt.bRop), gdi_rop3_code(primary->multi_dstblt.bRop));
if (!freerdp_primary_adjust_rect(update->log, orderName, context,
&primary->multi_dstblt.nLeftRect,
&primary->multi_dstblt.nTopRect,
&primary->multi_dstblt.nWidth,
&primary->multi_dstblt.nHeight))
return FALSE;
if (!freerdp_adjust_delta_rect(update->log, orderName, context, primary->multi_dstblt.numRectangles,
primary->multi_dstblt.rectangles))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->MultiDstBlt, context, &primary->multi_dstblt);
}
break;
@ -3737,18 +3452,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
WLog_Print(update->log, WLOG_DEBUG,
"Primary Drawing Order %s rop=%s [0x%08"PRIx32"]", orderName,
gdi_rop3_code_string(primary->multi_patblt.bRop), gdi_rop3_code(primary->multi_patblt.bRop));
if (!freerdp_primary_adjust_rect(update->log, orderName, context,
&primary->multi_patblt.nLeftRect,
&primary->multi_patblt.nTopRect,
&primary->multi_patblt.nWidth,
&primary->multi_patblt.nHeight))
return FALSE;
if (!freerdp_adjust_delta_rect(update->log, orderName, context, primary->multi_patblt.numRectangles,
primary->multi_patblt.rectangles))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->MultiPatBlt, context, &primary->multi_patblt);
}
break;
@ -3758,18 +3461,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
WLog_Print(update->log, WLOG_DEBUG,
"Primary Drawing Order %s rop=%s [0x%08"PRIx32"]", orderName,
gdi_rop3_code_string(primary->multi_scrblt.bRop), gdi_rop3_code(primary->multi_scrblt.bRop));
if (!freerdp_primary_adjust_rect(update->log, orderName, context,
&primary->multi_scrblt.nLeftRect,
&primary->multi_scrblt.nTopRect,
&primary->multi_scrblt.nWidth,
&primary->multi_scrblt.nHeight))
return FALSE;
if (!freerdp_adjust_delta_rect(update->log, orderName, context, primary->multi_scrblt.numRectangles,
primary->multi_scrblt.rectangles))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->MultiScrBlt, context, &primary->multi_scrblt);
}
break;
@ -3777,19 +3468,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
case ORDER_TYPE_MULTI_OPAQUE_RECT:
{
WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName);
if (!freerdp_primary_adjust_rect(update->log, orderName, context,
&primary->multi_opaque_rect.nLeftRect,
&primary->multi_opaque_rect.nTopRect,
&primary->multi_opaque_rect.nWidth,
&primary->multi_opaque_rect.nHeight))
return FALSE;
if (!freerdp_adjust_delta_rect(update->log, orderName, context,
primary->multi_opaque_rect.numRectangles,
primary->multi_opaque_rect.rectangles))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->MultiOpaqueRect, context, &primary->multi_opaque_rect);
}
break;
@ -3797,19 +3475,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
case ORDER_TYPE_MULTI_DRAW_NINE_GRID:
{
WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName);
if (!freerdp_primary_adjust_bound(update->log, orderName, context,
&primary->multi_draw_nine_grid.srcLeft,
&primary->multi_draw_nine_grid.srcTop,
&primary->multi_draw_nine_grid.srcRight,
&primary->multi_draw_nine_grid.srcBottom))
return FALSE;
if (!freerdp_adjust_delta_rect(update->log, orderName, context,
primary->multi_draw_nine_grid.nDeltaEntries,
primary->multi_draw_nine_grid.rectangles))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->MultiDrawNineGrid, context, &primary->multi_draw_nine_grid);
}
break;
@ -3833,18 +3498,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
WLog_Print(update->log, WLOG_DEBUG,
"Primary Drawing Order %s rop=%s [0x%08"PRIx32"]", orderName,
gdi_rop3_code_string(primary->memblt.bRop), gdi_rop3_code(primary->memblt.bRop));
if (!freerdp_primary_adjust_rect(update->log, orderName, context,
&primary->memblt.nLeftRect,
&primary->memblt.nTopRect,
&primary->memblt.nWidth,
&primary->memblt.nHeight))
return FALSE;
if (!freerdp_adjust_point(update->log, orderName, context, &primary->memblt.nXSrc,
&primary->memblt.nYSrc))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->MemBlt, context, &primary->memblt);
}
break;
@ -3854,18 +3507,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
WLog_Print(update->log, WLOG_DEBUG,
"Primary Drawing Order %s rop=%s [0x%08"PRIx32"]", orderName,
gdi_rop3_code_string(primary->mem3blt.bRop), gdi_rop3_code(primary->mem3blt.bRop));
if (!freerdp_primary_adjust_rect(update->log, orderName, context,
&primary->mem3blt.nLeftRect,
&primary->mem3blt.nTopRect,
&primary->mem3blt.nWidth,
&primary->mem3blt.nHeight))
return FALSE;
if (!freerdp_adjust_point(update->log, orderName, context, &primary->mem3blt.nXSrc,
&primary->mem3blt.nYSrc))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->Mem3Blt, context, &primary->mem3blt);
}
break;
@ -3873,12 +3514,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
case ORDER_TYPE_SAVE_BITMAP:
{
WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName);
if (!freerdp_primary_adjust_bound(update->log, orderName, context, &primary->save_bitmap.nLeftRect,
&primary->save_bitmap.nTopRect, &primary->save_bitmap.nRightRect,
&primary->save_bitmap.nBottomRect))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->SaveBitmap, context, &primary->save_bitmap);
}
break;
@ -3886,21 +3521,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
case ORDER_TYPE_GLYPH_INDEX:
{
WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName);
if (!freerdp_primary_adjust_bound(update->log, orderName, context, &primary->glyph_index.bkLeft,
&primary->glyph_index.bkTop,
&primary->glyph_index.bkRight, &primary->fast_index.bkBottom))
return FALSE;
if (!freerdp_primary_adjust_bound(update->log, orderName, context, &primary->glyph_index.opLeft,
&primary->glyph_index.opTop,
&primary->glyph_index.opRight, &primary->fast_index.opBottom))
return FALSE;
if (!freerdp_adjust_point(update->log, orderName, context, &primary->glyph_index.x,
&primary->glyph_index.y))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->GlyphIndex, context, &primary->glyph_index);
}
break;
@ -3908,22 +3528,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
case ORDER_TYPE_FAST_INDEX:
{
WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName);
if (!freerdp_primary_adjust_bound(update->log, orderName, context,
&primary->fast_index.bkLeft,
&primary->fast_index.bkTop,
&primary->fast_index.bkRight, &primary->fast_index.bkBottom))
return FALSE;
if (!freerdp_check_glyph_op_bound(update->log, orderName, context, primary->fast_index.opLeft,
primary->fast_index.opTop,
primary->fast_index.opRight, primary->fast_index.opBottom))
return FALSE;
if (!freerdp_adjust_point(update->log, orderName, context, &primary->fast_index.x,
&primary->fast_index.y))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->FastIndex, context, &primary->fast_index);
}
break;
@ -3931,20 +3535,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
case ORDER_TYPE_FAST_GLYPH:
{
WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName);
if (!freerdp_primary_adjust_bound(update->log, orderName, context, &primary->fast_glyph.bkLeft,
&primary->fast_glyph.bkTop,
&primary->fast_glyph.bkRight, &primary->fast_index.bkBottom))
return FALSE;
if (!freerdp_check_glyph_op_bound(update->log, orderName, context, primary->fast_glyph.opLeft,
primary->fast_glyph.opTop,
primary->fast_glyph.opRight, primary->fast_index.opBottom))
return FALSE;
if (!adjust_point(context, &primary->fast_glyph.x, &primary->fast_glyph.y))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->FastGlyph, context, &primary->fast_glyph);
}
break;
@ -3966,12 +3556,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
case ORDER_TYPE_ELLIPSE_SC:
{
WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName);
if (!freerdp_primary_adjust_bound(update->log, orderName, context, &primary->ellipse_sc.leftRect,
&primary->ellipse_sc.topRect,
&primary->ellipse_sc.rightRect, &primary->ellipse_sc.bottomRect))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->EllipseSC, context, &primary->ellipse_sc);
}
break;
@ -3979,12 +3563,6 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags)
case ORDER_TYPE_ELLIPSE_CB:
{
WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName);
if (!freerdp_primary_adjust_bound(update->log, orderName, context, &primary->ellipse_cb.leftRect,
&primary->ellipse_cb.topRect,
&primary->ellipse_cb.rightRect, &primary->ellipse_cb.bottomRect))
return FALSE;
rc = IFCALLRESULT(FALSE, primary->EllipseCB, context, &primary->ellipse_cb);
}
break;

View File

@ -273,8 +273,8 @@ static UINT32 process_rop(UINT32 src, UINT32 dst, UINT32 pat, const char* rop,
return stack[0];
}
static INLINE BOOL BitBlt_write(HGDI_DC hdcDest, HGDI_DC hdcSrc, UINT32 nXDest,
UINT32 nYDest, UINT32 nXSrc, UINT32 nYSrc, UINT32 x, UINT32 y,
static INLINE BOOL BitBlt_write(HGDI_DC hdcDest, HGDI_DC hdcSrc, INT32 nXDest,
INT32 nYDest, INT32 nXSrc, INT32 nYSrc, INT32 x, INT32 y,
BOOL useSrc, BOOL usePat, UINT32 style,
const char* rop, const gdiPalette* palette)
{
@ -282,7 +282,9 @@ static INLINE BOOL BitBlt_write(HGDI_DC hdcDest, HGDI_DC hdcSrc, UINT32 nXDest,
UINT32 colorA;
UINT32 colorB = 0;
UINT32 colorC = 0;
BYTE* dstp = gdi_get_bitmap_pointer(hdcDest, nXDest + x, nYDest + y);
const INT32 dstX = nXDest + x;
const INT32 dstY = nYDest + y;
BYTE* dstp = gdi_get_bitmap_pointer(hdcDest, dstX, dstY);
if (!dstp)
{
@ -338,11 +340,116 @@ static INLINE BOOL BitBlt_write(HGDI_DC hdcDest, HGDI_DC hdcSrc, UINT32 nXDest,
return WriteColor(dstp, hdcDest->format, dstColor);
}
static BOOL BitBlt_process(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc, const char* rop, const gdiPalette* palette)
static BOOL adjust_src_coordinates(HGDI_DC hdcSrc, INT32 nWidth, INT32 nHeight,
INT32* px, INT32* py)
{
INT64 x, y;
HGDI_BITMAP hSrcBmp;
INT32 nXSrc, nYSrc;
if (!hdcSrc || (nWidth < 0) || (nHeight < 0) || !px || !py)
return FALSE;
hSrcBmp = (HGDI_BITMAP) hdcSrc->selectedObject;
nXSrc = *px;
nYSrc = *py;
if (!hSrcBmp)
return FALSE;
if (nYSrc < 0)
{
nYSrc = 0;
nHeight = nHeight + nYSrc;
}
if ((nXSrc) < 0)
{
nXSrc = 0;
nWidth = nWidth + nXSrc;
}
if (hSrcBmp->width < (nXSrc + nWidth))
nXSrc = hSrcBmp->width - nWidth;
if (hSrcBmp->height < (nYSrc + nHeight))
nYSrc = hSrcBmp->height - nHeight;
if ((nXSrc < 0) || (nYSrc < 0))
return FALSE;
*px = nXSrc;
*py = nYSrc;
return TRUE;
}
static BOOL adjust_src_dst_coordinates(HGDI_DC hdcDest, INT32* pnXSrc, INT32* pnYSrc,
INT32* pnXDst, INT32* pnYDst, INT32* pnWidth, INT32* pnHeight)
{
HGDI_BITMAP hDstBmp;
volatile INT32 diffX, diffY;
volatile INT32 nXSrc, nYSrc;
volatile INT32 nXDst, nYDst, nWidth, nHeight;
if (!hdcDest || !pnXSrc || !pnYSrc || !pnXDst || !pnYDst || !pnWidth || !pnHeight)
return FALSE;
hDstBmp = (HGDI_BITMAP) hdcDest->selectedObject;
nXSrc = *pnXSrc;
nYSrc = *pnYSrc;
nXDst = *pnXDst;
nYDst = *pnYDst;
nWidth = *pnWidth;
nHeight = *pnHeight;
if (!hDstBmp)
return FALSE;
if (nXDst < 0)
{
nXSrc -= nXDst;
nWidth += nXDst;
nXDst = 0;
}
if (nYDst < 0)
{
nYSrc -= nYDst;
nHeight += nYDst;
nYDst = 0;
}
diffX = hDstBmp->width - nXDst - nWidth;
if (diffX < 0)
nWidth += diffX;
diffY = hDstBmp->height - nYDst - nHeight;
if (diffY < 0)
nHeight += diffY;
if ((nXDst < 0) || (nYDst < 0) || (nWidth < 0) || (nHeight < 0))
{
nXDst = 0;
nYDst = 0;
nWidth = 0;
nHeight = 0;
}
*pnXSrc = nXSrc;
*pnYSrc = nYSrc;
*pnXDst = nXDst;
*pnYDst = nYDst;
*pnWidth = nWidth;
*pnHeight = nHeight;
return TRUE;
}
static BOOL BitBlt_process(HGDI_DC hdcDest, INT32 nXDest, INT32 nYDest,
INT32 nWidth, INT32 nHeight, HGDI_DC hdcSrc,
INT32 nXSrc, INT32 nYSrc, const char* rop, const gdiPalette* palette)
{
INT32 x, y;
UINT32 style = 0;
BOOL useSrc = FALSE;
BOOL usePat = FALSE;
@ -368,9 +475,18 @@ static BOOL BitBlt_process(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
if (!hdcDest)
return FALSE;
if (!adjust_src_dst_coordinates(hdcDest, &nXSrc, &nYSrc, &nXDest, &nYDest, &nWidth, &nHeight))
return FALSE;
if (useSrc && !hdcSrc)
return FALSE;
if (useSrc)
{
if (!adjust_src_coordinates(hdcSrc, nWidth, nHeight, &nXSrc, &nYSrc))
return FALSE;
}
if (usePat)
{
style = gdi_GetBrushStyle(hdcDest);
@ -390,9 +506,9 @@ static BOOL BitBlt_process(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
if ((nXDest > nXSrc) && (nYDest > nYSrc))
{
for (y = (INT64)nHeight - 1; y >= 0; y--)
for (y = nHeight - 1; y >= 0; y--)
{
for (x = (INT64)nWidth - 1; x >= 0; x--)
for (x = nWidth - 1; x >= 0; x--)
{
if (!BitBlt_write(hdcDest, hdcSrc, nXDest, nYDest,
nXSrc, nYSrc, x, y, useSrc,
@ -405,7 +521,7 @@ static BOOL BitBlt_process(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
{
for (y = 0; y < nHeight; y++)
{
for (x = (INT64)nWidth - 1; x >= 0; x--)
for (x = nWidth - 1; x >= 0; x--)
{
if (!BitBlt_write(hdcDest, hdcSrc, nXDest, nYDest,
nXSrc, nYSrc, x, y, useSrc,
@ -416,7 +532,7 @@ static BOOL BitBlt_process(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
}
else if (nYDest > nYSrc)
{
for (y = (INT64)nHeight - 1; y >= 0; y--)
for (y = nHeight - 1; y >= 0; y--)
{
for (x = 0; x < nWidth; x++)
{
@ -458,9 +574,9 @@ static BOOL BitBlt_process(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
* @param rop raster operation code
* @return 0 on failure, non-zero otherwise
*/
BOOL gdi_BitBlt(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc, DWORD rop, const gdiPalette* palette)
BOOL gdi_BitBlt(HGDI_DC hdcDest, INT32 nXDest, INT32 nYDest,
INT32 nWidth, INT32 nHeight, HGDI_DC hdcSrc,
INT32 nXSrc, INT32 nYSrc, DWORD rop, const gdiPalette* palette)
{
HGDI_BITMAP hSrcBmp, hDstBmp;
@ -483,6 +599,12 @@ BOOL gdi_BitBlt(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
if (!hdcSrc)
return FALSE;
if (!adjust_src_dst_coordinates(hdcDest, &nXSrc, &nYSrc, &nXDest, &nYDest, &nWidth, &nHeight))
return FALSE;
if (!adjust_src_coordinates(hdcSrc, nWidth, nHeight, &nXSrc, &nYSrc))
return FALSE;
hSrcBmp = (HGDI_BITMAP) hdcSrc->selectedObject;
hDstBmp = (HGDI_BITMAP) hdcDest->selectedObject;
@ -500,6 +622,12 @@ BOOL gdi_BitBlt(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
hSrcBmp = (HGDI_BITMAP) hdcDest->selectedObject;
hDstBmp = (HGDI_BITMAP) hdcDest->selectedObject;
if (!adjust_src_dst_coordinates(hdcDest, &nXSrc, &nYSrc, &nXDest, &nYDest, &nWidth, &nHeight))
return FALSE;
if (!adjust_src_coordinates(hdcDest, nWidth, nHeight, &nXSrc, &nYSrc))
return FALSE;
if (!hSrcBmp || !hDstBmp)
return FALSE;

View File

@ -34,8 +34,8 @@
#include "clipping.h"
BOOL gdi_SetClipRgn(HGDI_DC hdc, UINT32 nXLeft, UINT32 nYLeft, UINT32 nWidth,
UINT32 nHeight)
BOOL gdi_SetClipRgn(HGDI_DC hdc, INT32 nXLeft, INT32 nYLeft, INT32 nWidth,
INT32 nHeight)
{
return gdi_SetRgn(hdc->clip, nXLeft, nYLeft, nWidth, nHeight);
}
@ -77,8 +77,8 @@ BOOL gdi_SetNullClipRgn(HGDI_DC hdc)
* @return nonzero if there is something to draw, 0 otherwise
*/
BOOL gdi_ClipCoords(HGDI_DC hdc, UINT32* x, UINT32* y, UINT32* w, UINT32* h,
UINT32* srcx, UINT32* srcy)
BOOL gdi_ClipCoords(HGDI_DC hdc, INT32* x, INT32* y, INT32* w, INT32* h,
INT32* srcx, INT32* srcy)
{
GDI_RECT bmp;
GDI_RECT clip;

View File

@ -29,12 +29,12 @@
extern "C" {
#endif
FREERDP_LOCAL BOOL gdi_SetClipRgn(HGDI_DC hdc, UINT32 nXLeft, UINT32 nYLeft,
UINT32 nWidth, UINT32 nHeight);
FREERDP_LOCAL BOOL gdi_SetClipRgn(HGDI_DC hdc, INT32 nXLeft, INT32 nYLeft,
INT32 nWidth, INT32 nHeight);
FREERDP_LOCAL HGDI_RGN gdi_GetClipRgn(HGDI_DC hdc);
FREERDP_LOCAL BOOL gdi_SetNullClipRgn(HGDI_DC hdc);
FREERDP_LOCAL BOOL gdi_ClipCoords(HGDI_DC hdc, UINT32* x, UINT32* y,
UINT32* w, UINT32* h, UINT32* srcx, UINT32* srcy);
FREERDP_LOCAL BOOL gdi_ClipCoords(HGDI_DC hdc, INT32* x, INT32* y,
INT32* w, INT32* h, INT32* srcx, INT32* srcy);
#ifdef __cplusplus
}

View File

@ -42,7 +42,7 @@
* @return draw mode
*/
UINT32 gdi_GetROP2(HGDI_DC hdc)
INT32 gdi_GetROP2(HGDI_DC hdc)
{
return hdc->drawMode;
}
@ -55,9 +55,9 @@ UINT32 gdi_GetROP2(HGDI_DC hdc)
* @return previous draw mode
*/
UINT32 gdi_SetROP2(HGDI_DC hdc, int fnDrawMode)
INT32 gdi_SetROP2(HGDI_DC hdc, INT32 fnDrawMode)
{
UINT32 prevDrawMode = hdc->drawMode;
INT32 prevDrawMode = hdc->drawMode;
if (fnDrawMode > 0 && fnDrawMode <= 16)
hdc->drawMode = fnDrawMode;
@ -113,11 +113,11 @@ UINT32 gdi_GetBkMode(HGDI_DC hdc)
*/
BOOL gdi_SetBkMode(HGDI_DC hdc, int iBkMode)
INT32 gdi_SetBkMode(HGDI_DC hdc, INT32 iBkMode)
{
if (iBkMode == GDI_OPAQUE || iBkMode == GDI_TRANSPARENT)
{
int previousBkMode = hdc->bkMode;
INT32 previousBkMode = hdc->bkMode;
hdc->bkMode = iBkMode;
return previousBkMode;
}

View File

@ -29,12 +29,12 @@
extern "C" {
#endif
FREERDP_LOCAL UINT32 gdi_GetROP2(HGDI_DC hdc);
FREERDP_LOCAL UINT32 gdi_SetROP2(HGDI_DC hdc, int fnDrawMode);
FREERDP_LOCAL INT32 gdi_GetROP2(HGDI_DC hdc);
FREERDP_LOCAL INT32 gdi_SetROP2(HGDI_DC hdc, INT32 fnDrawMode);
FREERDP_LOCAL UINT32 gdi_GetBkColor(HGDI_DC hdc);
FREERDP_LOCAL UINT32 gdi_SetBkColor(HGDI_DC hdc, UINT32 crColor);
FREERDP_LOCAL UINT32 gdi_GetBkMode(HGDI_DC hdc);
FREERDP_LOCAL BOOL gdi_SetBkMode(HGDI_DC hdc, int iBkMode);
FREERDP_LOCAL INT32 gdi_SetBkMode(HGDI_DC hdc, INT32 iBkMode);
FREERDP_LOCAL UINT32 gdi_SetTextColor(HGDI_DC hdc, UINT32 crColor);
#ifdef __cplusplus

View File

@ -584,8 +584,8 @@ static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
rdpGdi* gdi = context->gdi;
BOOL ret = FALSE;
const DWORD rop = gdi_rop3_code(patblt->bRop);
UINT32 nXSrc = 0;
UINT32 nYSrc = 0;
INT32 nXSrc = 0;
INT32 nYSrc = 0;
BYTE data[8 * 8 * 4];
HGDI_BITMAP hBmp = NULL;
@ -703,8 +703,12 @@ static BOOL gdi_opaque_rect(rdpContext* context,
UINT32 brush_color;
rdpGdi* gdi = context->gdi;
BOOL ret;
gdi_CRgnToRect(opaque_rect->nLeftRect, opaque_rect->nTopRect,
opaque_rect->nWidth, opaque_rect->nHeight, &rect);
INT32 x = opaque_rect->nLeftRect;
INT32 y = opaque_rect->nTopRect;
INT32 w = opaque_rect->nWidth;
INT32 h = opaque_rect->nHeight;
gdi_ClipCoords(gdi->drawing->hdc, &x, &y, &w, &h, NULL, NULL);
gdi_CRgnToRect(x, y, w, h, &rect);
if (!gdi_decode_color(gdi, opaque_rect->color, &brush_color, NULL))
return FALSE;
@ -738,8 +742,12 @@ static BOOL gdi_multi_opaque_rect(rdpContext* context,
for (i = 0; i < multi_opaque_rect->numRectangles; i++)
{
const DELTA_RECT* rectangle = &multi_opaque_rect->rectangles[i];
gdi_CRgnToRect(rectangle->left, rectangle->top,
rectangle->width, rectangle->height, &rect);
INT32 x = rectangle->left;
INT32 y = rectangle->top;
INT32 w = rectangle->width;
INT32 h = rectangle->height;
gdi_ClipCoords(gdi->drawing->hdc, &x, &y, &w, &h, NULL, NULL);
gdi_CRgnToRect(x, y, w, h, &rect);
ret = gdi_FillRect(gdi->drawing->hdc, &rect, hBrush);
if (!ret)
@ -755,6 +763,14 @@ static BOOL gdi_line_to(rdpContext* context, const LINE_TO_ORDER* lineTo)
UINT32 color;
HGDI_PEN hPen;
rdpGdi* gdi = context->gdi;
INT32 xStart = lineTo->nXStart;
INT32 yStart = lineTo->nYStart;
INT32 xEnd = lineTo->nXEnd;
INT32 yEnd = lineTo->nYEnd;
INT32 w = 0;
INT32 h = 0;
gdi_ClipCoords(gdi->drawing->hdc, &xStart, &yStart, &w, &h, NULL, NULL);
gdi_ClipCoords(gdi->drawing->hdc, &xEnd, &yEnd, &w, &h, NULL, NULL);
if (!gdi_decode_color(gdi, lineTo->penColor, &color, NULL))
return FALSE;
@ -780,6 +796,7 @@ static BOOL gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
HGDI_PEN hPen;
DELTA_POINT* points;
rdpGdi* gdi = context->gdi;
INT32 w = 0, h = 0;
if (!gdi_decode_color(gdi, polyline->penColor, &color, NULL))
return FALSE;
@ -792,6 +809,7 @@ static BOOL gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
gdi_SetROP2(gdi->drawing->hdc, polyline->bRop2);
x = polyline->xStart;
y = polyline->yStart;
gdi_ClipCoords(gdi->drawing->hdc, &x, &y, &w, &h, NULL, NULL);
gdi_MoveToEx(gdi->drawing->hdc, x, y, NULL);
points = polyline->points;
@ -799,6 +817,7 @@ static BOOL gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
{
x += points[i].x;
y += points[i].y;
gdi_ClipCoords(gdi->drawing->hdc, &x, &y, &w, &h, NULL, NULL);
gdi_LineTo(gdi->drawing->hdc, x, y);
gdi_MoveToEx(gdi->drawing->hdc, x, y, NULL);
}

View File

@ -33,12 +33,12 @@ FREERDP_LOCAL gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height,
BYTE* data);
FREERDP_LOCAL void gdi_bitmap_free_ex(gdiBitmap* gdi_bmp);
static INLINE BYTE* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, UINT32 x, UINT32 y)
static INLINE BYTE* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, INT32 x, INT32 y)
{
BYTE* p;
HGDI_BITMAP hBmp = (HGDI_BITMAP) hdcBmp->selectedObject;
if (x < hBmp->width && y < hBmp->height)
if ((x >= 0) && (y >= 0) && (x < hBmp->width) && (y < hBmp->height))
{
p = hBmp->data + (y * hBmp->scanline) + (x * GetBytesPerPixel(hdcBmp->format));
return p;

View File

@ -271,8 +271,8 @@ static void gdi_Glyph_Free(rdpContext* context, rdpGlyph* glyph)
}
}
static BOOL gdi_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, UINT32 x,
UINT32 y, UINT32 w, UINT32 h, UINT32 sx, UINT32 sy, BOOL fOpRedundant)
static BOOL gdi_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, INT32 x,
INT32 y, INT32 w, INT32 h, INT32 sx, INT32 sy, BOOL fOpRedundant)
{
gdiGlyph* gdi_glyph;
rdpGdi* gdi;
@ -325,8 +325,23 @@ static BOOL gdi_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, UINT32 x,
return rc;
}
static BOOL gdi_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y,
UINT32 width, UINT32 height, UINT32 bgcolor,
static BOOL gdi_Glyph_SetBounds(rdpContext* context, INT32 x, INT32 y, INT32 width, INT32 height)
{
rdpGdi* gdi;
if (!context || !context->gdi)
return FALSE;
gdi = context->gdi;
if (!gdi->drawing || !gdi->drawing->hdc)
return FALSE;
return gdi_SetClipRgn(gdi->drawing->hdc, x, y, width, height);
}
static BOOL gdi_Glyph_BeginDraw(rdpContext* context, INT32 x, INT32 y,
INT32 width, INT32 height, UINT32 bgcolor,
UINT32 fgcolor, BOOL fOpRedundant)
{
rdpGdi* gdi;
@ -339,43 +354,49 @@ static BOOL gdi_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y,
if (!gdi->drawing || !gdi->drawing->hdc)
return FALSE;
if (!gdi_decode_color(gdi, bgcolor, &bgcolor, NULL))
return FALSE;
if (!gdi_decode_color(gdi, fgcolor, &fgcolor, NULL))
return FALSE;
gdi_SetTextColor(gdi->drawing->hdc, bgcolor);
gdi_SetBkColor(gdi->drawing->hdc, fgcolor);
if (1)
if (!fOpRedundant)
{
GDI_RECT rect = { 0 };
HGDI_BRUSH brush = gdi_CreateSolidBrush(fgcolor);
if (!brush)
if (!gdi_decode_color(gdi, bgcolor, &bgcolor, NULL))
return FALSE;
if (x > 0)
rect.left = x;
if (!gdi_decode_color(gdi, fgcolor, &fgcolor, NULL))
return FALSE;
if (y > 0)
rect.top = y;
gdi_SetClipRgn(gdi->drawing->hdc, x, y, width, height);
gdi_SetTextColor(gdi->drawing->hdc, bgcolor);
gdi_SetBkColor(gdi->drawing->hdc, fgcolor);
rect.right = x + width - 1;
rect.bottom = y + height - 1;
if (1)
{
GDI_RECT rect = { 0 };
HGDI_BRUSH brush = gdi_CreateSolidBrush(fgcolor);
if ((x + width > rect.left) && (y + height > rect.top))
gdi_FillRect(gdi->drawing->hdc, &rect, brush);
if (!brush)
return FALSE;
gdi_DeleteObject((HGDIOBJECT)brush);
if (x > 0)
rect.left = x;
if (y > 0)
rect.top = y;
rect.right = x + width - 1;
rect.bottom = y + height - 1;
if ((x + width > rect.left) && (y + height > rect.top))
gdi_FillRect(gdi->drawing->hdc, &rect, brush);
gdi_DeleteObject((HGDIOBJECT)brush);
}
return gdi_SetNullClipRgn(gdi->drawing->hdc);
}
return gdi_SetClipRgn(gdi->drawing->hdc, x, y, width, height);
return TRUE;
}
static BOOL gdi_Glyph_EndDraw(rdpContext* context, UINT32 x, UINT32 y,
UINT32 width, UINT32 height, UINT32 bgcolor, UINT32 fgcolor)
static BOOL gdi_Glyph_EndDraw(rdpContext* context, INT32 x, INT32 y,
INT32 width, INT32 height, UINT32 bgcolor, UINT32 fgcolor)
{
rdpGdi* gdi;
@ -409,6 +430,7 @@ BOOL gdi_register_graphics(rdpGraphics* graphics)
glyph.Draw = gdi_Glyph_Draw;
glyph.BeginDraw = gdi_Glyph_BeginDraw;
glyph.EndDraw = gdi_Glyph_EndDraw;
glyph.SetBounds = gdi_Glyph_SetBounds;
graphics_register_glyph(graphics, &glyph);
return TRUE;
}

View File

@ -135,7 +135,7 @@ BOOL gdi_LineTo(HGDI_DC hdc, UINT32 nXEnd, UINT32 nYEnd)
INT32 bx2, by2;
HGDI_BITMAP bmp;
UINT32 pen;
UINT32 rop2 = gdi_GetROP2(hdc);
INT32 rop2 = gdi_GetROP2(hdc);
x1 = hdc->pen->posX;
y1 = hdc->pen->posY;
x2 = nXEnd;

View File

@ -47,8 +47,8 @@
* @return new region
*/
HGDI_RGN gdi_CreateRectRgn(UINT32 nLeftRect, UINT32 nTopRect,
UINT32 nRightRect, UINT32 nBottomRect)
HGDI_RGN gdi_CreateRectRgn(INT32 nLeftRect, INT32 nTopRect,
INT32 nRightRect, INT32 nBottomRect)
{
HGDI_RGN hRgn = (HGDI_RGN) calloc(1, sizeof(GDI_RGN));
@ -73,8 +73,8 @@ HGDI_RGN gdi_CreateRectRgn(UINT32 nLeftRect, UINT32 nTopRect,
* @return new rectangle
*/
HGDI_RECT gdi_CreateRect(UINT32 xLeft, UINT32 yTop,
UINT32 xRight, UINT32 yBottom)
HGDI_RECT gdi_CreateRect(INT32 xLeft, INT32 yTop,
INT32 xRight, INT32 yBottom)
{
HGDI_RECT hRect = (HGDI_RECT) calloc(1, sizeof(GDI_RECT));
@ -112,8 +112,8 @@ INLINE void gdi_RectToRgn(HGDI_RECT rect, HGDI_RGN rgn)
* @param rgn destination region
*/
INLINE void gdi_CRectToRgn(UINT32 left, UINT32 top,
UINT32 right, UINT32 bottom, HGDI_RGN rgn)
INLINE void gdi_CRectToRgn(INT32 left, INT32 top,
INT32 right, INT32 bottom, HGDI_RGN rgn)
{
rgn->x = left;
rgn->y = top;
@ -130,8 +130,9 @@ INLINE void gdi_CRectToRgn(UINT32 left, UINT32 top,
* @param h height
*/
INLINE void gdi_RectToCRgn(const HGDI_RECT rect, UINT32* x, UINT32* y,
UINT32* w, UINT32* h)
INLINE void gdi_RectToCRgn(const HGDI_RECT rect,
INT32* x, INT32* y,
INT32* w, INT32* h)
{
*x = rect->left;
*y = rect->top;
@ -151,9 +152,9 @@ INLINE void gdi_RectToCRgn(const HGDI_RECT rect, UINT32* x, UINT32* y,
* @param h height
*/
INLINE void gdi_CRectToCRgn(UINT32 left, UINT32 top, UINT32 right,
UINT32 bottom,
UINT32* x, UINT32* y, UINT32* w, UINT32* h)
INLINE void gdi_CRectToCRgn(INT32 left, INT32 top, INT32 right,
INT32 bottom,
INT32* x, INT32* y, INT32* w, INT32* h)
{
*x = left;
*y = top;
@ -184,7 +185,7 @@ INLINE void gdi_RgnToRect(HGDI_RGN rgn, HGDI_RECT rect)
* @param rect destination rectangle
*/
INLINE void gdi_CRgnToRect(INT64 x, INT64 y, UINT32 w, UINT32 h,
INLINE void gdi_CRgnToRect(INT64 x, INT64 y, INT32 w, INT32 h,
HGDI_RECT rect)
{
BOOL invalid = FALSE;
@ -221,8 +222,8 @@ INLINE void gdi_CRgnToRect(INT64 x, INT64 y, UINT32 w, UINT32 h,
* @param bottom y2
*/
INLINE void gdi_RgnToCRect(HGDI_RGN rgn, UINT32* left, UINT32* top,
UINT32* right, UINT32* bottom)
INLINE void gdi_RgnToCRect(HGDI_RGN rgn, INT32* left, INT32* top,
INT32* right, INT32* bottom)
{
*left = rgn->x;
*top = rgn->y;
@ -242,8 +243,8 @@ INLINE void gdi_RgnToCRect(HGDI_RGN rgn, UINT32* left, UINT32* top,
* @param bottom y2
*/
INLINE void gdi_CRgnToCRect(UINT32 x, UINT32 y, UINT32 w, UINT32 h,
UINT32* left, UINT32* top, UINT32* right, UINT32* bottom)
INLINE void gdi_CRgnToCRect(INT32 x, INT32 y, INT32 w, INT32 h,
INT32* left, INT32* top, INT32* right, INT32* bottom)
{
*left = x;
*top = y;
@ -273,8 +274,8 @@ INLINE void gdi_CRgnToCRect(UINT32 x, UINT32 y, UINT32 w, UINT32 h,
* @return nonzero if there is an overlap, 0 otherwise
*/
INLINE BOOL gdi_CopyOverlap(UINT32 x, UINT32 y, UINT32 width, UINT32 height,
UINT32 srcx, UINT32 srcy)
INLINE BOOL gdi_CopyOverlap(INT32 x, INT32 y, INT32 width, INT32 height,
INT32 srcx, INT32 srcy)
{
GDI_RECT dst;
GDI_RECT src;
@ -295,8 +296,8 @@ INLINE BOOL gdi_CopyOverlap(UINT32 x, UINT32 y, UINT32 width, UINT32 height,
* @return nonzero if successful, 0 otherwise
*/
INLINE BOOL gdi_SetRect(HGDI_RECT rc, UINT32 xLeft, UINT32 yTop,
UINT32 xRight, UINT32 yBottom)
INLINE BOOL gdi_SetRect(HGDI_RECT rc, INT32 xLeft, INT32 yTop,
INT32 xRight, INT32 yBottom)
{
rc->left = xLeft;
rc->top = yTop;
@ -315,8 +316,8 @@ INLINE BOOL gdi_SetRect(HGDI_RECT rc, UINT32 xLeft, UINT32 yTop,
* @return nonzero if successful, 0 otherwise
*/
INLINE BOOL gdi_SetRgn(HGDI_RGN hRgn, UINT32 nXLeft, UINT32 nYLeft,
UINT32 nWidth, UINT32 nHeight)
INLINE BOOL gdi_SetRgn(HGDI_RGN hRgn, INT32 nXLeft, INT32 nYLeft,
INT32 nWidth, INT32 nHeight)
{
hRgn->x = nXLeft;
hRgn->y = nYLeft;
@ -336,8 +337,8 @@ INLINE BOOL gdi_SetRgn(HGDI_RGN hRgn, UINT32 nXLeft, UINT32 nYLeft,
* @return nonzero if successful, 0 otherwise
*/
INLINE BOOL gdi_SetRectRgn(HGDI_RGN hRgn, UINT32 nLeftRect, UINT32 nTopRect,
UINT32 nRightRect, UINT32 nBottomRect)
INLINE BOOL gdi_SetRectRgn(HGDI_RGN hRgn, INT32 nLeftRect, INT32 nTopRect,
INT32 nRightRect, INT32 nBottomRect)
{
gdi_CRectToRgn(nLeftRect, nTopRect, nRightRect, nBottomRect, hRgn);
hRgn->null = FALSE;
@ -391,7 +392,7 @@ INLINE BOOL gdi_CopyRect(HGDI_RECT dst, HGDI_RECT src)
* @return nonzero if the point is inside, 0 otherwise
*/
INLINE BOOL gdi_PtInRect(HGDI_RECT rc, UINT32 x, UINT32 y)
INLINE BOOL gdi_PtInRect(HGDI_RECT rc, INT32 x, INT32 y)
{
/*
* points on the left and top sides are considered in,
@ -419,8 +420,8 @@ INLINE BOOL gdi_PtInRect(HGDI_RECT rc, UINT32 x, UINT32 y)
* @return nonzero on success, 0 otherwise
*/
INLINE BOOL gdi_InvalidateRegion(HGDI_DC hdc, UINT32 x, UINT32 y, UINT32 w,
UINT32 h)
INLINE BOOL gdi_InvalidateRegion(HGDI_DC hdc, INT32 x, INT32 y, INT32 w,
INT32 h)
{
GDI_RECT inv;
GDI_RECT rgn;

View File

@ -126,11 +126,11 @@ BOOL gdi_Ellipse(HGDI_DC hdc, int nLeftRect, int nTopRect, int nRightRect,
BOOL gdi_FillRect(HGDI_DC hdc, const HGDI_RECT rect, HGDI_BRUSH hbr)
{
UINT32 x, y;
INT32 x, y;
UINT32 color, dstColor;
BOOL monochrome = FALSE;
UINT32 nXDest, nYDest;
UINT32 nWidth, nHeight;
INT32 nXDest, nYDest;
INT32 nWidth, nHeight;
const BYTE* srcp;
DWORD formatSize;
gdi_RectToCRgn(rect, &nXDest, &nYDest, &nWidth, &nHeight);
@ -246,10 +246,10 @@ BOOL gdi_PolyPolygon(HGDI_DC hdc, GDI_POINT* lpPoints, int* lpPolyCounts,
return FALSE;
}
BOOL gdi_Rectangle(HGDI_DC hdc, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth,
UINT32 nHeight)
BOOL gdi_Rectangle(HGDI_DC hdc, INT32 nXDst, INT32 nYDst, INT32 nWidth,
INT32 nHeight)
{
UINT32 x, y;
INT32 x, y;
UINT32 color;
if (!gdi_ClipCoords(hdc, &nXDst, &nYDst, &nWidth, &nHeight, NULL, NULL))