Huw Davies : gdi32: Implement SetPixel.
Alexandre Julliard
julliard at winehq.org
Wed Oct 19 14:05:25 CDT 2011
Module: wine
Branch: master
Commit: 2ac6a1bbf6eb192a906f31837719e3c947979b0e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2ac6a1bbf6eb192a906f31837719e3c947979b0e
Author: Huw Davies <huw at codeweavers.com>
Date: Wed Oct 19 12:41:55 2011 +0100
gdi32: Implement SetPixel.
---
dlls/gdi32/dibdrv/dc.c | 2 +-
dlls/gdi32/dibdrv/dibdrv.h | 1 +
dlls/gdi32/dibdrv/graphics.c | 40 ++++++++++++++++++++++++++++++++++++++++
dlls/gdi32/dibdrv/objects.c | 6 ------
dlls/gdi32/gdi_private.h | 6 ++++++
dlls/gdi32/tests/bitmap.c | 38 +++++++++++++++++++-------------------
dlls/gdi32/tests/palette.c | 1 +
7 files changed, 68 insertions(+), 26 deletions(-)
diff --git a/dlls/gdi32/dibdrv/dc.c b/dlls/gdi32/dibdrv/dc.c
index e832a20..877c132 100644
--- a/dlls/gdi32/dibdrv/dc.c
+++ b/dlls/gdi32/dibdrv/dc.c
@@ -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 */
diff --git a/dlls/gdi32/dibdrv/dibdrv.h b/dlls/gdi32/dibdrv/dibdrv.h
index b23e931..c73bc8e 100644
--- a/dlls/gdi32/dibdrv/dibdrv.h
+++ b/dlls/gdi32/dibdrv/dibdrv.h
@@ -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;
diff --git a/dlls/gdi32/dibdrv/graphics.c b/dlls/gdi32/dibdrv/graphics.c
index f8b3f8a..b68b17e 100644
--- a/dlls/gdi32/dibdrv/graphics.c
+++ b/dlls/gdi32/dibdrv/graphics.c
@@ -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;
+}
diff --git a/dlls/gdi32/dibdrv/objects.c b/dlls/gdi32/dibdrv/objects.c
index a1f6829..8d84284 100644
--- a/dlls/gdi32/dibdrv/objects.c
+++ b/dlls/gdi32/dibdrv/objects.c
@@ -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
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index 67bdd2c..0d38efe 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -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;
diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c
index a412cc9..bf18b9b 100644
--- a/dlls/gdi32/tests/bitmap.c
+++ b/dlls/gdi32/tests/bitmap.c
@@ -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;
diff --git a/dlls/gdi32/tests/palette.c b/dlls/gdi32/tests/palette.c
index 039be59..0a5822a 100644
--- a/dlls/gdi32/tests/palette.c
+++ b/dlls/gdi32/tests/palette.c
@@ -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 );
More information about the wine-cvs
mailing list