mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 19:30:11 +01:00
wgl: Use HWND instead of HDC as primary framebuffer handle
EGL's native window is an HWND, so this removes the need to GetDC from the creation path there. Reviewed-by: Charmaine Lee <charmainel@vmware.com> Reviewed By: Bill Kristiansen <billkris@microsoft.com> Acked-by: Roland Scheidegger <sroland@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12727>
This commit is contained in:
parent
ddedf59625
commit
bb706ca93a
9 changed files with 15 additions and 27 deletions
|
|
@ -571,7 +571,7 @@ get_unlocked_refd_framebuffer_from_dc(HDC hDC)
|
|||
*/
|
||||
int iPixelFormat = get_matching_pixel_format(hDC);
|
||||
if (iPixelFormat)
|
||||
fb = stw_framebuffer_create(hDC, iPixelFormat, STW_FRAMEBUFFER_WGL_WINDOW);
|
||||
fb = stw_framebuffer_create(WindowFromDC(hDC), iPixelFormat, STW_FRAMEBUFFER_WGL_WINDOW);
|
||||
if (!fb)
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@ wglCreatePbufferARB(HDC hCurrentDC,
|
|||
DWORD dwStyle;
|
||||
RECT rect;
|
||||
HWND hWnd;
|
||||
HDC hDC;
|
||||
int iDisplayablePixelFormat;
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
BOOL bRet;
|
||||
|
|
@ -239,16 +238,11 @@ wglCreatePbufferARB(HDC hCurrentDC,
|
|||
assert(rect.bottom - rect.top == iHeight);
|
||||
#endif
|
||||
|
||||
hDC = GetDC(hWnd);
|
||||
if (!hDC) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* We can't pass non-displayable pixel formats to GDI, which is why we
|
||||
* create the framebuffer object before calling SetPixelFormat().
|
||||
*/
|
||||
fb = stw_framebuffer_create(hDC, iPixelFormat, STW_FRAMEBUFFER_PBUFFER);
|
||||
fb = stw_framebuffer_create(hWnd, iPixelFormat, STW_FRAMEBUFFER_PBUFFER);
|
||||
if (!fb) {
|
||||
SetLastError(ERROR_NO_SYSTEM_RESOURCES);
|
||||
return NULL;
|
||||
|
|
@ -267,7 +261,7 @@ wglCreatePbufferARB(HDC hCurrentDC,
|
|||
* We need to set a displayable pixel format on the hidden window DC
|
||||
* so that wglCreateContext and wglMakeCurrent are not overruled by GDI.
|
||||
*/
|
||||
bRet = SetPixelFormat(hDC, iDisplayablePixelFormat, &pfd);
|
||||
bRet = SetPixelFormat(GetDC(hWnd), iDisplayablePixelFormat, &pfd);
|
||||
assert(bRet);
|
||||
|
||||
return (HPBUFFERARB)fb;
|
||||
|
|
|
|||
|
|
@ -261,17 +261,11 @@ stw_call_window_proc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||
* with its mutex locked.
|
||||
*/
|
||||
struct stw_framebuffer *
|
||||
stw_framebuffer_create(HDC hdc, int iPixelFormat, enum stw_framebuffer_owner owner)
|
||||
stw_framebuffer_create(HWND hWnd, int iPixelFormat, enum stw_framebuffer_owner owner)
|
||||
{
|
||||
HWND hWnd;
|
||||
struct stw_framebuffer *fb;
|
||||
const struct stw_pixelformat_info *pfi;
|
||||
|
||||
/* We only support drawing to a window. */
|
||||
hWnd = WindowFromDC( hdc );
|
||||
if (!hWnd)
|
||||
return NULL;
|
||||
|
||||
fb = CALLOC_STRUCT( stw_framebuffer );
|
||||
if (fb == NULL)
|
||||
return NULL;
|
||||
|
|
@ -281,7 +275,7 @@ stw_framebuffer_create(HDC hdc, int iPixelFormat, enum stw_framebuffer_owner own
|
|||
|
||||
if (stw_dev->stw_winsys->create_framebuffer)
|
||||
fb->winsys_framebuffer =
|
||||
stw_dev->stw_winsys->create_framebuffer(stw_dev->screen, hdc, iPixelFormat);
|
||||
stw_dev->stw_winsys->create_framebuffer(stw_dev->screen, hWnd, iPixelFormat);
|
||||
|
||||
/*
|
||||
* We often need a displayable pixel format to make GDI happy. Set it
|
||||
|
|
@ -493,7 +487,7 @@ DrvSetPixelFormat(HDC hdc, LONG iPixelFormat)
|
|||
return bPbuffer;
|
||||
}
|
||||
|
||||
fb = stw_framebuffer_create(hdc, iPixelFormat, STW_FRAMEBUFFER_WGL_WINDOW);
|
||||
fb = stw_framebuffer_create(WindowFromDC(hdc), iPixelFormat, STW_FRAMEBUFFER_WGL_WINDOW);
|
||||
if (!fb) {
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ struct stw_framebuffer
|
|||
* must be called when done
|
||||
*/
|
||||
struct stw_framebuffer *
|
||||
stw_framebuffer_create(HDC hdc, int iPixelFormat, enum stw_framebuffer_owner owner);
|
||||
stw_framebuffer_create(HWND hwnd, int iPixelFormat, enum stw_framebuffer_owner owner);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ struct stw_winsys
|
|||
*/
|
||||
struct stw_winsys_framebuffer *
|
||||
(*create_framebuffer)( struct pipe_screen *screen,
|
||||
HDC hDC,
|
||||
HWND hWnd,
|
||||
int iPixelFormat );
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -94,10 +94,10 @@ gdi_get_pfd_flags(struct pipe_screen *screen)
|
|||
|
||||
static struct stw_winsys_framebuffer *
|
||||
gdi_create_framebuffer(struct pipe_screen *screen,
|
||||
HDC hDC,
|
||||
HWND hWnd,
|
||||
int iPixelFormat)
|
||||
{
|
||||
return d3d12_wgl_create_framebuffer(screen, hDC, iPixelFormat);
|
||||
return d3d12_wgl_create_framebuffer(screen, hWnd, iPixelFormat);
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
|
|
|||
|
|
@ -253,12 +253,12 @@ wgl_get_pfd_flags(struct pipe_screen *screen)
|
|||
|
||||
static struct stw_winsys_framebuffer *
|
||||
wgl_create_framebuffer(struct pipe_screen *screen,
|
||||
HDC hDC,
|
||||
HWND hWnd,
|
||||
int iPixelFormat)
|
||||
{
|
||||
#ifdef GALLIUM_D3D12
|
||||
if (use_d3d12)
|
||||
return d3d12_wgl_create_framebuffer(screen, hDC, iPixelFormat);
|
||||
return d3d12_wgl_create_framebuffer(screen, hWnd, iPixelFormat);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ d3d12_wgl_framebuffer_get_resource(struct stw_winsys_framebuffer *pframebuffer,
|
|||
|
||||
struct stw_winsys_framebuffer *
|
||||
d3d12_wgl_create_framebuffer(struct pipe_screen *screen,
|
||||
HDC hDC,
|
||||
HWND hWnd,
|
||||
int iPixelFormat)
|
||||
{
|
||||
const struct stw_pixelformat_info *pfi =
|
||||
|
|
@ -229,7 +229,7 @@ d3d12_wgl_create_framebuffer(struct pipe_screen *screen,
|
|||
|
||||
new (fb) struct d3d12_wgl_framebuffer();
|
||||
|
||||
fb->window = WindowFromDC(hDC);
|
||||
fb->window = hWnd;
|
||||
fb->screen = d3d12_screen(screen);
|
||||
fb->base.destroy = d3d12_wgl_framebuffer_destroy;
|
||||
fb->base.resize = d3d12_wgl_framebuffer_resize;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ d3d12_wgl_get_pfd_flags(struct pipe_screen *screen);
|
|||
|
||||
struct stw_winsys_framebuffer *
|
||||
d3d12_wgl_create_framebuffer(struct pipe_screen *screen,
|
||||
HDC hDC,
|
||||
HWND hWnd,
|
||||
int iPixelFormat);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue