diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2014-03-26 19:21:20 +0000 |
---|---|---|
committer | <> | 2014-05-08 15:03:54 +0000 |
commit | fb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch) | |
tree | c2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/Additions/common/crOpenGL/wgl.c | |
parent | 58ed4748338f9466599adfc8a9171280ed99e23f (diff) | |
download | VirtualBox-master.tar.gz |
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/Additions/common/crOpenGL/wgl.c')
-rw-r--r-- | src/VBox/Additions/common/crOpenGL/wgl.c | 173 |
1 files changed, 141 insertions, 32 deletions
diff --git a/src/VBox/Additions/common/crOpenGL/wgl.c b/src/VBox/Additions/common/crOpenGL/wgl.c index 71166343..a2ccf751 100644 --- a/src/VBox/Additions/common/crOpenGL/wgl.c +++ b/src/VBox/Additions/common/crOpenGL/wgl.c @@ -16,6 +16,8 @@ #include <windows.h> #include <stdio.h> +#include <iprt/cdefs.h> + /* Currently host part will misbehave re-creating context with proper visual bits * if contexts with alternative visual bits is requested. * For now we just report a superset of all visual bits to avoid that. @@ -65,7 +67,7 @@ static GLuint ComputeVisBits( HDC hdc ) } #endif -int WINAPI wglChoosePixelFormat_prox( HDC hdc, CONST PIXELFORMATDESCRIPTOR *pfd ) +DECLEXPORT(int) WINAPI wglChoosePixelFormat_prox( HDC hdc, CONST PIXELFORMATDESCRIPTOR *pfd ) { DWORD okayFlags; @@ -162,7 +164,7 @@ int WINAPI wglChoosePixelFormat_prox( HDC hdc, CONST PIXELFORMATDESCRIPTOR *pfd return 1; } -BOOL WINAPI wglSetPixelFormat_prox( HDC hdc, int pixelFormat, +DECLEXPORT(BOOL) WINAPI wglSetPixelFormat_prox( HDC hdc, int pixelFormat, CONST PIXELFORMATDESCRIPTOR *pdf ) { CR_DDI_PROLOGUE(); @@ -174,14 +176,14 @@ BOOL WINAPI wglSetPixelFormat_prox( HDC hdc, int pixelFormat, return 1; } -BOOL WINAPI wglDeleteContext_prox( HGLRC hglrc ) +DECLEXPORT(BOOL) WINAPI wglDeleteContext_prox( HGLRC hglrc ) { CR_DDI_PROLOGUE(); stubDestroyContext( (unsigned long) hglrc ); return 1; } -BOOL WINAPI wglMakeCurrent_prox( HDC hdc, HGLRC hglrc ) +DECLEXPORT(BOOL) WINAPI wglMakeCurrent_prox( HDC hdc, HGLRC hglrc ) { ContextInfo *context; WindowInfo *window; @@ -208,14 +210,14 @@ BOOL WINAPI wglMakeCurrent_prox( HDC hdc, HGLRC hglrc ) return ret; } -HGLRC WINAPI wglGetCurrentContext_prox( void ) +DECLEXPORT(HGLRC) WINAPI wglGetCurrentContext_prox( void ) { ContextInfo *context = stubGetCurrentContext(); CR_DDI_PROLOGUE(); return (HGLRC) (context ? context->id : 0); } -HDC WINAPI wglGetCurrentDC_prox( void ) +DECLEXPORT(HDC) WINAPI wglGetCurrentDC_prox( void ) { ContextInfo *context = stubGetCurrentContext(); CR_DDI_PROLOGUE(); @@ -225,14 +227,14 @@ HDC WINAPI wglGetCurrentDC_prox( void ) return (HDC) NULL; } -int WINAPI wglGetPixelFormat_prox( HDC hdc ) +DECLEXPORT(int) WINAPI wglGetPixelFormat_prox( HDC hdc ) { CR_DDI_PROLOGUE(); /* this is what we call our generic pixelformat, regardless of the HDC */ return 1; } -int WINAPI wglDescribePixelFormat_prox( HDC hdc, int pixelFormat, UINT nBytes, +DECLEXPORT(int) WINAPI wglDescribePixelFormat_prox( HDC hdc, int pixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR pfd ) { CR_DDI_PROLOGUE(); @@ -286,15 +288,37 @@ int WINAPI wglDescribePixelFormat_prox( HDC hdc, int pixelFormat, UINT nBytes, return 1; } -BOOL WINAPI wglShareLists_prox( HGLRC hglrc1, HGLRC hglrc2 ) +DECLEXPORT(BOOL) WINAPI wglShareLists_prox( HGLRC hglrc1, HGLRC hglrc2 ) { CR_DDI_PROLOGUE(); crWarning( "wglShareLists: unsupported" ); return 0; } +DECLEXPORT(void) WINAPI VBoxCtxChromiumParameteriCR(HGLRC hglrc, GLenum param, GLint value) +{ + ContextInfo *context; + + CR_DDI_PROLOGUE(); + +// crHashtableLock(stub.windowTable); + crHashtableLock(stub.contextTable); + + context = (ContextInfo *) crHashtableSearch(stub.contextTable, (unsigned long) hglrc); + + if (context) + { + stubCtxCheckCreate(context); + stubConChromiumParameteriCR(CR_CTX_CON(context), param, value); + } + else + crWarning("invalid context %#x", hglrc); -HGLRC WINAPI VBoxCreateContext( HDC hdc, struct VBOXUHGSMI *pHgsmi ) + crHashtableUnlock(stub.contextTable); +// crHashtableUnlock(stub.windowTable); +} + +DECLEXPORT(HGLRC) WINAPI VBoxCreateContext( HDC hdc, struct VBOXUHGSMI *pHgsmi ) { char dpyName[MAX_DPY_NAME]; ContextInfo *context; @@ -324,12 +348,97 @@ HGLRC WINAPI VBoxCreateContext( HDC hdc, struct VBOXUHGSMI *pHgsmi ) return (HGLRC) context->id; } -HGLRC WINAPI wglCreateContext_prox( HDC hdc ) +DECLEXPORT(GLint) WINAPI VBoxGetWindowId( HDC hdc ) +{ + WindowInfo *window; + GLint winid = 0; + + CR_DDI_PROLOGUE(); + + crHashtableLock(stub.windowTable); + + window = stubGetWindowInfo(hdc); + if (!window) + { + crWarning("stubGetWindowInfo: window not found!"); + goto end; + } + if (!window->spuWindow) + { + crWarning("stubGetWindowInfo: window is null!"); + goto end; + } + + winid = window->spuWindow; + +end: + crHashtableUnlock(stub.windowTable); + return winid; +} + +DECLEXPORT(GLint) WINAPI VBoxGetContextId( HGLRC hglrc ) +{ + ContextInfo *context; + GLint ctxid = 0; + + CR_DDI_PROLOGUE(); + +// crHashtableLock(stub.windowTable); + crHashtableLock(stub.contextTable); + + context = (ContextInfo *) crHashtableSearch(stub.contextTable, (unsigned long) hglrc); + if (!context) + { + crWarning("crHashtableSearch: context not found!"); + goto end; + } + + if (context->type != CHROMIUM) + { + crWarning("unexpected context type %d", context->type); + goto end; + } + + if (context->spuContext <= 0) + { + crWarning("no spuSontext defined"); + goto end; + } + + ctxid = context->spuContext; + +end: + crHashtableUnlock(stub.contextTable); + return ctxid; +} + + +DECLEXPORT(HGLRC) WINAPI wglCreateContext_prox( HDC hdc ) { return VBoxCreateContext(hdc, NULL); } -BOOL WINAPI +DECLEXPORT(void) WINAPI VBoxFlushToHost ( HGLRC hglrc ) +{ + ContextInfo *context; + + CR_DDI_PROLOGUE(); + +// crHashtableLock(stub.windowTable); + crHashtableLock(stub.contextTable); + + context = (ContextInfo *) crHashtableSearch(stub.contextTable, (unsigned long) hglrc); + + if (context) + stubConFlush(CR_CTX_CON(context)); + else + crWarning("invalid context %#x", hglrc); + + crHashtableUnlock(stub.contextTable); +// crHashtableUnlock(stub.windowTable); +} + +DECLEXPORT(BOOL) WINAPI wglSwapBuffers_prox( HDC hdc ) { WindowInfo *window = stubGetWindowInfo(hdc); @@ -338,14 +447,14 @@ wglSwapBuffers_prox( HDC hdc ) return 1; } -BOOL WINAPI wglCopyContext_prox( HGLRC src, HGLRC dst, UINT mask ) +DECLEXPORT(BOOL) WINAPI wglCopyContext_prox( HGLRC src, HGLRC dst, UINT mask ) { CR_DDI_PROLOGUE(); crWarning( "wglCopyContext: unsupported" ); return 0; } -HGLRC WINAPI wglCreateLayerContext_prox( HDC hdc, int layerPlane ) +DECLEXPORT(HGLRC) WINAPI wglCreateLayerContext_prox( HDC hdc, int layerPlane ) { CR_DDI_PROLOGUE(); stubInit(); @@ -353,27 +462,27 @@ HGLRC WINAPI wglCreateLayerContext_prox( HDC hdc, int layerPlane ) return 0; } -PROC WINAPI wglGetProcAddress_prox( LPCSTR name ) +DECLEXPORT(PROC) WINAPI wglGetProcAddress_prox( LPCSTR name ) { CR_DDI_PROLOGUE(); return (PROC) crGetProcAddress( name ); } -BOOL WINAPI wglUseFontBitmapsA_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase ) +DECLEXPORT(BOOL) WINAPI wglUseFontBitmapsA_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase ) { CR_DDI_PROLOGUE(); crWarning( "wglUseFontBitmapsA: unsupported" ); return 0; } -BOOL WINAPI wglUseFontBitmapsW_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase ) +DECLEXPORT(BOOL) WINAPI wglUseFontBitmapsW_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase ) { CR_DDI_PROLOGUE(); crWarning( "wglUseFontBitmapsW: unsupported" ); return 0; } -BOOL WINAPI wglDescribeLayerPlane_prox( HDC hdc, int pixelFormat, int layerPlane, +DECLEXPORT(BOOL) WINAPI wglDescribeLayerPlane_prox( HDC hdc, int pixelFormat, int layerPlane, UINT nBytes, LPLAYERPLANEDESCRIPTOR lpd ) { CR_DDI_PROLOGUE(); @@ -381,7 +490,7 @@ BOOL WINAPI wglDescribeLayerPlane_prox( HDC hdc, int pixelFormat, int layerPlane return 0; } -int WINAPI wglSetLayerPaletteEntries_prox( HDC hdc, int layerPlane, int start, +DECLEXPORT(int) WINAPI wglSetLayerPaletteEntries_prox( HDC hdc, int layerPlane, int start, int entries, CONST COLORREF *cr ) { CR_DDI_PROLOGUE(); @@ -389,7 +498,7 @@ int WINAPI wglSetLayerPaletteEntries_prox( HDC hdc, int layerPlane, int start, return 0; } -int WINAPI wglGetLayerPaletteEntries_prox( HDC hdc, int layerPlane, int start, +DECLEXPORT(int) WINAPI wglGetLayerPaletteEntries_prox( HDC hdc, int layerPlane, int start, int entries, COLORREF *cr ) { CR_DDI_PROLOGUE(); @@ -397,21 +506,21 @@ int WINAPI wglGetLayerPaletteEntries_prox( HDC hdc, int layerPlane, int start, return 0; } -BOOL WINAPI wglRealizeLayerPalette_prox( HDC hdc, int layerPlane, BOOL realize ) +DECLEXPORT(BOOL) WINAPI wglRealizeLayerPalette_prox( HDC hdc, int layerPlane, BOOL realize ) { CR_DDI_PROLOGUE(); crWarning( "wglRealizeLayerPalette: unsupported" ); return 0; } -DWORD WINAPI wglSwapMultipleBuffers_prox( UINT a, CONST void *b ) +DECLEXPORT(DWORD) WINAPI wglSwapMultipleBuffers_prox( UINT a, CONST void *b ) { CR_DDI_PROLOGUE(); crWarning( "wglSwapMultipleBuffer: unsupported" ); return 0; } -BOOL WINAPI wglUseFontOutlinesA_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase, +DECLEXPORT(BOOL) WINAPI wglUseFontOutlinesA_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT gmf ) { @@ -420,7 +529,7 @@ BOOL WINAPI wglUseFontOutlinesA_prox( HDC hdc, DWORD first, DWORD count, DWORD l return 0; } -BOOL WINAPI wglUseFontOutlinesW_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase, +DECLEXPORT(BOOL) WINAPI wglUseFontOutlinesW_prox( HDC hdc, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT gmf ) { @@ -429,7 +538,7 @@ BOOL WINAPI wglUseFontOutlinesW_prox( HDC hdc, DWORD first, DWORD count, DWORD l return 0; } -BOOL WINAPI wglSwapLayerBuffers_prox( HDC hdc, UINT planes ) +DECLEXPORT(BOOL) WINAPI wglSwapLayerBuffers_prox( HDC hdc, UINT planes ) { CR_DDI_PROLOGUE(); if (planes == WGL_SWAP_MAIN_PLANE) @@ -443,7 +552,7 @@ BOOL WINAPI wglSwapLayerBuffers_prox( HDC hdc, UINT planes ) } } -BOOL WINAPI wglChoosePixelFormatEXT_prox +DECLEXPORT(BOOL) WINAPI wglChoosePixelFormatEXT_prox (HDC hdc, const int *piAttributes, const FLOAT *pfAttributes, UINT nMaxFormats, int *piFormats, UINT *nNumFormats) { int *pi; @@ -565,7 +674,7 @@ BOOL WINAPI wglChoosePixelFormatEXT_prox return 1; } -BOOL WINAPI wglGetPixelFormatAttribivEXT_prox +DECLEXPORT(BOOL) WINAPI wglGetPixelFormatAttribivEXT_prox (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *pValues) { UINT i; @@ -700,7 +809,7 @@ BOOL WINAPI wglGetPixelFormatAttribivEXT_prox return 1; } -BOOL WINAPI wglGetPixelFormatAttribfvEXT_prox +DECLEXPORT(BOOL) WINAPI wglGetPixelFormatAttribfvEXT_prox (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, float *pValues) { UINT i; @@ -835,13 +944,13 @@ BOOL WINAPI wglGetPixelFormatAttribfvEXT_prox return 1; } -BOOL WINAPI wglSwapIntervalEXT_prox(int interval) +DECLEXPORT(BOOL) WINAPI wglSwapIntervalEXT_prox(int interval) { CR_DDI_PROLOGUE(); return TRUE; } -int WINAPI wglGetSwapIntervalEXT_prox() +DECLEXPORT(int) WINAPI wglGetSwapIntervalEXT_prox() { CR_DDI_PROLOGUE(); return 1; @@ -849,13 +958,13 @@ int WINAPI wglGetSwapIntervalEXT_prox() static GLubyte *gsz_wgl_extensions = "WGL_EXT_pixel_format WGL_ARB_pixel_format WGL_ARB_multisample"; -const GLubyte * WINAPI wglGetExtensionsStringEXT_prox() +DECLEXPORT(const GLubyte *) WINAPI wglGetExtensionsStringEXT_prox() { CR_DDI_PROLOGUE(); return gsz_wgl_extensions; } -const GLubyte * WINAPI wglGetExtensionsStringARB_prox(HDC hdc) +DECLEXPORT(const GLubyte *) WINAPI wglGetExtensionsStringARB_prox(HDC hdc) { CR_DDI_PROLOGUE(); (void) hdc; |