Bug 695763. Part 5. Invalidate background images if they are not decoded and we are asked to do a sync decode. r=matt.woodrow

This commit is contained in:
Timothy Nikkel 2013-06-26 11:43:27 -05:00
Родитель 38244a9048
Коммит e53199ae28
3 изменённых файлов: 30 добавлений и 8 удалений

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

@ -3036,19 +3036,29 @@ nsCSSRendering::GetBackgroundLayerRect(nsPresContext* aPresContext,
return state.mFillArea;
}
/* static */ bool
nsCSSRendering::IsBackgroundImageDecodedForStyleContextAndLayer(
const nsStyleBackground *aBackground, uint32_t aLayer)
{
const nsStyleImage* image = &aBackground->mLayers[aLayer].mImage;
if (image->GetType() == eStyleImageType_Image) {
nsCOMPtr<imgIContainer> img;
if (NS_SUCCEEDED(image->GetImageData()->GetImage(getter_AddRefs(img)))) {
if (!img->IsDecoded()) {
return false;
}
}
}
return true;
}
/* static */ bool
nsCSSRendering::AreAllBackgroundImagesDecodedForFrame(nsIFrame* aFrame)
{
const nsStyleBackground *bg = aFrame->StyleContext()->StyleBackground();
NS_FOR_VISIBLE_BACKGROUND_LAYERS_BACK_TO_FRONT(i, bg) {
const nsStyleImage* image = &bg->mLayers[i].mImage;
if (image->GetType() == eStyleImageType_Image) {
nsCOMPtr<imgIContainer> img;
if (NS_SUCCEEDED(image->GetImageData()->GetImage(getter_AddRefs(img)))) {
if (!img->IsDecoded()) {
return false;
}
}
if (!IsBackgroundImageDecodedForStyleContextAndLayer(bg, i)) {
return false;
}
}
return true;

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

@ -396,6 +396,12 @@ struct nsCSSRendering {
const nsStyleBackground::Layer& aLayer,
uint32_t aFlags);
/**
* Checks if image in layer aLayer of aBackground is currently decoded.
*/
static bool IsBackgroundImageDecodedForStyleContextAndLayer(
const nsStyleBackground *aBackground, uint32_t aLayer);
/**
* Checks if all images that are part of the background for aFrame are
* currently decoded.

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

@ -2193,6 +2193,12 @@ void nsDisplayBackgroundImage::ComputeInvalidationRegion(nsDisplayListBuilder* a
aInvalidRegion->Or(bounds, geometry->mBounds);
return;
}
if (aBuilder->ShouldSyncDecodeImages()) {
if (mBackgroundStyle &&
!nsCSSRendering::IsBackgroundImageDecodedForStyleContextAndLayer(mBackgroundStyle, mLayer)) {
aInvalidRegion->Or(*aInvalidRegion, bounds);
}
}
if (!bounds.IsEqualInterior(geometry->mBounds)) {
// Positioning area is unchanged, so invalidate just the change in the
// painting area.