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 243057 24a8f5ee0ad0
parent 243056 1d3c24b896a1
child 243058 d52554d9a8f0
push id4378
push userryanvm@gmail.com
push date2015-01-27 15:46 +0000
treeherdermozilla-beta@f91cc6838063 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbschouten, sledru
bugs1088833
milestone36.0
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
@@ -540,23 +540,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;
 
@@ -603,17 +603,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
@@ -145,27 +145,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
@@ -330,16 +330,19 @@ TextureClientD3D11::BorrowDrawTarget()
   if (mTexture) {
     mDrawTarget = Factory::CreateDrawTargetForD3D11Texture(mTexture, mFormat);
   } else
 #endif
   {
     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;