gdi32: Use NtGdiSetPixel for SetPixel implementation.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0bc43b3a92
commit
5a71d8415e
|
@ -524,9 +524,9 @@ BOOL CDECL EMFDRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right,
|
|||
}
|
||||
|
||||
/***********************************************************************
|
||||
* EMFDRV_SetPixel
|
||||
* EMFDC_SetPixel
|
||||
*/
|
||||
COLORREF CDECL EMFDRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
|
||||
BOOL EMFDC_SetPixel( DC_ATTR *dc_attr, INT x, INT y, COLORREF color )
|
||||
{
|
||||
EMRSETPIXELV emr;
|
||||
|
||||
|
@ -535,15 +535,19 @@ COLORREF CDECL EMFDRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
|
|||
emr.ptlPixel.x = x;
|
||||
emr.ptlPixel.y = y;
|
||||
emr.crColor = color;
|
||||
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
|
||||
}
|
||||
|
||||
if (EMFDRV_WriteRecord( dev, &emr.emr )) {
|
||||
RECTL bounds;
|
||||
bounds.left = bounds.right = x;
|
||||
bounds.top = bounds.bottom = y;
|
||||
EMFDRV_UpdateBBox( dev, &bounds );
|
||||
return color;
|
||||
}
|
||||
return -1;
|
||||
/***********************************************************************
|
||||
* EMFDRV_SetPixel
|
||||
*/
|
||||
COLORREF CDECL EMFDRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
|
||||
{
|
||||
RECTL bounds;
|
||||
bounds.left = bounds.right = x;
|
||||
bounds.top = bounds.bottom = y;
|
||||
EMFDRV_UpdateBBox( dev, &bounds );
|
||||
return CLR_INVALID;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
|
|
@ -60,6 +60,7 @@ extern BOOL METADC_Polyline( HDC hdc, const POINT *points,INT count) DECLSPEC_HI
|
|||
extern BOOL METADC_Rectangle( HDC hdc, INT left, INT top, INT right, INT bottom) DECLSPEC_HIDDEN;
|
||||
extern BOOL METADC_RoundRect( HDC hdc, INT left, INT top, INT right, INT bottom,
|
||||
INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
|
||||
extern BOOL METADC_SetPixel( HDC hdc, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN;
|
||||
|
||||
/* enhanced metafiles */
|
||||
extern BOOL EMFDC_AbortPath( DC_ATTR *dc_attr ) DECLSPEC_HIDDEN;
|
||||
|
@ -92,5 +93,6 @@ extern BOOL EMFDC_Rectangle( DC_ATTR *dc_attr, INT left, INT top, INT right,
|
|||
INT bottom) DECLSPEC_HIDDEN;
|
||||
extern BOOL EMFDC_RoundRect( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bottom,
|
||||
INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
|
||||
extern BOOL EMFDC_SetPixel( DC_ATTR *dc_attr, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN;
|
||||
|
||||
#endif /* __WINE_GDI_PRIVATE_H */
|
||||
|
|
|
@ -57,6 +57,19 @@ BOOL WINAPI GetCurrentPositionEx( HDC hdc, POINT *point )
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetPixel (GDI32.@)
|
||||
*/
|
||||
COLORREF WINAPI SetPixel( HDC hdc, INT x, INT y, COLORREF color )
|
||||
{
|
||||
DC_ATTR *dc_attr;
|
||||
|
||||
if (is_meta_dc( hdc )) return METADC_SetPixel( hdc, x, y, color );
|
||||
if (!(dc_attr = get_dc_attr( hdc ))) return CLR_INVALID;
|
||||
if (dc_attr->emf && !EMFDC_SetPixel( dc_attr, x, y, color )) return CLR_INVALID;
|
||||
return NtGdiSetPixel( hdc, x, y, color );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* LineTo (GDI32.@)
|
||||
*/
|
||||
|
|
|
@ -116,12 +116,11 @@ BOOL METADC_RoundRect( HDC hdc, INT left, INT top, INT right,
|
|||
}
|
||||
|
||||
/***********************************************************************
|
||||
* MFDRV_SetPixel
|
||||
* METADC_SetPixel
|
||||
*/
|
||||
COLORREF CDECL MFDRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
|
||||
BOOL METADC_SetPixel( HDC hdc, INT x, INT y, COLORREF color )
|
||||
{
|
||||
return MFDRV_MetaParam4(dev, META_SETPIXEL, x, y,HIWORD(color),
|
||||
LOWORD(color));
|
||||
return metadc_param4( hdc, META_SETPIXEL, x, y, HIWORD(color), LOWORD(color) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ static const struct gdi_dc_funcs MFDRV_Funcs =
|
|||
MFDRV_SetLayout, /* pSetLayout */
|
||||
MFDRV_SetMapMode, /* pSetMapMode */
|
||||
MFDRV_SetMapperFlags, /* pSetMapperFlags */
|
||||
MFDRV_SetPixel, /* pSetPixel */
|
||||
NULL, /* pSetPixel */
|
||||
MFDRV_SetPolyFillMode, /* pSetPolyFillMode */
|
||||
MFDRV_SetROP2, /* pSetROP2 */
|
||||
MFDRV_SetRelAbs, /* pSetRelAbs */
|
||||
|
|
|
@ -112,7 +112,6 @@ extern COLORREF CDECL MFDRV_SetDCPenColor( PHYSDEV dev, COLORREF color ) DECLSPE
|
|||
extern DWORD CDECL MFDRV_SetLayout( PHYSDEV dev, DWORD layout ) DECLSPEC_HIDDEN;
|
||||
extern INT CDECL MFDRV_SetMapMode( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN;
|
||||
extern DWORD CDECL MFDRV_SetMapperFlags( PHYSDEV dev, DWORD flags ) DECLSPEC_HIDDEN;
|
||||
extern COLORREF CDECL MFDRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN;
|
||||
extern INT CDECL MFDRV_SetPolyFillMode( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN;
|
||||
extern INT CDECL MFDRV_SetROP2( PHYSDEV dev, INT rop ) DECLSPEC_HIDDEN;
|
||||
extern INT CDECL MFDRV_SetRelAbs( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -399,15 +399,15 @@ BOOL WINAPI NtGdiRoundRect( HDC hdc, INT left, INT top, INT right,
|
|||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetPixel (GDI32.@)
|
||||
* NtGdiSetPixel (win32u.@)
|
||||
*/
|
||||
COLORREF WINAPI SetPixel( HDC hdc, INT x, INT y, COLORREF color )
|
||||
COLORREF WINAPI NtGdiSetPixel( HDC hdc, INT x, INT y, COLORREF color )
|
||||
{
|
||||
PHYSDEV physdev;
|
||||
COLORREF ret;
|
||||
DC * dc = get_dc_ptr( hdc );
|
||||
|
||||
if (!dc) return ~0;
|
||||
if (!dc) return CLR_INVALID;
|
||||
update_dc( dc );
|
||||
physdev = GET_DC_PHYSDEV( dc, pSetPixel );
|
||||
ret = physdev->funcs->pSetPixel( physdev, x, y, color );
|
||||
|
|
|
@ -3077,6 +3077,42 @@ static void test_metafile_file(void)
|
|||
ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError() = %u\n", GetLastError());
|
||||
}
|
||||
|
||||
static void test_mf_SetPixel(void)
|
||||
{
|
||||
HMETAFILE mf;
|
||||
COLORREF c;
|
||||
BOOL ret;
|
||||
HDC hdc;
|
||||
|
||||
hdc = CreateMetaFileW(NULL);
|
||||
ok(hdc != 0, "CreateEnhMetaFile failed\n");
|
||||
|
||||
c = GetPixel(hdc, 5, 5);
|
||||
ok(c == CLR_INVALID, "c = %x\n", c);
|
||||
|
||||
c = SetPixel(hdc, 5, 5, RGB(1,2,3));
|
||||
ok(c == 1, "c = %x\n", c);
|
||||
|
||||
c = SetPixel(hdc, 5, 5, RGB(1,2,3));
|
||||
ok(c == 1, "c = %x\n", c);
|
||||
|
||||
ret = SetPixelV(hdc, 5, 5, RGB(1,2,3));
|
||||
ok(ret, "ret = %x\n", ret);
|
||||
|
||||
c = GetPixel(hdc, 5, 5);
|
||||
ok(c == CLR_INVALID, "c = %x\n", c);
|
||||
|
||||
ret = Rectangle(hdc, 1, 1, 10, 10);
|
||||
ok(ret, "Rectangle failed\n");
|
||||
|
||||
c = GetPixel(hdc, 5, 5);
|
||||
ok(c == CLR_INVALID, "c = %x\n", c);
|
||||
|
||||
mf = CloseMetaFile(hdc);
|
||||
ok(mf != 0, "CloseEnhMetaFile failed\n");
|
||||
DeleteMetaFile(mf);
|
||||
}
|
||||
|
||||
static void test_enhmetafile_file(void)
|
||||
{
|
||||
char temp_path[MAX_PATH];
|
||||
|
@ -3178,6 +3214,40 @@ static void test_enhmetafile_file(void)
|
|||
ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError() = %u\n", GetLastError());
|
||||
}
|
||||
|
||||
static void test_emf_SetPixel(void)
|
||||
{
|
||||
HENHMETAFILE emf;
|
||||
COLORREF c;
|
||||
BOOL ret;
|
||||
HDC hdc;
|
||||
|
||||
hdc = CreateEnhMetaFileW(NULL, L"test.emf", NULL, NULL);
|
||||
ok(hdc != 0, "CreateEnhMetaFile failed\n");
|
||||
|
||||
c = GetPixel(hdc, 5, 5);
|
||||
ok(c == CLR_INVALID, "c = %x\n", c);
|
||||
|
||||
c = SetPixel(hdc, 5, 5, RGB(1,2,3));
|
||||
ok(c == CLR_INVALID, "c = %x\n", c);
|
||||
|
||||
ret = SetPixelV(hdc, 5, 5, RGB(1,2,3));
|
||||
todo_wine
|
||||
ok(!ret, "ret = %x\n", ret);
|
||||
|
||||
c = GetPixel(hdc, 5, 5);
|
||||
ok(c == CLR_INVALID, "c = %x\n", c);
|
||||
|
||||
ret = Rectangle(hdc, 1, 1, 10, 10);
|
||||
ok(ret, "Rectangle failed\n");
|
||||
|
||||
c = GetPixel(hdc, 5, 5);
|
||||
ok(c == CLR_INVALID, "c = %x\n", c);
|
||||
|
||||
emf = CloseEnhMetaFile(hdc);
|
||||
ok(emf != 0, "CloseEnhMetaFile failed\n");
|
||||
DeleteEnhMetaFile(emf);
|
||||
}
|
||||
|
||||
static void test_CopyMetaFile(void)
|
||||
{
|
||||
HDC hdcMetafile;
|
||||
|
@ -6272,6 +6342,7 @@ START_TEST(metafile)
|
|||
test_emf_WorldTransform();
|
||||
test_emf_text_extents();
|
||||
test_enhmetafile_file();
|
||||
test_emf_SetPixel();
|
||||
|
||||
/* For win-format metafiles (mfdrv) */
|
||||
test_mf_SaveDC();
|
||||
|
@ -6286,6 +6357,7 @@ START_TEST(metafile)
|
|||
test_mf_GetPath();
|
||||
test_mf_SetLayout();
|
||||
test_metafile_file();
|
||||
test_mf_SetPixel();
|
||||
|
||||
/* For metafile conversions */
|
||||
test_mf_conversions();
|
||||
|
|
Loading…
Reference in New Issue