Bug 1088833 - A bit of a clean up of warnings, and catch bad draw target in the d3d11 canvas case. r=bschouten, a=sledru
authorMilan Sreckovic <milan@mozilla.com>
Tue, 20 Jan 2015 12:47:29 -0500
changeset 249434 b314a91c568413197c712f25a8bb4495c1b8b41f
parent 249433 8f49a2fc3f0ccf0e6149e392df7405427df5affb
child 249435 f60d058bf1050b0a25cf157f6a9688e2a00dbc9e
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbschouten, sledru
bugs1088833
milestone37.0a2
Bug 1088833 - A bit of a clean up of warnings, and catch bad draw target in the d3d11 canvas case. r=bschouten, a=sledru
gfx/2d/Factory.cpp
gfx/layers/RotatedBuffer.cpp
gfx/layers/d3d10/CanvasLayerD3D10.cpp
gfx/layers/d3d10/PaintedLayerD3D10.cpp
gfx/layers/d3d11/TextureD3D11.cpp
--- a/gfx/2d/Factory.cpp
+++ b/gfx/2d/Factory.cpp
@@ -566,23 +566,23 @@ Factory::CreateDualDrawTargetForD3D10Tex
                                               SurfaceFormat aFormat)
 {
   MOZ_ASSERT(aTextureA && aTextureB);
   RefPtr<DrawTargetD2D> newTargetA;
   RefPtr<DrawTargetD2D> newTargetB;
 
   newTargetA = new DrawTargetD2D();
   if (!newTargetA->Init(aTextureA, aFormat)) {
-    gfxWarning() << "Failed to create draw target for D3D10 texture.";
+    gfxWarning() << "Failed to create dual draw target for D3D10 texture.";
     return nullptr;
   }
 
   newTargetB = new DrawTargetD2D();
   if (!newTargetB->Init(aTextureB, aFormat)) {
-    gfxWarning() << "Failed to create draw target for D3D10 texture.";
+    gfxWarning() << "Failed to create new draw target for D3D10 texture.";
     return nullptr;
   }
 
   RefPtr<DrawTarget> newTarget =
     new DrawTargetDual(newTargetA, newTargetB);
 
   RefPtr<DrawTarget> retVal = newTarget;
 
@@ -628,17 +628,17 @@ Factory::CreateDrawTargetForD3D11Texture
 
     if (mRecorder) {
       retVal = new DrawTargetRecording(mRecorder, retVal, true);
     }
 
     return retVal;
   }
 
-  gfxWarning() << "Failed to create draw target for D3D10 texture.";
+  gfxWarning() << "Failed to create draw target for D3D11 texture.";
 
   // Failed
   return nullptr;
 }
 
 void
 Factory::SetDirect3D11Device(ID3D11Device *aDevice)
 {
--- a/gfx/layers/RotatedBuffer.cpp
+++ b/gfx/layers/RotatedBuffer.cpp
@@ -359,17 +359,17 @@ RotatedContentBuffer::EnsureBufferOnWhit
   if (!mDTBufferOnWhite) {
     if (mBufferProviderOnWhite) {
       mDTBufferOnWhite =
         mBufferProviderOnWhite->BorrowDrawTarget();
     }
   }
 
   NS_WARN_IF_FALSE(mDTBufferOnWhite, "no buffer");
-  return mDTBufferOnWhite;
+  return !!mDTBufferOnWhite;
 }
 
 bool
 RotatedContentBuffer::HaveBuffer() const
 {
   return mDTBuffer || mBufferProvider;
 }
 
--- a/gfx/layers/d3d10/CanvasLayerD3D10.cpp
+++ b/gfx/layers/d3d10/CanvasLayerD3D10.cpp
@@ -143,27 +143,32 @@ CanvasLayerD3D10::UpdateSurface()
       return;
     }
   }
 
   D3D10_MAPPED_TEXTURE2D map;
   HRESULT hr = mTexture->Map(0, D3D10_MAP_WRITE_DISCARD, 0, &map);
 
   if (FAILED(hr)) {
-    NS_WARNING("Failed to lock CanvasLayer texture.");
+    gfxWarning() << "Failed to lock CanvasLayer texture.";
     return;
   }
 
   RefPtr<DrawTarget> destTarget =
     Factory::CreateDrawTargetForD3D10Texture(mTexture,
                                              SurfaceFormat::R8G8B8A8);
 
+  if (!destTarget) {
+    gfxWarning() << "Invalid D3D10 texture target R8G8B8A8";
+    return;
+  }
+
   if (surf) {
     if (!ReadbackSharedSurface(surf, destTarget)) {
-      NS_WARNING("Failed to readback into texture.");
+      gfxWarning() << "Failed to readback into texture.";
     }
   } else if (mSurface) {
     Rect r(Point(0, 0), ToRect(mBounds).Size());
     destTarget->DrawSurface(mSurface, r, r, DrawSurfaceOptions(),
                             DrawOptions(1.0F, CompositionOp::OP_SOURCE));
   }
 
   mTexture->Unmap(0);
--- a/gfx/layers/d3d10/PaintedLayerD3D10.cpp
+++ b/gfx/layers/d3d10/PaintedLayerD3D10.cpp
@@ -294,17 +294,17 @@ PaintedLayerD3D10::VerifyContentType(Sur
   if (mDrawTarget) {
     SurfaceFormat format = aMode != SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA ?
       SurfaceFormat::B8G8R8X8 : SurfaceFormat::B8G8R8A8;
 
     if (format != mDrawTarget->GetFormat()) {
       mDrawTarget = Factory::CreateDrawTargetForD3D10Texture(mTexture, format);
 
       if (!mDrawTarget) {
-        NS_WARNING("Failed to create drawtarget for PaintedLayerD3D10.");
+        gfxWarning() << "Failed to create drawtarget for PaintedLayerD3D10.";
         return;
       }
 
       mValidRegion.SetEmpty();
     }
   }    
 
   if (aMode != SurfaceMode::SURFACE_COMPONENT_ALPHA && mTextureOnWhite) {
@@ -463,17 +463,16 @@ PaintedLayerD3D10::CreateNewTextures(con
     if (aMode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
       mDrawTarget = Factory::CreateDualDrawTargetForD3D10Textures(mTexture, mTextureOnWhite, SurfaceFormat::B8G8R8X8);
     } else {
       mDrawTarget = Factory::CreateDrawTargetForD3D10Texture(mTexture, aMode != SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA ?
         SurfaceFormat::B8G8R8X8 : SurfaceFormat::B8G8R8A8);
     }
 
     if (!mDrawTarget) {
-      NS_WARNING("Failed to create DrawTarget for PaintedLayerD3D10.");
-      mDrawTarget = nullptr;
+      gfxWarning() << "Failed to create DrawTarget for PaintedLayerD3D10.";
       return;
     }
   }
 }
 
 } /* namespace layers */
 } /* namespace mozilla */
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -353,16 +353,19 @@ TextureClientD3D11::BorrowDrawTarget()
   // This may return a null DrawTarget
   if (mTexture) {
     mDrawTarget = Factory::CreateDrawTargetForD3D11Texture(mTexture, mFormat);
   } else
   {
     MOZ_ASSERT(mTexture10);
     mDrawTarget = Factory::CreateDrawTargetForD3D10Texture(mTexture10, mFormat);
   }
+  if (!mDrawTarget) {
+      gfxWarning() << "Invalid draw target for borrowing";
+  }
   return mDrawTarget;
 }
 
 bool
 TextureClientD3D11::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags)
 {
   mSize = aSize;
   HRESULT hr;