mirror of
https://github.com/FreeRDP/FreeRDP.git
synced 2024-12-04 15:23:32 +08:00
Fixed gdi LineTo and tests.
This commit is contained in:
parent
ebfe4fbce5
commit
d3538fc930
@ -100,7 +100,7 @@
|
||||
#define PIXEL_FORMAT_ARGB15 PIXEL_FORMAT_A1R5G5B5_F(0)
|
||||
#define PIXEL_FORMAT_ARGB15_VF PIXEL_FORMAT_A1R5G5B5_F(1)
|
||||
|
||||
#define PIXEL_FORMAT_X1R5G5B5_F(_flip) FREERDP_PIXEL_FORMAT(_flip, 16, FREERDP_PIXEL_FORMAT_TYPE_ARGB, 0, 5, 5, 5)
|
||||
#define PIXEL_FORMAT_X1R5G5B5_F(_flip) FREERDP_PIXEL_FORMAT(_flip, 15, FREERDP_PIXEL_FORMAT_TYPE_ARGB, 0, 5, 5, 5)
|
||||
#define PIXEL_FORMAT_RGB15 PIXEL_FORMAT_X1R5G5B5_F(0)
|
||||
#define PIXEL_FORMAT_RGB15_VF PIXEL_FORMAT_X1R5G5B5_F(1)
|
||||
|
||||
@ -108,7 +108,7 @@
|
||||
#define PIXEL_FORMAT_ABGR15 PIXEL_FORMAT_A1B5G5R5_F(0)
|
||||
#define PIXEL_FORMAT_ABGR15_VF PIXEL_FORMAT_A1B5G5R5_F(1)
|
||||
|
||||
#define PIXEL_FORMAT_X1B5G5R5_F(_flip) FREERDP_PIXEL_FORMAT(_flip, 16, FREERDP_PIXEL_FORMAT_TYPE_ABGR, 0, 5, 5, 5)
|
||||
#define PIXEL_FORMAT_X1B5G5R5_F(_flip) FREERDP_PIXEL_FORMAT(_flip, 15, FREERDP_PIXEL_FORMAT_TYPE_ABGR, 0, 5, 5, 5)
|
||||
#define PIXEL_FORMAT_BGR15 PIXEL_FORMAT_X1B5G5R5_F(0)
|
||||
#define PIXEL_FORMAT_BGR15_VF PIXEL_FORMAT_X1B5G5R5_F(1)
|
||||
|
||||
@ -605,11 +605,11 @@ static INLINE UINT32 GetColor(UINT32 format, BYTE r, BYTE g, BYTE b, BYTE a)
|
||||
|
||||
case PIXEL_FORMAT_ARGB15:
|
||||
return (((_r >> 3) & 0x1F) << 10) | (((_g >> 3) & 0x1F) << 5) | ((
|
||||
_b >> 3) & 0x1F);
|
||||
_b >> 3) & 0x1F) | (_a ? 0x8000 : 0x0000);
|
||||
|
||||
case PIXEL_FORMAT_ABGR15:
|
||||
return (((_b >> 3) & 0x1F) << 10) | (((_g >> 3) & 0x1F) << 5) | ((
|
||||
_r >> 3) & 0x1F);
|
||||
_r >> 3) & 0x1F) | (_a ? 0x8000 : 0x0000);
|
||||
|
||||
/* 15bpp formats */
|
||||
case PIXEL_FORMAT_RGB15:
|
||||
@ -618,7 +618,7 @@ static INLINE UINT32 GetColor(UINT32 format, BYTE r, BYTE g, BYTE b, BYTE a)
|
||||
|
||||
case PIXEL_FORMAT_BGR15:
|
||||
return (((_b >> 3) & 0x1F) << 10) | (((_g >> 3) & 0x1F) << 5) | ((
|
||||
_r >> 3) & 0x1F);;
|
||||
_r >> 3) & 0x1F);
|
||||
|
||||
/* 8bpp formats */
|
||||
case PIXEL_FORMAT_RGB8:
|
||||
@ -665,13 +665,18 @@ static INLINE UINT32 ReadColor(const BYTE* src, UINT32 format)
|
||||
break;
|
||||
|
||||
case 16:
|
||||
case 15:
|
||||
color = ((UINT32)src[1] << 8) | src[0];
|
||||
break;
|
||||
|
||||
case 15:
|
||||
color = ((UINT32)src[1] << 8) | src[0];
|
||||
|
||||
if (!ColorHasAlpha(format))
|
||||
color = color & 0x7FFF;
|
||||
|
||||
break;
|
||||
|
||||
case 8:
|
||||
case 4:
|
||||
case 1:
|
||||
color = *src;
|
||||
break;
|
||||
|
||||
@ -702,14 +707,19 @@ static INLINE BOOL WriteColor(BYTE* dst, UINT32 format, UINT32 color)
|
||||
break;
|
||||
|
||||
case 16:
|
||||
dst[1] = color >> 8;
|
||||
dst[0] = color;
|
||||
break;
|
||||
|
||||
case 15:
|
||||
if (!ColorHasAlpha(format))
|
||||
color = color & 0x7FFF;
|
||||
|
||||
dst[1] = color >> 8;
|
||||
dst[0] = color;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
case 4:
|
||||
case 1:
|
||||
dst[0] = color;
|
||||
break;
|
||||
|
||||
|
@ -47,79 +47,80 @@
|
||||
*/
|
||||
static BOOL gdi_rop_color(UINT32 rop, BYTE* pixelPtr, UINT32 pen, UINT32 format)
|
||||
{
|
||||
UINT32 pixel = ReadColor(pixelPtr, format);
|
||||
const UINT32 srcPixel = ReadColor(pixelPtr, format);
|
||||
UINT32 dstPixel;
|
||||
|
||||
switch (rop)
|
||||
{
|
||||
case GDI_R2_BLACK: /* LineTo_BLACK */
|
||||
pixel = GetColor(format, 0, 0, 0, 0xFF);
|
||||
dstPixel = GetColor(format, 0, 0, 0, 0xFF);
|
||||
break;
|
||||
|
||||
case GDI_R2_NOTMERGEPEN: /* LineTo_NOTMERGEPEN */
|
||||
pixel = ~(pixel | pen);
|
||||
dstPixel = ~(srcPixel | pen);
|
||||
break;
|
||||
|
||||
case GDI_R2_MASKNOTPEN: /* LineTo_MASKNOTPEN */
|
||||
pixel &= ~pen;
|
||||
dstPixel = srcPixel & ~pen;
|
||||
break;
|
||||
|
||||
case GDI_R2_NOTCOPYPEN: /* LineTo_NOTCOPYPEN */
|
||||
pixel = ~pen;
|
||||
dstPixel = ~pen;
|
||||
break;
|
||||
|
||||
case GDI_R2_MASKPENNOT: /* LineTo_MASKPENNOT */
|
||||
pixel = pen & ~pixel;
|
||||
dstPixel = pen & ~srcPixel;
|
||||
break;
|
||||
|
||||
case GDI_R2_NOT: /* LineTo_NOT */
|
||||
pixel = ~pixel;
|
||||
dstPixel = ~srcPixel;
|
||||
break;
|
||||
|
||||
case GDI_R2_XORPEN: /* LineTo_XORPEN */
|
||||
pixel = pixel ^ pen;
|
||||
dstPixel = srcPixel ^ pen;
|
||||
break;
|
||||
|
||||
case GDI_R2_NOTMASKPEN: /* LineTo_NOTMASKPEN */
|
||||
pixel = ~(pixel & pen);
|
||||
dstPixel = ~(srcPixel & pen);
|
||||
break;
|
||||
|
||||
case GDI_R2_MASKPEN: /* LineTo_MASKPEN */
|
||||
pixel &= pen;
|
||||
dstPixel = srcPixel & pen;
|
||||
break;
|
||||
|
||||
case GDI_R2_NOTXORPEN: /* LineTo_NOTXORPEN */
|
||||
pixel = ~(pixel ^ pen);
|
||||
dstPixel = ~(srcPixel ^ pen);
|
||||
break;
|
||||
|
||||
case GDI_R2_NOP: /* LineTo_NOP */
|
||||
dstPixel = srcPixel;
|
||||
break;
|
||||
|
||||
case GDI_R2_MERGENOTPEN: /* LineTo_MERGENOTPEN */
|
||||
pixel |= ~pen;
|
||||
dstPixel = srcPixel | ~pen;
|
||||
break;
|
||||
|
||||
case GDI_R2_COPYPEN: /* LineTo_COPYPEN */
|
||||
pixel = pen;
|
||||
dstPixel = pen;
|
||||
break;
|
||||
|
||||
case GDI_R2_MERGEPENNOT: /* LineTo_MERGEPENNOT */
|
||||
pixel = pixel | ~pen;
|
||||
dstPixel = srcPixel | ~pen;
|
||||
break;
|
||||
|
||||
case GDI_R2_MERGEPEN: /* LineTo_MERGEPEN */
|
||||
pixel = pixel | pen;
|
||||
dstPixel = srcPixel | pen;
|
||||
break;
|
||||
|
||||
case GDI_R2_WHITE: /* LineTo_WHITE */
|
||||
pixel = GetColor(format, 0, 0, 0, 0);
|
||||
dstPixel = GetColor(format, 0xFF, 0xFF, 0xFF, 0xFF);
|
||||
break;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
WriteColor(pixelPtr, format, pixel);
|
||||
return TRUE;
|
||||
return WriteColor(pixelPtr, format, dstPixel);
|
||||
}
|
||||
|
||||
BOOL gdi_LineTo(HGDI_DC hdc, UINT32 nXEnd, UINT32 nYEnd)
|
||||
|
@ -695,6 +695,7 @@ int TestGdiLine(int argc, char* argv[])
|
||||
const UINT32 map_size = sizeof(rop_map) / sizeof(rop_map[0]);
|
||||
HGDI_BITMAP hBmp_LineTo[LINTETO_NUMBER] = {NULL};
|
||||
gdiPalette* hPalette = &g;
|
||||
UINT32 penColor;
|
||||
const UINT32 format = colorFormats[i];
|
||||
g.format = format;
|
||||
|
||||
@ -711,8 +712,9 @@ int TestGdiLine(int argc, char* argv[])
|
||||
|
||||
hdc->format = format;
|
||||
gdi_SetNullClipRgn(hdc);
|
||||
penColor = GetColor(format, 0xFF, 0xFF, 0xFF, 0xFF);
|
||||
|
||||
if (!(pen = gdi_CreatePen(1, 1, 0, format, hPalette)))
|
||||
if (!(pen = gdi_CreatePen(1, 1, penColor, format, hPalette)))
|
||||
{
|
||||
printf("gdi_CreatePen failed\n");
|
||||
goto fail;
|
||||
@ -776,6 +778,10 @@ int TestGdiLine(int argc, char* argv[])
|
||||
|
||||
for (x = 0; x < map_size; x++)
|
||||
{
|
||||
char name[1024];
|
||||
_snprintf(name, sizeof(name), "%s [%s]", gdi_rop_to_string(rop_map[x].rop),
|
||||
GetColorFormatName(hdc->format));
|
||||
|
||||
/* Test Case 13: (0,0) -> (16,16), R2_NOTMERGEPEN */
|
||||
if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS, hPalette))
|
||||
{
|
||||
@ -789,7 +795,7 @@ int TestGdiLine(int argc, char* argv[])
|
||||
gdi_LineTo(hdc, 16, 16);
|
||||
|
||||
if (!test_assert_bitmaps_equal(hBmp, rop_map[x].bmp,
|
||||
gdi_rop_to_string(rop_map[x].rop),
|
||||
name,
|
||||
hPalette))
|
||||
goto fail;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user