VirtualBox

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

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

GA/common/crOpenGL: warnings (gcc)

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

© 2023 Oracle
ContactPrivacy policyTerms of Use