Bug 791711 - Invalidate again if the SharedImageID was removed. r=nical
authorKan-Ru Chen (陳侃如) <kanru@kanru.info>
Sat, 20 Oct 2012 08:18:31 +0800
changeset 110970 6fb79aaa409276b18f54cf76ae50f89bdb64bf14
parent 110969 54af2c396f5fa7442b5dfe24e6e90e88fa60044e
child 110971 62207930924a39a638d70aed986d57614b0d7f50
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersnical
bugs791711
milestone19.0a1
Bug 791711 - Invalidate again if the SharedImageID was removed. r=nical
content/html/content/src/nsHTMLMediaElement.cpp
content/media/VideoFrameContainer.cpp
gfx/layers/ipc/ImageContainerParent.cpp
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -2787,17 +2787,17 @@ void nsHTMLMediaElement::EndSrcMediaStre
   GetSrcMediaStream()->RemoveListener(mSrcStreamListener);
   // Kill its reference to this element
   mSrcStreamListener->Forget();
   mSrcStreamListener = nullptr;
   GetSrcMediaStream()->RemoveAudioOutput(this);
   VideoFrameContainer* container = GetVideoFrameContainer();
   if (container) {
     GetSrcMediaStream()->RemoveVideoOutput(container);
-    container->GetImageContainer()->SetCurrentImage(nullptr);
+    container->ClearCurrentFrame();
   }
   if (mPaused) {
     GetSrcMediaStream()->ChangeExplicitBlockerCount(-1);
   }
   if (mPausedForInactiveDocument) {
     GetSrcMediaStream()->ChangeExplicitBlockerCount(-1);
   }
   mSrcStream = nullptr;
--- a/content/media/VideoFrameContainer.cpp
+++ b/content/media/VideoFrameContainer.cpp
@@ -72,16 +72,20 @@ void VideoFrameContainer::ClearCurrentFr
 
   // See comment in SetCurrentFrame for the reasoning behind
   // using a kungFuDeathGrip here.
   nsRefPtr<Image> kungFuDeathGrip;
   kungFuDeathGrip = mImageContainer->LockCurrentImage();
   mImageContainer->UnlockCurrentImage();
 
   mImageContainer->SetCurrentImage(nullptr);
+
+  // We removed the current image so we will have to invalidate once
+  // again to setup the ImageContainer <-> Compositor pair.
+  mNeedInvalidation = true;
 }
 
 ImageContainer* VideoFrameContainer::GetImageContainer() {
   return mImageContainer;
 }
 
 
 double VideoFrameContainer::GetFrameDelay()
@@ -92,17 +96,20 @@ double VideoFrameContainer::GetFrameDela
 
 void VideoFrameContainer::Invalidate()
 {
   NS_ASSERTION(NS_IsMainThread(), "Must call on main thread");
 
   if (!mNeedInvalidation) {
     return;
   }
-  if (mImageContainer && mImageContainer->IsAsync()) {
+
+  if (mImageContainer &&
+      mImageContainer->IsAsync() &&
+      mImageContainer->HasCurrentImage()) {
     mNeedInvalidation = false;
   }
 
   if (!mElement) {
     // Element has been destroyed
     return;
   }
 
--- a/gfx/layers/ipc/ImageContainerParent.cpp
+++ b/gfx/layers/ipc/ImageContainerParent.cpp
@@ -113,17 +113,17 @@ bool ImageContainerParent::IsExistingID(
 }
 
 SharedImage* ImageContainerParent::SwapSharedImage(uint64_t aID, 
                                                    SharedImage* aImage)
 {
   int idx = IndexOf(aID);
   if (idx == SHAREDIMAGEMAP_INVALID_INDEX) {
     sSharedImageMap->AppendElement(ImageIDPair(aImage,aID));
-  return nullptr;
+    return nullptr;
   }
   SharedImage *prev = (*sSharedImageMap)[idx].image;
   (*sSharedImageMap)[idx].image = aImage;
   (*sSharedImageMap)[idx].version++;
   return prev;
 }
 
 uint32_t ImageContainerParent::GetSharedImageVersion(uint64_t aID)