Bug 1428558 - Part 8. Integrate SharedSurfacesAnimation with the rest of imagelib. r=nical

This patch makes ImageContainer create a SharedSurfacesAnimation object
when it detects that we are using shared surfaces and are producing full
frames.

Differential Revision: https://phabricator.services.mozilla.com/D7505
This commit is contained in:
Andrew Osmond 2018-10-02 13:28:33 -04:00
Родитель 016a11ff73
Коммит 379404ac50
4 изменённых файлов: 32 добавлений и 9 удалений

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

@ -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<IntRect>& 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<IntRect>& 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);

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

@ -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<gfx::IntRect>& aDirtyRect);
void ReleaseImageContainer();
private:
void SetCurrentImage(layers::ImageContainer* aContainer,
gfx::SourceSurface* aSurface,
bool aInTransaction);
const Maybe<gfx::IntRect>& aDirtyRect);
struct ImageContainerEntry {
ImageContainerEntry(const gfx::IntSize& aSize,

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

@ -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)) {

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

@ -622,7 +622,7 @@ VectorImage::SendInvalidationNotifications()
GetMaxSizedIntRect());
}
UpdateImageContainer();
UpdateImageContainer(Nothing());
}
NS_IMETHODIMP_(IntRect)