Bug 1086670 - Add some gfxCriticalError logs around DrawTarget creation. r=Bas

This commit is contained in:
Nicolas Silva 2014-11-20 15:48:07 +01:00
parent 4fd81c101e
commit cc878d2bd9
3 changed files with 22 additions and 9 deletions

View File

@ -77,8 +77,6 @@ public:
HRESULT hr = mDT->mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpTexture));
if (FAILED(hr)) {
gfxCriticalError() << "[D2D] CreateTexture2D failure " << size << " Code: " << hexa(hr);
// Crash debug builds but try to recover in release builds.
MOZ_ASSERT(false);
return;
}
mDT->mDevice->CopyResource(tmpTexture, mDT->mTexture);
@ -94,8 +92,6 @@ public:
if (FAILED(hr)) {
gfxCriticalError() << "[D2D] CreateSharedBitmap failure " << size << " Code: " << hexa(hr);
// Crash debug builds but try to recover in release builds.
MOZ_ASSERT(false);
return;
}
@ -1386,7 +1382,7 @@ DrawTargetD2D::Init(ID3D10Texture2D *aTexture, SurfaceFormat aFormat)
mFormat = aFormat;
if (!mTexture) {
gfxDebug() << "No valid texture for Direct2D draw target initialization.";
gfxCriticalError() << "No valid texture for Direct2D draw target initialization.";
return false;
}

View File

@ -265,6 +265,7 @@ TemporaryRef<DrawTarget>
Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFormat aFormat)
{
if (!CheckSurfaceSize(aSize)) {
gfxCriticalError() << "Failed to allocate a surface due to invalid size " << aSize;
return nullptr;
}
@ -336,7 +337,7 @@ Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFor
if (!retVal) {
// Failed
gfxDebug() << "Failed to create DrawTarget, Type: " << int(aBackend) << " Size: " << aSize;
gfxCriticalError() << "Failed to create DrawTarget, Type: " << int(aBackend) << " Size: " << aSize;
}
return retVal.forget();
@ -355,7 +356,9 @@ Factory::CreateDrawTargetForData(BackendType aBackend,
int32_t aStride,
SurfaceFormat aFormat)
{
MOZ_ASSERT(aData);
if (!CheckSurfaceSize(aSize)) {
gfxCriticalError() << "Failed to allocate a surface due to invalid size " << aSize;
return nullptr;
}
@ -491,6 +494,8 @@ Factory::CreateScaledFontWithCairo(const NativeFont& aNativeFont, Float aSize, c
TemporaryRef<DrawTarget>
Factory::CreateDualDrawTarget(DrawTarget *targetA, DrawTarget *targetB)
{
MOZ_ASSERT(targetA && targetB);
RefPtr<DrawTarget> newTarget =
new DrawTargetDual(targetA, targetB);
@ -508,6 +513,8 @@ Factory::CreateDualDrawTarget(DrawTarget *targetA, DrawTarget *targetB)
TemporaryRef<DrawTarget>
Factory::CreateDrawTargetForD3D10Texture(ID3D10Texture2D *aTexture, SurfaceFormat aFormat)
{
MOZ_ASSERT(aTexture);
RefPtr<DrawTargetD2D> newTarget;
newTarget = new DrawTargetD2D();
@ -532,6 +539,7 @@ Factory::CreateDualDrawTargetForD3D10Textures(ID3D10Texture2D *aTextureA,
ID3D10Texture2D *aTextureB,
SurfaceFormat aFormat)
{
MOZ_ASSERT(aTextureA && aTextureB);
RefPtr<DrawTargetD2D> newTargetA;
RefPtr<DrawTargetD2D> newTargetB;
@ -585,6 +593,8 @@ Factory::GetDirect3D10Device()
TemporaryRef<DrawTarget>
Factory::CreateDrawTargetForD3D11Texture(ID3D11Texture2D *aTexture, SurfaceFormat aFormat)
{
MOZ_ASSERT(aTexture);
RefPtr<DrawTargetD2D1> newTarget;
newTarget = new DrawTargetD2D1();
@ -754,6 +764,7 @@ Factory::CreateWrappingDataSourceSurface(uint8_t *aData, int32_t aStride,
const IntSize &aSize,
SurfaceFormat aFormat)
{
MOZ_ASSERT(aData);
if (aSize.width <= 0 || aSize.height <= 0) {
return nullptr;
}
@ -773,7 +784,7 @@ Factory::CreateDataSourceSurface(const IntSize &aSize,
bool aZero)
{
if (!CheckSurfaceSize(aSize)) {
gfxWarning() << "CreateDataSourceSurface failed with bad size";
gfxCriticalError() << "Failed to allocate a surface due to invalid size " << aSize;
return nullptr;
}
@ -793,7 +804,7 @@ Factory::CreateDataSourceSurfaceWithStride(const IntSize &aSize,
bool aZero)
{
if (aStride < aSize.width * BytesPerPixel(aFormat)) {
gfxWarning() << "CreateDataSourceSurfaceWithStride failed with bad stride";
gfxCriticalError() << "CreateDataSourceSurfaceWithStride failed with bad stride";
return nullptr;
}
@ -802,7 +813,7 @@ Factory::CreateDataSourceSurfaceWithStride(const IntSize &aSize,
return newSurf.forget();
}
gfxWarning() << "CreateDataSourceSurfaceWithStride failed to initialize";
gfxCriticalError() << "CreateDataSourceSurfaceWithStride failed to initialize";
return nullptr;
}

View File

@ -627,6 +627,9 @@ RotatedContentBuffer::BeginPaint(PaintedLayer* aLayer,
destBufferRect = ComputeBufferRect(neededRegion.GetBounds());
CreateBuffer(result.mContentType, destBufferRect, bufferFlags,
&destDTBuffer, &destDTBufferOnWhite);
MOZ_ASSERT(destDTBuffer, "Failed to allocate a texture");
MOZ_ASSERT(destDTBufferOnWhite || !(bufferFlags & BUFFER_COMPONENT_ALPHA),
"Failed to allocate the texture on white");
if (!destDTBuffer) {
return result;
}
@ -647,6 +650,9 @@ RotatedContentBuffer::BeginPaint(PaintedLayer* aLayer,
// The buffer's not big enough, so allocate a new one
CreateBuffer(result.mContentType, destBufferRect, bufferFlags,
&destDTBuffer, &destDTBufferOnWhite);
MOZ_ASSERT(destDTBuffer, "Failed to allocate a texture");
MOZ_ASSERT(destDTBufferOnWhite || !(bufferFlags & BUFFER_COMPONENT_ALPHA),
"Failed to allocate the texture on white");
if (!destDTBuffer) {
return result;
}