Commit daf776fd authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

When we blit with a monochrome dibsection as the source we should use

the colour table of that dib. Added a test for this.
parent 4543c278
...@@ -157,8 +157,8 @@ static void test_createdibitmap(void) ...@@ -157,8 +157,8 @@ static void test_createdibitmap(void)
static void test_dibsections(void) static void test_dibsections(void)
{ {
HDC hdc, hdcmem; HDC hdc, hdcmem, hdcmem2;
HBITMAP hdib, oldbm; HBITMAP hdib, oldbm, hdib2, oldbm2;
char bmibuf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)]; char bmibuf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf; BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf;
BYTE *bits; BYTE *bits;
...@@ -167,6 +167,7 @@ static void test_dibsections(void) ...@@ -167,6 +167,7 @@ static void test_dibsections(void)
char logpalbuf[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)]; char logpalbuf[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)];
LOGPALETTE *plogpal = (LOGPALETTE*)logpalbuf; LOGPALETTE *plogpal = (LOGPALETTE*)logpalbuf;
WORD *index; WORD *index;
DWORD *bits32;
HPALETTE hpal, oldpal; HPALETTE hpal, oldpal;
hdc = GetDC(0); hdc = GetDC(0);
...@@ -234,6 +235,25 @@ static void test_dibsections(void) ...@@ -234,6 +235,25 @@ static void test_dibsections(void)
rgb[0].rgbRed, rgb[0].rgbGreen, rgb[0].rgbBlue, rgb[0].rgbReserved, rgb[0].rgbRed, rgb[0].rgbGreen, rgb[0].rgbBlue, rgb[0].rgbReserved,
rgb[1].rgbRed, rgb[1].rgbGreen, rgb[1].rgbBlue, rgb[1].rgbReserved); rgb[1].rgbRed, rgb[1].rgbGreen, rgb[1].rgbBlue, rgb[1].rgbReserved);
/* Bottom and 2nd row from top green, everything else magenta */
bits[0] = bits[1] = 0xff;
bits[13 * 4] = bits[13*4 + 1] = 0xff;
pbmi->bmiHeader.biBitCount = 32;
hdib2 = CreateDIBSection(NULL, pbmi, DIB_RGB_COLORS, (void **)&bits32, NULL, 0);
ok(hdib2 != NULL, "CreateDIBSection failed\n");
hdcmem2 = CreateCompatibleDC(hdc);
oldbm2 = SelectObject(hdcmem2, hdib2);
BitBlt(hdcmem2, 0, 0, 16,16, hdcmem, 0, 0, SRCCOPY);
ok(bits32[0] == 0xff00, "lower left pixel is %08lx\n", bits32[0]);
ok(bits32[17] == 0xff00ff, "bottom but one, left pixel is %08lx\n", bits32[17]);
SelectObject(hdcmem2, oldbm2);
DeleteObject(hdib2);
SelectObject(hdcmem, oldbm); SelectObject(hdcmem, oldbm);
DeleteObject(hdib); DeleteObject(hdib);
......
...@@ -563,6 +563,24 @@ static int perfect_graphics(void) ...@@ -563,6 +563,24 @@ static int perfect_graphics(void)
return perfect; return perfect;
} }
static void get_colors(X11DRV_PDEVICE *physDevDst, X11DRV_PDEVICE *physDevSrc,
int *fg, int *bg)
{
RGBQUAD rgb[2];
*fg = physDevDst->textPixel;
*bg = physDevDst->backgroundPixel;
if(physDevSrc->depth == 1) {
if(GetDIBColorTable(physDevSrc->hdc, 0, 2, rgb) == 2) {
DWORD logcolor;
logcolor = RGB(rgb[0].rgbRed, rgb[0].rgbGreen, rgb[0].rgbBlue);
*fg = X11DRV_PALETTE_ToPhysical( physDevDst, logcolor );
logcolor = RGB(rgb[1].rgbRed, rgb[1].rgbGreen,rgb[1].rgbBlue);
*bg = X11DRV_PALETTE_ToPhysical( physDevDst, logcolor );
}
}
}
/*********************************************************************** /***********************************************************************
* BITBLT_StretchRow * BITBLT_StretchRow
* *
...@@ -868,6 +886,7 @@ static int BITBLT_GetSrcAreaStretch( X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE ...@@ -868,6 +886,7 @@ static int BITBLT_GetSrcAreaStretch( X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE
XImage *imageSrc, *imageDst; XImage *imageSrc, *imageDst;
RECT rectSrc = *visRectSrc; RECT rectSrc = *visRectSrc;
RECT rectDst = *visRectDst; RECT rectDst = *visRectDst;
int fg, bg;
if (widthSrc < 0) xSrc += widthSrc; if (widthSrc < 0) xSrc += widthSrc;
if (widthDst < 0) xDst += widthDst; if (widthDst < 0) xDst += widthDst;
...@@ -882,6 +901,7 @@ static int BITBLT_GetSrcAreaStretch( X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE ...@@ -882,6 +901,7 @@ static int BITBLT_GetSrcAreaStretch( X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE
rectDst.top -= yDst; rectDst.top -= yDst;
rectDst.bottom -= yDst; rectDst.bottom -= yDst;
get_colors(physDevDst, physDevSrc, &fg, &bg);
/* FIXME: avoid BadMatch errors */ /* FIXME: avoid BadMatch errors */
imageSrc = XGetImage( gdi_display, physDevSrc->drawable, imageSrc = XGetImage( gdi_display, physDevSrc->drawable,
physDevSrc->org.x + visRectSrc->left, physDevSrc->org.x + visRectSrc->left,
...@@ -893,9 +913,8 @@ static int BITBLT_GetSrcAreaStretch( X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE ...@@ -893,9 +913,8 @@ static int BITBLT_GetSrcAreaStretch( X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE
rectDst.bottom - rectDst.top, physDevDst->depth ); rectDst.bottom - rectDst.top, physDevDst->depth );
BITBLT_StretchImage( imageSrc, imageDst, widthSrc, heightSrc, BITBLT_StretchImage( imageSrc, imageDst, widthSrc, heightSrc,
widthDst, heightDst, &rectSrc, &rectDst, widthDst, heightDst, &rectSrc, &rectDst,
physDevDst->textPixel, physDevDst->depth != 1 ? fg, physDevDst->depth != 1 ?
physDevDst->backgroundPixel : bg : physDevSrc->backgroundPixel,
physDevSrc->backgroundPixel,
GetStretchBltMode(physDevDst->hdc) ); GetStretchBltMode(physDevDst->hdc) );
XPutImage( gdi_display, pixmap, gc, imageDst, 0, 0, 0, 0, XPutImage( gdi_display, pixmap, gc, imageDst, 0, 0, 0, 0,
rectDst.right - rectDst.left, rectDst.bottom - rectDst.top ); rectDst.right - rectDst.left, rectDst.bottom - rectDst.top );
...@@ -919,6 +938,7 @@ static int BITBLT_GetSrcArea( X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE *physDe ...@@ -919,6 +938,7 @@ static int BITBLT_GetSrcArea( X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE *physDe
int exposures = 0; int exposures = 0;
INT width = visRectSrc->right - visRectSrc->left; INT width = visRectSrc->right - visRectSrc->left;
INT height = visRectSrc->bottom - visRectSrc->top; INT height = visRectSrc->bottom - visRectSrc->top;
int fg, bg;
if (physDevSrc->depth == physDevDst->depth) if (physDevSrc->depth == physDevDst->depth)
{ {
...@@ -976,17 +996,19 @@ static int BITBLT_GetSrcArea( X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE *physDe ...@@ -976,17 +996,19 @@ static int BITBLT_GetSrcArea( X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE *physDe
{ {
if (physDevSrc->depth == 1) /* monochrome -> color */ if (physDevSrc->depth == 1) /* monochrome -> color */
{ {
get_colors(physDevDst, physDevSrc, &fg, &bg);
if (X11DRV_PALETTE_XPixelToPalette) if (X11DRV_PALETTE_XPixelToPalette)
{ {
XSetBackground( gdi_display, gc, XSetBackground( gdi_display, gc,
X11DRV_PALETTE_XPixelToPalette[physDevDst->textPixel] ); X11DRV_PALETTE_XPixelToPalette[fg] );
XSetForeground( gdi_display, gc, XSetForeground( gdi_display, gc,
X11DRV_PALETTE_XPixelToPalette[physDevDst->backgroundPixel]); X11DRV_PALETTE_XPixelToPalette[bg]);
} }
else else
{ {
XSetBackground( gdi_display, gc, physDevDst->textPixel ); XSetBackground( gdi_display, gc, fg );
XSetForeground( gdi_display, gc, physDevDst->backgroundPixel ); XSetForeground( gdi_display, gc, bg );
} }
XCopyPlane( gdi_display, physDevSrc->drawable, pixmap, gc, XCopyPlane( gdi_display, physDevSrc->drawable, pixmap, gc,
physDevSrc->org.x + visRectSrc->left, physDevSrc->org.x + visRectSrc->left,
...@@ -1399,11 +1421,15 @@ static BOOL BITBLT_InternalStretchBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT ...@@ -1399,11 +1421,15 @@ static BOOL BITBLT_InternalStretchBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT
wine_tsx11_unlock(); wine_tsx11_unlock();
return TRUE; return TRUE;
} }
if (physDevSrc->depth == 1) if (physDevSrc->depth == 1)
{ {
int fg, bg;
get_colors(physDevDst, physDevSrc, &fg, &bg);
wine_tsx11_lock(); wine_tsx11_lock();
XSetBackground( gdi_display, physDevDst->gc, physDevDst->textPixel );
XSetForeground( gdi_display, physDevDst->gc, physDevDst->backgroundPixel ); XSetBackground( gdi_display, physDevDst->gc, fg );
XSetForeground( gdi_display, physDevDst->gc, bg );
XSetFunction( gdi_display, physDevDst->gc, GXcopy ); XSetFunction( gdi_display, physDevDst->gc, GXcopy );
XCopyPlane( gdi_display, physDevSrc->drawable, XCopyPlane( gdi_display, physDevSrc->drawable,
physDevDst->drawable, physDevDst->gc, physDevDst->drawable, physDevDst->gc,
......
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