diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 594a34b23dd5..f37ec589fa8e 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -300,23 +300,6 @@ gfxPlatform::Init() sCmapDataLog = PR_NewLogModule("cmapdata");; #endif - bool useOffMainThreadCompositing = false; - useOffMainThreadCompositing = GetPrefLayersOffMainThreadCompositionEnabled() || - Preferences::GetBool("browser.tabs.remote", false); -#ifdef MOZ_X11 - useOffMainThreadCompositing &= (PR_GetEnv("MOZ_USE_OMTC") != NULL) || - (PR_GetEnv("MOZ_OMTC_ENABLED") != NULL); -#endif - - if (useOffMainThreadCompositing && (XRE_GetProcessType() == - GeckoProcessType_Default)) { - CompositorParent::StartUp(); - if (Preferences::GetBool("layers.async-video.enabled",false)) { - ImageBridgeChild::StartUp(); - } - - } - /* Initialize the GfxInfo service. * Note: we can't call functions on GfxInfo that depend * on gPlatform until after it has been initialized @@ -348,6 +331,19 @@ gfxPlatform::Init() mozilla::gl::GLContext::StaticInit(); #endif + bool useOffMainThreadCompositing = GetPrefLayersOffMainThreadCompositionEnabled() || + Preferences::GetBool("browser.tabs.remote", false); + useOffMainThreadCompositing &= GetPlatform()->SupportsOffMainThreadCompositing(); + + if (useOffMainThreadCompositing && (XRE_GetProcessType() == + GeckoProcessType_Default)) { + CompositorParent::StartUp(); + if (Preferences::GetBool("layers.async-video.enabled",false)) { + ImageBridgeChild::StartUp(); + } + + } + nsresult rv; #if defined(XP_MACOSX) || defined(XP_WIN) || defined(ANDROID) // temporary, until this is implemented on others @@ -1815,6 +1811,7 @@ gfxPlatform::GetOrientationSyncMillis() const */ static bool sPrefLayersOffMainThreadCompositionEnabled = false; static bool sPrefLayersOffMainThreadCompositionTestingEnabled = false; +static bool sPrefLayersOffMainThreadCompositionForceEnabled = false; static bool sPrefLayersAccelerationForceEnabled = false; static bool sPrefLayersAccelerationDisabled = false; static bool sPrefLayersPreferOpenGL = false; @@ -1827,6 +1824,7 @@ void InitLayersAccelerationPrefs() { sPrefLayersOffMainThreadCompositionEnabled = Preferences::GetBool("layers.offmainthreadcomposition.enabled", false); sPrefLayersOffMainThreadCompositionTestingEnabled = Preferences::GetBool("layers.offmainthreadcomposition.testing.enabled", false); + sPrefLayersOffMainThreadCompositionForceEnabled = Preferences::GetBool("layers.offmainthreadcomposition.force-enabled", false); sPrefLayersAccelerationForceEnabled = Preferences::GetBool("layers.acceleration.force-enabled", false) || Preferences::GetBool("browser.tabs.remote", false); sPrefLayersAccelerationDisabled = Preferences::GetBool("layers.acceleration.disabled", false); @@ -1841,9 +1839,16 @@ bool gfxPlatform::GetPrefLayersOffMainThreadCompositionEnabled() { InitLayersAccelerationPrefs(); return sPrefLayersOffMainThreadCompositionEnabled || + sPrefLayersOffMainThreadCompositionForceEnabled || sPrefLayersOffMainThreadCompositionTestingEnabled; } +bool gfxPlatform::GetPrefLayersOffMainThreadCompositionForceEnabled() +{ + InitLayersAccelerationPrefs(); + return sPrefLayersOffMainThreadCompositionForceEnabled; +} + bool gfxPlatform::GetPrefLayersAccelerationForceEnabled() { InitLayersAccelerationPrefs(); diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 386990fcb0b9..f01e561ff76f 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -462,6 +462,7 @@ public: * only once, and remain the same until restart. */ static bool GetPrefLayersOffMainThreadCompositionEnabled(); + static bool GetPrefLayersOffMainThreadCompositionForceEnabled(); static bool GetPrefLayersAccelerationForceEnabled(); static bool GetPrefLayersAccelerationDisabled(); static bool GetPrefLayersPreferOpenGL(); @@ -629,6 +630,8 @@ private: virtual qcms_profile* GetPlatformCMSOutputProfile(); + virtual bool SupportsOffMainThreadCompositing() { return true; } + nsRefPtr mScreenReferenceSurface; nsTArray mCJKPrefLangs; nsCOMPtr mSRGBOverrideObserver; diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index eced3d6e765c..106de1c2762f 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -9,6 +9,7 @@ #endif #include "gfxPlatformGtk.h" +#include "prenv.h" #include "nsUnicharUtils.h" #include "nsUnicodeProperties.h" @@ -498,6 +499,17 @@ gfxPlatformGtk::GetScreenDepth() const return sDepth; } +bool +gfxPlatformGtk::SupportsOffMainThreadCompositing() +{ +#ifdef MOZ_X11 + return (PR_GetEnv("MOZ_USE_OMTC") != nullptr) || + (PR_GetEnv("MOZ_OMTC_ENABLED") != nullptr); +#else + return true; +#endif +} + qcms_profile * gfxPlatformGtk::GetPlatformCMSOutputProfile() { diff --git a/gfx/thebes/gfxPlatformGtk.h b/gfx/thebes/gfxPlatformGtk.h index a536c934a84e..57591511d349 100644 --- a/gfx/thebes/gfxPlatformGtk.h +++ b/gfx/thebes/gfxPlatformGtk.h @@ -130,6 +130,8 @@ protected: private: virtual qcms_profile *GetPlatformCMSOutputProfile(); + + virtual bool SupportsOffMainThreadCompositing(); #ifdef MOZ_X11 static bool sUseXRender; #endif diff --git a/gfx/thebes/gfxPlatformMac.cpp b/gfx/thebes/gfxPlatformMac.cpp index b482129deb84..12375d21f4da 100644 --- a/gfx/thebes/gfxPlatformMac.cpp +++ b/gfx/thebes/gfxPlatformMac.cpp @@ -431,6 +431,17 @@ gfxPlatformMac::UseAcceleratedCanvas() return OSXVersion() >= 0x1070 && Preferences::GetBool("gfx.canvas.azure.accelerated", false); } +bool +gfxPlatformMac::SupportsOffMainThreadCompositing() +{ + // 10.6.X has crashes on tinderbox with OMTC, so disable it + // for now. + if (OSXVersion() >= 0x1070) { + return true; + } + return GetPrefLayersOffMainThreadCompositionForceEnabled(); +} + qcms_profile * gfxPlatformMac::GetPlatformCMSOutputProfile() { diff --git a/gfx/thebes/gfxPlatformMac.h b/gfx/thebes/gfxPlatformMac.h index ebf961d80bd7..a9e34abb4f46 100644 --- a/gfx/thebes/gfxPlatformMac.h +++ b/gfx/thebes/gfxPlatformMac.h @@ -89,6 +89,8 @@ public: private: virtual qcms_profile* GetPlatformCMSOutputProfile(); + virtual bool SupportsOffMainThreadCompositing(); + // read in the pref value for the lower threshold on font anti-aliasing static uint32_t ReadAntiAliasingThreshold(); diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 77ae3124e3f5..15074ad058ee 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -4015,7 +4015,11 @@ pref("layers.acceleration.draw-fps", false); pref("layers.draw-borders", false); +#ifdef XP_MACOSX +pref("layers.offmainthreadcomposition.enabled", true); +#else pref("layers.offmainthreadcomposition.enabled", false); +#endif // same effect as layers.offmainthreadcomposition.enabled, but specifically for // use with tests. pref("layers.offmainthreadcomposition.testing.enabled", false);