Bug 1383786 - Make it possible to update TextureHost image keys. r=sotaro
☠☠ backed out by 9e3f77db6b22 ☠ ☠
authorNicolas Silva <nsilva@mozilla.com>
Fri, 22 Sep 2017 14:51:46 +0200
changeset 669144 fa524e77ef3e0496d052be067a87cc28db6659a0
parent 669143 3d11e27057a37db169e3e8f166fed60b854152e4
child 669145 6b52ab7a62ed59b6ab7a12e3a0bda3d8d2788594
push id81223
push usergpascutto@mozilla.com
push dateFri, 22 Sep 2017 15:21:17 +0000
reviewerssotaro
bugs1383786
milestone58.0a1
Bug 1383786 - Make it possible to update TextureHost image keys. r=sotaro
gfx/layers/composite/GPUVideoTextureHost.cpp
gfx/layers/composite/GPUVideoTextureHost.h
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TextureHost.h
gfx/layers/d3d11/TextureD3D11.cpp
gfx/layers/d3d11/TextureD3D11.h
gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h
gfx/layers/wr/AsyncImagePipelineManager.cpp
gfx/layers/wr/WebRenderBridgeParent.cpp
gfx/layers/wr/WebRenderTextureHost.cpp
gfx/layers/wr/WebRenderTextureHost.h
--- a/gfx/layers/composite/GPUVideoTextureHost.cpp
+++ b/gfx/layers/composite/GPUVideoTextureHost.cpp
@@ -114,23 +114,23 @@ GPUVideoTextureHost::CreateRenderTexture
 uint32_t
 GPUVideoTextureHost::NumSubTextures() const
 {
   MOZ_ASSERT(mWrappedTextureHost);
   return mWrappedTextureHost->NumSubTextures();
 }
 
 void
-GPUVideoTextureHost::AddWRImage(wr::ResourceUpdateQueue& aResources,
-                                Range<const wr::ImageKey>& aImageKeys,
-                                const wr::ExternalImageId& aExtID)
+GPUVideoTextureHost::PushResourceUpdates(wr::ResourceUpdateQueue& aResources,
+                                         ResourceUpdateOp aOp,
+                                         const Range<wr::ImageKey>& aImageKeys,
+                                         const wr::ExternalImageId& aExtID)
 {
   MOZ_ASSERT(mWrappedTextureHost);
-
-  mWrappedTextureHost->AddWRImage(aResources, aImageKeys, aExtID);
+  mWrappedTextureHost->PushResourceUpdates(aResources, aOp, aImageKeys, aExtID);
 }
 
 void
 GPUVideoTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder,
                                        const wr::LayoutRect& aBounds,
                                        const wr::LayoutRect& aClip,
                                        wr::ImageRendering aFilter,
                                        Range<const wr::ImageKey>& aImageKeys)
--- a/gfx/layers/composite/GPUVideoTextureHost.h
+++ b/gfx/layers/composite/GPUVideoTextureHost.h
@@ -45,19 +45,20 @@ public:
 #endif
 
   virtual bool HasIntermediateBuffer() const override;
 
   virtual void CreateRenderTexture(const wr::ExternalImageId& aExternalImageId) override;
 
   virtual uint32_t NumSubTextures() const override;
 
-  virtual void AddWRImage(wr::ResourceUpdateQueue& aResources,
-                          Range<const wr::ImageKey>& aImageKeys,
-                          const wr::ExternalImageId& aExtID) override;
+  virtual void PushResourceUpdates(wr::ResourceUpdateQueue& aResources,
+                                   ResourceUpdateOp aOp,
+                                   const Range<wr::ImageKey>& aImageKeys,
+                                   const wr::ExternalImageId& aExtID) override;
 
   virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
                                  const wr::LayoutRect& aBounds,
                                  const wr::LayoutRect& aClip,
                                  wr::ImageRendering aFilter,
                                  Range<const wr::ImageKey>& aImageKeys) override;
 
 protected:
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -572,48 +572,41 @@ BufferTextureHost::NumSubTextures() cons
   if (GetFormat() == gfx::SurfaceFormat::YUV) {
     return 3;
   }
 
   return 1;
 }
 
 void
