static void set_display_string( RenderSPU *render_spu, const char *response )
{
    if (!crStrcmp(response, "DEFAULT")) {
        const char *display = crGetenv("DISPLAY");
        if (display)
            crStrncpy(render_spu->display_string,
                                display,
                                sizeof(render_spu->display_string));
        else
            crStrcpy(render_spu->display_string, ""); /* empty string */
    }
    else {
        crStrncpy(render_spu->display_string,
                            response,
                            sizeof(render_spu->display_string));
    }
}
Esempio n. 2
0
/**
 * Create a new _Chromium_ window, not GLX, WGL or CGL.
 * Called by crWindowCreate() only.
 */
    GLint
stubNewWindow( const char *dpyName, GLint visBits )
{
    WindowInfo *winInfo;
    GLint spuWin, size[2];

    spuWin = stub.spu->dispatch_table.WindowCreate( dpyName, visBits );
    if (spuWin < 0) {
	return -1;
    }

    winInfo = (WindowInfo *) crCalloc(sizeof(WindowInfo));
    if (!winInfo) {
	stub.spu->dispatch_table.WindowDestroy(spuWin);
	return -1;
    }

    winInfo->type = CHROMIUM;

    /* Ask the head SPU for the initial window size */
    size[0] = size[1] = 0;
    stub.spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, 0, GL_INT, 2, size);
    if (size[0] == 0 && size[1] == 0) {
	/* use some reasonable defaults */
	size[0] = size[1] = 512;
    }
    winInfo->width = size[0];
    winInfo->height = size[1];
    winInfo->mapped = 1;

    if (!dpyName)
	dpyName = "";

    crStrncpy(winInfo->dpyName, dpyName, MAX_DPY_NAME);
    winInfo->dpyName[MAX_DPY_NAME-1] = 0;

    /* Use spuWin as the hash table index and GLX/WGL handle */
#ifdef WINDOWS
    winInfo->drawable = (HDC) spuWin;
#elif defined(Darwin)
    winInfo->drawable = (CGSWindowID) spuWin;
#elif defined(GLX)
    winInfo->drawable = (GLXDrawable) spuWin;
#endif
    winInfo->spuWindow = spuWin;

    crHashtableAdd(stub.windowTable, (unsigned int) spuWin, winInfo);

    return spuWin;
}
Esempio n. 3
0
/**
 * Allocate a new ContextInfo object, initialize it, put it into the
 * context hash table.  If type==CHROMIUM, call the head SPU's
 * CreateContext() function too.
 */
    ContextInfo *
stubNewContext( const char *dpyName, GLint visBits, ContextType type,
	unsigned long shareCtx )
{
    GLint spuContext = -1, spuShareCtx = 0;
    ContextInfo *context;

    if (shareCtx > 0) {
	/* translate shareCtx to a SPU context ID */
	context = (ContextInfo *)
	    crHashtableSearch(stub.contextTable, shareCtx);
		if (context)
			spuShareCtx = context->spuContext;
	}

	if (type == CHROMIUM) {
		spuContext
			= stub.spu->dispatch_table.CreateContext(dpyName, visBits, spuShareCtx);
		if (spuContext < 0)
			return NULL;
	}

	context = crCalloc(sizeof(ContextInfo));
	if (!context) {
		stub.spu->dispatch_table.DestroyContext(spuContext);
		return NULL;
	}

	if (!dpyName)
		dpyName = "";

	context->id = stub.freeContextNumber++;
	context->type = type;
	context->spuContext = spuContext;
	context->visBits = visBits;
	context->currentDrawable = NULL;
	crStrncpy(context->dpyName, dpyName, MAX_DPY_NAME);
	context->dpyName[MAX_DPY_NAME-1] = 0;

#if defined(GLX) || defined(DARWIN)
	context->share = (ContextInfo *)
		crHashtableSearch(stub.contextTable, (unsigned long) shareCtx);
#endif

	crHashtableAdd(stub.contextTable, context->id, (void *) context);

	return context;
}
Esempio n. 4
0
static char *
crSDPErrorString( int err )
{
	static char buf[512], *temp;
	
	temp = strerror( err );
	if ( temp )
	{
		crStrncpy( buf, temp, sizeof(buf)-1 );
		buf[sizeof(buf)-1] = 0;
	}
	else
	{
		sprintf( buf, "err=%d", err );
	}
  
	return buf;
}
Esempio n. 5
0
static char *
crSDPErrorString( int err )
{
	static char buf[512], *temp;
	
	sprintf( buf, "err=%d", err );
	
#define X(x)	crStrcpy(buf,x); break
  
	switch ( err )
	{
	case WSAECONNREFUSED:
		X( "connection refused" );
	case WSAECONNRESET:
		X( "connection reset" );
	default:
		FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
					   FORMAT_MESSAGE_FROM_SYSTEM |
					   FORMAT_MESSAGE_MAX_WIDTH_MASK, NULL, err,
					   MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
					   (LPTSTR) &temp, 0, NULL );
		if ( temp )
		{
			crStrncpy( buf, temp, sizeof(buf)-1 );
			buf[sizeof(buf)-1] = 0;
		}
	}
  
