From 1d405a865544d09855f5fe7ca5990c54172f0b4b Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Wed, 17 Sep 2014 23:23:09 +0200 Subject: [PATCH] Bug 1068613 - Part 3: Log failures in D2D, D2D 1.1 and the D3D11 TextureClient. r=bas --- gfx/2d/DrawTargetD2D.cpp | 9 ++++----- gfx/2d/DrawTargetD2D1.cpp | 19 ++++++++++++++++--- gfx/layers/d3d11/TextureD3D11.cpp | 8 +++++++- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/gfx/2d/DrawTargetD2D.cpp b/gfx/2d/DrawTargetD2D.cpp index c24641ddf92..b6b816b37db 100644 --- a/gfx/2d/DrawTargetD2D.cpp +++ b/gfx/2d/DrawTargetD2D.cpp @@ -76,7 +76,7 @@ public: HRESULT hr = mDT->mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpTexture)); if (FAILED(hr)) { - gfxWarning() << "Failure to create temporary texture. Size: " << size << " Code: " << hr; + gfxCriticalError() << "[D2D] CreateTexture2D failure " << size << " Code: " << hr; // Crash debug builds but try to recover in release builds. MOZ_ASSERT(false); return; @@ -93,7 +93,7 @@ public: &props, byRef(mOldSurfBitmap)); if (FAILED(hr)) { - gfxWarning() << "Failed to create shared bitmap for old surface. Code: " << hr; + gfxCriticalError() << "[D2D] CreateSharedBitmap failure " << size << " Code: " << hr; // Crash debug builds but try to recover in release builds. MOZ_ASSERT(false); return; @@ -532,8 +532,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface, hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mipTexture)); if (FAILED(hr)) { - gfxWarning() << "Failure to create temporary texture. Size: " << - aSurface->GetSize() << " Code: " << hr; + gfxCriticalError() << "[D2D] CreateTexture2D failure " << aSurface->GetSize() << " Code: " << hr; return; } @@ -560,7 +559,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface, hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpDSTexture)); if (FAILED(hr)) { - gfxWarning() << "Failure to create temporary texture. Size: " << dsSize << " Code: " << hr; + gfxCriticalError() << "[D2D] CreateTexture2D failure " << dsSize << " Code: " << hr; return; } diff --git a/gfx/2d/DrawTargetD2D1.cpp b/gfx/2d/DrawTargetD2D1.cpp index 7ecdb058bc7..8af71dd90e8 100644 --- a/gfx/2d/DrawTargetD2D1.cpp +++ b/gfx/2d/DrawTargetD2D1.cpp @@ -619,6 +619,10 @@ DrawTargetD2D1::CreateSourceSurfaceFromData(unsigned char *aData, D2D1::BitmapProperties1(D2D1_BITMAP_OPTIONS_NONE, D2DPixelFormat(aFormat)), byRef(bitmap)); + if (FAILED(hr)) { + gfxCriticalError() << "[D2D1.1] CreateBitmap failure " << aSize << " Code: " << hr; + } + if (!bitmap) { return nullptr; } @@ -704,7 +708,7 @@ bool DrawTargetD2D1::Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat) { HRESULT hr; - +` hr = Factory::GetD2D1Device()->CreateDeviceContext(D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS, byRef(mDC)); if (FAILED(hr)) { @@ -728,7 +732,7 @@ DrawTargetD2D1::Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat) hr = mDC->CreateBitmapFromDxgiSurface(dxgiSurface, props, (ID2D1Bitmap1**)byRef(mBitmap)); if (FAILED(hr)) { - gfxWarning() << *this << ": Error " << hr << " failed to create new bitmap."; + gfxCriticalError() << "[D2D1.1] CreateBitmapFromDxgiSurface failure Code: " << hr; return false; } @@ -741,7 +745,12 @@ DrawTargetD2D1::Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat) props.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED; props.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; - mDC->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(mTempBitmap)); + hr = mDC->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(mTempBitmap)); + + if (FAILED(hr)) { + gfxCriticalError() << "[D2D1.1] CreateBitmap failure " << mSize << " Code: " << hr; + return false; + } mDC->SetTarget(mBitmap); @@ -1273,6 +1282,10 @@ DrawTargetD2D1::OptimizeSourceSurface(SourceSurface* aSurface) const D2D1::BitmapProperties1(D2D1_BITMAP_OPTIONS_NONE, D2DPixelFormat(data->GetFormat())), byRef(bitmap)); + if (FAILED(hr)) { + gfxCriticalError() << "[D2D1.1] CreateBitmap failure " << data->GetSize() << " Code: " << hr; + } + data->Unmap(); if (!bitmap) { diff --git a/gfx/layers/d3d11/TextureD3D11.cpp b/gfx/layers/d3d11/TextureD3D11.cpp index d9bc9cf1981..0d6d02839e0 100644 --- a/gfx/layers/d3d11/TextureD3D11.cpp +++ b/gfx/layers/d3d11/TextureD3D11.cpp @@ -13,6 +13,7 @@ #include "gfx2DGlue.h" #include "gfxPrefs.h" #include "ReadbackManagerD3D11.h" +#include "mozilla/gfx/Logging.h" namespace mozilla { @@ -286,6 +287,11 @@ TextureClientD3D11::Unlock() RefPtr tex; HRESULT hr = device->CreateTexture2D(&desc, nullptr, byRef(tex)); + if (FAILED(hr)) { + gfx::gfxCriticalError() << "[D3D11] CreateTexture2D failure " << mSize << " Code: " << hr; + return false; + } + if (SUCCEEDED(hr)) { device->CopyResource(tex, mTexture10); @@ -369,7 +375,7 @@ TextureClientD3D11::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlag } if (FAILED(hr)) { - LOGD3D11("Error creating texture for client!"); + gfx::gfxCriticalError() << "[D3D11] CreateTexture2D failure " << aSize << " Code: " << hr; return false; }