-BufferTextureHost::AddWRImage(wr::ResourceUpdateQueue& aResources,
-                              Range<const wr::ImageKey>& aImageKeys,
-                              const wr::ExternalImageId& aExtID)
+BufferTextureHost::PushResourceUpdates(wr::ResourceUpdateQueue& aResources,
+                                       ResourceUpdateOp aOp,
+                                       const Range<wr::ImageKey>& aImageKeys,
+                                       const wr::ExternalImageId& aExtID)
 {
+  auto method = aOp == TextureHost::ADD_IMAGE ? &wr::ResourceUpdateQueue::AddExternalImage
+                                              : &wr::ResourceUpdateQueue::UpdateExternalImage;
+  auto bufferType = wr::WrExternalImageBufferType::ExternalBuffer;
+
   if (GetFormat() != gfx::SurfaceFormat::YUV) {
     MOZ_ASSERT(aImageKeys.length() == 1);
 
     wr::ImageDescriptor descriptor(GetSize(),
                                    ImageDataSerializer::ComputeRGBStride(GetFormat(), GetSize().width),
                                    GetFormat());
-    aResources.AddExternalImageBuffer(aImageKeys[0], descriptor, aExtID);
+    (aResources.*method)(aImageKeys[0], descriptor, aExtID, bufferType, 0);
   } else {
     MOZ_ASSERT(aImageKeys.length() == 3);
 
     const layers::YCbCrDescriptor& desc = mDescriptor.get_YCbCrDescriptor();
     wr::ImageDescriptor yDescriptor(desc.ySize(), desc.ySize().width, gfx::SurfaceFormat::A8);
     wr::ImageDescriptor cbcrDescriptor(desc.cbCrSize(), desc.cbCrSize().width, gfx::SurfaceFormat::A8);
-    aResources.AddExternalImage(aImageKeys[0],
-                                yDescriptor,
-                                aExtID,
-                                wr::WrExternalImageBufferType::ExternalBuffer,
-                                0);
-    aResources.AddExternalImage(aImageKeys[1],
-                                cbcrDescriptor,
-                                aExtID,
-                                wr::WrExternalImageBufferType::ExternalBuffer,
-                                1);
-    aResources.AddExternalImage(aImageKeys[2],
-                                cbcrDescriptor,
-                                aExtID,
-                                wr::WrExternalImageBufferType::ExternalBuffer,
-                                2);
+    (aResources.*method)(aImageKeys[0], yDescriptor, aExtID, bufferType, 0);
+    (aResources.*method)(aImageKeys[1], cbcrDescriptor, aExtID, bufferType, 1);
+    (aResources.*method)(aImageKeys[2], cbcrDescriptor, aExtID, bufferType, 2);
   }
 }
 
 void
 BufferTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder,
                                      const wr::LayoutRect& aBounds,
                                      const wr::LayoutRect& aClip,
                                      wr::ImageRendering aFilter,
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -620,23 +620,28 @@ public:
   {
     MOZ_RELEASE_ASSERT(false, "No CreateRenderTexture() implementation for this TextureHost type.");
   }
 
   /// Returns the number of actual textures that will be used to render this.
   /// For example in a lot of YUV cases it will be 3
   virtual uint32_t NumSubTextures() const { return 1; }
 
+  enum ResourceUpdateOp {
+    ADD_IMAGE,
+    UPDATE_IMAGE,
+  };
+
   // Add all necessary TextureHost informations to the resource update queue.
-  // Then, WR will use this informations to read from the TextureHost.
-  virtual void AddWRImage(wr::ResourceUpdateQueue& aResources,
-                          Range<const wr::ImageKey>& aImageKeys,
-                          const wr::ExternalImageId& aExtID)
+  virtual void PushResourceUpdates(wr::ResourceUpdateQueue& aResources,
+                                   ResourceUpdateOp aOp,
+                                   const Range<wr::ImageKey>& aImageKeys,
+                                   const wr::ExternalImageId& aExtID)
   {
-    MOZ_ASSERT_UNREACHABLE("No AddWRImage() implementation for this TextureHost type.");
+    MOZ_ASSERT_UNREACHABLE("Unimplemented");
   }
 
   // Put all necessary WR commands into DisplayListBuilder for this textureHost rendering.
   virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
                                  const wr::LayoutRect& aBounds,
                                  const wr::LayoutRect& aClip,
                                  wr::ImageRendering aFilter,
                                  Range<const wr::ImageKey>& aKeys)
