Bug 1366941 - Checking LayersIPCChannel type when using recycled textureClient; r?nical
MozReview-Commit-ID: 94PQA67fvoJ
--- 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