From: Alexandros Frantzis alexandros.frantzis@collabora.com
--- dlls/win32u/dibdrv/dc.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/dlls/win32u/dibdrv/dc.c b/dlls/win32u/dibdrv/dc.c index 637b92f5256..0d53915b2ba 100644 --- a/dlls/win32u/dibdrv/dc.c +++ b/dlls/win32u/dibdrv/dc.c @@ -426,17 +426,8 @@ static const struct { 16, 5, 0, 6, 5, 5, 11, 0, 0, 16, 16, 8 }, };
-/********************************************************************** - * dibdrv_wglDescribePixelFormat - */ -static int dibdrv_wglDescribePixelFormat( HDC hdc, int fmt, UINT size, PIXELFORMATDESCRIPTOR *descr ) +static void describe_pixel_format( int fmt, PIXELFORMATDESCRIPTOR *descr ) { - int ret = ARRAY_SIZE( pixel_formats ); - - if (!descr) return ret; - if (fmt <= 0 || fmt > ret) return 0; - if (size < sizeof(*descr)) return 0; - memset( descr, 0, sizeof(*descr) ); descr->nSize = sizeof(*descr); descr->nVersion = 1; @@ -460,7 +451,6 @@ static int dibdrv_wglDescribePixelFormat( HDC hdc, int fmt, UINT size, PIXELFORM descr->cStencilBits = pixel_formats[fmt - 1].stencil_bits; descr->cAuxBuffers = 0; descr->iLayerType = PFD_MAIN_PLANE; - return ret; }
/*********************************************************************** @@ -506,7 +496,8 @@ static struct wgl_context *dibdrv_wglCreateContext( HDC hdc ) int format = dibdrv_wglGetPixelFormat( hdc );
if (!format) format = 1; - if (!dibdrv_wglDescribePixelFormat( hdc, format, sizeof(descr), &descr )) return NULL; + if (format <= 0 || format > ARRAY_SIZE( pixel_formats )) return NULL; + describe_pixel_format( format, &descr );
if (!osmesa_funcs) return NULL; return osmesa_funcs->create_context( hdc, &descr ); @@ -585,19 +576,38 @@ static BOOL dibdrv_wglSwapBuffers( HDC hdc ) return TRUE; }
+/*********************************************************************** + * dibdrv_get_pixel_formats + */ +static void dibdrv_get_pixel_formats( struct wgl_pixel_format *formats, + UINT max_formats, UINT *num_formats, + UINT *num_onscreen_formats ) +{ + UINT num_pixel_formats = ARRAY_SIZE( pixel_formats ); + UINT i; + + if (formats) + { + for (i = 0; i < min( max_formats, num_pixel_formats ); ++i) + describe_pixel_format( i + 1, &formats[i].pfd ); + } + *num_formats = *num_onscreen_formats = num_pixel_formats; +} + static struct opengl_funcs opengl_funcs = { { dibdrv_wglCopyContext, /* p_wglCopyContext */ dibdrv_wglCreateContext, /* p_wglCreateContext */ dibdrv_wglDeleteContext, /* p_wglDeleteContext */ - dibdrv_wglDescribePixelFormat, /* p_wglDescribePixelFormat */ + NULL, /* p_wglDescribePixelFormat */ dibdrv_wglGetPixelFormat, /* p_wglGetPixelFormat */ dibdrv_wglGetProcAddress, /* p_wglGetProcAddress */ dibdrv_wglMakeCurrent, /* p_wglMakeCurrent */ dibdrv_wglSetPixelFormat, /* p_wglSetPixelFormat */ dibdrv_wglShareLists, /* p_wglShareLists */ dibdrv_wglSwapBuffers, /* p_wglSwapBuffers */ + dibdrv_get_pixel_formats, /* p_get_pixel_formats */ } };
This merge request was approved by Huw Davies.