Bug 1164763 - Avoid one extra IPC round-trip when compositor-lru-size == 0. r=mattwoodrow,billm

This commit is contained in:
Kan-Ru Chen 2015-05-25 17:20:10 +08:00
parent 59770e5830
commit 9797e46901

View File

@ -143,6 +143,19 @@ private:
TabChild *mTabChild; TabChild *mTabChild;
}; };
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;
}
NS_IMPL_ISUPPORTS(TabChild::DelayedFireContextMenuEvent, NS_IMPL_ISUPPORTS(TabChild::DelayedFireContextMenuEvent,
nsITimerCallback) nsITimerCallback)
@ -2987,7 +3000,9 @@ void
TabChild::MakeVisible() TabChild::MakeVisible()
{ {
CompositorChild* compositor = CompositorChild::Get(); CompositorChild* compositor = CompositorChild::Get();
if (UsingCompositorLRU()) {
compositor->SendNotifyVisible(mLayersId); compositor->SendNotifyVisible(mLayersId);
}
if (mWidget) { if (mWidget) {
mWidget->Show(true); mWidget->Show(true);
@ -2998,7 +3013,14 @@ void
TabChild::MakeHidden() TabChild::MakeHidden()
{ {
CompositorChild* compositor = CompositorChild::Get(); CompositorChild* compositor = CompositorChild::Get();
if (UsingCompositorLRU()) {
compositor->SendNotifyHidden(mLayersId); compositor->SendNotifyHidden(mLayersId);
} else {
// Clear cached resources directly. This avoids one extra IPC
// round-trip from CompositorChild to CompositorParent when
// CompositorLRU is not used.
compositor->RecvClearCachedResources(mLayersId);
}
if (mWidget) { if (mWidget) {
mWidget->Show(false); mWidget->Show(false);