コード例 #1
0
ファイル: renderspu.c プロジェクト: apaka/vbox
GLint renderspuWindowCreateEx( const char *dpyName, GLint visBits, GLint id )
{
    WindowInfo *window;
    VisualInfo *visual;
    GLboolean showIt;

    if (id <= 0)
    {
        id = (GLint)crHashtableAllocKeys(render_spu.windowTable, 1);
        if (id <= 0)
        {
            crWarning("failed to allocate window id");
            return -1;
        }
    }
    else
    {
        if (crHashtableIsKeyUsed(render_spu.windowTable, id))
        {
            crWarning("the specified window key %d is in use", id);
            return -1;
        }
    }


    if (!dpyName || crStrlen(render_spu.display_string) > 0)
        dpyName = render_spu.display_string;

    visual = renderspuFindVisual( dpyName, visBits );
    if (!visual)
    {
        crWarning( "Render SPU: Couldn't create a window, renderspuFindVisual returned NULL" );
        return -1;
    }

    /* Allocate WindowInfo */
    window = (WindowInfo *) crCalloc(sizeof(WindowInfo));
    if (!window)
    {
        crWarning( "Render SPU: Couldn't create a window" );
        return -1;
    }
    
    crHashtableAdd(render_spu.windowTable, id, window);

    showIt = 0;

    /*
    crDebug("Render SPU: Creating window (visBits=0x%x, id=%d)", visBits, window->BltInfo.Base.id);
    */
    /* Have GLX/WGL/AGL create the window */
    if (!renderspuWindowInit( window, visual, showIt, id ))
    {
        crFree(window);
        crWarning( "Render SPU: Couldn't create a window, renderspu_SystemCreateWindow failed" );
        return -1;
    }
    
    return window->BltInfo.Base.id;
}
コード例 #2
0
ファイル: renderspu.c プロジェクト: apaka/vbox
static ContextInfo * renderspuCreateContextInternal(const char *dpyName, GLint visBits, GLint idCtx, ContextInfo * sharedContext)
{
    ContextInfo *context;
    VisualInfo *visual;

    if (idCtx <= 0)
    {
        idCtx = (GLint)crHashtableAllocKeys(render_spu.contextTable, 1);
        if (idCtx <= 0)
        {
            crWarning("failed to allocate context id");
            return NULL;
        }
    }
    else
    {
        if (crHashtableIsKeyUsed(render_spu.contextTable, idCtx))
        {
            crWarning("the specified ctx key %d is in use", idCtx);
            return NULL;
        }
    }


    if (!dpyName || crStrlen(render_spu.display_string)>0)
        dpyName = render_spu.display_string;

    visual = renderspuFindVisual(dpyName, visBits);
    if (!visual)
        return NULL;

    context = (ContextInfo *) crCalloc(sizeof(ContextInfo));
    if (!context)
        return NULL;
    context->BltInfo.Base.id = idCtx;
    context->shared = sharedContext;
    if (!renderspu_SystemCreateContext(visual, context, sharedContext))
        return NULL;

    crHashtableAdd(render_spu.contextTable, idCtx, context);

    context->BltInfo.Base.visualBits = visual->visAttribs;
    /*
    crDebug("Render SPU: CreateContext(%s, 0x%x) returning %d",
                    dpyName, visBits, context->BltInfo.Base.id);
    */

    if (sharedContext)
        ASMAtomicIncU32(&sharedContext->cRefs);
    context->cRefs = 1;

    return context;
}
コード例 #3
0
ファイル: renderspu.c プロジェクト: boompig/chromium
GLint RENDER_APIENTRY
renderspuCreateContext(const char *dpyName, GLint visBits, GLint shareCtx)
{
	ContextInfo *context, *sharedContext = NULL;
	VisualInfo *visual;

	if (shareCtx > 0) {
		sharedContext
			= (ContextInfo *) crHashtableSearch(render_spu.contextTable, shareCtx);
	}

	if (!dpyName || crStrlen(render_spu.display_string)>0)
		dpyName = render_spu.display_string;

	visual = renderspuFindVisual(dpyName, visBits);
	if (!visual)
		return -1;

	context = (ContextInfo *) crCalloc(sizeof(ContextInfo));
	if (!context)
		return -1;
	context->id = render_spu.context_id;
	context->shared = sharedContext;
	if (!renderspu_SystemCreateContext(visual, context, sharedContext))
		return -1;

	crHashtableAdd(render_spu.contextTable, render_spu.context_id, context);
	render_spu.context_id++;

	/*
	crDebug("Render SPU: CreateContext(%s, 0x%x) returning %d",
					dpyName, visBits, context->id);
	*/

	return context->id;
}
コード例 #4
0
ファイル: renderspu.c プロジェクト: boompig/chromium
GLint RENDER_APIENTRY
renderspuWindowCreate( const char *dpyName, GLint visBits )
{
	WindowInfo *window;
	VisualInfo *visual;
	GLboolean showIt;

	if (!dpyName || crStrlen(render_spu.display_string) > 0)
		dpyName = render_spu.display_string;

	visual = renderspuFindVisual( dpyName, visBits );
	if (!visual)
	{
		crWarning( "Render SPU: Couldn't create a window, renderspuFindVisual returned NULL" );
		return -1;
	}

	/* Allocate WindowInfo */
	window = (WindowInfo *) crCalloc(sizeof(WindowInfo));
	if (!window)
	{
		crWarning( "Render SPU: Couldn't create a window" );
		return -1;
	}

	crHashtableAdd(render_spu.windowTable, render_spu.window_id, window);
	window->id = render_spu.window_id;
	render_spu.window_id++;

	window->x = render_spu.defaultX;
	window->y = render_spu.defaultY;
	window->width  = render_spu.defaultWidth;
	window->height = render_spu.defaultHeight;

	if ((render_spu.render_to_app_window || render_spu.render_to_crut_window) && !crGetenv("CRNEWSERVER"))
		showIt = 0;
	else
		showIt = window->id > 0;

	/* Set window->title, replacing %i with the window ID number */
	{
		const char *s = crStrstr(render_spu.window_title, "%i");
		if (s) {
			int i, j, k;
			window->title = crAlloc(crStrlen(render_spu.window_title) + 10);
			for (i = 0; render_spu.window_title[i] != '%'; i++)
				window->title[i] = render_spu.window_title[i];
			k = sprintf(window->title + i, "%d", window->id);
			CRASSERT(k < 10);
			i++; /* skip the 'i' after the '%' */
			j = i + k;
			for (; (window->title[j] = s[i]) != 0; i++, j++)
				;
		}
		else {
			window->title = crStrdup(render_spu.window_title);
		}
	}

	/*
	crDebug("Render SPU: Creating window (visBits=0x%x, id=%d)", visBits, window->id);
	*/
	/* Have GLX/WGL/AGL create the window */
	if (!renderspu_SystemCreateWindow( visual, showIt, window ))
	{
		crFree(window);
		crWarning( "Render SPU: Couldn't create a window, renderspu_SystemCreateWindow failed" );
		return -1;
	}

	CRASSERT(window->visual == visual);

	return window->id;
}