wined3d: Make ActivateContext a bit smaller.

This commit is contained in:
Stefan Dösinger 2007-07-09 00:48:53 +02:00 committed by Alexandre Julliard
parent fdadf26c20
commit 1fb168f018

View file

@ -650,32 +650,23 @@ static WineD3DContext *findThreadContextForSwapChain(IWineD3DSwapChain *swapchai
}
/*****************************************************************************
* ActivateContext
* FindContext
*
* Finds a rendering context and drawable matching the device and render
* target for the current thread, activates them and puts them into the
* requested state.
* Finds a context for the current render target and thread
*
* Params:
* This: Device to activate the context for
* target: Requested render target
* usage: Prepares the context for blitting, drawing or other actions
* Parameters:
* target: Render target to find the context for
* tid: Thread to activate the context for
*
* Returns: The needed context
*
*****************************************************************************/
void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextUsage usage) {
DWORD tid = GetCurrentThreadId();
int i;
DWORD dirtyState, idx;
BYTE shift;
WineD3DContext *context = This->activeContext;
BOOL oldRenderOffscreen = This->render_offscreen;
TRACE("(%p): Selecting context for render target %p, thread %d\n", This, target, tid);
if(This->lastActiveRenderTarget != target || tid != This->lastThread) {
static inline WineD3DContext *FindContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, DWORD tid) {
IWineD3DSwapChain *swapchain = NULL;
HRESULT hr;
BOOL readTexture = wined3d_settings.offscreen_rendering_mode != ORM_FBO && This->render_offscreen;
WineD3DContext *context = This->activeContext;
BOOL oldRenderOffscreen = This->render_offscreen;
hr = IWineD3DSurface_GetContainer(target, &IID_IWineD3DSwapChain, (void **) &swapchain);
if(hr == WINED3D_OK && swapchain) {
@ -817,10 +808,38 @@ void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextU
This->isInDraw = oldInDraw;
}
This->lastActiveRenderTarget = target;
if(oldRenderOffscreen != This->render_offscreen && This->depth_copy_state != WINED3D_DCS_NO_COPY) {
This->depth_copy_state = WINED3D_DCS_COPY;
}
return context;
}
/*****************************************************************************
* ActivateContext
*
* Finds a rendering context and drawable matching the device and render
* target for the current thread, activates them and puts them into the
* requested state.
*
* Params:
* This: Device to activate the context for
* target: Requested render target
* usage: Prepares the context for blitting, drawing or other actions
*
*****************************************************************************/
void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextUsage usage) {
DWORD tid = GetCurrentThreadId();
int i;
DWORD dirtyState, idx;
BYTE shift;
WineD3DContext *context;
TRACE("(%p): Selecting context for render target %p, thread %d\n", This, target, tid);
if(This->lastActiveRenderTarget != target || tid != This->lastThread) {
context = FindContext(This, target, tid);
This->lastActiveRenderTarget = target;
} else {
/* Stick to the old context */
context = This->activeContext;