VirtualBox

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

Last change on this file since 53517 was 51559, checked in by vboxsync, 11 years ago

crOpenGL: wglShareLists support

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 41.1 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( const char *dpyName, GLint visBits, ContextType type,
480 unsigned long shareCtx
481#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
482 , struct VBOXUHGSMI *pHgsmi
483#endif
484 )
485{
486 GLint spuContext = -1, spuShareCtx = 0, spuConnection = 0;
487 ContextInfo *context;
488
489 if (shareCtx > 0) {
490 /* translate shareCtx to a SPU context ID */
491 context = (ContextInfo *)
492 crHashtableSearch(stub.contextTable, shareCtx);
493 if (context)
494 spuShareCtx = context->spuContext;
495 }
496
497 if (type == CHROMIUM) {
498#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
499 if (pHgsmi)
500 {
501 spuConnection = stub.spu->dispatch_table.VBoxConCreate(pHgsmi);
502 if (!spuConnection)
503 {
504 crWarning("VBoxConCreate failed");
505 return NULL;
506 }
507 }
508#endif
509 spuContext
510 = stub.spu->dispatch_table.VBoxCreateContext(spuConnection, dpyName, visBits, spuShareCtx);
511 if (spuContext < 0)
512 {
513 crWarning("VBoxCreateContext failed");
514#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
515 if (spuConnection)
516 stub.spu->dispatch_table.VBoxConDestroy(spuConnection);
517#endif
518 return NULL;
519 }
520 }
521
522 context = crCalloc(sizeof(ContextInfo));
523 if (!context) {
524 stub.spu->dispatch_table.DestroyContext(spuContext);
525#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
526 if (spuConnection)
527 stub.spu->dispatch_table.VBoxConDestroy(spuConnection);
528#endif
529 return NULL;
530 }
531
532 if (!dpyName)
533 dpyName = "";
534
535 context->id = stub.freeContextNumber++;
536 context->type = type;
537 context->spuContext = spuContext;
538 context->visBits = visBits;
539 context->currentDrawable = NULL;
540 crStrncpy(context->dpyName, dpyName, MAX_DPY_NAME);
541 context->dpyName[MAX_DPY_NAME-1] = 0;
542
543#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
544 context->spuConnection = spuConnection;
545 context->pHgsmi = pHgsmi;
546#endif
547
548#ifdef CHROMIUM_THREADSAFE
549 VBoxTlsRefInit(context, stubContextDtor);
550#endif
551
552#if defined(GLX) || defined(DARWIN)
553 context->share = (ContextInfo *)
554 crHashtableSearch(stub.contextTable, (unsigned long) shareCtx);
555#endif
556
557#ifdef GLX
558 context->pGLXPixmapsHash = crAllocHashtable();
559 context->damageQueryFailed = GL_FALSE;
560 context->damageEventsBase = 0;
561#endif
562
563 crHashtableAdd(stub.contextTable, context->id, (void *) context);
564
565 return context;
566}
567
568
569#ifdef Darwin
570
571#define SET_ATTR(l,i,a) ( (l)[(i)++] = (a) )
572#define SET_ATTR_V(l,i,a,v) ( SET_ATTR(l,i,a), SET_ATTR(l,i,v) )
573
574void stubSetPFA( ContextInfo *ctx, CGLPixelFormatAttribute *attribs, int size, GLint *num ) {
575 GLuint visual = ctx->visBits;
576 int i = 0;
577
578 CRASSERT(visual & CR_RGB_BIT);
579
580 SET_ATTR_V(attribs, i, kCGLPFAColorSize, 8);
581
582 if( visual & CR_DEPTH_BIT )
583 SET_ATTR_V(attribs, i, kCGLPFADepthSize, 16);
584
585 if( visual & CR_ACCUM_BIT )
586 SET_ATTR_V(attribs, i, kCGLPFAAccumSize, 1);
587
588 if( visual & CR_STENCIL_BIT )
589 SET_ATTR_V(attribs, i, kCGLPFAStencilSize, 1);
590
591 if( visual & CR_ALPHA_BIT )
592 SET_ATTR_V(attribs, i, kCGLPFAAlphaSize, 1);
593
594 if( visual & CR_DOUBLE_BIT )
595 SET_ATTR(attribs, i, kCGLPFADoubleBuffer);
596
597 if( visual & CR_STEREO_BIT )
598 SET_ATTR(attribs, i, kCGLPFAStereo);
599
600/* SET_ATTR_V(attribs, i, kCGLPFASampleBuffers, 1);
601 SET_ATTR_V(attribs, i, kCGLPFASamples, 0);
602 SET_ATTR_V(attribs, i, kCGLPFADisplayMask, 0); */
603 SET_ATTR(attribs, i, kCGLPFABackingStore);
604 SET_ATTR(attribs, i, kCGLPFAWindow);
605 SET_ATTR_V(attribs, i, kCGLPFADisplayMask, ctx->disp_mask);
606
607 SET_ATTR(attribs, i, 0);
608
609 *num = i;
610}
611
612#endif
613
614/**
615 * This creates a native GLX/WGL context.
616 */
617static GLboolean
618InstantiateNativeContext( WindowInfo *window, ContextInfo *context )
619{
620#ifdef WINDOWS
621 context->hglrc = stub.wsInterface.wglCreateContext( window->drawable );
622 return context->hglrc ? GL_TRUE : GL_FALSE;
623#elif defined(Darwin)
624 CGLContextObj shareCtx = NULL;
625 CGLPixelFormatObj pix;
626 long npix;
627
628 CGLPixelFormatAttribute attribs[16];
629 GLint ind = 0;
630
631 if( context->share ) {
632 if( context->cglc != context->share->cglc ) {
633 crWarning("CGLCreateContext() is trying to share a non-existant "
634 "CGL context. Setting share context to zero.");
635 shareCtx = 0;
636 }
637 else
638 shareCtx = context->cglc;
639 }
640
641 stubSetPFA( context, attribs, 16, &ind );
642
643 stub.wsInterface.CGLChoosePixelFormat( attribs, &pix, &npix );
644 stub.wsInterface.CGLCreateContext( pix, shareCtx, &context->cglc );
645 if( !context->cglc )
646 crError("InstantiateNativeContext: Couldn't Create the context!");
647
648 stub.wsInterface.CGLDestroyPixelFormat( pix );
649
650 if( context->parambits ) {
651 /* Set the delayed parameters */
652 if( context->parambits & VISBIT_SWAP_RECT )
653 stub.wsInterface.CGLSetParameter( context->cglc, kCGLCPSwapRectangle, context->swap_rect );
654
655 if( context->parambits & VISBIT_SWAP_INTERVAL )
656 stub.wsInterface.CGLSetParameter( context->cglc, kCGLCPSwapInterval, &(context->swap_interval) );
657
658 if( context->parambits & VISBIT_CLIENT_STORAGE )
659 stub.wsInterface.CGLSetParameter( context->cglc, kCGLCPClientStorage, (long*)&(context->client_storage) );
660
661 context->parambits = 0;
662 }
663
664 return context->cglc ? GL_TRUE : GL_FALSE;
665#elif defined(GLX)
666 GLXContext shareCtx = 0;
667
668 /* sort out context sharing here */
669 if (context->share) {
670 if (context->glxContext != context->share->glxContext) {
671 crWarning("glXCreateContext() is trying to share a non-existant "
672 "GLX context. Setting share context to zero.");
673 shareCtx = 0;
674 }
675 else {
676 shareCtx = context->glxContext;
677 }
678 }
679
680 context->glxContext = stub.wsInterface.glXCreateContext( window->dpy,
681 context->visual, shareCtx, context->direct );
682
683 return context->glxContext ? GL_TRUE : GL_FALSE;
684#endif
685}
686
687
688/**
689 * Utility functions to get window size and titlebar text.
690 */
691#ifdef WINDOWS
692
693void
694stubGetWindowGeometry(const WindowInfo *window, int *x, int *y,
695 unsigned int *w, unsigned int *h )
696{
697 RECT rect;
698
699 if (!window->drawable || !window->hWnd) {
700 *w = *h = 0;
701 return;
702 }
703
704 if (window->hWnd!=WindowFromDC(window->drawable))
705 {
706 crWarning("Window(%i) DC is no longer valid", window->spuWindow);
707 return;
708 }
709
710 if (!GetClientRect(window->hWnd, &rect))
711 {
712 crWarning("GetClientRect failed for %p", window->hWnd);
713 *w = *h = 0;
714 return;
715 }
716 *w = rect.right - rect.left;
717 *h = rect.bottom - rect.top;
718
719 if (!ClientToScreen( window->hWnd, (LPPOINT) &rect ))
720 {
721 crWarning("ClientToScreen failed for %p", window->hWnd);
722 *w = *h = 0;
723 return;
724 }
725 *x = rect.left;
726 *y = rect.top;
727}
728
729static void
730GetWindowTitle( const WindowInfo *window, char *title )
731{
732 /* XXX - we don't handle recurseUp */
733 if (window->hWnd)
734 GetWindowText(window->hWnd, title, 100);
735 else
736 title[0] = 0;
737}
738
739static void
740GetCursorPosition(WindowInfo *window, int pos[2])
741{
742 RECT rect;
743 POINT point;
744 GLint size[2], x, y;
745 unsigned int NativeHeight, NativeWidth, ChromiumHeight, ChromiumWidth;
746 float WidthRatio, HeightRatio;
747 static int DebugFlag = 0;
748
749 // apparently the "window" parameter passed to this
750 // function contains the native window information
751 HWND NATIVEhwnd = window->hWnd;
752
753 if (NATIVEhwnd!=WindowFromDC(window->drawable))
754 {
755 crWarning("Window(%i) DC is no longer valid", window->spuWindow);
756 return;
757 }
758
759 // get the native window's height and width
760 stubGetWindowGeometry(window, &x, &y, &NativeWidth, &NativeHeight);
761
762 // get the spu window's height and width
763 stub.spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, window->spuWindow, GL_INT, 2, size);
764 ChromiumWidth = size[0];
765 ChromiumHeight = size[1];
766
767 // get the ratio of the size of the native window to the cr window
768 WidthRatio = (float)ChromiumWidth / (float)NativeWidth;
769 HeightRatio = (float)ChromiumHeight / (float)NativeHeight;
770
771 // output some debug information at the beginning
772 if(DebugFlag)
773 {
774 DebugFlag = 0;
775 crDebug("Native Window Handle = %d", NATIVEhwnd);
776 crDebug("Native Width = %i", NativeWidth);
777 crDebug("Native Height = %i", NativeHeight);
778 crDebug("Chromium Width = %i", ChromiumWidth);
779 crDebug("Chromium Height = %i", ChromiumHeight);
780 }
781
782 if (NATIVEhwnd)
783 {
784 GetClientRect( NATIVEhwnd, &rect );
785 GetCursorPos (&point);
786
787 // make sure these coordinates are relative to the native window,
788 // not the whole desktop
789 ScreenToClient(NATIVEhwnd, &point);
790
791 // calculate the new position of the virtual cursor
792 pos[0] = (int)(point.x * WidthRatio);
793 pos[1] = (int)((NativeHeight - point.y) * HeightRatio);
794 }
795 else
796 {
797 pos[0] = 0;
798 pos[1] = 0;
799 }
800}
801
802#elif defined(Darwin)
803
804extern OSStatus CGSGetScreenRectForWindow( CGSConnectionID cid, CGSWindowID wid, float *outRect );
805extern OSStatus CGSGetWindowBounds( CGSConnectionID cid, CGSWindowID wid, float *bounds );
806
807void
808stubGetWindowGeometry( const WindowInfo *window, int *x, int *y, unsigned int *w, unsigned int *h )
809{
810 float rect[4];
811
812 if( !window ||
813 !window->connection ||
814 !window->drawable ||
815 CGSGetWindowBounds( window->connection, window->drawable, rect ) != noErr )
816 {
817 *x = *y = 0;
818 *w = *h = 0;
819 } else {
820 *x = (int) rect[0];
821 *y = (int) rect[1];
822 *w = (int) rect[2];
823 *h = (int) rect[3];
824 }
825}
826
827
828static void
829GetWindowTitle( const WindowInfo *window, char *title )
830{
831 /* XXX \todo Darwin window Title */
832 title[0] = '\0';
833}
834
835
836static void
837GetCursorPosition( const WindowInfo *window, int pos[2] )
838{
839 Point mouse_pos;
840 float window_rect[4];
841
842 GetMouse( &mouse_pos );
843 CGSGetScreenRectForWindow( window->connection, window->drawable, window_rect );
844
845 pos[0] = mouse_pos.h - (int) window_rect[0];
846 pos[1] = (int) window_rect[3] - (mouse_pos.v - (int) window_rect[1]);
847
848 /*crDebug( "%i %i", pos[0], pos[1] );*/
849}
850
851#elif defined(GLX)
852
853void
854stubGetWindowGeometry(WindowInfo *window, int *x, int *y, unsigned int *w, unsigned int *h)
855{
856 Window root, child;
857 unsigned int border, depth;
858 Display *dpy;
859
860 dpy = stubGetWindowDisplay(window);
861
862 //@todo: Performing those checks is expensive operation, especially for simple apps with high FPS.
863 // Disabling those triples glxgears fps, thus using xevents instead of per frame polling is much more preferred.
864 //@todo: Check similar on windows guests, though doubtful as there're no XSync like calls on windows.
865 if (window && dpy)
866 {
867 XLOCK(dpy);
868 }
869
870 if (!window
871 || !dpy
872 || !window->drawable
873 || !XGetGeometry(dpy, window->drawable, &root, x, y, w, h, &border, &depth)
874 || !XTranslateCoordinates(dpy, window->drawable, root, 0, 0, x, y, &child))
875 {
876 crWarning("Failed to get windows geometry for %p, try xwininfo", window);
877 *x = *y = 0;
878 *w = *h = 0;
879 }
880
881 if (window && dpy)
882 {
883 XUNLOCK(dpy);
884 }
885}
886
887static char *
888GetWindowTitleHelper( Display *dpy, Window window, GLboolean recurseUp )
889{
890 while (1) {
891 char *name;
892 if (!XFetchName(dpy, window, &name))
893 return NULL;
894 if (name[0]) {
895 return name;
896 }
897 else if (recurseUp) {
898 /* This window has no name, try the parent */
899 Status stat;
900 Window root, parent, *children;
901 unsigned int numChildren;
902 stat = XQueryTree( dpy, window, &root, &parent,
903 &children, &numChildren );
904 if (!stat || window == root)
905 return NULL;
906 if (children)
907 XFree(children);
908 window = parent;
909 }
910 else {
911 XFree(name);
912 return NULL;
913 }
914 }
915}
916
917static void
918GetWindowTitle( const WindowInfo *window, char *title )
919{
920 char *t = GetWindowTitleHelper(window->dpy, window->drawable, GL_TRUE);
921 if (t) {
922 crStrcpy(title, t);
923 XFree(t);
924 }
925 else {
926 title[0] = 0;
927 }
928}
929
930
931/**
932 *Return current cursor position in local window coords.
933 */
934static void
935GetCursorPosition(WindowInfo *window, int pos[2] )
936{
937 int rootX, rootY;
938 Window root, child;
939 unsigned int mask;
940 int x, y;
941
942 XLOCK(window->dpy);
943
944 Bool q = XQueryPointer(window->dpy, window->drawable, &root, &child,
945 &rootX, &rootY, &pos[0], &pos[1], &mask);
946 if (q) {
947 unsigned int w, h;
948 stubGetWindowGeometry( window, &x, &y, &w, &h );
949 /* invert Y */
950 pos[1] = (int) h - pos[1] - 1;
951 }
952 else {
953 pos[0] = pos[1] = 0;
954 }
955
956 XUNLOCK(window->dpy);
957}
958
959#endif
960
961
962/**
963 * This function is called by MakeCurrent() and determines whether or
964 * not a new rendering context should be bound to Chromium or the native
965 * OpenGL.
966 * \return GL_FALSE if native OpenGL should be used, or GL_TRUE if Chromium
967 * should be used.
968 */
969static GLboolean
970stubCheckUseChromium( WindowInfo *window )
971{
972 int x, y;
973 unsigned int w, h;
974
975 /* If the provided window is CHROMIUM, we're clearly intended
976 * to create a CHROMIUM context.
977 */
978 if (window->type == CHROMIUM)
979 return GL_TRUE;
980
981 if (stub.ignoreFreeglutMenus) {
982 const char *glutMenuTitle = "freeglut menu";
983 char title[1000];
984 GetWindowTitle(window, title);
985 if (crStrcmp(title, glutMenuTitle) == 0) {
986 crDebug("GL faker: Ignoring freeglut menu window");
987 return GL_FALSE;
988 }
989 }
990
991 /* If the user's specified a window count for Chromium, see if
992 * this window satisfies that criterium.
993 */
994 stub.matchChromiumWindowCounter++;
995 if (stub.matchChromiumWindowCount > 0) {
996 if (stub.matchChromiumWindowCounter != stub.matchChromiumWindowCount) {
997 crDebug("Using native GL, app window doesn't meet match_window_count");
998 return GL_FALSE;
999 }
1000 }
1001
1002 /* If the user's specified a window list to ignore, see if this
1003 * window satisfies that criterium.
1004 */
1005 if (stub.matchChromiumWindowID) {
1006 GLuint i;
1007
1008 for (i = 0; i <= stub.numIgnoreWindowID; i++) {
1009 if (stub.matchChromiumWindowID[i] == stub.matchChromiumWindowCounter) {
1010 crDebug("Ignore window ID %d, using native GL", stub.matchChromiumWindowID[i]);
1011 return GL_FALSE;
1012 }
1013 }
1014 }
1015
1016 /* If the user's specified a minimum window size for Chromium, see if
1017 * this window satisfies that criterium.
1018 */
1019 if (stub.minChromiumWindowWidth > 0 &&
1020 stub.minChromiumWindowHeight > 0) {
1021 stubGetWindowGeometry( window, &x, &y, &w, &h );
1022 if (w >= stub.minChromiumWindowWidth &&
1023 h >= stub.minChromiumWindowHeight) {
1024
1025 /* Check for maximum sized window now too */
1026 if (stub.maxChromiumWindowWidth &&
1027 stub.maxChromiumWindowHeight) {
1028 if (w < stub.maxChromiumWindowWidth &&
1029 h < stub.maxChromiumWindowHeight)
1030 return GL_TRUE;
1031 else
1032 return GL_FALSE;
1033 }
1034
1035 return GL_TRUE;
1036 }
1037 crDebug("Using native GL, app window doesn't meet minimum_window_size");
1038 return GL_FALSE;
1039 }
1040 else if (stub.matchWindowTitle) {
1041 /* If the user's specified a window title for Chromium, see if this
1042 * window satisfies that criterium.
1043 */
1044 GLboolean wildcard = GL_FALSE;
1045 char title[1000];
1046 char *titlePattern;
1047 int len;
1048 /* check for leading '*' wildcard */
1049 if (stub.matchWindowTitle[0] == '*') {
1050 titlePattern = crStrdup( stub.matchWindowTitle + 1 );
1051 wildcard = GL_TRUE;
1052 }
1053 else {
1054 titlePattern = crStrdup( stub.matchWindowTitle );
1055 }
1056 /* check for trailing '*' wildcard */
1057 len = crStrlen(titlePattern);
1058 if (len > 0 && titlePattern[len - 1] == '*') {
1059 titlePattern[len - 1] = '\0'; /* terminate here */
1060 wildcard = GL_TRUE;
1061 }
1062
1063 GetWindowTitle( window, title );
1064 if (title[0]) {
1065 if (wildcard) {
1066 if (crStrstr(title, titlePattern)) {
1067 crFree(titlePattern);
1068 return GL_TRUE;
1069 }
1070 }
1071 else if (crStrcmp(title, titlePattern) == 0) {
1072 crFree(titlePattern);
1073 return GL_TRUE;
1074 }
1075 }
1076 crFree(titlePattern);
1077 crDebug("Using native GL, app window title doesn't match match_window_title string (\"%s\" != \"%s\")", title, stub.matchWindowTitle);
1078 return GL_FALSE;
1079 }
1080
1081 /* Window title and size don't matter */
1082 CRASSERT(stub.minChromiumWindowWidth == 0);
1083 CRASSERT(stub.minChromiumWindowHeight == 0);
1084 CRASSERT(stub.matchWindowTitle == NULL);
1085
1086 /* User hasn't specified a width/height or window title.
1087 * We'll use chromium for this window (and context) if no other is.
1088 */
1089
1090 return GL_TRUE; /* use Chromium! */
1091}
1092
1093static void stubWindowCheckOwnerCB(unsigned long key, void *data1, void *data2)
1094{
1095 WindowInfo *pWindow = (WindowInfo *) data1;
1096 ContextInfo *pCtx = (ContextInfo *) data2;
1097
1098 if (pWindow->pOwner == pCtx)
1099 {
1100#ifdef WINDOWS
1101 /* Note: can't use WindowFromDC(context->pOwnWindow->drawable) here
1102 because GL context is already released from DC and actual guest window
1103 could be destroyed.
1104 */
1105 stubDestroyWindow(CR_CTX_CON(pCtx), (GLint)pWindow->hWnd);
1106#else
1107 stubDestroyWindow(CR_CTX_CON(pCtx), (GLint)pWindow->drawable);
1108#endif
1109 }
1110}
1111
1112GLboolean stubCtxCreate(ContextInfo *context)
1113{
1114 /*
1115 * Create a Chromium context.
1116 */
1117#if defined(GLX) || defined(DARWIN)
1118 GLint spuShareCtx = context->share ? context->share->spuContext : 0;
1119#else
1120 GLint spuShareCtx = 0;
1121#endif
1122 GLint spuConnection = 0;
1123 CRASSERT(stub.spu);
1124 CRASSERT(stub.spu->dispatch_table.CreateContext);
1125 context->type = CHROMIUM;
1126
1127#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
1128 if (context->pHgsmi)
1129 {
1130 spuConnection = stub.spu->dispatch_table.VBoxConCreate(context->pHgsmi);
1131 if (!spuConnection)
1132 {
1133 crWarning("VBoxConCreate failed");
1134 return GL_FALSE;
1135 }
1136 context->spuConnection = spuConnection;
1137 }
1138#endif
1139
1140 context->spuContext
1141 = stub.spu->dispatch_table.VBoxCreateContext(spuConnection, context->dpyName,
1142 context->visBits,
1143 spuShareCtx);
1144
1145 return GL_TRUE;
1146}
1147
1148GLboolean stubCtxCheckCreate(ContextInfo *context)
1149{
1150 if (context->type == UNDECIDED)
1151 return stubCtxCreate(context);
1152 return CHROMIUM == context->type;
1153}
1154
1155
1156GLboolean
1157stubMakeCurrent( WindowInfo *window, ContextInfo *context )
1158{
1159 GLboolean retVal;
1160
1161 /*
1162 * Get WindowInfo and ContextInfo pointers.
1163 */
1164
1165 if (!context || !window) {
1166 ContextInfo * currentContext = stubGetCurrentContext();
1167 if (currentContext)
1168 currentContext->currentDrawable = NULL;
1169 if (context)
1170 context->currentDrawable = NULL;
1171 stubSetCurrentContext(NULL);
1172 return GL_TRUE; /* OK */
1173 }
1174
1175#ifdef CHROMIUM_THREADSAFE
1176 stubCheckMultithread();
1177#endif
1178
1179 if (context->type == UNDECIDED) {
1180 /* Here's where we really create contexts */
1181#ifdef CHROMIUM_THREADSAFE
1182 crLockMutex(&stub.mutex);
1183#endif
1184
1185 if (stubCheckUseChromium(window)) {
1186 GLint spuConnection = 0;
1187
1188 if (!stubCtxCreate(context))
1189 {
1190 crWarning("stubCtxCreate failed");
1191 return GL_FALSE;
1192 }
1193
1194#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
1195 spuConnection = context->spuConnection;
1196#endif
1197
1198 if (window->spuWindow == -1)
1199 {
1200 /*crDebug("(1)stubMakeCurrent ctx=%p(%i) window=%p(%i)", context, context->spuContext, window, window->spuWindow);*/
1201 window->spuWindow = stub.spu->dispatch_table.VBoxWindowCreate(spuConnection, window->dpyName, context->visBits );
1202#ifdef CR_NEWWINTRACK
1203 window->u32ClientID = stub.spu->dispatch_table.VBoxPackGetInjectID(spuConnection);
1204#endif
1205 }
1206 }
1207 else {
1208 /*
1209 * Create a native OpenGL context.
1210 */
1211 if (!InstantiateNativeContext(window, context))
1212 {
1213#ifdef CHROMIUM_THREADSAFE
1214 crUnlockMutex(&stub.mutex);
1215#endif
1216 return 0; /* false */
1217 }
1218 context->type = NATIVE;
1219 }
1220
1221#ifdef CHROMIUM_THREADSAFE
1222 crUnlockMutex(&stub.mutex);
1223#endif
1224 }
1225
1226
1227 if (context->type == NATIVE) {
1228 /*
1229 * Native OpenGL MakeCurrent().
1230 */
1231#ifdef WINDOWS
1232 retVal = (GLboolean) stub.wsInterface.wglMakeCurrent( window->drawable, context->hglrc );
1233#elif defined(Darwin)
1234 // XXX \todo We need to differentiate between these two..
1235 retVal = ( stub.wsInterface.CGLSetSurface(context->cglc, window->connection, window->drawable, window->surface) == noErr );
1236 retVal = ( stub.wsInterface.CGLSetCurrentContext(context->cglc) == noErr );
1237#elif defined(GLX)
1238 retVal = (GLboolean) stub.wsInterface.glXMakeCurrent( window->dpy, window->drawable, context->glxContext );
1239#endif
1240 }
1241 else {
1242 /*
1243 * SPU chain MakeCurrent().
1244 */
1245 CRASSERT(context->type == CHROMIUM);
1246 CRASSERT(context->spuContext >= 0);
1247
1248 /*if (context->currentDrawable && context->currentDrawable != window)
1249 crDebug("Rebinding context %p to a different window", context);*/
1250
1251 if (window->type == NATIVE) {
1252 crWarning("Can't rebind a chromium context to a native window\n");
1253 retVal = 0;
1254 }
1255 else {
1256 if (window->spuWindow == -1)
1257 {
1258 /*crDebug("(2)stubMakeCurrent ctx=%p(%i) window=%p(%i)", context, context->spuContext, window, window->spuWindow);*/
1259 window->spuWindow = stub.spu->dispatch_table.VBoxWindowCreate(
1260#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
1261 context->spuConnection,
1262#else
1263 0,
1264#endif
1265 window->dpyName, context->visBits );
1266#ifdef CR_NEWWINTRACK
1267 window->u32ClientID = stub.spu->dispatch_table.VBoxPackGetInjectID(
1268# if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
1269 context->spuConnection
1270# else
1271 0
1272# endif
1273 );
1274#endif
1275 if (context->currentDrawable && context->currentDrawable->type==CHROMIUM
1276 && context->currentDrawable->pOwner==context)
1277 {
1278#ifdef WINDOWS
1279 if (context->currentDrawable->hWnd!=WindowFromDC(context->currentDrawable->drawable))
1280 {
1281 stubDestroyWindow(CR_CTX_CON(context), (GLint)context->currentDrawable->hWnd);
1282 }
1283#else
1284 Window root;
1285 int x, y;
1286 unsigned int border, depth, w, h;
1287
1288 XLOCK(context->currentDrawable->dpy);
1289 if (!XGetGeometry(context->currentDrawable->dpy, context->currentDrawable->drawable, &root, &x, &y, &w, &h, &border, &depth))
1290 {
1291 stubDestroyWindow(CR_CTX_CON(context), (GLint)context->currentDrawable->drawable);
1292 }
1293 XUNLOCK(context->currentDrawable->dpy);
1294#endif
1295
1296 }
1297 }
1298
1299 if (window->spuWindow != (GLint)window->drawable)
1300 stub.spu->dispatch_table.MakeCurrent( window->spuWindow, (GLint) window->drawable, context->spuContext );
1301 else
1302 stub.spu->dispatch_table.MakeCurrent( window->spuWindow, 0, /* native window handle */ context->spuContext );
1303
1304 retVal = 1;
1305 }
1306 }
1307
1308 window->type = context->type;
1309 window->pOwner = context;
1310 context->currentDrawable = window;
1311 stubSetCurrentContext(context);
1312
1313 if (retVal) {
1314 /* Now, if we've transitions from Chromium to native rendering, or
1315 * vice versa, we have to change all the OpenGL entrypoint pointers.
1316 */
1317 if (context->type == NATIVE) {
1318 /* Switch to native API */
1319 /*printf(" Switching to native API\n");*/
1320 stubSetDispatch(&stub.nativeDispatch);
1321 }
1322 else if (context->type == CHROMIUM) {
1323 /* Switch to stub (SPU) API */
1324 /*printf(" Switching to spu API\n");*/
1325 stubSetDispatch(&stub.spuDispatch);
1326 }
1327 else {
1328 /* no API switch needed */
1329 }
1330 }
1331
1332 if (!window->width && window->type == CHROMIUM) {
1333 /* One time window setup */
1334 int x, y;
1335 unsigned int winW, winH;
1336
1337 stubGetWindowGeometry( window, &x, &y, &winW, &winH );
1338
1339 /* If we're not using GLX/WGL (no app window) we'll always get
1340 * a width and height of zero here. In that case, skip the viewport
1341 * call since we're probably using a tilesort SPU with fake_window_dims
1342 * which the tilesort SPU will use for the viewport.
1343 */
1344 window->width = winW;
1345 window->height = winH;
1346#if defined(WINDOWS) && defined(VBOX_WITH_WDDM)
1347 if (stubIsWindowVisible(window))
1348#endif
1349 {
1350 if (stub.trackWindowSize)
1351 stub.spuDispatch.WindowSize( window->spuWindow, winW, winH );
1352 if (stub.trackWindowPos)
1353 stub.spuDispatch.WindowPosition(window->spuWindow, x, y);
1354 if (winW > 0 && winH > 0)
1355 stub.spu->dispatch_table.Viewport( 0, 0, winW, winH );
1356 }
1357#ifdef VBOX_WITH_WDDM
1358 if (stub.trackWindowVisibleRgn)
1359 stub.spu->dispatch_table.WindowVisibleRegion(window->spuWindow, 0, NULL);
1360#endif
1361 }
1362
1363 /* Update window mapping state.
1364 * Basically, this lets us hide render SPU windows which correspond
1365 * to unmapped application windows. Without this, "pertly" (for example)
1366 * opens *lots* of temporary windows which otherwise clutter the screen.
1367 */
1368 if (stub.trackWindowVisibility && window->type == CHROMIUM && window->drawable) {
1369 const int mapped = stubIsWindowVisible(window);
1370 if (mapped != window->mapped) {
1371 crDebug("Dispatched: WindowShow(%i, %i)", window->spuWindow, mapped);
1372 stub.spu->dispatch_table.WindowShow(window->spuWindow, mapped);
1373 window->mapped = mapped;
1374 }
1375 }
1376
1377 return retVal;
1378}
1379
1380void
1381stubDestroyContext( unsigned long contextId )
1382{
1383 ContextInfo *context;
1384
1385 if (!stub.contextTable) {
1386 return;
1387 }
1388
1389 /* the lock order is windowTable->contextTable (see wglMakeCurrent_prox, glXMakeCurrent)
1390 * this is why we need to take a windowTable lock since we will later do stub.windowTable access & locking */
1391 crHashtableLock(stub.windowTable);
1392 crHashtableLock(stub.contextTable);
1393
1394 context = (ContextInfo *) crHashtableSearch(stub.contextTable, contextId);
1395
1396 CRASSERT(context);
1397
1398 stubDestroyContextLocked(context);
1399
1400#ifdef CHROMIUM_THREADSAFE
1401 if (stubGetCurrentContext() == context) {
1402 stubSetCurrentContext(NULL);
1403 }
1404
1405 VBoxTlsRefMarkDestroy(context);
1406 VBoxTlsRefRelease(context);
1407#else
1408 if (stubGetCurrentContext() == context) {
1409 stubSetCurrentContext(NULL);
1410 }
1411 stubContextFree(context);
1412#endif
1413 crHashtableUnlock(stub.contextTable);
1414 crHashtableUnlock(stub.windowTable);
1415}
1416
1417void
1418stubSwapBuffers(WindowInfo *window, GLint flags)
1419{
1420 if (!window)
1421 return;
1422
1423 /* Determine if this window is being rendered natively or through
1424 * Chromium.
1425 */
1426
1427 if (window->type == NATIVE) {
1428 /*printf("*** Swapping native window %d\n", (int) drawable);*/
1429#ifdef WINDOWS
1430 (void) stub.wsInterface.wglSwapBuffers( window->drawable );
1431#elif defined(Darwin)
1432 /* ...is this ok? */
1433/* stub.wsInterface.CGLFlushDrawable( context->cglc ); */
1434 crDebug("stubSwapBuffers: unable to swap (no context!)");
1435#elif defined(GLX)
1436 stub.wsInterface.glXSwapBuffers( window->dpy, window->drawable );
1437#endif
1438 }
1439 else if (window->type == CHROMIUM) {
1440 /* Let the SPU do the buffer swap */
1441 /*printf("*** Swapping chromium window %d\n", (int) drawable);*/
1442 if (stub.appDrawCursor) {
1443 int pos[2];
1444 GetCursorPosition(window, pos);
1445 stub.spu->dispatch_table.ChromiumParametervCR(GL_CURSOR_POSITION_CR, GL_INT, 2, pos);
1446 }
1447 stub.spu->dispatch_table.SwapBuffers( window->spuWindow, flags );
1448 }
1449 else {
1450 crDebug("Calling SwapBuffers on a window we haven't seen before (no-op).");
1451 }
1452}
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