Bug 1366941 - Checking LayersIPCChannel type when using recycled textureClient; r=nical
authordmu@mozilla.com <dmu@mozilla.com>
Wed, 24 May 2017 11:01:45 +0000
changeset 362082 b98b73c139ebfd184ae52c3da7191ae37601d996
parent 362081 2109d6a6d1c8f69cee5674a216b42fccf09ff2a2
child 362083 bb5fc68d7f713ca944ab2d85a66269405323963a
push id91011
push userkwierso@gmail.com
push dateSat, 03 Jun 2017 00:31:42 +0000
treeherdermozilla-inbound@bb37ef22d35c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1366941
milestone55.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 1366941 - Checking LayersIPCChannel type when using recycled textureClient; r=nical MozReview-Commit-ID: 94PQA67fvoJ
dom/canvas/WebGLContext.cpp
gfx/gl/SharedSurface.cpp
gfx/gl/SharedSurface.h
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -2347,17 +2347,17 @@ WebGLContext::GetVRFrame()
 
     RefPtr<SharedSurfaceTextureClient> sharedSurface = screen->Front();
     if (!sharedSurface) {
         return nullptr;
     }
 
     if (sharedSurface && sharedSurface->GetAllocator() != vrmc) {
         RefPtr<SharedSurfaceTextureClient> dest =
-        screen->Factory()->NewTexClient(sharedSurface->GetSize());
+        screen->Factory()->NewTexClient(sharedSurface->GetSize(), vrmc);
         if (!dest) {
             return nullptr;
         }
         gl::SharedSurface* destSurf = dest->Surf();
         destSurf->ProducerAcquire();
         SharedSurface::ProdCopy(sharedSurface->Surf(), dest->Surf(),
                                 screen->Factory());
         destSurf->ProducerRelease();
--- a/gfx/gl/SharedSurface.cpp
+++ b/gfx/gl/SharedSurface.cpp
@@ -12,16 +12,17 @@
 #include "GLScreenBuffer.h"
 #include "nsThreadUtils.h"
 #include "ScopedGLHelpers.h"
 #include "SharedSurfaceGL.h"
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/TextureClientSharedSurface.h"
 #include "mozilla/layers/TextureForwarder.h"
 #include "mozilla/Unused.h"
+#include "VRManagerChild.h"
 
 namespace mozilla {
 namespace gl {
 
 /*static*/ void
 SharedSurface::ProdCopy(SharedSurface* src, SharedSurface* dest,
                         SurfaceFactory* factory)
 {
@@ -312,25 +313,32 @@ SurfaceFactory::~SurfaceFactory()
     MOZ_RELEASE_ASSERT(mRecycleTotalPool.empty(),"GFX: Surface recycle pool not empty.");
 
     // If we mRecycleFreePool.clear() before StopRecycling(), we may try to recycle it,
     // fail, call StopRecycling(), then return here and call it again.
     mRecycleFreePool.clear();
 }
 
 already_AddRefed<layers::SharedSurfaceTextureClient>
-SurfaceFactory::NewTexClient(const gfx::IntSize& size)
+SurfaceFactory::NewTexClient(const gfx::IntSize& size, const layers::LayersIPCChannel* aLayersChannel)
 {
     while (!mRecycleFreePool.empty()) {
         RefPtr<layers::SharedSurfaceTextureClient> cur = mRecycleFreePool.front();
         mRecycleFreePool.pop();
 
-        if (cur->Surf()->mSize == size) {
-            cur->Surf()->WaitForBufferOwnership();
-            return cur.forget();
+        if (cur->Surf()->mSize == size){
+            // In the general case, textureClients transit textures through
+            // CompositorForwarder. But, the textureClient created by VRManagerChild
+            // has a different LayerIPCChannel, PVRManager. Therefore, textureClients
+            // need to be separated into different cases.
+            if ((aLayersChannel && aLayersChannel == cur->GetAllocator()) ||
+                (cur->GetAllocator() != gfx::VRManagerChild::Get())) {
+                cur->Surf()->WaitForBufferOwnership();
+                return cur.forget();
+            }
         }
 
         StopRecycling(cur);
     }
 
     UniquePtr<SharedSurface> surf = Move(CreateShared(size));
     if (!surf)
         return nullptr;
--- a/gfx/gl/SharedSurface.h
+++ b/gfx/gl/SharedSurface.h
@@ -301,17 +301,18 @@ protected:
 
     void StartRecycling(layers::SharedSurfaceTextureClient* tc);
     void SetRecycleCallback(layers::SharedSurfaceTextureClient* tc);
     void StopRecycling(layers::SharedSurfaceTextureClient* tc);
 
 public:
     UniquePtr<SharedSurface> NewSharedSurface(const gfx::IntSize& size);
     //already_AddRefed<ShSurfHandle> NewShSurfHandle(const gfx::IntSize& size);
-    already_AddRefed<layers::SharedSurfaceTextureClient> NewTexClient(const gfx::IntSize& size);
+    already_AddRefed<layers::SharedSurfaceTextureClient> NewTexClient(const gfx::IntSize& size,
+                                                                      const layers::LayersIPCChannel* aLayersChannel = nullptr);
 
     static void RecycleCallback(layers::TextureClient* tc, void* /*closure*/);
 
     // Auto-deletes surfs of the wrong type.
     bool Recycle(layers::SharedSurfaceTextureClient* texClient);
 };
 
 class ScopedReadbackFB