diff --git a/include/freerdp/gdi/16bpp.h b/include/freerdp/gdi/16bpp.h index 629e6129b..5e0b76777 100644 --- a/include/freerdp/gdi/16bpp.h +++ b/include/freerdp/gdi/16bpp.h @@ -21,9 +21,11 @@ #include #include -typedef void (*pSetPixel16_ROP2)(uint16 *pixel, uint16 *pen); +typedef int (*pLineTo_16bpp)(HGDI_DC hdc, int nXEnd, int nYEnd); -int FillRect_16bpp(HGDI_DC hdc, HGDI_RECT rect, HGDI_BRUSH hbr); -int BitBlt_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, int rop); -int PatBlt_16bpp(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, int rop); -int LineTo_16bpp(HGDI_DC hdc, int nXEnd, int nYEnd); +FREERDP_API uint16 gdi_get_color_16bpp(HGDI_DC hdc, GDI_COLOR color); + +FREERDP_API int FillRect_16bpp(HGDI_DC hdc, HGDI_RECT rect, HGDI_BRUSH hbr); +FREERDP_API int BitBlt_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, int rop); +FREERDP_API int PatBlt_16bpp(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, int rop); +FREERDP_API int LineTo_16bpp(HGDI_DC hdc, int nXEnd, int nYEnd); diff --git a/include/freerdp/gdi/32bpp.h b/include/freerdp/gdi/32bpp.h index 010cba9bd..a843b6172 100644 --- a/include/freerdp/gdi/32bpp.h +++ b/include/freerdp/gdi/32bpp.h @@ -21,7 +21,7 @@ #include #include -typedef void (*pSetPixel32_ROP2)(uint32 *pixel, uint32 *pen); +typedef int (*pLineTo_32bpp)(HGDI_DC hdc, int nXEnd, int nYEnd); FREERDP_API uint32 gdi_get_color_32bpp(HGDI_DC hdc, GDI_COLOR color); diff --git a/include/freerdp/gdi/8bpp.h b/include/freerdp/gdi/8bpp.h index c55b77391..cd944dcc1 100644 --- a/include/freerdp/gdi/8bpp.h +++ b/include/freerdp/gdi/8bpp.h @@ -21,7 +21,9 @@ #include #include -typedef void (*pSetPixel8_ROP2)(uint8 *pixel, uint8 *pen); +typedef int (*pLineTo_8bpp)(HGDI_DC hdc, int nXEnd, int nYEnd); + +FREERDP_API uint8 gdi_get_color_8bpp(HGDI_DC hdc, GDI_COLOR color); FREERDP_API int FillRect_8bpp(HGDI_DC hdc, HGDI_RECT rect, HGDI_BRUSH hbr); FREERDP_API int BitBlt_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, int rop); diff --git a/libfreerdp-gdi/16bpp.c b/libfreerdp-gdi/16bpp.c index 2c5102a25..70f41caf6 100644 --- a/libfreerdp-gdi/16bpp.c +++ b/libfreerdp-gdi/16bpp.c @@ -886,107 +886,139 @@ INLINE void SetPixel_WHITE_16bpp(uint16 *pixel, uint16 *pen) *pixel = 0xFFFF; } -pSetPixel16_ROP2 SetPixel16_ROP2_[16] = +#define PIXEL_TYPE uint16 +#define GDI_GET_POINTER gdi_GetPointer_16bpp +#define GDI_GET_PEN_COLOR gdi_GetPenColor_16bpp + +#define LINE_TO LineTo_BLACK_16bpp +#define SET_PIXEL_ROP2 SetPixel_BLACK_16bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOTMERGEPEN_16bpp +#define SET_PIXEL_ROP2 SetPixel_NOTMERGEPEN_16bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MASKNOTPEN_16bpp +#define SET_PIXEL_ROP2 SetPixel_MASKNOTPEN_16bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOTCOPYPEN_16bpp +#define SET_PIXEL_ROP2 SetPixel_NOTCOPYPEN_16bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MASKPENNOT_16bpp +#define SET_PIXEL_ROP2 SetPixel_MASKPENNOT_16bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOT_16bpp +#define SET_PIXEL_ROP2 SetPixel_NOT_16bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_XORPEN_16bpp +#define SET_PIXEL_ROP2 SetPixel_XORPEN_16bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOTMASKPEN_16bpp +#define SET_PIXEL_ROP2 SetPixel_NOTMASKPEN_16bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MASKPEN_16bpp +#define SET_PIXEL_ROP2 SetPixel_MASKPEN_16bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOTXORPEN_16bpp +#define SET_PIXEL_ROP2 SetPixel_NOTXORPEN_16bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOP_16bpp +#define SET_PIXEL_ROP2 SetPixel_NOP_16bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MERGENOTPEN_16bpp +#define SET_PIXEL_ROP2 SetPixel_MERGENOTPEN_16bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_COPYPEN_16bpp +#define SET_PIXEL_ROP2 SetPixel_COPYPEN_16bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MERGEPENNOT_16bpp +#define SET_PIXEL_ROP2 SetPixel_MERGEPENNOT_16bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MERGEPEN_16bpp +#define SET_PIXEL_ROP2 SetPixel_MERGEPEN_16bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_WHITE_16bpp +#define SET_PIXEL_ROP2 SetPixel_WHITE_16bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#undef PIXEL_TYPE +#undef GDI_GET_POINTER +#undef GDI_GET_PEN_COLOR + +pLineTo_16bpp LineTo_ROP2_16bpp[32] = { - SetPixel_BLACK_16bpp, - SetPixel_NOTMERGEPEN_16bpp, - SetPixel_MASKNOTPEN_16bpp, - SetPixel_NOTCOPYPEN_16bpp, - SetPixel_MASKPENNOT_16bpp, - SetPixel_NOT_16bpp, - SetPixel_XORPEN_16bpp, - SetPixel_NOTMASKPEN_16bpp, - SetPixel_MASKPEN_16bpp, - SetPixel_NOTXORPEN_16bpp, - SetPixel_NOP_16bpp, - SetPixel_MERGENOTPEN_16bpp, - SetPixel_COPYPEN_16bpp, - SetPixel_MERGEPENNOT_16bpp, - SetPixel_MERGEPEN_16bpp, - SetPixel_WHITE_16bpp + LineTo_BLACK_16bpp, + LineTo_NOTMERGEPEN_16bpp, + LineTo_MASKNOTPEN_16bpp, + LineTo_NOTCOPYPEN_16bpp, + LineTo_MASKPENNOT_16bpp, + LineTo_NOT_16bpp, + LineTo_XORPEN_16bpp, + LineTo_NOTMASKPEN_16bpp, + LineTo_MASKPEN_16bpp, + LineTo_NOTXORPEN_16bpp, + LineTo_NOP_16bpp, + LineTo_MERGENOTPEN_16bpp, + LineTo_COPYPEN_16bpp, + LineTo_MERGEPENNOT_16bpp, + LineTo_MERGEPEN_16bpp, + LineTo_WHITE_16bpp }; int LineTo_16bpp(HGDI_DC hdc, int nXEnd, int nYEnd) { - int x, y; - int x1, y1; - int x2, y2; - int e, e2; - int dx, dy; - int sx, sy; - HGDI_BITMAP bmp; - int bx1, by1; - int bx2, by2; + pLineTo_16bpp _LineTo; + int rop2 = gdi_GetROP2(hdc) - 1; - int irop2; - uint16 pen; - uint16 *pixel; + _LineTo = LineTo_ROP2_16bpp[rop2]; - x1 = hdc->pen->posX; - y1 = hdc->pen->posY; - x2 = nXEnd; - y2 = nYEnd; - - dx = (x1 > x2) ? x1 - x2 : x2 - x1; - dy = (y1 > y2) ? y1 - y2 : y2 - y1; - - sx = (x1 < x2) ? 1 : -1; - sy = (y1 < y2) ? 1 : -1; - - e = dx - dy; - - x = x1; - y = y1; - - irop2 = gdi_GetROP2(hdc) - 1; - bmp = (HGDI_BITMAP) hdc->selectedObject; - - if (hdc->clip->null) - { - bx1 = (x1 < x2) ? x1 : x2; - by1 = (y1 < y2) ? y1 : y2; - bx2 = (x1 > x2) ? x1 : x2; - by2 = (y1 > y2) ? y1 : y2; - } + if (_LineTo != NULL) + return _LineTo(hdc, nXEnd, nYEnd); else - { - bx1 = hdc->clip->x; - by1 = hdc->clip->y; - bx2 = bx1 + hdc->clip->w - 1; - by2 = by1 + hdc->clip->h - 1; - } - - pen = gdi_GetPenColor_16bpp(hdc->pen); - - while (1) - { - if (!(x == x2 && y == y2)) - { - if ((x >= bx1 && x <= bx2) && (y >= by1 && y <= by2)) - { - pixel = gdi_GetPointer_16bpp(bmp, x, y); - SetPixel16_ROP2_[irop2](pixel, &pen); - } - } - else - { - break; - } - - e2 = 2 * e; - - if (e2 > -dy) - { - e -= dy; - x += sx; - } - - if (e2 < dx) - { - e += dx; - y += sy; - } - } - - return 1; + return 0; } diff --git a/libfreerdp-gdi/32bpp.c b/libfreerdp-gdi/32bpp.c index 3c7285625..728215ace 100644 --- a/libfreerdp-gdi/32bpp.c +++ b/libfreerdp-gdi/32bpp.c @@ -820,202 +820,234 @@ int PatBlt_32bpp(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, i return 1; } -INLINE void SetPixel_BLACK_32bpp(uint32 *pixel, uint32 *pen) +INLINE void SetPixel_BLACK_32bpp(uint32* pixel, uint32* pen) { /* D = 0 */ *pixel = 0; } -INLINE void SetPixel_NOTMERGEPEN_32bpp(uint32 *pixel, uint32 *pen) +INLINE void SetPixel_NOTMERGEPEN_32bpp(uint32* pixel, uint32* pen) { /* D = ~(D | P) */ *pixel = ~(*pixel | *pen); } -INLINE void SetPixel_MASKNOTPEN_32bpp(uint32 *pixel, uint32 *pen) +INLINE void SetPixel_MASKNOTPEN_32bpp(uint32* pixel, uint32* pen) { /* D = D & ~P */ *pixel &= ~(*pen); } -INLINE void SetPixel_NOTCOPYPEN_32bpp(uint32 *pixel, uint32 *pen) +INLINE void SetPixel_NOTCOPYPEN_32bpp(uint32* pixel, uint32* pen) { /* D = ~P */ *pixel = ~(*pen); } -INLINE void SetPixel_MASKPENNOT_32bpp(uint32 *pixel, uint32 *pen) +INLINE void SetPixel_MASKPENNOT_32bpp(uint32* pixel, uint32* pen) { /* D = P & ~D */ *pixel = *pen & ~*pixel; } -INLINE void SetPixel_NOT_32bpp(uint32 *pixel, uint32 *pen) +INLINE void SetPixel_NOT_32bpp(uint32* pixel, uint32* pen) { /* D = ~D */ *pixel = ~(*pixel); } -INLINE void SetPixel_XORPEN_32bpp(uint32 *pixel, uint32 *pen) +INLINE void SetPixel_XORPEN_32bpp(uint32* pixel, uint32* pen) { /* D = D ^ P */ *pixel = *pixel ^ *pen; } -INLINE void SetPixel_NOTMASKPEN_32bpp(uint32 *pixel, uint32 *pen) +INLINE void SetPixel_NOTMASKPEN_32bpp(uint32* pixel, uint32* pen) { /* D = ~(D & P) */ *pixel = ~(*pixel & *pen); } -INLINE void SetPixel_MASKPEN_32bpp(uint32 *pixel, uint32 *pen) +INLINE void SetPixel_MASKPEN_32bpp(uint32* pixel, uint32* pen) { /* D = D & P */ *pixel &= *pen; } -INLINE void SetPixel_NOTXORPEN_32bpp(uint32 *pixel, uint32 *pen) +INLINE void SetPixel_NOTXORPEN_32bpp(uint32* pixel, uint32* pen) { /* D = ~(D ^ P) */ *pixel = ~(*pixel ^ *pen); } -INLINE void SetPixel_NOP_32bpp(uint32 *pixel, uint32 *pen) +INLINE void SetPixel_NOP_32bpp(uint32* pixel, uint32* pen) { /* D = D */ } -INLINE void SetPixel_MERGENOTPEN_32bpp(uint32 *pixel, uint32 *pen) +INLINE void SetPixel_MERGENOTPEN_32bpp(uint32* pixel, uint32* pen) { /* D = D | ~P */ *pixel |= ~(*pen); } -INLINE void SetPixel_COPYPEN_32bpp(uint32 *pixel, uint32 *pen) +INLINE void SetPixel_COPYPEN_32bpp(uint32* pixel, uint32* pen) { /* D = P */ *pixel = *pen; } -INLINE void SetPixel_MERGEPENNOT_32bpp(uint32 *pixel, uint32 *pen) +INLINE void SetPixel_MERGEPENNOT_32bpp(uint32* pixel, uint32* pen) { /* D = P | ~D */ *pixel = *pen | ~(*pixel); } -INLINE void SetPixel_MERGEPEN_32bpp(uint32 *pixel, uint32 *pen) +INLINE void SetPixel_MERGEPEN_32bpp(uint32* pixel, uint32* pen) { /* D = P | D */ *pixel |= *pen; } -INLINE void SetPixel_WHITE_32bpp(uint32 *pixel, uint32 *pen) +INLINE void SetPixel_WHITE_32bpp(uint32* pixel, uint32* pen) { /* D = 1 */ *pixel = 0xFFFFFF; } -pSetPixel32_ROP2 SetPixel32_ROP2_[32] = +#define PIXEL_TYPE uint32 +#define GDI_GET_POINTER gdi_GetPointer_32bpp +#define GDI_GET_PEN_COLOR gdi_GetPenColor_32bpp + +#define LINE_TO LineTo_BLACK_32bpp +#define SET_PIXEL_ROP2 SetPixel_BLACK_32bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOTMERGEPEN_32bpp +#define SET_PIXEL_ROP2 SetPixel_NOTMERGEPEN_32bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MASKNOTPEN_32bpp +#define SET_PIXEL_ROP2 SetPixel_MASKNOTPEN_32bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOTCOPYPEN_32bpp +#define SET_PIXEL_ROP2 SetPixel_NOTCOPYPEN_32bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MASKPENNOT_32bpp +#define SET_PIXEL_ROP2 SetPixel_MASKPENNOT_32bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOT_32bpp +#define SET_PIXEL_ROP2 SetPixel_NOT_32bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_XORPEN_32bpp +#define SET_PIXEL_ROP2 SetPixel_XORPEN_32bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOTMASKPEN_32bpp +#define SET_PIXEL_ROP2 SetPixel_NOTMASKPEN_32bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MASKPEN_32bpp +#define SET_PIXEL_ROP2 SetPixel_MASKPEN_32bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOTXORPEN_32bpp +#define SET_PIXEL_ROP2 SetPixel_NOTXORPEN_32bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOP_32bpp +#define SET_PIXEL_ROP2 SetPixel_NOP_32bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MERGENOTPEN_32bpp +#define SET_PIXEL_ROP2 SetPixel_MERGENOTPEN_32bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_COPYPEN_32bpp +#define SET_PIXEL_ROP2 SetPixel_COPYPEN_32bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MERGEPENNOT_32bpp +#define SET_PIXEL_ROP2 SetPixel_MERGEPENNOT_32bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MERGEPEN_32bpp +#define SET_PIXEL_ROP2 SetPixel_MERGEPEN_32bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_WHITE_32bpp +#define SET_PIXEL_ROP2 SetPixel_WHITE_32bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#undef PIXEL_TYPE +#undef GDI_GET_POINTER +#undef GDI_GET_PEN_COLOR + +pLineTo_32bpp LineTo_ROP2_32bpp[32] = { - SetPixel_BLACK_32bpp, - SetPixel_NOTMERGEPEN_32bpp, - SetPixel_MASKNOTPEN_32bpp, - SetPixel_NOTCOPYPEN_32bpp, - SetPixel_MASKPENNOT_32bpp, - SetPixel_NOT_32bpp, - SetPixel_XORPEN_32bpp, - SetPixel_NOTMASKPEN_32bpp, - SetPixel_MASKPEN_32bpp, - SetPixel_NOTXORPEN_32bpp, - SetPixel_NOP_32bpp, - SetPixel_MERGENOTPEN_32bpp, - SetPixel_COPYPEN_32bpp, - SetPixel_MERGEPENNOT_32bpp, - SetPixel_MERGEPEN_32bpp, - SetPixel_WHITE_32bpp + LineTo_BLACK_32bpp, + LineTo_NOTMERGEPEN_32bpp, + LineTo_MASKNOTPEN_32bpp, + LineTo_NOTCOPYPEN_32bpp, + LineTo_MASKPENNOT_32bpp, + LineTo_NOT_32bpp, + LineTo_XORPEN_32bpp, + LineTo_NOTMASKPEN_32bpp, + LineTo_MASKPEN_32bpp, + LineTo_NOTXORPEN_32bpp, + LineTo_NOP_32bpp, + LineTo_MERGENOTPEN_32bpp, + LineTo_COPYPEN_32bpp, + LineTo_MERGEPENNOT_32bpp, + LineTo_MERGEPEN_32bpp, + LineTo_WHITE_32bpp }; int LineTo_32bpp(HGDI_DC hdc, int nXEnd, int nYEnd) { - int x, y; - int x1, y1; - int x2, y2; - int e, e2; - int dx, dy; - int sx, sy; - HGDI_BITMAP bmp; - int bx1, by1; - int bx2, by2; + pLineTo_32bpp _LineTo; + int rop2 = gdi_GetROP2(hdc) - 1; - int irop2; - uint32 pen; - uint32 *pixel; + _LineTo = LineTo_ROP2_32bpp[rop2]; - x1 = hdc->pen->posX; - y1 = hdc->pen->posY; - x2 = nXEnd; - y2 = nYEnd; - - dx = (x1 > x2) ? x1 - x2 : x2 - x1; - dy = (y1 > y2) ? y1 - y2 : y2 - y1; - - sx = (x1 < x2) ? 1 : -1; - sy = (y1 < y2) ? 1 : -1; - - e = dx - dy; - - x = x1; - y = y1; - - irop2 = gdi_GetROP2(hdc) - 1; - bmp = (HGDI_BITMAP) hdc->selectedObject; - - if (hdc->clip->null) - { - bx1 = (x1 < x2) ? x1 : x2; - by1 = (y1 < y2) ? y1 : y2; - bx2 = (x1 > x2) ? x1 : x2; - by2 = (y1 > y2) ? y1 : y2; - } + if (_LineTo != NULL) + return _LineTo(hdc, nXEnd, nYEnd); else - { - bx1 = hdc->clip->x; - by1 = hdc->clip->y; - bx2 = bx1 + hdc->clip->w - 1; - by2 = by1 + hdc->clip->h - 1; - } - - pen = gdi_GetPenColor_32bpp(hdc->pen); - - while (1) - { - if (!(x == x2 && y == y2)) - { - if ((x >= bx1 && x <= bx2) && (y >= by1 && y <= by2)) - { - pixel = gdi_GetPointer_32bpp(bmp, x, y); - SetPixel32_ROP2_[irop2](pixel, &pen); - } - } - else - { - break; - } - - e2 = 2 * e; - - if (e2 > -dy) - { - e -= dy; - x += sx; - } - - if (e2 < dx) - { - e += dx; - y += sy; - } - } - - return 1; + return 0; } diff --git a/libfreerdp-gdi/8bpp.c b/libfreerdp-gdi/8bpp.c index c4f261563..d5a8a0054 100644 --- a/libfreerdp-gdi/8bpp.c +++ b/libfreerdp-gdi/8bpp.c @@ -795,107 +795,139 @@ INLINE void SetPixel_WHITE_8bpp(uint8* pixel, uint8* pen) *pixel = 0xFF; } -pSetPixel8_ROP2 SetPixel8_ROP2_[16] = +#define PIXEL_TYPE uint8 +#define GDI_GET_POINTER gdi_GetPointer_8bpp +#define GDI_GET_PEN_COLOR gdi_GetPenColor_8bpp + +#define LINE_TO LineTo_BLACK_8bpp +#define SET_PIXEL_ROP2 SetPixel_BLACK_8bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOTMERGEPEN_8bpp +#define SET_PIXEL_ROP2 SetPixel_NOTMERGEPEN_8bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MASKNOTPEN_8bpp +#define SET_PIXEL_ROP2 SetPixel_MASKNOTPEN_8bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOTCOPYPEN_8bpp +#define SET_PIXEL_ROP2 SetPixel_NOTCOPYPEN_8bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MASKPENNOT_8bpp +#define SET_PIXEL_ROP2 SetPixel_MASKPENNOT_8bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOT_8bpp +#define SET_PIXEL_ROP2 SetPixel_NOT_8bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_XORPEN_8bpp +#define SET_PIXEL_ROP2 SetPixel_XORPEN_8bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOTMASKPEN_8bpp +#define SET_PIXEL_ROP2 SetPixel_NOTMASKPEN_8bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MASKPEN_8bpp +#define SET_PIXEL_ROP2 SetPixel_MASKPEN_8bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOTXORPEN_8bpp +#define SET_PIXEL_ROP2 SetPixel_NOTXORPEN_8bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_NOP_8bpp +#define SET_PIXEL_ROP2 SetPixel_NOP_8bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MERGENOTPEN_8bpp +#define SET_PIXEL_ROP2 SetPixel_MERGENOTPEN_8bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_COPYPEN_8bpp +#define SET_PIXEL_ROP2 SetPixel_COPYPEN_8bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MERGEPENNOT_8bpp +#define SET_PIXEL_ROP2 SetPixel_MERGEPENNOT_8bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_MERGEPEN_8bpp +#define SET_PIXEL_ROP2 SetPixel_MERGEPEN_8bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#define LINE_TO LineTo_WHITE_8bpp +#define SET_PIXEL_ROP2 SetPixel_WHITE_8bpp +#include "include/line.c" +#undef LINE_TO +#undef SET_PIXEL_ROP2 + +#undef PIXEL_TYPE +#undef GDI_GET_POINTER +#undef GDI_GET_PEN_COLOR + +pLineTo_8bpp LineTo_ROP2_8bpp[32] = { - SetPixel_BLACK_8bpp, - SetPixel_NOTMERGEPEN_8bpp, - SetPixel_MASKNOTPEN_8bpp, - SetPixel_NOTCOPYPEN_8bpp, - SetPixel_MASKPENNOT_8bpp, - SetPixel_NOT_8bpp, - SetPixel_XORPEN_8bpp, - SetPixel_NOTMASKPEN_8bpp, - SetPixel_MASKPEN_8bpp, - SetPixel_NOTXORPEN_8bpp, - SetPixel_NOP_8bpp, - SetPixel_MERGENOTPEN_8bpp, - SetPixel_COPYPEN_8bpp, - SetPixel_MERGEPENNOT_8bpp, - SetPixel_MERGEPEN_8bpp, - SetPixel_WHITE_8bpp + LineTo_BLACK_8bpp, + LineTo_NOTMERGEPEN_8bpp, + LineTo_MASKNOTPEN_8bpp, + LineTo_NOTCOPYPEN_8bpp, + LineTo_MASKPENNOT_8bpp, + LineTo_NOT_8bpp, + LineTo_XORPEN_8bpp, + LineTo_NOTMASKPEN_8bpp, + LineTo_MASKPEN_8bpp, + LineTo_NOTXORPEN_8bpp, + LineTo_NOP_8bpp, + LineTo_MERGENOTPEN_8bpp, + LineTo_COPYPEN_8bpp, + LineTo_MERGEPENNOT_8bpp, + LineTo_MERGEPEN_8bpp, + LineTo_WHITE_8bpp }; int LineTo_8bpp(HGDI_DC hdc, int nXEnd, int nYEnd) { - int x, y; - int x1, y1; - int x2, y2; - int e, e2; - int dx, dy; - int sx, sy; - HGDI_BITMAP bmp; - int bx1, by1; - int bx2, by2; + pLineTo_8bpp _LineTo; + int rop2 = gdi_GetROP2(hdc) - 1; - int irop2; - uint8 pen; - uint8* pixel; + _LineTo = LineTo_ROP2_8bpp[rop2]; - x1 = hdc->pen->posX; - y1 = hdc->pen->posY; - x2 = nXEnd; - y2 = nYEnd; - - dx = (x1 > x2) ? x1 - x2 : x2 - x1; - dy = (y1 > y2) ? y1 - y2 : y2 - y1; - - sx = (x1 < x2) ? 1 : -1; - sy = (y1 < y2) ? 1 : -1; - - e = dx - dy; - - x = x1; - y = y1; - - irop2 = gdi_GetROP2(hdc) - 1; - bmp = (HGDI_BITMAP) hdc->selectedObject; - - if (hdc->clip->null) - { - bx1 = (x1 < x2) ? x1 : x2; - by1 = (y1 < y2) ? y1 : y2; - bx2 = (x1 > x2) ? x1 : x2; - by2 = (y1 > y2) ? y1 : y2; - } + if (_LineTo != NULL) + return _LineTo(hdc, nXEnd, nYEnd); else - { - bx1 = hdc->clip->x; - by1 = hdc->clip->y; - bx2 = bx1 + hdc->clip->w - 1; - by2 = by1 + hdc->clip->h - 1; - } - - pen = gdi_GetPenColor_8bpp(hdc->pen); - - while (1) - { - if (!(x == x2 && y == y2)) - { - if ((x >= bx1 && x <= bx2) && (y >= by1 && y <= by2)) - { - pixel = gdi_GetPointer_8bpp(bmp, x, y); - SetPixel8_ROP2_[irop2](pixel, &pen); - } - } - else - { - break; - } - - e2 = 2 * e; - - if (e2 > -dy) - { - e -= dy; - x += sx; - } - - if (e2 < dx) - { - e += dx; - y += sy; - } - } - - return 1; + return 0; } diff --git a/libfreerdp-gdi/include/line.c b/libfreerdp-gdi/include/line.c new file mode 100644 index 000000000..ab35d1e72 --- /dev/null +++ b/libfreerdp-gdi/include/line.c @@ -0,0 +1,110 @@ +/** + * FreeRDP: A Remote Desktop Protocol Client + * GDI LineTo + * + * Copyright 2010-2011 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* do not include this file directly! */ + +int LINE_TO(HGDI_DC hdc, int nXEnd, int nYEnd) +{ + int x, y; + int x1, y1; + int x2, y2; + int e, e2; + int dx, dy; + int sx, sy; + int bx1, by1; + int bx2, by2; + PIXEL_TYPE pen; + PIXEL_TYPE* pixel; + HGDI_BITMAP bmp; + + x1 = hdc->pen->posX; + y1 = hdc->pen->posY; + x2 = nXEnd; + y2 = nYEnd; + + dx = (x1 > x2) ? x1 - x2 : x2 - x1; + dy = (y1 > y2) ? y1 - y2 : y2 - y1; + + sx = (x1 < x2) ? 1 : -1; + sy = (y1 < y2) ? 1 : -1; + + e = dx - dy; + + x = x1; + y = y1; + + bmp = (HGDI_BITMAP) hdc->selectedObject; + + if (hdc->clip->null) + { + bx1 = (x1 < x2) ? x1 : x2; + by1 = (y1 < y2) ? y1 : y2; + bx2 = (x1 > x2) ? x1 : x2; + by2 = (y1 > y2) ? y1 : y2; + } + else + { + bx1 = hdc->clip->x; + by1 = hdc->clip->y; + bx2 = bx1 + hdc->clip->w - 1; + by2 = by1 + hdc->clip->h - 1; + } + + pen = GDI_GET_PEN_COLOR(hdc->pen); + + while (1) + { + if (!(x == x2 && y == y2)) + { + if ((x >= bx1 && x <= bx2) && (y >= by1 && y <= by2)) + { + pixel = GDI_GET_POINTER(bmp, x, y); + SET_PIXEL_ROP2(pixel, &pen); + } + } + else + { + break; + } + + e2 = 2 * e; + + if (e2 > -dy) + { + e -= dy; + x += sx; + } + + if (e2 < dx) + { + e += dx; + y += sy; + } + } + + return 1; +} + +/* +#undef LINE_TO +#undef PIXEL_TYPE +#undef SET_PIXEL_ROP2 +#undef GDI_GET_POINTER +#undef GDI_GET_PEN_COLOR +*/