Bug 774388 - Patch 4: Flatten the way that we track whether we are using OMTC, and move Layers IPC shutdown code back to gfxPlatform (but still triggered by ShutdownXPCOM) - r=nical,sotaro

This commit is contained in:
Benoit Jacob 2014-06-06 09:51:24 -04:00
Родитель 7ec9b3199d
Коммит c0944ebe5b
16 изменённых файлов: 87 добавлений и 97 удалений

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

@ -1710,8 +1710,7 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
// PBrowsers are created, because they rely on the Compositor
// already being around. (Creation is async, so can't happen
// on demand.)
bool useOffMainThreadCompositing = !!CompositorParent::CompositorLoop();
if (useOffMainThreadCompositing) {
if (gfxPlatform::UsesOffMainThreadCompositing()) {
DebugOnly<bool> opened = PCompositor::Open(this);
MOZ_ASSERT(opened);

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

@ -1888,9 +1888,9 @@ TabParent::GetWidget() const
bool
TabParent::UseAsyncPanZoom()
{
bool usingOffMainThreadCompositing = !!CompositorParent::CompositorLoop();
return (usingOffMainThreadCompositing && gfxPrefs::AsyncPanZoomEnabled() &&
GetScrollingBehavior() == ASYNC_PAN_ZOOM);
return gfxPlatform::UsesOffMainThreadCompositing() &&
gfxPrefs::AsyncPanZoomEnabled() &&
GetScrollingBehavior() == ASYNC_PAN_ZOOM;
}
nsEventStatus

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

@ -277,6 +277,9 @@ gfxPlatform::gfxPlatform()
uint32_t contentMask = BackendTypeBit(BackendType::CAIRO);
InitBackendPrefs(canvasMask, BackendType::CAIRO,
contentMask, BackendType::CAIRO);
mUsesOffMainThreadCompositing = ComputeUsesOffMainThreadCompositing();
mAlreadyShutDownLayersIPC = false;
}
gfxPlatform*
@ -364,17 +367,12 @@ gfxPlatform::Init()
mozilla::gl::GLContext::StaticInit();
#endif
bool useOffMainThreadCompositing = OffMainThreadCompositionRequired() ||
GetPrefLayersOffMainThreadCompositionEnabled();
if (!OffMainThreadCompositionRequired()) {
useOffMainThreadCompositing &= GetPlatform()->SupportsOffMainThreadCompositing();
}
if (useOffMainThreadCompositing && (XRE_GetProcessType() == GeckoProcessType_Default)) {
CompositorParent::StartUp();
if (UsesOffMainThreadCompositing() &&
XRE_GetProcessType() == GeckoProcessType_Default)
{
mozilla::layers::CompositorParent::StartUp();
if (gfxPrefs::AsyncVideoEnabled()) {
ImageBridgeChild::StartUp();
mozilla::layers::ImageBridgeChild::StartUp();
}
#ifdef MOZ_WIDGET_GONK
SharedBufferManagerChild::StartUp();
@ -444,6 +442,9 @@ gfxPlatform::Init()
void
gfxPlatform::Shutdown()
{
MOZ_ASSERT(gPlatform, "gfxPlatform already down!");
MOZ_ASSERT(gPlatform->mAlreadyShutDownLayersIPC, "ShutdownLayersIPC should have been called before this point!");
// These may be called before the corresponding subsystems have actually
// started up. That's OK, they can handle it.
gfxFontCache::Shutdown();
@ -506,6 +507,25 @@ gfxPlatform::Shutdown()
gPlatform = nullptr;
}
/* static */ void
gfxPlatform::ShutdownLayersIPC()
{
MOZ_ASSERT(!gPlatform->mAlreadyShutDownLayersIPC);
if (UsesOffMainThreadCompositing() &&
XRE_GetProcessType() == GeckoProcessType_Default)
{
// This must happen after the shutdown of media and widgets, which
// are triggered by the NS_XPCOM_SHUTDOWN_OBSERVER_ID notification.
layers::ImageBridgeChild::ShutDown();
#ifdef MOZ_WIDGET_GONK
layers::SharedBufferManagerChild::ShutDown();
#endif
layers::CompositorParent::ShutDown();
}
gPlatform->mAlreadyShutDownLayersIPC = true;
}
gfxPlatform::~gfxPlatform()
{
mScreenReferenceSurface = nullptr;
@ -532,7 +552,6 @@ gfxPlatform::~gfxPlatform()
bool
gfxPlatform::PreferMemoryOverShmem() const {
MOZ_ASSERT(!CompositorParent::IsInCompositorThread());
return mLayersPreferMemoryOverShmem;
}
@ -1542,9 +1561,7 @@ gfxPlatform::GetBackendPref(const char* aBackendPrefName, uint32_t &aBackendBitm
bool
gfxPlatform::OffMainThreadCompositingEnabled()
{
return XRE_GetProcessType() == GeckoProcessType_Default ?
CompositorParent::CompositorLoop() != nullptr :
CompositorChild::ChildProcessHasCompositor();
return UsesOffMainThreadCompositing();
}
eCMSMode
@ -2008,27 +2025,6 @@ InitLayersAccelerationPrefs()
}
}
bool
gfxPlatform::GetPrefLayersOffMainThreadCompositionEnabled()
{
InitLayersAccelerationPrefs();
return gfxPrefs::LayersOffMainThreadCompositionEnabled() ||
gfxPrefs::LayersOffMainThreadCompositionForceEnabled() ||
gfxPrefs::LayersOffMainThreadCompositionTestingEnabled();
}
bool gfxPlatform::OffMainThreadCompositionRequired()
{
InitLayersAccelerationPrefs();
#if defined(MOZ_WIDGET_GTK) && defined(NIGHTLY_BUILD)
// Linux users who chose OpenGL are being grandfathered in to OMTC
return sPrefBrowserTabsRemoteAutostart ||
gfxPrefs::LayersAccelerationForceEnabled();
#else
return sPrefBrowserTabsRemoteAutostart;
#endif
}
bool
gfxPlatform::CanUseDirect3D9()
{
@ -2075,3 +2071,25 @@ gfxPlatform::GetScaledFontForFontWithCairoSkia(DrawTarget* aTarget, gfxFont* aFo
return nullptr;
}
bool
gfxPlatform::ComputeUsesOffMainThreadCompositing()
{
InitLayersAccelerationPrefs();
bool result =
sPrefBrowserTabsRemoteAutostart ||
gfxPrefs::LayersOffMainThreadCompositionEnabled() ||
gfxPrefs::LayersOffMainThreadCompositionForceEnabled() ||
gfxPrefs::LayersOffMainThreadCompositionTestingEnabled();
#if defined(MOZ_WIDGET_GTK) && defined(NIGHTLY_BUILD)
// Linux users who chose OpenGL are being grandfathered in to OMTC
result |=
gfxPrefs::LayersAccelerationForceEnabled() ||
PR_GetEnv("MOZ_USE_OMTC") ||
PR_GetEnv("MOZ_OMTC_ENABLED"); // yeah, these two env vars do the same thing.
// I'm told that one of them is enabled on some test slaves config.
// so be slightly careful if you think you can
// remove one of them.
#endif
return result;
}

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

@ -170,6 +170,8 @@ public:
*/
static void Shutdown();
static void ShutdownLayersIPC();
/**
* Create an offscreen surface of the given dimensions
* and image format.
@ -433,16 +435,9 @@ public:
static bool OffMainThreadCompositingEnabled();
/** Use gfxPlatform::GetPref* methods instead of direct calls to Preferences
* to get the values for layers preferences. These will only be evaluated
* only once, and remain the same until restart.
*/
static bool GetPrefLayersOffMainThreadCompositionEnabled();
static bool CanUseDirect3D9();
static bool CanUseDirect3D11();
static bool OffMainThreadCompositionRequired();
/**
* Is it possible to use buffer rotation. Note that these
* check the preference, but also allow for the override to
@ -549,6 +544,10 @@ public:
virtual bool IsInGonkEmulator() const { return false; }
static bool UsesOffMainThreadCompositing() {
return GetPlatform()->mUsesOffMainThreadCompositing;
}
protected:
gfxPlatform();
virtual ~gfxPlatform();
@ -618,6 +617,13 @@ protected:
// max number of entries in word cache
int32_t mWordCacheMaxEntries;
// Whether we use OMTC/OMPC (as opposed to main-thread compositing)
bool mUsesOffMainThreadCompositing;
// Whether ShutdownLayersIPC has alrady been called. Used to enforce that
// it is called before Shutdown.
bool mAlreadyShutDownLayersIPC;
private:
/**
* Start up Thebes.
@ -632,7 +638,7 @@ private:
virtual void GetPlatformCMSOutputProfile(void *&mem, size_t &size);
virtual bool SupportsOffMainThreadCompositing() { return true; }
bool ComputeUsesOffMainThreadCompositing();
nsRefPtr<gfxASurface> mScreenReferenceSurface;
mozilla::RefPtr<mozilla::gfx::DrawTarget> mScreenReferenceDrawTarget;

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

@ -252,18 +252,6 @@ gfxPlatformGtk::GetScreenDepth() const
return sDepth;
}
bool
gfxPlatformGtk::SupportsOffMainThreadCompositing()
{
// Nightly builds have OMTC support by default for Electrolysis testing.
#if defined(MOZ_X11) && !defined(NIGHTLY_BUILD)
return (PR_GetEnv("MOZ_USE_OMTC") != nullptr) ||
(PR_GetEnv("MOZ_OMTC_ENABLED") != nullptr);
#else
return true;
#endif
}
void
gfxPlatformGtk::GetPlatformCMSOutputProfile(void *&mem, size_t &size)
{

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

@ -98,7 +98,6 @@ protected:
private:
virtual void GetPlatformCMSOutputProfile(void *&mem, size_t &size);
virtual bool SupportsOffMainThreadCompositing();
#ifdef MOZ_X11
static bool sUseXRender;
#endif

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

@ -435,12 +435,6 @@ gfxPlatformMac::UseAcceleratedCanvas()
return nsCocoaFeatures::OnLionOrLater() && Preferences::GetBool("gfx.canvas.azure.accelerated", false);
}
bool
gfxPlatformMac::SupportsOffMainThreadCompositing()
{
return true;
}
void
gfxPlatformMac::GetPlatformCMSOutputProfile(void* &mem, size_t &size)
{

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

@ -72,8 +72,6 @@ public:
private:
virtual void GetPlatformCMSOutputProfile(void* &mem, size_t &size);
virtual bool SupportsOffMainThreadCompositing();
// read in the pref value for the lower threshold on font anti-aliasing
static uint32_t ReadAntiAliasingThreshold();

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

@ -160,17 +160,6 @@ gfxQtPlatform::MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
aFontData, aLength);
}
bool
gfxQtPlatform::SupportsOffMainThreadCompositing()
{
#if defined(MOZ_X11) && !defined(NIGHTLY_BUILD)
return (PR_GetEnv("MOZ_USE_OMTC") != nullptr) ||
(PR_GetEnv("MOZ_OMTC_ENABLED") != nullptr);
#else
return true;
#endif
}
bool
gfxQtPlatform::IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags)
{

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

@ -83,8 +83,6 @@ public:
virtual int GetScreenDepth() const MOZ_OVERRIDE;
virtual bool SupportsOffMainThreadCompositing() MOZ_OVERRIDE;
protected:
static gfxFontconfigUtils *sFontconfigUtils;

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

@ -1380,8 +1380,8 @@ gfxWindowsPlatform::GetD3D9DeviceManager()
// We should only create the d3d9 device on the compositor thread
// or we don't have a compositor thread.
if (!mDeviceManager &&
(CompositorParent::IsInCompositorThread() ||
!CompositorParent::CompositorLoop())) {
(!gfxPlatform::UsesOffMainThreadCompositing() ||
CompositorParent::IsInCompositorThread())) {
mDeviceManager = new DeviceManagerD3D9();
if (!mDeviceManager->Init()) {
NS_WARNING("Could not initialise device manager");

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

@ -71,7 +71,6 @@
#include "nsDOMBlobBuilder.h"
#include "nsDOMFileReader.h"
#include "gfxPlatform.h"
#include "nsFormData.h"
#include "nsHostObjectProtocolHandler.h"
#include "nsHostObjectURI.h"

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

@ -737,7 +737,7 @@ RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader,
}
}
if (CompositorParent::CompositorLoop()) {
if (gfxPlatform::UsesOffMainThreadCompositing()) {
// Our remote frame will push layers updates to the compositor,
// and we'll keep an indirect reference to that tree.
*aId = mLayersId = CompositorParent::AllocateLayerTreeId();

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

@ -998,7 +998,8 @@ MetroWidget::ShouldUseOffMainThreadCompositing()
return false;
}
// toolkit or test widgets can't use omtc, they don't have ICoreWindow.
return (CompositorParent::CompositorLoop() && mWindowType == eWindowType_toplevel);
return gfxPlatform::UsesOffMainThreadCompositing() &&
mWindowType == eWindowType_toplevel;
}
bool
@ -1008,7 +1009,8 @@ MetroWidget::ShouldUseMainThreadD3D10Manager()
if (!mView) {
return false;
}
return (!CompositorParent::CompositorLoop() && mWindowType == eWindowType_toplevel);
return !gfxPlatform::UsesOffMainThreadCompositing() &&
mWindowType == eWindowType_toplevel;
}
bool

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

@ -888,6 +888,9 @@ CheckForBasicBackends(nsTArray<LayersBackend>& aHints)
void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
{
MOZ_ASSERT(gfxPlatform::UsesOffMainThreadCompositing(),
"This function assumes OMTC");
// Recreating this is tricky, as we may still have an old and we need
// to make sure it's properly destroyed by calling DestroyCompositor!
@ -946,7 +949,7 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
bool nsBaseWidget::ShouldUseOffMainThreadCompositing()
{
return CompositorParent::CompositorLoop();
return gfxPlatform::UsesOffMainThreadCompositing();
}
LayerManager* nsBaseWidget::GetLayerManager(PLayerTransactionChild* aShadowManager,

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

@ -149,6 +149,8 @@ extern nsresult nsStringInputStreamConstructor(nsISupports *, REFNSIID, void **)
#include "jsapi.h"
#include "gfxPlatform.h"
using namespace mozilla;
using base::AtExitManager;
using mozilla::ipc::BrowserProcessSubThread;
@ -797,13 +799,6 @@ ShutdownXPCOM(nsIServiceManager* servMgr)
}
}
// This must happen after the shutdown of media and widgets, which
// are triggered by the NS_XPCOM_SHUTDOWN_OBSERVER_ID notification.
layers::ImageBridgeChild::ShutDown();
#ifdef MOZ_WIDGET_GONK
layers::SharedBufferManagerChild::ShutDown();
#endif
NS_ProcessPendingEvents(thread);
mozilla::scache::StartupCache::DeleteSingleton();
if (observerService)
@ -811,7 +806,9 @@ ShutdownXPCOM(nsIServiceManager* servMgr)
NotifyObservers(nullptr, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID,
nullptr);
layers::CompositorParent::ShutDown();
// This must happen after the shutdown of media and widgets, which
// are triggered by the NS_XPCOM_SHUTDOWN_OBSERVER_ID notification.
gfxPlatform::ShutdownLayersIPC();
gXPCOMThreadsShutDown = true;
NS_ProcessPendingEvents(thread);