Bug 1281456 - Decouple TextureForwarder and CompositableForwarder. r=gw280

This commit is contained in:
Matt Woodrow 2016-09-27 16:22:20 +13:00
parent c6471e4eeb
commit 55f506db9f
85 changed files with 576 additions and 635 deletions

View File

@ -15,7 +15,7 @@
#include "ScopedGLHelpers.h"
#include "gfx2DGlue.h"
#include "../layers/ipc/ShadowLayers.h"
#include "mozilla/layers/CompositableForwarder.h"
#include "mozilla/layers/TextureForwarder.h"
#include "mozilla/layers/TextureClientSharedSurface.h"
#ifdef XP_WIN
@ -69,16 +69,17 @@ GLScreenBuffer::Create(GLContext* gl,
/* static */ UniquePtr<SurfaceFactory>
GLScreenBuffer::CreateFactory(GLContext* gl,
const SurfaceCaps& caps,
const RefPtr<layers::CompositableForwarder>& forwarder,
KnowsCompositor* compositorConnection,
const layers::TextureFlags& flags)
{
return CreateFactory(gl, caps, forwarder, forwarder->GetCompositorBackendType(), flags);
return CreateFactory(gl, caps, compositorConnection->GetTextureForwarder(),
compositorConnection->GetCompositorBackendType(), flags);
}
/* static */ UniquePtr<SurfaceFactory>
GLScreenBuffer::CreateFactory(GLContext* gl,
const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
LayersIPCChannel* ipcChannel,
const mozilla::layers::LayersBackend backend,
const layers::TextureFlags& flags)
{
@ -87,18 +88,18 @@ GLScreenBuffer::CreateFactory(GLContext* gl,
switch (backend) {
case mozilla::layers::LayersBackend::LAYERS_OPENGL: {
#if defined(XP_MACOSX)
factory = SurfaceFactory_IOSurface::Create(gl, caps, allocator, flags);
factory = SurfaceFactory_IOSurface::Create(gl, caps, ipcChannel, flags);
#elif defined(MOZ_WIDGET_GONK)
factory = MakeUnique<SurfaceFactory_Gralloc>(gl, caps, allocator, flags);
factory = MakeUnique<SurfaceFactory_Gralloc>(gl, caps, ipcChannel, flags);
#elif defined(GL_PROVIDER_GLX)
if (sGLXLibrary.UseTextureFromPixmap())
factory = SurfaceFactory_GLXDrawable::Create(gl, caps, allocator, flags);
factory = SurfaceFactory_GLXDrawable::Create(gl, caps, ipcChannel, flags);
#elif defined(MOZ_WIDGET_UIKIT)
factory = MakeUnique<SurfaceFactory_GLTexture>(mGLContext, caps, allocator, mFlags);
factory = MakeUnique<SurfaceFactory_GLTexture>(mGLContext, caps, ipcChannel, mFlags);
#else
if (gl->GetContextType() == GLContextType::EGL) {
if (XRE_IsParentProcess()) {
factory = SurfaceFactory_EGLImage::Create(gl, caps, allocator, flags);
factory = SurfaceFactory_EGLImage::Create(gl, caps, ipcChannel, flags);
}
}
#endif
@ -113,11 +114,11 @@ GLScreenBuffer::CreateFactory(GLContext* gl,
(gl->IsWARP() == dm->IsWARP()) &&
dm->TextureSharingWorks())
{
factory = SurfaceFactory_ANGLEShareHandle::Create(gl, caps, allocator, flags);
factory = SurfaceFactory_ANGLEShareHandle::Create(gl, caps, ipcChannel, flags);
}
if (!factory && gfxPrefs::WebGLDXGLEnabled()) {
factory = SurfaceFactory_D3D11Interop::Create(gl, caps, allocator, flags);
factory = SurfaceFactory_D3D11Interop::Create(gl, caps, ipcChannel, flags);
}
#endif
break;
@ -128,7 +129,7 @@ GLScreenBuffer::CreateFactory(GLContext* gl,
#ifdef GL_PROVIDER_GLX
if (!factory && sGLXLibrary.UseTextureFromPixmap()) {
factory = SurfaceFactory_GLXDrawable::Create(gl, caps, allocator, flags);
factory = SurfaceFactory_GLXDrawable::Create(gl, caps, ipcChannel, flags);
}
#endif
}

View File

@ -25,7 +25,8 @@
namespace mozilla {
namespace layers {
class CompositableForwarder;
class KnowsCompositor;
class LayersIPCChannel;
class SharedSurfaceTextureClient;
} // namespace layers
@ -137,12 +138,12 @@ public:
static UniquePtr<SurfaceFactory>
CreateFactory(GLContext* gl,
const SurfaceCaps& caps,
const RefPtr<layers::CompositableForwarder>& forwarder,
layers::KnowsCompositor* compositorConnection,
const layers::TextureFlags& flags);
static UniquePtr<SurfaceFactory>
CreateFactory(GLContext* gl,
const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
layers::LayersIPCChannel* ipcChannel,
const mozilla::layers::LayersBackend backend,
const layers::TextureFlags& flags);

View File

@ -15,6 +15,7 @@
#include "SharedSurfaceGL.h"
#include "mozilla/layers/CompositorTypes.h"
#include "mozilla/layers/TextureClientSharedSurface.h"
#include "mozilla/layers/TextureForwarder.h"
#include "mozilla/Unused.h"
namespace mozilla {
@ -287,7 +288,7 @@ ChooseBufferBits(const SurfaceCaps& caps,
SurfaceFactory::SurfaceFactory(SharedSurfaceType type, GLContext* gl,
const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags)
: mType(type)
, mGL(gl)

View File

@ -39,7 +39,7 @@ class DrawTarget;
} // namespace gfx
namespace layers {
class ClientIPCAllocator;
class LayersIPCChannel;
class SharedSurfaceTextureClient;
enum class TextureFlags : uint32_t;
class SurfaceDescriptor;
@ -267,7 +267,7 @@ public:
const SharedSurfaceType mType;
GLContext* const mGL;
const SurfaceCaps mCaps;
const RefPtr<layers::ClientIPCAllocator> mAllocator;
const RefPtr<layers::LayersIPCChannel> mAllocator;
const layers::TextureFlags mFlags;
const GLFormats mFormats;
Mutex mMutex;
@ -278,7 +278,7 @@ protected:
RefSet<layers::SharedSurfaceTextureClient> mRecycleTotalPool;
SurfaceFactory(SharedSurfaceType type, GLContext* gl, const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags);
public:

View File

@ -320,7 +320,7 @@ SharedSurface_ANGLEShareHandle::ReadbackBySharedHandle(gfx::DataSourceSurface* o
/*static*/ UniquePtr<SurfaceFactory_ANGLEShareHandle>
SurfaceFactory_ANGLEShareHandle::Create(GLContext* gl, const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags)
{
GLLibraryEGL* egl = &sEGLLibrary;
@ -340,7 +340,7 @@ SurfaceFactory_ANGLEShareHandle::Create(GLContext* gl, const SurfaceCaps& caps,
SurfaceFactory_ANGLEShareHandle::SurfaceFactory_ANGLEShareHandle(GLContext* gl,
const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags,
GLLibraryEGL* egl,
EGLConfig config)

View File

@ -80,12 +80,12 @@ protected:
public:
static UniquePtr<SurfaceFactory_ANGLEShareHandle> Create(GLContext* gl,
const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags);
protected:
SurfaceFactory_ANGLEShareHandle(GLContext* gl, const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags, GLLibraryEGL* egl,
EGLConfig config);

View File

@ -391,7 +391,7 @@ SharedSurface_D3D11Interop::ToSurfaceDescriptor(layers::SurfaceDescriptor* const
/*static*/ UniquePtr<SurfaceFactory_D3D11Interop>
SurfaceFactory_D3D11Interop::Create(GLContext* gl, const SurfaceCaps& caps,
layers::ClientIPCAllocator* allocator,
layers::LayersIPCChannel* allocator,
const layers::TextureFlags& flags)
{
WGLLibrary* wgl = &sWGLLib;
@ -411,7 +411,7 @@ SurfaceFactory_D3D11Interop::Create(GLContext* gl, const SurfaceCaps& caps,
SurfaceFactory_D3D11Interop::SurfaceFactory_D3D11Interop(GLContext* gl,
const SurfaceCaps& caps,
layers::ClientIPCAllocator* allocator,
layers::LayersIPCChannel* allocator,
const layers::TextureFlags& flags,
DXInterop2Device* interop)
: SurfaceFactory(SharedSurfaceType::DXGLInterop2, gl, caps, allocator, flags)

View File

@ -75,12 +75,12 @@ public:
static UniquePtr<SurfaceFactory_D3D11Interop> Create(GLContext* gl,
const SurfaceCaps& caps,
layers::ClientIPCAllocator* allocator,
layers::LayersIPCChannel* allocator,
const layers::TextureFlags& flags);
protected:
SurfaceFactory_D3D11Interop(GLContext* gl, const SurfaceCaps& caps,
layers::ClientIPCAllocator* allocator,
layers::LayersIPCChannel* allocator,
const layers::TextureFlags& flags,
DXInterop2Device* interop);

View File

@ -170,7 +170,7 @@ SharedSurface_EGLImage::ReadbackBySharedHandle(gfx::DataSourceSurface* out_surfa
/*static*/ UniquePtr<SurfaceFactory_EGLImage>
SurfaceFactory_EGLImage::Create(GLContext* prodGL, const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags)
{
EGLContext context = GLContextEGL::Cast(prodGL)->mContext;

View File

@ -90,14 +90,14 @@ public:
// Fallible:
static UniquePtr<SurfaceFactory_EGLImage> Create(GLContext* prodGL,
const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags);
protected:
const EGLContext mContext;
SurfaceFactory_EGLImage(GLContext* prodGL, const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags,
EGLContext context)
: SurfaceFactory(SharedSurfaceType::EGLImageShare, prodGL, caps, allocator, flags)

View File

@ -148,7 +148,7 @@ class SurfaceFactory_GLTexture
public:
SurfaceFactory_GLTexture(GLContext* prodGL,
const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags)
: SurfaceFactory(SharedSurfaceType::SharedGLTexture, prodGL, caps, allocator, flags)
{

View File

@ -13,6 +13,7 @@
#include "mozilla/layers/LayersSurfaces.h"
#include "mozilla/layers/ShadowLayerUtilsX11.h"
#include "mozilla/layers/ISurfaceAllocator.h"
#include "mozilla/layers/TextureForwarder.h"
#include "mozilla/X11Util.h"
namespace mozilla {
@ -120,7 +121,7 @@ SharedSurface_GLXDrawable::ReadbackBySharedHandle(gfx::DataSourceSurface* out_su
UniquePtr<SurfaceFactory_GLXDrawable>
SurfaceFactory_GLXDrawable::Create(GLContext* prodGL,
const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags)
{
MOZ_ASSERT(caps.alpha, "GLX surfaces require an alpha channel!");

View File

@ -49,14 +49,14 @@ class SurfaceFactory_GLXDrawable
public:
static UniquePtr<SurfaceFactory_GLXDrawable> Create(GLContext* prodGL,
const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags);
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) override;
private:
SurfaceFactory_GLXDrawable(GLContext* prodGL, const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags)
: SurfaceFactory(SharedSurfaceType::GLXDrawable, prodGL, caps, allocator, flags)
{ }

View File

@ -35,7 +35,7 @@ using namespace mozilla::layers;
using namespace android;
SurfaceFactory_Gralloc::SurfaceFactory_Gralloc(GLContext* prodGL, const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags)
: SurfaceFactory(SharedSurfaceType::Gralloc, prodGL, caps, allocator, flags)
{
@ -48,7 +48,7 @@ SharedSurface_Gralloc::Create(GLContext* prodGL,
const gfx::IntSize& size,
bool hasAlpha,
layers::TextureFlags flags,
ClientIPCAllocator* allocator)
LayersIPCChannel* allocator)
{
GLLibraryEGL* egl = &sEGLLibrary;
MOZ_ASSERT(egl);
@ -118,7 +118,7 @@ SharedSurface_Gralloc::SharedSurface_Gralloc(GLContext* prodGL,
const gfx::IntSize& size,
bool hasAlpha,
GLLibraryEGL* egl,
layers::ClientIPCAllocator* allocator,
layers::LayersIPCChannel* allocator,
layers::TextureClient* textureClient,
GLuint prodTex)
: SharedSurface(SharedSurfaceType::Gralloc,

View File

@ -12,7 +12,7 @@
namespace mozilla {
namespace layers {
class ClientIPCAllocator;
class LayersIPCChannel;
class TextureClient;
}
@ -29,7 +29,7 @@ public:
const gfx::IntSize& size,
bool hasAlpha,
layers::TextureFlags flags,
layers::ClientIPCAllocator* allocator);
layers::LayersIPCChannel* allocator);
static SharedSurface_Gralloc* Cast(SharedSurface* surf) {
MOZ_ASSERT(surf->mType == SharedSurfaceType::Gralloc);
@ -40,7 +40,7 @@ public:
protected:
GLLibraryEGL* const mEGL;
EGLSync mSync;
RefPtr<layers::ClientIPCAllocator> mAllocator;
RefPtr<layers::LayersIPCChannel> mAllocator;
RefPtr<layers::TextureClient> mTextureClient;
const GLuint mProdTex;
@ -48,7 +48,7 @@ protected:
const gfx::IntSize& size,
bool hasAlpha,
GLLibraryEGL* egl,
layers::ClientIPCAllocator* allocator,
layers::LayersIPCChannel* allocator,
layers::TextureClient* textureClient,
GLuint prodTex);
@ -83,7 +83,7 @@ class SurfaceFactory_Gralloc
{
public:
SurfaceFactory_Gralloc(GLContext* prodGL, const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags);
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) override {

View File

@ -211,7 +211,7 @@ SharedSurface_IOSurface::ReadbackBySharedHandle(gfx::DataSourceSurface* out_surf
/*static*/ UniquePtr<SurfaceFactory_IOSurface>
SurfaceFactory_IOSurface::Create(GLContext* gl, const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags)
{
auto maxDims = gfx::IntSize::Truncate(MacIOSurface::GetMaxWidth(),

View File

@ -77,13 +77,13 @@ public:
// Infallible.
static UniquePtr<SurfaceFactory_IOSurface> Create(GLContext* gl,
const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags);
protected:
const gfx::IntSize mMaxDims;
SurfaceFactory_IOSurface(GLContext* gl, const SurfaceCaps& caps,
const RefPtr<layers::ClientIPCAllocator>& allocator,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags,
const gfx::IntSize& maxDims)
: SurfaceFactory(SharedSurfaceType::IOSurface, gl, caps, allocator, flags)

View File

@ -27,16 +27,17 @@ public:
LayersBackend aLayersBackend,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags,
ClientIPCAllocator* aAllocator);
LayersIPCChannel* aAllocator);
virtual TextureData*
CreateSimilar(ClientIPCAllocator* aAllocator,
CreateSimilar(LayersIPCChannel* aAllocator,
LayersBackend aLayersBackend,
TextureFlags aFlags = TextureFlags::DEFAULT,
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const override;
virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
virtual void Deallocate(ClientIPCAllocator*) override;
virtual void Deallocate(LayersIPCChannel*) override;
MemoryTextureData(const BufferDescriptor& aDesc,
gfx::BackendType aMoz2DBackend,
@ -66,16 +67,17 @@ public:
LayersBackend aLayersBackend,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags,
ClientIPCAllocator* aAllocator);
LayersIPCChannel* aAllocator);
virtual TextureData*
CreateSimilar(ClientIPCAllocator* aAllocator,
CreateSimilar(LayersIPCChannel* aAllocator,
LayersBackend aLayersBackend,
TextureFlags aFlags = TextureFlags::DEFAULT,
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const override;
virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
virtual void Deallocate(ClientIPCAllocator* aAllocator) override;
virtual void Deallocate(LayersIPCChannel* aAllocator) override;
ShmemTextureData(const BufferDescriptor& aDesc,
gfx::BackendType aMoz2DBackend, mozilla::ipc::Shmem aShmem)
@ -114,22 +116,21 @@ BufferTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
gfx::BackendType aMoz2DBackend,
LayersBackend aLayersBackend, TextureFlags aFlags,
TextureAllocationFlags aAllocFlags,
ClientIPCAllocator* aAllocator)
LayersIPCChannel* aAllocator)
{
if (!aAllocator || aAllocator->IsSameProcess()) {
return MemoryTextureData::Create(aSize, aFormat, aMoz2DBackend,
aLayersBackend, aFlags,
aAllocFlags, aAllocator);
} else if (aAllocator->AsShmemAllocator()) {
} else {
return ShmemTextureData::Create(aSize, aFormat, aMoz2DBackend,
aLayersBackend, aFlags,
aAllocFlags, aAllocator);
}
return nullptr;
}
BufferTextureData*
BufferTextureData::CreateInternal(ClientIPCAllocator* aAllocator,
BufferTextureData::CreateInternal(LayersIPCChannel* aAllocator,
const BufferDescriptor& aDesc,
gfx::BackendType aMoz2DBackend,
int32_t aBufferSize,
@ -144,19 +145,18 @@ BufferTextureData::CreateInternal(ClientIPCAllocator* aAllocator,
GfxMemoryImageReporter::DidAlloc(buffer);
return new MemoryTextureData(aDesc, aMoz2DBackend, buffer, aBufferSize);
} else if (aAllocator->AsShmemAllocator()) {
} else {
ipc::Shmem shm;
if (!aAllocator->AsShmemAllocator()->AllocUnsafeShmem(aBufferSize, OptimalShmemType(), &shm)) {
if (!aAllocator->AllocUnsafeShmem(aBufferSize, OptimalShmemType(), &shm)) {
return nullptr;
}
return new ShmemTextureData(aDesc, aMoz2DBackend, shm);
}
return nullptr;
}
BufferTextureData*
BufferTextureData::CreateForYCbCrWithBufferSize(ClientIPCAllocator* aAllocator,
BufferTextureData::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
int32_t aBufferSize,
TextureFlags aTextureFlags)
{
@ -164,10 +164,8 @@ BufferTextureData::CreateForYCbCrWithBufferSize(ClientIPCAllocator* aAllocator,
return nullptr;
}
auto fwd = aAllocator->AsCompositableForwarder();
bool hasIntermediateBuffer = fwd ? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV,
fwd->GetCompositorBackendType())
: true;
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV,
aAllocator->GetCompositorBackendType());
// Initialize the metadata with something, even if it will have to be rewritten
// afterwards since we don't know the dimensions of the texture at this point.
@ -175,12 +173,12 @@ BufferTextureData::CreateForYCbCrWithBufferSize(ClientIPCAllocator* aAllocator,
0, 0, 0, StereoMode::MONO,
hasIntermediateBuffer);
return CreateInternal(aAllocator, desc, gfx::BackendType::NONE, aBufferSize,
return CreateInternal(aAllocator->GetTextureForwarder(), desc, gfx::BackendType::NONE, aBufferSize,
aTextureFlags);
}
BufferTextureData*
BufferTextureData::CreateForYCbCr(ClientIPCAllocator* aAllocator,
BufferTextureData::CreateForYCbCr(KnowsCompositor* aAllocator,
gfx::IntSize aYSize,
gfx::IntSize aCbCrSize,
StereoMode aStereoMode,
@ -198,17 +196,16 @@ BufferTextureData::CreateForYCbCr(ClientIPCAllocator* aAllocator,
aCbCrSize.width, aCbCrSize.height,
yOffset, cbOffset, crOffset);
auto fwd = aAllocator ? aAllocator->AsCompositableForwarder() : nullptr;
bool hasIntermediateBuffer = fwd ? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV,
fwd->GetCompositorBackendType())
: true;
bool hasIntermediateBuffer = aAllocator ? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV,
aAllocator->GetCompositorBackendType())
: true;
YCbCrDescriptor descriptor = YCbCrDescriptor(aYSize, aCbCrSize, yOffset, cbOffset,
crOffset, aStereoMode,
hasIntermediateBuffer);
return CreateInternal(aAllocator, descriptor, gfx::BackendType::NONE, bufSize,
aTextureFlags);
return CreateInternal(aAllocator ? aAllocator->GetTextureForwarder() : nullptr, descriptor,
gfx::BackendType::NONE, bufSize, aTextureFlags);
}
void
@ -462,7 +459,7 @@ MemoryTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
gfx::BackendType aMoz2DBackend,
LayersBackend aLayersBackend, TextureFlags aFlags,
TextureAllocationFlags aAllocFlags,
ClientIPCAllocator* aAllocator)
LayersIPCChannel* aAllocator)
{
// Should have used CreateForYCbCr.
MOZ_ASSERT(aFormat != gfx::SurfaceFormat::YUV);
@ -482,10 +479,6 @@ MemoryTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
return nullptr;
}
// LAYERS_NONE must imply that we have no compositable forwarder
MOZ_ASSERT_IF(aLayersBackend == LayersBackend::LAYERS_NONE,
!aAllocator || !aAllocator->AsCompositableForwarder());
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(aFormat, aLayersBackend);
GfxMemoryImageReporter::DidAlloc(buf);
@ -496,7 +489,7 @@ MemoryTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
}
void
MemoryTextureData::Deallocate(ClientIPCAllocator*)
MemoryTextureData::Deallocate(LayersIPCChannel*)
{
MOZ_ASSERT(mBuffer);
GfxMemoryImageReporter::WillFree(mBuffer);
@ -505,15 +498,13 @@ MemoryTextureData::Deallocate(ClientIPCAllocator*)
}
TextureData*
MemoryTextureData::CreateSimilar(ClientIPCAllocator* aAllocator,
MemoryTextureData::CreateSimilar(LayersIPCChannel* aAllocator,
LayersBackend aLayersBackend,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags) const
{
auto fwd = aAllocator ? aAllocator->AsCompositableForwarder() : nullptr;
auto backend = fwd ? fwd->GetCompositorBackendType() : LayersBackend::LAYERS_NONE;
return MemoryTextureData::Create(GetSize(), GetFormat(), mMoz2DBackend,
backend, aFlags, aAllocFlags, aAllocator);
aLayersBackend, aFlags, aAllocFlags, aAllocator);
}
bool
@ -534,13 +525,13 @@ ShmemTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
gfx::BackendType aMoz2DBackend,
LayersBackend aLayersBackend, TextureFlags aFlags,
TextureAllocationFlags aAllocFlags,
ClientIPCAllocator* aAllocator)
LayersIPCChannel* aAllocator)
{
MOZ_ASSERT(aAllocator);
// Should have used CreateForYCbCr.
MOZ_ASSERT(aFormat != gfx::SurfaceFormat::YUV);
if (!aAllocator || !aAllocator->AsShmemAllocator()) {
if (!aAllocator) {
return nullptr;
}
@ -555,7 +546,7 @@ ShmemTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
}
mozilla::ipc::Shmem shm;
if (!aAllocator->AsShmemAllocator()->AllocUnsafeShmem(bufSize, OptimalShmemType(), &shm)) {
if (!aAllocator->AllocUnsafeShmem(bufSize, OptimalShmemType(), &shm)) {
return nullptr;
}
@ -564,10 +555,6 @@ ShmemTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
return nullptr;
}
// LAYERS_NONE must imply that we have no compositable forwarder
MOZ_ASSERT_IF(aLayersBackend == LayersBackend::LAYERS_NONE,
!aAllocator || !aAllocator->AsCompositableForwarder());
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(aFormat, aLayersBackend);
BufferDescriptor descriptor = RGBDescriptor(aSize, aFormat, hasIntermediateBuffer);
@ -578,21 +565,19 @@ ShmemTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
}
TextureData*
ShmemTextureData::CreateSimilar(ClientIPCAllocator* aAllocator,
ShmemTextureData::CreateSimilar(LayersIPCChannel* aAllocator,
LayersBackend aLayersBackend,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags) const
{
auto fwd = aAllocator ? aAllocator->AsCompositableForwarder() : nullptr;
auto backend = fwd ? fwd->GetCompositorBackendType() : LayersBackend::LAYERS_NONE;
return ShmemTextureData::Create(GetSize(), GetFormat(), mMoz2DBackend,
backend, aFlags, aAllocFlags, aAllocator);
aLayersBackend, aFlags, aAllocFlags, aAllocator);
}
void
ShmemTextureData::Deallocate(ClientIPCAllocator* aAllocator)
ShmemTextureData::Deallocate(LayersIPCChannel* aAllocator)
{
aAllocator->AsShmemAllocator()->DeallocShmem(mShmem);
aAllocator->DeallocShmem(mShmem);
}
} // namespace

View File

@ -26,9 +26,9 @@ public:
LayersBackend aLayersBackend,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags,
ClientIPCAllocator* aAllocator);
LayersIPCChannel* aAllocator);
static BufferTextureData* CreateForYCbCr(ClientIPCAllocator* aAllocator,
static BufferTextureData* CreateForYCbCr(KnowsCompositor* aAllocator,
gfx::IntSize aYSize,
gfx::IntSize aCbCrSize,
StereoMode aStereoMode,
@ -37,7 +37,7 @@ public:
// It is generally better to use CreateForYCbCr instead.
// This creates a half-initialized texture since we don't know the sizes and
// offsets in the buffer.
static BufferTextureData* CreateForYCbCrWithBufferSize(ClientIPCAllocator* aAllocator,
static BufferTextureData* CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
int32_t aSize,
TextureFlags aTextureFlags);
@ -70,7 +70,7 @@ protected:
gfx::SurfaceFormat GetFormat() const;
static BufferTextureData* CreateInternal(ClientIPCAllocator* aAllocator,
static BufferTextureData* CreateInternal(LayersIPCChannel* aAllocator,
const BufferDescriptor& aDesc,
gfx::BackendType aMoz2DBackend,
int32_t aBufferSize,

View File

@ -53,7 +53,7 @@ D3D11ShareHandleImage::GetSize()
}
TextureClient*
D3D11ShareHandleImage::GetTextureClient(TextureForwarder* aForwarder)
D3D11ShareHandleImage::GetTextureClient(KnowsCompositor* aForwarder)
{
return mTextureClient;
}
@ -142,7 +142,7 @@ D3D11RecycleAllocator::Allocate(gfx::SurfaceFormat aFormat,
{
return CreateD3D11TextureClientWithDevice(aSize, aFormat,
aTextureFlags, aAllocFlags,
mDevice, mSurfaceAllocator);
mDevice, mSurfaceAllocator->GetTextureForwarder());
}
already_AddRefed<TextureClient>

View File

@ -19,7 +19,7 @@ namespace layers {
class D3D11RecycleAllocator : public TextureClientRecycleAllocator
{
public:
explicit D3D11RecycleAllocator(TextureForwarder* aAllocator,
explicit D3D11RecycleAllocator(KnowsCompositor* aAllocator,
ID3D11Device* aDevice)
: TextureClientRecycleAllocator(aAllocator)
, mDevice(aDevice)
@ -54,7 +54,7 @@ public:
gfx::IntSize GetSize() override;
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
virtual TextureClient* GetTextureClient(TextureForwarder* aForwarder) override;
virtual TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override;
virtual gfx::IntRect GetPictureRect() override { return mPictureRect; }
ID3D11Texture2D* GetTexture() const;

View File

@ -128,10 +128,10 @@ D3D9SurfaceImage::GetSize()
}
TextureClient*
D3D9SurfaceImage::GetTextureClient(TextureForwarder* aForwarder)
D3D9SurfaceImage::GetTextureClient(KnowsCompositor* aForwarder)
{
MOZ_ASSERT(mTextureClient);
MOZ_ASSERT(mTextureClient->GetAllocator() == aForwarder);
MOZ_ASSERT(mTextureClient->GetAllocator() == aForwarder->GetTextureForwarder());
return mTextureClient;
}
@ -207,7 +207,8 @@ D3D9RecycleAllocator::Allocate(gfx::SurfaceFormat aFormat,
return nullptr;
}
return MakeAndAddRef<TextureClient>(data, aTextureFlags, mSurfaceAllocator);
return MakeAndAddRef<TextureClient>(data, aTextureFlags,
mSurfaceAllocator->GetTextureForwarder());
}
already_AddRefed<TextureClient>

View File

@ -19,7 +19,7 @@ class TextureClient;
class D3D9RecycleAllocator : public TextureClientRecycleAllocator
{
public:
explicit D3D9RecycleAllocator(TextureForwarder* aAllocator,
explicit D3D9RecycleAllocator(KnowsCompositor* aAllocator,
IDirect3DDevice9* aDevice)
: TextureClientRecycleAllocator(aAllocator)
, mDevice(aDevice)
@ -60,7 +60,7 @@ public:
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
virtual TextureClient* GetTextureClient(TextureForwarder* aForwarder) override;
virtual TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override;
already_AddRefed<IDirect3DSurface9> GetD3D9Surface();

View File

@ -40,7 +40,7 @@ public:
// in the other process and send it across.
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override { return nullptr; }
virtual TextureClient* GetTextureClient(TextureForwarder* aForwarder) override
virtual TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override
{
MOZ_ASSERT(aForwarder == ImageBridgeChild::GetSingleton(), "Must only use GPUVideo on ImageBridge");
return mTextureClient;

View File

@ -155,7 +155,7 @@ static bool UploadData(IDirect3DDevice9* aDevice,
}
TextureClient*
IMFYCbCrImage::GetD3D9TextureClient(TextureForwarder* aForwarder)
IMFYCbCrImage::GetD3D9TextureClient(KnowsCompositor* aForwarder)
{
RefPtr<IDirect3DDevice9> device = DeviceManagerD3D9::GetDevice();
if (!device) {
@ -207,20 +207,19 @@ IMFYCbCrImage::GetD3D9TextureClient(TextureForwarder* aForwarder)
}
mTextureClient = TextureClient::CreateWithData(
DXGIYCbCrTextureData::Create(aForwarder,
TextureFlags::DEFAULT,
DXGIYCbCrTextureData::Create(TextureFlags::DEFAULT,
textureY, textureCb, textureCr,
shareHandleY, shareHandleCb, shareHandleCr,
GetSize(), mData.mYSize, mData.mCbCrSize),
TextureFlags::DEFAULT,
aForwarder
aForwarder->GetTextureForwarder()
);
return mTextureClient;
}
TextureClient*
IMFYCbCrImage::GetTextureClient(TextureForwarder* aForwarder)
IMFYCbCrImage::GetTextureClient(KnowsCompositor* aForwarder)
{
if (mTextureClient) {
return mTextureClient;
@ -275,12 +274,11 @@ IMFYCbCrImage::GetTextureClient(TextureForwarder* aForwarder)
}
mTextureClient = TextureClient::CreateWithData(
DXGIYCbCrTextureData::Create(aForwarder,
TextureFlags::DEFAULT,
DXGIYCbCrTextureData::Create(TextureFlags::DEFAULT,
textureY, textureCb, textureCr,
GetSize(), mData.mYSize, mData.mCbCrSize),
TextureFlags::DEFAULT,
aForwarder
aForwarder->GetTextureForwarder()
);
return mTextureClient;

View File

@ -20,11 +20,11 @@ public:
virtual bool IsValid() { return true; }
virtual TextureClient* GetTextureClient(TextureForwarder* aForwarder) override;
virtual TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override;
protected:
TextureClient* GetD3D9TextureClient(TextureForwarder* aForwarder);
TextureClient* GetD3D9TextureClient(KnowsCompositor* aForwarder);
~IMFYCbCrImage();

View File

@ -739,7 +739,7 @@ SourceSurfaceImage::~SourceSurfaceImage()
}
TextureClient*
SourceSurfaceImage::GetTextureClient(TextureForwarder* aForwarder)
SourceSurfaceImage::GetTextureClient(KnowsCompositor* aForwarder)
{
if (!aForwarder) {
return nullptr;
@ -760,7 +760,6 @@ SourceSurfaceImage::GetTextureClient(TextureForwarder* aForwarder)
// gfx::BackendType::NONE means default to content backend
textureClient = TextureClient::CreateFromSurface(aForwarder,
surface,
aForwarder->GetCompositorBackendType(),
BackendSelector::Content,
mTextureFlags,
ALLOC_DEFAULT);

View File

@ -151,7 +151,7 @@ class PImageContainerChild;
class SharedPlanarYCbCrImage;
class PlanarYCbCrImage;
class TextureClient;
class TextureForwarder;
class KnowsCompositor;
class GrallocImage;
class NVImage;
@ -228,7 +228,7 @@ public:
* For use with the TextureForwarder only (so that the later can
* synchronize the TextureClient with the TextureHost).
*/
virtual TextureClient* GetTextureClient(TextureForwarder* aForwarder) { return nullptr; }
virtual TextureClient* GetTextureClient(KnowsCompositor* aForwarder) { return nullptr; }
/* Access to derived classes. */
virtual EGLImageImage* AsEGLImageImage() { return nullptr; }
@ -890,7 +890,7 @@ public:
}
void SetTextureFlags(TextureFlags aTextureFlags) { mTextureFlags = aTextureFlags; }
virtual TextureClient* GetTextureClient(TextureForwarder* aForwarder) override;
virtual TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override;
virtual gfx::IntSize GetSize() override { return mSize; }

View File

@ -16,14 +16,14 @@ using namespace mozilla::layers;
using namespace mozilla::gfx;
TextureClient*
MacIOSurfaceImage::GetTextureClient(TextureForwarder* aForwarder)
MacIOSurfaceImage::GetTextureClient(KnowsCompositor* aForwarder)
{
if (!mTextureClient) {
BackendType backend = BackendType::NONE;
mTextureClient = TextureClient::CreateWithData(
MacIOSurfaceTextureData::Create(mSurface, backend),
TextureFlags::DEFAULT,
aForwarder
aForwarder->GetTextureForwarder()
);
}
return mTextureClient;

View File

@ -31,7 +31,7 @@ public:
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
virtual TextureClient* GetTextureClient(TextureForwarder* aForwarder) override;
virtual TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override;
virtual MacIOSurfaceImage* AsMacIOSurfaceImage() override {
return this;

View File

@ -86,9 +86,9 @@ PersistentBufferProviderBasic::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFo
already_AddRefed<PersistentBufferProviderShared>
PersistentBufferProviderShared::Create(gfx::IntSize aSize,
gfx::SurfaceFormat aFormat,
CompositableForwarder* aFwd)
KnowsCompositor* aFwd)
{
if (!aFwd || !aFwd->IPCOpen()) {
if (!aFwd || !aFwd->GetTextureForwarder()->IPCOpen()) {
return nullptr;
}
@ -110,7 +110,7 @@ PersistentBufferProviderShared::Create(gfx::IntSize aSize,
PersistentBufferProviderShared::PersistentBufferProviderShared(gfx::IntSize aSize,
gfx::SurfaceFormat aFormat,
CompositableForwarder* aFwd,
KnowsCompositor* aFwd,
RefPtr<TextureClient>& aTexture)
: mSize(aSize)
@ -136,7 +136,7 @@ PersistentBufferProviderShared::~PersistentBufferProviderShared()
}
bool
PersistentBufferProviderShared::SetForwarder(CompositableForwarder* aFwd)
PersistentBufferProviderShared::SetForwarder(KnowsCompositor* aFwd)
{
MOZ_ASSERT(aFwd);
if (!aFwd) {
@ -152,7 +152,7 @@ PersistentBufferProviderShared::SetForwarder(CompositableForwarder* aFwd)
mFwd->GetActiveResourceTracker().RemoveObject(this);
}
if (mFwd->AsTextureForwarder() != aFwd->AsTextureForwarder() ||
if (mFwd->GetTextureForwarder() != aFwd->GetTextureForwarder() ||
mFwd->GetCompositorBackendType() != aFwd->GetCompositorBackendType()) {
// We are going to be used with an different and/or incompatible forwarder.
// This should be extremely rare. We have to copy the front buffer into a
@ -225,7 +225,7 @@ PersistentBufferProviderShared::GetTexture(Maybe<uint32_t> aIndex)
already_AddRefed<gfx::DrawTarget>
PersistentBufferProviderShared::BorrowDrawTarget(const gfx::IntRect& aPersistedRect)
{
if (!mFwd->IPCOpen()) {
if (!mFwd->GetTextureForwarder()->IPCOpen()) {
return nullptr;
}
@ -442,4 +442,4 @@ PersistentBufferProviderShared::Destroy()
}
} // namespace layers
} // namespace mozilla
} // namespace mozilla

View File

@ -9,7 +9,7 @@
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/RefPtr.h" // for RefPtr, already_AddRefed, etc
#include "mozilla/layers/LayersTypes.h"
#include "mozilla/layers/CompositableForwarder.h"
#include "mozilla/layers/TextureForwarder.h"
#include "mozilla/gfx/Types.h"
#include "mozilla/Vector.h"
@ -64,7 +64,7 @@ public:
virtual void OnShutdown() {}
virtual bool SetForwarder(CompositableForwarder* aFwd) { return true; }
virtual bool SetForwarder(KnowsCompositor* aFwd) { return true; }
/**
* Return true if this provider preserves the drawing state (clips, transforms,
@ -117,7 +117,7 @@ public:
static already_AddRefed<PersistentBufferProviderShared>
Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
CompositableForwarder* aFwd);
KnowsCompositor* aFwd);
virtual LayersBackend GetType() override { return LayersBackend::LAYERS_CLIENT; }
@ -135,12 +135,12 @@ public:
virtual void OnShutdown() override { Destroy(); }
virtual bool SetForwarder(CompositableForwarder* aFwd) override;
virtual bool SetForwarder(KnowsCompositor* aFwd) override;
virtual bool PreservesDrawingState() const override { return false; }
protected:
PersistentBufferProviderShared(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
CompositableForwarder* aFwd,
KnowsCompositor* aFwd,
RefPtr<TextureClient>& aTexture);
~PersistentBufferProviderShared();
@ -152,7 +152,7 @@ protected:
gfx::IntSize mSize;
gfx::SurfaceFormat mFormat;
RefPtr<CompositableForwarder> mFwd;
RefPtr<KnowsCompositor> mFwd;
Vector<RefPtr<TextureClient>, 4> mTextures;
// Offset of the texture in mTextures that the canvas uses.
Maybe<uint32_t> mBack;

View File

@ -25,7 +25,8 @@ public:
virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
virtual TextureData*
CreateSimilar(ClientIPCAllocator* aAllocator,
CreateSimilar(LayersIPCChannel* aAllocator,
LayersBackend aLayersBackend,
TextureFlags aFlags = TextureFlags::DEFAULT,
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const override;
@ -34,7 +35,7 @@ public:
static
DIBTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat);
virtual void Deallocate(ClientIPCAllocator* aAllocator) override
virtual void Deallocate(LayersIPCChannel* aAllocator) override
{
mSurface = nullptr;
}
@ -62,7 +63,8 @@ public:
virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
virtual TextureData*
CreateSimilar(ClientIPCAllocator* aAllocator,
CreateSimilar(LayersIPCChannel* aAllocator,
LayersBackend aLayersBackend,
TextureFlags aFlags = TextureFlags::DEFAULT,
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const override;
@ -70,7 +72,7 @@ public:
static
DIBTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
ClientIPCAllocator* aAllocator);
LayersIPCChannel* aAllocator);
void DeallocateData()
{
@ -85,7 +87,7 @@ public:
}
}
virtual void Deallocate(ClientIPCAllocator* aAllocator) override
virtual void Deallocate(LayersIPCChannel* aAllocator) override
{
DeallocateData();
}
@ -137,7 +139,7 @@ DIBTextureData::BorrowDrawTarget()
DIBTextureData*
DIBTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
ClientIPCAllocator* aAllocator)
LayersIPCChannel* aAllocator)
{
if (!aAllocator) {
return nullptr;
@ -153,7 +155,8 @@ DIBTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
}
TextureData*
MemoryDIBTextureData::CreateSimilar(ClientIPCAllocator* aAllocator,
MemoryDIBTextureData::CreateSimilar(LayersIPCChannel* aAllocator,
LayersBackend aLayersBackend,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags) const
{
@ -216,7 +219,8 @@ MemoryDIBTextureData::UpdateFromSurface(gfx::SourceSurface* aSurface)
}
TextureData*
ShmemDIBTextureData::CreateSimilar(ClientIPCAllocator* aAllocator,
ShmemDIBTextureData::CreateSimilar(LayersIPCChannel* aAllocator,
LayersBackend aLayersBackend,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags) const
{
@ -280,7 +284,7 @@ ShmemDIBTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
DIBTextureData*
ShmemDIBTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
ClientIPCAllocator* aAllocator)
LayersIPCChannel* aAllocator)
{
MOZ_ASSERT(aAllocator->GetParentPid() != base::ProcessId());

View File

@ -28,7 +28,7 @@ public:
static
DIBTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
ClientIPCAllocator* aAllocator);
LayersIPCChannel* aAllocator);
protected:
DIBTextureData(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,

View File

@ -49,7 +49,7 @@ TextureWrapperImage::GetAsSourceSurface()
}
TextureClient*
TextureWrapperImage::GetTextureClient(TextureForwarder* aForwarder)
TextureWrapperImage::GetTextureClient(KnowsCompositor* aForwarder)
{
return mTextureClient;
}

View File

@ -24,7 +24,7 @@ public:
gfx::IntSize GetSize() override;
gfx::IntRect GetPictureRect() override;
already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
TextureClient* GetTextureClient(TextureForwarder* aForwarder) override;
TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override;
private:
gfx::IntRect mPictureRect;

View File

@ -106,13 +106,14 @@ X11TextureData::UpdateFromSurface(gfx::SourceSurface* aSurface)
}
void
X11TextureData::Deallocate(ClientIPCAllocator*)
X11TextureData::Deallocate(LayersIPCChannel*)
{
mSurface = nullptr;
}
TextureData*
X11TextureData::CreateSimilar(ClientIPCAllocator* aAllocator,
X11TextureData::CreateSimilar(LayersIPCChannel* aAllocator,
LayersBackend aLayersBackend,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags) const
{
@ -121,7 +122,7 @@ X11TextureData::CreateSimilar(ClientIPCAllocator* aAllocator,
X11TextureData*
X11TextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
TextureFlags aFlags, ClientIPCAllocator* aAllocator)
TextureFlags aFlags, LayersIPCChannel* aAllocator)
{
MOZ_ASSERT(aSize.width >= 0 && aSize.height >= 0);
if (aSize.width <= 0 || aSize.height <= 0 ||

View File

@ -17,7 +17,7 @@ class X11TextureData : public TextureData
{
public:
static X11TextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
TextureFlags aFlags, ClientIPCAllocator* aAllocator);
TextureFlags aFlags, LayersIPCChannel* aAllocator);
virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
@ -29,10 +29,11 @@ public:
virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
virtual void Deallocate(ClientIPCAllocator*) override;
virtual void Deallocate(LayersIPCChannel*) override;
virtual TextureData*
CreateSimilar(ClientIPCAllocator* aAllocator,
CreateSimilar(LayersIPCChannel* aAllocator,
LayersBackend aLayersBackend,
TextureFlags aFlags = TextureFlags::DEFAULT,
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const override;

View File

@ -211,7 +211,7 @@ static inline void SwapRB_R8G8B8A8(uint8_t* pixel) {
class TexClientFactory
{
ClientIPCAllocator* const mAllocator;
CompositableForwarder* const mAllocator;
const bool mHasAlpha;
const gfx::IntSize mSize;
const gfx::BackendType mBackendType;
@ -219,7 +219,7 @@ class TexClientFactory
const LayersBackend mLayersBackend;
public:
TexClientFactory(ClientIPCAllocator* allocator, bool hasAlpha,
TexClientFactory(CompositableForwarder* allocator, bool hasAlpha,
const gfx::IntSize& size, gfx::BackendType backendType,
TextureFlags baseTexFlags, LayersBackend layersBackend)
: mAllocator(allocator)
@ -267,7 +267,7 @@ public:
};
static already_AddRefed<TextureClient>
TexClientFromReadback(SharedSurface* src, ClientIPCAllocator* allocator,
TexClientFromReadback(SharedSurface* src, CompositableForwarder* allocator,
TextureFlags baseFlags, LayersBackend layersBackend)
{
auto backendType = gfx::BackendType::CAIRO;
@ -423,7 +423,7 @@ CanvasClientSharedSurface::UpdateRenderer(gfx::IntSize aSize, Renderer& aRendere
} else {
mShSurfClient = gl->Screen()->Front();
if (mShSurfClient && mShSurfClient->GetAllocator() &&
mShSurfClient->GetAllocator()->AsCompositableForwarder() != GetForwarder()) {
mShSurfClient->GetAllocator() != GetForwarder()->GetTextureForwarder()) {
mShSurfClient = CloneSurface(mShSurfClient->Surf(), gl->Screen()->Factory());
}
if (!mShSurfClient) {

View File

@ -92,7 +92,7 @@ public:
void UpdateTextureFactoryIdentifier(const TextureFactoryIdentifier& aNewIdentifier);
TextureFactoryIdentifier GetTextureFactoryIdentifier()
{
return mForwarder->GetTextureFactoryIdentifier();
return AsShadowForwarder()->GetTextureFactoryIdentifier();
}
virtual void FlushRendering() override;

View File

@ -35,9 +35,9 @@ RemoveTextureFromCompositableTracker::ReleaseTextureClient()
!mTextureClient->GetAllocator()->UsesImageBridge())
{
RefPtr<TextureClientReleaseTask> task = new TextureClientReleaseTask(mTextureClient);
RefPtr<ClientIPCAllocator> allocator = mTextureClient->GetAllocator();
RefPtr<LayersIPCChannel> allocator = mTextureClient->GetAllocator();
mTextureClient = nullptr;
allocator->AsClientAllocator()->GetMessageLoop()->PostTask(task.forget());
allocator->GetMessageLoop()->PostTask(task.forget());
} else {
mTextureClient = nullptr;
}
@ -173,9 +173,8 @@ CompositableClient::CreateTextureClientFromSurface(gfx::SourceSurface* aSurface,
TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags)
{
return TextureClient::CreateFromSurface(GetForwarder()->AsTextureForwarder(),
return TextureClient::CreateFromSurface(GetForwarder(),
aSurface,
GetForwarder()->GetCompositorBackendType(),
aSelector,
aTextureFlags | mTextureFlags,
aAllocFlags);
@ -224,7 +223,7 @@ CompositableClient::GetTextureClientRecycler()
return nullptr;
}
if(!mForwarder->UsesImageBridge()) {
if(!mForwarder->GetTextureForwarder()->UsesImageBridge()) {
MOZ_ASSERT(NS_IsMainThread());
mTextureClientRecycler = new layers::TextureClientRecycleAllocator(mForwarder);
return mTextureClientRecycler;

View File

@ -310,6 +310,7 @@ ContentClientRemoteBuffer::CreateBackBuffer(const IntRect& aBufferRect)
if (mTextureFlags & TextureFlags::COMPONENT_ALPHA) {
mTextureClientOnWhite = mTextureClient->CreateSimilar(
mForwarder->GetCompositorBackendType(),
mTextureFlags | ExtraTextureFlags(),
TextureAllocationFlags::ALLOC_CLEAR_BUFFER_WHITE
);

View File

@ -33,14 +33,14 @@ GPUVideoTextureData::FillInfo(TextureData::Info& aInfo) const
}
void
GPUVideoTextureData::Deallocate(ClientIPCAllocator* aAllocator)
GPUVideoTextureData::Deallocate(LayersIPCChannel* aAllocator)
{
dom::VideoDecoderManagerChild::GetSingleton()->DeallocateSurfaceDescriptorGPUVideo(mSD);
mSD = SurfaceDescriptorGPUVideo();
}
void
GPUVideoTextureData::Forget(ClientIPCAllocator* aAllocator)
GPUVideoTextureData::Forget(LayersIPCChannel* aAllocator)
{
// We always need to manually deallocate on the client side.
// Ideally we'd set up our TextureClient with the DEALLOCATE_CLIENT

View File

@ -30,9 +30,9 @@ public:
virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
virtual void Deallocate(ClientIPCAllocator* aAllocator) override;
virtual void Deallocate(LayersIPCChannel* aAllocator) override;
virtual void Forget(ClientIPCAllocator* aAllocator) override;
virtual void Forget(LayersIPCChannel* aAllocator) override;
protected:
SurfaceDescriptorGPUVideo mSD;

View File

@ -78,7 +78,7 @@ ImageClient::RemoveTextureWithWaiter(TextureClient* aTexture,
AsyncTransactionWaiter* aAsyncTransactionWaiter)
{
if (aAsyncTransactionWaiter &&
GetForwarder()->UsesImageBridge()) {
GetForwarder()->GetTextureForwarder()->UsesImageBridge()) {
RefPtr<AsyncTransactionTracker> request =
new RemoveTextureFromCompositableTracker(aAsyncTransactionWaiter);
GetForwarder()->RemoveTextureFromCompositableAsync(request, this, aTexture);
@ -103,7 +103,7 @@ TextureInfo ImageClientSingle::GetTextureInfo() const
void
ImageClientSingle::FlushAllImages(AsyncTransactionWaiter* aAsyncTransactionWaiter)
{
MOZ_ASSERT(GetForwarder()->UsesImageBridge());
MOZ_ASSERT(GetForwarder()->GetTextureForwarder()->UsesImageBridge());
for (auto& b : mBuffers) {
RemoveTextureWithWaiter(b.mTextureClient, aAsyncTransactionWaiter);
@ -219,13 +219,13 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer, uint32_t aContentFlag
if (image->GetFormat() == ImageFormat::EGLIMAGE) {
EGLImageImage* typedImage = image->AsEGLImageImage();
texture = EGLImageTextureData::CreateTextureClient(
typedImage, size, GetForwarder(), mTextureFlags);
typedImage, size, GetForwarder()->GetTextureForwarder(), mTextureFlags);
#ifdef MOZ_WIDGET_ANDROID
} else if (image->GetFormat() == ImageFormat::SURFACE_TEXTURE) {
SurfaceTextureImage* typedImage = image->AsSurfaceTextureImage();
texture = AndroidSurfaceTextureData::CreateTextureClient(
typedImage->GetSurfaceTexture(), size, typedImage->GetOriginPos(),
GetForwarder(), mTextureFlags
GetForwarder()->GetTextureForwarder(), mTextureFlags
);
#endif
} else {

View File

@ -75,7 +75,7 @@ struct TextureDeallocParams
{
TextureData* data;
RefPtr<TextureChild> actor;
RefPtr<ClientIPCAllocator> allocator;
RefPtr<LayersIPCChannel> allocator;
bool clientDeallocation;
bool syncDeallocation;
bool workAroundSharedSurfaceOwnershipIssue;
@ -119,15 +119,15 @@ public:
bool Recv__delete__() override { return true; }
ClientIPCAllocator* GetAllocator() { return mTextureForwarder; }
LayersIPCChannel* GetAllocator() { return mTextureForwarder; }
void ActorDestroy(ActorDestroyReason why) override;
bool IPCOpen() const { return mIPCOpen; }
void Lock() const { if (mCompositableForwarder && mCompositableForwarder->UsesImageBridge()) { mLock.Enter(); } }
void Lock() const { if (mCompositableForwarder && mCompositableForwarder->GetTextureForwarder()->UsesImageBridge()) { mLock.Enter(); } }
void Unlock() const { if (mCompositableForwarder && mCompositableForwarder->UsesImageBridge()) { mLock.Leave(); } }
void Unlock() const { if (mCompositableForwarder && mCompositableForwarder->GetTextureForwarder()->UsesImageBridge()) { mLock.Leave(); } }
private:
@ -240,7 +240,7 @@ private:
};
static void DestroyTextureData(TextureData* aTextureData, ClientIPCAllocator* aAllocator,
static void DestroyTextureData(TextureData* aTextureData, LayersIPCChannel* aAllocator,
bool aDeallocate, bool aMainThreadOnly)
{
if (!aTextureData) {
@ -248,7 +248,7 @@ static void DestroyTextureData(TextureData* aTextureData, ClientIPCAllocator* aA
}
if (aMainThreadOnly && !NS_IsMainThread()) {
RefPtr<ClientIPCAllocator> allocatorRef = aAllocator;
RefPtr<LayersIPCChannel> allocatorRef = aAllocator;
NS_DispatchToMainThread(NS_NewRunnableFunction([aTextureData, allocatorRef, aDeallocate]() -> void {
DestroyTextureData(aTextureData, allocatorRef, aDeallocate, true);
}));
@ -352,7 +352,7 @@ DeallocateTextureClient(TextureDeallocParams params)
MessageLoop* ipdlMsgLoop = nullptr;
if (params.allocator) {
ipdlMsgLoop = params.allocator->AsClientAllocator()->GetMessageLoop();
ipdlMsgLoop = params.allocator->GetMessageLoop();
if (!ipdlMsgLoop) {
// An allocator with no message loop means we are too late in the shutdown
// sequence.
@ -385,7 +385,7 @@ DeallocateTextureClient(TextureDeallocParams params)
if (!ipdlMsgLoop) {
// If we don't have a message loop we can't know for sure that we are in
// the IPDL thread and use the ClientIPCAllocator.
// the IPDL thread and use the LayersIPCChannel.
// This should ideally not happen outside of gtest, but some shutdown raciness
// could put us in this situation.
params.allocator = nullptr;
@ -641,7 +641,7 @@ TextureClient::UpdateFromSurface(gfx::SourceSurface* aSurface)
already_AddRefed<TextureClient>
TextureClient::CreateSimilar(TextureFlags aFlags, TextureAllocationFlags aAllocFlags) const
TextureClient::CreateSimilar(LayersBackend aLayersBackend, TextureFlags aFlags, TextureAllocationFlags aAllocFlags) const
{
MOZ_ASSERT(IsValid());
@ -651,7 +651,7 @@ TextureClient::CreateSimilar(TextureFlags aFlags, TextureAllocationFlags aAllocF
}
LockActor();
TextureData* data = mData->CreateSimilar(mAllocator, aFlags, aAllocFlags);
TextureData* data = mData->CreateSimilar(mAllocator, aLayersBackend, aFlags, aAllocFlags);
UnlockActor();
if (!data) {
@ -869,7 +869,7 @@ TextureClient::CancelWaitFenceHandleOnImageBridge()
ImageBridgeChild::GetSingleton()->CancelWaitFenceHandle(this);
}
void CancelTextureClientRecycle(uint64_t aTextureId, ClientIPCAllocator* aAllocator)
void CancelTextureClientRecycle(uint64_t aTextureId, LayersIPCChannel* aAllocator)
{
if (!aAllocator) {
return;
@ -918,17 +918,17 @@ TextureClient::SetRecycleAllocator(ITextureClientRecycleAllocator* aAllocator)
bool
TextureClient::InitIPDLActor(CompositableForwarder* aForwarder)
{
MOZ_ASSERT(aForwarder && aForwarder->GetMessageLoop() == mAllocator->AsClientAllocator()->GetMessageLoop());
MOZ_ASSERT(aForwarder && aForwarder->GetTextureForwarder()->GetMessageLoop() == mAllocator->GetMessageLoop());
if (mActor && !mActor->mDestroyed) {
CompositableForwarder* currentFwd = mActor->mCompositableForwarder;
TextureForwarder* currentTexFwd = mActor->mTextureForwarder;
if (currentFwd != aForwarder) {
// It's a bit iffy but right now ShadowLayerForwarder inherits TextureForwarder
// even though it should not. ShadowLayerForwarder::AsTextureForwarder actually
// even though it should not. ShadowLayerForwarder::GetTextureForwarder actually
// returns a pointer to the CompositorBridgeChild.
// It's Ok for a texture to move from a ShadowLayerForwarder to another, but
// not form a CompositorBridgeChild to another (they use different channels).
if (currentTexFwd && currentTexFwd != aForwarder->AsTextureForwarder()) {
if (currentTexFwd && currentTexFwd != aForwarder->GetTextureForwarder()) {
gfxCriticalError() << "Attempt to move a texture to a different channel CF.";
return false;
}
@ -947,10 +947,10 @@ TextureClient::InitIPDLActor(CompositableForwarder* aForwarder)
return false;
}
mActor = static_cast<TextureChild*>(aForwarder->CreateTexture(desc,
aForwarder->GetCompositorBackendType(),
GetFlags(),
mSerial));
mActor = static_cast<TextureChild*>(aForwarder->GetTextureForwarder()->CreateTexture(desc,
aForwarder->GetCompositorBackendType(),
GetFlags(),
mSerial));
if (!mActor) {
gfxCriticalError() << static_cast<int32_t>(desc.type()) << ", "
<< static_cast<int32_t>(aForwarder->GetCompositorBackendType()) << ", "
@ -959,7 +959,7 @@ TextureClient::InitIPDLActor(CompositableForwarder* aForwarder)
MOZ_CRASH("GFX: Invalid actor");
}
mActor->mCompositableForwarder = aForwarder;
mActor->mTextureForwarder = aForwarder->AsTextureForwarder();
mActor->mTextureForwarder = aForwarder->GetTextureForwarder();
mActor->mTextureClient = this;
mActor->mMainThreadOnly = !!(mFlags & TextureFlags::DEALLOCATE_MAIN_THREAD);
@ -973,9 +973,10 @@ TextureClient::InitIPDLActor(CompositableForwarder* aForwarder)
}
bool
TextureClient::InitIPDLActor(TextureForwarder* aForwarder)
TextureClient::InitIPDLActor(KnowsCompositor* aForwarder)
{
MOZ_ASSERT(aForwarder && aForwarder->GetMessageLoop() == mAllocator->AsClientAllocator()->GetMessageLoop());
MOZ_ASSERT(aForwarder && aForwarder->GetTextureForwarder()->GetMessageLoop() == mAllocator->GetMessageLoop());
TextureForwarder* fwd = aForwarder->GetTextureForwarder();
if (mActor && !mActor->mDestroyed) {
CompositableForwarder* currentFwd = mActor->mCompositableForwarder;
TextureForwarder* currentTexFwd = mActor->mTextureForwarder;
@ -985,11 +986,11 @@ TextureClient::InitIPDLActor(TextureForwarder* aForwarder)
return false;
}
if (currentTexFwd && currentTexFwd != aForwarder) {
if (currentTexFwd && currentTexFwd != fwd) {
gfxCriticalError() << "Attempt to move a texture to a different channel TF.";
return false;
}
mActor->mTextureForwarder = aForwarder;
mActor->mTextureForwarder = fwd;
return true;
}
MOZ_ASSERT(!mActor || mActor->mDestroyed, "Cannot use a texture on several IPC channels.");
@ -999,12 +1000,12 @@ TextureClient::InitIPDLActor(TextureForwarder* aForwarder)
return false;
}
mActor = static_cast<TextureChild*>(aForwarder->CreateTexture(desc,
aForwarder->GetCompositorBackendType(),
GetFlags(),
mSerial));
mActor = static_cast<TextureChild*>(fwd->CreateTexture(desc,
aForwarder->GetCompositorBackendType(),
GetFlags(),
mSerial));
MOZ_ASSERT(mActor);
mActor->mTextureForwarder = aForwarder;
mActor->mTextureForwarder = fwd;
mActor->mTextureClient = this;
mActor->mMainThreadOnly = !!(mFlags & TextureFlags::DEALLOCATE_MAIN_THREAD);
@ -1039,7 +1040,7 @@ BackendTypeForBackendSelector(LayersBackend aLayersBackend, BackendSelector aSel
// static
already_AddRefed<TextureClient>
TextureClient::CreateForDrawing(CompositableForwarder* aAllocator,
TextureClient::CreateForDrawing(KnowsCompositor* aAllocator,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,
BackendSelector aSelector,
@ -1047,9 +1048,10 @@ TextureClient::CreateForDrawing(CompositableForwarder* aAllocator,
TextureAllocationFlags aAllocFlags)
{
LayersBackend layersBackend = aAllocator->GetCompositorBackendType();
return TextureClient::CreateForDrawing(aAllocator->AsTextureForwarder(),
return TextureClient::CreateForDrawing(aAllocator->GetTextureForwarder(),
aFormat, aSize,
layersBackend,
aAllocator->GetMaxTextureSize(),
aSelector,
aTextureFlags,
aAllocFlags);
@ -1061,18 +1063,11 @@ TextureClient::CreateForDrawing(TextureForwarder* aAllocator,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,
LayersBackend aLayersBackend,
int32_t aMaxTextureSize,
BackendSelector aSelector,
TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags)
{
// What we want here is the "real" TextureForwarder. ShadowLayerForwarder,
// while inheriting TextureForwarder, actually forwards all of its TF methods
// to CompositorBridgeChild. In order to avoid odd situations where some
// textures point to a ShadowLayerForwarder and some point directly to the
// CompositorBridgeChild, we just get the actual TextureForwarder which is
// returned by AsTextureForwarder...
aAllocator = aAllocator->AsTextureForwarder();
gfx::BackendType moz2DBackend = BackendTypeForBackendSelector(aLayersBackend, aSelector);
// also test the validity of aAllocator
@ -1087,26 +1082,22 @@ TextureClient::CreateForDrawing(TextureForwarder* aAllocator,
TextureData* data = nullptr;
#if defined(XP_WIN)
int32_t maxTextureSize = aAllocator->GetMaxTextureSize();
#endif
#ifdef XP_WIN
if (aLayersBackend == LayersBackend::LAYERS_D3D11 &&
(moz2DBackend == gfx::BackendType::DIRECT2D ||
moz2DBackend == gfx::BackendType::DIRECT2D1_1 ||
(!!(aAllocFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT) &&
DeviceManagerDx::Get()->GetContentDevice())) &&
aSize.width <= maxTextureSize &&
aSize.height <= maxTextureSize)
aSize.width <= aMaxTextureSize &&
aSize.height <= aMaxTextureSize)
{
data = DXGITextureData::Create(aSize, aFormat, aAllocFlags);
}
if (aLayersBackend == LayersBackend::LAYERS_D3D9 &&
moz2DBackend == gfx::BackendType::CAIRO &&
aAllocator->IsSameProcess() &&
aSize.width <= maxTextureSize &&
aSize.height <= maxTextureSize &&
aSize.width <= aMaxTextureSize &&
aSize.height <= aMaxTextureSize &&
NS_IsMainThread() &&
DeviceManagerD3D9::GetDevice()) {
data = D3D9TextureData::Create(aSize, aFormat, aAllocFlags);
@ -1170,18 +1161,15 @@ TextureClient::CreateForDrawing(TextureForwarder* aAllocator,
// static
already_AddRefed<TextureClient>
TextureClient::CreateFromSurface(TextureForwarder* aAllocator,
TextureClient::CreateFromSurface(KnowsCompositor* aAllocator,
gfx::SourceSurface* aSurface,
LayersBackend aLayersBackend,
BackendSelector aSelector,
TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags)
{
aAllocator = aAllocator->AsTextureForwarder();
// also test the validity of aAllocator
MOZ_ASSERT(aAllocator && aAllocator->IPCOpen());
if (!aAllocator || !aAllocator->IPCOpen()) {
MOZ_ASSERT(aAllocator && aAllocator->GetTextureForwarder()->IPCOpen());
if (!aAllocator || !aAllocator->GetTextureForwarder()->IPCOpen()) {
return nullptr;
}
@ -1193,11 +1181,12 @@ TextureClient::CreateFromSurface(TextureForwarder* aAllocator,
TextureData* data = nullptr;
#if defined(XP_WIN)
gfx::BackendType moz2DBackend = BackendTypeForBackendSelector(aLayersBackend, aSelector);
LayersBackend layersBackend = aAllocator->GetCompositorBackendType();
gfx::BackendType moz2DBackend = BackendTypeForBackendSelector(layersBackend, aSelector);
int32_t maxTextureSize = aAllocator->GetMaxTextureSize();
if (aLayersBackend == LayersBackend::LAYERS_D3D11 &&
if (layersBackend == LayersBackend::LAYERS_D3D11 &&
(moz2DBackend == gfx::BackendType::DIRECT2D ||
moz2DBackend == gfx::BackendType::DIRECT2D1_1 ||
(!!(aAllocFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT) &&
@ -1210,13 +1199,13 @@ TextureClient::CreateFromSurface(TextureForwarder* aAllocator,
#endif
if (data) {
return MakeAndAddRef<TextureClient>(data, aTextureFlags, aAllocator);
return MakeAndAddRef<TextureClient>(data, aTextureFlags, aAllocator->GetTextureForwarder());
}
// Fall back to using UpdateFromSurface
RefPtr<TextureClient> client = CreateForDrawing(aAllocator, aSurface->GetFormat(), size,
aLayersBackend, aSelector, aTextureFlags, aAllocFlags);
aSelector, aTextureFlags, aAllocFlags);
if (!client) {
return nullptr;
}
@ -1232,22 +1221,22 @@ TextureClient::CreateFromSurface(TextureForwarder* aAllocator,
// static
already_AddRefed<TextureClient>
TextureClient::CreateForRawBufferAccess(ClientIPCAllocator* aAllocator,
TextureClient::CreateForRawBufferAccess(KnowsCompositor* aAllocator,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,
gfx::BackendType aMoz2DBackend,
TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags)
{
auto fwd = aAllocator->AsCompositableForwarder();
auto backend = fwd ? fwd->GetCompositorBackendType() : LayersBackend::LAYERS_NONE;
return CreateForRawBufferAccess(aAllocator, aFormat, aSize, aMoz2DBackend,
backend, aTextureFlags, aAllocFlags);
return CreateForRawBufferAccess(aAllocator->GetTextureForwarder(),
aFormat, aSize, aMoz2DBackend,
aAllocator->GetCompositorBackendType(),
aTextureFlags, aAllocFlags);
}
// static
already_AddRefed<TextureClient>
TextureClient::CreateForRawBufferAccess(ClientIPCAllocator* aAllocator,
TextureClient::CreateForRawBufferAccess(LayersIPCChannel* aAllocator,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,
gfx::BackendType aMoz2DBackend,
@ -1287,15 +1276,15 @@ TextureClient::CreateForRawBufferAccess(ClientIPCAllocator* aAllocator,
// static
already_AddRefed<TextureClient>
TextureClient::CreateForYCbCr(ClientIPCAllocator* aAllocator,
TextureClient::CreateForYCbCr(KnowsCompositor* aAllocator,
gfx::IntSize aYSize,
gfx::IntSize aCbCrSize,
StereoMode aStereoMode,
TextureFlags aTextureFlags)
{
// The only reason we allow aAllocator to be null is for gtests
MOZ_ASSERT(!aAllocator || aAllocator->IPCOpen());
if (aAllocator && !aAllocator->IPCOpen()) {
MOZ_ASSERT(!aAllocator || aAllocator->GetLayersIPCActor()->IPCOpen());
if (aAllocator && !aAllocator->GetLayersIPCActor()->IPCOpen()) {
return nullptr;
}
@ -1309,18 +1298,19 @@ TextureClient::CreateForYCbCr(ClientIPCAllocator* aAllocator,
return nullptr;
}
return MakeAndAddRef<TextureClient>(data, aTextureFlags, aAllocator);
return MakeAndAddRef<TextureClient>(data, aTextureFlags,
aAllocator ? aAllocator->GetTextureForwarder() : nullptr);
}
// static
already_AddRefed<TextureClient>
TextureClient::CreateForYCbCrWithBufferSize(ClientIPCAllocator* aAllocator,
TextureClient::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
size_t aSize,
TextureFlags aTextureFlags)
{
// also test the validity of aAllocator
MOZ_ASSERT(aAllocator && aAllocator->IPCOpen());
if (!aAllocator || !aAllocator->IPCOpen()) {
MOZ_ASSERT(!aAllocator || aAllocator->GetLayersIPCActor()->IPCOpen());
if (aAllocator && !aAllocator->GetLayersIPCActor()->IPCOpen()) {
return nullptr;
}
@ -1331,10 +1321,11 @@ TextureClient::CreateForYCbCrWithBufferSize(ClientIPCAllocator* aAllocator,
return nullptr;
}
return MakeAndAddRef<TextureClient>(data, aTextureFlags, aAllocator);
return MakeAndAddRef<TextureClient>(data, aTextureFlags,
aAllocator ? aAllocator->GetTextureForwarder() : 0);
}
TextureClient::TextureClient(TextureData* aData, TextureFlags aFlags, ClientIPCAllocator* aAllocator)
TextureClient::TextureClient(TextureData* aData, TextureFlags aFlags, LayersIPCChannel* aAllocator)
: AtomicRefCountedWithFinalize("TextureClient")
, mAllocator(aAllocator)
, mActor(nullptr)
@ -1467,7 +1458,7 @@ public:
int32_t readCount;
};
explicit ShmemTextureReadLock(ClientIPCAllocator* aAllocator);
explicit ShmemTextureReadLock(LayersIPCChannel* aAllocator);
~ShmemTextureReadLock();
@ -1485,9 +1476,8 @@ public:
mozilla::layers::ShmemSection& GetShmemSection() { return mShmemSection; }
ShmemTextureReadLock(ISurfaceAllocator* aAllocator, const mozilla::layers::ShmemSection& aShmemSection)
: mAllocator(aAllocator)
, mShmemSection(aShmemSection)
explicit ShmemTextureReadLock(const mozilla::layers::ShmemSection& aShmemSection)
: mShmemSection(aShmemSection)
, mAllocSuccess(true)
{
MOZ_COUNT_CTOR(ShmemTextureReadLock);
@ -1499,7 +1489,7 @@ public:
(mShmemSection.shmem().get<char>() + mShmemSection.offset());
}
RefPtr<ISurfaceAllocator> mAllocator;
RefPtr<LayersIPCChannel> mClientAllocator;
mozilla::layers::ShmemSection mShmemSection;
bool mAllocSuccess;
};
@ -1512,7 +1502,7 @@ TextureReadLock::Deserialize(const ReadLockDescriptor& aDescriptor, ISurfaceAllo
case ReadLockDescriptor::TShmemSection: {
const ShmemSection& section = aDescriptor.get_ShmemSection();
MOZ_RELEASE_ASSERT(section.shmem().IsReadable());
return MakeAndAddRef<ShmemTextureReadLock>(aAllocator, section);
return MakeAndAddRef<ShmemTextureReadLock>(section);
}
case ReadLockDescriptor::Tuintptr_t: {
if (!aAllocator->IsSameProcess()) {
@ -1545,7 +1535,7 @@ TextureReadLock::Deserialize(const ReadLockDescriptor& aDescriptor, ISurfaceAllo
}
// static
already_AddRefed<TextureReadLock>
TextureReadLock::Create(ClientIPCAllocator* aAllocator)
TextureReadLock::Create(LayersIPCChannel* aAllocator)
{
if (aAllocator->IsSameProcess()) {
// If our compositor is in the same process, we can save some cycles by not
@ -1604,15 +1594,14 @@ MemoryTextureReadLock::GetReadCount()
return mReadCount;
}
ShmemTextureReadLock::ShmemTextureReadLock(ClientIPCAllocator* aAllocator)
: mAllocator(aAllocator)
ShmemTextureReadLock::ShmemTextureReadLock(LayersIPCChannel* aAllocator)
: mClientAllocator(aAllocator)
, mAllocSuccess(false)
{
MOZ_COUNT_CTOR(ShmemTextureReadLock);
MOZ_ASSERT(mAllocator);
MOZ_ASSERT(mAllocator->AsTextureForwarder());
MOZ_ASSERT(mClientAllocator);
#define MOZ_ALIGN_WORD(x) (((x) + 3) & ~3)
if (mAllocator->AsTextureForwarder()->GetTileLockAllocator()->AllocShmemSection(
if (mClientAllocator->GetTileLockAllocator()->AllocShmemSection(
MOZ_ALIGN_WORD(sizeof(ShmReadLockInfo)), &mShmemSection)) {
ShmReadLockInfo* info = GetShmReadLockInfoPtr();
info->readCount = 1;
@ -1622,8 +1611,7 @@ ShmemTextureReadLock::ShmemTextureReadLock(ClientIPCAllocator* aAllocator)
ShmemTextureReadLock::~ShmemTextureReadLock()
{
auto fwd = mAllocator->AsTextureForwarder();
if (fwd) {
if (mClientAllocator) {
// Release one read count that is added in constructor.
// The count is kept for calling GetReadCount() by TextureClientPool.
ReadUnlock();
@ -1657,9 +1645,8 @@ ShmemTextureReadLock::ReadUnlock() {
int32_t readCount = PR_ATOMIC_DECREMENT(&info->readCount);
MOZ_ASSERT(readCount >= 0);
if (readCount <= 0) {
auto fwd = mAllocator->AsTextureForwarder();
if (fwd) {
fwd->GetTileLockAllocator()->DeallocShmemSection(mShmemSection);
if (mClientAllocator) {
mClientAllocator->GetTileLockAllocator()->DeallocShmemSection(mShmemSection);
} else {
// we are on the compositor process
FixedSizeSmallShmemSectionAllocator::FreeShmemSection(mShmemSection);
@ -1738,7 +1725,7 @@ SyncObject::CreateSyncObject(SyncHandle aHandle)
}
already_AddRefed<TextureClient>
TextureClient::CreateWithData(TextureData* aData, TextureFlags aFlags, ClientIPCAllocator* aAllocator)
TextureClient::CreateWithData(TextureData* aData, TextureFlags aFlags, LayersIPCChannel* aAllocator)
{
if (!aData) {
return nullptr;

View File

@ -50,8 +50,9 @@ namespace layers {
class AsyncTransactionWaiter;
class BufferTextureData;
class CompositableForwarder;
class KnowsCompositor;
class GrallocTextureData;
class ClientIPCAllocator;
class LayersIPCChannel;
class CompositableClient;
struct PlanarYCbCrData;
class Image;
@ -213,7 +214,7 @@ public:
virtual bool IsValid() const = 0;
static already_AddRefed<TextureReadLock>
Create(ClientIPCAllocator* aAllocator);
Create(LayersIPCChannel* aAllocator);
static already_AddRefed<TextureReadLock>
Deserialize(const ReadLockDescriptor& aDescriptor, ISurfaceAllocator* aAllocator);
@ -269,15 +270,16 @@ public:
virtual bool BorrowMappedYCbCrData(MappedYCbCrTextureData&) { return false; }
virtual void Deallocate(ClientIPCAllocator* aAllocator) = 0;
virtual void Deallocate(LayersIPCChannel* aAllocator) = 0;
/// Depending on the texture's flags either Deallocate or Forget is called.
virtual void Forget(ClientIPCAllocator* aAllocator) {}
virtual void Forget(LayersIPCChannel* aAllocator) {}
virtual bool Serialize(SurfaceDescriptor& aDescriptor) = 0;
virtual TextureData*
CreateSimilar(ClientIPCAllocator* aAllocator,
CreateSimilar(LayersIPCChannel* aAllocator,
LayersBackend aLayersBackend,
TextureFlags aFlags = TextureFlags::DEFAULT,
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const { return nullptr; }
@ -331,26 +333,16 @@ class TextureClient
: public AtomicRefCountedWithFinalize<TextureClient>
{
public:
explicit TextureClient(TextureData* aData, TextureFlags aFlags, ClientIPCAllocator* aAllocator);
explicit TextureClient(TextureData* aData, TextureFlags aFlags, LayersIPCChannel* aAllocator);
virtual ~TextureClient();
static already_AddRefed<TextureClient>
CreateWithData(TextureData* aData, TextureFlags aFlags, ClientIPCAllocator* aAllocator);
CreateWithData(TextureData* aData, TextureFlags aFlags, LayersIPCChannel* aAllocator);
// Creates and allocates a TextureClient usable with Moz2D.
static already_AddRefed<TextureClient>
CreateForDrawing(TextureForwarder* aAllocator,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,
LayersBackend aLayersBackend,
BackendSelector aSelector,
TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT);
// TODO: remove this one and use the one above instead.
static already_AddRefed<TextureClient>
CreateForDrawing(CompositableForwarder* aAllocator,
CreateForDrawing(KnowsCompositor* aAllocator,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,
BackendSelector aSelector,
@ -358,16 +350,15 @@ public:
TextureAllocationFlags flags = ALLOC_DEFAULT);
static already_AddRefed<TextureClient>
CreateFromSurface(TextureForwarder* aAllocator,
CreateFromSurface(KnowsCompositor* aAllocator,
gfx::SourceSurface* aSurface,
LayersBackend aLayersBackend,
BackendSelector aSelector,
TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags);
// Creates and allocates a TextureClient supporting the YCbCr format.
static already_AddRefed<TextureClient>
CreateForYCbCr(ClientIPCAllocator* aAllocator,
CreateForYCbCr(KnowsCompositor* aAllocator,
gfx::IntSize aYSize,
gfx::IntSize aCbCrSize,
StereoMode aStereoMode,
@ -376,17 +367,7 @@ public:
// Creates and allocates a TextureClient (can be accessed through raw
// pointers).
static already_AddRefed<TextureClient>
CreateForRawBufferAccess(ClientIPCAllocator* aAllocator,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,
gfx::BackendType aMoz2dBackend,
LayersBackend aLayersBackend,
TextureFlags aTextureFlags,
TextureAllocationFlags flags = ALLOC_DEFAULT);
// TODO: remove this one and use the one above instead.
static already_AddRefed<TextureClient>
CreateForRawBufferAccess(ClientIPCAllocator* aAllocator,
CreateForRawBufferAccess(KnowsCompositor* aAllocator,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,
gfx::BackendType aMoz2dBackend,
@ -397,13 +378,14 @@ public:
// pointers) with a certain buffer size. It's unfortunate that we need this.
// providing format and sizes could let us do more optimization.
static already_AddRefed<TextureClient>
CreateForYCbCrWithBufferSize(ClientIPCAllocator* aAllocator,
CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
size_t aSize,
TextureFlags aTextureFlags);
// Creates and allocates a TextureClient of the same type.
already_AddRefed<TextureClient>
CreateSimilar(TextureFlags aFlags = TextureFlags::DEFAULT,
CreateSimilar(LayersBackend aLayersBackend = LayersBackend::LAYERS_NONE,
TextureFlags aFlags = TextureFlags::DEFAULT,
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const;
/**
@ -580,7 +562,7 @@ public:
* Should be called only once per TextureClient.
* The TextureClient must not be locked when calling this method.
*/
bool InitIPDLActor(TextureForwarder* aForwarder);
bool InitIPDLActor(KnowsCompositor* aForwarder);
/**
* Return a pointer to the IPDLActor.
@ -650,7 +632,7 @@ public:
void SyncWithObject(SyncObject* aFence) { mData->SyncWithObject(aFence); }
ClientIPCAllocator* GetAllocator() { return mAllocator; }
LayersIPCChannel* GetAllocator() { return mAllocator; }
ITextureClientRecycleAllocator* GetRecycleAllocator() { return mRecycleAllocator; }
void SetRecycleAllocator(ITextureClientRecycleAllocator* aAllocator);
@ -707,6 +689,30 @@ public:
private:
static void TextureClientRecycleCallback(TextureClient* aClient, void* aClosure);
// Internal helpers for creating texture clients using the actual forwarder instead
// of KnowsCompositor. TextureClientPool uses these to let it cache texture clients
// per-process instead of per ShadowLayerForwarder, but everyone else should
// use the public functions instead.
friend class TextureClientPool;
static already_AddRefed<TextureClient>
CreateForDrawing(TextureForwarder* aAllocator,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,
LayersBackend aLayersBackend,
int32_t aMaxTextureSize,
BackendSelector aSelector,
TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT);
static already_AddRefed<TextureClient>
CreateForRawBufferAccess(LayersIPCChannel* aAllocator,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,
gfx::BackendType aMoz2dBackend,
LayersBackend aLayersBackend,
TextureFlags aTextureFlags,
TextureAllocationFlags flags = ALLOC_DEFAULT);
/**
* Called once, during the destruction of the Texture, on the thread in which
@ -735,7 +741,7 @@ protected:
TextureData::Info mInfo;
RefPtr<ClientIPCAllocator> mAllocator;
RefPtr<LayersIPCChannel> mAllocator;
RefPtr<TextureChild> mActor;
RefPtr<ITextureClientRecycleAllocator> mRecycleAllocator;
RefPtr<TextureReadLock> mReadLock;

View File

@ -38,6 +38,7 @@ ClearCallback(nsITimer *aTimer, void *aClosure)
}
TextureClientPool::TextureClientPool(LayersBackend aLayersBackend,
int32_t aMaxTextureSize,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,
TextureFlags aFlags,
@ -47,6 +48,7 @@ TextureClientPool::TextureClientPool(LayersBackend aLayersBackend,
uint32_t aPoolUnusedSize,
TextureForwarder* aAllocator)
: mBackend(aLayersBackend)
, mMaxTextureSize(aMaxTextureSize)
, mFormat(aFormat)
, mSize(aSize)
, mFlags(aFlags)
@ -160,6 +162,7 @@ TextureClientPool::AllocateTextureClient()
TextureClient::CreateForDrawing(mSurfaceAllocator,
mFormat, mSize,
mBackend,
mMaxTextureSize,
BackendSelector::Content,
mFlags);
}

View File

@ -45,6 +45,7 @@ class TextureClientPool final : public TextureClientAllocator
public:
TextureClientPool(LayersBackend aBackend,
int32_t aMaxTextureSize,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,
TextureFlags aFlags,
@ -102,6 +103,7 @@ public:
void Clear();
LayersBackend GetBackend() const { return mBackend; }
int32_t GetMaxTextureSize() const { return mMaxTextureSize; }
gfx::SurfaceFormat GetFormat() { return mFormat; }
TextureFlags GetFlags() const { return mFlags; }
@ -122,6 +124,9 @@ private:
/// Backend passed to the TextureClient for buffer creation.
LayersBackend mBackend;
// Max texture size passed to the TextureClient for buffer creation.
int32_t mMaxTextureSize;
/// Format is passed to the TextureClient for buffer creation.
gfx::SurfaceFormat mFormat;

View File

@ -72,7 +72,7 @@ public:
return true;
}
already_AddRefed<TextureClient> Allocate(TextureForwarder* aAllocator) override
already_AddRefed<TextureClient> Allocate(KnowsCompositor* aAllocator) override
{
return mAllocator->Allocate(mFormat,
mSize,
@ -114,7 +114,7 @@ YCbCrTextureClientAllocationHelper::IsCompatible(TextureClient* aTextureClient)
}
already_AddRefed<TextureClient>
YCbCrTextureClientAllocationHelper::Allocate(TextureForwarder* aAllocator)
YCbCrTextureClientAllocationHelper::Allocate(KnowsCompositor* aAllocator)
{
return TextureClient::CreateForYCbCr(aAllocator,
mData.mYSize, mData.mCbCrSize,
@ -122,7 +122,7 @@ YCbCrTextureClientAllocationHelper::Allocate(TextureForwarder* aAllocator)
mTextureFlags);
}
TextureClientRecycleAllocator::TextureClientRecycleAllocator(TextureForwarder* aAllocator)
TextureClientRecycleAllocator::TextureClientRecycleAllocator(KnowsCompositor* aAllocator)
: mSurfaceAllocator(aAllocator)
, mMaxPooledSize(kMaxPooledSized)
, mLock("TextureClientRecycleAllocatorImp.mLock")
@ -189,7 +189,7 @@ TextureClientRecycleAllocator::CreateOrRecycle(ITextureClientAllocationHelper& a
RefPtr<Runnable> task = new TextureClientReleaseTask(textureHolder->GetTextureClient());
textureHolder->ClearTextureClient();
textureHolder = nullptr;
mSurfaceAllocator->GetMessageLoop()->PostTask(task.forget());
mSurfaceAllocator->GetTextureForwarder()->GetMessageLoop()->PostTask(task.forget());
} else {
textureHolder->GetTextureClient()->RecycleTexture(aHelper.mTextureFlags);
}
@ -227,7 +227,6 @@ TextureClientRecycleAllocator::Allocate(gfx::SurfaceFormat aFormat,
TextureAllocationFlags aAllocFlags)
{
return TextureClient::CreateForDrawing(mSurfaceAllocator, aFormat, aSize,
mSurfaceAllocator->GetCompositorBackendType(),
aSelector, aTextureFlags, aAllocFlags);
}

View File

@ -48,7 +48,7 @@ public:
, mAllocationFlags(aAllocationFlags)
{}
virtual already_AddRefed<TextureClient> Allocate(TextureForwarder* aAllocator) = 0;
virtual already_AddRefed<TextureClient> Allocate(KnowsCompositor* aAllocator) = 0;
virtual bool IsCompatible(TextureClient* aTextureClient) = 0;
const gfx::SurfaceFormat mFormat;
@ -66,7 +66,7 @@ public:
bool IsCompatible(TextureClient* aTextureClient) override;
already_AddRefed<TextureClient> Allocate(TextureForwarder* aAllocator) override;
already_AddRefed<TextureClient> Allocate(KnowsCompositor* aAllocator) override;
protected:
const PlanarYCbCrData& mData;
@ -88,7 +88,7 @@ protected:
virtual ~TextureClientRecycleAllocator();
public:
explicit TextureClientRecycleAllocator(TextureForwarder* aAllocator);
explicit TextureClientRecycleAllocator(KnowsCompositor* aAllocator);
void SetMaxPoolSize(uint32_t aMax);
@ -115,7 +115,7 @@ protected:
TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags);
RefPtr<TextureForwarder> mSurfaceAllocator;
RefPtr<KnowsCompositor> mSurfaceAllocator;
friend class DefaultTextureClientAllocationHelper;
void RecycleTextureClient(TextureClient* aClient) override;

View File

@ -32,7 +32,7 @@ SharedSurfaceTextureData::~SharedSurfaceTextureData()
{}
void
SharedSurfaceTextureData::Deallocate(ClientIPCAllocator*)
SharedSurfaceTextureData::Deallocate(LayersIPCChannel*)
{}
void
@ -55,7 +55,7 @@ SharedSurfaceTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
SharedSurfaceTextureClient::SharedSurfaceTextureClient(SharedSurfaceTextureData* aData,
TextureFlags aFlags,
ClientIPCAllocator* aAllocator)
LayersIPCChannel* aAllocator)
: TextureClient(aData, aFlags, aAllocator)
{
mWorkaroundAnnoyingSharedSurfaceLifetimeIssues = true;
@ -63,7 +63,7 @@ SharedSurfaceTextureClient::SharedSurfaceTextureClient(SharedSurfaceTextureData*
already_AddRefed<SharedSurfaceTextureClient>
SharedSurfaceTextureClient::Create(UniquePtr<gl::SharedSurface> surf, gl::SurfaceFactory* factory,
ClientIPCAllocator* aAllocator, TextureFlags aFlags)
LayersIPCChannel* aAllocator, TextureFlags aFlags)
{
if (!surf) {
return nullptr;

View File

@ -48,7 +48,7 @@ public:
virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
virtual void Deallocate(ClientIPCAllocator*) override;
virtual void Deallocate(LayersIPCChannel*) override;
gl::SharedSurface* Surf() const { return mSurf.get(); }
};
@ -58,13 +58,13 @@ class SharedSurfaceTextureClient : public TextureClient
public:
SharedSurfaceTextureClient(SharedSurfaceTextureData* aData,
TextureFlags aFlags,
ClientIPCAllocator* aAllocator);
LayersIPCChannel* aAllocator);
~SharedSurfaceTextureClient();
static already_AddRefed<SharedSurfaceTextureClient>
Create(UniquePtr<gl::SharedSurface> surf, gl::SurfaceFactory* factory,
ClientIPCAllocator* aAllocator, TextureFlags aFlags);
LayersIPCChannel* aAllocator, TextureFlags aFlags);
virtual void SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle) override;

View File

@ -1057,7 +1057,7 @@ ClientMultiTiledLayerBuffer::ValidateTile(TileClient& aTile,
if (!aTile.mAllocator) {
aTile.SetTextureAllocator(mManager->GetCompositorBridgeChild()->GetTexturePool(
mManager->GetCompositorBackendType(),
mManager->AsShadowForwarder(),
gfxPlatform::GetPlatform()->Optimal2DFormatForContent(content),
TextureFlags::DISALLOW_BIGIMAGE | TextureFlags::IMMEDIATE_UPLOAD));
MOZ_ASSERT(aTile.mAllocator);

View File

@ -457,7 +457,7 @@ D3D11TextureData::Create(SourceSurface* aSurface,
}
void
D3D11TextureData::Deallocate(ClientIPCAllocator* aAllocator)
D3D11TextureData::Deallocate(LayersIPCChannel* aAllocator)
{
mDrawTarget = nullptr;
mTexture = nullptr;
@ -467,7 +467,7 @@ already_AddRefed<TextureClient>
CreateD3D11TextureClientWithDevice(IntSize aSize, SurfaceFormat aFormat,
TextureFlags aTextureFlags, TextureAllocationFlags aAllocFlags,
ID3D11Device* aDevice,
ClientIPCAllocator* aAllocator)
LayersIPCChannel* aAllocator)
{
TextureData* data = D3D11TextureData::Create(aSize, aFormat, aAllocFlags, aDevice);
if (!data) {
@ -477,7 +477,8 @@ CreateD3D11TextureClientWithDevice(IntSize aSize, SurfaceFormat aFormat,
}
TextureData*
D3D11TextureData::CreateSimilar(ClientIPCAllocator* aAllocator,
D3D11TextureData::CreateSimilar(LayersIPCChannel* aAllocator,
LayersBackend aLayersBackend,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags) const
{
@ -491,8 +492,7 @@ D3D11TextureData::GetDXGIResource(IDXGIResource** aOutResource)
}
DXGIYCbCrTextureData*
DXGIYCbCrTextureData::Create(ClientIPCAllocator* aAllocator,
TextureFlags aFlags,
DXGIYCbCrTextureData::Create(TextureFlags aFlags,
IUnknown* aTextureY,
IUnknown* aTextureCb,
IUnknown* aTextureCr,
@ -523,8 +523,7 @@ DXGIYCbCrTextureData::Create(ClientIPCAllocator* aAllocator,
}
DXGIYCbCrTextureData*
DXGIYCbCrTextureData::Create(ClientIPCAllocator* aAllocator,
TextureFlags aFlags,
DXGIYCbCrTextureData::Create(TextureFlags aFlags,
ID3D11Texture2D* aTextureY,
ID3D11Texture2D* aTextureCb,
ID3D11Texture2D* aTextureCr,
@ -568,7 +567,7 @@ DXGIYCbCrTextureData::Create(ClientIPCAllocator* aAllocator,
return nullptr;
}
return DXGIYCbCrTextureData::Create(aAllocator, aFlags,
return DXGIYCbCrTextureData::Create(aFlags,
aTextureY, aTextureCb, aTextureCr,
handleY, handleCb, handleCr,
aSize, aSizeY, aSizeCbCr);
@ -595,7 +594,7 @@ DXGIYCbCrTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
}
void
DXGIYCbCrTextureData::Deallocate(ClientIPCAllocator*)
DXGIYCbCrTextureData::Deallocate(LayersIPCChannel*)
{
mHoldRefs[0] = nullptr;
mHoldRefs[1] = nullptr;

View File

@ -72,7 +72,8 @@ public:
virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
virtual TextureData*
CreateSimilar(ClientIPCAllocator* aAllocator,
CreateSimilar(LayersIPCChannel* aAllocator,
LayersBackend aLayersBackend,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags) const override;
@ -81,7 +82,7 @@ public:
ID3D11Texture2D* GetD3D11Texture() { return mTexture; }
virtual void Deallocate(ClientIPCAllocator* aAllocator) override;
virtual void Deallocate(LayersIPCChannel* aAllocator) override;
D3D11TextureData* AsD3D11TextureData() override {
return this;
@ -109,14 +110,13 @@ already_AddRefed<TextureClient>
CreateD3D11extureClientWithDevice(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
TextureFlags aTextureFlags, TextureAllocationFlags aAllocFlags,
ID3D11Device* aDevice,
ClientIPCAllocator* aAllocator);
LayersIPCChannel* aAllocator);
class DXGIYCbCrTextureData : public TextureData
{
public:
static DXGIYCbCrTextureData*
Create(ClientIPCAllocator* aAllocator,
TextureFlags aFlags,
Create(TextureFlags aFlags,
IUnknown* aTextureY,
IUnknown* aTextureCb,
IUnknown* aTextureCr,
@ -128,8 +128,7 @@ public:
const gfx::IntSize& aSizeCbCr);
static DXGIYCbCrTextureData*
Create(ClientIPCAllocator* aAllocator,
TextureFlags aFlags,
Create(TextureFlags aFlags,
ID3D11Texture2D* aTextureCb,
ID3D11Texture2D* aTextureY,
ID3D11Texture2D* aTextureCr,
@ -147,13 +146,7 @@ public:
virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override { return nullptr; }
// This TextureData should not be used in a context where we use CreateSimilar
// (ex. component alpha) because the underlying texture is always created by
// an external producer.
virtual DXGIYCbCrTextureData*
CreateSimilar(ClientIPCAllocator*, TextureFlags, TextureAllocationFlags) const override { return nullptr; }
virtual void Deallocate(ClientIPCAllocator* aAllocator) override;
virtual void Deallocate(LayersIPCChannel* aAllocator) override;
virtual bool UpdateFromSurface(gfx::SourceSurface*) override { return false; }
@ -273,7 +266,7 @@ already_AddRefed<TextureClient>
CreateD3D11TextureClientWithDevice(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
TextureFlags aTextureFlags, TextureAllocationFlags aAllocFlags,
ID3D11Device* aDevice,
ClientIPCAllocator* aAllocator);
LayersIPCChannel* aAllocator);
/**

View File

@ -593,7 +593,7 @@ D3D9TextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
}
TextureData*
D3D9TextureData::CreateSimilar(ClientIPCAllocator*, TextureFlags aFlags, TextureAllocationFlags aAllocFlags) const
D3D9TextureData::CreateSimilar(LayersIPCChannel*, LayersBackend, TextureFlags aFlags, TextureAllocationFlags aAllocFlags) const
{
return D3D9TextureData::Create(mSize, mFormat, aAllocFlags);
}

View File

@ -189,14 +189,15 @@ public:
virtual bool UpdateFromSurface(gfx::SourceSurface* aSurface) override;
virtual TextureData*
CreateSimilar(ClientIPCAllocator* aAllocator,
CreateSimilar(LayersIPCChannel* aAllocator,
LayersBackend aLayersBackend,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags) const override;
static D3D9TextureData*
Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, TextureAllocationFlags aFlags);
virtual void Deallocate(ClientIPCAllocator* aAllocator) override {}
virtual void Deallocate(LayersIPCChannel* aAllocator) override {}
protected:
D3D9TextureData(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
@ -232,7 +233,7 @@ public:
virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
virtual void Deallocate(ClientIPCAllocator* aAllocator) override {}
virtual void Deallocate(LayersIPCChannel* aAllocator) override {}
IDirect3DDevice9* GetD3D9Device() { return mDevice; }
IDirect3DTexture9* GetD3D9Texture() { return mTexture; }

View File

@ -19,7 +19,6 @@
#include "mozilla/layers/TextureForwarder.h" // for TextureForwarder
#include "nsRegion.h" // for nsIntRegion
#include "mozilla/gfx/Rect.h"
#include "nsExpirationTracker.h"
#include "nsHashKeys.h"
#include "nsTHashtable.h"
@ -34,36 +33,6 @@ class SurfaceDescriptorTiles;
class ThebesBufferData;
class PTextureChild;
/**
* See ActiveResourceTracker below.
*/
class ActiveResource
{
public:
virtual void NotifyInactive() = 0;
nsExpirationState* GetExpirationState() { return &mExpirationState; }
bool IsActivityTracked() { return mExpirationState.IsTracked(); }
private:
nsExpirationState mExpirationState;
};
/**
* A convenience class on top of nsExpirationTracker
*/
class ActiveResourceTracker : public nsExpirationTracker<ActiveResource, 3>
{
public:
ActiveResourceTracker(uint32_t aExpirationCycle, const char* aName)
: nsExpirationTracker(aExpirationCycle, aName)
{}
virtual void NotifyExpired(ActiveResource* aResource) override
{
RemoveObject(aResource);
aResource->NotifyInactive();
}
};
/**
* A transaction is a set of changes that happenned on the content side, that
* should be sent to the compositor side.
@ -73,16 +42,14 @@ public:
* ShadowLayerForwarder is an example of a CompositableForwarder (that can
* additionally forward modifications of the Layer tree).
* ImageBridgeChild is another CompositableForwarder.
*
* CompositableForwarder implements KnowsCompositor for simplicity as all
* implementations of CompositableForwarder currently also implement KnowsCompositor.
* This dependency could be split if we add new use cases.
*/
class CompositableForwarder : public TextureForwarder
class CompositableForwarder : public KnowsCompositor
{
public:
CompositableForwarder()
{
mActiveResourceTracker = MakeUnique<ActiveResourceTracker>(1000, "CompositableForwarder");
}
/**
* Setup the IPDL actor for aCompositable to be part of layers
* transactions.
@ -163,22 +130,15 @@ public:
virtual void UpdateFwdTransactionId() = 0;
virtual uint64_t GetFwdTransactionId() = 0;
virtual CompositableForwarder* AsCompositableForwarder() override { return this; }
virtual bool InForwarderThread() = 0;
void AssertInForwarderThread() {
MOZ_ASSERT(InForwarderThread());
}
ActiveResourceTracker& GetActiveResourceTracker() { return *mActiveResourceTracker.get(); }
protected:
nsTArray<RefPtr<TextureClient> > mTexturesToRemove;
nsTArray<RefPtr<CompositableClient>> mCompositableClientsToRemove;
UniquePtr<ActiveResourceTracker> mActiveResourceTracker;
};
} // namespace layers

View File

@ -52,9 +52,26 @@ using mozilla::gfx::GPUProcessManager;
namespace mozilla {
namespace layers {
static int sShmemCreationCounter = 0;
static void ResetShmemCounter()
{
sShmemCreationCounter = 0;
}
static void ShmemAllocated(CompositorBridgeChild* aProtocol)
{
sShmemCreationCounter++;
if (sShmemCreationCounter > 256) {
aProtocol->SendSyncWithCompositor();
ResetShmemCounter();
MOZ_PERFORMANCE_WARNING("gfx", "The number of shmem allocations is too damn high!");
}
}
static StaticRefPtr<CompositorBridgeChild> sCompositorBridge;
Atomic<int32_t> TextureForwarder::sSerialCounter(0);
Atomic<int32_t> KnowsCompositor::sSerialCounter(0);
CompositorBridgeChild::CompositorBridgeChild(ClientLayerManager *aLayerManager)
: mLayerManager(aLayerManager)
@ -943,12 +960,13 @@ CompositorBridgeChild::CancelWaitForRecycle(uint64_t aTextureId)
}
TextureClientPool*
CompositorBridgeChild::GetTexturePool(LayersBackend aBackend,
CompositorBridgeChild::GetTexturePool(KnowsCompositor* aAllocator,
SurfaceFormat aFormat,
TextureFlags aFlags)
{
for (size_t i = 0; i < mTexturePools.Length(); i++) {
if (mTexturePools[i]->GetBackend() == aBackend &&
if (mTexturePools[i]->GetBackend() == aAllocator->GetCompositorBackendType() &&
mTexturePools[i]->GetMaxTextureSize() == aAllocator->GetMaxTextureSize() &&
mTexturePools[i]->GetFormat() == aFormat &&
mTexturePools[i]->GetFlags() == aFlags) {
return mTexturePools[i];
@ -956,7 +974,9 @@ CompositorBridgeChild::GetTexturePool(LayersBackend aBackend,
}
mTexturePools.AppendElement(
new TextureClientPool(aBackend, aFormat,
new TextureClientPool(aAllocator->GetCompositorBackendType(),
aAllocator->GetMaxTextureSize(),
aFormat,
gfx::gfxVars::TileSize(),
aFlags,
gfxPrefs::LayersTilePoolShrinkTimeout(),
@ -1013,6 +1033,7 @@ CompositorBridgeChild::AllocUnsafeShmem(size_t aSize,
ipc::SharedMemory::SharedMemoryType aType,
ipc::Shmem* aShmem)
{
ShmemAllocated(this);
return PCompositorBridgeChild::AllocUnsafeShmem(aSize, aType, aShmem);
}
@ -1021,6 +1042,7 @@ CompositorBridgeChild::AllocShmem(size_t aSize,
ipc::SharedMemory::SharedMemoryType aType,
ipc::Shmem* aShmem)
{
ShmemAllocated(this);
return PCompositorBridgeChild::AllocShmem(aSize, aType, aShmem);
}
@ -1107,6 +1129,12 @@ CompositorBridgeChild::ProcessingError(Result aCode, const char* aReason)
}
}
void
CompositorBridgeChild::WillEndTransaction()
{
ResetShmemCounter();
}
} // namespace layers
} // namespace mozilla

View File

@ -43,12 +43,13 @@ class TextureClientPool;
struct FrameMetrics;
class CompositorBridgeChild final : public PCompositorBridgeChild,
public TextureForwarder,
public ShmemAllocator
public TextureForwarder
{
typedef InfallibleTArray<AsyncParentMessageData> AsyncParentMessageArray;
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorBridgeChild, override);
explicit CompositorBridgeChild(ClientLayerManager *aLayerManager);
void Destroy();
@ -189,7 +190,7 @@ public:
virtual void CancelWaitForRecycle(uint64_t aTextureId) override;
TextureClientPool* GetTexturePool(LayersBackend aBackend,
TextureClientPool* GetTexturePool(KnowsCompositor* aAllocator,
gfx::SurfaceFormat aFormat,
TextureFlags aFlags);
void ClearTexturePool();
@ -221,10 +222,10 @@ public:
PAPZChild* AllocPAPZChild(const uint64_t& aLayersId) override;
bool DeallocPAPZChild(PAPZChild* aActor) override;
virtual ShmemAllocator* AsShmemAllocator() override { return this; }
void ProcessingError(Result aCode, const char* aReason) override;
void WillEndTransaction();
private:
// Private destructor, to discourage deletion outside of Release():
virtual ~CompositorBridgeChild();

View File

@ -239,6 +239,9 @@ public:
mozilla::ipc::SharedMemory::SharedMemoryType aType,
mozilla::ipc::Shmem* aShmem) override;
virtual void DeallocShmem(mozilla::ipc::Shmem& aShmem) override;
virtual bool RecvSyncWithCompositor() override { return true; }
};
class CompositorBridgeParent final : public CompositorBridgeParentBase

View File

@ -10,6 +10,7 @@
#include "gfxPrefs.h"
#include "mozilla/layers/ImageBridgeParent.h" // for ImageBridgeParent
#include "mozilla/layers/TextureHost.h" // for TextureHost
#include "mozilla/layers/TextureForwarder.h"
namespace mozilla {
namespace layers {
@ -95,10 +96,10 @@ const uint32_t sShmemPageSize = 4096;
const uint32_t sSupportedBlockSize = 4;
#endif
FixedSizeSmallShmemSectionAllocator::FixedSizeSmallShmemSectionAllocator(ClientIPCAllocator* aShmProvider)
FixedSizeSmallShmemSectionAllocator::FixedSizeSmallShmemSectionAllocator(LayersIPCChannel* aShmProvider)
: mShmProvider(aShmProvider)
{
MOZ_ASSERT(mShmProvider && mShmProvider->AsShmemAllocator());
MOZ_ASSERT(mShmProvider);
}
FixedSizeSmallShmemSectionAllocator::~FixedSizeSmallShmemSectionAllocator()
@ -106,6 +107,12 @@ FixedSizeSmallShmemSectionAllocator::~FixedSizeSmallShmemSectionAllocator()
ShrinkShmemSectionHeap();
}
bool
FixedSizeSmallShmemSectionAllocator::IPCOpen() const
{
return mShmProvider->IPCOpen();
}
bool
FixedSizeSmallShmemSectionAllocator::AllocShmemSection(uint32_t aSize, ShmemSection* aShmemSection)
{
@ -132,7 +139,7 @@ FixedSizeSmallShmemSectionAllocator::AllocShmemSection(uint32_t aSize, ShmemSect
if (!aShmemSection->shmem().IsWritable()) {
ipc::Shmem tmp;
if (!GetShmAllocator()->AllocUnsafeShmem(sShmemPageSize, OptimalShmemType(), &tmp)) {
if (!mShmProvider->AllocUnsafeShmem(sShmemPageSize, OptimalShmemType(), &tmp)) {
return false;
}
@ -233,7 +240,7 @@ FixedSizeSmallShmemSectionAllocator::ShrinkShmemSectionHeap()
while (i < mUsedShmems.size()) {
ShmemSectionHeapHeader* header = mUsedShmems[i].get<ShmemSectionHeapHeader>();
if (header->mAllocatedBlocks == 0) {
GetShmAllocator()->DeallocShmem(mUsedShmems[i]);
mShmProvider->DeallocShmem(mUsedShmems[i]);
// We don't particularly care about order, move the last one in the array
// to this position.
if (i < mUsedShmems.size() - 1) {

View File

@ -40,7 +40,6 @@ class DataSourceSurface;
namespace layers {
class CompositableForwarder;
class ShadowLayerForwarder;
class TextureForwarder;
class ShmemAllocator;
@ -48,6 +47,7 @@ class ShmemSectionAllocator;
class LegacySurfaceDescriptorAllocator;
class ClientIPCAllocator;
class HostIPCAllocator;
class LayersIPCChannel;
enum BufferCapabilities {
DEFAULT_BUFFER_CAPS = 0,
@ -91,9 +91,7 @@ public:
virtual CompositableForwarder* AsCompositableForwarder() { return nullptr; }
virtual TextureForwarder* AsTextureForwarder() { return nullptr; }
virtual ShadowLayerForwarder* AsLayerForwarder() { return nullptr; }
virtual TextureForwarder* GetTextureForwarder() { return nullptr; }
virtual ClientIPCAllocator* AsClientAllocator() { return nullptr; }
@ -299,7 +297,7 @@ public:
uint32_t mSize;
};
explicit FixedSizeSmallShmemSectionAllocator(ClientIPCAllocator* aShmProvider);
explicit FixedSizeSmallShmemSectionAllocator(LayersIPCChannel* aShmProvider);
~FixedSizeSmallShmemSectionAllocator();
@ -314,13 +312,11 @@ public:
void ShrinkShmemSectionHeap();
ShmemAllocator* GetShmAllocator() { return mShmProvider->AsShmemAllocator(); }
bool IPCOpen() const { return mShmProvider->IPCOpen(); }
bool IPCOpen() const;
protected:
std::vector<mozilla::ipc::Shmem> mUsedShmems;
ClientIPCAllocator* mShmProvider;
LayersIPCChannel* mShmProvider;
};
} // namespace layers

View File

@ -1227,7 +1227,6 @@ ImageBridgeChild::DispatchAllocShmemInternal(size_t aSize,
void
ImageBridgeChild::ProxyDeallocShmemNow(SynchronousTask* aTask,
ISurfaceAllocator* aAllocator,
ipc::Shmem* aShmem)
{
AutoCompleteTask complete(aTask);
@ -1255,7 +1254,6 @@ ImageBridgeChild::DeallocShmem(ipc::Shmem& aShmem)
RefPtr<ImageBridgeChild>(this),
&ImageBridgeChild::ProxyDeallocShmemNow,
&task,
this,
&aShmem);
GetMessageLoop()->PostTask(runnable.forget());

View File

@ -109,14 +109,16 @@ bool InImageBridgeChildThread();
*/
class ImageBridgeChild final : public PImageBridgeChild
, public CompositableForwarder
, public ShmemAllocator
, public TextureForwarder
{
friend class ImageContainer;
typedef InfallibleTArray<AsyncParentMessageData> AsyncParentMessageArray;
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ImageBridgeChild, override);
virtual ShmemAllocator* AsShmemAllocator() override { return this; }
TextureForwarder* GetTextureForwarder() override { return this; }
LayersIPCActor* GetLayersIPCActor() override { return this; }
/**
* Creates the image bridge with a dedicated thread for ImageBridgeChild.
@ -172,12 +174,6 @@ public:
PImageContainerChild* aChild, uint64_t* aID) override;
bool DeallocPCompositableChild(PCompositableChild* aActor) override;
/**
* This must be called by the static function DeleteImageBridgeSync defined
* in ImageBridgeChild.cpp ONLY.
*/
~ImageBridgeChild();
virtual PTextureChild*
AllocPTextureChild(const SurfaceDescriptor& aSharedData, const LayersBackend& aLayersBackend, const TextureFlags& aFlags, const uint64_t& aSerial) override;
@ -225,6 +221,13 @@ public:
void FlushAllImages(ImageClient* aClient, ImageContainer* aContainer);
private:
/**
* This must be called by the static function DeleteImageBridgeSync defined
* in ImageBridgeChild.cpp ONLY.
*/
~ImageBridgeChild();
// Helpers for dispatching.
already_AddRefed<CanvasClient> CreateCanvasClientNow(
CanvasClient::CanvasClientType aType,
@ -256,10 +259,7 @@ private:
RefPtr<AsyncTransactionWaiter> aWaiter);
void ProxyAllocShmemNow(SynchronousTask* aTask, AllocShmemParams* aParams);
void ProxyDeallocShmemNow(
SynchronousTask* aTask,
ISurfaceAllocator* aAllocator,
Shmem* aShmem);
void ProxyDeallocShmemNow(SynchronousTask* aTask, Shmem* aShmem);
public:
// CompositableForwarder

View File

@ -108,8 +108,6 @@ public:
}
protected:
virtual bool RecvSyncWithCompositor() override { return true; }
virtual bool RecvShutdown() override;
virtual bool RecvPaintTime(const uint64_t& aTransactionId,

View File

@ -220,6 +220,8 @@ parent:
async PTexture(SurfaceDescriptor aSharedData, LayersBackend aBackend, TextureFlags aTextureFlags, uint64_t id, uint64_t aSerial);
sync SyncWithCompositor();
child:
// Send back Compositor Frame Metrics from APZCs so tiled layers can
// update progressively.

View File

@ -125,8 +125,6 @@ parent:
async SetConfirmedTargetAPZC(uint64_t aInputBlockId, ScrollableLayerGuid[] aTargets);
async Shutdown();
sync SyncWithCompositor();
child:
async __delete__();
};

View File

@ -46,23 +46,6 @@ class Shmem;
namespace layers {
static int sShmemCreationCounter = 0;
static void ResetShmemCounter()
{
sShmemCreationCounter = 0;
}
static void ShmemAllocated(LayerTransactionChild* aProtocol)
{
sShmemCreationCounter++;
if (sShmemCreationCounter > 256) {
aProtocol->SendSyncWithCompositor();
ResetShmemCounter();
MOZ_PERFORMANCE_WARNING("gfx", "The number of shmem allocations is too damn high!");
}
}
using namespace mozilla::gfx;
using namespace mozilla::gl;
using namespace mozilla::ipc;
@ -184,7 +167,7 @@ struct AutoTxnEnd {
};
void
TextureForwarder::IdentifyTextureHost(const TextureFactoryIdentifier& aIdentifier)
KnowsCompositor::IdentifyTextureHost(const TextureFactoryIdentifier& aIdentifier)
{
mTextureFactoryIdentifier = aIdentifier;
@ -547,7 +530,7 @@ ShadowLayerForwarder::RemoveTextureFromCompositableAsync(AsyncTransactionTracker
bool
ShadowLayerForwarder::InWorkerThread()
{
return MessageLoop::current() && (GetMessageLoop()->id() == MessageLoop::current()->id());
return MessageLoop::current() && (GetTextureForwarder()->GetMessageLoop()->id() == MessageLoop::current()->id());
}
void
@ -587,7 +570,7 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies,
{
*aSent = false;
ResetShmemCounter();
GetCompositorBridgeChild()->WillEndTransaction();
MOZ_ASSERT(aId);
@ -727,7 +710,7 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies,
mTxn->mTargetOrientation,
aRegionToClear);
if (!IsSameProcess()) {
if (!GetTextureForwarder()->IsSameProcess()) {
MOZ_LAYERS_LOG(("[LayersForwarder] syncing before send..."));
PlatformSyncBeforeUpdate();
}
@ -781,68 +764,12 @@ ShadowLayerForwarder::SetLayerObserverEpoch(uint64_t aLayerObserverEpoch)
Unused << mShadowManager->SendSetLayerObserverEpoch(aLayerObserverEpoch);
}
bool
ShadowLayerForwarder::AllocUnsafeShmem(size_t aSize,
ipc::SharedMemory::SharedMemoryType aShmType,
ipc::Shmem* aShmem)
{
MOZ_ASSERT(HasShadowManager(), "no shadow manager");
if (!IPCOpen()) {
return false;
}
ShmemAllocated(mShadowManager);
return GetCompositorBridgeChild()->AllocUnsafeShmem(aSize, aShmType, aShmem);
}
bool
ShadowLayerForwarder::AllocShmem(size_t aSize,
ipc::SharedMemory::SharedMemoryType aShmType,
ipc::Shmem* aShmem)
{
MOZ_ASSERT(HasShadowManager(), "no shadow manager");
if (!IPCOpen()) {
return false;
}
ShmemAllocated(mShadowManager);
return GetCompositorBridgeChild()->AllocShmem(aSize, aShmType, aShmem);
}
void
ShadowLayerForwarder::DeallocShmem(ipc::Shmem& aShmem)
{
MOZ_ASSERT(HasShadowManager(), "no shadow manager");
if (HasShadowManager() && mShadowManager->IPCOpen()) {
GetCompositorBridgeChild()->DeallocShmem(aShmem);
}
}
bool
ShadowLayerForwarder::IPCOpen() const
{
return HasShadowManager() && mShadowManager->IPCOpen();
}
bool
ShadowLayerForwarder::IsSameProcess() const
{
if (!HasShadowManager() || !mShadowManager->IPCOpen()) {
return false;
}
return mShadowManager->OtherPid() == base::GetCurrentProcId();
}
base::ProcessId
ShadowLayerForwarder::GetParentPid() const
{
if (!HasShadowManager() || !mShadowManager->IPCOpen()) {
return base::ProcessId();
}
return mShadowManager->OtherPid();
}
/**
* We bail out when we have no shadow manager. That can happen when the
* layer manager is created by the preallocated process.
@ -905,22 +832,6 @@ void ShadowLayerForwarder::AttachAsyncCompositable(uint64_t aCompositableID,
aCompositableID));
}
PTextureChild*
ShadowLayerForwarder::CreateTexture(const SurfaceDescriptor& aSharedData,
LayersBackend aLayersBackend,
TextureFlags aFlags,
uint64_t aSerial)
{
if (!HasShadowManager() ||
!mShadowManager->IPCOpen() ||
!mShadowManager->Manager()) {
gfxCriticalNote << "ShadowLayerForwarder::CreateTexture fails with HSM:" << HasShadowManager() << ", IPCOpen:" << mShadowManager->IPCOpen() << ", Destroyed:" << mShadowManager->IsDestroyed() << ", M:" << !!mShadowManager->Manager();
return nullptr;
}
return mShadowManager->Manager()->SendPTextureConstructor(aSharedData, aLayersBackend, aFlags, mShadowManager->GetId(), aSerial);
}
void ShadowLayerForwarder::SetShadowManager(PLayerTransactionChild* aShadowManager)
{
mShadowManager = static_cast<LayerTransactionChild*>(aShadowManager);
@ -1024,7 +935,7 @@ ShadowLayerForwarder::AllocSurfaceDescriptorWithCaps(const gfx::IntSize& aSize,
}
MemoryOrShmem bufferDesc;
if (IsSameProcess()) {
if (GetTextureForwarder()->IsSameProcess()) {
uint8_t* data = new (std::nothrow) uint8_t[size];
if (!data) {
return false;
@ -1035,7 +946,7 @@ ShadowLayerForwarder::AllocSurfaceDescriptorWithCaps(const gfx::IntSize& aSize,
} else {
mozilla::ipc::Shmem shmem;
if (!AllocUnsafeShmem(size, OptimalShmemType(), &shmem)) {
if (!GetTextureForwarder()->AllocUnsafeShmem(size, OptimalShmemType(), &shmem)) {
return false;
}
@ -1070,7 +981,7 @@ ShadowLayerForwarder::DestroySurfaceDescriptor(SurfaceDescriptor* aSurface)
SurfaceDescriptorBuffer& desc = aSurface->get_SurfaceDescriptorBuffer();
switch (desc.data().type()) {
case MemoryOrShmem::TShmem: {
DeallocShmem(desc.data().get_Shmem());
GetTextureForwarder()->DeallocShmem(desc.data().get_Shmem());
break;
}
case MemoryOrShmem::Tuintptr_t: {
@ -1102,15 +1013,6 @@ ShadowLayerForwarder::GetFwdTransactionId()
return compositorBridge ? compositorBridge->GetFwdTransactionId() : 0;
}
void
ShadowLayerForwarder::CancelWaitForRecycle(uint64_t aTextureId)
{
auto compositorBridge = GetCompositorBridgeChild();
if (compositorBridge) {
compositorBridge->CancelWaitForRecycle(aTextureId);
}
}
CompositorBridgeChild*
ShadowLayerForwarder::GetCompositorBridgeChild()
{
@ -1124,11 +1026,5 @@ ShadowLayerForwarder::GetCompositorBridgeChild()
return mCompositorBridgeChild;
}
TextureForwarder*
ShadowLayerForwarder::AsTextureForwarder()
{
return GetCompositorBridgeChild();
}
} // namespace layers
} // namespace mozilla

View File

@ -17,7 +17,9 @@
#include "mozilla/dom/ScreenOrientation.h" // for ScreenOrientation
#include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc
#include "mozilla/layers/CompositableForwarder.h"
#include "mozilla/layers/TextureForwarder.h"
#include "mozilla/layers/CompositorTypes.h" // for OpenMode, etc
#include "mozilla/layers/CompositorBridgeChild.h"
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsRegion.h" // for nsIntRegion
#include "nsTArrayForwardDeclare.h" // for InfallibleTArray
@ -116,39 +118,21 @@ class Transaction;
* from the content thread. (See CompositableForwarder.h and ImageBridgeChild.h)
*/
class ShadowLayerForwarder final : public CompositableForwarder
, public ShmemAllocator
class ShadowLayerForwarder final : public LayersIPCActor
, public CompositableForwarder
, public LegacySurfaceDescriptorAllocator
{
friend class ClientLayerManager;
public:
virtual ~ShadowLayerForwarder();
virtual ShmemAllocator* AsShmemAllocator() override { return this; }
virtual ShadowLayerForwarder* AsLayerForwarder() override { return this; }
// TODO: confusingly, this returns a pointer to the CompositorBridgeChild.
// Right now ShadowLayerForwarder inherits TextureForwarder but it would
// probably be best if it didn't, since it forwards all of the relevent
// methods to CompositorBridgeChild.
virtual TextureForwarder* AsTextureForwarder() override;
virtual LegacySurfaceDescriptorAllocator*
AsLegacySurfaceDescriptorAllocator() override { return this; }
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ShadowLayerForwarder, override);
/**
* Setup the IPDL actor for aCompositable to be part of layers
* transactions.
*/
virtual void Connect(CompositableClient* aCompositable,
ImageContainer* aImageContainer) override;
virtual PTextureChild* CreateTexture(const SurfaceDescriptor& aSharedData,
LayersBackend aLayersBackend,
TextureFlags aFlags,
uint64_t aSerial) override;
void Connect(CompositableClient* aCompositable,
ImageContainer* aImageContainer) override;
/**
* Adds an edit in the layers transaction in order to attach
@ -230,11 +214,11 @@ public:
/**
* See CompositableForwarder::UseTiledLayerBuffer
*/
virtual void UseTiledLayerBuffer(CompositableClient* aCompositable,
void UseTiledLayerBuffer(CompositableClient* aCompositable,
const SurfaceDescriptorTiles& aTileLayerDescriptor) override;
virtual bool DestroyInTransaction(PTextureChild* aTexture, bool synchronously) override;
virtual bool DestroyInTransaction(PCompositableChild* aCompositable, bool synchronously) override;
bool DestroyInTransaction(PTextureChild* aTexture, bool synchronously) override;
bool DestroyInTransaction(PCompositableChild* aCompositable, bool synchronously) override;
virtual void RemoveTextureFromCompositable(CompositableClient* aCompositable,
TextureClient* aTexture) override;
@ -344,25 +328,8 @@ public:
* buffer, and the double-buffer pair is gone.
*/
virtual bool AllocUnsafeShmem(size_t aSize,
mozilla::ipc::SharedMemory::SharedMemoryType aType,
mozilla::ipc::Shmem* aShmem) override;
virtual bool AllocShmem(size_t aSize,
mozilla::ipc::SharedMemory::SharedMemoryType aType,
mozilla::ipc::Shmem* aShmem) override;
virtual void DeallocShmem(mozilla::ipc::Shmem& aShmem) override;
virtual bool IPCOpen() const override;
virtual bool IsSameProcess() const override;
virtual MessageLoop* GetMessageLoop() const override { return mMessageLoop; }
virtual void CancelWaitForRecycle(uint64_t aTextureId) override;
virtual base::ProcessId GetParentPid() const override;
/**
* Construct a shadow of |aLayer| on the "other side", at the
* LayerManagerComposite.
@ -401,7 +368,12 @@ public:
// Returns true if aSurface wraps a Shmem.
static bool IsShmem(SurfaceDescriptor* aSurface);
TextureForwarder* GetTextureForwarder() override { return GetCompositorBridgeChild(); }
LayersIPCActor* GetLayersIPCActor() override { return this; }
protected:
virtual ~ShadowLayerForwarder();
explicit ShadowLayerForwarder(ClientLayerManager* aClientLayerManager);
#ifdef DEBUG

View File

@ -57,7 +57,7 @@ SharedPlanarYCbCrImage::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
}
TextureClient*
SharedPlanarYCbCrImage::GetTextureClient(TextureForwarder* aForwarder)
SharedPlanarYCbCrImage::GetTextureClient(KnowsCompositor* aForwarder)
{
return mTextureClient.get();
}
@ -157,10 +157,9 @@ SharedPlanarYCbCrImage::AdoptData(const Data &aData)
uint32_t cbOffset = aData.mCbChannel - base;
uint32_t crOffset = aData.mCrChannel - base;
auto fwd = mCompositable->GetForwarder()->AsCompositableForwarder();
bool hasIntermediateBuffer = fwd ? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV,
fwd->GetCompositorBackendType())
: true;
auto fwd = mCompositable->GetForwarder();
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV,
fwd->GetCompositorBackendType());
static_cast<BufferTextureData*>(mTextureClient->GetInternalData())->SetDesciptor(
YCbCrDescriptor(aData.mYSize, aData.mCbCrSize, yOffset, cbOffset, crOffset,

View File

@ -30,7 +30,7 @@ protected:
~SharedPlanarYCbCrImage();
public:
virtual TextureClient* GetTextureClient(TextureForwarder* aForwarder) override;
virtual TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override;
virtual uint8_t* GetBuffer() override;
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;

View File

@ -98,7 +98,7 @@ SharedRGBImage::GetSize()
}
TextureClient*
SharedRGBImage::GetTextureClient(TextureForwarder* aForwarder)
SharedRGBImage::GetTextureClient(KnowsCompositor* aForwarder)
{
return mTextureClient.get();
}

View File

@ -38,7 +38,7 @@ protected:
~SharedRGBImage();
public:
virtual TextureClient* GetTextureClient(TextureForwarder* aForwarder) override;
virtual TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override;
virtual uint8_t* GetBuffer() override;

View File

@ -15,17 +15,85 @@
#include "mozilla/layers/TextureClient.h" // for TextureClient
#include "nsRegion.h" // for nsIntRegion
#include "mozilla/gfx/Rect.h"
#include "nsExpirationTracker.h"
namespace mozilla {
namespace layers {
class TextureForwarder : public ClientIPCAllocator
/**
* See ActiveResourceTracker below.
*/
class ActiveResource
{
public:
TextureForwarder()
: mSerial(++sSerialCounter)
virtual void NotifyInactive() = 0;
nsExpirationState* GetExpirationState() { return &mExpirationState; }
bool IsActivityTracked() { return mExpirationState.IsTracked(); }
private:
nsExpirationState mExpirationState;
};
/**
* A convenience class on top of nsExpirationTracker
*/
class ActiveResourceTracker : public nsExpirationTracker<ActiveResource, 3>
{
public:
ActiveResourceTracker(uint32_t aExpirationCycle, const char* aName)
: nsExpirationTracker(aExpirationCycle, aName)
{}
virtual void NotifyExpired(ActiveResource* aResource) override
{
RemoveObject(aResource);
aResource->NotifyInactive();
}
};
/**
* An abstract interface for classes that implement the autogenerated
* IPDL actor class. Lets us check if they are still valid for IPC.
*/
class LayersIPCActor {
public:
virtual bool IPCOpen() const { return true; }
};
/**
* An abstract interface for LayersIPCActors that implement a top-level
* IPDL protocol so also have their own channel.
* Has their own MessageLoop for message dispatch, and can allocate
* shmem.
*/
class LayersIPCChannel : public LayersIPCActor
, public ShmemAllocator {
public:
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
virtual bool IsSameProcess() const = 0;
virtual bool UsesImageBridge() const { return false; }
virtual base::ProcessId GetParentPid() const = 0;
virtual MessageLoop* GetMessageLoop() const = 0;
virtual FixedSizeSmallShmemSectionAllocator* GetTileLockAllocator() { return nullptr; }
virtual void CancelWaitForRecycle(uint64_t aTextureId) = 0;
protected:
virtual ~LayersIPCChannel() {}
};
/**
* An abstract interface for classes that can allocate PTexture objects
* across IPDL. Currently a sub-class of LayersIPCChannel for simplicity
* since all our implementations use both, but could be independant if needed.
*/
class TextureForwarder : public LayersIPCChannel {
public:
/**
* Create a TextureChild/Parent pair as as well as the TextureHost on the parent side.
*/
@ -34,16 +102,28 @@ public:
LayersBackend aLayersBackend,
TextureFlags aFlags,
uint64_t aSerial) = 0;
};
virtual TextureForwarder* AsTextureForwarder() override { return this; }
/**
* An abstract interface for classes that are tied to a specific Compositor across
* IPDL and uses TextureFactoryIdentifier to describe this Compositor.
*/
class KnowsCompositor {
public:
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
virtual FixedSizeSmallShmemSectionAllocator* GetTileLockAllocator() { return nullptr; }
int32_t GetSerial() { return mSerial; }
KnowsCompositor()
: mSerial(++sSerialCounter)
{
mActiveResourceTracker = MakeUnique<ActiveResourceTracker>(1000, "CompositableForwarder");
}
void IdentifyTextureHost(const TextureFactoryIdentifier& aIdentifier);
virtual int32_t GetMaxTextureSize() const override
SyncObject* GetSyncObject() { return mSyncObject; }
int32_t GetMaxTextureSize() const
{
return mTextureFactoryIdentifier.mMaxTextureSize;
}
@ -73,12 +153,23 @@ public:
return mTextureFactoryIdentifier;
}
SyncObject* GetSyncObject() { return mSyncObject; }
int32_t GetSerial() { return mSerial; }
ActiveResourceTracker& GetActiveResourceTracker() { return *mActiveResourceTracker.get(); }
/**
* Helpers for finding other related interface. These are infallible.
*/
virtual TextureForwarder* GetTextureForwarder() = 0;
virtual LayersIPCActor* GetLayersIPCActor() = 0;
protected:
TextureFactoryIdentifier mTextureFactoryIdentifier;
RefPtr<SyncObject> mSyncObject;
UniquePtr<ActiveResourceTracker> mActiveResourceTracker;
const int32_t mSerial;
static mozilla::Atomic<int32_t> sSerialCounter;
};

View File

@ -15,10 +15,13 @@ namespace layers {
class VideoBridgeChild final : public PVideoBridgeChild
, public TextureForwarder
, public ShmemAllocator
, public KnowsCompositor
{
public:
~VideoBridgeChild();
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoBridgeChild, override);
TextureForwarder* GetTextureForwarder() override { return this; }
LayersIPCActor* GetLayersIPCActor() override { return this; }
static void Startup();
static void Shutdown();
@ -53,13 +56,13 @@ public:
void CancelWaitForRecycle(uint64_t aTextureId) override { MOZ_ASSERT(false, "NO RECYCLING HERE"); }
// ISurfaceAllocator
ShmemAllocator* AsShmemAllocator() override { return this; }
bool IsSameProcess() const override;
bool CanSend() { return true; }
private:
VideoBridgeChild();
~VideoBridgeChild();
MessageLoop* mMessageLoop;
};

View File

@ -110,7 +110,7 @@ GrallocTextureData::~GrallocTextureData()
}
void
GrallocTextureData::Deallocate(ClientIPCAllocator* aAllocator)
GrallocTextureData::Deallocate(LayersIPCChannel* aAllocator)
{
MOZ_ASSERT(aAllocator);
if (aAllocator && aAllocator->IPCOpen()) {
@ -122,7 +122,7 @@ GrallocTextureData::Deallocate(ClientIPCAllocator* aAllocator)
}
void
GrallocTextureData::Forget(ClientIPCAllocator* aAllocator)
GrallocTextureData::Forget(LayersIPCChannel* aAllocator)
{
MOZ_ASSERT(aAllocator);
if (aAllocator && aAllocator->IPCOpen()) {
@ -290,7 +290,7 @@ GrallocTextureData::UpdateFromSurface(gfx::SourceSurface* aSurface)
GrallocTextureData*
GrallocTextureData::Create(gfx::IntSize aSize, AndroidFormat aAndroidFormat,
gfx::BackendType aMoz2dBackend, uint32_t aUsage,
ClientIPCAllocator* aAllocator)
LayersIPCChannel* aAllocator)
{
if (!aAllocator || !aAllocator->IPCOpen()) {
return nullptr;
@ -345,7 +345,7 @@ GrallocTextureData::Create(gfx::IntSize aSize, AndroidFormat aAndroidFormat,
GrallocTextureData*
GrallocTextureData::CreateForDrawing(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
gfx::BackendType aMoz2dBackend,
ClientIPCAllocator* aAllocator)
LayersIPCChannel* aAllocator)
{
if (DisableGralloc(aFormat, aSize)) {
return nullptr;
@ -397,7 +397,7 @@ GrallocTextureData::GetTextureFlags() const
// static
GrallocTextureData*
GrallocTextureData::CreateForYCbCr(gfx::IntSize aYSize, gfx::IntSize aCbCrSize,
ClientIPCAllocator* aAllocator)
LayersIPCChannel* aAllocator)
{
MOZ_ASSERT(aYSize.width == aCbCrSize.width * 2);
MOZ_ASSERT(aYSize.height == aCbCrSize.height * 2);
@ -410,7 +410,7 @@ GrallocTextureData::CreateForYCbCr(gfx::IntSize aYSize, gfx::IntSize aCbCrSize,
// static
GrallocTextureData*
GrallocTextureData::CreateForGLRendering(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
ClientIPCAllocator* aAllocator)
LayersIPCChannel* aAllocator)
{
if (aFormat == gfx::SurfaceFormat::YUV) {
return nullptr;
@ -446,7 +446,7 @@ GrallocTextureData::TextureClientFromSharedSurface(gl::SharedSurface* abstractSu
}
TextureData*
GrallocTextureData::CreateSimilar(ClientIPCAllocator* aAllocator,
GrallocTextureData::CreateSimilar(LayersIPCChannel* aAllocator,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags) const
{

View File

@ -51,30 +51,30 @@ public:
virtual bool BorrowMappedData(MappedTextureData& aMap) override;
virtual void Deallocate(ClientIPCAllocator*) override;
virtual void Deallocate(LayersIPCChannel*) override;
virtual void Forget(ClientIPCAllocator*) override;
virtual void Forget(LayersIPCChannel*) override;
static GrallocTextureData* CreateForDrawing(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
gfx::BackendType aMoz2dBackend,
ClientIPCAllocator* aAllocator);
LayersIPCChannel* aAllocator);
static GrallocTextureData* CreateForYCbCr(gfx::IntSize aYSize, gfx::IntSize aCbCrSize,
ClientIPCAllocator* aAllocator);
LayersIPCChannel* aAllocator);
static GrallocTextureData* CreateForGLRendering(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
ClientIPCAllocator* aAllocator);
LayersIPCChannel* aAllocator);
static GrallocTextureData* Create(gfx::IntSize aSize, AndroidFormat aFormat,
gfx::BackendType aMoz2DBackend, uint32_t aUsage,
ClientIPCAllocator* aAllocator);
LayersIPCChannel* aAllocator);
static already_AddRefed<TextureClient>
TextureClientFromSharedSurface(gl::SharedSurface* abstractSurf, TextureFlags flags);
virtual TextureData*
CreateSimilar(ClientIPCAllocator* aAllocator,
CreateSimilar(LayersIPCChannel* aAllocator,
TextureFlags aFlags = TextureFlags::DEFAULT,
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const override;

View File

@ -113,13 +113,13 @@ MacIOSurfaceTextureData::BorrowDrawTarget()
}
void
MacIOSurfaceTextureData::Deallocate(ClientIPCAllocator*)
MacIOSurfaceTextureData::Deallocate(LayersIPCChannel*)
{
mSurface = nullptr;
}
void
MacIOSurfaceTextureData::Forget(ClientIPCAllocator*)
MacIOSurfaceTextureData::Forget(LayersIPCChannel*)
{
mSurface = nullptr;
}

View File

@ -35,9 +35,9 @@ public:
virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
virtual void Deallocate(ClientIPCAllocator*) override;
virtual void Deallocate(LayersIPCChannel*) override;
virtual void Forget(ClientIPCAllocator*) override;
virtual void Forget(LayersIPCChannel*) override;
virtual bool UpdateFromSurface(gfx::SourceSurface* aSurface) override;

View File

@ -29,7 +29,7 @@ EGLImageTextureData::EGLImageTextureData(EGLImageImage* aImage, gfx::IntSize aSi
already_AddRefed<TextureClient>
EGLImageTextureData::CreateTextureClient(EGLImageImage* aImage, gfx::IntSize aSize,
ClientIPCAllocator* aAllocator, TextureFlags aFlags)
LayersIPCChannel* aAllocator, TextureFlags aFlags)
{
MOZ_ASSERT(XRE_IsParentProcess(),
"Can't pass an `EGLImage` between processes.");
@ -82,7 +82,7 @@ already_AddRefed<TextureClient>
AndroidSurfaceTextureData::CreateTextureClient(AndroidSurfaceTexture* aSurfTex,
gfx::IntSize aSize,
gl::OriginPos aOriginPos,
ClientIPCAllocator* aAllocator,
LayersIPCChannel* aAllocator,
TextureFlags aFlags)
{
MOZ_ASSERT(XRE_IsParentProcess(),

View File

@ -26,15 +26,15 @@ public:
static already_AddRefed<TextureClient>
CreateTextureClient(EGLImageImage* aImage, gfx::IntSize aSize,
ClientIPCAllocator* aAllocator, TextureFlags aFlags);
LayersIPCChannel* aAllocator, TextureFlags aFlags);
virtual void FillInfo(TextureData::Info& aInfo) const override;
virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
virtual void Deallocate(ClientIPCAllocator*) override { mImage = nullptr; }
virtual void Deallocate(LayersIPCChannel*) override { mImage = nullptr; }
virtual void Forget(ClientIPCAllocator*) override { mImage = nullptr; }
virtual void Forget(LayersIPCChannel*) override { mImage = nullptr; }
// Unused functions.
virtual bool Lock(OpenMode, FenceHandle*) override { return true; }
@ -57,7 +57,7 @@ public:
CreateTextureClient(gl::AndroidSurfaceTexture* aSurfTex,
gfx::IntSize aSize,
gl::OriginPos aOriginPos,
ClientIPCAllocator* aAllocator,
LayersIPCChannel* aAllocator,
TextureFlags aFlags);
~AndroidSurfaceTextureData();
@ -72,7 +72,7 @@ public:
virtual void Unlock() override {}
// Our data is always owned externally.
virtual void Deallocate(ClientIPCAllocator*) override {}
virtual void Deallocate(LayersIPCChannel*) override {}
protected:
AndroidSurfaceTextureData(gl::AndroidSurfaceTexture* aSurfTex, gfx::IntSize aSize);

View File

@ -31,9 +31,14 @@ class VRDisplayClient;
class VRManagerChild : public PVRManagerChild
, public layers::TextureForwarder
, public layers::ShmemAllocator
, public layers::KnowsCompositor
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRManagerChild, override);
TextureForwarder* GetTextureForwarder() override { return this; }
LayersIPCActor* GetLayersIPCActor() override { return this; }
static VRManagerChild* Get();
// Indicate that an observer wants to receive VR events.
@ -111,8 +116,6 @@ protected:
// ShmemAllocator
virtual ShmemAllocator* AsShmemAllocator() override { return this; }
virtual bool AllocShmem(size_t aSize,
ipc::SharedMemory::SharedMemoryType aType,
ipc::Shmem* aShmem) override;

View File

@ -1356,7 +1356,7 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
}
lf->SetShadowManager(shadowManager);
lf->IdentifyTextureHost(textureFactoryIdentifier);
lm->UpdateTextureFactoryIdentifier(textureFactoryIdentifier);
ImageBridgeChild::IdentifyCompositorTextureHost(textureFactoryIdentifier);
gfx::VRManagerChild::IdentifyTextureHost(textureFactoryIdentifier);
WindowUsesOMTC();