@@ -736,19 +741,20 @@ public:
   virtual BufferTextureHost* AsBufferTextureHost() override { return this; }
 
   const BufferDescriptor& GetBufferDescriptor() const { return mDescriptor; }
 
   virtual void CreateRenderTexture(const wr::ExternalImageId& aExternalImageId) override;
 
   virtual uint32_t NumSubTextures() const override;
 
-  virtual void AddWRImage(wr::ResourceUpdateQueue& aResources,
-                          Range<const wr::ImageKey>& aImageKeys,
-                          const wr::ExternalImageId& aExtID) override;
+  virtual void PushResourceUpdates(wr::ResourceUpdateQueue& aResources,
+                                   ResourceUpdateOp aOp,
+                                   const Range<wr::ImageKey>& aImageKeys,
+                                   const wr::ExternalImageId& aExtID) override;
 
   virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
                                  const wr::LayoutRect& aBounds,
                                  const wr::LayoutRect& aClip,
                                  wr::ImageRendering aFilter,
                                  Range<const wr::ImageKey>& aImageKeys) override;
 
 protected:
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -1058,52 +1058,44 @@ DXGITextureHostD3D11::NumSubTextures() c
     default: {
       MOZ_ASSERT_UNREACHABLE("unexpected format");
       return 1;
     }
   }
 }
 
 void
-DXGITextureHostD3D11::AddWRImage(wr::ResourceUpdateQueue& aResources,
-                                 Range<const wr::ImageKey>& aImageKeys,
-                                 const wr::ExternalImageId& aExtID)
+DXGITextureHostD3D11::PushResourceUpdates(wr::ResourceUpdateQueue& aResources,
+                                          ResourceUpdateOp aOp,
+                                          const Range<wr::ImageKey>& aImageKeys,
+                                          const wr::ExternalImageId& aExtID) override;
 {
   MOZ_ASSERT(mHandle);
+  auto method = aOp == TextureHost::ADD_IMAGE ? &wr::ResourceUpdateQueue::AddExternalImage
+                                              : &wr::ResourceUpdateQueue::UpdateExternalImage;
+  auto bufferType = wr::WrExternalImageBufferType::TextureExternalHandle;
 
   switch (mFormat) {
     case gfx::SurfaceFormat::R8G8B8X8:
     case gfx::SurfaceFormat::R8G8B8A8:
     case gfx::SurfaceFormat::B8G8R8A8:
     case gfx::SurfaceFormat::B8G8R8X8: {
       MOZ_ASSERT(aImageKeys.length() == 1);
 
       wr::ImageDescriptor descriptor(GetSize(), GetFormat());
-      aResources.AddExternalImage(aImageKeys[0],
-                                  descriptor,
-                                  aExtID,
-                                  wr::WrExternalImageBufferType::Texture2DHandle,
-                                  0);
+      (aResources.*method)(aImageKeys[0], descriptor, aExtID, bufferType, 0);
       break;
     }
     case gfx::SurfaceFormat::NV12: {
       MOZ_ASSERT(aImageKeys.length() == 2);
 
       wr::ImageDescriptor descriptor0(GetSize(), gfx::SurfaceFormat::A8);
       wr::ImageDescriptor descriptor1(GetSize() / 2, gfx::SurfaceFormat::R8G8);
-      aResources.AddExternalImage(aImageKeys[0],
-                                  descriptor0,
-                                  aExtID,
-                                  wr::WrExternalImageBufferType::TextureExternalHandle,
-                                  0);
-      aResources.AddExternalImage(aImageKeys[1],
-                                  descriptor1,
-                                  aExtID,
-                                  wr::WrExternalImageBufferType::TextureExternalHandle,
-                                  1);
+      (aResources.*method)(aImageKeys[0], descriptor0, aExtID, bufferType, 0);
+      (aResources.*method)(aImageKeys[1], descriptor1, aExtID, bufferType, 1);
       break;
     }
     default: {
       MOZ_ASSERT_UNREACHABLE("unexpected to be called");
     }
   }
 }
 
