зеркало из https://github.com/mozilla/gecko-dev.git
Remove the static compositor backend variable. (bug 1211109 part 2, r=mattwoodrow)
This commit is contained in:
Родитель
f35bf0138b
Коммит
3716363c72
|
@ -18,31 +18,6 @@ class Matrix4x4;
|
|||
|
||||
namespace layers {
|
||||
|
||||
/* static */ LayersBackend Compositor::sBackend = LayersBackend::LAYERS_NONE;
|
||||
/* static */ LayersBackend
|
||||
Compositor::GetBackend()
|
||||
{
|
||||
if (sBackend != LayersBackend::LAYERS_NONE) {
|
||||
AssertOnCompositorThread();
|
||||
}
|
||||
return sBackend;
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
Compositor::SetBackend(LayersBackend backend)
|
||||
{
|
||||
if (!gIsGtest && sBackend != backend &&
|
||||
sBackend != LayersBackend::LAYERS_NONE &&
|
||||
backend != LayersBackend::LAYERS_NONE) {
|
||||
// Assert this once we figure out bug 972891.
|
||||
#ifdef XP_MACOSX
|
||||
gfxWarning() << "Changing compositor from " << unsigned(sBackend) << " to " << unsigned(backend);
|
||||
#endif
|
||||
}
|
||||
|
||||
sBackend = backend;
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
Compositor::AssertOnCompositorThread()
|
||||
{
|
||||
|
|
|
@ -463,16 +463,6 @@ public:
|
|||
*/
|
||||
static void AssertOnCompositorThread();
|
||||
|
||||
/**
|
||||
* We enforce that there can only be one Compositor backend type off the main
|
||||
* thread at the same time. The backend type in use can be checked with this
|
||||
* static method. We need this for creating texture clients/hosts etc. when we
|
||||
* don't have a reference to a Compositor.
|
||||
*
|
||||
* This can only be used from the compositor thread!
|
||||
*/
|
||||
static LayersBackend GetBackend();
|
||||
|
||||
size_t GetFillRatio() {
|
||||
float fillRatio = 0;
|
||||
if (mPixelsFilled > 0 && mPixelsPerFrame > 0) {
|
||||
|
@ -521,11 +511,6 @@ protected:
|
|||
|
||||
bool ShouldDrawDiagnostics(DiagnosticFlags);
|
||||
|
||||
/**
|
||||
* Set the global Compositor backend, checking that one isn't already set.
|
||||
*/
|
||||
static void SetBackend(LayersBackend backend);
|
||||
|
||||
/**
|
||||
* Render time for the current composition.
|
||||
*/
|
||||
|
|
|
@ -71,7 +71,6 @@ BasicCompositor::BasicCompositor(nsIWidget *aWidget)
|
|||
: mWidget(aWidget)
|
||||
{
|
||||
MOZ_COUNT_CTOR(BasicCompositor);
|
||||
SetBackend(LayersBackend::LAYERS_BASIC);
|
||||
|
||||
mMaxTextureSize =
|
||||
Factory::GetMaxSurfaceSize(gfxPlatform::GetPlatform()->GetContentBackendFor(LayersBackend::LAYERS_BASIC));
|
||||
|
|
|
@ -285,7 +285,7 @@ TextureClient::InitIPDLActor(CompositableForwarder* aForwarder)
|
|||
return false;
|
||||
}
|
||||
|
||||
mActor = static_cast<TextureChild*>(aForwarder->CreateTexture(desc, GetFlags()));
|
||||
mActor = static_cast<TextureChild*>(aForwarder->CreateTexture(desc, aForwarder->GetCompositorBackendType(), GetFlags()));
|
||||
MOZ_ASSERT(mActor);
|
||||
mActor->mForwarder = aForwarder;
|
||||
mActor->mTextureClient = this;
|
||||
|
|
|
@ -161,7 +161,7 @@ LayerManagerComposite::UpdateRenderBounds(const IntRect& aRect)
|
|||
bool
|
||||
LayerManagerComposite::AreComponentAlphaLayersEnabled()
|
||||
{
|
||||
return Compositor::GetBackend() != LayersBackend::LAYERS_BASIC &&
|
||||
return mCompositor->GetBackendType() != LayersBackend::LAYERS_BASIC &&
|
||||
LayerManager::AreComponentAlphaLayersEnabled();
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
~TextureParent();
|
||||
|
||||
bool Init(const SurfaceDescriptor& aSharedData,
|
||||
const LayersBackend& aLayersBackend,
|
||||
const TextureFlags& aFlags);
|
||||
|
||||
void CompositorRecycle();
|
||||
|
@ -93,11 +94,10 @@ public:
|
|||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// static
|
||||
PTextureParent*
|
||||
TextureHost::CreateIPDLActor(CompositableParentManager* aManager,
|
||||
const SurfaceDescriptor& aSharedData,
|
||||
LayersBackend aLayersBackend,
|
||||
TextureFlags aFlags)
|
||||
{
|
||||
if (aSharedData.type() == SurfaceDescriptor::TSurfaceDescriptorMemory &&
|
||||
|
@ -107,7 +107,7 @@ TextureHost::CreateIPDLActor(CompositableParentManager* aManager,
|
|||
return nullptr;
|
||||
}
|
||||
TextureParent* actor = new TextureParent(aManager);
|
||||
if (!actor->Init(aSharedData, aFlags)) {
|
||||
if (!actor->Init(aSharedData, aLayersBackend, aFlags)) {
|
||||
delete actor;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -200,10 +200,10 @@ already_AddRefed<TextureHost> CreateTextureHostD3D9(const SurfaceDescriptor& aDe
|
|||
ISurfaceAllocator* aDeallocator,
|
||||
TextureFlags aFlags);
|
||||
|
||||
// static
|
||||
already_AddRefed<TextureHost>
|
||||
TextureHost::Create(const SurfaceDescriptor& aDesc,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
LayersBackend aBackend,
|
||||
TextureFlags aFlags)
|
||||
{
|
||||
switch (aDesc.type()) {
|
||||
|
@ -219,7 +219,7 @@ TextureHost::Create(const SurfaceDescriptor& aDesc,
|
|||
return CreateTextureHostOGL(aDesc, aDeallocator, aFlags);
|
||||
|
||||
case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface:
|
||||
if (Compositor::GetBackend() == LayersBackend::LAYERS_OPENGL) {
|
||||
if (aBackend == LayersBackend::LAYERS_OPENGL) {
|
||||
return CreateTextureHostOGL(aDesc, aDeallocator, aFlags);
|
||||
} else {
|
||||
return CreateTextureHostBasic(aDesc, aDeallocator, aFlags);
|
||||
|
@ -238,7 +238,7 @@ TextureHost::Create(const SurfaceDescriptor& aDesc,
|
|||
|
||||
case SurfaceDescriptor::TSurfaceDescriptorD3D10:
|
||||
case SurfaceDescriptor::TSurfaceDescriptorDXGIYCbCr:
|
||||
if (Compositor::GetBackend() == LayersBackend::LAYERS_D3D9) {
|
||||
if (aBackend == LayersBackend::LAYERS_D3D9) {
|
||||
return CreateTextureHostD3D9(aDesc, aDeallocator, aFlags);
|
||||
} else {
|
||||
return CreateTextureHostD3D11(aDesc, aDeallocator, aFlags);
|
||||
|
@ -798,10 +798,12 @@ TextureParent::RecvClientRecycle()
|
|||
|
||||
bool
|
||||
TextureParent::Init(const SurfaceDescriptor& aSharedData,
|
||||
const LayersBackend& aBackend,
|
||||
const TextureFlags& aFlags)
|
||||
{
|
||||
mTextureHost = TextureHost::Create(aSharedData,
|
||||
mCompositableManager,
|
||||
aBackend,
|
||||
aFlags);
|
||||
if (mTextureHost) {
|
||||
mTextureHost->mActor = this;
|
||||
|
|
|
@ -325,9 +325,11 @@ public:
|
|||
/**
|
||||
* Factory method.
|
||||
*/
|
||||
static already_AddRefed<TextureHost> Create(const SurfaceDescriptor& aDesc,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
TextureFlags aFlags);
|
||||
static already_AddRefed<TextureHost> Create(
|
||||
const SurfaceDescriptor& aDesc,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
LayersBackend aBackend,
|
||||
TextureFlags aFlags);
|
||||
|
||||
/**
|
||||
* Tell to TextureChild that TextureHost is recycled.
|
||||
|
@ -450,6 +452,7 @@ public:
|
|||
*/
|
||||
static PTextureParent* CreateIPDLActor(CompositableParentManager* aManager,
|
||||
const SurfaceDescriptor& aSharedData,
|
||||
LayersBackend aLayersBackend,
|
||||
TextureFlags aFlags);
|
||||
static bool DestroyIPDLActor(PTextureParent* actor);
|
||||
|
||||
|
|
|
@ -154,7 +154,6 @@ CompositorD3D11::CompositorD3D11(nsIWidget* aWidget)
|
|||
, mHwnd(nullptr)
|
||||
, mDisableSequenceForNextFrame(false)
|
||||
{
|
||||
SetBackend(LayersBackend::LAYERS_D3D11);
|
||||
}
|
||||
|
||||
CompositorD3D11::~CompositorD3D11()
|
||||
|
|
|
@ -29,7 +29,6 @@ CompositorD3D9::CompositorD3D9(PCompositorParent* aParent, nsIWidget *aWidget)
|
|||
, mDeviceResetCount(0)
|
||||
, mFailedResetAttempts(0)
|
||||
{
|
||||
Compositor::SetBackend(LayersBackend::LAYERS_D3D9);
|
||||
}
|
||||
|
||||
CompositorD3D9::~CompositorD3D9()
|
||||
|
|
|
@ -64,7 +64,10 @@ public:
|
|||
/**
|
||||
* Create a TextureChild/Parent pair as as well as the TextureHost on the parent side.
|
||||
*/
|
||||
virtual PTextureChild* CreateTexture(const SurfaceDescriptor& aSharedData, TextureFlags aFlags) = 0;
|
||||
virtual PTextureChild* CreateTexture(
|
||||
const SurfaceDescriptor& aSharedData,
|
||||
LayersBackend aLayersBackend,
|
||||
TextureFlags aFlags) = 0;
|
||||
|
||||
/**
|
||||
* Communicate to the compositor that aRegion in the texture identified by
|
||||
|
@ -166,7 +169,7 @@ public:
|
|||
* We only don't allow changing the backend type at runtime so this value can
|
||||
* be queried once and will not change until Gecko is restarted.
|
||||
*/
|
||||
virtual LayersBackend GetCompositorBackendType() const override
|
||||
LayersBackend GetCompositorBackendType() const override
|
||||
{
|
||||
return mTextureFactoryIdentifier.mParentBackend;
|
||||
}
|
||||
|
|
|
@ -84,12 +84,8 @@ public:
|
|||
void Finalize();
|
||||
|
||||
/**
|
||||
* Returns the type of backend that is used off the main thread.
|
||||
* We only don't allow changing the backend type at runtime so this value can
|
||||
* be queried once and will not change until Gecko is restarted.
|
||||
*
|
||||
* XXX - With e10s this may not be true anymore. we can have accelerated widgets
|
||||
* and non-accelerated widgets (small popups, etc.)
|
||||
* Returns the preferred compositor backend type for drawing. If not known
|
||||
* or not supported, LAYERS_NONE is returned.
|
||||
*/
|
||||
virtual LayersBackend GetCompositorBackendType() const = 0;
|
||||
|
||||
|
|
|
@ -856,6 +856,7 @@ ImageBridgeChild::DeallocShmem(ipc::Shmem& aShmem)
|
|||
|
||||
PTextureChild*
|
||||
ImageBridgeChild::AllocPTextureChild(const SurfaceDescriptor&,
|
||||
const LayersBackend&,
|
||||
const TextureFlags&)
|
||||
{
|
||||
MOZ_ASSERT(!mShuttingDown);
|
||||
|
@ -951,10 +952,11 @@ ImageBridgeChild::RecvDidComposite(InfallibleTArray<ImageCompositeNotification>&
|
|||
|
||||
PTextureChild*
|
||||
ImageBridgeChild::CreateTexture(const SurfaceDescriptor& aSharedData,
|
||||
LayersBackend aLayersBackend,
|
||||
TextureFlags aFlags)
|
||||
{
|
||||
MOZ_ASSERT(!mShuttingDown);
|
||||
return SendPTextureConstructor(aSharedData, aFlags);
|
||||
return SendPTextureConstructor(aSharedData, aLayersBackend, aFlags);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -185,7 +185,7 @@ public:
|
|||
~ImageBridgeChild();
|
||||
|
||||
virtual PTextureChild*
|
||||
AllocPTextureChild(const SurfaceDescriptor& aSharedData, const TextureFlags& aFlags) override;
|
||||
AllocPTextureChild(const SurfaceDescriptor& aSharedData, const LayersBackend& aLayersBackend, const TextureFlags& aFlags) override;
|
||||
|
||||
virtual bool
|
||||
DeallocPTextureChild(PTextureChild* actor) override;
|
||||
|
@ -292,6 +292,7 @@ public:
|
|||
virtual void DeallocShmem(mozilla::ipc::Shmem& aShmem) override;
|
||||
|
||||
virtual PTextureChild* CreateTexture(const SurfaceDescriptor& aSharedData,
|
||||
LayersBackend aLayersBackend,
|
||||
TextureFlags aFlags) override;
|
||||
|
||||
virtual bool IsSameProcess() const override;
|
||||
|
|
|
@ -91,12 +91,6 @@ ImageBridgeParent::~ImageBridgeParent()
|
|||
sImageBridges.erase(OtherPid());
|
||||
}
|
||||
|
||||
LayersBackend
|
||||
ImageBridgeParent::GetCompositorBackendType() const
|
||||
{
|
||||
return Compositor::GetBackend();
|
||||
}
|
||||
|
||||
void
|
||||
ImageBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
|
@ -138,12 +132,6 @@ ImageBridgeParent::RecvUpdate(EditArray&& aEdits, EditReplyArray* aReply)
|
|||
{
|
||||
AutoImageBridgeParentAsyncMessageSender autoAsyncMessageSender(this);
|
||||
|
||||
// If we don't actually have a compositor, then don't bother
|
||||
// creating any textures.
|
||||
if (Compositor::GetBackend() == LayersBackend::LAYERS_NONE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
EditReplyVector replyv;
|
||||
for (EditArray::index_type i = 0; i < aEdits.Length(); ++i) {
|
||||
if (!ReceiveCompositableUpdate(aEdits[i], replyv)) {
|
||||
|
@ -256,9 +244,10 @@ bool ImageBridgeParent::DeallocPCompositableParent(PCompositableParent* aActor)
|
|||
|
||||
PTextureParent*
|
||||
ImageBridgeParent::AllocPTextureParent(const SurfaceDescriptor& aSharedData,
|
||||
const LayersBackend& aLayersBackend,
|
||||
const TextureFlags& aFlags)
|
||||
{
|
||||
return TextureHost::CreateIPDLActor(this, aSharedData, aFlags);
|
||||
return TextureHost::CreateIPDLActor(this, aSharedData, aLayersBackend, aFlags);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -49,7 +49,10 @@ public:
|
|||
ImageBridgeParent(MessageLoop* aLoop, Transport* aTransport, ProcessId aChildProcessId);
|
||||
~ImageBridgeParent();
|
||||
|
||||
virtual LayersBackend GetCompositorBackendType() const override;
|
||||
LayersBackend GetCompositorBackendType() const override {
|
||||
MOZ_CRASH("ImageBridgeParent does not support GetCompositorBackendType");
|
||||
return LayersBackend::LAYERS_NONE;
|
||||
}
|
||||
|
||||
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
|
||||
|
@ -80,6 +83,7 @@ public:
|
|||
bool DeallocPCompositableParent(PCompositableParent* aActor) override;
|
||||
|
||||
virtual PTextureParent* AllocPTextureParent(const SurfaceDescriptor& aSharedData,
|
||||
const LayersBackend& aLayersBackend,
|
||||
const TextureFlags& aFlags) override;
|
||||
virtual bool DeallocPTextureParent(PTextureParent* actor) override;
|
||||
|
||||
|
|
|
@ -126,6 +126,7 @@ LayerTransactionChild::ActorDestroy(ActorDestroyReason why)
|
|||
|
||||
PTextureChild*
|
||||
LayerTransactionChild::AllocPTextureChild(const SurfaceDescriptor&,
|
||||
const LayersBackend&,
|
||||
const TextureFlags&)
|
||||
{
|
||||
MOZ_ASSERT(!mDestroyed);
|
||||
|
|
|
@ -65,6 +65,7 @@ protected:
|
|||
virtual bool DeallocPCompositableChild(PCompositableChild* actor) override;
|
||||
|
||||
virtual PTextureChild* AllocPTextureChild(const SurfaceDescriptor& aSharedData,
|
||||
const LayersBackend& aLayersBackend,
|
||||
const TextureFlags& aFlags) override;
|
||||
virtual bool DeallocPTextureChild(PTextureChild* actor) override;
|
||||
|
||||
|
|
|
@ -924,9 +924,11 @@ LayerTransactionParent::DeallocPCompositableParent(PCompositableParent* aActor)
|
|||
|
||||
PTextureParent*
|
||||
LayerTransactionParent::AllocPTextureParent(const SurfaceDescriptor& aSharedData,
|
||||
const LayersBackend& aLayersBackend,
|
||||
const TextureFlags& aFlags)
|
||||
{
|
||||
return TextureHost::CreateIPDLActor(this, aSharedData, aFlags);
|
||||
MOZ_ASSERT(aLayersBackend == mLayerManager->GetCompositor()->GetBackendType());
|
||||
return TextureHost::CreateIPDLActor(this, aSharedData, aLayersBackend, aFlags);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -150,6 +150,7 @@ protected:
|
|||
virtual bool DeallocPCompositableParent(PCompositableParent* actor) override;
|
||||
|
||||
virtual PTextureParent* AllocPTextureParent(const SurfaceDescriptor& aSharedData,
|
||||
const LayersBackend& aLayersBackend,
|
||||
const TextureFlags& aFlags) override;
|
||||
virtual bool DeallocPTextureParent(PTextureParent* actor) override;
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ using mozilla::layers::DiagnosticTypes from "mozilla/layers/CompositorTypes.h";
|
|||
using struct mozilla::layers::FrameMetrics from "FrameMetrics.h";
|
||||
using mozilla::layers::FrameMetrics::ViewID from "FrameMetrics.h";
|
||||
using struct mozilla::layers::FenceHandle from "mozilla/layers/FenceUtils.h";
|
||||
using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
|
|
@ -59,7 +59,7 @@ parent:
|
|||
|
||||
sync PCompositable(TextureInfo aInfo,
|
||||
PImageContainer aImageContainer) returns (uint64_t id);
|
||||
async PTexture(SurfaceDescriptor aSharedData, TextureFlags aTextureFlags);
|
||||
async PTexture(SurfaceDescriptor aSharedData, LayersBackend aBackend, TextureFlags aTextureFlags);
|
||||
async PMediaSystemResourceManager();
|
||||
async PImageContainer();
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ using mozilla::layers::TextureFlags from "mozilla/layers/CompositorTypes.h";
|
|||
using class mozilla::layers::APZTestData from "mozilla/layers/APZTestData.h";
|
||||
using mozilla::layers::FrameMetrics::ViewID from "FrameMetrics.h";
|
||||
using struct mozilla::layers::ScrollableLayerGuid from "FrameMetrics.h";
|
||||
using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h";
|
||||
|
||||
/**
|
||||
* The layers protocol is spoken between thread contexts that manage
|
||||
|
@ -50,7 +51,7 @@ child:
|
|||
parent:
|
||||
async PLayer();
|
||||
async PCompositable(TextureInfo aTextureInfo);
|
||||
async PTexture(SurfaceDescriptor aSharedData, TextureFlags aTextureFlags);
|
||||
async PTexture(SurfaceDescriptor aSharedData, LayersBackend aBackend, TextureFlags aTextureFlags);
|
||||
|
||||
// The isFirstPaint flag can be used to indicate that this is the first update
|
||||
// for a particular document.
|
||||
|
|
|
@ -816,13 +816,14 @@ void ShadowLayerForwarder::AttachAsyncCompositable(uint64_t aCompositableID,
|
|||
|
||||
PTextureChild*
|
||||
ShadowLayerForwarder::CreateTexture(const SurfaceDescriptor& aSharedData,
|
||||
LayersBackend aLayersBackend,
|
||||
TextureFlags aFlags)
|
||||
{
|
||||
if (!HasShadowManager() ||
|
||||
!mShadowManager->IPCOpen()) {
|
||||
return nullptr;
|
||||
}
|
||||
return mShadowManager->SendPTextureConstructor(aSharedData, aFlags);
|
||||
return mShadowManager->SendPTextureConstructor(aSharedData, aLayersBackend, aFlags);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -128,6 +128,7 @@ public:
|
|||
ImageContainer* aImageContainer) override;
|
||||
|
||||
virtual PTextureChild* CreateTexture(const SurfaceDescriptor& aSharedData,
|
||||
LayersBackend aLayersBackend,
|
||||
TextureFlags aFlags) override;
|
||||
|
||||
/**
|
||||
|
|
|
@ -92,7 +92,6 @@ CompositorOGL::CompositorOGL(nsIWidget *aWidget, int aSurfaceWidth,
|
|||
, mCurrentProgram(nullptr)
|
||||
{
|
||||
MOZ_COUNT_CTOR(CompositorOGL);
|
||||
SetBackend(LayersBackend::LAYERS_OPENGL);
|
||||
}
|
||||
|
||||
CompositorOGL::~CompositorOGL()
|
||||
|
|
|
@ -62,8 +62,7 @@ private:
|
|||
/* static */ GLManager*
|
||||
GLManager::CreateGLManager(LayerManagerComposite* aManager)
|
||||
{
|
||||
if (aManager &&
|
||||
Compositor::GetBackend() == LayersBackend::LAYERS_OPENGL) {
|
||||
if (aManager && aManager->GetCompositor()->GetBackendType() == LayersBackend::LAYERS_OPENGL) {
|
||||
return new GLManagerCompositor(static_cast<CompositorOGL*>(
|
||||
aManager->GetCompositor()));
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче