Bug 1182929 - Work around bug 803703 by refusing to turn heavily-downscaled images into image layers. r=seth

This commit is contained in:
Markus Stange 2015-07-14 12:06:27 -04:00
Родитель 126f7f1171
Коммит d47ec8dfc5
1 изменённых файлов: 29 добавлений и 1 удалений

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

@ -1430,7 +1430,35 @@ nsDisplayImage::CanOptimizeToImageLayer(LayerManager* aManager,
? imgIContainer::FLAG_SYNC_DECODE ? imgIContainer::FLAG_SYNC_DECODE
: imgIContainer::FLAG_NONE; : imgIContainer::FLAG_NONE;
return mImage->IsImageContainerAvailable(aManager, flags); if (!mImage->IsImageContainerAvailable(aManager, flags)) {
return false;
}
int32_t imageWidth;
int32_t imageHeight;
mImage->GetWidth(&imageWidth);
mImage->GetHeight(&imageHeight);
if (imageWidth == 0 || imageHeight == 0) {
NS_ASSERTION(false, "invalid image size");
return false;
}
const int32_t factor = mFrame->PresContext()->AppUnitsPerDevPixel();
const LayoutDeviceRect destRect =
LayoutDeviceRect::FromAppUnits(GetDestRect(), factor);
// Calculate the scaling factor for the frame.
const gfxSize scale = gfxSize(destRect.width / imageWidth,
destRect.height / imageHeight);
if (scale.width < 0.2 || scale.height < 0.2) {
// This would look awful as long as we can't use high-quality downscaling
// for image layers (bug 803703), so don't turn this into an image layer.
return false;
}
return true;
} }
already_AddRefed<ImageContainer> already_AddRefed<ImageContainer>