Commit 2ac6a1bb authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

gdi32: Implement SetPixel.

parent ddbaa949
......@@ -606,7 +606,7 @@ const struct gdi_dc_funcs dib_driver =
NULL, /* pSetLayout */
NULL, /* pSetMapMode */
NULL, /* pSetMapperFlags */
NULL, /* pSetPixel */
dibdrv_SetPixel, /* pSetPixel */
NULL, /* pSetPixelFormat */
NULL, /* pSetPolyFillMode */
dibdrv_SetROP2, /* pSetROP2 */
......
......@@ -120,6 +120,7 @@ extern HBRUSH dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush ) DECLSPEC_HIDDEN
extern HPEN dibdrv_SelectPen( PHYSDEV dev, HPEN hpen ) DECLSPEC_HIDDEN;
extern COLORREF dibdrv_SetDCBrushColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF dibdrv_SetDCPenColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF dibdrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL dibdrv_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst,
PHYSDEV src_dev, struct bitblt_coords *src, DWORD rop ) DECLSPEC_HIDDEN;
......
......@@ -240,3 +240,43 @@ BOOL dibdrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
return TRUE;
}
/***********************************************************************
* dibdrv_SetPixel
*/
COLORREF dibdrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
{
dibdrv_physdev *pdev = get_dibdrv_pdev( dev );
int i;
POINT pt;
DWORD pixel;
const WINEREGION *clip = get_wine_region( pdev->clip );
TRACE( "(%p, %d, %d, %08x)\n", dev, x, y, color );
pt.x = x;
pt.y = y;
LPtoDP( dev->hdc, &pt, 1 );
/* SetPixel doesn't do the 1bpp massaging like other fg colors */
pixel = get_pixel_color( pdev, color, FALSE );
color = pdev->dib.funcs->pixel_to_colorref( &pdev->dib, pixel );
for (i = 0; i < clip->numRects; i++)
{
if (pt_in_rect( clip->rects + i, pt ))
{
RECT rect;
rect.left = pt.x;
rect.top = pt.y;
rect.right = rect.left + 1;
rect.bottom = rect.top + 1;
pdev->dib.funcs->solid_rects( &pdev->dib, 1, &rect, 0, pixel );
break;
}
}
release_wine_region( pdev->clip );
return color;
}
......@@ -259,12 +259,6 @@ static inline void order_end_points(int *s, int *e)
}
}
static inline BOOL pt_in_rect( const RECT *rect, const POINT *pt )
{
return ((pt->x >= rect->left) && (pt->x < rect->right) &&
(pt->y >= rect->top) && (pt->y < rect->bottom));
}
#define Y_INCREASING_MASK 0x0f
#define X_INCREASING_MASK 0xc3
#define X_MAJOR_MASK 0x99
......
......@@ -480,6 +480,12 @@ static inline void offset_rect( RECT *rect, int offset_x, int offset_y )
rect->bottom += offset_y;
}
static inline BOOL pt_in_rect( const RECT *rect, POINT pt )
{
return ((pt.x >= rect->left) && (pt.x < rect->right) &&
(pt.y >= rect->top) && (pt.y < rect->bottom));
}
static inline void get_bounding_rect( RECT *rect, int x, int y, int width, int height )
{
rect->left = x;
......
......@@ -582,17 +582,17 @@ static void test_dibsections(void)
test_color(hdcmem, DIBINDEX(0), c0, 0, 1);
test_color(hdcmem, DIBINDEX(1), c1, 0, 1);
test_color(hdcmem, DIBINDEX(2), c0, 1, 1);
test_color(hdcmem, PALETTEINDEX(0), c0, 1, 1);
test_color(hdcmem, PALETTEINDEX(1), c0, 1, 1);
test_color(hdcmem, PALETTEINDEX(2), c0, 1, 1);
test_color(hdcmem, DIBINDEX(2), c0, 0, 1);
test_color(hdcmem, PALETTEINDEX(0), c0, 0, 1);
test_color(hdcmem, PALETTEINDEX(1), c0, 0, 1);
test_color(hdcmem, PALETTEINDEX(2), c0, 0, 1);
test_color(hdcmem, PALETTERGB(pbmi->bmiColors[0].rgbRed, pbmi->bmiColors[0].rgbGreen,
pbmi->bmiColors[0].rgbBlue), c0, 1, 1);
pbmi->bmiColors[0].rgbBlue), c0, 0, 1);
test_color(hdcmem, PALETTERGB(pbmi->bmiColors[1].rgbRed, pbmi->bmiColors[1].rgbGreen,
pbmi->bmiColors[1].rgbBlue), c1, 1, 1);
test_color(hdcmem, PALETTERGB(0, 0, 0), c0, 1, 1);
test_color(hdcmem, PALETTERGB(0xff, 0xff, 0xff), c0, 1, 1);
test_color(hdcmem, PALETTERGB(0, 0, 0xfe), c1, 1, 1);
pbmi->bmiColors[1].rgbBlue), c1, 0, 1);
test_color(hdcmem, PALETTERGB(0, 0, 0), c0, 0, 1);
test_color(hdcmem, PALETTERGB(0xff, 0xff, 0xff), c0, 0, 1);
test_color(hdcmem, PALETTERGB(0, 0, 0xfe), c1, 0, 1);
SelectObject(hdcmem, oldbm);
DeleteObject(hdib);
......@@ -706,20 +706,20 @@ static void test_dibsections(void)
test_color(hdcmem, DIBINDEX(0), c0, 0, 1);
test_color(hdcmem, DIBINDEX(1), c1, 0, 1);
test_color(hdcmem, DIBINDEX(2), c0, 1, 1);
test_color(hdcmem, DIBINDEX(2), c0, 0, 1);
test_color(hdcmem, PALETTEINDEX(0), c0, 0, 1);
test_color(hdcmem, PALETTEINDEX(1), c1, 0, 1);
test_color(hdcmem, PALETTEINDEX(2), c0, 1, 1);
test_color(hdcmem, PALETTEINDEX(2), c0, 0, 1);
test_color(hdcmem, PALETTERGB(plogpal->palPalEntry[0].peRed, plogpal->palPalEntry[0].peGreen,
plogpal->palPalEntry[0].peBlue), c0, 1, 1);
plogpal->palPalEntry[0].peBlue), c0, 0, 1);
test_color(hdcmem, PALETTERGB(plogpal->palPalEntry[1].peRed, plogpal->palPalEntry[1].peGreen,
plogpal->palPalEntry[1].peBlue), c1, 1, 1);
test_color(hdcmem, PALETTERGB(0, 0, 0), c1, 1, 1);
test_color(hdcmem, PALETTERGB(0xff, 0xff, 0xff), c0, 1, 1);
test_color(hdcmem, PALETTERGB(0, 0, 0xfe), c0, 1, 1);
test_color(hdcmem, PALETTERGB(0, 1, 0), c1, 1, 1);
test_color(hdcmem, PALETTERGB(0x3f, 0, 0x3f), c1, 1, 1);
test_color(hdcmem, PALETTERGB(0x40, 0, 0x40), c0, 1, 1);
plogpal->palPalEntry[1].peBlue), c1, 0, 1);
test_color(hdcmem, PALETTERGB(0, 0, 0), c1, 0, 1);
test_color(hdcmem, PALETTERGB(0xff, 0xff, 0xff), c0, 0, 1);
test_color(hdcmem, PALETTERGB(0, 0, 0xfe), c0, 0, 1);
test_color(hdcmem, PALETTERGB(0, 1, 0), c1, 0, 1);
test_color(hdcmem, PALETTERGB(0x3f, 0, 0x3f), c1, 0, 1);
test_color(hdcmem, PALETTERGB(0x40, 0, 0x40), c0, 0, 1);
/* Bottom and 2nd row from top green, everything else magenta */
bits[0] = bits[1] = 0xff;
......
......@@ -109,6 +109,7 @@ static void test_DIB_PAL_COLORS(void) {
SetPixel( memhdc, 0, 0, setColor );
chkColor = RGB( logpalettedata[3].peRed, logpalettedata[3].peGreen, logpalettedata[3].peBlue );
getColor = GetPixel( memhdc, 0, 0 );
todo_wine /* this will be removed with the GetPixel patch */
ok( getColor == chkColor, "getColor=%08X\n", (UINT)getColor );
SelectPalette( memhdc, hpalOld, FALSE );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment