diff --git a/image/Image.cpp b/image/Image.cpp index fa6b9c0657bc..4eeea1861221 100644 --- a/image/Image.cpp +++ b/image/Image.cpp @@ -4,12 +4,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "Image.h" +#include "gfxPrefs.h" #include "Layers.h" // for LayerManager #include "nsRefreshDriver.h" #include "nsContentUtils.h" #include "mozilla/SizeOfState.h" #include "mozilla/TimeStamp.h" #include "mozilla/Tuple.h" // for Tie +#include "mozilla/layers/SharedSurfacesChild.h" namespace mozilla { namespace image { @@ -71,7 +73,7 @@ ImageResource::GetSpecTruncatedTo1k(nsCString& aSpec) const void ImageResource::SetCurrentImage(ImageContainer* aContainer, SourceSurface* aSurface, - bool aInTransaction) + const Maybe& aDirtyRect) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aContainer); @@ -97,11 +99,26 @@ ImageResource::SetCurrentImage(ImageContainer* aContainer, mLastFrameID++, mImageProducerID)); - if (aInTransaction) { + if (aDirtyRect) { aContainer->SetCurrentImagesInTransaction(imageList); } else { aContainer->SetCurrentImages(imageList); } + + // If we are generating full frames, and we are animated, then we should + // request that the image container be treated as such, to avoid display + // list rebuilding to update frames for WebRender. + if (gfxPrefs::ImageAnimatedGenerateFullFrames() && + mProgressTracker->GetProgress() & FLAG_IS_ANIMATED) { + if (aDirtyRect) { + layers::SharedSurfacesChild::UpdateAnimation(aContainer, aSurface, + aDirtyRect.ref()); + } else { + IntRect dirtyRect(IntPoint(0, 0), aSurface->GetSize()); + layers::SharedSurfacesChild::UpdateAnimation(aContainer, aSurface, + dirtyRect); + } + } } ImgDrawResult @@ -253,14 +270,14 @@ ImageResource::GetImageContainerImpl(LayerManager* aManager, } } - SetCurrentImage(container, surface, true); + SetCurrentImage(container, surface, Nothing()); entry->mLastDrawResult = drawResult; container.forget(aOutContainer); return drawResult; } void -ImageResource::UpdateImageContainer() +ImageResource::UpdateImageContainer(const Maybe& aDirtyRect) { MOZ_ASSERT(NS_IsMainThread()); @@ -278,7 +295,12 @@ ImageResource::UpdateImageContainer() // managed to convert the weak reference into a strong reference, that // means that an imagelib user still is holding onto the container. thus // we cannot consolidate and must keep updating the duplicate container. - SetCurrentImage(container, surface, false); + if (aDirtyRect) { + SetCurrentImage(container, surface, aDirtyRect); + } else { + IntRect dirtyRect(IntPoint(0, 0), bestSize); + SetCurrentImage(container, surface, Some(dirtyRect)); + } } else { // Stop tracking if our weak pointer to the image container was freed. mImageContainers.RemoveElementAt(i); diff --git a/image/Image.h b/image/Image.h index 56bcc9ca5181..f52374dacfe3 100644 --- a/image/Image.h +++ b/image/Image.h @@ -6,6 +6,7 @@ #ifndef mozilla_image_Image_h #define mozilla_image_Image_h +#include "mozilla/Maybe.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Tuple.h" #include "mozilla/TimeStamp.h" @@ -393,14 +394,14 @@ protected: uint32_t aFlags, layers::ImageContainer** aContainer); - void UpdateImageContainer(); + void UpdateImageContainer(const Maybe& aDirtyRect); void ReleaseImageContainer(); private: void SetCurrentImage(layers::ImageContainer* aContainer, gfx::SourceSurface* aSurface, - bool aInTransaction); + const Maybe& aDirtyRect); struct ImageContainerEntry { ImageContainerEntry(const gfx::IntSize& aSize, diff --git a/image/RasterImage.cpp b/image/RasterImage.cpp index a327fd002e31..87acacfb97ab 100644 --- a/image/RasterImage.cpp +++ b/image/RasterImage.cpp @@ -1714,7 +1714,7 @@ RasterImage::NotifyProgress(Progress aProgress, if (!aInvalidRect.IsEmpty() && wasDefaultFlags) { // Update our image container since we're invalidating. - UpdateImageContainer(); + UpdateImageContainer(Some(aInvalidRect)); } if (!(aDecoderFlags & DecoderFlags::FIRST_FRAME_ONLY)) { diff --git a/image/VectorImage.cpp b/image/VectorImage.cpp index 01c0f83d9e4e..f09ead6d3999 100644 --- a/image/VectorImage.cpp +++ b/image/VectorImage.cpp @@ -622,7 +622,7 @@ VectorImage::SendInvalidationNotifications() GetMaxSizedIntRect()); } - UpdateImageContainer(); + UpdateImageContainer(Nothing()); } NS_IMETHODIMP_(IntRect)