winex11: Set the reported screen bpp based on the available pixmap formats.

This commit is contained in:
Alexandre Julliard 2011-07-06 12:38:31 +02:00
parent 99e422c975
commit 2e4b0b1ef4
4 changed files with 18 additions and 31 deletions

View file

@ -5053,7 +5053,7 @@ HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc)
if (!XGetGeometry(gdi_display, pixmap, &root, &x, &y, &width, &height,
&border_width, &depth)) depth = 0;
wine_tsx11_unlock();
if (!depth) return 0;
if (!pixmap_formats[depth]) return 0;
TRACE("\tPixmap properties: width=%d, height=%d, depth=%d\n",
width, height, depth);
@ -5062,7 +5062,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.
*/
if (!(hBmp = CreateBitmap( width, height, 1, depth_to_bpp(depth), NULL ))) return 0;
if (!(hBmp = CreateBitmap( width, height, 1, pixmap_formats[depth]->bits_per_pixel, NULL ))) return 0;
/* force bitmap to be owned by a screen DC */
hdcMem = CreateCompatibleDC( hdc );

View file

@ -240,10 +240,8 @@ INT CDECL X11DRV_GetDeviceCaps( X11DRV_PDEVICE *physDev, INT cap )
* BITSPIXEL: 8 -> COLORRES: 18
* BITSPIXEL: 16 -> COLORRES: 16
* BITSPIXEL: 24 -> COLORRES: 24
* (note that depth_to_bpp never chooses a bpp of 24)
* BITSPIXEL: 32 -> COLORRES: 24 */
return (screen_bpp <= 8) ? 18 :
(screen_bpp == 32) ? 24 : screen_bpp;
return (screen_bpp <= 8) ? 18 : min( 24, screen_bpp );
case RASTERCAPS:
return (RC_BITBLT | RC_BANDING | RC_SCALING | RC_BITMAP64 | RC_DI_BITMAP |
RC_DIBTODEV | RC_BIGFONT | RC_STRETCHBLT | RC_STRETCHDIB | RC_DEVBITS |

View file

@ -503,8 +503,6 @@ extern COLORREF X11DRV_PALETTE_GetColor( X11DRV_PDEVICE *physDev, COLORREF color
extern int X11DRV_PALETTE_LookupPixel(ColorShifts *shifts, COLORREF color) DECLSPEC_HIDDEN;
extern void X11DRV_PALETTE_ComputeColorShifts(ColorShifts *shifts, unsigned long redMask, unsigned long greenMask, unsigned long blueMask) DECLSPEC_HIDDEN;
extern unsigned int depth_to_bpp( unsigned int depth ) DECLSPEC_HIDDEN;
/* GDI escapes */
#define X11DRV_ESCAPE 6789
@ -589,6 +587,7 @@ static inline size_t get_property_size( int format, unsigned long count )
}
extern Visual *visual DECLSPEC_HIDDEN;
extern XPixmapFormatValues **pixmap_formats DECLSPEC_HIDDEN;
extern Window root_window DECLSPEC_HIDDEN;
extern int clipping_cursor DECLSPEC_HIDDEN;
extern unsigned int screen_width DECLSPEC_HIDDEN;

View file

@ -69,6 +69,7 @@ static CRITICAL_SECTION X11DRV_CritSection = { &critsect_debug, -1, 0, 0, 0, 0 }
static Screen *screen;
Visual *visual;
XPixmapFormatValues **pixmap_formats;
unsigned int screen_width;
unsigned int screen_height;
unsigned int screen_bpp;
@ -324,33 +325,21 @@ void CDECL wine_tsx11_unlock(void)
/***********************************************************************
* depth_to_bpp
*
* Convert X11-reported depth to the BPP value that Windows apps expect to see.
* init_pixmap_formats
*/
unsigned int depth_to_bpp( unsigned int depth )
static void init_pixmap_formats( Display *display )
{
switch (depth)
int i, count, max = 32;
XPixmapFormatValues *formats = XListPixmapFormats( display, &count );
for (i = 0; i < count; i++)
{
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;
TRACE( "depth %u, bpp %u, pad %u\n",
formats[i].depth, formats[i].bits_per_pixel, formats[i].scanline_pad );
if (formats[i].depth > max) max = formats[i].depth;
}
pixmap_formats = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pixmap_formats) * (max + 1) );
for (i = 0; i < count; i++) pixmap_formats[formats[i].depth] = &formats[i];
}
@ -579,7 +568,8 @@ static BOOL process_attach(void)
}
}
if (!screen_depth) screen_depth = DefaultDepthOfScreen( screen );
screen_bpp = depth_to_bpp( screen_depth );
init_pixmap_formats( display );
screen_bpp = pixmap_formats[screen_depth]->bits_per_pixel;
XInternAtoms( display, (char **)atom_names, NB_XATOMS - FIRST_XATOM, False, X11DRV_Atoms );