Bug 1504699 - Part 3. Expose parent surface to SharedSurfacesAnimation. r=nical
authorAndrew Osmond <aosmond@mozilla.com>
Mon, 01 Oct 2018 14:37:07 -0400
changeset 503959 0871bc2a309c9df65ff41d27b6615e51201cad0d
parent 503958 944b5385a34248376ae0d92beabf4bcb8a045567
child 503960 0c50877a2132bc8bcbcdee8ddb8dce13913c1c80
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1504699
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1504699 - Part 3. Expose parent surface to SharedSurfacesAnimation. r=nical SourceSurfaceSharedData can be wrapped by RecyclingDataSurface in order to facilitate its lifetime management. As long as the latter is alive, the former cannot be reused by the animated image decoder for a future frame's contents. SharedSurfacesAnimation will need to hold onto the RecyclingDataSurface as long as WebRender is using the surface. Differential Revision: https://phabricator.services.mozilla.com/D10899
gfx/layers/ipc/SharedSurfacesChild.cpp
gfx/layers/ipc/SharedSurfacesChild.h
--- a/gfx/layers/ipc/SharedSurfacesChild.cpp
+++ b/gfx/layers/ipc/SharedSurfacesChild.cpp
@@ -340,17 +340,17 @@ SharedSurfacesChild::Share(ImageContaine
 
   if (surface->GetType() != SurfaceType::DATA_SHARED) {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
   auto sharedSurface = static_cast<SourceSurfaceSharedData*>(surface.get());
   SharedSurfacesAnimation* anim = aContainer->GetSharedSurfacesAnimation();
   if (anim) {
-    return anim->UpdateKey(sharedSurface, aManager, aResources, aKey);
+    return anim->UpdateKey(surface, sharedSurface, aManager, aResources, aKey);
   }
 
   return Share(sharedSurface, aManager, aResources, aKey);
 }
 
 /* static */ nsresult
 SharedSurfacesChild::Share(SourceSurface* aSurface,
                            wr::ExternalImageId& aId)
@@ -448,21 +448,22 @@ SharedSurfacesChild::UpdateAnimation(Ima
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
   SharedSurfacesAnimation* anim =
     aContainer->EnsureSharedSurfacesAnimation();
   MOZ_ASSERT(anim);
 
   auto sharedSurface = static_cast<SourceSurfaceSharedData*>(aSurface);
-  return anim->SetCurrentFrame(sharedSurface, aDirtyRect);
+  return anim->SetCurrentFrame(aSurface, sharedSurface, aDirtyRect);
 }
 
 nsresult
-SharedSurfacesAnimation::SetCurrentFrame(SourceSurfaceSharedData* aSurface,
+SharedSurfacesAnimation::SetCurrentFrame(SourceSurface* aParentSurface,
+                                         SourceSurfaceSharedData* aSurface,
                                          const gfx::IntRect& aDirtyRect)
 {
   MOZ_ASSERT(aSurface);
 
   SharedUserData* data = nullptr;
   nsresult rv = SharedSurfacesChild::ShareInternal(aSurface, &data);
   if (NS_FAILED(rv)) {
     return rv;
@@ -489,17 +490,18 @@ SharedSurfacesAnimation::SetCurrentFrame
                                           ViewAs<ImagePixel>(dirtyRect.ref()));
     }
   }
 
   return NS_OK;
 }
 
 nsresult
-SharedSurfacesAnimation::UpdateKey(SourceSurfaceSharedData* aSurface,
+SharedSurfacesAnimation::UpdateKey(SourceSurface* aParentSurface,
+                                   SourceSurfaceSharedData* aSurface,
                                    WebRenderLayerManager* aManager,
                                    wr::IpcResourceUpdateQueue& aResources,
                                    wr::ImageKey& aKey)
 {
   SharedUserData* data = nullptr;
   nsresult rv = SharedSurfacesChild::ShareInternal(aSurface, &data);
   if (NS_FAILED(rv)) {
     return rv;
--- a/gfx/layers/ipc/SharedSurfacesChild.h
+++ b/gfx/layers/ipc/SharedSurfacesChild.h
@@ -184,31 +184,39 @@ private:
 class SharedSurfacesAnimation final : private SharedSurfacesChild::SharedUserData
 {
 public:
   SharedSurfacesAnimation()
   { }
 
   /**
    * Set the animation to display the given frame.
+   * @param aParentSurface The owning surface of aSurface. This may be the same
+   *                       or it may be a wrapper surface such as
+   *                       RecyclingSourceSurface.
    * @param aSurface    The current frame.
    * @param aDirtyRect  Dirty rect representing the change between the new frame
    *                    and the previous frame. We will request only the delta
    *                    be reuploaded by WebRender.
    */
-  nsresult SetCurrentFrame(gfx::SourceSurfaceSharedData* aSurface,
+  nsresult SetCurrentFrame(gfx::SourceSurface* aParentSurface,
+                           gfx::SourceSurfaceSharedData* aSurface,
                            const gfx::IntRect& aDirtyRect);
 
   /**
    * Generate an ImageKey for the given frame.
+   * @param aParentSurface The owning surface of aSurface. This may be the same
+   *                       or it may be a wrapper surface such as
+   *                       RecyclingSourceSurface.
    * @param aSurface  The current frame. This should match what was cached via
    *                  SetCurrentFrame, but if it does not, it will need to
    *                  regenerate the cached ImageKey.
    */
-  nsresult UpdateKey(gfx::SourceSurfaceSharedData* aSurface,
+  nsresult UpdateKey(gfx::SourceSurface* aParentSurface,
+                     gfx::SourceSurfaceSharedData* aSurface,
                      WebRenderLayerManager* aManager,
                      wr::IpcResourceUpdateQueue& aResources,
                      wr::ImageKey& aKey);
 
   /**
    * Release our reference to all frames up to and including the frame which
    * has an external image ID which matches aId.
    */