From bc5aa1be0cf5ea3aebfacd9baf69a12acabebbda Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 3 Aug 2016 11:31:42 +0200 Subject: [PATCH] Added more GDI orders. --- include/freerdp/gdi/gdi.h | 3 + libfreerdp/gdi/bitmap.c | 222 ++++++++++++++++++++++++++++++++++++++ libfreerdp/gdi/brush.c | 12 +++ libfreerdp/gdi/graphics.h | 2 +- 4 files changed, 238 insertions(+), 1 deletion(-) diff --git a/include/freerdp/gdi/gdi.h b/include/freerdp/gdi/gdi.h index b028cfdbb..6d77a86fc 100644 --- a/include/freerdp/gdi/gdi.h +++ b/include/freerdp/gdi/gdi.h @@ -78,6 +78,9 @@ #define GDI_DSxn 0x00990066 /* D = ~(D ^ S) */ #define GDI_PSDnox 0x002D060A /* D = P ^ (S | ~D) */ +#define GDI_PSDPxox 0x002E064A +#define GDI_PSDPxoxn 0x00D1066A +#define GDI_PSDPaox 0x001C06CA #define GDI_PDSona 0x00100C85 /* D = P & ~(D | S) */ #define GDI_DSPDxox 0x00740646 /* D = D ^ (S | ( P ^ D)) */ #define GDI_DPSDonox 0x005B18A9 /* D = D ^ (P | ~(S | D)) */ diff --git a/libfreerdp/gdi/bitmap.c b/libfreerdp/gdi/bitmap.c index 63fd44941..a1b48e6ff 100644 --- a/libfreerdp/gdi/bitmap.c +++ b/libfreerdp/gdi/bitmap.c @@ -1061,6 +1061,216 @@ static BOOL BitBlt_DSPDxox(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, return TRUE; } +static BOOL BitBlt_PSDPxox(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, + UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc, + UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette) +{ + UINT32 x, y, colorC; + + if (!hdcDest || !hdcSrc) + return FALSE; + + switch (gdi_GetBrushStyle(hdcDest)) + { + case GDI_BS_SOLID: + colorC = hdcDest->brush->color; + + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + const BYTE* srcp = gdi_get_bitmap_pointer( + hdcSrc, nXSrc + x, nYSrc + y); + BYTE* dstp = gdi_get_bitmap_pointer( + hdcDest, nXDest + x, nYDest + y); + + if (srcp && dstp) + { + UINT32 color; + UINT32 colorA = ReadColor(srcp, hdcSrc->format); + UINT32 colorB = ReadColor(dstp, hdcDest->format); + colorA = ConvertColor(colorA, hdcSrc->format, + hdcDest->format, palette); + color = (colorA ^ colorC) | (colorB ^ colorC); + WriteColor(dstp, hdcDest->format, color); + } + } + } + + break; + + default: + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + const BYTE* srcp = gdi_get_bitmap_pointer( + hdcSrc, nXSrc + x, nYSrc + y); + const BYTE* patp = gdi_get_brush_pointer( + hdcDest, nXDest + x, nYDest + y); + BYTE* dstp = gdi_get_bitmap_pointer( + hdcDest, nXDest + x, nYDest + y); + + if (srcp && dstp) + { + UINT32 color; + UINT32 colorA = ReadColor(srcp, hdcSrc->format); + UINT32 colorB = ReadColor(dstp, hdcDest->format); + UINT32 colorC = ReadColor(patp, hdcDest->format); + colorA = ConvertColor(colorA, hdcSrc->format, + hdcDest->format, palette); + color = (colorA ^ colorC) | (colorB ^ colorC); + WriteColor(dstp, hdcDest->format, color); + } + } + } + + break; + } + + return TRUE; +} + +static BOOL BitBlt_PSDPaox(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, + UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc, + UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette) +{ + UINT32 x, y, colorC; + + if (!hdcDest || !hdcSrc) + return FALSE; + + switch (gdi_GetBrushStyle(hdcDest)) + { + case GDI_BS_SOLID: + colorC = hdcDest->brush->color; + + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + const BYTE* srcp = gdi_get_bitmap_pointer( + hdcSrc, nXSrc + x, nYSrc + y); + BYTE* dstp = gdi_get_bitmap_pointer( + hdcDest, nXDest + x, nYDest + y); + + if (srcp && dstp) + { + UINT32 color; + UINT32 colorA = ReadColor(srcp, hdcSrc->format); + UINT32 colorB = ReadColor(dstp, hdcDest->format); + colorA = ConvertColor(colorA, hdcSrc->format, + hdcDest->format, palette); + color = (colorA & colorC) | (colorB ^ colorC); + WriteColor(dstp, hdcDest->format, color); + } + } + } + + break; + + default: + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + const BYTE* srcp = gdi_get_bitmap_pointer( + hdcSrc, nXSrc + x, nYSrc + y); + const BYTE* patp = gdi_get_brush_pointer( + hdcDest, nXDest + x, nYDest + y); + BYTE* dstp = gdi_get_bitmap_pointer( + hdcDest, nXDest + x, nYDest + y); + + if (srcp && dstp) + { + UINT32 color; + UINT32 colorA = ReadColor(srcp, hdcSrc->format); + UINT32 colorB = ReadColor(dstp, hdcDest->format); + UINT32 colorC = ReadColor(patp, hdcDest->format); + colorA = ConvertColor(colorA, hdcSrc->format, + hdcDest->format, palette); + color = (colorA & colorC) | (colorB ^ colorC); + WriteColor(dstp, hdcDest->format, color); + } + } + } + + break; + } + + return TRUE; +} + +static BOOL BitBlt_PSDPxoxn(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, + UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc, + UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette) +{ + UINT32 x, y, colorC; + + if (!hdcDest || !hdcSrc) + return FALSE; + + switch (gdi_GetBrushStyle(hdcDest)) + { + case GDI_BS_SOLID: + colorC = hdcDest->brush->color; + + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + const BYTE* srcp = gdi_get_bitmap_pointer( + hdcSrc, nXSrc + x, nYSrc + y); + BYTE* dstp = gdi_get_bitmap_pointer( + hdcDest, nXDest + x, nYDest + y); + + if (srcp && dstp) + { + UINT32 color; + UINT32 colorA = ReadColor(srcp, hdcSrc->format); + UINT32 colorB = ReadColor(dstp, hdcDest->format); + colorA = ConvertColor(colorA, hdcSrc->format, + hdcDest->format, palette); + color = (colorA ^ colorC) | (colorB ^ ~colorC); + WriteColor(dstp, hdcDest->format, color); + } + } + } + + break; + + default: + for (y = 0; y < nHeight; y++) + { + for (x = 0; x < nWidth; x++) + { + const BYTE* srcp = gdi_get_bitmap_pointer( + hdcSrc, nXSrc + x, nYSrc + y); + const BYTE* patp = gdi_get_brush_pointer( + hdcDest, nXDest + x, nYDest + y); + BYTE* dstp = gdi_get_bitmap_pointer( + hdcDest, nXDest + x, nYDest + y); + + if (srcp && dstp) + { + UINT32 color; + UINT32 colorA = ReadColor(srcp, hdcSrc->format); + UINT32 colorB = ReadColor(dstp, hdcDest->format); + UINT32 colorC = ReadColor(patp, hdcDest->format); + colorA = ConvertColor(colorA, hdcSrc->format, + hdcDest->format, palette); + color = (colorA ^ colorC) | (colorB ^ ~colorC); + WriteColor(dstp, hdcDest->format, color); + } + } + } + + break; + } + + return TRUE; +} + static BOOL BitBlt_PSDPxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc, UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette) @@ -1771,6 +1981,18 @@ BOOL gdi_BitBlt(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest, return BitBlt_DSPDxox(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, palette); + case GDI_PSDPxox: + return BitBlt_PSDPxox(hdcDest, nXDest, nYDest, nWidth, nHeight, + hdcSrc, nXSrc, nYSrc, palette); + + case GDI_PSDPaox: + return BitBlt_PSDPaox(hdcDest, nXDest, nYDest, nWidth, nHeight, + hdcSrc, nXSrc, nYSrc, palette); + + case GDI_PSDPxoxn: + return BitBlt_PSDPxoxn(hdcDest, nXDest, nYDest, nWidth, nHeight, + hdcSrc, nXSrc, nYSrc, palette); + case GDI_PSDPxax: return BitBlt_PSDPxax(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, palette); diff --git a/libfreerdp/gdi/brush.c b/libfreerdp/gdi/brush.c index 0de152e42..18d39b5a8 100644 --- a/libfreerdp/gdi/brush.c +++ b/libfreerdp/gdi/brush.c @@ -205,6 +205,18 @@ const char* gdi_rop_to_string(UINT32 code) _snprintf(buffer, sizeof(buffer), "GDI_PDSona [%08X]", code); break; + case GDI_PSDPaox: + _snprintf(buffer, sizeof(buffer), "GDI_PSDPaox [%08X]", code); + break; + + case GDI_PSDPxox: + _snprintf(buffer, sizeof(buffer), "GDI_PSDPxox [%08X]", code); + break; + + case GDI_PSDPxoxn: + _snprintf(buffer, sizeof(buffer), "GDI_PSDPxoxn [%08X]", code); + break; + case GDI_DSPDxox: _snprintf(buffer, sizeof(buffer), "GDI_DSPDxox [%08X]", code); break; diff --git a/libfreerdp/gdi/graphics.h b/libfreerdp/gdi/graphics.h index 0e21dd687..5478ceaa8 100644 --- a/libfreerdp/gdi/graphics.h +++ b/libfreerdp/gdi/graphics.h @@ -26,7 +26,7 @@ #include HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, UINT32 width, UINT32 height, - UINT32 format, BYTE* data); + UINT32 format, BYTE* data); BOOL gdi_register_graphics(rdpGraphics* graphics);