Module: wine Branch: master Commit: 0d30daa8e4221a40a295c6714777b05959570af3 URL: http://source.winehq.org/git/wine.git/?a=commit;h=0d30daa8e4221a40a295c67147...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Feb 4 14:36:18 2008 +0100
winex11: Abstract the depth->bpp conversion and use it in X11DRV_DIB_CreateDIBFromPixmap.
---
dlls/winex11.drv/dib.c | 2 +- dlls/winex11.drv/x11drv.h | 2 + dlls/winex11.drv/x11drv_main.c | 61 +++++++++++++++++++++------------------- 3 files changed, 35 insertions(+), 30 deletions(-)
diff --git a/dlls/winex11.drv/dib.c b/dlls/winex11.drv/dib.c index 2f0bbc9..b05d904 100644 --- a/dlls/winex11.drv/dib.c +++ b/dlls/winex11.drv/dib.c @@ -4856,7 +4856,7 @@ HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc) * Create an HBITMAP with the same dimensions and BPP as the pixmap, * and make it a container for the pixmap passed. */ - hBmp = CreateBitmap( width, height, 1, depth, NULL ); + if (!(hBmp = CreateBitmap( width, height, 1, depth_to_bpp(depth), NULL ))) return 0;
/* force bitmap to be owned by a screen DC */ hdcMem = CreateCompatibleDC( hdc ); diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index ffd0469..7af082c 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -463,6 +463,8 @@ extern BOOL X11DRV_IsSolidColor(COLORREF color); extern COLORREF X11DRV_PALETTE_ToLogical(int pixel); extern int X11DRV_PALETTE_ToPhysical(X11DRV_PDEVICE *physDev, COLORREF color);
+extern unsigned int depth_to_bpp( unsigned int depth ); + /* GDI escapes */
#define X11DRV_ESCAPE 6789 diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index 8d822ef..6f682c2 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -278,6 +278,37 @@ void wine_tsx11_unlock(void)
/*********************************************************************** + * depth_to_bpp + * + * Convert X11-reported depth to the BPP value that Windows apps expect to see. + */ +unsigned int depth_to_bpp( unsigned int depth ) +{ + switch (depth) + { + case 1: + case 8: + return depth; + case 15: + case 16: + return 16; + case 24: + /* This is not necessarily right. X11 always has 24 bits per pixel, but it can run + * with 24 bit framebuffers and 32 bit framebuffers. It doesn't make any difference + * for windowing, but gl applications can get visuals with alpha channels. So we + * should check the framebuffer and/or opengl formats available to find out what the + * framebuffer actually does + */ + case 32: + return 32; + default: + FIXME( "Unexpected X11 depth %d bpp, what to report to app?\n", depth ); + return depth; + } +} + + +/*********************************************************************** * get_config_key * * Get a config key from either the app-specific or the default config @@ -491,35 +522,7 @@ static BOOL process_attach(void) screen_depth = desktop_vi->depth; XFree(desktop_vi); } - - switch(screen_depth) { - case 8: - screen_bpp = 8; - break; - - case 15: - /* In GetDeviceCaps MSDN description explicitly states that - * in 15 bpp mode 16 is returned. - */ - /* fall through */ - case 16: - screen_bpp = 16; - break; - - case 24: - /* This is not necessarily right. X11 always has 24 bits per pixel, but it can run - * with 24 bit framebuffers and 32 bit framebuffers. It doesn't make any difference - * for windowing, but gl applications can get visuals with alpha channels. So we - * should check the framebuffer and/or opengl formats available to find out what the - * framebuffer actually does - */ - screen_bpp = 32; - break; - - default: - FIXME("Unexpected X11 depth %d bpp, what to report to app?\n", screen_depth); - screen_bpp = screen_depth; - } + screen_bpp = depth_to_bpp( screen_depth );
XInternAtoms( display, (char **)atom_names, NB_XATOMS - FIRST_XATOM, False, X11DRV_Atoms );