Bug 1425484 - Part 1. Allow using SharedSurfacesChild::Share with the external image ID directly. r=jrmuizel
authorAndrew Osmond <aosmond@mozilla.com>
Thu, 26 Apr 2018 19:00:12 -0400
changeset 472070 f389cb76ed88cde89d3c3339e419ed99f7b2d337
parent 472069 13b1094802143e1d2c05ae5c23749ed02712062d
child 472071 fae8c28c3966314bd80d40444b6cf756ba143301
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1425484
milestone61.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 1425484 - Part 1. Allow using SharedSurfacesChild::Share with the external image ID directly. r=jrmuizel
gfx/layers/ipc/SharedSurfacesChild.cpp
gfx/layers/ipc/SharedSurfacesChild.h
--- a/gfx/layers/ipc/SharedSurfacesChild.cpp
+++ b/gfx/layers/ipc/SharedSurfacesChild.cpp
@@ -362,16 +362,41 @@ SharedSurfacesChild::Share(ImageContaine
   if (surface->GetType() != SurfaceType::DATA_SHARED) {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
   auto sharedSurface = static_cast<SourceSurfaceSharedData*>(surface.get());
   return Share(sharedSurface, aManager, aResources, aKey);
 }
 
+/* static */ nsresult
+SharedSurfacesChild::Share(SourceSurface* aSurface,
+                           wr::ExternalImageId& aId)
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  MOZ_ASSERT(aSurface);
+
+  if (aSurface->GetType() != SurfaceType::DATA_SHARED) {
+    return NS_ERROR_NOT_IMPLEMENTED;
+  }
+
+  // The external image ID does not change with the invalidation counter. The
+  // caller of this should be aware of the invalidations of the surface through
+  // another mechanism (e.g. imgRequestProxy listener notifications).
+  auto sharedSurface = static_cast<SourceSurfaceSharedData*>(aSurface);
+  SharedUserData* data = nullptr;
+  nsresult rv = ShareInternal(sharedSurface, &data);
+  if (NS_SUCCEEDED(rv)) {
+    MOZ_ASSERT(data);
+    aId = data->Id();
+  }
+
+  return rv;
+}
+
 /* static */ void
 SharedSurfacesChild::Unshare(const wr::ExternalImageId& aId,
                              nsTArray<ImageKeyData>& aKeys)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   for (const auto& entry : aKeys) {
     if (entry.mManager->IsDestroyed()) {
--- a/gfx/layers/ipc/SharedSurfacesChild.h
+++ b/gfx/layers/ipc/SharedSurfacesChild.h
@@ -38,16 +38,24 @@ public:
    * the surface to be mapped, but knows there will be such a need in the
    * future. This may be called from any thread, but it may cause a dispatch to
    * the main thread.
    */
   static void Share(gfx::SourceSurfaceSharedData* aSurface);
 
   /**
    * Request that the surface be mapped into the compositor thread's memory
+   * space, and a valid ExternalImageId be generated for it for use with
+   * WebRender. This must be called from the main thread.
+   */
+  static nsresult Share(gfx::SourceSurface* aSurface,
+                        wr::ExternalImageId& aId);
+
+  /**
+   * Request that the surface be mapped into the compositor thread's memory
    * space, and a valid ImageKey be generated for it for use with WebRender.
    * This must be called from the main thread.
    */
   static nsresult Share(gfx::SourceSurfaceSharedData* aSurface,
                         WebRenderLayerManager* aManager,
                         wr::IpcResourceUpdateQueue& aResources,
                         wr::ImageKey& aKey);