wined3d: Make ActivateContext a bit smaller.
This commit is contained in:
parent
fdadf26c20
commit
1fb168f018
|
@ -650,32 +650,23 @@ static WineD3DContext *findThreadContextForSwapChain(IWineD3DSwapChain *swapchai
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* ActivateContext
|
* FindContext
|
||||||
*
|
*
|
||||||
* Finds a rendering context and drawable matching the device and render
|
* Finds a context for the current render target and thread
|
||||||
* target for the current thread, activates them and puts them into the
|
|
||||||
* requested state.
|
|
||||||
*
|
*
|
||||||
* Params:
|
* Parameters:
|
||||||
* This: Device to activate the context for
|
* target: Render target to find the context for
|
||||||
* target: Requested render target
|
* tid: Thread to activate the context for
|
||||||
* usage: Prepares the context for blitting, drawing or other actions
|
*
|
||||||
|
* Returns: The needed context
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextUsage usage) {
|
static inline WineD3DContext *FindContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, DWORD tid) {
|
||||||
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) {
|
|
||||||
IWineD3DSwapChain *swapchain = NULL;
|
IWineD3DSwapChain *swapchain = NULL;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
BOOL readTexture = wined3d_settings.offscreen_rendering_mode != ORM_FBO && This->render_offscreen;
|
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);
|
hr = IWineD3DSurface_GetContainer(target, &IID_IWineD3DSwapChain, (void **) &swapchain);
|
||||||
if(hr == WINED3D_OK && swapchain) {
|
if(hr == WINED3D_OK && swapchain) {
|
||||||
|
@ -817,10 +808,38 @@ void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextU
|
||||||
|
|
||||||
This->isInDraw = oldInDraw;
|
This->isInDraw = oldInDraw;
|
||||||
}
|
}
|
||||||
This->lastActiveRenderTarget = target;
|
|
||||||
if(oldRenderOffscreen != This->render_offscreen && This->depth_copy_state != WINED3D_DCS_NO_COPY) {
|
if(oldRenderOffscreen != This->render_offscreen && This->depth_copy_state != WINED3D_DCS_NO_COPY) {
|
||||||
This->depth_copy_state = WINED3D_DCS_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 {
|
} else {
|
||||||
/* Stick to the old context */
|
/* Stick to the old context */
|
||||||
context = This->activeContext;
|
context = This->activeContext;
|
||||||
|
|
Loading…
Reference in New Issue