From 53cc70b5758efed9f3764d13cc42570e70dfca03 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Mon, 10 Jan 2011 17:24:10 -0500 Subject: [PATCH] Bug 624170. Part 1: Don't try to release the DC for null surfaces. r=bas; a=blocking-beta9+ landed on a CLOSED TREE --- gfx/layers/d3d9/ThebesLayerD3D9.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/gfx/layers/d3d9/ThebesLayerD3D9.cpp b/gfx/layers/d3d9/ThebesLayerD3D9.cpp index 3ca75ce73e91..70f8cc9df1d6 100644 --- a/gfx/layers/d3d9/ThebesLayerD3D9.cpp +++ b/gfx/layers/d3d9/ThebesLayerD3D9.cpp @@ -319,6 +319,7 @@ class OpaqueRenderer { public: OpaqueRenderer(const nsIntRegion& aUpdateRegion) : mUpdateRegion(aUpdateRegion), mDC(NULL) {} + ~OpaqueRenderer() { End(); } already_AddRefed Begin(LayerD3D9* aLayer); void End(); IDirect3DTexture9* GetTexture() { return mTmpTexture; } @@ -365,7 +366,11 @@ OpaqueRenderer::Begin(LayerD3D9* aLayer) void OpaqueRenderer::End() { - mSurface->ReleaseDC(mDC); + if (mSurface && mDC) { + mSurface->ReleaseDC(mDC); + mSurface = NULL; + mDC = NULL; + } } static void @@ -437,12 +442,13 @@ ThebesLayerD3D9::DrawRegion(const nsIntRegion &aRegion, SurfaceMode aMode) } } - if (destinationSurface) { - nsRefPtr context = new gfxContext(destinationSurface); - context->Translate(gfxPoint(-bounds.x, -bounds.y)); - LayerManagerD3D9::CallbackInfo cbInfo = mD3DManager->GetCallbackInfo(); - cbInfo.Callback(this, context, aRegion, nsIntRegion(), cbInfo.CallbackData); - } + if (!destinationSurface) + return; + + nsRefPtr context = new gfxContext(destinationSurface); + context->Translate(gfxPoint(-bounds.x, -bounds.y)); + LayerManagerD3D9::CallbackInfo cbInfo = mD3DManager->GetCallbackInfo(); + cbInfo.Callback(this, context, aRegion, nsIntRegion(), cbInfo.CallbackData); nsAutoTArray srcTextures; nsAutoTArray destTextures;