Backed out changeset fce8bb3c16f7 (
bug 1389021) for breaking debug builds.
--- a/gfx/layers/ipc/CompositorManagerParent.cpp
+++ b/gfx/layers/ipc/CompositorManagerParent.cpp
@@ -4,24 +4,22 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/layers/CompositorManagerParent.h"
#include "mozilla/gfx/GPUParent.h"
#include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/layers/CrossProcessCompositorBridgeParent.h"
#include "mozilla/layers/CompositorThread.h"
-#include "nsAutoPtr.h"
#include "VsyncSource.h"
namespace mozilla {
namespace layers {
StaticRefPtr<CompositorManagerParent> CompositorManagerParent::sInstance;
-StaticAutoPtr<nsTArray<CompositorManagerParent*>> CompositorManagerParent::sActiveActors;
StaticMutex CompositorManagerParent::sMutex;
/* static */ already_AddRefed<CompositorManagerParent>
CompositorManagerParent::CreateSameProcess()
{
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
StaticMutexAutoLock lock(sMutex);
@@ -39,21 +37,16 @@ CompositorManagerParent::CreateSameProce
// on the main thread and complete before we return the manager handles.
RefPtr<CompositorManagerParent> parent = new CompositorManagerParent();
parent->SetOtherProcessId(base::GetCurrentProcId());
// CompositorManagerParent::Bind would normally add a reference for IPDL but
// we don't use that in the same process case.
parent.get()->AddRef();
sInstance = parent;
-
- if (!sActiveActors) {
- sActiveActors = new nsTArray<CompositorManagerParent*>();
- }
- sActiveActors->AppendElement(parent);
return parent.forget();
}
/* static */ void
CompositorManagerParent::Create(Endpoint<PCompositorManagerParent>&& aEndpoint)
{
MOZ_ASSERT(NS_IsMainThread());
@@ -126,22 +119,16 @@ CompositorManagerParent::Bind(Endpoint<P
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
if (NS_WARN_IF(!aEndpoint.Bind(this))) {
return;
}
// Add the IPDL reference to ourself, so we can't get freed until IPDL is
// done with us.
AddRef();
-
- StaticMutexAutoLock lock(sMutex);
- if (!sActiveActors) {
- sActiveActors = new nsTArray<CompositorManagerParent*>();
- }
- sActiveActors->AppendElement(this);
}
void
CompositorManagerParent::ActorDestroy(ActorDestroyReason aReason)
{
StaticMutexAutoLock lock(sMutex);
if (sInstance == this) {
sInstance = nullptr;
@@ -151,59 +138,25 @@ CompositorManagerParent::ActorDestroy(Ac
void
CompositorManagerParent::DeallocPCompositorManagerParent()
{
MessageLoop::current()->PostTask(
NewRunnableMethod("layers::CompositorManagerParent::DeferredDestroy",
this,
&CompositorManagerParent::DeferredDestroy));
- StaticMutexAutoLock lock(sMutex);
- if (sActiveActors) {
- sActiveActors->RemoveElement(this);
- }
Release();
}
void
CompositorManagerParent::DeferredDestroy()
{
mCompositorThreadHolder = nullptr;
}
-/* static */ void
-CompositorManagerParent::ShutdownInternal()
-{
- nsAutoPtr<nsTArray<CompositorManagerParent*>> actors;
-
- // We move here because we may attempt to acquire the same lock during the
- // destroy to remove the reference in sActiveActors.
- {
- StaticMutexAutoLock lock(sMutex);
- actors = sActiveActors.forget();
- }
-
- if (actors) {
- for (auto& actor : *actors) {
- actor->Close();
- }
- }
-}
-
-/* static */ void
-CompositorManagerParent::Shutdown()
-{
- MOZ_ASSERT(NS_IsMainThread());
-
- CompositorThreadHolder::Loop()->PostTask(
- NS_NewRunnableFunction("layers::CompositorManagerParent::Shutdown", []() -> void {
- CompositorManagerParent::ShutdownInternal();
- }));
-}
-
PCompositorBridgeParent*
CompositorManagerParent::AllocPCompositorBridgeParent(const CompositorBridgeOptions& aOpt)
{
switch (aOpt.type()) {
case CompositorBridgeOptions::TContentCompositorOptions: {
CrossProcessCompositorBridgeParent* bridge =
new CrossProcessCompositorBridgeParent(this);
bridge->AddRef();
--- a/gfx/layers/ipc/CompositorManagerParent.h
+++ b/gfx/layers/ipc/CompositorManagerParent.h
@@ -22,36 +22,32 @@ class CompositorThreadHolder;
class CompositorManagerParent final : public PCompositorManagerParent
{
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorManagerParent)
public:
static already_AddRefed<CompositorManagerParent> CreateSameProcess();
static void Create(Endpoint<PCompositorManagerParent>&& aEndpoint);
- static void Shutdown();
static already_AddRefed<CompositorBridgeParent>
CreateSameProcessWidgetCompositorBridge(CSSToLayoutDeviceScale aScale,
const CompositorOptions& aOptions,
bool aUseExternalSurfaceSize,
const gfx::IntSize& aSurfaceSize);
void ActorDestroy(ActorDestroyReason aReason) override;
bool DeallocPCompositorBridgeParent(PCompositorBridgeParent* aActor) override;
PCompositorBridgeParent* AllocPCompositorBridgeParent(const CompositorBridgeOptions& aOpt) override;
private:
static StaticRefPtr<CompositorManagerParent> sInstance;
- static StaticAutoPtr<nsTArray<CompositorManagerParent*>> sActiveActors;
static StaticMutex sMutex;
- static void ShutdownInternal();
-
CompositorManagerParent();
~CompositorManagerParent() override;
void Bind(Endpoint<PCompositorManagerParent>&& aEndpoint);
void DeallocPCompositorManagerParent() override;
void DeferredDestroy();
--- a/gfx/layers/ipc/CompositorThread.cpp
+++ b/gfx/layers/ipc/CompositorThread.cpp
@@ -124,17 +124,16 @@ void
CompositorThreadHolder::Shutdown()
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on the main Thread!");
MOZ_ASSERT(sCompositorThreadHolder, "The compositor thread has already been shut down!");
ReleaseImageBridgeParentSingleton();
gfx::ReleaseVRManagerParentSingleton();
MediaSystemResourceService::Shutdown();
- CompositorManagerParent::Shutdown();
sCompositorThreadHolder = nullptr;
// No locking is needed around sFinishedCompositorShutDown because it is only
// ever accessed on the main thread.
SpinEventLoopUntil([&]() { return sFinishedCompositorShutDown; });
CompositorBridgeParent::FinishShutdown();