Bug 900201 - Implement GfxInfo on gonk - r=ehsan
☠☠ backed out by 0dde7bd3e303 ☠ ☠
authorBenoit Jacob <bjacob@mozilla.com>
Mon, 12 Aug 2013 23:55:28 +0200
changeset 155258 716e54fb5d09e7f598aa64920c27fee2c4f449d0
parent 155257 5f50fb2c8768766ca09623cf52322267b9cc6621
child 155259 73ec9b19228ac76a06599bc393783f4298478d9e
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs900201
milestone26.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 900201 - Implement GfxInfo on gonk - r=ehsan
widget/gonk/GfxInfo.cpp
widget/gonk/GfxInfo.h
widget/gonk/moz.build
widget/gonk/nsWidgetFactory.cpp
new file mode 100644
--- /dev/null
+++ b/widget/gonk/GfxInfo.cpp
@@ -0,0 +1,189 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "GfxInfo.h"
+
+using namespace mozilla::widget;
+
+/* GetD2DEnabled and GetDwriteEnabled shouldn't be called until after gfxPlatform initialization
+ * has occurred because they depend on it for information. (See bug 591561) */
+nsresult
+GfxInfo::GetD2DEnabled(bool *aEnabled)
+{
+  return NS_ERROR_FAILURE;
+}
+
+nsresult
+GfxInfo::GetDWriteEnabled(bool *aEnabled)
+{
+  return NS_ERROR_FAILURE;
+}
+
+/* readonly attribute DOMString DWriteVersion; */
+NS_IMETHODIMP
+GfxInfo::GetDWriteVersion(nsAString & aDwriteVersion)
+{
+  return NS_ERROR_FAILURE;
+}
+
+/* readonly attribute DOMString cleartypeParameters; */
+NS_IMETHODIMP
+GfxInfo::GetCleartypeParameters(nsAString & aCleartypeParams)
+{
+  return NS_ERROR_FAILURE;
+}
+
+/* readonly attribute DOMString adapterDescription; */
+NS_IMETHODIMP
+GfxInfo::GetAdapterDescription(nsAString & aAdapterDescription)
+{
+  aAdapterDescription.AssignLiteral("");
+  return NS_OK;
+}
+
+/* readonly attribute DOMString adapterDescription2; */
+NS_IMETHODIMP
+GfxInfo::GetAdapterDescription2(nsAString & aAdapterDescription)
+{
+  return NS_ERROR_FAILURE;
+}
+
+/* readonly attribute DOMString adapterRAM; */
+NS_IMETHODIMP
+GfxInfo::GetAdapterRAM(nsAString & aAdapterRAM)
+{
+  aAdapterRAM.AssignLiteral("");
+  return NS_OK;
+}
+
+/* readonly attribute DOMString adapterRAM2; */
+NS_IMETHODIMP
+GfxInfo::GetAdapterRAM2(nsAString & aAdapterRAM)
+{
+  return NS_ERROR_FAILURE;
+}
+
+/* readonly attribute DOMString adapterDriver; */
+NS_IMETHODIMP
+GfxInfo::GetAdapterDriver(nsAString & aAdapterDriver)
+{
+  aAdapterDriver.AssignLiteral("");
+  return NS_OK;
+}
+
+/* readonly attribute DOMString adapterDriver2; */
+NS_IMETHODIMP
+GfxInfo::GetAdapterDriver2(nsAString & aAdapterDriver)
+{
+  return NS_ERROR_FAILURE;
+}
+
+/* readonly attribute DOMString adapterDriverVersion; */
+NS_IMETHODIMP
+GfxInfo::GetAdapterDriverVersion(nsAString & aAdapterDriverVersion)
+{
+  aAdapterDriverVersion.AssignLiteral("");
+  return NS_OK;
+}
+
+/* readonly attribute DOMString adapterDriverVersion2; */
+NS_IMETHODIMP
+GfxInfo::GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion)
+{
+  return NS_ERROR_FAILURE;
+}
+
+/* readonly attribute DOMString adapterDriverDate; */
+NS_IMETHODIMP
+GfxInfo::GetAdapterDriverDate(nsAString & aAdapterDriverDate)
+{
+  aAdapterDriverDate.AssignLiteral("");
+  return NS_OK;
+}
+
+/* readonly attribute DOMString adapterDriverDate2; */
+NS_IMETHODIMP
+GfxInfo::GetAdapterDriverDate2(nsAString & aAdapterDriverDate)
+{
+  return NS_ERROR_FAILURE;
+}
+
+/* readonly attribute DOMString adapterVendorID; */
+NS_IMETHODIMP
+GfxInfo::GetAdapterVendorID(nsAString & aAdapterVendorID)
+{
+  aAdapterVendorID.AssignLiteral("");
+  return NS_OK;
+}
+
+/* readonly attribute DOMString adapterVendorID2; */
+NS_IMETHODIMP
+GfxInfo::GetAdapterVendorID2(nsAString & aAdapterVendorID)
+{
+  return NS_ERROR_FAILURE;
+}
+
+/* readonly attribute DOMString adapterDeviceID; */
+NS_IMETHODIMP
+GfxInfo::GetAdapterDeviceID(nsAString & aAdapterDeviceID)
+{
+  aAdapterDeviceID.AssignLiteral("");
+  return NS_OK;
+}
+
+/* readonly attribute DOMString adapterDeviceID2; */
+NS_IMETHODIMP
+GfxInfo::GetAdapterDeviceID2(nsAString & aAdapterDeviceID)
+{
+  return NS_ERROR_FAILURE;
+}
+
+/* readonly attribute boolean isGPU2Active; */
+NS_IMETHODIMP
+GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active)
+{
+  return NS_ERROR_FAILURE;
+}
+
+const nsTArray<GfxDriverInfo>&
+GfxInfo::GetGfxDriverInfo()
+{
+  return *mDriverInfo;
+}
+
+#ifdef DEBUG
+
+// Implement nsIGfxInfoDebug
+
+/* void spoofVendorID (in DOMString aVendorID); */
+NS_IMETHODIMP GfxInfo::SpoofVendorID(const nsAString & aVendorID)
+{
+  return NS_OK;
+}
+
+/* void spoofDeviceID (in unsigned long aDeviceID); */
+NS_IMETHODIMP GfxInfo::SpoofDeviceID(const nsAString & aDeviceID)
+{
+  return NS_OK;
+}
+
+/* void spoofDriverVersion (in DOMString aDriverVersion); */
+NS_IMETHODIMP GfxInfo::SpoofDriverVersion(const nsAString & aDriverVersion)
+{
+  return NS_OK;
+}
+
+/* void spoofOSVersion (in unsigned long aVersion); */
+NS_IMETHODIMP GfxInfo::SpoofOSVersion(uint32_t aVersion)
+{
+  return NS_OK;
+}
+
+#endif
+
+uint32_t GfxInfo::OperatingSystemVersion() const
+{
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/widget/gonk/GfxInfo.h
@@ -0,0 +1,57 @@
+/* vim: se cin sw=2 ts=2 et : */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef __mozilla_widget_GfxInfo_h__
+#define __mozilla_widget_GfxInfo_h__
+
+#include "GfxInfoBase.h"
+#include "GfxDriverInfo.h"
+
+#include "nsString.h"
+
+namespace mozilla {
+namespace widget {
+
+class GfxInfo : public GfxInfoBase
+{
+public:
+  // We only declare the subset of nsIGfxInfo that we actually implement. The
+  // rest is brought forward from GfxInfoBase.
+  NS_IMETHOD GetD2DEnabled(bool *aD2DEnabled);
+  NS_IMETHOD GetDWriteEnabled(bool *aDWriteEnabled);
+  NS_IMETHOD GetDWriteVersion(nsAString & aDwriteVersion);
+  NS_IMETHOD GetCleartypeParameters(nsAString & aCleartypeParams);
+  NS_IMETHOD GetAdapterDescription(nsAString & aAdapterDescription);
+  NS_IMETHOD GetAdapterDriver(nsAString & aAdapterDriver);
+  NS_IMETHOD GetAdapterVendorID(nsAString & aAdapterVendorID);
+  NS_IMETHOD GetAdapterDeviceID(nsAString & aAdapterDeviceID);
+  NS_IMETHOD GetAdapterRAM(nsAString & aAdapterRAM);
+  NS_IMETHOD GetAdapterDriverVersion(nsAString & aAdapterDriverVersion);
+  NS_IMETHOD GetAdapterDriverDate(nsAString & aAdapterDriverDate);
+  NS_IMETHOD GetAdapterDescription2(nsAString & aAdapterDescription);
+  NS_IMETHOD GetAdapterDriver2(nsAString & aAdapterDriver);
+  NS_IMETHOD GetAdapterVendorID2(nsAString & aAdapterVendorID);
+  NS_IMETHOD GetAdapterDeviceID2(nsAString & aAdapterDeviceID);
+  NS_IMETHOD GetAdapterRAM2(nsAString & aAdapterRAM);
+  NS_IMETHOD GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion);
+  NS_IMETHOD GetAdapterDriverDate2(nsAString & aAdapterDriverDate);
+  NS_IMETHOD GetIsGPU2Active(bool *aIsGPU2Active);
+  using GfxInfoBase::GetFeatureStatus;
+  using GfxInfoBase::GetFeatureSuggestedDriverVersion;
+  using GfxInfoBase::GetWebGLParameter;
+
+  virtual uint32_t OperatingSystemVersion() const;
+
+protected:
+
+  virtual const nsTArray<GfxDriverInfo>& GetGfxDriverInfo();
+};
+
+} // namespace widget
+} // namespace mozilla
+
+#endif /* __mozilla_widget_GfxInfo_h__ */
--- a/widget/gonk/moz.build
+++ b/widget/gonk/moz.build
@@ -48,14 +48,15 @@ CPP_SOURCES += [
     'Tokenizer.cpp',
     'Unicode.cpp',
     'VirtualKeyMap.cpp',
     'nsAppShell.cpp',
     'nsIdleServiceGonk.cpp',
     'nsLookAndFeel.cpp',
     'nsWidgetFactory.cpp',
     'nsWindow.cpp',
+    'GfxInfo.cpp',
 ]
 
 if CONFIG['ANDROID_VERSION'] == '15':
     CPP_SOURCES += [
         'HwcComposer2D.cpp'
     ]