@@ -1298,19 +1290,20 @@ DXGIYCbCrTextureHostD3D11::BindTextureSo
 
 void
 DXGIYCbCrTextureHostD3D11::CreateRenderTexture(const wr::ExternalImageId& aExternalImageId)
 {
   // We use AddImage() directly. It's no corresponding RenderTextureHost.
 }
 
 void
-DXGIYCbCrTextureHostD3D11::AddWRImage(wr::ResourceUpdateQueue& aResources,
-                                      Range<const wr::ImageKey>& aImageKeys,
-                                      const wr::ExternalImageId& aExtID)
+DXGIYCbCrTextureHostD3D11::PushResourceUpdates(wr::ResourceUpdateQueue& aResources,
+                                               ResourceUpdateOp aOp,
+                                               const Range<wr::ImageKey>& aImageKeys,
+                                               const wr::ExternalImageId& aExtID) override;
 {
   // TODO - This implementation is very slow (read-back, copy on the copy and re-upload).
 
   MOZ_ASSERT(mTextures[0] && mTextures[1] && mTextures[2]);
   MOZ_ASSERT(aImageKeys.length() == 1);
 
   // There are 3 A8 channel data in DXGIYCbCrTextureHostD3D11, but ANGLE doesn't
   // support for converting the D3D A8 texture to OpenGL texture handle. So, we
@@ -1326,17 +1319,21 @@ DXGIYCbCrTextureHostD3D11::AddWRImage(wr
   if (!dataSourceSurface->Map(gfx::DataSourceSurface::MapType::READ, &map)) {
     return;
   }
 
   IntSize size = dataSourceSurface->GetSize();
   wr::ImageDescriptor descriptor(size, map.mStride, dataSourceSurface->GetFormat());
   wr::Vec_u8 imgBytes;
   imgBytes.PushBytes(Range<uint8_t>(map.mData, size.height * map.mStride));
-  aResources.AddImage(aImageKeys[0], descriptor, imgBytes);
+  if (aOp == TextureHost::ADD_IMAGE) {
+    aResources.AddImage(aImageKeys[0], descriptor, imgBytes);
+  } else {
+    aResource.UpdateImage(aImageKeys[0], descriptor, imgBytes);
+  }
 
   dataSourceSurface->Unmap();
 }
 
 void
 DXGIYCbCrTextureHostD3D11::PushExternalImage(wr::DisplayListBuilder& aBuilder,
                                              const wr::LayoutRect& aBounds,
                                              const wr::LayoutRect& aClip,
--- a/gfx/layers/d3d11/TextureD3D11.h
+++ b/gfx/layers/d3d11/TextureD3D11.h
@@ -332,19 +332,20 @@ public:
   virtual gfx::IntSize GetSize() const override { return mSize; }
 
   virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override;
 
   virtual void CreateRenderTexture(const wr::ExternalImageId& aExternalImageId) override;
 
   virtual uint32_t NumSubTextures() const override;
 
-  virtual void AddWRImage(wr::ResourceUpdateQueue& aAPI,
-                          Range<const wr::ImageKey>& aImageKeys,
-                          const wr::ExternalImageId& aExtID) override;
+  virtual void PushResourceUpdates(wr::ResourceUpdateQueue& aResources,
+                                   ResourceUpdateOp aOp,
+                                   const Range<wr::ImageKey>& aImageKeys,
+                                   const wr::ExternalImageId& aExtID) override;
 
   virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
                                  const wr::LayoutRect& aBounds,
                                  const wr::LayoutRect& aClip,
                                  wr::ImageRendering aFilter,
                                  Range<const wr::ImageKey>& aImageKeys) override;
 
 protected:
@@ -392,19 +393,20 @@ public:
 
   virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override
   {
     return nullptr;
   }
 
   virtual void CreateRenderTexture(const wr::ExternalImageId& aExternalImageId) override;
 
-  virtual void AddWRImage(wr::ResourceUpdateQueue& aResources,
-                          Range<const wr::ImageKey>& aImageKeys,
-                          const wr::ExternalImageId& aExtID) override;
+  virtual void PushResourceUpdates(wr::ResourceUpdateQueue& aResources,
+                                   ResourceUpdateOp aOp,
+                                   const Range<wr::ImageKey>& aImageKeys,
+                                   const wr::ExternalImageId& aExtID) override;
 
   virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
                                  const wr::LayoutRect& aBounds,
                                  const wr::LayoutRect& aClip,
                                  wr::ImageRendering aFilter,
                                  Range<const wr::ImageKey>& aImageKeys) override;
 
 private:
--- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
+++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
@@ -142,69 +142,58 @@ MacIOSurfaceTextureHostOGL::NumSubTextur
     default: {
       MOZ_ASSERT_UNREACHABLE("unexpected format");
       return 1;
     }
   }
 }
 
 void
-MacIOSurfaceTextureHostOGL::AddWRImage(wr::ResourceUpdateQueue& aResources,
-                                       Range<const wr::ImageKey>& aImageKeys,
-                                       const wr::ExternalImageId& aExtID)
+MacIOSurfaceTextureHostOGL::PushResourceUpdates(wr::ResourceUpdateQueue& aResources,
+                                                ResourceUpdateOp aOp,
+                                                const Range<wr::ImageKey>& aImageKeys,
+                                                const wr::ExternalImageId& aExtID) override;
 {
   MOZ_ASSERT(mSurface);
 
+  auto method = aOp == TextureHost::ADD_IMAGE ? &wr::ResourceUpdateQueue::AddExternalImage
+                                              : &wr::ResourceUpdateQueue::UpdateExternalImage;
+  auto bufferType = wr::WrExternalImageBufferType::TextureRectHandle;
+
   switch (GetFormat()) {
     case gfx::SurfaceFormat::R8G8B8X8:
     case gfx::SurfaceFormat::R8G8B8A8:
     case gfx::SurfaceFormat::B8G8R8A8:
     case gfx::SurfaceFormat::B8G8R8X8: {
       MOZ_ASSERT(aImageKeys.length() == 1);
       MOZ_ASSERT(mSurface->GetPlaneCount() == 0);
       wr::ImageDescriptor descriptor(GetSize(), GetFormat());
-      aResources.AddExternalImage(aImageKeys[0],
-                                  descriptor,
-                                  aExtID,
-                                  wr::WrExternalImageBufferType::TextureRectHandle,
-                                  0);
+      (aResources.*method)(aImageKeys[0], descriptor, aExtID, bufferType, 0);
       break;
     }
     case gfx::SurfaceFormat::YUV422: {
       // This is the special buffer format. The buffer contents could be a
       // converted RGB interleaving data or a YCbCr interleaving data depending
       // on the different platform setting. (e.g. It will be RGB at OpenGL 2.1
       // and YCbCr at OpenGL 3.1)
       MOZ_ASSERT(aImageKeys.length() == 1);
       MOZ_ASSERT(mSurface->GetPlaneCount() == 0);
       wr::ImageDescriptor descriptor(GetSize(), gfx::SurfaceFormat::R8G8B8X8);
-      aResources.AddExternalImage(aImageKeys[0],
-                                  descriptor,
-                                  aExtID,
-                                  wr::WrExternalImageBufferType::TextureRectHandle,
-                                  0);
+      (aResources.*method)(aImageKeys[0], descriptor, aExtID, bufferType, 0);
       break;
     }
     case gfx::SurfaceFormat::NV12: {
       MOZ_ASSERT(aImageKeys.length() == 2);
       MOZ_ASSERT(mSurface->GetPlaneCount() == 2);
       wr::ImageDescriptor descriptor0(gfx::IntSize(mSurface->GetDevicePixelWidth(0), mSurface->GetDevicePixelHeight(0)),
                                       gfx::SurfaceFormat::A8);
       wr::ImageDescriptor descriptor1(gfx::IntSize(mSurface->GetDevicePixelWidth(1), mSurface->GetDevicePixelHeight(1)),
                                       gfx::SurfaceFormat::R8G8);
-      aResources.AddExternalImage(aImageKeys[0],
-                                  descriptor0,
-                                  aExtID,
-                                  wr::WrExternalImageBufferType::TextureRectHandle,
-                                  0);
-      aResources.AddExternalImage(aImageKeys[1],
-                                  descriptor1,
-                                  aExtID,
-                                  wr::WrExternalImageBufferType::TextureRectHandle,
-                                  1);
+      (aResources.*method)(aImageKeys[0], descriptor0, aExtID, bufferType, 0);
+      (aResources.*method)(aImageKeys[1], descriptor1, aExtID, bufferType, 1);
       break;
     }
     default: {
       MOZ_ASSERT_UNREACHABLE("unexpected to be called");
     }
   }
 }
 
--- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h
+++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h
@@ -61,19 +61,20 @@ public:
   virtual MacIOSurfaceTextureHostOGL* AsMacIOSurfaceTextureHost() override { return this; }
 
   virtual MacIOSurface* GetMacIOSurface() override { return mSurface; }
 
   virtual void CreateRenderTexture(const wr::ExternalImageId& aExternalImageId) override;
 
   virtual uint32_t NumSubTextures() const override;
 
-  virtual void AddWRImage(wr::ResourceUpdateQueue& aResources,
-                          Range<const wr::ImageKey>& aImageKeys,
-                          const wr::ExternalImageId& aExtID) override;
+  virtual void PushResourceUpdates(wr::ResourceUpdateQueue& aResources,
+                                   ResourceUpdateOp aOp,
+                                   const Range<wr::ImageKey>& aImageKeys,
+                                   const wr::ExternalImageId& aExtID) override;
 
   virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
                                  const wr::LayoutRect& aBounds,
                                  const wr::LayoutRect& aClip,
                                  wr::ImageRendering aFilter,
                                  Range<const wr::ImageKey>& aImageKeys) override;
 
 protected:
--- a/gfx/layers/wr/AsyncImagePipelineManager.cpp
+++ b/gfx/layers/wr/AsyncImagePipelineManager.cpp
@@ -173,18 +173,19 @@ AsyncImagePipelineManager::GenerateImage
   WebRenderTextureHost* wrTexture = aTexture->AsWebRenderTextureHost();
 
   if (!gfxEnv::EnableWebRenderRecording() && wrTexture) {
     auto numKeys = wrTexture->NumSubTextures();
     for (uint32_t i = 0; i < numKeys; ++i) {
       aKeys.AppendElement(GenerateImageKey());
     }
     MOZ_ASSERT(!aKeys.IsEmpty());
-    Range<const wr::ImageKey> keys(&aKeys[0], aKeys.Length());
-    wrTexture->AddWRImage(aResources, keys, wrTexture->GetExternalImageKey());
+    Range<wr::ImageKey> keys(&aKeys[0], aKeys.Length());
+    wrTexture->PushResourceUpdates(aResources, TextureHost::ADD_IMAGE,
+                                   keys, wrTexture->GetExternalImageKey());
     return true;
   } else {
     RefPtr<gfx::DataSourceSurface> dSurf = aTexture->GetAsSurface();
     if (!dSurf) {
       NS_ERROR("TextureHost does not return DataSourceSurface");
       return false;
     }
     gfx::DataSourceSurface::MappedSurface map;
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -324,17 +324,17 @@ WebRenderBridgeParent::UpdateResources(c
 
   return true;
 }
 
 bool
 WebRenderBridgeParent::AddExternalImage(wr::ExternalImageId aExtId, wr::ImageKey aKey,
                                         wr::ResourceUpdateQueue& aResources)
 {
-  Range<const wr::ImageKey> keys(&aKey, 1);
+  Range<wr::ImageKey> keys(&aKey, 1);
   // Check if key is obsoleted.
   if (keys[0].mNamespace != mIdNamespace) {
     return true;
   }
   MOZ_ASSERT(mExternalImageIds.Get(wr::AsUint64(aExtId)).get());
 
   RefPtr<WebRenderImageHost> host = mExternalImageIds.Get(wr::AsUint64(aExtId));
   if (!host) {
@@ -344,17 +344,18 @@ WebRenderBridgeParent::AddExternalImage(
   if (!gfxEnv::EnableWebRenderRecording()) {
     TextureHost* texture = host->GetAsTextureHostForComposite();
     if (!texture) {
       NS_ERROR("TextureHost does not exist");
       return false;
     }
     WebRenderTextureHost* wrTexture = texture->AsWebRenderTextureHost();
     if (wrTexture) {
-      wrTexture->AddWRImage(aResources, keys, wrTexture->GetExternalImageKey());
+      wrTexture->PushResourceUpdates(aResources, TextureHost::ADD_IMAGE, keys,
+                                     wrTexture->GetExternalImageKey());
       return true;
     }
   }
   RefPtr<DataSourceSurface> dSurf = host->GetAsSurface();
   if (!dSurf) {
     NS_ERROR("TextureHost does not return DataSourceSurface");
     return false;
   }
--- a/gfx/layers/wr/WebRenderTextureHost.cpp
+++ b/gfx/layers/wr/WebRenderTextureHost.cpp
@@ -137,24 +137,25 @@ WebRenderTextureHost::GetRGBStride()
 uint32_t
 WebRenderTextureHost::NumSubTextures() const
 {
   MOZ_ASSERT(mWrappedTextureHost);
   return mWrappedTextureHost->NumSubTextures();
 }
 
 void
-WebRenderTextureHost::AddWRImage(wr::ResourceUpdateQueue& aResources,
-                                 Range<const wr::ImageKey>& aImageKeys,
-                                 const wr::ExternalImageId& aExtID)
+WebRenderTextureHost::PushResourceUpdates(wr::ResourceUpdateQueue& aResources,
+                                          ResourceUpdateOp aOp,
+                                          const Range<wr::ImageKey>& aImageKeys,
+                                          const wr::ExternalImageId& aExtID)
 {
   MOZ_ASSERT(mWrappedTextureHost);
   MOZ_ASSERT(mExternalImageId == aExtID);
 
-  mWrappedTextureHost->AddWRImage(aResources, aImageKeys, aExtID);
+  mWrappedTextureHost->PushResourceUpdates(aResources, aOp, aImageKeys, aExtID);
 }
 
 void
 WebRenderTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder,
                                         const wr::LayoutRect& aBounds,
                                         const wr::LayoutRect& aClip,
                                         wr::ImageRendering aFilter,
                                         Range<const wr::ImageKey>& aImageKeys)
--- a/gfx/layers/wr/WebRenderTextureHost.h
+++ b/gfx/layers/wr/WebRenderTextureHost.h
@@ -60,19 +60,20 @@ public:
   virtual WebRenderTextureHost* AsWebRenderTextureHost() override { return this; }
 
   wr::ExternalImageId GetExternalImageKey() { return mExternalImageId; }
 
   int32_t GetRGBStride();
 
   virtual uint32_t NumSubTextures() const override;
 
-  virtual void AddWRImage(wr::ResourceUpdateQueue& aResources,
-                          Range<const wr::ImageKey>& aImageKeys,
-                          const wr::ExternalImageId& aExtID) override;
+  virtual void PushResourceUpdates(wr::ResourceUpdateQueue& aResources,
+                                   ResourceUpdateOp aOp,
+                                   const Range<wr::ImageKey>& aImageKeys,
+                                   const wr::ExternalImageId& aExtID) override;
 
   virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
                                  const wr::LayoutRect& aBounds,
                                  const wr::LayoutRect& aClip,
                                  wr::ImageRendering aFilter,
                                  Range<const wr::ImageKey>& aImageKeys) override;
 
 protected: