stub.h revision 99eaecfc4b64d7f3c37c1108c292d11ad1fb0a62
/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
/*
* How this all works...
*
* This directory implements three different interfaces to Chromium:
*
* 1. the Chromium interface - this is defined by the functions that start
* with the "cr" prefix and are defined in chromium.h and implemented in
* stub.c. Typically, this is used by parallel apps (like psubmit).
*
* 2. GLX emulation interface - the glX*() functions are emulated here.
* When glXCreateContext() is called we may either create a real, native
* GLX context or a Chromium context (depending on match_window_title and
* minimum_window_size).
*
* 3. WGL emulation interface - the wgl*() functions are emulated here.
* When wglCreateContext() is called we may either create a real, native
* WGL context or a Chromium context (depending on match_window_title and
* minimum_window_size).
*
*
*/
#ifndef CR_STUB_H
#define CR_STUB_H
#include "chromium.h"
#include "cr_version.h"
#include "cr_hash.h"
#include "cr_process.h"
#include "cr_spu.h"
#include "cr_threads.h"
#include "spu_dispatch_table.h"
#ifdef GLX
#endif
# define CR_NEWWINTRACK
#endif
#if !defined(CHROMIUM_THREADSAFE) && defined(CR_NEWWINTRACK)
#endif
#ifdef CHROMIUM_THREADSAFE
# include <cr_threads.h>
#endif
/*#define VBOX_TEST_MEGOO*/
#if 0 && defined(CR_NEWWINTRACK) && !defined(WINDOWS)
#else
#endif
/* When we first create a rendering context we can't be sure whether
* CreateContext() we'll mark the ContextInfo object as UNDECIDED then
* switch it to either NATIVE or CHROMIUM the first time MakeCurrent()
* is called. In MakeCurrent() we can use a criteria like window size
* or window title to decide between CHROMIUM and NATIVE.
*/
typedef enum
{
} ContextType;
#define MAX_DPY_NAME 1000
typedef struct context_info_t ContextInfo;
typedef struct window_info_t WindowInfo;
#ifdef GLX
typedef struct glxpixmap_info_t GLX_Pixmap_t;
struct glxpixmap_info_t
{
int x, y;
};
#endif
struct context_info_t
{
char dpyName[MAX_DPY_NAME];
unsigned long id; /* the client-visible handle */
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
struct VBOXUHGSMI *pHgsmi;
#endif
#ifdef CHROMIUM_THREADSAFE
#endif
#ifdef WINDOWS
/* CGLContextEnable (CGLEnable, CGLDisable, and CGLIsEnabled) */
unsigned int options;
/* CGLContextParameter (CGLSetParameter and CGLGetParameter) */
unsigned long client_storage;
long surf_order, surf_opacy;
long disp_mask;
int damageEventsBase;
#endif
};
#ifdef DARWIN
enum {
};
#endif
struct window_info_t
{
char dpyName[MAX_DPY_NAME];
int x, y;
#ifdef WINDOWS
# ifdef CR_NEWWINTRACK
# endif
#endif
#ifdef CR_NEWWINTRACK
#endif
};
/* "Global" variables for the stub library */
typedef struct {
/* the first SPU in the SPU chain on this app node */
/* config options */
int appDrawCursor;
char *matchWindowTitle;
int ignoreFreeglutMenus;
int trackWindowSize;
int trackWindowPos;
char *spu_dir;
int force_pbuffers;
/* thread safety stuff */
#ifdef CHROMIUM_THREADSAFE
#endif
/* contexts */
int freeContextNumber;
#ifndef CHROMIUM_THREADSAFE
#endif
/* windows */
#ifdef GLX
/* Shared memory, used to transfer XServer pixmaps data into client memory */
#endif
#ifdef WINDOWS
# ifndef CR_NEWWINTRACK
# endif
# ifdef VBOX_WITH_WDDM
bool bRunningUnderWDDM;
# endif
#endif
#ifdef CR_NEWWINTRACK
bool volatile bShutdownSyncThread;
#endif
} Stub;
#ifdef CHROMIUM_THREADSAFE
/* we place the g_stubCurrentContextTLS outside the Stub data because Stub data is inited by the client's call,
* while we need g_stubCurrentContextTLS the g_stubCurrentContextTLS to be valid at any time to be able to handle
* THREAD_DETACH cleanup on windows.
* Note that we can not do
* STUB_INIT_LOCK();
* if (stub_initialized) stubSetCurrentContext(NULL);
* STUB_INIT_UNLOCK();
* on THREAD_DETACH since it may cause deadlock, i.e. in this situation loader lock is acquired first and then the init lock,
* but since we use GetModuleFileName in crGetProcName called from stubInitLocked, the lock order might be the oposite.
* Note that GetModuleFileName acquires the loader lock.
* */
extern CRtsd g_stubCurrentContextTSD;
{
return ctx;
}
# define stubSetCurrentContext(_ctx) VBoxTlsRefSetCurrent(ContextInfo, &g_stubCurrentContextTSD, _ctx)
#else
#endif
#endif
#ifdef WINDOWS
/* WGL versions */
extern void stubInstallWindowMessageHook();
extern void stubUninstallWindowMessageHook();
extern CGSConnectionID _CGSDefaultConnection(void);
/* These don't seem to be included in the OSX glext.h ... */
/* GLX versions */
#endif
extern ContextInfo *stubNewContext( const char *dpyName, GLint visBits, ContextType type, unsigned long shareCtx
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
, struct VBOXUHGSMI *pHgsmi
#endif
);
extern void stubDestroyContext( unsigned long contextId );
extern void stubGetWindowGeometry(const WindowInfo *win, int *x, int *y, unsigned int *w, unsigned int *h);
extern bool stubInit(void);
extern void APIENTRY stub_GetChromiumParametervCR( GLenum target, GLuint index, GLenum type, GLsizei count, GLvoid *values );
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
#else
# define CR_CTX_CON(_pCtx) (0)
#endif
#endif /* CR_STUB_H */