Bug 1070018 - Log HRESULT error codes as hexadecimal values rather than signed integers. r=Bas

This commit is contained in:
Nicolas Silva 2014-09-23 11:35:39 -04:00
parent 10212ddd80
commit a318a426b4
9 changed files with 66 additions and 56 deletions

View File

@ -76,7 +76,7 @@ public:
HRESULT hr = mDT->mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpTexture));
if (FAILED(hr)) {
gfxCriticalError() << "[D2D] CreateTexture2D failure " << size << " Code: " << hr;
gfxCriticalError() << "[D2D] CreateTexture2D failure " << size << " Code: " << hexa(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)) {
gfxCriticalError() << "[D2D] CreateSharedBitmap failure " << size << " Code: " << hr;
gfxCriticalError() << "[D2D] CreateSharedBitmap failure " << size << " Code: " << hexa(hr);
// Crash debug builds but try to recover in release builds.
MOZ_ASSERT(false);
return;
@ -241,7 +241,7 @@ DrawTargetD2D::Flush()
HRESULT hr = mRT->Flush();
if (FAILED(hr)) {
gfxWarning() << "Error reported when trying to flush D2D rendertarget. Code: " << hr;
gfxWarning() << "Error reported when trying to flush D2D rendertarget. Code: " << hexa(hr);
}
// We no longer depend on any target.
@ -471,7 +471,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
HRESULT hr = mDevice->CreateRenderTargetView(mTempTexture, nullptr, byRef(mTempRTView));
if (FAILED(hr)) {
gfxWarning() << "Failure to create RenderTargetView. Code: " << hr;
gfxWarning() << "Failure to create RenderTargetView. Code: " << hexa(hr);
return;
}
}
@ -532,7 +532,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mipTexture));
if (FAILED(hr)) {
gfxCriticalError() << "[D2D] CreateTexture2D failure " << aSurface->GetSize() << " Code: " << hr;
gfxCriticalError() << "[D2D] CreateTexture2D failure " << aSurface->GetSize() << " Code: " << hexa(hr);
return;
}
@ -559,7 +559,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpDSTexture));
if (FAILED(hr)) {
gfxCriticalError() << "[D2D] CreateTexture2D failure " << dsSize << " Code: " << hr;
gfxCriticalError() << "[D2D] CreateTexture2D failure " << dsSize << " Code: " << hexa(hr);
return;
}
@ -1268,14 +1268,14 @@ DrawTargetD2D::CreatePathBuilder(FillRule aFillRule) const
HRESULT hr = factory()->CreatePathGeometry(byRef(path));
if (FAILED(hr)) {
gfxWarning() << "Failed to create Direct2D Path Geometry. Code: " << hr;
gfxWarning() << "Failed to create Direct2D Path Geometry. Code: " << hexa(hr);
return nullptr;
}
RefPtr<ID2D1GeometrySink> sink;
hr = path->Open(byRef(sink));
if (FAILED(hr)) {
gfxWarning() << "Failed to access Direct2D Path Geometry. Code: " << hr;
gfxWarning() << "Failed to access Direct2D Path Geometry. Code: " << hexa(hr);
return nullptr;
}
@ -1305,7 +1305,7 @@ DrawTargetD2D::CreateGradientStops(GradientStop *rawStops, uint32_t aNumStops, E
delete [] stops;
if (FAILED(hr)) {
gfxWarning() << "Failed to create GradientStopCollection. Code: " << hr;
gfxWarning() << "Failed to create GradientStopCollection. Code: " << hexa(hr);
return nullptr;
}
@ -1362,7 +1362,7 @@ DrawTargetD2D::Init(const IntSize &aSize, SurfaceFormat aFormat)
hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mTexture));
if (FAILED(hr)) {
gfxCriticalError() << "Failed to init Direct2D DrawTarget. Size: " << mSize << " Code: " << hr;
gfxCriticalError() << "Failed to init Direct2D DrawTarget. Size: " << mSize << " Code: " << hexa(hr);
return false;
}
@ -1432,7 +1432,7 @@ DrawTargetD2D::InitD3D10Data()
hr = createD3DEffect((void*)d2deffect, sizeof(d2deffect), 0, mDevice, nullptr, byRef(mPrivateData->mEffect));
if (FAILED(hr)) {
gfxWarning() << "Failed to initialize Direct2D required effects. Code: " << hr;
gfxWarning() << "Failed to initialize Direct2D required effects. Code: " << hexa(hr);
return false;
}
@ -1454,7 +1454,7 @@ DrawTargetD2D::InitD3D10Data()
byRef(mPrivateData->mInputLayout));
if (FAILED(hr)) {
gfxWarning() << "Failed to initialize Direct2D required InputLayout. Code: " << hr;
gfxWarning() << "Failed to initialize Direct2D required InputLayout. Code: " << hexa(hr);
return false;
}
@ -1466,7 +1466,7 @@ DrawTargetD2D::InitD3D10Data()
hr = mDevice->CreateBuffer(&bufferDesc, &data, byRef(mPrivateData->mVB));
if (FAILED(hr)) {
gfxWarning() << "Failed to initialize Direct2D required VertexBuffer. Code: " << hr;
gfxWarning() << "Failed to initialize Direct2D required VertexBuffer. Code: " << hexa(hr);
return false;
}
@ -1771,7 +1771,7 @@ DrawTargetD2D::FinalizeRTForOperation(CompositionOp aOperator, const Pattern &aP
mDevice->CopyResource(tmpTexture, mTexture);
if (FAILED(hr)) {
gfxWarning() << *this << "Failed to create shader resource view for temp texture. Code: " << hr;
gfxWarning() << *this << "Failed to create shader resource view for temp texture. Code: " << hexa(hr);
return;
}
@ -1780,7 +1780,7 @@ DrawTargetD2D::FinalizeRTForOperation(CompositionOp aOperator, const Pattern &aP
hr = mDevice->CreateShaderResourceView(tmpTexture, nullptr, byRef(mBckSRView));
if (FAILED(hr)) {
gfxWarning() << *this << "Failed to create shader resource view for temp texture. Code: " << hr;
gfxWarning() << *this << "Failed to create shader resource view for temp texture. Code: " << hexa(hr);
return;
}
@ -2005,21 +2005,21 @@ DrawTargetD2D::EnsureViews()
if (FAILED(hr)) {
gfxWarning() << *this << "Failed to create temporary texture for rendertarget. Size: "
<< mSize << " Code: " << hr;
<< mSize << " Code: " << hexa(hr);
return;
}
hr = mDevice->CreateShaderResourceView(mTempTexture, nullptr, byRef(mSRView));
if (FAILED(hr)) {
gfxWarning() << *this << "Failed to create shader resource view for temp texture. Code: " << hr;
gfxWarning() << *this << "Failed to create shader resource view for temp texture. Code: " << hexa(hr);
return;
}
hr = mDevice->CreateRenderTargetView(mTexture, nullptr, byRef(mRTView));
if (FAILED(hr)) {
gfxWarning() << *this << "Failed to create rendertarget view for temp texture. Code: " << hr;
gfxWarning() << *this << "Failed to create rendertarget view for temp texture. Code: " << hexa(hr);
}
}

View File

@ -620,7 +620,7 @@ DrawTargetD2D1::CreateSourceSurfaceFromData(unsigned char *aData,
byRef(bitmap));
if (FAILED(hr)) {
gfxCriticalError() << "[D2D1.1] CreateBitmap failure " << aSize << " Code: " << hr;
gfxCriticalError() << "[D2D1.1] CreateBitmap failure " << aSize << " Code: " << hexa(hr);
}
if (!bitmap) {
@ -649,14 +649,14 @@ DrawTargetD2D1::CreatePathBuilder(FillRule aFillRule) const
HRESULT hr = factory()->CreatePathGeometry(byRef(path));
if (FAILED(hr)) {
gfxWarning() << *this << ": Failed to create Direct2D Path Geometry. Code: " << hr;
gfxWarning() << *this << ": Failed to create Direct2D Path Geometry. Code: " << hexa(hr);
return nullptr;
}
RefPtr<ID2D1GeometrySink> sink;
hr = path->Open(byRef(sink));
if (FAILED(hr)) {
gfxWarning() << *this << ": Failed to access Direct2D Path Geometry. Code: " << hr;
gfxWarning() << *this << ": Failed to access Direct2D Path Geometry. Code: " << hexa(hr);
return nullptr;
}
@ -691,7 +691,7 @@ DrawTargetD2D1::CreateGradientStops(GradientStop *rawStops, uint32_t aNumStops,
delete [] stops;
if (FAILED(hr)) {
gfxWarning() << *this << ": Failed to create GradientStopCollection. Code: " << hr;
gfxWarning() << *this << ": Failed to create GradientStopCollection. Code: " << hexa(hr);
return nullptr;
}
@ -712,7 +712,7 @@ DrawTargetD2D1::Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat)
hr = Factory::GetD2D1Device()->CreateDeviceContext(D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS, byRef(mDC));
if (FAILED(hr)) {
gfxWarning() << *this << ": Error " << hr << " failed to initialize new DeviceContext.";
gfxWarning() << *this << ": Error " << hexa(hr) << " failed to initialize new DeviceContext.";
return false;
}
@ -732,7 +732,7 @@ DrawTargetD2D1::Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat)
hr = mDC->CreateBitmapFromDxgiSurface(dxgiSurface, props, (ID2D1Bitmap1**)byRef(mBitmap));
if (FAILED(hr)) {
gfxCriticalError() << "[D2D1.1] CreateBitmapFromDxgiSurface failure Code: " << hr;
gfxCriticalError() << "[D2D1.1] CreateBitmapFromDxgiSurface failure Code: " << hexa(hr);
return false;
}
@ -748,7 +748,7 @@ DrawTargetD2D1::Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat)
hr = mDC->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(mTempBitmap));
if (FAILED(hr)) {
gfxCriticalError() << "[D2D1.1] CreateBitmap failure " << mSize << " Code: " << hr;
gfxCriticalError() << "[D2D1.1] CreateBitmap failure " << mSize << " Code: " << hexa(hr);
return false;
}
@ -766,7 +766,7 @@ DrawTargetD2D1::Init(const IntSize &aSize, SurfaceFormat aFormat)
hr = Factory::GetD2D1Device()->CreateDeviceContext(D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS, byRef(mDC));
if (FAILED(hr)) {
gfxWarning() << *this << ": Error " << hr << " failed to initialize new DeviceContext.";
gfxWarning() << *this << ": Error " << hexa(hr) << " failed to initialize new DeviceContext.";
return false;
}
@ -786,7 +786,7 @@ DrawTargetD2D1::Init(const IntSize &aSize, SurfaceFormat aFormat)
mDC->CreateBitmap(D2DIntSize(aSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(mBitmap));
if (FAILED(hr)) {
gfxWarning() << *this << ": Error " << hr << " failed to create new CommandList.";
gfxWarning() << *this << ": Error " << hexa(hr) << " failed to create new CommandList.";
return false;
}
@ -1283,7 +1283,7 @@ DrawTargetD2D1::OptimizeSourceSurface(SourceSurface* aSurface) const
byRef(bitmap));
if (FAILED(hr)) {
gfxCriticalError() << "[D2D1.1] CreateBitmap failure " << data->GetSize() << " Code: " << hr;
gfxCriticalError() << "[D2D1.1] CreateBitmap failure " << data->GetSize() << " Code: " << hexa(hr);
}
data->Unmap();

