wined3d: Avoid some common invalid context accesses.

Unfortunately there are plenty of other places left. Perhaps we should
consider creating our own window when the context becomes invalid and making
the context current on that instead.
This commit is contained in:
Henri Verbeet 2010-03-17 21:59:54 +01:00 committed by Alexandre Julliard
parent 135f364110
commit 7c930589bc
3 changed files with 25 additions and 0 deletions

View File

@ -4369,6 +4369,12 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfac
}
context = context_acquire(This, (IWineD3DSurface *)target, CTXUSAGE_CLEAR);
if (!context->valid)
{
context_release(context);
WARN("Invalid context, skipping clear.\n");
return WINED3D_OK;
}
target->get_drawable_size(context, &drawable_width, &drawable_height);
@ -5842,6 +5848,13 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
else if (!surface_is_offscreen(dst_surface)) context = context_acquire(This, dst_surface, CTXUSAGE_RESOURCELOAD);
else context = context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
if (!context->valid)
{
context_release(context);
WARN("Invalid context, skipping blit.\n");
return;
}
gl_info = context->gl_info;
if (!surface_is_offscreen(src_surface))

View File

@ -596,6 +596,12 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
This->isInDraw = TRUE;
context = context_acquire(This, This->render_targets[0], CTXUSAGE_DRAWPRIM);
if (!context->valid)
{
context_release(context);
WARN("Invalid context, skipping draw.\n");
return;
}
if (This->stencilBufferTarget) {
/* Note that this depends on the context_acquire() call above to set

View File

@ -223,6 +223,12 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
IWineD3DSwapChain_SetDestWindowOverride(iface, hDestWindowOverride);
context = context_acquire(This->device, This->backBuffer[0], CTXUSAGE_RESOURCELOAD);
if (!context->valid)
{
context_release(context);
WARN("Invalid context, skipping present.\n");
return WINED3D_OK;
}
/* Render the cursor onto the back buffer, using our nifty directdraw blitting code :-) */
if (This->device->bCursorVisible && This->device->cursorTexture)