--- a/widget/gonk/nsWidgetFactory.cpp
+++ b/widget/gonk/nsWidgetFactory.cpp
@@ -31,30 +31,41 @@
 
 #include "nsHTMLFormatConverter.h"
 #include "nsXULAppAPI.h"
 
 #include "PuppetWidget.h"
 
 using namespace mozilla::widget;
 
+// taken from android/nsWidgetFactory.cpp. GfxInfo is a legacy kludge, unfortunately
+// for the time being we still have to implement it on all platforms.
+#include "GfxInfo.h"
+namespace mozilla {
+namespace widget {
+// This constructor should really be shared with all platforms.
+NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init)
+}
+}
+
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerGonk)
 NS_GENERIC_FACTORY_CONSTRUCTOR(PuppetScreenManager)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIdleServiceGonk, nsIdleServiceGonk::GetInstance)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
 
 NS_DEFINE_NAMED_CID(NS_APPSHELL_CID);
 NS_DEFINE_NAMED_CID(NS_WINDOW_CID);
 NS_DEFINE_NAMED_CID(NS_CHILD_CID);
 NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID);
 NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID);
 NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID);
+NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
 
 static nsresult
 ScreenManagerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
 {
     return (XRE_GetProcessType() == GeckoProcessType_Default) ?
         nsScreenManagerGonkConstructor(aOuter, aIID, aResult) :
         PuppetScreenManagerConstructor(aOuter, aIID, aResult);
 }
