Refactor acceleration pref initialization. (bug 1254899 part 2, r=jrmuizel)
☠☠ backed out by df82a3088812 ☠ ☠
authorDavid Anderson <danderson@mozilla.com>
Wed, 27 Apr 2016 22:54:24 -0700
changeset 295162 f2056259d227bb92c7712e84f61c90f65d502fba
parent 295161 b805df0c8296d6bf85d88e2bd702a790b3bf676d
child 295163 2de214d5d1e098230aa00d80813615104a27f067
push id75834
push userdanderson@mozilla.com
push dateThu, 28 Apr 2016 05:58:25 +0000
treeherdermozilla-inbound@f749ee384012 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1254899
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Refactor acceleration pref initialization. (bug 1254899 part 2, r=jrmuizel)
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
gfx/thebes/gfxWindowsPlatform.cpp
gfx/thebes/gfxWindowsPlatform.h
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -169,18 +169,16 @@ static bool gCMSInitialized = false;
 static eCMSMode gCMSMode = eCMSMode_Off;
 
 static void ShutdownCMS();
 
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/SourceSurfaceCairo.h"
 using namespace mozilla::gfx;
 
-void InitLayersAccelerationPrefs();
-
 /* Class to listen for pref changes so that chrome code can dynamically
    force sRGB as an output profile. See Bug #452125. */
 class SRGBOverrideObserver final : public nsIObserver,
                                    public nsSupportsWeakReference
 {
     ~SRGBOverrideObserver() {}
 public:
     NS_DECL_ISUPPORTS
@@ -652,26 +650,26 @@ gfxPlatform::Init()
     gPlatform = new gfxPlatformGtk;
 #elif defined(MOZ_WIDGET_QT)
     gPlatform = new gfxQtPlatform;
 #elif defined(ANDROID)
     gPlatform = new gfxAndroidPlatform;
 #else
     #error "No gfxPlatform implementation available"
 #endif
+    gPlatform->InitAcceleration();
 
 #ifdef USE_SKIA
     SkGraphics::Init();
 #endif
 
 #ifdef MOZ_GL_DEBUG
     GLContext::StaticInit();
 #endif
 
-    InitLayersAccelerationPrefs();
     InitLayersIPC();
 
     gPlatform->PopulateScreenInfo();
     gPlatform->ComputeTileSize();
 
     nsresult rv;
 
     bool usePlatformFontList = true;
@@ -2057,17 +2055,17 @@ bool gANGLESupportsD3D11 = false;
 static bool sLayersSupportsHardwareVideoDecoding = false;
 static bool sLayersHardwareVideoDecodingFailed = false;
 static bool sBufferRotationCheckPref = true;
 static bool sPrefBrowserTabsRemoteAutostart = false;
 
 static bool sLayersAccelerationPrefsInitialized = false;
 
 void
-InitLayersAccelerationPrefs()
+gfxPlatform::InitAcceleration()
 {
   if (sLayersAccelerationPrefsInitialized) {
     return;
   }
 
   // If this is called for the first time on a non-main thread, we're screwed.
   // At the moment there's no explicit guarantee that the main thread calls
   // this before the compositor thread, but let's at least make the assumption
@@ -2223,17 +2221,17 @@ gfxPlatform::GetScaledFontForFontWithCai
 
 /* static */ bool
 gfxPlatform::UsesOffMainThreadCompositing()
 {
   static bool firstTime = true;
   static bool result = false;
 
   if (firstTime) {
-    InitLayersAccelerationPrefs();
+    MOZ_ASSERT(sLayersAccelerationPrefsInitialized);
     result =
       sPrefBrowserTabsRemoteAutostart ||
       !gfxPrefs::LayersOffMainThreadCompositionForceDisabled();
 #if defined(MOZ_WIDGET_GTK)
     // Linux users who chose OpenGL are being grandfathered in to OMTC
     result |= gfxPrefs::LayersAccelerationForceEnabled();
 
 #endif
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -660,16 +660,18 @@ public:
     uint64_t GetDeviceCounter() const {
       return mDeviceCounter;
     }
 
 protected:
     gfxPlatform();
     virtual ~gfxPlatform();
 
+    virtual void InitAcceleration();
+
     /**
      * Initialized hardware vsync based on each platform.
      */
     virtual already_AddRefed<mozilla::gfx::VsyncSource> CreateHardwareVsyncSource();
 
     // Returns whether or not layers should be accelerated by default on this platform.
     virtual bool AccelerateLayersByDefault();
 
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -384,29 +384,16 @@ gfxWindowsPlatform::gfxWindowsPlatform()
 
   /* 
    * Initialize COM 
    */ 
   CoInitialize(nullptr); 
 
   RegisterStrongMemoryReporter(new GfxD2DVramReporter());
 
-  // Set up the D3D11 feature levels we can ask for.
-  if (IsWin8OrLater()) {
-    mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_11_1);
-  }
-  mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_11_0);
-  mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_10_1);
-  mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_10_0);
-  mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_9_3);
-
-  UpdateDeviceInitData();
-  InitializeDevices();
-  UpdateRenderMode();
-
   RegisterStrongMemoryReporter(new GPUAdapterReporter());
   RegisterStrongMemoryReporter(new D3D11TextureReporter());
   RegisterStrongMemoryReporter(new D3D9TextureReporter());
   RegisterStrongMemoryReporter(new D3D9SharedTextureReporter());
 }
 
 gfxWindowsPlatform::~gfxWindowsPlatform()
 {
@@ -420,16 +407,35 @@ gfxWindowsPlatform::~gfxWindowsPlatform(
   mAdapter = nullptr;
 
   /* 
    * Uninitialize COM 
    */ 
   CoUninitialize();
 }
 
+void
+gfxWindowsPlatform::InitAcceleration()
+{
+  gfxPlatform::InitAcceleration();
+
+  // Set up the D3D11 feature levels we can ask for.
+  if (IsWin8OrLater()) {
+    mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_11_1);
+  }
+  mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_11_0);
+  mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_10_1);
+  mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_10_0);
+  mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_9_3);
+
+  UpdateDeviceInitData();
+  InitializeDevices();
+  UpdateRenderMode();
+}
+
 bool
 gfxWindowsPlatform::CanUseHardwareVideoDecoding()
 {
   if (!gfxPrefs::LayersPreferD3D9() && !mCompositorD3D11TextureSharingWorks) {
     return false;
   }
   return !IsWARP() && gfxPlatform::CanUseHardwareVideoDecoding();
 }
