Bug 1265824 - handle the texture uploading and readLock related things for direct mapping texture source r?mattwoodrow draft
authorDoug Thayer <dothayer@mozilla.com>
Wed, 02 May 2018 18:31:31 -0700
changeset 816210 f5cbdceb802df4f80d36d7b0c31f3e2959fa1a18
parent 816209 570a882598f37507b58e5a9c533c7be360bd7314
child 816211 cbe7962f7da9138172774b54cddae654f8c1944e
push id115776
push userbmo:dothayer@mozilla.com
push dateTue, 10 Jul 2018 18:33:51 +0000
reviewersmattwoodrow
bugs1265824
milestone63.0a1
Bug 1265824 - handle the texture uploading and readLock related things for direct mapping texture source r?mattwoodrow MozReview-Commit-ID: BC065h1Ac6k
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TextureHost.h
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -882,21 +882,32 @@ BufferTextureHost::AcquireTextureSource(
   if (!UploadIfNeeded()) {
     return false;
   }
   aTexture = mFirstSource;
   return !!mFirstSource;
 }
 
 void
+BufferTextureHost::ReadUnlock()
+{
+  if (mFirstSource) {
+    mFirstSource->Sync();
+  }
+
+  TextureHost::ReadUnlock();
+}
+
+void
 BufferTextureHost::UnbindTextureSource()
 {
   if (mFirstSource && mFirstSource->IsOwnedBy(this)) {
     mFirstSource->Unbind();
   }
+
   // This texture is not used by any layer anymore.
   // If the texture doesn't have an intermediate buffer, it means we are
   // compositing synchronously on the CPU, so we don't need to wait until
   // the end of the next composition to ReadUnlock (which other textures do
   // by default).
   // If the texture has an intermediate buffer we don't care either because
   // texture uploads are also performed synchronously for BufferTextureHost.
   ReadUnlock();
@@ -990,17 +1001,19 @@ BufferTextureHost::Upload(nsIntRegion *a
     return false;
   }
   if (!mProvider) {
     // This can happen if we send textures to a compositable that isn't yet
     // attached to a layer.
     return false;
   }
   if (!mHasIntermediateBuffer && EnsureWrappingTextureSource()) {
-    return true;
+    if (!mFirstSource || !mFirstSource->IsDirectMap()) {
+      return true;
+    }
   }
 
   if (mFormat == gfx::SurfaceFormat::UNKNOWN) {
     NS_WARNING("BufferTextureHost: unsupported format!");
     return false;
   } else if (mFormat == gfx::SurfaceFormat::YUV) {
     const YCbCrDescriptor& desc = mDescriptor.get_YCbCrDescriptor();
 
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -666,17 +666,17 @@ public:
   }
 
   /**
    * Some API's can use the cross-process IOSurface directly, such as OpenVR
    */
   virtual MacIOSurface* GetMacIOSurface() { return nullptr; }
 
 protected:
-  void ReadUnlock();
+  virtual void ReadUnlock();
 
   void RecycleTexture(TextureFlags aFlags);
 
   virtual void UpdatedInternal(const nsIntRegion *Region) {}
 
   /**
    * Called when mCompositableCount becomes 0.
    */
@@ -771,16 +771,18 @@ public:
                                    const wr::ExternalImageId& aExtID) override;
 
   virtual void PushDisplayItems(wr::DisplayListBuilder& aBuilder,
                                 const wr::LayoutRect& aBounds,
                                 const wr::LayoutRect& aClip,
                                 wr::ImageRendering aFilter,
                                 const Range<wr::ImageKey>& aImageKeys) override;
 
+  virtual void ReadUnlock() override;
+
 protected:
   bool Upload(nsIntRegion *aRegion = nullptr);
   bool UploadIfNeeded();
   bool MaybeUpload(nsIntRegion *aRegion);
   bool EnsureWrappingTextureSource();
 
   virtual void UpdatedInternal(const nsIntRegion* aRegion = nullptr) override;