#undef X
  
	temp = buf + crStrlen(buf) - 1;
	while ( temp > buf && isspace( *temp ) )
	{
		*temp = '\0';
		temp--;
	}
  
	return buf;
}
Esempio n. 6
0
stubGetWindowInfo( Display *dpy, GLXDrawable drawable )
#endif
{
    WindowInfo *winInfo = (WindowInfo *) crHashtableSearch(stub.windowTable, (unsigned int) drawable);
    if (!winInfo) {
	winInfo = (WindowInfo *) crCalloc(sizeof(WindowInfo));
	if (!winInfo)
	    return NULL;
#ifdef GLX
	crStrncpy(winInfo->dpyName, DisplayString(dpy), MAX_DPY_NAME);
	winInfo->dpyName[MAX_DPY_NAME-1] = 0;
	winInfo->dpy = dpy;
#elif defined(Darwin)
	winInfo->connection = _CGSDefaultConnection(); // store our connection as default
#endif
	winInfo->drawable = drawable;
	winInfo->type = UNDECIDED;
	winInfo->spuWindow = -1;
	winInfo->mapped = -1; /* don't know */
	crHashtableAdd(stub.windowTable, (unsigned int) drawable, winInfo);
    }
    return winInfo;
}
/**
 * Allocate a new ContextInfo object, initialize it, put it into the
 * context hash table.  If type==CHROMIUM, call the head SPU's
 * CreateContext() function too.
 */
    ContextInfo *
stubNewContext(char *dpyName, GLint visBits, ContextType type, unsigned long shareCtx
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
        , struct VBOXUHGSMI *pHgsmi
#endif
    )
{
    GLint spuContext = -1, spuShareCtx = 0, spuConnection = 0;
    ContextInfo *context;

    if (shareCtx > 0) {
    /* translate shareCtx to a SPU context ID */
    context = (ContextInfo *)
        crHashtableSearch(stub.contextTable, shareCtx);
        if (context)
            spuShareCtx = context->spuContext;
    }

    if (type == CHROMIUM) {
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
        if (pHgsmi)
        {
            spuConnection = stub.spu->dispatch_table.VBoxConCreate(pHgsmi);
            if (!spuConnection)
            {
                crWarning("VBoxConCreate failed");
                return NULL;
            }
        }
#endif
        spuContext
            = stub.spu->dispatch_table.VBoxCreateContext(spuConnection, dpyName, visBits, spuShareCtx);
        if (spuContext < 0)
        {
            crWarning("VBoxCreateContext failed");
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
            if (spuConnection)
                stub.spu->dispatch_table.VBoxConDestroy(spuConnection);
#endif
            return NULL;
        }
    }

    context = crCalloc(sizeof(ContextInfo));
    if (!context) {
        stub.spu->dispatch_table.DestroyContext(spuContext);
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
        if (spuConnection)
            stub.spu->dispatch_table.VBoxConDestroy(spuConnection);
#endif
        return NULL;
    }

    if (!dpyName)
        dpyName = "";

    context->id = stub.freeContextNumber++;
    context->type = type;
    context->spuContext = spuContext;
    context->visBits = visBits;
    context->currentDrawable = NULL;
    crStrncpy(context->dpyName, dpyName, MAX_DPY_NAME);
    context->dpyName[MAX_DPY_NAME-1] = 0;

#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
    context->spuConnection = spuConnection;
    context->pHgsmi = pHgsmi;
#endif

#ifdef CHROMIUM_THREADSAFE
    VBoxTlsRefInit(context, stubContextDtor);
#endif

#if defined(GLX) || defined(DARWIN)
    context->share = (ContextInfo *)
        crHashtableSearch(stub.contextTable, (unsigned long) shareCtx);
#endif

#ifdef GLX
    context->pGLXPixmapsHash = crAllocHashtable();
    context->damageQueryFailed = GL_FALSE;
    context->damageEventsBase = 0;
#endif

    crHashtableAdd(stub.contextTable, context->id, (void *) context);

    return context;
}
stubGetWindowInfo( Display *dpy, GLXDrawable drawable )
#endif
{
#ifndef WINDOWS
    WindowInfo *winInfo = (WindowInfo *) crHashtableSearch(stub.windowTable, (unsigned int) drawable);
#else
    WindowInfo *winInfo;
    HWND hwnd;
    hwnd = WindowFromDC(drawable);

    if (!hwnd)
    {
        return NULL;
    }

    winInfo = (WindowInfo *) crHashtableSearch(stub.windowTable, (unsigned int) hwnd);
#endif
    if (!winInfo) {
    winInfo = (WindowInfo *) crCalloc(sizeof(WindowInfo));
    if (!winInfo)
        return NULL;
#ifdef GLX
    crStrncpy(winInfo->dpyName, DisplayString(dpy), MAX_DPY_NAME);
    winInfo->dpyName[MAX_DPY_NAME-1] = 0;
    winInfo->dpy = dpy;
    winInfo->pVisibleRegions = NULL;
#elif defined(Darwin)
    winInfo->connection = _CGSDefaultConnection(); // store our connection as default
#elif defined(WINDOWS)
    winInfo->hVisibleRegion = INVALID_HANDLE_VALUE;
    winInfo->hWnd = hwnd;
#endif
    winInfo->drawable = drawable;
    winInfo->type = UNDECIDED;
    winInfo->spuWindow = -1;
#ifdef VBOX_WITH_WDDM
    if (stub.bRunningUnderWDDM)
        winInfo->mapped = 0;
    else
#endif
    {
        winInfo->mapped = -1; /* don't know */
    }
    winInfo->pOwner = NULL;
#ifdef CR_NEWWINTRACK
    winInfo->u32ClientID = -1;
#endif
#ifndef WINDOWS
    crHashtableAdd(stub.windowTable, (unsigned int) drawable, winInfo);
#else
    crHashtableAdd(stub.windowTable, (unsigned int) hwnd, winInfo);
#endif
    }
#ifdef WINDOWS
    else
    {
        winInfo->drawable = drawable;
    }
#endif
    return winInfo;
}
/**
 * Create a new _Chromium_ window, not GLX, WGL or CGL.
 * Called by crWindowCreate() only.
 */
    GLint
stubNewWindow( const char *dpyName, GLint visBits )
{
    WindowInfo *winInfo;
    GLint spuWin, size[2];

    spuWin = stub.spu->dispatch_table.WindowCreate( dpyName, visBits );
    if (spuWin < 0) {
    return -1;
    }

    winInfo = (WindowInfo *) crCalloc(sizeof(WindowInfo));
    if (!winInfo) {
    stub.spu->dispatch_table.WindowDestroy(spuWin);
    return -1;
    }

    winInfo->type = CHROMIUM;

    /* Ask the head SPU for the initial window size */
    size[0] = size[1] = 0;
    stub.spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, 0, GL_INT, 2, size);
    if (size[0] == 0 && size[1] == 0) {
    /* use some reasonable defaults */
    size[0] = size[1] = 512;
    }
    winInfo->width = size[0];
    winInfo->height = size[1];
#ifdef VBOX_WITH_WDDM
    if (stub.bRunningUnderWDDM)
    {
        crError("Should not be here: WindowCreate/Destroy & VBoxPackGetInjectID require connection id!");
        winInfo->mapped = 0;
    }
    else
#endif
    {
        winInfo->mapped = 1;
    }

    if (!dpyName)
    dpyName = "";

    crStrncpy(winInfo->dpyName, dpyName, MAX_DPY_NAME);
    winInfo->dpyName[MAX_DPY_NAME-1] = 0;

    /* Use spuWin as the hash table index and GLX/WGL handle */
#ifdef WINDOWS
    winInfo->drawable = (HDC) spuWin;
    winInfo->hVisibleRegion = INVALID_HANDLE_VALUE;
#elif defined(Darwin)
    winInfo->drawable = (CGSWindowID) spuWin;
#elif defined(GLX)
    winInfo->drawable = (GLXDrawable) spuWin;
    winInfo->pVisibleRegions = NULL;
    winInfo->cVisibleRegions = 0;
#endif
#ifdef CR_NEWWINTRACK
    winInfo->u32ClientID = stub.spu->dispatch_table.VBoxPackGetInjectID(0);
#endif
    winInfo->spuWindow = spuWin;

    crHashtableAdd(stub.windowTable, (unsigned int) spuWin, winInfo);

    return spuWin;
}