VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/context.c@ 62060

Last change on this file since 62060 was 62060, checked in by vboxsync, 8 years ago

crOpenGL: stubMakeCurrent - make sure retVal is initialized.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 41.2 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7/**
8 * \mainpage OpenGL_stub
9 *
10 * \section OpenGL_stubIntroduction Introduction
11 *
12 * Chromium consists of all the top-level files in the cr
13 * directory. The OpenGL_stub module basically takes care of API dispatch,
14 * and OpenGL state management.
15 *
16 */
17
18/**
19 * This file manages OpenGL rendering contexts in the faker library.
20 * The big issue is switching between Chromium and native GL context
21 * management. This is where we support multiple client OpenGL
22 * windows. Typically, one window is handled by Chromium while any
23 * other windows are handled by the native OpenGL library.
24 */
25
26#include "chromium.h"
27#include "cr_error.h"
28#include "cr_spu.h"
29#include "cr_mem.h"
30#include "cr_string.h"
31#include "cr_environment.h"
32#include "stub.h"
33
34/**
35 * This function should be called from MakeCurrent(). It'll detect if
36 * we're in a multi-thread situation, and do the right thing for dispatch.
37 */
38#ifdef CHROMIUM_THREADSAFE
39 static void
40stubCheckMultithread( void )
41{
42 static unsigned long knownID;
43 static GLboolean firstCall = GL_TRUE;
44
45 if (stub.threadSafe)
46 return; /* nothing new, nothing to do */
47
48 if (firstCall) {
49 knownID = crThreadID();
50 firstCall = GL_FALSE;
51 }
52 else if (knownID != crThreadID()) {
53 /* going thread-safe now! */
54 stub.threadSafe = GL_TRUE;
55 crSPUCopyDispatchTable(&glim, &stubThreadsafeDispatch);
56 }
57}
58#endif
59
60
61/**
62 * Install the given dispatch table as the table used for all gl* calls.
63 */
64 static void
65stubSetDispatch( SPUDispatchTable *table )
66{
67 CRASSERT(table);
68
69#ifdef CHROMIUM_THREADSAFE
70 /* always set the per-thread dispatch pointer */
71 crSetTSD(&stub.dispatchTSD, (void *) table);
72 if (stub.threadSafe) {
73 /* Do nothing - the thread-safe dispatch functions will call GetTSD()
74 * to get a pointer to the dispatch table, and jump through it.
75 */
76 }
77 else
78#endif
79 {
80 /* Single thread mode - just install the caller's dispatch table */
81 /* This conditional is an optimization to try to avoid unnecessary
82 * copying. It seems to work with atlantis, multiwin, etc. but
83 * _could_ be a problem. (Brian)
84 */
85 if (glim.copy_of != table->copy_of)
86 crSPUCopyDispatchTable(&glim, table);
87 }
88}
89
90void stubForcedFlush(GLint con)
91{
92#if 0
93 GLint buffer;
94 stub.spu->dispatch_table.GetIntegerv(GL_DRAW_BUFFER, &buffer);
95 stub.spu->dispatch_table.DrawBuffer(GL_FRONT);
96 stub.spu->dispatch_table.Flush();
97 stub.spu->dispatch_table.DrawBuffer(buffer);
98#else
99 if (con)
100 {
101 stub.spu->dispatch_table.VBoxConFlush(con);
102 }
103 else
104 {
105 stub.spu->dispatch_table.Flush();
106 }
107#endif
108}
109
110void stubConChromiumParameteriCR(GLint con, GLenum param, GLint value)
111{
112// if (con)
113 stub.spu->dispatch_table.VBoxConChromiumParameteriCR(con, param, value);
114// else
115// crError("VBoxConChromiumParameteriCR called with null connection");
116}
117
118void stubConChromiumParametervCR(GLint con, GLenum target, GLenum type, GLsizei count, const GLvoid *values)
119{
120// if (con)
121 stub.spu->dispatch_table.VBoxConChromiumParametervCR(con, target, type, count, values);
122// else
123// crError("VBoxConChromiumParameteriCR called with null connection");
124}
125
126void stubConFlush(GLint con)
127{
128 if (con)
129 stub.spu->dispatch_table.VBoxConFlush(con);
130 else
131 crError("stubConFlush called with null connection");
132}
133
134static void stubWindowCleanupForContextsCB(unsigned long key, void *data1, void *data2)
135{
136 ContextInfo *context = (ContextInfo *) data1;
137
138 CRASSERT(context);
139
140 if (context->currentDrawable == data2)
141 context->currentDrawable = NULL;
142}
143
144void stubDestroyWindow( GLint con, GLint window )
145{
146 WindowInfo *winInfo = (WindowInfo *)
147 crHashtableSearch(stub.windowTable, (unsigned int) window);
148 if (winInfo && winInfo->type == CHROMIUM && stub.spu)
149 {
150 crHashtableLock(stub.windowTable);
151
152 stub.spu->dispatch_table.VBoxWindowDestroy(con, winInfo->spuWindow );
153
154#ifdef WINDOWS
155 if (winInfo->hVisibleRegion != INVALID_HANDLE_VALUE)
156 {
157 DeleteObject(winInfo->hVisibleRegion);
158 }
159#elif defined(GLX)
160 if (winInfo->pVisibleRegions)
161 {
162 XFree(winInfo->pVisibleRegions);
163 }
164# ifdef CR_NEWWINTRACK
165 if (winInfo->syncDpy)
166 {
167 XCloseDisplay(winInfo->syncDpy);
168 }
169# endif
170#endif
171
172 stubForcedFlush(con);
173
174 crHashtableWalk(stub.contextTable, stubWindowCleanupForContextsCB, winInfo);
175
176 crHashtableDelete(stub.windowTable, window, crFree);
177
178 crHashtableUnlock(stub.windowTable);
179 }
180}
181
182/**
183 * Create a new _Chromium_ window, not GLX, WGL or CGL.
184 * Called by crWindowCreate() only.
185 */
186 GLint
187stubNewWindow( const char *dpyName, GLint visBits )
188{
189 WindowInfo *winInfo;
190 GLint spuWin, size[2];
191
192 spuWin = stub.spu->dispatch_table.WindowCreate( dpyName, visBits );
193 if (spuWin < 0) {
194 return -1;
195 }
196
197 winInfo = (WindowInfo *) crCalloc(sizeof(WindowInfo));
198 if (!winInfo) {
199 stub.spu->dispatch_table.WindowDestroy(spuWin);
200 return -1;
201 }
202
203 winInfo->type = CHROMIUM;
204
205 /* Ask the head SPU for the initial window size */
206 size[0] = size[1] = 0;
207 stub.spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, 0, GL_INT, 2, size);
208 if (size[0] == 0 && size[1] == 0) {
209 /* use some reasonable defaults */
210 size[0] = size[1] = 512;
211 }
212 winInfo->width = size[0];
213 winInfo->height = size[1];
214#ifdef VBOX_WITH_WDDM
215 if (stub.bRunningUnderWDDM)
216 {
217 crError("Should not be here: WindowCreate/Destroy & VBoxPackGetInjectID require connection id!");
218 winInfo->mapped = 0;
219 }
220 else
221#endif
222 {
223 winInfo->mapped = 1;
224 }
225
226 if (!dpyName)
227 dpyName = "";
228
229 crStrncpy(winInfo->dpyName, dpyName, MAX_DPY_NAME);
230 winInfo->dpyName[MAX_DPY_NAME-1] = 0;
231
232 /* Use spuWin as the hash table index and GLX/WGL handle */
233#ifdef WINDOWS
234 winInfo->drawable = (HDC) spuWin;
235 winInfo->hVisibleRegion = INVALID_HANDLE_VALUE;
236#elif defined(Darwin)
237 winInfo->drawable = (CGSWindowID) spuWin;
238#elif defined(GLX)
239 winInfo->drawable = (GLXDrawable) spuWin;
240 winInfo->pVisibleRegions = NULL;
241 winInfo->cVisibleRegions = 0;
242#endif
243#ifdef CR_NEWWINTRACK
244 winInfo->u32ClientID = stub.spu->dispatch_table.VBoxPackGetInjectID(0);
245#endif
246 winInfo->spuWindow = spuWin;
247
248 crHashtableAdd(stub.windowTable, (unsigned int) spuWin, winInfo);
249
250 return spuWin;
251}
252
253#ifdef GLX
254static XErrorHandler oldErrorHandler;
255static unsigned char lastXError = Success;
256
257static int
258errorHandler (Display *dpy, XErrorEvent *e)
259{
260 lastXError = e->error_code;
261 return 0;
262}
263#endif
264
265GLboolean
266stubIsWindowVisible(WindowInfo *win)
267{
268#if defined(WINDOWS)
269# ifdef VBOX_WITH_WDDM
270 if (stub.bRunningUnderWDDM)
271 return win->mapped;
272# endif
273 return GL_TRUE;
274#elif defined(Darwin)
275 return GL_TRUE;
276#elif defined(GLX)
277 Display *dpy = stubGetWindowDisplay(win);
278 if (dpy)
279 {
280 XWindowAttributes attr;
281 XLOCK(dpy);
282 XGetWindowAttributes(dpy, win->drawable, &attr);
283 XUNLOCK(dpy);
284
285 if (attr.map_state == IsUnmapped)
286 {
287 return GL_FALSE;
288 }
289# if 1
290 return GL_TRUE;
291# else
292 if (attr.override_redirect)
293 {
294 return GL_TRUE;
295 }
296
297 if (!stub.bXExtensionsChecked)
298 {
299 stubCheckXExtensions(win);
300 }
301
302 if (!stub.bHaveXComposite)
303 {
304 return GL_TRUE;
305 }
306 else
307 {
308 Pixmap p;
309
310 crLockMutex(&stub.mutex);
311
312 XLOCK(dpy);
313 XSync(dpy, false);
314 oldErrorHandler = XSetErrorHandler(errorHandler);
315 /*@todo this will create new pixmap for window every call*/
316 p = XCompositeNameWindowPixmap(dpy, win->drawable);
317 XSync(dpy, false);
318 XSetErrorHandler(oldErrorHandler);
319 XUNLOCK(dpy);
320
321 switch (lastXError)
322 {
323 case Success:
324 XFreePixmap(dpy, p);
325 crUnlockMutex(&stub.mutex);
326 return GL_FALSE;
327 break;
328 case BadMatch:
329 /*Window isn't redirected*/
330 lastXError = Success;
331 break;
332 default:
333 crWarning("Unexpected XError %i", (int)lastXError);
334 lastXError = Success;
335 }
336
337 crUnlockMutex(&stub.mutex);
338
339 return GL_TRUE;
340 }
341# endif
342 }
343 else {
344 /* probably created by crWindowCreate() */
345 return win->mapped;
346 }
347#endif
348}
349
350
351/**
352 * Given a Windows HDC or GLX Drawable, return the corresponding
353 * WindowInfo structure. Create a new one if needed.
354 */
355WindowInfo *
356#ifdef WINDOWS
357 stubGetWindowInfo( HDC drawable )
358#elif defined(Darwin)
359 stubGetWindowInfo( CGSWindowID drawable )
360#elif defined(GLX)
361stubGetWindowInfo( Display *dpy, GLXDrawable drawable )
362#endif
363{
364#ifndef WINDOWS
365 WindowInfo *winInfo = (WindowInfo *) crHashtableSearch(stub.windowTable, (unsigned int) drawable);
366#else
367 WindowInfo *winInfo;
368 HWND hwnd;
369 hwnd = WindowFromDC(drawable);
370
371 if (!hwnd)
372 {
373 return NULL;
374 }
375
376 winInfo = (WindowInfo *) crHashtableSearch(stub.windowTable, (unsigned int) hwnd);
377#endif
378 if (!winInfo) {
379 winInfo = (WindowInfo *) crCalloc(sizeof(WindowInfo));
380 if (!winInfo)
381 return NULL;
382#ifdef GLX
383 crStrncpy(winInfo->dpyName, DisplayString(dpy), MAX_DPY_NAME);
384 winInfo->dpyName[MAX_DPY_NAME-1] = 0;
385 winInfo->dpy = dpy;
386 winInfo->pVisibleRegions = NULL;
387#elif defined(Darwin)
388 winInfo->connection = _CGSDefaultConnection(); // store our connection as default
389#elif defined(WINDOWS)
390 winInfo->hVisibleRegion = INVALID_HANDLE_VALUE;
391 winInfo->hWnd = hwnd;
392#endif
393 winInfo->drawable = drawable;
394 winInfo->type = UNDECIDED;
395 winInfo->spuWindow = -1;
396#ifdef VBOX_WITH_WDDM
397 if (stub.bRunningUnderWDDM)
398 winInfo->mapped = 0;
399 else
400#endif
401 {
402 winInfo->mapped = -1; /* don't know */
403 }
404 winInfo->pOwner = NULL;
405#ifdef CR_NEWWINTRACK
406 winInfo->u32ClientID = -1;
407#endif
408#ifndef WINDOWS
409 crHashtableAdd(stub.windowTable, (unsigned int) drawable, winInfo);
410#else
411 crHashtableAdd(stub.windowTable, (unsigned int) hwnd, winInfo);
412#endif
413 }
414#ifdef WINDOWS
415 else
416 {
417 winInfo->drawable = drawable;
418 }
419#endif
420 return winInfo;
421}
422
423static void stubWindowCheckOwnerCB(unsigned long key, void *data1, void *data2);
424
425static void
426stubContextFree( ContextInfo *context )
427{
428 crMemZero(context, sizeof(ContextInfo)); /* just to be safe */
429 crFree(context);
430}
431
432static void
433stubDestroyContextLocked( ContextInfo *context )
434{
435 unsigned long contextId = context->id;
436 if (context->type == NATIVE) {
437#ifdef WINDOWS
438 stub.wsInterface.wglDeleteContext( context->hglrc );
439#elif defined(Darwin)
440 stub.wsInterface.CGLDestroyContext( context->cglc );
441#elif defined(GLX)
442 stub.wsInterface.glXDestroyContext( context->dpy, context->glxContext );
443#endif
444 }
445 else if (context->type == CHROMIUM) {
446 /* Have pack SPU or tilesort SPU, etc. destroy the context */
447 CRASSERT(context->spuContext >= 0);
448 stub.spu->dispatch_table.DestroyContext( context->spuContext );
449 crHashtableWalk(stub.windowTable, stubWindowCheckOwnerCB, context);
450#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
451 if (context->spuConnection)
452 {
453 stub.spu->dispatch_table.VBoxConDestroy(context->spuConnection);
454 context->spuConnection = 0;
455 }
456#endif
457 }
458
459#ifdef GLX
460 crFreeHashtable(context->pGLXPixmapsHash, crFree);
461#endif
462
463 crHashtableDelete(stub.contextTable, contextId, NULL);
464}
465
466#ifdef CHROMIUM_THREADSAFE
467static DECLCALLBACK(void) stubContextDtor(void*pvContext)
468{
469 stubContextFree((ContextInfo*)pvContext);
470}
471#endif
472
473/**
474 * Allocate a new ContextInfo object, initialize it, put it into the
475 * context hash table. If type==CHROMIUM, call the head SPU's
476 * CreateContext() function too.
477 */
478 ContextInfo *
479stubNewContext(char *dpyName, GLint visBits, ContextType type, unsigned long shareCtx
480#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
481 , struct VBOXUHGSMI *pHgsmi
482#endif
483 )
484{
485 GLint spuContext = -1, spuShareCtx = 0, spuConnection = 0;
486 ContextInfo *context;
487
488 if (shareCtx > 0) {
489 /* translate shareCtx to a SPU context ID */
490 context = (ContextInfo *)
491 crHashtableSearch(stub.contextTable, shareCtx);
492 if (context)
493 spuShareCtx = context->spuContext;
494 }
495
496 if (type == CHROMIUM) {
497#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
498 if (pHgsmi)
499 {
500 spuConnection = stub.spu->dispatch_table.VBoxConCreate(pHgsmi);
501 if (!spuConnection)
502 {
503 crWarning("VBoxConCreate failed");
504 return NULL;
505 }
506 }
507#endif
508 spuContext
509 = stub.spu->dispatch_table.VBoxCreateContext(spuConnection, dpyName, visBits, spuShareCtx);
510 if (spuContext < 0)
511 {
512 crWarning("VBoxCreateContext failed");
513#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
514 if (spuConnection)
515 stub.spu->dispatch_table.VBoxConDestroy(spuConnection);
516#endif
517 return NULL;
518 }
519 }
520
521 context = crCalloc(sizeof(ContextInfo));
522 if (!context) {
523 stub.spu->dispatch_table.DestroyContext(spuContext);
524#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
525 if (spuConnection)
526 stub.spu->dispatch_table.VBoxConDestroy(spuConnection);
527#endif
528 return NULL;
529 }
530
531 if (!dpyName)
532 dpyName = "";
533
534 context->id = stub.freeContextNumber++;
535 context->type = type;
536 context->spuContext = spuContext;
537 context->visBits = visBits;
538 context->currentDrawable = NULL;
539 crStrncpy(context->dpyName, dpyName, MAX_DPY_NAME);
540 context->dpyName[MAX_DPY_NAME-1] = 0;
541
542#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
543 context->spuConnection = spuConnection;
544 context->pHgsmi = pHgsmi;
545#endif
546
547#ifdef CHROMIUM_THREADSAFE
548 VBoxTlsRefInit(context, stubContextDtor);
549#endif
550
551#if defined(GLX) || defined(DARWIN)
552 context->share = (ContextInfo *)
553 crHashtableSearch(stub.contextTable, (unsigned long) shareCtx);
554#endif
555
556#ifdef GLX
557 context->pGLXPixmapsHash = crAllocHashtable();
558 context->damageQueryFailed = GL_FALSE;
559 context->damageEventsBase = 0;
560#endif
561
562 crHashtableAdd(stub.contextTable, context->id, (void *) context);
563
564 return context;
565}
566
567
568#ifdef Darwin
569
570#define SET_ATTR(l,i,a) ( (l)[(i)++] = (a) )
571#define SET_ATTR_V(l,i,a,v) ( SET_ATTR(l,i,a), SET_ATTR(l,i,v) )
572
573void stubSetPFA( ContextInfo *ctx, CGLPixelFormatAttribute *attribs, int size, GLint *num ) {
574 GLuint visual = ctx->visBits;
575 int i = 0;
576
577 CRASSERT(visual & CR_RGB_BIT);
578
579 SET_ATTR_V(attribs, i, kCGLPFAColorSize, 8);
580
581 if( visual & CR_DEPTH_BIT )
582 SET_ATTR_V(attribs, i, kCGLPFADepthSize, 16);
583
584 if( visual & CR_ACCUM_BIT )
585 SET_ATTR_V(attribs, i, kCGLPFAAccumSize, 1);
586
587 if( visual & CR_STENCIL_BIT )
588 SET_ATTR_V(attribs, i, kCGLPFAStencilSize, 1);
589
590 if( visual & CR_ALPHA_BIT )
591 SET_ATTR_V(attribs, i, kCGLPFAAlphaSize, 1);
592
593 if( visual & CR_DOUBLE_BIT )
594 SET_ATTR(attribs, i, kCGLPFADoubleBuffer);
595
596 if( visual & CR_STEREO_BIT )
597 SET_ATTR(attribs, i, kCGLPFAStereo);
598
599/* SET_ATTR_V(attribs, i, kCGLPFASampleBuffers, 1);
600 SET_ATTR_V(attribs, i, kCGLPFASamples, 0);
601 SET_ATTR_V(attribs, i, kCGLPFADisplayMask, 0); */
602 SET_ATTR(attribs, i, kCGLPFABackingStore);
603 //SET_ATTR(attribs, i, kCGLPFAWindow); // kCGLPFAWindow deprecated starting from OSX 10.7
604 SET_ATTR_V(attribs, i, kCGLPFADisplayMask, ctx->disp_mask);
605
606 SET_ATTR(attribs, i, 0);
607
608 *num = i;
609}
610
611#endif
612
613/**
614 * This creates a native GLX/WGL context.
615 */
616static GLboolean
617InstantiateNativeContext( WindowInfo *window, ContextInfo *context )
618{
619#ifdef WINDOWS
620 context->hglrc = stub.wsInterface.wglCreateContext( window->drawable );
621 return context->hglrc ? GL_TRUE : GL_FALSE;
622#elif defined(Darwin)
623 CGLContextObj shareCtx = NULL;
624 CGLPixelFormatObj pix;
625 long npix;
626
627 CGLPixelFormatAttribute attribs[16];
628 GLint ind = 0;
629
630 if( context->share ) {
631 if( context->cglc != context->share->cglc ) {
632 crWarning("CGLCreateContext() is trying to share a non-existant "
633 "CGL context. Setting share context to zero.");
634 shareCtx = 0;
635 }
636 else
637 shareCtx = context->cglc;
638 }
639
640 stubSetPFA( context, attribs, 16, &ind );
641
642 stub.wsInterface.CGLChoosePixelFormat( attribs, &pix, &npix );
643 stub.wsInterface.CGLCreateContext( pix, shareCtx, &context->cglc );
644 if( !context->cglc )
645 crError("InstantiateNativeContext: Couldn't Create the context!");
646
647 stub.wsInterface.CGLDestroyPixelFormat( pix );
648
649 if( context->parambits ) {
650 /* Set the delayed parameters */
651 if( context->parambits & VISBIT_SWAP_RECT )
652 stub.wsInterface.CGLSetParameter( context->cglc, kCGLCPSwapRectangle, context->swap_rect );
653
654 if( context->parambits & VISBIT_SWAP_INTERVAL )
655 stub.wsInterface.CGLSetParameter( context->cglc, kCGLCPSwapInterval, &(context->swap_interval) );
656
657 if( context->parambits & VISBIT_CLIENT_STORAGE )
658 stub.wsInterface.CGLSetParameter( context->cglc, kCGLCPClientStorage, (long*)&(context->client_storage) );
659
660 context->parambits = 0;
661 }
662
663 return context->cglc ? GL_TRUE : GL_FALSE;
664#elif defined(GLX)
665 GLXContext shareCtx = 0;
666
667 /* sort out context sharing here */
668 if (context->share) {
669 if (context->glxContext != context->share->glxContext) {
670 crWarning("glXCreateContext() is trying to share a non-existant "
671 "GLX context. Setting share context to zero.");
672 shareCtx = 0;
673 }
674 else {
675 shareCtx = context->glxContext;
676 }
677 }
678
679 context->glxContext = stub.wsInterface.glXCreateContext( window->dpy,
680 context->visual, shareCtx, context->direct );
681
682 return context->glxContext ? GL_TRUE : GL_FALSE;
683#endif
684}
685
686
687/**
688 * Utility functions to get window size and titlebar text.
689 */
690#ifdef WINDOWS
691
692void
693stubGetWindowGeometry(WindowInfo *window, int *x, int *y,
694 unsigned int *w, unsigned int *h )
695{
696 RECT rect;
697
698 if (!window->drawable || !window->hWnd) {
699 *w = *h = 0;
700 return;
701 }
702
703 if (window->hWnd!=WindowFromDC(window->drawable))
704 {
705 crWarning("Window(%i) DC is no longer valid", window->spuWindow);
706 return;
707 }
708
709 if (!GetClientRect(window->hWnd, &rect))
710 {
711 crWarning("GetClientRect failed for %p", window->hWnd);
712 *w = *h = 0;
713 return;
714 }
715 *w = rect.right - rect.left;
716 *h = rect.bottom - rect.top;
717
718 if (!ClientToScreen( window->hWnd, (LPPOINT) &rect ))
719 {
720 crWarning("ClientToScreen failed for %p", window->hWnd);
721 *w = *h = 0;
722 return;
723 }
724 *x = rect.left;
725 *y = rect.top;
726}
727
728static void
729GetWindowTitle( const WindowInfo *window, char *title )
730{
731 /* XXX - we don't handle recurseUp */
732 if (window->hWnd)
733 GetWindowText(window->hWnd, title, 100);
734 else
735 title[0] = 0;
736}
737
738static void
739GetCursorPosition(WindowInfo *window, int pos[2])
740{
741 RECT rect;
742 POINT point;
743 GLint size[2], x, y;
744 unsigned int NativeHeight, NativeWidth, ChromiumHeight, ChromiumWidth;
745 float WidthRatio, HeightRatio;
746 static int DebugFlag = 0;
747
748 // apparently the "window" parameter passed to this
749 // function contains the native window information
750 HWND NATIVEhwnd = window->hWnd;
751
752 if (NATIVEhwnd!=WindowFromDC(window->drawable))
753 {
754 crWarning("Window(%i) DC is no longer valid", window->spuWindow);
755 return;
756 }
757
758 // get the native window's height and width
759 stubGetWindowGeometry(window, &x, &y, &NativeWidth, &NativeHeight);
760
761 // get the spu window's height and width
762 stub.spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, window->spuWindow, GL_INT, 2, size);
763 ChromiumWidth = size[0];
764 ChromiumHeight = size[1];
765
766 // get the ratio of the size of the native window to the cr window
767 WidthRatio = (float)ChromiumWidth / (float)NativeWidth;
768 HeightRatio = (float)ChromiumHeight / (float)NativeHeight;
769
770 // output some debug information at the beginning
771 if(DebugFlag)
772 {
773 DebugFlag = 0;
774 crDebug("Native Window Handle = %d", NATIVEhwnd);
775 crDebug("Native Width = %i", NativeWidth);
776 crDebug("Native Height = %i", NativeHeight);
777 crDebug("Chromium Width = %i", ChromiumWidth);
778 crDebug("Chromium Height = %i", ChromiumHeight);
779 }
780
781 if (NATIVEhwnd)
782 {
783 GetClientRect( NATIVEhwnd, &rect );
784 GetCursorPos (&point);
785
786 // make sure these coordinates are relative to the native window,
787 // not the whole desktop
788 ScreenToClient(NATIVEhwnd, &point);
789
790 // calculate the new position of the virtual cursor
791 pos[0] = (int)(point.x * WidthRatio);
792 pos[1] = (int)((NativeHeight - point.y) * HeightRatio);
793 }
794 else
795 {
796 pos[0] = 0;
797 pos[1] = 0;
798 }
799}
800
801#elif defined(Darwin)
802
803extern OSStatus CGSGetScreenRectForWindow( CGSConnectionID cid, CGSWindowID wid, float *outRect );
804extern OSStatus CGSGetWindowBounds( CGSConnectionID cid, CGSWindowID wid, float *bounds );
805
806void
807stubGetWindowGeometry( const WindowInfo *window, int *x, int *y, unsigned int *w, unsigned int *h )
808{
809 float rect[4];
810
811 if( !window ||
812 !window->connection ||
813 !window->drawable ||
814 CGSGetWindowBounds( window->connection, window->drawable, rect ) != noErr )
815 {
816 *x = *y = 0;
817 *w = *h = 0;
818 } else {
819 *x = (int) rect[0];
820 *y = (int) rect[1];
821 *w = (int) rect[2];
822 *h = (int) rect[3];
823 }
824}
825
826
827static void
828GetWindowTitle( const WindowInfo *window, char *title )
829{
830 /* XXX \todo Darwin window Title */
831 title[0] = '\0';
832}
833
834
835static void
836GetCursorPosition( const WindowInfo *window, int pos[2] )
837{
838 Point mouse_pos;
839 float window_rect[4];
840
841 GetMouse( &mouse_pos );
842 CGSGetScreenRectForWindow( window->connection, window->drawable, window_rect );
843
844 pos[0] = mouse_pos.h - (int) window_rect[0];
845 pos[1] = (int) window_rect[3] - (mouse_pos.v - (int) window_rect[1]);
846
847 /*crDebug( "%i %i", pos[0], pos[1] );*/
848}
849
850#elif defined(GLX)
851
852void
853stubGetWindowGeometry(WindowInfo *window, int *x, int *y, unsigned int *w, unsigned int *h)
854{
855 Window root, child;
856 unsigned int border, depth;
857 Display *dpy;
858
859 dpy = stubGetWindowDisplay(window);
860
861 //@todo: Performing those checks is expensive operation, especially for simple apps with high FPS.
862 // Disabling those triples glxgears fps, thus using xevents instead of per frame polling is much more preferred.
863 //@todo: Check similar on windows guests, though doubtful as there're no XSync like calls on windows.
864 if (window && dpy)
865 {
866 XLOCK(dpy);
867 }
868
869 if (!window
870 || !dpy
871 || !window->drawable
872 || !XGetGeometry(dpy, window->drawable, &root, x, y, w, h, &border, &depth)
873 || !XTranslateCoordinates(dpy, window->drawable, root, 0, 0, x, y, &child))
874 {
875 crWarning("Failed to get windows geometry for %p, try xwininfo", window);
876 *x = *y = 0;
877 *w = *h = 0;
878 }
879
880 if (window && dpy)
881 {
882 XUNLOCK(dpy);
883 }
884}
885
886static char *
887GetWindowTitleHelper( Display *dpy, Window window, GLboolean recurseUp )
888{
889 while (1) {
890 char *name;
891 if (!XFetchName(dpy, window, &name))
892 return NULL;
893 if (name[0]) {
894 return name;
895 }
896 else if (recurseUp) {
897 /* This window has no name, try the parent */
898 Status stat;
899 Window root, parent, *children;
900 unsigned int numChildren;
901 stat = XQueryTree( dpy, window, &root, &parent,
902 &children, &numChildren );
903 if (!stat || window == root)
904 return NULL;
905 if (children)
906 XFree(children);
907 window = parent;
908 }
909 else {
910 XFree(name);
911 return NULL;
912 }
913 }
914}
915
916static void
917GetWindowTitle( const WindowInfo *window, char *title )
918{
919 char *t = GetWindowTitleHelper(window->dpy, window->drawable, GL_TRUE);
920 if (t) {
921 crStrcpy(title, t);
922 XFree(t);
923 }
924 else {
925 title[0] = 0;
926 }
927}
928
929
930/**
931 *Return current cursor position in local window coords.
932 */
933static void
934GetCursorPosition(WindowInfo *window, int pos[2] )
935{
936 int rootX, rootY;
937 Window root, child;
938 unsigned int mask;
939 int x, y;
940
941 XLOCK(window->dpy);
942
943 Bool q = XQueryPointer(window->dpy, window->drawable, &root, &child,
944 &rootX, &rootY, &pos[0], &pos[1], &mask);
945 if (q) {
946 unsigned int w, h;
947 stubGetWindowGeometry( window, &x, &y, &w, &h );
948 /* invert Y */
949 pos[1] = (int) h - pos[1] - 1;
950 }
951 else {
952 pos[0] = pos[1] = 0;
953 }
954
955 XUNLOCK(window->dpy);
956}
957
958#endif
959
960
961/**
962 * This function is called by MakeCurrent() and determines whether or
963 * not a new rendering context should be bound to Chromium or the native
964 * OpenGL.
965 * \return GL_FALSE if native OpenGL should be used, or GL_TRUE if Chromium
966 * should be used.
967 */
968static GLboolean
969stubCheckUseChromium( WindowInfo *window )
970{
971 int x, y;
972 unsigned int w, h;
973
974 /* If the provided window is CHROMIUM, we're clearly intended
975 * to create a CHROMIUM context.
976 */
977 if (window->type == CHROMIUM)
978 return GL_TRUE;
979
980 if (stub.ignoreFreeglutMenus) {
981 const char *glutMenuTitle = "freeglut menu";
982 char title[1000];
983 GetWindowTitle(window, title);
984 if (crStrcmp(title, glutMenuTitle) == 0) {
985 crDebug("GL faker: Ignoring freeglut menu window");
986 return GL_FALSE;
987 }
988 }
989
990 /* If the user's specified a window count for Chromium, see if
991 * this window satisfies that criterium.
992 */
993 stub.matchChromiumWindowCounter++;
994 if (stub.matchChromiumWindowCount > 0) {
995 if (stub.matchChromiumWindowCounter != stub.matchChromiumWindowCount) {
996 crDebug("Using native GL, app window doesn't meet match_window_count");
997 return GL_FALSE;
998 }
999 }
1000
1001 /* If the user's specified a window list to ignore, see if this
1002 * window satisfies that criterium.
1003 */
1004 if (stub.matchChromiumWindowID) {
1005 GLuint i;
1006
1007 for (i = 0; i <= stub.numIgnoreWindowID; i++) {
1008 if (stub.matchChromiumWindowID[i] == stub.matchChromiumWindowCounter) {
1009 crDebug("Ignore window ID %d, using native GL", stub.matchChromiumWindowID[i]);
1010 return GL_FALSE;
1011 }
1012 }
1013 }
1014
1015 /* If the user's specified a minimum window size for Chromium, see if
1016 * this window satisfies that criterium.
1017 */
1018 if (stub.minChromiumWindowWidth > 0 &&
1019 stub.minChromiumWindowHeight > 0) {
1020 stubGetWindowGeometry( window, &x, &y, &w, &h );
1021 if (w >= stub.minChromiumWindowWidth &&
1022 h >= stub.minChromiumWindowHeight) {
1023
1024 /* Check for maximum sized window now too */
1025 if (stub.maxChromiumWindowWidth &&
1026 stub.maxChromiumWindowHeight) {
1027 if (w < stub.maxChromiumWindowWidth &&
1028 h < stub.maxChromiumWindowHeight)
1029 return GL_TRUE;
1030 else
1031 return GL_FALSE;
1032 }
1033
1034 return GL_TRUE;
1035 }
1036 crDebug("Using native GL, app window doesn't meet minimum_window_size");
1037 return GL_FALSE;
1038 }
1039 else if (stub.matchWindowTitle) {
1040 /* If the user's specified a window title for Chromium, see if this
1041 * window satisfies that criterium.
1042 */
1043 GLboolean wildcard = GL_FALSE;
1044 char title[1000];
1045 char *titlePattern;
1046 int len;
1047 /* check for leading '*' wildcard */
1048 if (stub.matchWindowTitle[0] == '*') {
1049 titlePattern = crStrdup( stub.matchWindowTitle + 1 );
1050 wildcard = GL_TRUE;
1051 }
1052 else {
1053 titlePattern = crStrdup( stub.matchWindowTitle );
1054 }
1055 /* check for trailing '*' wildcard */
1056 len = crStrlen(titlePattern);
1057 if (len > 0 && titlePattern[len - 1] == '*') {
1058 titlePattern[len - 1] = '\0'; /* terminate here */
1059 wildcard = GL_TRUE;
1060 }
1061
1062 GetWindowTitle( window, title );
1063 if (title[0]) {
1064 if (wildcard) {
1065 if (crStrstr(title, titlePattern)) {
1066 crFree(titlePattern);
1067 return GL_TRUE;
1068 }
1069 }
1070 else if (crStrcmp(title, titlePattern) == 0) {
1071 crFree(titlePattern);
1072 return GL_TRUE;
1073 }
1074 }
1075 crFree(titlePattern);
1076 crDebug("Using native GL, app window title doesn't match match_window_title string (\"%s\" != \"%s\")", title, stub.matchWindowTitle);
1077 return GL_FALSE;
1078 }
1079
1080 /* Window title and size don't matter */
1081 CRASSERT(stub.minChromiumWindowWidth == 0);
1082 CRASSERT(stub.minChromiumWindowHeight == 0);
1083 CRASSERT(stub.matchWindowTitle == NULL);
1084
1085 /* User hasn't specified a width/height or window title.
1086 * We'll use chromium for this window (and context) if no other is.
1087 */
1088
1089 return GL_TRUE; /* use Chromium! */
1090}
1091
1092static void stubWindowCheckOwnerCB(unsigned long key, void *data1, void *data2)
1093{
1094 WindowInfo *pWindow = (WindowInfo *) data1;
1095 ContextInfo *pCtx = (ContextInfo *) data2;
1096
1097 if (pWindow->pOwner == pCtx)
1098 {
1099#ifdef WINDOWS
1100 /* Note: can't use WindowFromDC(context->pOwnWindow->drawable) here
1101 because GL context is already released from DC and actual guest window
1102 could be destroyed.
1103 */
1104 stubDestroyWindow(CR_CTX_CON(pCtx), (GLint)pWindow->hWnd);
1105#else
1106 stubDestroyWindow(CR_CTX_CON(pCtx), (GLint)pWindow->drawable);
1107#endif
1108 }
1109}
1110
1111GLboolean stubCtxCreate(ContextInfo *context)
1112{
1113 /*
1114 * Create a Chromium context.
1115 */
1116#if defined(GLX) || defined(DARWIN)
1117 GLint spuShareCtx = context->share ? context->share->spuContext : 0;
1118#else
1119 GLint spuShareCtx = 0;
1120#endif
1121 GLint spuConnection = 0;
1122 CRASSERT(stub.spu);
1123 CRASSERT(stub.spu->dispatch_table.CreateContext);
1124 context->type = CHROMIUM;
1125
1126#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
1127 if (context->pHgsmi)
1128 {
1129 spuConnection = stub.spu->dispatch_table.VBoxConCreate(context->pHgsmi);
1130 if (!spuConnection)
1131 {
1132 crError("VBoxConCreate failed");
1133 return GL_FALSE;
1134 }
1135 context->spuConnection = spuConnection;
1136 }
1137#endif
1138
1139 context->spuContext
1140 = stub.spu->dispatch_table.VBoxCreateContext(spuConnection, context->dpyName,
1141 context->visBits,
1142 spuShareCtx);
1143
1144 return GL_TRUE;
1145}
1146
1147GLboolean stubCtxCheckCreate(ContextInfo *context)
1148{
1149 if (context->type == UNDECIDED)
1150 return stubCtxCreate(context);
1151 return CHROMIUM == context->type;
1152}
1153
1154
1155GLboolean
1156stubMakeCurrent( WindowInfo *window, ContextInfo *context )
1157{
1158 GLboolean retVal = GL_FALSE;
1159
1160 /*
1161 * Get WindowInfo and ContextInfo pointers.
1162 */
1163
1164 if (!context || !window) {
1165 ContextInfo * currentContext = stubGetCurrentContext();
1166 if (currentContext)
1167 currentContext->currentDrawable = NULL;
1168 if (context)
1169 context->currentDrawable = NULL;
1170 stubSetCurrentContext(NULL);
1171 return GL_TRUE; /* OK */
1172 }
1173
1174#ifdef CHROMIUM_THREADSAFE
1175 stubCheckMultithread();
1176#endif
1177
1178 if (context->type == UNDECIDED) {
1179 /* Here's where we really create contexts */
1180#ifdef CHROMIUM_THREADSAFE
1181 crLockMutex(&stub.mutex);
1182#endif
1183
1184 if (stubCheckUseChromium(window)) {
1185 GLint spuConnection = 0;
1186
1187 if (!stubCtxCreate(context))
1188 {
1189 crWarning("stubCtxCreate failed");
1190 return GL_FALSE;
1191 }
1192
1193#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
1194 spuConnection = context->spuConnection;
1195#endif
1196
1197 if (window->spuWindow == -1)
1198 {
1199 /*crDebug("(1)stubMakeCurrent ctx=%p(%i) window=%p(%i)", context, context->spuContext, window, window->spuWindow);*/
1200 window->spuWindow = stub.spu->dispatch_table.VBoxWindowCreate(spuConnection, window->dpyName, context->visBits );
1201#ifdef CR_NEWWINTRACK
1202 window->u32ClientID = stub.spu->dispatch_table.VBoxPackGetInjectID(spuConnection);
1203#endif
1204 }
1205 }
1206 else {
1207 /*
1208 * Create a native OpenGL context.
1209 */
1210 if (!InstantiateNativeContext(window, context))
1211 {
1212#ifdef CHROMIUM_THREADSAFE
1213 crUnlockMutex(&stub.mutex);
1214#endif
1215 return 0; /* false */
1216 }
1217 context->type = NATIVE;
1218 }
1219
1220#ifdef CHROMIUM_THREADSAFE
1221 crUnlockMutex(&stub.mutex);
1222#endif
1223 }
1224
1225
1226 if (context->type == NATIVE) {
1227 /*
1228 * Native OpenGL MakeCurrent().
1229 */
1230#ifdef WINDOWS
1231 retVal = (GLboolean) stub.wsInterface.wglMakeCurrent( window->drawable, context->hglrc );
1232#elif defined(Darwin)
1233 // XXX \todo We need to differentiate between these two..
1234 retVal = ( stub.wsInterface.CGLSetSurface(context->cglc, window->connection, window->drawable, window->surface) == noErr );
1235 retVal = ( stub.wsInterface.CGLSetCurrentContext(context->cglc) == noErr );
1236#elif defined(GLX)
1237 retVal = (GLboolean) stub.wsInterface.glXMakeCurrent( window->dpy, window->drawable, context->glxContext );
1238#endif
1239 }
1240 else {
1241 /*
1242 * SPU chain MakeCurrent().
1243 */
1244 CRASSERT(context->type == CHROMIUM);
1245 CRASSERT(context->spuContext >= 0);
1246
1247 /*if (context->currentDrawable && context->currentDrawable != window)
1248 crDebug("Rebinding context %p to a different window", context);*/
1249
1250 if (window->type == NATIVE) {
1251 crWarning("Can't rebind a chromium context to a native window\n");
1252 retVal = 0;
1253 }
1254 else {
1255 if (window->spuWindow == -1)
1256 {
1257 /*crDebug("(2)stubMakeCurrent ctx=%p(%i) window=%p(%i)", context, context->spuContext, window, window->spuWindow);*/
1258 window->spuWindow = stub.spu->dispatch_table.VBoxWindowCreate(
1259#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
1260 context->spuConnection,
1261#else
1262 0,
1263#endif
1264 window->dpyName, context->visBits );
1265#ifdef CR_NEWWINTRACK
1266 window->u32ClientID = stub.spu->dispatch_table.VBoxPackGetInjectID(
1267# if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
1268 context->spuConnection
1269# else
1270 0
1271# endif
1272 );
1273#endif
1274 if (context->currentDrawable && context->currentDrawable->type==CHROMIUM
1275 && context->currentDrawable->pOwner==context)
1276 {
1277#ifdef WINDOWS
1278 if (context->currentDrawable->hWnd!=WindowFromDC(context->currentDrawable->drawable))
1279 {
1280 stubDestroyWindow(CR_CTX_CON(context), (GLint)context->currentDrawable->hWnd);
1281 }
1282#else
1283 Window root;
1284 int x, y;
1285 unsigned int border, depth, w, h;
1286
1287 XLOCK(context->currentDrawable->dpy);
1288 if (!XGetGeometry(context->currentDrawable->dpy, context->currentDrawable->drawable, &root, &x, &y, &w, &h, &border, &depth))
1289 {
1290 stubDestroyWindow(CR_CTX_CON(context), (GLint)context->currentDrawable->drawable);
1291 }
1292 XUNLOCK(context->currentDrawable->dpy);
1293#endif
1294
1295 }
1296 }
1297
1298 if (window->spuWindow != (GLint)window->drawable)
1299 stub.spu->dispatch_table.MakeCurrent( window->spuWindow, (GLint) window->drawable, context->spuContext );
1300 else
1301 stub.spu->dispatch_table.MakeCurrent( window->spuWindow, 0, /* native window handle */ context->spuContext );
1302
1303 retVal = 1;
1304 }
1305 }
1306
1307 window->type = context->type;
1308 window->pOwner = context;
1309 context->currentDrawable = window;
1310 stubSetCurrentContext(context);
1311
1312 if (retVal) {
1313 /* Now, if we've transitions from Chromium to native rendering, or
1314 * vice versa, we have to change all the OpenGL entrypoint pointers.
1315 */
1316 if (context->type == NATIVE) {
1317 /* Switch to native API */
1318 /*printf(" Switching to native API\n");*/
1319 stubSetDispatch(&stub.nativeDispatch);
1320 }
1321 else if (context->type == CHROMIUM) {
1322 /* Switch to stub (SPU) API */
1323 /*printf(" Switching to spu API\n");*/
1324 stubSetDispatch(&stub.spuDispatch);
1325 }
1326 else {
1327 /* no API switch needed */
1328 }
1329 }
1330
1331 if (!window->width && window->type == CHROMIUM) {
1332 /* One time window setup */
1333 int x, y;
1334 unsigned int winW, winH;
1335
1336 stubGetWindowGeometry( window, &x, &y, &winW, &winH );
1337
1338 /* If we're not using GLX/WGL (no app window) we'll always get
1339 * a width and height of zero here. In that case, skip the viewport
1340 * call since we're probably using a tilesort SPU with fake_window_dims
1341 * which the tilesort SPU will use for the viewport.
1342 */
1343 window->width = winW;
1344 window->height = winH;
1345#if defined(WINDOWS) && defined(VBOX_WITH_WDDM)
1346 if (stubIsWindowVisible(window))
1347#endif
1348 {
1349 if (stub.trackWindowSize)
1350 stub.spuDispatch.WindowSize( window->spuWindow, winW, winH );
1351 if (stub.trackWindowPos)
1352 stub.spuDispatch.WindowPosition(window->spuWindow, x, y);
1353 if (winW > 0 && winH > 0)
1354 stub.spu->dispatch_table.Viewport( 0, 0, winW, winH );
1355 }
1356#ifdef VBOX_WITH_WDDM
1357 if (stub.trackWindowVisibleRgn)
1358 stub.spu->dispatch_table.WindowVisibleRegion(window->spuWindow, 0, NULL);
1359#endif
1360 }
1361
1362 /* Update window mapping state.
1363 * Basically, this lets us hide render SPU windows which correspond
1364 * to unmapped application windows. Without this, "pertly" (for example)
1365 * opens *lots* of temporary windows which otherwise clutter the screen.
1366 */
1367 if (stub.trackWindowVisibility && window->type == CHROMIUM && window->drawable) {
1368 const int mapped = stubIsWindowVisible(window);
1369 if (mapped != window->mapped) {
1370 crDebug("Dispatched: WindowShow(%i, %i)", window->spuWindow, mapped);
1371 stub.spu->dispatch_table.WindowShow(window->spuWindow, mapped);
1372 window->mapped = mapped;
1373 }
1374 }
1375
1376 return retVal;
1377}
1378
1379void
1380stubDestroyContext( unsigned long contextId )
1381{
1382 ContextInfo *context;
1383
1384 if (!stub.contextTable) {
1385 return;
1386 }
1387
1388 /* the lock order is windowTable->contextTable (see wglMakeCurrent_prox, glXMakeCurrent)
1389 * this is why we need to take a windowTable lock since we will later do stub.windowTable access & locking */
1390 crHashtableLock(stub.windowTable);
1391 crHashtableLock(stub.contextTable);
1392
1393 context = (ContextInfo *) crHashtableSearch(stub.contextTable, contextId);
1394 if (context)
1395 stubDestroyContextLocked(context);
1396 else
1397 crError("No context.");
1398
1399#ifdef CHROMIUM_THREADSAFE
1400 if (stubGetCurrentContext() == context) {
1401 stubSetCurrentContext(NULL);
1402 }
1403
1404 VBoxTlsRefMarkDestroy(context);
1405 VBoxTlsRefRelease(context);
1406#else
1407 if (stubGetCurrentContext() == context) {
1408 stubSetCurrentContext(NULL);
1409 }
1410 stubContextFree(context);
1411#endif
1412 crHashtableUnlock(stub.contextTable);
1413 crHashtableUnlock(stub.windowTable);
1414}
1415
1416void
1417stubSwapBuffers(WindowInfo *window, GLint flags)
1418{
1419 if (!window)
1420 return;
1421
1422 /* Determine if this window is being rendered natively or through
1423 * Chromium.
1424 */
1425
1426 if (window->type == NATIVE) {
1427 /*printf("*** Swapping native window %d\n", (int) drawable);*/
1428#ifdef WINDOWS
1429 (void) stub.wsInterface.wglSwapBuffers( window->drawable );
1430#elif defined(Darwin)
1431 /* ...is this ok? */
1432/* stub.wsInterface.CGLFlushDrawable( context->cglc ); */
1433 crDebug("stubSwapBuffers: unable to swap (no context!)");
1434#elif defined(GLX)
1435 stub.wsInterface.glXSwapBuffers( window->dpy, window->drawable );
1436#endif
1437 }
1438 else if (window->type == CHROMIUM) {
1439 /* Let the SPU do the buffer swap */
1440 /*printf("*** Swapping chromium window %d\n", (int) drawable);*/
1441 if (stub.appDrawCursor) {
1442 int pos[2];
1443 GetCursorPosition(window, pos);
1444 stub.spu->dispatch_table.ChromiumParametervCR(GL_CURSOR_POSITION_CR, GL_INT, 2, pos);
1445 }
1446 stub.spu->dispatch_table.SwapBuffers( window->spuWindow, flags );
1447 }
1448 else {
1449 crDebug("Calling SwapBuffers on a window we haven't seen before (no-op).");
1450 }
1451}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette