Force OMTC on when enabling multi-process tabs (bug 897502, r=ncameron).

This commit is contained in:
David Anderson 2013-08-19 00:13:32 -07:00
parent fd57425fcc
commit 6ef84f269e
5 changed files with 30 additions and 11 deletions

View File

@ -362,17 +362,18 @@ gfxPlatform::Init()
mozilla::gl::GLContext::StaticInit();
#endif
bool useOffMainThreadCompositing = GetPrefLayersOffMainThreadCompositionEnabled() ||
Preferences::GetBool("browser.tabs.remote", false);
useOffMainThreadCompositing &= GetPlatform()->SupportsOffMainThreadCompositing();
bool useOffMainThreadCompositing = OffMainThreadCompositionRequired() ||
GetPrefLayersOffMainThreadCompositionEnabled();
if (useOffMainThreadCompositing && (XRE_GetProcessType() ==
GeckoProcessType_Default)) {
if (!OffMainThreadCompositionRequired()) {
useOffMainThreadCompositing &= GetPlatform()->SupportsOffMainThreadCompositing();
}
if (useOffMainThreadCompositing && (XRE_GetProcessType() == GeckoProcessType_Default)) {
CompositorParent::StartUp();
if (Preferences::GetBool("layers.async-video.enabled",false)) {
if (Preferences::GetBool("layers.async-video.enabled", false)) {
ImageBridgeChild::StartUp();
}
}
nsresult rv;
@ -1886,6 +1887,7 @@ static bool sLayersSupportsD3D9 = true;
static int sPrefLayoutFrameRate = -1;
static bool sBufferRotationEnabled = false;
static bool sComponentAlphaEnabled = true;
static bool sPrefBrowserTabsRemote = false;
static bool sLayersAccelerationPrefsInitialized = false;
@ -1904,6 +1906,7 @@ InitLayersAccelerationPrefs()
sPrefLayoutFrameRate = Preferences::GetInt("layout.frame_rate", -1);
sBufferRotationEnabled = Preferences::GetBool("layers.bufferrotation.enabled", true);
sComponentAlphaEnabled = Preferences::GetBool("layers.componentalpha.enabled", true);
sPrefBrowserTabsRemote = Preferences::GetBool("browser.tabs.remote", false);
nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
if (gfxInfo) {
@ -1942,6 +1945,12 @@ gfxPlatform::GetPrefLayersAccelerationForceEnabled()
return sPrefLayersAccelerationForceEnabled;
}
bool gfxPlatform::OffMainThreadCompositionRequired()
{
InitLayersAccelerationPrefs();
return sPrefBrowserTabsRemote;
}
bool
gfxPlatform::GetPrefLayersAccelerationDisabled()
{

View File

@ -487,6 +487,8 @@ public:
static bool CanUseDirect3D9();
static int GetPrefLayoutFrameRate();
static bool OffMainThreadCompositionRequired();
/**
* Is it possible to use buffer rotation
*/

View File

@ -502,7 +502,8 @@ gfxPlatformGtk::GetScreenDepth() const
bool
gfxPlatformGtk::SupportsOffMainThreadCompositing()
{
#ifdef MOZ_X11
// 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

View File

@ -3370,11 +3370,19 @@ XREMain::XRE_mainStartup(bool* aExitFlag)
// (called inside gdk_display_open). This is a requirement for off main tread compositing.
// This is done only on X11 platforms if the environment variable MOZ_USE_OMTC is set so
// as to avoid overhead when omtc is not used.
//
// On nightly builds, we call this by default to enable OMTC for Electrolysis testing. On
// aurora, beta, and release builds, there is a small tpaint regression from enabling this
// call, so it sits behind an environment variable.
//
// An environment variable is used instead of a pref on X11 platforms because we start having
// access to prefs long after the first call to XOpenDisplay which is hard to change due to
// interdependencies in the initialization.
# ifndef NIGHTLY_BUILD
if (PR_GetEnv("MOZ_USE_OMTC") ||
PR_GetEnv("MOZ_OMTC_ENABLED")) {
PR_GetEnv("MOZ_OMTC_ENABLED"))
# endif
{
XInitThreads();
}
#endif

View File

@ -1534,8 +1534,7 @@ nsChildView::ComputeShouldAccelerate(bool aDefault)
bool
nsChildView::ShouldUseOffMainThreadCompositing()
{
// Don't use OMTC (which requires OpenGL) for transparent windows or for
// popup windows.
// Don't use OMTC for transparent windows or for popup windows.
if (!mView || ![[mView window] isOpaque] ||
[[mView window] isKindOfClass:[PopupWindow class]])
return false;