From 8dcbfe2c0bbf4d97c61e67d80903bf1c3ae0b376 Mon Sep 17 00:00:00 2001 From: Andrew Osmond Date: Fri, 17 Nov 2017 06:45:25 -0500 Subject: [PATCH] Bug 1368776 - Part 4. Handle all potential DrawResult values to make Image::GetImageContainerImpl more generic. r=tnikkel RasterImage::GetCurrentImage can only return a subset of the DrawResult values, and the original RasterImage::GetImageContainer implementation relied upon this behavior. Now we handle them all to ensure that when other image implementations reuse it, they may return any valid DrawResult and get the expected results. --- image/Image.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/image/Image.cpp b/image/Image.cpp index bfb8df03ae5c..2494e8454387 100644 --- a/image/Image.cpp +++ b/image/Image.cpp @@ -97,18 +97,28 @@ ImageResource::GetImageContainerImpl(LayerManager* aManager, RefPtr container = mImageContainer.get(); - bool mustRedecode = - (aFlags & (FLAG_SYNC_DECODE | FLAG_SYNC_DECODE_IF_FAST)) && - mLastImageContainerDrawResult != DrawResult::SUCCESS && - mLastImageContainerDrawResult != DrawResult::BAD_IMAGE; - - if (container && !mustRedecode) { - return container.forget(); + if (container) { + switch (mLastImageContainerDrawResult) { + case DrawResult::SUCCESS: + case DrawResult::BAD_IMAGE: + case DrawResult::BAD_ARGS: + return container.forget(); + case DrawResult::NOT_READY: + case DrawResult::INCOMPLETE: + case DrawResult::TEMPORARY_ERROR: + // Temporary conditions where we need to rerequest the frame to recover. + break; + case DrawResult::WRONG_SIZE: + // Unused by GetFrameInternal + default: + MOZ_ASSERT_UNREACHABLE("Unhandled DrawResult type!"); + return container.forget(); + } + } else { + // We need a new ImageContainer, so create one. + container = LayerManager::CreateImageContainer(); } - // We need a new ImageContainer, so create one. - container = LayerManager::CreateImageContainer(); - DrawResult drawResult; RefPtr image; Tie(drawResult, image) = GetCurrentImage(container, aSize, aFlags);