From 9797e46901667f1fcce1a3f35f00bbbb13e1f214 Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Mon, 25 May 2015 17:20:10 +0800 Subject: [PATCH] Bug 1164763 - Avoid one extra IPC round-trip when compositor-lru-size == 0. r=mattwoodrow,billm --- dom/ipc/TabChild.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 51df272fe48..fdcacef13de 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -143,6 +143,19 @@ private: 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, nsITimerCallback) @@ -2987,7 +3000,9 @@ void TabChild::MakeVisible() { CompositorChild* compositor = CompositorChild::Get(); - compositor->SendNotifyVisible(mLayersId); + if (UsingCompositorLRU()) { + compositor->SendNotifyVisible(mLayersId); + } if (mWidget) { mWidget->Show(true); @@ -2998,7 +3013,14 @@ void TabChild::MakeHidden() { CompositorChild* compositor = CompositorChild::Get(); - compositor->SendNotifyHidden(mLayersId); + if (UsingCompositorLRU()) { + 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) { mWidget->Show(false);