Bug 1477033. Cleanup InitFeatureObject. r=kats
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Thu, 19 Jul 2018 14:11:34 -0400
changeset 485109 73ee6e93886bac3c4670444933a07718360f1670
parent 485108 47f25d0b1e1d7986a90aace67c5d90f42959e63f
child 485110 dbf25e19fc98cc8f4489c6b9fabb5065311c5fea
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1477033
milestone63.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
Bug 1477033. Cleanup InitFeatureObject. r=kats This removes an unused gfxConfig check and changes Maybe<FeatureStatus> into FeatureStatus as none of the callers were using None. MozReview-Commit-ID: Kep6nYpDI3B
widget/GfxInfoBase.cpp
widget/GfxInfoBase.h
widget/windows/GfxInfo.cpp
--- a/widget/GfxInfoBase.cpp
+++ b/widget/GfxInfoBase.cpp
@@ -1394,58 +1394,48 @@ GfxInfoBase::BuildFeatureStateLog(JSCont
 }
 
 void
 GfxInfoBase::DescribeFeatures(JSContext* aCx, JS::Handle<JSObject*> aObj)
 {
   JS::Rooted<JSObject*> obj(aCx);
 
   gfx::FeatureStatus gpuProcess = gfxConfig::GetValue(Feature::GPU_PROCESS);
-  InitFeatureObject(aCx, aObj, "gpuProcess", FEATURE_GPU_PROCESS, Some(gpuProcess), &obj);
+  InitFeatureObject(aCx, aObj, "gpuProcess", gpuProcess, &obj);
 
   // Only include AL if the platform attempted to use it.
   gfx::FeatureStatus advancedLayers = gfxConfig::GetValue(Feature::ADVANCED_LAYERS);
   if (advancedLayers != FeatureStatus::Unused) {
-    InitFeatureObject(aCx, aObj, "advancedLayers", FEATURE_ADVANCED_LAYERS,
-                      Some(advancedLayers), &obj);
+    InitFeatureObject(aCx, aObj, "advancedLayers", advancedLayers, &obj);
 
     if (gfxConfig::UseFallback(Fallback::NO_CONSTANT_BUFFER_OFFSETTING)) {
       JS::Rooted<JS::Value> trueVal(aCx, JS::BooleanValue(true));
       JS_SetProperty(aCx, obj, "noConstantBufferOffsetting", trueVal);
     }
   }
 }
 
 bool
 GfxInfoBase::InitFeatureObject(JSContext* aCx,
                                JS::Handle<JSObject*> aContainer,
                                const char* aName,
-                               int32_t aFeature,
-                               const Maybe<mozilla::gfx::FeatureStatus>& aFeatureStatus,
+                               mozilla::gfx::FeatureStatus& aFeatureStatus,
                                JS::MutableHandle<JSObject*> aOutObj)
 {
   JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
   if (!obj) {
     return false;
   }
 
-  nsCString failureId = NS_LITERAL_CSTRING("OK");
-  int32_t unused;
-  if (!NS_SUCCEEDED(GetFeatureStatus(aFeature, failureId, &unused))) {
-    return false;
-  }
+  // Set "status".
+  const char* status = FeatureStatusToString(aFeatureStatus);
 
-  // Set "status".
-  if (aFeatureStatus) {
-    const char* status = FeatureStatusToString(aFeatureStatus.value());
-
-    JS::Rooted<JSString*> str(aCx, JS_NewStringCopyZ(aCx, status));
-    JS::Rooted<JS::Value> val(aCx, JS::StringValue(str));
-    JS_SetProperty(aCx, obj, "status", val);
-  }
+  JS::Rooted<JSString*> str(aCx, JS_NewStringCopyZ(aCx, status));
+  JS::Rooted<JS::Value> val(aCx, JS::StringValue(str));
+  JS_SetProperty(aCx, obj, "status", val);
 
   // Add the feature object to the container.
   {
     JS::Rooted<JS::Value> val(aCx, JS::ObjectValue(*obj));
     JS_SetProperty(aCx, aContainer, aName, val);
   }
 
   aOutObj.set(obj);
--- a/widget/GfxInfoBase.h
+++ b/widget/GfxInfoBase.h
@@ -116,18 +116,17 @@ protected:
   // (while subclasses check for more specific ones).
   virtual const nsTArray<GfxDriverInfo>& GetGfxDriverInfo() = 0;
 
   virtual void DescribeFeatures(JSContext* aCx, JS::Handle<JSObject*> obj);
   bool InitFeatureObject(
     JSContext* aCx,
     JS::Handle<JSObject*> aContainer,
     const char* aName,
-    int32_t aFeature,
-    const Maybe<mozilla::gfx::FeatureStatus>& aKnownStatus,
+    mozilla::gfx::FeatureStatus& aKnownStatus,
     JS::MutableHandle<JSObject*> aOutObj);
 
   NS_IMETHOD ControlGPUProcessForXPCShell(bool aEnable, bool *_retval) override;
 
 private:
   virtual int32_t FindBlocklistedDeviceInList(const nsTArray<GfxDriverInfo>& aDriverInfo,
                                               nsAString& aSuggestedVersion,
                                               int32_t aFeature,
--- a/widget/windows/GfxInfo.cpp
+++ b/widget/windows/GfxInfo.cpp
@@ -1569,18 +1569,17 @@ void
 GfxInfo::DescribeFeatures(JSContext* aCx, JS::Handle<JSObject*> aObj)
 {
   // Add the platform neutral features
   GfxInfoBase::DescribeFeatures(aCx, aObj);
 
   JS::Rooted<JSObject*> obj(aCx);
 
   gfx::FeatureStatus d3d11 = gfxConfig::GetValue(Feature::D3D11_COMPOSITING);
-  if (!InitFeatureObject(aCx, aObj, "d3d11", FEATURE_DIRECT3D_11_ANGLE,
-                         Some(d3d11), &obj)) {
+  if (!InitFeatureObject(aCx, aObj, "d3d11", d3d11, &obj)) {
     return;
   }
   if (d3d11 == gfx::FeatureStatus::Available) {
     DeviceManagerDx* dm = DeviceManagerDx::Get();
     JS::Rooted<JS::Value> val(aCx, JS::Int32Value(dm->GetCompositorFeatureLevel()));
     JS_SetProperty(aCx, obj, "version", val);
 
     val = JS::BooleanValue(dm->IsWARP());
@@ -1598,18 +1597,17 @@ GfxInfo::DescribeFeatures(JSContext* aCx
       }
     }
 
     val = JS::BooleanValue(blacklisted);
     JS_SetProperty(aCx, obj, "blacklisted", val);
   }
 
   gfx::FeatureStatus d2d = gfxConfig::GetValue(Feature::DIRECT2D);
-  if (!InitFeatureObject(aCx, aObj, "d2d", nsIGfxInfo::FEATURE_DIRECT2D,
-                         Some(d2d), &obj)) {
+  if (!InitFeatureObject(aCx, aObj, "d2d", d2d, &obj)) {
     return;
   }
   {
     const char* version = "1.1";
     JS::Rooted<JSString*> str(aCx, JS_NewStringCopyZ(aCx, version));
     JS::Rooted<JS::Value> val(aCx, JS::StringValue(str));
     JS_SetProperty(aCx, obj, "version", val);
   }