Bug 1262390: In some cases, we fail with the small allocation because of the device reset situation. r?bas.schouten
MozReview-Commit-ID: BKMOZbgJ7px
--- a/gfx/2d/DrawTargetD2D1.cpp
+++ b/gfx/2d/DrawTargetD2D1.cpp
@@ -1353,16 +1353,19 @@ DrawTargetD2D1::FinalizeDrawing(Composit
if (FAILED(hr) || !blendEffect) {
gfxWarning() << "Failed to create blend effect!";
return;
}
// We don't need to preserve the current content of this layer as the output
// of the blend effect should completely replace it.
RefPtr<ID2D1Image> tmpImage = GetImageForLayerContent(false);
+ if (!tmpImage) {
+ return;
+ }
blendEffect->SetInput(0, tmpImage);
blendEffect->SetInput(1, source);
blendEffect->SetValue(D2D1_BLEND_PROP_MODE, D2DBlendMode(aOp));
mDC->DrawImage(blendEffect, D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR, D2D1_COMPOSITE_MODE_BOUNDED_SOURCE_COPY);
// This may seem a little counter intuitive. If this is false, we go through the regular
@@ -1456,19 +1459,23 @@ DrawTargetD2D1::GetImageForLayerContent(
{
PopAllClips();
if (!CurrentLayer().mCurrentList) {
RefPtr<ID2D1Bitmap> tmpBitmap;
HRESULT hr = mDC->CreateBitmap(D2DIntSize(mSize), D2D1::BitmapProperties(D2DPixelFormat(mFormat)), getter_AddRefs(tmpBitmap));
if (FAILED(hr)) {
gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(mSize))) << "[D2D1.1] 6CreateBitmap failure " << mSize << " Code: " << hexa(hr) << " format " << (int)mFormat;
- // For now, crash in this scenario; this should happen because tmpBitmap is
+ // If it's a recreate target error, return and handle it elsewhere.
+ if (hr == D2DERR_RECREATE_TARGET) {
+ mDC->Flush();
+ return nullptr;
+ }
+ // For now, crash in other scenarios; this should happen because tmpBitmap is
// null and CopyFromBitmap call below dereferences it.
- // return;
}
mDC->Flush();
tmpBitmap->CopyFromBitmap(nullptr, mBitmap, nullptr);
return tmpBitmap.forget();
} else {
RefPtr<ID2D1CommandList> list = CurrentLayer().mCurrentList;
mDC->CreateCommandList(getter_AddRefs(CurrentLayer().mCurrentList));