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.
This commit is contained in:
Andrew Osmond 2017-11-17 06:45:25 -05:00
Родитель 0b4ae23fa1
Коммит 8dcbfe2c0b
1 изменённых файлов: 20 добавлений и 10 удалений

Просмотреть файл

@ -97,18 +97,28 @@ ImageResource::GetImageContainerImpl(LayerManager* aManager,
RefPtr<layers::ImageContainer> 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<layers::Image> image;
Tie(drawResult, image) = GetCurrentImage(container, aSize, aFlags);