Ejemplo n.º 1
0
static void
RENDER_APIENTRY renderspuWindowDestroy( GLint win )
{
    WindowInfo *window;
    GET_CONTEXT(pOldCtx);

    CRASSERT(win >= 0);
    window = (WindowInfo *) crHashtableSearch(render_spu.windowTable, win);
    if (window) {
        crDebug("Render SPU: Destroy window (%d)", win);
        renderspu_SystemDestroyWindow( window );
        /* remove window info from hash table, and free it */
        crHashtableDelete(render_spu.windowTable, win, crFree);

        /* check if this window is bound to some ctx. Note: window pointer is already freed here */
        crHashtableWalk(render_spu.contextTable, renderspuCheckCurrentCtxWindowCB, window);

        /* restore current context */
        {
            GET_CONTEXT(pNewCtx);
            if (pNewCtx!=pOldCtx)
            {
                renderspuMakeCurrent(pOldCtx&&pOldCtx->currentWindow ? pOldCtx->currentWindow->id:0, 0,
                                     pOldCtx ? pOldCtx->id:0);
            }
        }
    }
    else {
        crDebug("Render SPU: Attempt to destroy invalid window (%d)", win);
    }
}
Ejemplo n.º 2
0
void
renderspu_SystemMakeCurrent(WindowInfo *window, GLint nativeWindow,
                            ContextInfo *context)
{
    Boolean result;
/*    DEBUG_MSG_POETZSCH (("makecurrent %d: \n", window->BltInfo.Base.id));*/

    CRASSERT(render_spu.ws.aglSetCurrentContext);
    //crDebug( "renderspu_SystemMakeCurrent( %x, %i, %x )", window, nativeWindow, context );

    nativeWindow = 0;

    if(window && context)
    {
        CRASSERT(window->window);
        CRASSERT(context->context);

        if(window->visual != context->visual)
        {
            crDebug("Render SPU (renderspu_SystemMakeCurrent): MakeCurrent visual mismatch (0x%x != 0x%x); remaking window.",
                    (uint)window->visual->visAttribs, (uint)context->visual->visAttribs);
            /*
             * XXX have to revisit this issue!!!
             *
             * But for now we destroy the current window
             * and re-create it with the context's visual abilities
             */
            renderspu_SystemDestroyWindow(window);
            renderspu_SystemCreateWindow(context->visual, window->visible,
                                         window);
        }

        /* This is the normal case: rendering to the render SPU's own window */
        result = renderspuWindowAttachContext(window, window->window,
                                              context);
        /* XXX this is a total hack to work around an NVIDIA driver bug */
        if(render_spu.self.GetFloatv && context->haveWindowPosARB)
        {
            GLfloat f[4];
            render_spu.self.GetFloatv(GL_CURRENT_RASTER_POSITION, f);
            if (!window->everCurrent || f[1] < 0.0)
            {
                crDebug("Render SPU (renderspu_SystemMakeCurrent): Resetting raster pos");
                render_spu.self.WindowPos2iARB(0, 0);
            }
        }
        /* Reapply the visible regions */
        renderspu_SystemWindowApplyVisibleRegion(window);
    }
    else
        renderspuWindowAttachContext (0, 0, 0);
}
Ejemplo n.º 3
0
static void
RENDER_APIENTRY renderspuWindowDestroy( GLint win )
{
	WindowInfo *window;
	CRASSERT(win >= 0);
	window = (WindowInfo *) crHashtableSearch(render_spu.windowTable, win);
	if (window) {
		renderspu_SystemDestroyWindow( window );
		/* remove window info from hash table, and free it */
		crHashtableDelete(render_spu.windowTable, win, crFree);
	}
	else {
		crDebug("Render SPU: Attempt to destroy invalid window (%d)", win);
	}
}
Ejemplo n.º 4
0
void renderspuWindowTerm( WindowInfo *window )
{
    GET_CONTEXT(pOldCtx);
    /* ensure no concurrent draws can take place */
    renderspuVBoxCompositorSet(window, NULL);
    renderspuVBoxPresentBlitterCleanup(window);
    renderspu_SystemDestroyWindow( window );
    RTCritSectDelete(&window->CompositorLock);
    /* check if this window is bound to some ctx. Note: window pointer is already freed here */
    crHashtableWalk(render_spu.contextTable, renderspuCheckCurrentCtxWindowCB, window);
    /* restore current context */
    {
        GET_CONTEXT(pNewCtx);
        if (pNewCtx!=pOldCtx)
        {
            renderspuMakeCurrent(pOldCtx&&pOldCtx->currentWindow ? pOldCtx->currentWindow->BltInfo.Base.id:CR_RENDER_DEFAULT_WINDOW_ID, 0,
                                     pOldCtx ? pOldCtx->BltInfo.Base.id:CR_RENDER_DEFAULT_CONTEXT_ID);
        }
    }
}
Ejemplo n.º 5
0
static void DeleteWindowCallback( void *data )
{
    WindowInfo *window = (WindowInfo *) data;
    renderspu_SystemDestroyWindow(window);
    crFree(window);
}
Ejemplo n.º 6
0
void renderspu_SystemMakeCurrent( WindowInfo *window, GLint nativeWindow, ContextInfo *context )
{
    CRASSERT(render_spu.ws.wglMakeCurrent);

    if (context && window) {
        if (window->visual != context->visual) {
            /*
             * XXX have to revisit this issue!!!
             *
             * But for now we destroy the current window
             * and re-create it with the context's visual abilities
             */

            /*@todo Chromium has no correct code to remove window ids and associated info from 
             * various tables. This is hack which just hides the root case.
             */
            crDebug("Recreating window in renderspu_SystemMakeCurrent\n");
            renderspu_SystemDestroyWindow( window );
            renderspu_SystemVBoxCreateWindow( context->visual, window->visible, window );
        }

        if (render_spu.render_to_app_window && nativeWindow)
        {
            /* The render_to_app_window option 
             * is set and we've got a nativeWindow
             * handle, save the handle for 
             * later calls to swapbuffers().
             *
             * NOTE: This doesn't work, except 
             * for software driven Mesa.
             * We'd need to object link the 
             * crappfaker and crserver to be able to share
             * the HDC values between processes.. FIXME!
             */
            if (context->shared)
            {
                /* first make sure we have shared context created */
                renderspuChkActivateSharedContext(context->shared);
            }

            window->nativeWindow = (HDC) nativeWindow;
            if (context->hRC == 0) {
                context->hRC = render_spu.ws.wglCreateContext( window->nativeWindow );
                if (!context->hRC)
                {
                    crError( "(MakeCurrent) Couldn't create the context for the window (error 0x%x)", GetLastError() );
                }
            }

            if (context->shared
                    && context->shared->hRC
                    && context->hRC)
            {
                /* share lists */
                render_spu.ws.wglShareLists(context->shared->hRC, context->hRC);
            }

            render_spu.ws.wglMakeCurrent( window->nativeWindow, context->hRC );
        }
        else
        {
            if (!context->hRC) {
                if (context->shared)
                {
                    /* first make sure we have shared context created */
                    renderspuChkActivateSharedContext(context->shared);
                }

                context->hRC = render_spu.ws.wglCreateContext(window->device_context);
                if (!context->hRC)
                {
                    crError( "Render SPU: (MakeCurrent) Couldn't create the context for the window (error 0x%x)", GetLastError() );
                }

                if (context->shared
                        && context->shared->hRC
                        && context->hRC)
                {
                    /* share lists */
                    render_spu.ws.wglShareLists(context->shared->hRC, context->hRC);
                }

                /*Requery ext function pointers, we skip dummy ctx as it should never be used with ext functions*/
                if (0 && context->id)
                {
                    int numFuncs, i;
                    SPUNamedFunctionTable ext_table[1000];


                    crDebug("Default server ctx created, requerying ext functions");
                    /*requery ext functions*/
                    numFuncs = renderspuCreateFunctions(ext_table);
                    numFuncs += crLoadOpenGLExtensions( &render_spu.ws, ext_table+numFuncs);
                    CRASSERT(numFuncs < 1000);

                    /*change spu dispatch*/
                    crSPUChangeDispatch(&render_spu.self, ext_table);


                    /*cleanup temp table*/
                    for (i=0; i<numFuncs; ++i)
                    {
                        if (ext_table[i].name) crFree(ext_table[i].name);
                    }
                }
            }

            /*crDebug("MakeCurrent 0x%x, 0x%x", window->device_context, context->hRC);*/
            if (!render_spu.ws.wglMakeCurrent(window->device_context, context->hRC))
            {
                DWORD err = GetLastError();
                crError("Render SPU: (MakeCurrent) failed to make 0x%x, 0x%x current with 0x%x error.", window->device_context, context->hRC, err);
            }
        }

        renderspuAtiQuirk_ChkApply();
    }
    else {
        render_spu.ws.wglMakeCurrent( 0, 0 );
    }
}