Remove CompositorLRU and associated code. (bug 1287362, r=mattwoodrow)

This commit is contained in:
David Anderson 2016-07-19 21:12:54 -07:00
Родитель 21a8ece643
Коммит fe699affc1
11 изменённых файлов: 4 добавлений и 250 удалений

Просмотреть файл

@ -148,19 +148,6 @@ static const char BEFORE_FIRST_PAINT[] = "before-first-paint";
typedef nsDataHashtable<nsUint64HashKey, TabChild*> TabChildMap;
static TabChildMap* sTabChildren;
static bool
UsingCompositorLRU()
{
static bool sHavePrefs = false;
static uint32_t sCompositorLRUSize = 0;
if (!sHavePrefs) {
sHavePrefs = true;
Preferences::AddUintVarCache(&sCompositorLRUSize,
"layers.compositor-lru-size", 0);
}
return sCompositorLRUSize != 0;
}
TabChildBase::TabChildBase()
: mTabChildGlobal(nullptr)
{
@ -2872,11 +2859,6 @@ TabChild::NotifyPainted()
void
TabChild::MakeVisible()
{
CompositorBridgeChild* compositor = CompositorBridgeChild::Get();
if (UsingCompositorLRU()) {
compositor->SendNotifyVisible(mLayersId);
}
if (mPuppetWidget) {
mPuppetWidget->Show(true);
}
@ -2886,14 +2868,10 @@ void
TabChild::MakeHidden()
{
CompositorBridgeChild* compositor = CompositorBridgeChild::Get();
if (UsingCompositorLRU()) {
compositor->SendNotifyHidden(mLayersId);
} else {
// Clear cached resources directly. This avoids one extra IPC
// round-trip from CompositorBridgeChild to CompositorBridgeParent when
// CompositorLRU is not used.
compositor->RecvClearCachedResources(mLayersId);
}
// Clear cached resources directly. This avoids one extra IPC
// round-trip from CompositorBridgeChild to CompositorBridgeParent.
compositor->RecvClearCachedResources(mLayersId);
if (mPuppetWidget) {
mPuppetWidget->Show(false);

Просмотреть файл

@ -698,26 +698,6 @@ CompositorBridgeChild::SendResume()
return PCompositorBridgeChild::SendResume();
}
bool
CompositorBridgeChild::SendNotifyHidden(const uint64_t& id)
{
MOZ_ASSERT(mCanSend);
if (!mCanSend) {
return true;
}
return PCompositorBridgeChild::SendNotifyHidden(id);
}
bool
CompositorBridgeChild::SendNotifyVisible(const uint64_t& id)
{
MOZ_ASSERT(mCanSend);
if (!mCanSend) {
return true;
}
return PCompositorBridgeChild::SendNotifyVisible(id);
}
bool
CompositorBridgeChild::SendNotifyChildCreated(const uint64_t& id)
{

Просмотреть файл

@ -149,8 +149,6 @@ public:
bool SendWillClose();
bool SendPause();
bool SendResume();
bool SendNotifyHidden(const uint64_t& id);
bool SendNotifyVisible(const uint64_t& id);
bool SendNotifyChildCreated(const uint64_t& id);
bool SendAdoptChild(const uint64_t& id);
bool SendMakeSnapshot(const SurfaceDescriptor& inSnapshot, const gfx::IntRect& dirtyRect);

Просмотреть файл

@ -36,7 +36,6 @@
#include "mozilla/layers/AsyncCompositionManager.h"
#include "mozilla/layers/BasicCompositor.h" // for BasicCompositor
#include "mozilla/layers/Compositor.h" // for Compositor
#include "mozilla/layers/CompositorLRU.h" // for CompositorLRU
#include "mozilla/layers/CompositorOGL.h" // for CompositorOGL
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/CompositorTypes.h"
@ -1992,8 +1991,6 @@ public:
virtual bool RecvWillClose() override { return true; }
virtual bool RecvPause() override { return true; }
virtual bool RecvResume() override { return true; }
virtual bool RecvNotifyHidden(const uint64_t& id) override;
virtual bool RecvNotifyVisible(const uint64_t& id) override;
virtual bool RecvNotifyChildCreated(const uint64_t& child) override;
virtual bool RecvAdoptChild(const uint64_t& child) override { return false; }
virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
@ -2396,22 +2393,6 @@ CompositorBridgeParent::IsSameProcess() const
return OtherPid() == base::GetCurrentProcId();
}
bool
CrossProcessCompositorBridgeParent::RecvNotifyHidden(const uint64_t& id)
{
RefPtr<CompositorLRU> lru = CompositorLRU::GetSingleton();
lru->Add(this, id);
return true;
}
bool
CrossProcessCompositorBridgeParent::RecvNotifyVisible(const uint64_t& id)
{
RefPtr<CompositorLRU> lru = CompositorLRU::GetSingleton();
lru->Remove(this, id);
return true;
}
bool
CrossProcessCompositorBridgeParent::RecvRequestNotifyAfterRemotePaint()
{
@ -2422,9 +2403,6 @@ CrossProcessCompositorBridgeParent::RecvRequestNotifyAfterRemotePaint()
void
CrossProcessCompositorBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
{
RefPtr<CompositorLRU> lru = CompositorLRU::GetSingleton();
lru->Remove(this);
// We must keep this object alive untill the code handling message
// reception is finished on this thread.
MessageLoop::current()->PostTask(NewRunnableMethod(this, &CrossProcessCompositorBridgeParent::DeferredDestroy));

Просмотреть файл

@ -234,8 +234,6 @@ public:
virtual bool RecvWillClose() override;
virtual bool RecvPause() override;
virtual bool RecvResume() override;
virtual bool RecvNotifyHidden(const uint64_t& id) override { return true; }
virtual bool RecvNotifyVisible(const uint64_t& id) override { return true; }
virtual bool RecvNotifyChildCreated(const uint64_t& child) override;
virtual bool RecvAdoptChild(const uint64_t& child) override;
virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,

Просмотреть файл

@ -1,101 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 et :
*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 "CompositorLRU.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Preferences.h"
#include "mozilla/unused.h"
#include "CompositorBridgeParent.h"
namespace mozilla {
namespace layers {
mozilla::StaticRefPtr<CompositorLRU> CompositorLRU::sSingleton;
void
CompositorLRU::Init()
{
Unused << GetSingleton();
}
CompositorLRU*
CompositorLRU::GetSingleton()
{
if (sSingleton) {
return sSingleton;
}
sSingleton = new CompositorLRU();
ClearOnShutdown(&sSingleton);
return sSingleton;
}
CompositorLRU::CompositorLRU()
{
mLRUSize = Preferences::GetUint("layers.compositor-lru-size", uint32_t(0));
}
CompositorLRU::~CompositorLRU()
{
}
void
CompositorLRU::Add(PCompositorBridgeParent* aCompositor, const uint64_t& aId)
{
auto index = mLRU.IndexOf(std::make_pair(aCompositor, aId));
if (index != nsTArray<CompositorLayerPair>::NoIndex) {
return;
}
if (mLRUSize == 0) {
Unused << aCompositor->SendClearCachedResources(aId);
return;
}
if (mLRU.Length() == mLRUSize) {
CompositorLayerPair victim = mLRU.LastElement();
Unused << victim.first->SendClearCachedResources(victim.second);
mLRU.RemoveElement(victim);
}
mLRU.InsertElementAt(0, std::make_pair(aCompositor, aId));
}
void
CompositorLRU::Remove(PCompositorBridgeParent* aCompositor, const uint64_t& aId)
{
if (mLRUSize == 0) {
return;
}
auto index = mLRU.IndexOf(std::make_pair(aCompositor, aId));
if (index == nsTArray<PCompositorBridgeParent*>::NoIndex) {
return;
}
mLRU.RemoveElementAt(index);
}
void
CompositorLRU::Remove(PCompositorBridgeParent* aCompositor)
{
if (mLRUSize == 0) {
return;
}
for (int32_t i = mLRU.Length() - 1; i >= 0; --i) {
if (mLRU[i].first == aCompositor) {
mLRU.RemoveElementAt(i);
}
}
}
} // namespace layers
} // namespace mozilla

Просмотреть файл

@ -1,61 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 et :
*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#ifndef mozilla_CompositorLRU_h
#define mozilla_CompositorLRU_h
#include "mozilla/StaticPtr.h"
#include "nsISupportsImpl.h"
#include "nsTArray.h"
#include <utility>
namespace mozilla {
namespace layers {
class PCompositorBridgeParent;
class CompositorLRU final
{
typedef std::pair<PCompositorBridgeParent*, uint64_t> CompositorLayerPair;
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorLRU)
static void Init();
static CompositorLRU* GetSingleton();
/**
* Adds the (PCompositorBridgeParent, LayerId) pair to the LRU pool. If
* the pool size grows over mLRUSize, the oldest PCompositorBridgeParent
* is evicted.
*/
void Add(PCompositorBridgeParent* aCompositor, const uint64_t& id);
/**
* Remove the (PCompositorBridgeParent, LayersId) pair from the LRU pool.
*/
void Remove(PCompositorBridgeParent* aCompositor, const uint64_t& id);
/**
* Remove all PCompositorBridgeParents from the LRU pool.
*/
void Remove(PCompositorBridgeParent* aCompositor);
private:
static StaticRefPtr<CompositorLRU> sSingleton;
CompositorLRU();
~CompositorLRU();
uint32_t mLRUSize;
nsTArray<CompositorLayerPair> mLRU;
};
} // namespace layers
} // namespace mozilla
#endif // mozilla_CompositorLRU_h

Просмотреть файл

@ -142,14 +142,6 @@ parent:
sync Pause();
sync Resume();
// The child layer tree is hidden. id is the layers id of the child
// layer tree.
async NotifyHidden(uint64_t id);
// The child layer tree is visible. id is the layers id of the child
// layer tree.
async NotifyVisible(uint64_t id);
async NotifyChildCreated(uint64_t id);
async AdoptChild(uint64_t id);

Просмотреть файл

@ -158,7 +158,6 @@ EXPORTS.mozilla.layers += [
'ipc/CompositableTransactionParent.h',
'ipc/CompositorBridgeChild.h',
'ipc/CompositorBridgeParent.h',
'ipc/CompositorLRU.h',
'ipc/CompositorThread.h',
'ipc/FenceUtils.h',
'ipc/GonkNativeHandle.h',
@ -346,7 +345,6 @@ UNIFIED_SOURCES += [
'ipc/CompositorBench.cpp',
'ipc/CompositorBridgeChild.cpp',
'ipc/CompositorBridgeParent.cpp',
'ipc/CompositorLRU.cpp',
'ipc/CompositorThread.cpp',
'ipc/FenceUtils.cpp',
'ipc/ImageBridgeChild.cpp',

Просмотреть файл

@ -125,7 +125,6 @@ using namespace mozilla::system;
#include "TouchManager.h"
#include "MediaDecoder.h"
#include "MediaPrefs.h"
#include "mozilla/layers/CompositorLRU.h"
#include "mozilla/dom/devicestorage/DeviceStorageStatics.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/StaticPresData.h"
@ -310,8 +309,6 @@ nsLayoutStatics::Initialize()
PromiseDebugging::Init();
layers::CompositorLRU::Init();
mozilla::dom::devicestorage::DeviceStorageStatics::Initialize();
mozilla::dom::WebCryptoThreadPool::Initialize();

Просмотреть файл

@ -4599,9 +4599,6 @@ pref("layers.force-active", false);
// platform and are the optimal surface type.
pref("layers.gralloc.disable", false);
// Don't use compositor-lru on this platform
pref("layers.compositor-lru-size", 0);
// Enable/Disable the geolocation API for content
pref("geo.enabled", true);