View File

@ -535,7 +535,7 @@ FilterNodeD2D1::Create(DrawTarget* aDT, ID2D1DeviceContext *aDC, FilterType aTyp
hr = aDC->CreateEffect(GetCLDIDForFilterType(aType), byRef(effect));
if (FAILED(hr)) {
gfxWarning() << "Failed to create effect for FilterType: " << hr;
gfxWarning() << "Failed to create effect for FilterType: " << hexa(hr);
return nullptr;
}

View File

@ -101,6 +101,14 @@ MOZ_BEGIN_ENUM_CLASS(LogOptions, int)
NoNewline = 0x01
MOZ_END_ENUM_CLASS(LogOptions)
template<typename T>
struct Hexa {
Hexa(T aVal) : mVal(aVal) {}
T mVal;
};
template<typename T>
Hexa<T> hexa(T val) { return Hexa<T>(val); }
template<int L, typename Logger = BasicLogger>
class Log
{
@ -145,7 +153,9 @@ public:
{ mMessage << "Rect" << aRect; return *this; }
Log &operator<<(const Matrix& aMatrix)
{ mMessage << "Matrix(" << aMatrix._11 << " " << aMatrix._12 << " ; " << aMatrix._21 << " " << aMatrix._22 << " ; " << aMatrix._31 << " " << aMatrix._32 << ")"; return *this; }
template<typename T>
Log &operator<<(Hexa<T> aHex)
{ mMessage << "0x" << std::hex << aHex.mVal << std::dec; return *this; }
private:

View File

@ -299,7 +299,7 @@ PathBuilderD2D::Finish()
HRESULT hr = mSink->Close();
if (FAILED(hr)) {
gfxDebug() << "Failed to close PathSink. Code: " << hr;
gfxDebug() << "Failed to close PathSink. Code: " << hexa(hr);
return nullptr;
}
@ -319,14 +319,14 @@ PathD2D::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule)
HRESULT hr = DrawTargetD2D::factory()->CreatePathGeometry(byRef(path));
if (FAILED(hr)) {
gfxWarning() << "Failed to create PathGeometry. Code: " << hr;
gfxWarning() << "Failed to create PathGeometry. Code: " << hexa(hr);
return nullptr;
}
RefPtr<ID2D1GeometrySink> sink;
hr = path->Open(byRef(sink));
if (FAILED(hr)) {
gfxWarning() << "Failed to open Geometry for writing. Code: " << hr;
gfxWarning() << "Failed to open Geometry for writing. Code: " << hexa(hr);
return nullptr;
}
@ -367,7 +367,7 @@ PathD2D::StreamToSink(PathSink *aSink) const
D2D1::IdentityMatrix(), &sink);
if (FAILED(hr)) {
gfxWarning() << "Failed to stream D2D path to sink. Code: " << hr;
gfxWarning() << "Failed to stream D2D path to sink. Code: " << hexa(hr);
return;
}
}
@ -418,7 +418,7 @@ PathD2D::GetBounds(const Matrix &aTransform) const
Rect bounds = ToRect(d2dBounds);
if (FAILED(hr) || !bounds.IsFinite()) {
gfxWarning() << "Failed to get stroked bounds for path. Code: " << hr;
gfxWarning() << "Failed to get stroked bounds for path. Code: " << hexa(hr);
return Rect();
}
@ -438,7 +438,7 @@ PathD2D::GetStrokedBounds(const StrokeOptions &aStrokeOptions,
Rect bounds = ToRect(d2dBounds);
if (FAILED(hr) || !bounds.IsFinite()) {
gfxWarning() << "Failed to get stroked bounds for path. Code: " << hr;
gfxWarning() << "Failed to get stroked bounds for path. Code: " << hexa(hr);
return Rect();
}

View File

@ -382,7 +382,7 @@ RadialGradientEffectD2D1::CreateGradientTexture()
HRESULT hr = mEffectContext->CreateResourceTexture(nullptr, &props, &textureData.front(), &stride, 4096 * 4, byRef(tex));
if (FAILED(hr)) {
gfxWarning() << "Failed to create resource texture: " << hr;
gfxWarning() << "Failed to create resource texture: " << hexa(hr);
}
return tex.forget();

View File

@ -72,14 +72,14 @@ SourceSurfaceD2D::InitFromData(unsigned char *aData,
hr = aRT->CreateBitmap(D2DIntSize(aSize), props, byRef(mBitmap));
if (FAILED(hr)) {
gfxWarning() << "Failed to create D2D Bitmap for data. Code: " << hr;
gfxWarning() << "Failed to create D2D Bitmap for data. Code: " << hexa(hr);
return false;
}
hr = mBitmap->CopyFromMemory(nullptr, aData, aStride);
if (FAILED(hr)) {
gfxWarning() << "Failed to copy data to D2D bitmap. Code: " << hr;
gfxWarning() << "Failed to copy data to D2D bitmap. Code: " << hexa(hr);
return false;
}
@ -101,7 +101,7 @@ SourceSurfaceD2D::InitFromTexture(ID3D10Texture2D *aTexture,
hr = aTexture->QueryInterface((IDXGISurface**)&surf);
if (FAILED(hr)) {
gfxWarning() << "Failed to QI texture to surface. Code: " << hr;
gfxWarning() << "Failed to QI texture to surface. Code: " << hexa(hr);
return false;
}
@ -115,7 +115,7 @@ SourceSurfaceD2D::InitFromTexture(ID3D10Texture2D *aTexture,
hr = aRT->CreateSharedBitmap(IID_IDXGISurface, surf, &props, byRef(mBitmap));
if (FAILED(hr)) {
gfxWarning() << "Failed to create SharedBitmap. Code: " << hr;
gfxWarning() << "Failed to create SharedBitmap. Code: " << hexa(hr);
return false;
}
@ -150,14 +150,14 @@ DataSourceSurfaceD2D::DataSourceSurfaceD2D(SourceSurfaceD2D* aSourceSurface)
HRESULT hr = aSourceSurface->mDevice->CreateTexture2D(&desc, nullptr,
byRef(sourceTexture));
if (FAILED(hr)) {
gfxWarning() << "Failed to create texture. Code: " << hr;
gfxWarning() << "Failed to create texture. Code: " << hexa(hr);
return;
}
RefPtr<IDXGISurface> dxgiSurface;
hr = sourceTexture->QueryInterface((IDXGISurface**)byRef(dxgiSurface));
if (FAILED(hr)) {
gfxWarning() << "Failed to create DXGI surface. Code: " << hr;
gfxWarning() << "Failed to create DXGI surface. Code: " << hexa(hr);
return;
}
@ -170,7 +170,7 @@ DataSourceSurfaceD2D::DataSourceSurfaceD2D(SourceSurfaceD2D* aSourceSurface)
&rtProps,
byRef(renderTarget));
if (FAILED(hr)) {
gfxWarning() << "Failed to create render target. Code: " << hr;
gfxWarning() << "Failed to create render target. Code: " << hexa(hr);
return;
}
@ -189,7 +189,7 @@ DataSourceSurfaceD2D::DataSourceSurfaceD2D(SourceSurfaceD2D* aSourceSurface)
}
hr = renderTarget->EndDraw();
if (FAILED(hr)) {
gfxWarning() << "Failed to draw bitmap. Code: " << hr;
gfxWarning() << "Failed to draw bitmap. Code: " << hexa(hr);
return;
}
@ -198,7 +198,7 @@ DataSourceSurfaceD2D::DataSourceSurfaceD2D(SourceSurfaceD2D* aSourceSurface)
desc.BindFlags = 0;
hr = aSourceSurface->mDevice->CreateTexture2D(&desc, nullptr, byRef(mTexture));
if (FAILED(hr)) {
gfxWarning() << "Failed to create staging texture. Code: " << hr;
gfxWarning() << "Failed to create staging texture. Code: " << hexa(hr);
mTexture = nullptr;
return;
}
@ -273,7 +273,7 @@ DataSourceSurfaceD2D::Map(MapType aMapType, MappedSurface *aMappedSurface)
HRESULT hr = mTexture->Map(0, mapType, 0, &map);
if (FAILED(hr)) {
gfxWarning() << "Texture map failed with code: " << hr;
gfxWarning() << "Texture map failed with code: " << hexa(hr);
return false;
}
@ -306,7 +306,7 @@ DataSourceSurfaceD2D::EnsureMappedTexture()
HRESULT hr = mTexture->Map(0, D3D10_MAP_READ, 0, &mData);
if (FAILED(hr)) {
gfxWarning() << "Failed to map texture. Code: " << hr;
gfxWarning() << "Failed to map texture. Code: " << hexa(hr);
mTexture = nullptr;
} else {
mMapped = true;

View File

@ -67,7 +67,7 @@ SourceSurfaceD2DTarget::GetDataSurface()
HRESULT hr = Factory::GetDirect3D10Device()->CreateTexture2D(&desc, nullptr, byRef(dataSurf->mTexture));
if (FAILED(hr)) {
gfxDebug() << "Failed to create staging texture for SourceSurface. Code: " << hr;
gfxDebug() << "Failed to create staging texture for SourceSurface. Code: " << hexa(hr);
return nullptr;
}
Factory::GetDirect3D10Device()->CopyResource(dataSurf->mTexture, mTexture);
@ -94,7 +94,7 @@ SourceSurfaceD2DTarget::GetSRView()
HRESULT hr = Factory::GetDirect3D10Device()->CreateShaderResourceView(mTexture, nullptr, byRef(mSRView));
if (FAILED(hr)) {
gfxWarning() << "Failed to create ShaderResourceView. Code: " << hr;
gfxWarning() << "Failed to create ShaderResourceView. Code: " << hexa(hr);
}
return mSRView;
@ -143,7 +143,7 @@ SourceSurfaceD2DTarget::GetBitmap(ID2D1RenderTarget *aRT)
hr = mTexture->QueryInterface((IDXGISurface**)byRef(surf));
if (FAILED(hr)) {
gfxWarning() << "Failed to query interface texture to DXGISurface. Code: " << hr;
gfxWarning() << "Failed to query interface texture to DXGISurface. Code: " << hexa(hr);
return nullptr;
}
@ -157,7 +157,7 @@ SourceSurfaceD2DTarget::GetBitmap(ID2D1RenderTarget *aRT)
byRef(mBitmap));
if (FAILED(hr)) {
gfxWarning() << "Failed in CreateBitmap. Code: " << hr;
gfxWarning() << "Failed in CreateBitmap. Code: " << hexa(hr);
return nullptr;
}
@ -276,7 +276,7 @@ DataSourceSurfaceD2DTarget::Map(MapType aMapType, MappedSurface *aMappedSurface)
HRESULT hr = mTexture->Map(0, mapType, 0, &map);
if (FAILED(hr)) {
gfxWarning() << "Texture map failed with code: " << hr;
gfxWarning() << "Texture map failed with code: " << hexa(hr);
return false;
}
@ -304,7 +304,7 @@ DataSourceSurfaceD2DTarget::EnsureMapped()
if (!mMapped) {
HRESULT hr = mTexture->Map(0, D3D10_MAP_READ, 0, &mMap);
if (FAILED(hr)) {
gfxWarning() << "Failed to map texture to memory. Code: " << hr;
gfxWarning() << "Failed to map texture to memory. Code: " << hexa(hr);
return;
}
mMapped = true;

View File

@ -288,7 +288,7 @@ TextureClientD3D11::Unlock()
HRESULT hr = device->CreateTexture2D(&desc, nullptr, byRef(tex));
if (FAILED(hr)) {
gfx::gfxCriticalError() << "[D3D11] CreateTexture2D failure " << mSize << " Code: " << hr;
gfx::gfxCriticalError() << "[D3D11] CreateTexture2D failure " << mSize << " Code: " << gfx::hexa(hr);
return;
}
@ -375,7 +375,7 @@ TextureClientD3D11::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlag
}
if (FAILED(hr)) {
gfx::gfxCriticalError() << "[D3D11] CreateTexture2D failure " << aSize << " Code: " << hr;
gfx::gfxCriticalError() << "[D3D11] CreateTexture2D failure " << aSize << " Code: " << gfx::hexa(hr);
return false;
}