xserver-multidpi/hw/xwin/glx/winpriv.c
Jon Turney f5f4d32ac7 Add Windows-DRI extension
If windowsdriproto headers are available, build a Windows-DRI extension,
which supports requests to enable local clients to directly render GL to a
Windows drawable:

- a query to check if WGL is being used on a screen
- a query to map a fbconfigID to a native pixelformatindex
- a query to map a drawable to a native handle

Windows-DRI can only be useful if we are using WGL, so make an note if WGL
is active on a screen.

Make validGlxDrawable() public

Adjust glxWinSetPixelFormat() so it doesn't require a context, just a
screen and config.

That enables factoring out the deferred drawable creation code as
glxWinDeferredCreateDrawable()

Enhance glxWinDeferredCreateDrawable(), so that pixmaps are placed into a
file mapping, so they exist in memory which can be shared with the direct
rendering process.

Currently, this file mapping is accessed by a name generated from the XID.
This will not be unique across multiple server instances. It would perhaps
be better, although more complicated, to use an anonymous file mapping, and
then duplicate the handle for the direct rendering process.

Use glxWinDeferredCreateDrawable() to ensure the native handle exists for
the Windows-DRI query to map a drawable to native handle.

v2:
Various printf format warning fixes

v3:
Fix format warnings on x86
Move some uninteresting windows-dri output to debug log level

v4:
check for windowsdriproto when  --enable-windowsdri
use windowsdriproto_CFLAGS

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2016-09-15 20:10:29 +01:00

129 lines
3.2 KiB
C

/*
* Export window information for the Windows-OpenGL GLX implementation.
*
* Authors: Alexander Gottwald
*/
#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
#include "win.h"
#include "winpriv.h"
#include "winwindow.h"
void
winCreateWindowsWindow(WindowPtr pWin);
/**
* Return size and handles of a window.
* If pWin is NULL, then the information for the root window is requested.
*/
HWND
winGetWindowInfo(WindowPtr pWin)
{
winTrace("%s: pWin %p XID 0x%x\n", __FUNCTION__, pWin, (unsigned int)pWin->drawable.id);
/* a real window was requested */
if (pWin != NULL) {
/* Get the window and screen privates */
ScreenPtr pScreen = pWin->drawable.pScreen;
winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
winScreenInfoPtr pScreenInfo = NULL;
HWND hwnd = NULL;
if (pWinScreen == NULL) {
ErrorF("winGetWindowInfo: screen has no privates\n");
return NULL;
}
hwnd = pWinScreen->hwndScreen;
pScreenInfo = pWinScreen->pScreenInfo;
#ifdef XWIN_MULTIWINDOW
/* check for multiwindow mode */
if (pScreenInfo->fMultiWindow) {
winWindowPriv(pWin);
if (pWinPriv == NULL) {
ErrorF("winGetWindowInfo: window has no privates\n");
return hwnd;
}
if (pWinPriv->hWnd == NULL) {
winCreateWindowsWindow(pWin);
winDebug("winGetWindowInfo: forcing window to exist\n");
}
if (pWinPriv->hWnd != NULL) {
/* copy window handle */
hwnd = pWinPriv->hWnd;
/* mark GLX active on that hwnd */
pWinPriv->fWglUsed = TRUE;
}
return hwnd;
}
#endif
#ifdef XWIN_MULTIWINDOWEXTWM
/* check for multiwindow external wm mode */
if (pScreenInfo->fMWExtWM) {
win32RootlessWindowPtr pRLWinPriv
= (win32RootlessWindowPtr) RootlessFrameForWindow(pWin, FALSE);
if (pRLWinPriv == NULL) {
ErrorF("winGetWindowInfo: window has no privates\n");
return hwnd;
}
if (pRLWinPriv->hWnd != NULL) {
/* copy window handle */
hwnd = pRLWinPriv->hWnd;
}
return hwnd;
}
#endif
}
else {
ScreenPtr pScreen = g_ScreenInfo[0].pScreen;
winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
if (pWinScreen == NULL) {
ErrorF("winGetWindowInfo: screen has no privates\n");
return NULL;
}
ErrorF("winGetWindowInfo: returning root window\n");
return pWinScreen->hwndScreen;
}
return NULL;
}
Bool
winCheckScreenAiglxIsSupported(ScreenPtr pScreen)
{
winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
winScreenInfoPtr pScreenInfo = pWinScreen->pScreenInfo;
#ifdef XWIN_MULTIWINDOW
if (pScreenInfo->fMultiWindow)
return TRUE;
#endif
#ifdef XWIN_MULTIWINDOWEXTWM
if (pScreenInfo->fMWExtWM)
return TRUE;
#endif
return FALSE;
}
void
winSetScreenAiglxIsActive(ScreenPtr pScreen)
{
winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
pWinScreen->fNativeGlActive = TRUE;
}