Bug 595154 - Part 4: Bail when texture lock fails. r=vlad a=b
authorBas Schouten <bschouten@mozilla.com>
Tue, 14 Sep 2010 12:57:25 +0200
changeset 53786 1c6eda75b12991cf86bb1315416eb32b9864a6ad
parent 53785 fcea662e0e0fa1ade57e58fe67b4bf246e6b3136
child 53787 e523182f96397d06acedc258644c9c9ce891a428
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersvlad, b
bugs595154
milestone2.0b7pre
Bug 595154 - Part 4: Bail when texture lock fails. r=vlad a=b
gfx/layers/d3d9/CanvasLayerD3D9.cpp
--- a/gfx/layers/d3d9/CanvasLayerD3D9.cpp
+++ b/gfx/layers/d3d9/CanvasLayerD3D9.cpp
@@ -104,17 +104,22 @@ CanvasLayerD3D9::Updated(const nsIntRect
     cairo_d2d_finish_device(gfxWindowsPlatform::GetPlatform()->GetD2DDevice());
     return;
   }
 #endif
 
   if (mGLContext) {
     // WebGL reads entire surface.
     D3DLOCKED_RECT r;
-    mTexture->LockRect(0, &r, NULL, 0);
+    HRESULT hr = mTexture->LockRect(0, &r, NULL, 0);
+
+    if (FAILED(hr)) {
+      NS_WARNING("Failed to lock CanvasLayer texture.");
+      return;
+    }
 
     PRUint8 *destination;
     if (r.Pitch != mBounds.width * 4) {
       destination = new PRUint8[mBounds.width * mBounds.height * 4];
     } else {
       destination = (PRUint8*)r.pBits;
     }
 
@@ -160,17 +165,22 @@ CanvasLayerD3D9::Updated(const nsIntRect
   } else if (mSurface) {
     RECT r;
     r.left = aRect.x;
     r.top = aRect.y;
     r.right = aRect.XMost();
     r.bottom = aRect.YMost();
 
     D3DLOCKED_RECT lockedRect;
-    mTexture->LockRect(0, &lockedRect, &r, 0);
+    HRESULT hr = mTexture->LockRect(0, &lockedRect, &r, 0);
+
+    if (FAILED(hr)) {
+      NS_WARNING("Failed to lock CanvasLayer texture.");
+      return;
+    }
 
     PRUint8 *startBits;
     PRUint32 sourceStride;
 
     nsRefPtr<gfxImageSurface> sourceSurface;
 
     if (mSurface->GetType() == gfxASurface::SurfaceTypeWin32) {
       sourceSurface = static_cast<gfxWindowsSurface*>(mSurface.get())->GetImageSurface();