diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index f0930f64f09a..d8f998f7ebf4 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -2352,7 +2352,7 @@ WebGLContext::GetVRFrame() if (sharedSurface && sharedSurface->GetAllocator() != vrmc) { RefPtr dest = - screen->Factory()->NewTexClient(sharedSurface->GetSize()); + screen->Factory()->NewTexClient(sharedSurface->GetSize(), vrmc); if (!dest) { return nullptr; } diff --git a/gfx/gl/SharedSurface.cpp b/gfx/gl/SharedSurface.cpp index fa1d19172f25..53f74490eb05 100644 --- a/gfx/gl/SharedSurface.cpp +++ b/gfx/gl/SharedSurface.cpp @@ -17,6 +17,7 @@ #include "mozilla/layers/TextureClientSharedSurface.h" #include "mozilla/layers/TextureForwarder.h" #include "mozilla/Unused.h" +#include "VRManagerChild.h" namespace mozilla { namespace gl { @@ -317,15 +318,22 @@ SurfaceFactory::~SurfaceFactory() } already_AddRefed -SurfaceFactory::NewTexClient(const gfx::IntSize& size) +SurfaceFactory::NewTexClient(const gfx::IntSize& size, const layers::LayersIPCChannel* aLayersChannel) { while (!mRecycleFreePool.empty()) { RefPtr 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); diff --git a/gfx/gl/SharedSurface.h b/gfx/gl/SharedSurface.h index 158586a3c98e..e180319e0473 100644 --- a/gfx/gl/SharedSurface.h +++ b/gfx/gl/SharedSurface.h @@ -306,7 +306,8 @@ protected: public: UniquePtr NewSharedSurface(const gfx::IntSize& size); //already_AddRefed NewShSurfHandle(const gfx::IntSize& size); - already_AddRefed NewTexClient(const gfx::IntSize& size); + already_AddRefed NewTexClient(const gfx::IntSize& size, + const layers::LayersIPCChannel* aLayersChannel = nullptr); static void RecycleCallback(layers::TextureClient* tc, void* /*closure*/);