Bug 1220082 - Assign frame ids to animated images so that they get invalidated correctly. r=seth

This commit is contained in:
Matt Woodrow
2016-01-12 17:14:09 +13:00
parent 25f9cdb6aa
commit 6e81da0d05
4 changed files with 24 additions and 5 deletions

View File

@@ -289,13 +289,19 @@ ImageContainer::ClearAllImages()
void
ImageContainer::SetCurrentImageInTransaction(Image *aImage)
{
AutoTArray<NonOwningImage,1> images;
images.AppendElement(NonOwningImage(aImage));
SetCurrentImagesInTransaction(images);
}
void
ImageContainer::SetCurrentImagesInTransaction(const nsTArray<NonOwningImage>& aImages)
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
NS_ASSERTION(!mImageClient, "Should use async image transfer with ImageBridge.");
AutoTArray<NonOwningImage,1> images;
images.AppendElement(NonOwningImage(aImage));
SetCurrentImageInternal(images);
SetCurrentImageInternal(aImages);
}
bool ImageContainer::IsAsync() const

View File

@@ -434,6 +434,7 @@ public:
* You won't get meaningful painted/dropped counts when using this method.
*/
void SetCurrentImageInTransaction(Image* aImage);
void SetCurrentImagesInTransaction(const nsTArray<NonOwningImage>& aImages);
/**
* Returns true if this ImageContainer uses the ImageBridge IPDL protocol.

View File

@@ -78,6 +78,8 @@ RasterImage::RasterImage(ImageURL* aURI /* = nullptr */) :
mLockCount(0),
mDecodeCount(0),
mRequestedSampleSize(0),
mImageProducerID(ImageContainer::AllocateProducerID()),
mLastFrameID(0),
mLastImageContainerDrawResult(DrawResult::NOT_READY),
#ifdef DEBUG
mFramesNotified(0),
@@ -691,7 +693,11 @@ RasterImage::GetImageContainer(LayerManager* aManager, uint32_t aFlags)
// |image| holds a reference to a SourceSurface which in turn holds a lock on
// the current frame's VolatileBuffer, ensuring that it doesn't get freed as
// long as the layer system keeps this ImageContainer alive.
container->SetCurrentImageInTransaction(image);
AutoTArray<ImageContainer::NonOwningImage, 1> imageList;
imageList.AppendElement(ImageContainer::NonOwningImage(image, TimeStamp(),
mLastFrameID++,
mImageProducerID));
container->SetCurrentImagesInTransaction(imageList);
mLastImageContainerDrawResult = drawResult;
mImageContainer = container;
@@ -718,7 +724,9 @@ RasterImage::UpdateImageContainer()
mLastImageContainerDrawResult = drawResult;
AutoTArray<ImageContainer::NonOwningImage, 1> imageList;
imageList.AppendElement(ImageContainer::NonOwningImage(image));
imageList.AppendElement(ImageContainer::NonOwningImage(image, TimeStamp(),
mLastFrameID++,
mImageProducerID));
container->SetCurrentImages(imageList);
}

View File

@@ -36,6 +36,7 @@
#include "mozilla/TimeStamp.h"
#include "mozilla/WeakPtr.h"
#include "mozilla/UniquePtr.h"
#include "ImageContainer.h"
#ifdef DEBUG
#include "imgIContainerDebug.h"
#endif
@@ -367,6 +368,9 @@ private: // data
// the layer system needs it.
WeakPtr<layers::ImageContainer> mImageContainer;
layers::ImageContainer::ProducerID mImageProducerID;
layers::ImageContainer::FrameID mLastFrameID;
// If mImageContainer is non-null, this contains the DrawResult we obtained
// the last time we updated it.
DrawResult mLastImageContainerDrawResult;