@@ -62,27 +73,29 @@ ScreenManagerConstructor(nsISupports *aO
 static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
     { &kNS_WINDOW_CID, false, NULL, nsWindowConstructor },
     { &kNS_CHILD_CID, false, NULL, nsWindowConstructor },
     { &kNS_APPSHELL_CID, false, NULL, nsAppShellConstructor },
     { &kNS_SCREENMANAGER_CID, false, NULL, ScreenManagerConstructor },
     { &kNS_HTMLFORMATCONVERTER_CID, false, NULL, nsHTMLFormatConverterConstructor },
     { &kNS_IDLE_SERVICE_CID, false, NULL, nsIdleServiceGonkConstructor },
     { &kNS_TRANSFERABLE_CID, false, NULL, nsTransferableConstructor },
+    { &kNS_GFXINFO_CID, false, NULL, mozilla::widget::GfxInfoConstructor },
     { NULL }
 };
 
 static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
     { "@mozilla.org/widgets/window/gonk;1", &kNS_WINDOW_CID },
     { "@mozilla.org/widgets/child_window/gonk;1", &kNS_CHILD_CID },
     { "@mozilla.org/widget/appshell/gonk;1", &kNS_APPSHELL_CID },
     { "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID },
     { "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID },
     { "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID },
     { "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID },
+    { "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID },
     { NULL }
 };
 
 static void
 nsWidgetGonkModuleDtor()
 {
     nsLookAndFeel::Shutdown();
     nsAppShellShutdown();