Module: wine Branch: master Commit: aa390e840b025c41524439093fb268f259b1190c URL: http://source.winehq.org/git/wine.git/?a=commit;h=aa390e840b025c41524439093f...
Author: Stefan Dösinger stefan@codeweavers.com Date: Fri Dec 7 16:12:26 2007 +0100
gdi32, winex11drv: Add a test for compatible bitmap depths.
---
dlls/gdi32/tests/bitmap.c | 36 +++++++++++++++++++++++++----------- dlls/winex11.drv/bitmap.c | 8 ++++---- 2 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c index 6f87e29..49dbb4e 100644 --- a/dlls/gdi32/tests/bitmap.c +++ b/dlls/gdi32/tests/bitmap.c @@ -1555,7 +1555,8 @@ static void test_select_object(void) { HDC hdc; HBITMAP hbm, hbm_old; - INT planes, bpp; + INT planes, bpp, i; + DWORD depths[] = {8, 15, 16, 24, 32};
hdc = GetDC(0); ok(hdc != 0, "GetDC(0) failed\n"); @@ -1594,17 +1595,30 @@ static void test_select_object(void)
DeleteObject(hbm);
- /* test a color bitmap that doesn't match the dc's bpp */ - planes = GetDeviceCaps(hdc, PLANES); - bpp = GetDeviceCaps(hdc, BITSPIXEL) == 24 ? 8 : 24; - - hbm = CreateBitmap(10, 10, planes, bpp, NULL); - ok(hbm != 0, "CreateBitmap failed\n"); - - hbm_old = SelectObject(hdc, hbm); - ok(hbm_old == 0, "SelectObject should fail\n"); + for(i = 0; i < sizeof(depths)/sizeof(depths[0]); i++) { + /* test a color bitmap to dc bpp matching */ + planes = GetDeviceCaps(hdc, PLANES); + bpp = GetDeviceCaps(hdc, BITSPIXEL); + + hbm = CreateBitmap(10, 10, planes, depths[i], NULL); + ok(hbm != 0, "CreateBitmap failed\n"); + + hbm_old = SelectObject(hdc, hbm); + if(depths[i] == bpp || + (bpp == 16 && depths[i] == 15) /* 16 and 15 bpp are compatible */ + ) { + ok(hbm_old != 0, "SelectObject failed, BITSPIXEL: %d, created depth: %d\n", bpp, depths[i]); + SelectObject(hdc, hbm_old); + } else { + if(bpp == 24 && depths[i] == 32) { + todo_wine ok(hbm_old == 0, "SelectObject should fail. BITSPIXELS: %d, created depth: %d\n", bpp, depths[i]); + } else { + ok(hbm_old == 0, "SelectObject should fail. BITSPIXELS: %d, created depth: %d\n", bpp, depths[i]); + } + }
- DeleteObject(hbm); + DeleteObject(hbm); + }
DeleteDC(hdc); } diff --git a/dlls/winex11.drv/bitmap.c b/dlls/winex11.drv/bitmap.c index 6d4180b..e1a26d4 100644 --- a/dlls/winex11.drv/bitmap.c +++ b/dlls/winex11.drv/bitmap.c @@ -124,10 +124,10 @@ BOOL X11DRV_CreateBitmap( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, LPVOID bmBit /* check if bpp is compatible with screen depth */ if (!((bitmap.bmBitsPixel == 1) || (bitmap.bmBitsPixel == screen_depth) || - (bitmap.bmBitsPixel == 24 && screen_depth == 32) || - (bitmap.bmBitsPixel == 32 && screen_depth == 24) || - (bitmap.bmBitsPixel == 15 && screen_depth == 16) || - (bitmap.bmBitsPixel == 16 && screen_depth == 15))) + (bitmap.bmBitsPixel == 24 && screen_depth == 32) || /* FIXME: Not compatible */ + (bitmap.bmBitsPixel == 32 && screen_depth == 24) || /* FIXME: Not compatible */ + (bitmap.bmBitsPixel == 15 && screen_depth == 16) || /* Confirmed by tests */ + (bitmap.bmBitsPixel == 16 && screen_depth == 15))) /* TODO: Confirm this */ { ERR("Trying to make bitmap with planes=%d, bpp=%d\n", bitmap.bmPlanes, bitmap.bmBitsPixel);