diff options
Diffstat (limited to 'xorg-server/hw/xwin/glx/indirect.c')
-rw-r--r-- | xorg-server/hw/xwin/glx/indirect.c | 121 |
1 files changed, 101 insertions, 20 deletions
diff --git a/xorg-server/hw/xwin/glx/indirect.c b/xorg-server/hw/xwin/glx/indirect.c index ba995c007..252e5993e 100644 --- a/xorg-server/hw/xwin/glx/indirect.c +++ b/xorg-server/hw/xwin/glx/indirect.c @@ -78,6 +78,10 @@ #include <winpriv.h> #include <wgl_ext_api.h> +#include "win.h" + +extern Bool g_fXdmcpEnabled; +extern Bool g_fNativeGl; #define NUM_ELEMENTS(x) (sizeof(x)/ sizeof(x[1])) @@ -96,6 +100,7 @@ struct __GLXWinContext { HGLRC ctx; /* Windows GL Context */ __GLXWinContext *shareContext; /* Context with which we will share display lists and textures */ HWND hwnd; /* For detecting when HWND has changed */ + BOOL GlCtxWnd; /* TRUE when we should destroy the window when the context is destroyed. */ }; struct __GLXWinDrawable @@ -130,6 +135,7 @@ struct __GLXWinScreen RealizeWindowProcPtr RealizeWindow; UnrealizeWindowProcPtr UnrealizeWindow; CopyWindowProcPtr CopyWindow; + PositionWindowProcPtr PositionWindow; }; struct __GLXWinConfig @@ -385,6 +391,7 @@ static __GLXdrawable *glxWinCreateDrawable(__GLXscreen *screen, static Bool glxWinRealizeWindow(WindowPtr pWin); static Bool glxWinUnrealizeWindow(WindowPtr pWin); static void glxWinCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc); +static Bool glxWinPositionWindow(WindowPtr pWindow, int x, int y); static HDC glxWinMakeDC(__GLXWinContext *gc, __GLXWinDrawable *draw, HDC *hdc, HWND *hwnd); static void glxWinReleaseDC(HWND hwnd, HDC hdc, __GLXWinDrawable *draw); @@ -408,7 +415,8 @@ __GLXprovider __glXWGLProvider = { void glxWinPushNativeProvider(void) { - GlxPushProvider(&__glXWGLProvider); + if (g_fNativeGl) + GlxPushProvider(&__glXWGLProvider); } /* ---------------------------------------------------------------------- */ @@ -435,6 +443,16 @@ glxWinScreenSwapInterval(__GLXdrawable *drawable, int interval) return ret; } +static LRESULT CALLBACK GlxWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + if (uMsg== WM_NCHITTEST) + { + return HTTRANSPARENT; + } + else + return DefWindowProc(hwnd, uMsg, wParam, lParam); +} + /* This is called by GlxExtensionInit() asking the GLX provider if it can handle the screen... */ static __GLXscreen * glxWinScreenProbe(ScreenPtr pScreen) @@ -471,27 +489,29 @@ glxWinScreenProbe(ScreenPtr pScreen) pScreen->UnrealizeWindow = glxWinUnrealizeWindow; screen->CopyWindow = pScreen->CopyWindow; pScreen->CopyWindow = glxWinCopyWindow; + screen->PositionWindow = pScreen->PositionWindow; + pScreen->PositionWindow = glxWinPositionWindow; /* Dump out some useful information about the native renderer */ // create window class -#define WIN_GL_TEST_WINDOW_CLASS "XWinGLTest" { static wATOM glTestWndClass = 0; if (glTestWndClass == 0) { WNDCLASSEX wc; + glTestWndClass=1; wc.cbSize = sizeof(WNDCLASSEX); - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = DefWindowProc; + wc.style = CS_OWNDC ; + wc.lpfnWndProc = GlxWindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = GetModuleHandle(NULL); wc.hIcon = 0; wc.hCursor = 0; - wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); + wc.hbrBackground = 0; wc.lpszMenuName = NULL; - wc.lpszClassName = WIN_GL_TEST_WINDOW_CLASS; + wc.lpszClassName = WIN_GL_WINDOW_CLASS; wc.hIconSm = 0; RegisterClassEx (&wc); } @@ -499,7 +519,7 @@ glxWinScreenProbe(ScreenPtr pScreen) // create an invisible window for a scratch DC hwnd = CreateWindowExA(0, - WIN_GL_TEST_WINDOW_CLASS, + WIN_GL_WINDOW_CLASS, "XWin GL Renderer Capabilities Test Window", 0, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL); if (hwnd == NULL) @@ -522,6 +542,8 @@ glxWinScreenProbe(ScreenPtr pScreen) gl_extensions = (const char *)glGetStringWrapperNonstatic(GL_EXTENSIONS); ErrorF("GL_EXTENSIONS: %s\n", gl_extensions); wgl_extensions = wglGetExtensionsStringARBWrapper(hdc); + if (!wgl_extensions) + wgl_extensions=""; ErrorF("WGL_EXTENSIONS:%s\n", wgl_extensions); // Can you see the problem here? The extensions string is DC specific @@ -658,6 +680,7 @@ glxWinScreenProbe(ScreenPtr pScreen) if (screen->has_WGL_ARB_multisample) { screen->base.GLXversion = xstrdup("1.4"); + screen->base.GLXminor=4; /* XXX: this just controls the version string returned to glXQueryServerString() there is currently no way to control the version number the server returns to @@ -667,6 +690,7 @@ glxWinScreenProbe(ScreenPtr pScreen) else { screen->base.GLXversion = xstrdup("1.3"); + screen->base.GLXminor=3; } LogMessage(X_INFO, "AIGLX: Set GLX version to %s\n", screen->base.GLXversion); } @@ -691,6 +715,7 @@ glxWinRealizeWindow(WindowPtr pWin) Bool result; ScreenPtr pScreen = pWin->drawable.pScreen; glxWinScreen *screenPriv = (glxWinScreen *) glxGetScreen(pScreen); + winWindowPriv(pWin); GLWIN_DEBUG_MSG("glxWinRealizeWindow"); @@ -698,7 +723,12 @@ glxWinRealizeWindow(WindowPtr pWin) pScreen->RealizeWindow = screenPriv->RealizeWindow; result = pScreen->RealizeWindow(pWin); pScreen->RealizeWindow = glxWinRealizeWindow; - + + // Check if ze need to move the window\n + if (g_fXdmcpEnabled && pWinPriv->hWnd) + { + ShowWindow(pWinPriv->hWnd,SW_SHOW); + } return result; } @@ -734,14 +764,42 @@ glxWinCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc) pScreen->CopyWindow = screenPriv->CopyWindow; pScreen->CopyWindow(pWindow, ptOldOrg, prgnSrc); pScreen->CopyWindow = glxWinCopyWindow; + } static Bool +glxWinPositionWindow(WindowPtr pWin, int x, int y) +{ + Bool result; + __GLXWinDrawable *pGlxDraw; + ScreenPtr pScreen = pWin->drawable.pScreen; + glxWinScreen *screenPriv = (glxWinScreen *) glxGetScreen(pScreen); + winWindowPriv(pWin); + + pScreen->PositionWindow = screenPriv->PositionWindow; + result = pScreen->PositionWindow(pWin, x, y); + pScreen->PositionWindow = glxWinPositionWindow; + + if (g_fXdmcpEnabled && pWinPriv->hWnd) + { + MoveWindow(pWinPriv->hWnd, + pWin->drawable.x, + pWin->drawable.y, + pWin->drawable.width, + pWin->drawable.height, + FALSE); + } + return result; +} + + +static Bool glxWinUnrealizeWindow(WindowPtr pWin) { Bool result; ScreenPtr pScreen = pWin->drawable.pScreen; glxWinScreen *screenPriv = (glxWinScreen *)glxGetScreen(pScreen); + winWindowPriv(pWin); GLWIN_DEBUG_MSG("glxWinUnrealizeWindow"); @@ -749,6 +807,9 @@ glxWinUnrealizeWindow(WindowPtr pWin) result = pScreen->UnrealizeWindow(pWin); pScreen->UnrealizeWindow = glxWinUnrealizeWindow; + if (g_fXdmcpEnabled && pWinPriv->hWnd) + ShowWindow(pWinPriv->hWnd,SW_HIDE); + return result; } @@ -934,7 +995,7 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable __GLXconfig *config = gc->base.config; GLXWinConfig *winConfig = (GLXWinConfig *)config; - + GLWIN_DEBUG_MSG("glxWinSetPixelFormat: pixelFormatIndex %d", winConfig->pixelFormatIndex); /* @@ -978,7 +1039,7 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable { PIXELFORMATDESCRIPTOR pfd; int pixelFormat; - + /* convert fbConfig to PFD */ if (fbConfigToPixelFormat(gc->base.config, &pfd, drawableTypeOverride)) { @@ -1155,6 +1216,7 @@ glxWinDeferredCreateContext(__GLXWinContext *gc, __GLXWinDrawable *draw) { HDC dc; HWND hwnd; + winWindowPriv(((WindowPtr) draw->base.pDraw)); GLWIN_DEBUG_MSG("glxWinDeferredCreateContext: attach context %p to drawable %p", gc, draw); switch (draw->base.type) @@ -1190,6 +1252,9 @@ glxWinDeferredCreateContext(__GLXWinContext *gc, __GLXWinDrawable *draw) { if (draw->hPbuffer == NULL) { + __GLXscreen *screen; + glxWinScreen *winScreen; + int pixelFormat; // XXX: which DC are supposed to use??? HDC screenDC = GetDC(NULL); @@ -1198,10 +1263,10 @@ glxWinDeferredCreateContext(__GLXWinContext *gc, __GLXWinDrawable *draw) ErrorF("glxWinDeferredCreateContext: tried to attach a context whose fbConfig doesn't have drawableType GLX_PBUFFER_BIT to a GLX_DRAWABLE_PBUFFER drawable\n"); } - __GLXscreen *screen = gc->base.pGlxScreen; - glxWinScreen *winScreen = (glxWinScreen *)screen; + screen = gc->base.pGlxScreen; + winScreen = (glxWinScreen *)screen; - int pixelFormat = fbConfigToPixelFormatIndex(screenDC, gc->base.config, GLX_DRAWABLE_PBUFFER, winScreen); + pixelFormat = fbConfigToPixelFormatIndex(screenDC, gc->base.config, GLX_DRAWABLE_PBUFFER, winScreen); if (pixelFormat == 0) { ErrorF("wglChoosePixelFormat error: %s\n", glxWinErrorMessage()); @@ -1226,11 +1291,16 @@ glxWinDeferredCreateContext(__GLXWinContext *gc, __GLXWinDrawable *draw) { if (draw->dibDC == NULL) { - BITMAPINFOHEADER bmpHeader = { sizeof(bmpHeader), - draw->base.pDraw->width, draw->base.pDraw->height, - 1, draw->base.pDraw->bitsPerPixel, - BI_RGB}; + BITMAPINFOHEADER bmpHeader; void *pBits; + + ZeroMemory(&bmpHeader,sizeof(bmpHeader)); + bmpHeader.biSize=sizeof(bmpHeader); + bmpHeader.biWidth=draw->base.pDraw->width; + bmpHeader.biHeight=draw->base.pDraw->height; + bmpHeader.biPlanes=1; + bmpHeader.biBitCount=draw->base.pDraw->bitsPerPixel; + bmpHeader.biCompression=BI_RGB; if (!(gc->base.config->drawableType & GLX_PIXMAP_BIT)) { @@ -1282,6 +1352,8 @@ glxWinDeferredCreateContext(__GLXWinContext *gc, __GLXWinDrawable *draw) dc = glxWinMakeDC(gc, draw, &dc, &hwnd); gc->ctx = wglCreateContext(dc); + gc->GlCtxWnd = pWinPriv->GlCtxWnd; + glxWinReleaseDC(hwnd, dc, draw); if (gc->ctx == NULL) @@ -1445,16 +1517,18 @@ glxWinContextDestroy(__GLXcontext *base) if (gc->ctx) { + BOOL ret; /* It's bad style to delete the context while it's still current */ if (wglGetCurrentContext() == gc->ctx) { wglMakeCurrent(NULL, NULL); } - BOOL ret = wglDeleteContext(gc->ctx); + ret = wglDeleteContext(gc->ctx); if (!ret) ErrorF("wglDeleteContext error: %s\n", glxWinErrorMessage()); gc->ctx = NULL; + if (gc->GlCtxWnd) DestroyWindow(gc->hwnd); } xfree(gc); @@ -1988,12 +2062,15 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen *screen) /* fill in configs */ for (i = 0; i < numConfigs; i++) { + int sizevalues=num_attrs*sizeof(int); + int *values=(int*)_alloca(sizevalues); + + memset(values,0,sizevalues); + c = &(result[i]); c->base.next = NULL; c->pixelFormatIndex = i+1; - int values[num_attrs]; - if (!wglGetPixelFormatAttribivARBWrapper(hdc, i+1, 0, num_attrs, attrs, values)) { ErrorF("wglGetPixelFormatAttribivARB failed for index %d, error %s\n", i+1, glxWinErrorMessage()); @@ -2032,6 +2109,10 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen *screen) case WGL_TYPE_RGBA_FLOAT_ARB: GLWIN_DEBUG_MSG("pixelFormat %d is WGL_TYPE_RGBA_FLOAT_ARB, skipping", i+1); continue; + + case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT: + GLWIN_DEBUG_MSG("pixelFormat %d is WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT, skipping", i+1); + continue; case WGL_TYPE_RGBA_ARB: c->base.indexBits = 0; |