Bug 1309200 - Add gfx::Factory::GetDefaultSoftwareBackend. r=Bas
☠☠ backed out by 6f5c85e2f3f8 ☠ ☠
authorNicolas Silva <nsilva@mozilla.com>
Fri, 28 Oct 2016 18:27:37 +0200
changeset 320023 b5ad7d04ed432709e739174b6f9671e2945b973c
parent 320022 1563a66b64d8791070bd6b6317187d76533a1466
child 320024 b05eb6590d71d53d564534cb0f3c8bcf08b826cf
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs1309200
milestone52.0a1
Bug 1309200 - Add gfx::Factory::GetDefaultSoftwareBackend. r=Bas
gfx/2d/2D.h
gfx/2d/Factory.cpp
gfx/ipc/GPUParent.cpp
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -1291,21 +1291,23 @@ struct TileSet
   Tile* mTiles;
   size_t mTileCount;
 };
 
 struct Config {
   LogForwarder* mLogForwarder;
   int32_t mMaxTextureSize;
   int32_t mMaxAllocSize;
+  BackendType mDefaultSoftwareBackend;
 
   Config()
   : mLogForwarder(nullptr)
   , mMaxTextureSize(8192)
   , mMaxAllocSize(52000000)
+  , mDefaultSoftwareBackend(BackendType::CAIRO)
   {}
 };
 
 class GFX2D_API Factory
 {
 public:
   static void Init(const Config& aConfig);
   static void ShutDown();
@@ -1433,16 +1435,18 @@ public:
 
   static already_AddRefed<DrawEventRecorder>
     CreateEventRecorderForFile(const char *aFilename);
 
   static void SetGlobalEventRecorder(DrawEventRecorder *aRecorder);
 
   static uint32_t GetMaxSurfaceSize(BackendType aType);
 
+  static BackendType GetDefaultSoftwareBackend();
+
   static LogForwarder* GetLogForwarder() { return sConfig ? sConfig->mLogForwarder : nullptr; }
 
 private:
   static Config* sConfig;
 public:
 
 #ifdef USE_SKIA_GPU
   static already_AddRefed<DrawTarget>
--- a/gfx/2d/Factory.cpp
+++ b/gfx/2d/Factory.cpp
@@ -212,16 +212,22 @@ Factory::HasSSE2()
     sDetectionState = HasCPUIDBit(1u, edx, (1u<<26)) ? HAS_SSE2 : NO_SSE2;
   }
   return sDetectionState == HAS_SSE2;
 #else
   return false;
 #endif
 }
 
+BackendType
+Factory::GetDefaultSoftwareBackend()
+{
+  return sConfig ? sConfig->mDefaultSoftwareBackend : BackendType::CAIRO;
+}
+
 // If the size is "reasonable", we want gfxCriticalError to assert, so
 // this is the option set up for it.
 inline int LoggerOptionsBasedOnSize(const IntSize& aSize)
 {
   return CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(aSize));
 }
 
 bool
--- a/gfx/ipc/GPUParent.cpp
+++ b/gfx/ipc/GPUParent.cpp
@@ -87,17 +87,17 @@ GPUParent::Init(base::ProcessId aParentP
 #endif
 
   // Ensure gfxPrefs are initialized.
   gfxPrefs::GetSingleton();
   gfxConfig::Init();
   gfxVars::Initialize();
   gfxPlatform::InitNullMetadata();
   // Ensure our Factory is initialised, mainly for gfx logging to work.
-  gfxPlatform::InitMoz2DLogging();
+  gfxPlatform::InitMoz2D();
 #if defined(XP_WIN)
   DeviceManagerDx::Init();
   DeviceManagerD3D9::Init();
 #endif
   if (NS_FAILED(NS_InitMinimalXPCOM())) {
     return false;
   }
   CompositorThreadHolder::Start();
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -648,17 +648,17 @@ gfxPlatform::Init()
       forcedPrefs.AppendPrintf("-T%d%d%d%d) ",
                                gfxPrefs::AndroidRGB16Force(),
                                gfxPrefs::CanvasAzureAccelerated(),
                                gfxPrefs::DisableGralloc(),
                                gfxPrefs::ForceShmemTiles());
       ScopedGfxFeatureReporter::AppNote(forcedPrefs);
     }
 
-    InitMoz2DLogging();
+    InitMoz2D();
 
     gGfxPlatformPrefsLock = new Mutex("gfxPlatform::gGfxPlatformPrefsLock");
 
     /* Initialize the GfxInfo service.
      * Note: we can't call functions on GfxInfo that depend
      * on gPlatform until after it has been initialized
      * below. GfxInfo initialization annotates our
      * crash reports so we want to do it before
@@ -788,25 +788,26 @@ gfxPlatform::Init()
     InitOpenGLConfig();
 
     if (obs) {
       obs->NotifyObservers(nullptr, "gfx-features-ready", nullptr);
     }
 }
 
 /* static */ void
-gfxPlatform::InitMoz2DLogging()
+gfxPlatform::InitMoz2D()
 {
     auto fwd = new CrashStatsLogForwarder("GraphicsCriticalError");
     fwd->SetCircularBufferSize(gfxPrefs::GfxLoggingCrashLength());
 
     mozilla::gfx::Config cfg;
     cfg.mLogForwarder = fwd;
     cfg.mMaxTextureSize = gfxPrefs::MaxTextureSize();
     cfg.mMaxAllocSize = gfxPrefs::MaxAllocSize();
+    cfg.mDefaultSoftwareBackend = gPlatform->GetSoftwareBackend();
 
     gfx::Factory::Init(cfg);
 }
 
 static bool sLayersIPCIsUp = false;
 
 /* static */ void
 gfxPlatform::InitNullMetadata()
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -173,17 +173,17 @@ public:
     static void InitLayersIPC();
     static void ShutdownLayersIPC();
 
     /**
      * Initialize ScrollMetadata statics. Does not depend on gfxPlatform.
      */
     static void InitNullMetadata();
 
-    static void InitMoz2DLogging();
+    static void InitMoz2D();
 
     /**
      * Create an offscreen surface of the given dimensions
      * and image format.
      */
     virtual already_AddRefed<gfxASurface>
       CreateOffscreenSurface(const IntSize& aSize,
                              gfxImageFormat aFormat) = 0;