From 04dc05db17350c5183290a28fa133bf96784b515 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Tue, 7 Jul 2015 09:58:18 +1200 Subject: [PATCH] Bug 1143575. Pass a list of timestamped images to ImageContainer::SetCurrentImages. r=nical --HG-- extra : commitid : 2JD9zKhyZMo extra : rebase_source : f5276dee70345e932daca7a4d082f5917e09bf9e --- dom/media/DOMMediaStream.cpp | 4 +++- dom/media/VideoFrameContainer.cpp | 9 ++++++++- dom/plugins/ipc/PluginInstanceParent.cpp | 5 ++++- gfx/layers/ImageContainer.cpp | 11 ++++------- gfx/layers/ImageContainer.h | 20 ++++++++++++++------ image/RasterImage.cpp | 5 ++++- 6 files changed, 37 insertions(+), 17 deletions(-) diff --git a/dom/media/DOMMediaStream.cpp b/dom/media/DOMMediaStream.cpp index 1f012f8fcddf..40bdee8bd364 100644 --- a/dom/media/DOMMediaStream.cpp +++ b/dom/media/DOMMediaStream.cpp @@ -678,7 +678,9 @@ DOMHwMediaStream::DOMHwMediaStream() mImageContainer = LayerManager::CreateImageContainer(ImageContainer::ASYNCHRONOUS_OVERLAY); nsRefPtr img = mImageContainer->CreateImage(ImageFormat::OVERLAY_IMAGE); mOverlayImage = static_cast(img.get()); - mImageContainer->SetCurrentImage(mOverlayImage); + nsAutoTArray images; + images.AppendElement(ImageContainer::NonOwningImage(img)); + mImageContainer->SetCurrentImages(images); #endif } diff --git a/dom/media/VideoFrameContainer.cpp b/dom/media/VideoFrameContainer.cpp index 66682f466931..e7064b75070a 100644 --- a/dom/media/VideoFrameContainer.cpp +++ b/dom/media/VideoFrameContainer.cpp @@ -55,7 +55,14 @@ void VideoFrameContainer::SetCurrentFrame(const gfxIntSize& aIntrinsicSize, nsTArray kungFuDeathGrip; mImageContainer->GetCurrentImages(&kungFuDeathGrip); - mImageContainer->SetCurrentImage(aImage); + if (aImage) { + nsAutoTArray imageList; + imageList.AppendElement( + ImageContainer::NonOwningImage(aImage, aTargetTime)); + mImageContainer->SetCurrentImages(imageList); + } else { + mImageContainer->ClearAllImages(); + } gfx::IntSize newFrameSize = mImageContainer->GetCurrentSize(); if (oldFrameSize != newFrameSize) { mImageSizeChanged = true; diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index e7042186ccd5..a1bf8f18bdb2 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -633,7 +633,10 @@ PluginInstanceParent::RecvShow(const NPRect& updatedRect, cairoData.mSourceSurface = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(nullptr, surface); cairoImage->SetData(cairoData); - container->SetCurrentImage(cairoImage); + nsAutoTArray imageList; + imageList.AppendElement( + ImageContainer::NonOwningImage(image, TimeStamp())); + container->SetCurrentImages(imageList); } else if (mImageContainer) { mImageContainer->ClearAllImages(); diff --git a/gfx/layers/ImageContainer.cpp b/gfx/layers/ImageContainer.cpp index 761f82ed65fb..a2d4e8be7cb4 100644 --- a/gfx/layers/ImageContainer.cpp +++ b/gfx/layers/ImageContainer.cpp @@ -252,18 +252,15 @@ ImageContainer::ClearCurrentImage() } void -ImageContainer::SetCurrentImage(Image *aImage) +ImageContainer::SetCurrentImages(const nsTArray& aImages) { - if (!aImage) { - ClearAllImages(); - return; - } - + MOZ_ASSERT(!aImages.IsEmpty()); ReentrantMonitorAutoEnter mon(mReentrantMonitor); if (IsAsync()) { ImageBridgeChild::DispatchImageClientUpdate(mImageClient, this); } - SetCurrentImageInternal(aImage); + MOZ_ASSERT(aImages.Length() == 1); + SetCurrentImageInternal(aImages[0].mImage); } void diff --git a/gfx/layers/ImageContainer.h b/gfx/layers/ImageContainer.h index 0709dd7dbf73..11e57f22f768 100644 --- a/gfx/layers/ImageContainer.h +++ b/gfx/layers/ImageContainer.h @@ -267,11 +267,11 @@ protected: * An ImageContainer can operate in one of these modes: * 1) Normal. Triggered by constructing the ImageContainer with * DISABLE_ASYNC or when compositing is happening on the main thread. - * SetCurrentImage changes ImageContainer state but nothing is sent to the + * SetCurrentImages changes ImageContainer state but nothing is sent to the * compositor until the next layer transaction. * 2) Asynchronous. Initiated by constructing the ImageContainer with * ENABLE_ASYNC when compositing is happening on the main thread. - * SetCurrentImage sends a message through the ImageBridge to the compositor + * SetCurrentImages sends a message through the ImageBridge to the compositor * thread to update the image, without going through the main thread or * a layer transaction. * The ImageContainer uses a shared memory block containing a cross-process mutex @@ -302,24 +302,32 @@ public: */ B2G_ACL_EXPORT already_AddRefed CreateImage(ImageFormat aFormat); + struct NonOwningImage { + NonOwningImage(Image* aImage, TimeStamp aTimeStamp) + : mImage(aImage), mTimeStamp(aTimeStamp) {} + Image* mImage; + TimeStamp mTimeStamp; + }; /** - * Set an Image as the current image to display. The Image must have + * Set aImages as the list of timestamped to display. The Images must have * been created by this ImageContainer. * Can be called on any thread. This method takes mReentrantMonitor * when accessing thread-shared state. - * aImage can be null. While it's null, nothing will be painted. + * aImages must be non-empty. The first timestamp in the list may be + * null but the others must not be, and the timestamps must increase. + * Every element of aImages must have non-null mImage. * * The Image data must not be modified after this method is called! * Note that this must not be called if ENABLE_ASYNC has not been set. * - * Implementations must call CurrentImageChanged() while holding + * The implementation calls CurrentImageChanged() while holding * mReentrantMonitor. * * If this ImageContainer has an ImageClient for async video: * Schedule a task to send the image to the compositor using the * PImageBridge protcol without using the main thread. */ - void SetCurrentImage(Image* aImage); + void SetCurrentImages(const nsTArray& aImages); /** * Clear all images. Let ImageClient release all TextureClients. diff --git a/image/RasterImage.cpp b/image/RasterImage.cpp index fce11139345f..bd2e2d02abc1 100644 --- a/image/RasterImage.cpp +++ b/image/RasterImage.cpp @@ -905,7 +905,10 @@ RasterImage::UpdateImageContainer() } mLastImageContainerDrawResult = result.first(); - container->SetCurrentImage(result.second()); + nsAutoTArray imageList; + imageList.AppendElement( + ImageContainer::NonOwningImage(result.second(), TimeStamp())); + container->SetCurrentImages(imageList); } size_t