Bug 1316931 - Put DX interop2 status into gfxVars. r?dvander,jgilbert draft
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 14 Nov 2016 17:13:40 -0500
changeset 438621 3247148923846b4d653c1f2bce12e96cf63b68c1
parent 438550 71fd23fa0803a548b6e571aa25d0533a06cd0421
child 536973 9c3b6c04c7fcf8b5e30eae5e5424acba051e56bc
push id35791
push userkgupta@mozilla.com
push dateMon, 14 Nov 2016 22:14:06 +0000
reviewersdvander, jgilbert
bugs1316931
milestone53.0a1
Bug 1316931 - Put DX interop2 status into gfxVars. r?dvander,jgilbert This allows the GLContextProviderWGL to be created on the compositor thread, which is something we need for webrender integration. MozReview-Commit-ID: DtBe9nUTdK7
gfx/config/gfxVars.h
gfx/gl/GLContextProviderWGL.cpp
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
gfx/thebes/gfxUtils.cpp
gfx/thebes/gfxUtils.h
--- a/gfx/config/gfxVars.h
+++ b/gfx/config/gfxVars.h
@@ -27,16 +27,17 @@ class gfxVarReceiver;
   _(ContentBackend,             BackendType,      BackendType::NONE)    \
   _(TileSize,                   IntSize,          IntSize(-1, -1))      \
   _(UseXRender,                 bool,             false)                \
   _(OffscreenFormat,            gfxImageFormat,   mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32) \
   _(RequiresAcceleratedGLContextForCompositorOGL, bool, false)          \
   _(CanUseHardwareVideoDecoding, bool,            false)                \
   _(PDMWMFDisableD3D11Dlls,     nsCString,        nsCString())          \
   _(PDMWMFDisableD3D9Dlls,      nsCString,        nsCString())          \
+  _(DXInterop2Blocked,          bool,             false)                \
 
   /* Add new entries above this line. */
 
 // Some graphics settings are computed on the UI process and must be
 // communicated to content and GPU processes. gfxVars helps facilitate
 // this. Its function is similar to gfxPrefs, except rather than hold
 // user preferences, it holds dynamically computed values.
 //
--- a/gfx/gl/GLContextProviderWGL.cpp
+++ b/gfx/gl/GLContextProviderWGL.cpp
@@ -10,16 +10,17 @@
 #include "nsIWidget.h"
 #include "gfxPlatform.h"
 #include "gfxWindowsSurface.h"
 
 #include "gfxCrashReporterUtils.h"
 
 #include "prenv.h"
 
+#include "mozilla/gfx/gfxVars.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/widget/CompositorWidget.h"
 
 namespace mozilla {
 namespace gl {
 
 using namespace mozilla::gfx;
@@ -214,19 +215,17 @@ WGLLibrary::EnsureInitialized()
             }
         }
 
         ////
 
         mHasDXInterop = HasExtension(extString, "WGL_NV_DX_interop");
         mHasDXInterop2 = HasExtension(extString, "WGL_NV_DX_interop2");
 
-        nsCString blocklistId;
-        if (gfxUtils::IsFeatureBlacklisted(nullptr, nsIGfxInfo::FEATURE_DX_INTEROP2,
-                                           &blocklistId) &&
+        if (gfxVars::DXInterop2Blocked() &&
             !gfxPrefs::IgnoreDXInterop2Blacklist())
         {
             mHasDXInterop2 = false;
         }
 
         if (mHasDXInterop || mHasDXInterop2) {
             if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, &dxInteropSymbols[0],
                                               lookupFunc))
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -790,21 +790,38 @@ gfxPlatform::Init()
     if (skiaCacheSize != kDefaultGlyphCacheSize) {
       SkGraphics::SetFontCacheLimit(skiaCacheSize);
     }
 #endif
 
     InitNullMetadata();
     InitOpenGLConfig();
 
+    if (XRE_IsParentProcess()) {
+      gfxVars::SetDXInterop2Blocked(IsDXInterop2Blocked());
+    }
+
     if (obs) {
       obs->NotifyObservers(nullptr, "gfx-features-ready", nullptr);
     }
 }
 
+/* static*/ bool
+gfxPlatform::IsDXInterop2Blocked()
+{
+  nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
+  nsCString blockId;
+  int32_t status;
+  if (!NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DX_INTEROP2,
+                                              blockId, &status))) {
+    return true;
+  }
+  return status != nsIGfxInfo::FEATURE_STATUS_OK;
+}
+
 /* static */ void
 gfxPlatform::InitMoz2DLogging()
 {
     auto fwd = new CrashStatsLogForwarder("GraphicsCriticalError");
     fwd->SetCircularBufferSize(gfxPrefs::GfxLoggingCrashLength());
 
     mozilla::gfx::Config cfg;
     cfg.mLogForwarder = fwd;
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -802,16 +802,18 @@ private:
     /**
      * This uses nsIScreenManager to determine the screen size and color depth
      */
     void PopulateScreenInfo();
 
     void InitCompositorAccelerationPrefs();
     void InitGPUProcessPrefs();
 
+    static bool IsDXInterop2Blocked();
+
     RefPtr<gfxASurface> mScreenReferenceSurface;
     nsCOMPtr<nsIObserver> mSRGBOverrideObserver;
     nsCOMPtr<nsIObserver> mFontPrefsObserver;
     nsCOMPtr<nsIObserver> mMemoryPressureObserver;
 
     // The preferred draw target backend to use for canvas
     mozilla::gfx::BackendType mPreferredCanvasBackend;
     // The fallback draw target backend to use for canvas, if the preferred backend fails
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -1487,35 +1487,16 @@ gfxUtils::ThreadSafeGetFeatureStatus(con
 
     return runnable->GetNSResult();
   }
 
   return gfxInfo->GetFeatureStatus(feature, failureId, status);
 }
 
 /* static */ bool
-gfxUtils::IsFeatureBlacklisted(nsCOMPtr<nsIGfxInfo> gfxInfo, int32_t feature,
-                               nsACString* const out_blacklistId)
-{
-  if (!gfxInfo) {
-    gfxInfo = services::GetGfxInfo();
-  }
-
-  int32_t status;
-  if (!NS_SUCCEEDED(gfxUtils::ThreadSafeGetFeatureStatus(gfxInfo, feature,
-                                                         *out_blacklistId, &status)))
-  {
-    out_blacklistId->AssignLiteral("");
-    return true;
-  }
-
-  return status != nsIGfxInfo::FEATURE_STATUS_OK;
-}
-
-/* static */ bool
 gfxUtils::DumpDisplayList() {
   return gfxPrefs::LayoutDumpDisplayList() ||
          (gfxPrefs::LayoutDumpDisplayListContent() && XRE_IsContentProcess());
 }
 
 FILE *gfxUtils::sDumpPaintFile = stderr;
 
 namespace mozilla {
--- a/gfx/thebes/gfxUtils.h
+++ b/gfx/thebes/gfxUtils.h
@@ -272,21 +272,16 @@ public:
                                    const char16_t* aEncoderOptions,
                                    nsIInputStream** outStream);
 
     static nsresult ThreadSafeGetFeatureStatus(const nsCOMPtr<nsIGfxInfo>& gfxInfo,
                                                int32_t feature,
                                                nsACString& failureId,
                                                int32_t* status);
 
-    // Can pass `nullptr` for gfxInfo.
-    // If FAILED(ThreadSafeGetFeatureStatus), out_blacklistId will be empty.
-    static bool IsFeatureBlacklisted(nsCOMPtr<nsIGfxInfo> gfxInfo, int32_t feature,
-                                     nsACString* const out_blacklistId);
-
     /**
      * Copy to the clipboard as a PNG encoded Data URL.
      */
     static void CopyAsDataURI(SourceSurface* aSourceSurface);
     static void CopyAsDataURI(DrawTarget* aDT);
 
     static bool DumpDisplayList();