Henri Verbeet : wined3d: Avoid some common invalid context accesses.

Alexandre Julliard julliard at winehq.org
Thu Mar 18 11:19:28 CDT 2010


Module: wine
Branch: master
Commit: 7c930589bc40097eb0ebb84310a3ea0ae6999edb
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7c930589bc40097eb0ebb84310a3ea0ae6999edb

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Wed Mar 17 21:59:54 2010 +0100

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.

---

 dlls/wined3d/device.c    |   13 +++++++++++++
 dlls/wined3d/drawprim.c  |    6 ++++++
 dlls/wined3d/swapchain.c |    6 ++++++
 3 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 2d3ec56..bd13451 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -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))
diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index 0ed0e11..da7aab4 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -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
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index dfe194d..776aa68 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -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)




More information about the wine-cvs mailing list