@@ -2038,18 +2044,18 @@ gfxWindowsPlatform::AttemptD3D11DeviceCr
     MutexAutoLock lock(mDeviceLock);
     mD3D11Device = device;
   }
 
   // Only test this when not using WARP since it can fail and cause
   // GetDeviceRemovedReason to return weird values.
   mCompositorD3D11TextureSharingWorks = ::DoesD3D11TextureSharingWork(mD3D11Device);
 
-  if (!mCompositorD3D11TextureSharingWorks || !DoesRenderTargetViewNeedsRecreating(mD3D11Device)) {
-      gANGLESupportsD3D11 = false;
+  if (!mCompositorD3D11TextureSharingWorks || DoesRenderTargetViewNeedsRecreating(mD3D11Device)) {
+    gANGLESupportsD3D11 = false;
   }
 
   mD3D11Device->SetExceptionMode(0);
   mIsWARP = false;
   return FeatureStatus::Available;
 }
 
 bool
--- a/gfx/thebes/gfxWindowsPlatform.h
+++ b/gfx/thebes/gfxWindowsPlatform.h
@@ -275,16 +275,17 @@ protected:
 protected:
     RenderMode mRenderMode;
 
     int8_t mUseClearTypeForDownloadableFonts;
     int8_t mUseClearTypeAlways;
 
 private:
     void Init();
+    void InitAcceleration() override;
 
     void InitializeDevices();
     void InitializeD3D11();
     void InitializeD2D();
     bool InitDWriteSupport();
 
     void DisableD2D();