From 6d3dfbc3a184c052aa94eafb5835951556fc1f99 Mon Sep 17 00:00:00 2001 From: Joe Drew Date: Wed, 19 Jan 2011 20:30:12 -0500 Subject: [PATCH] Bug 625160 - Part 2 - Create GfxInfoBase, a base class that all GfxInfo implementations will inherit from. r=jrmuizel We want to be able to have a common implementation of GetFeatureStatus and GetFeatureSuggestedDriverVersion that will load from a pref when it's been set by a downloaded blacklist. This makes it possible. --- widget/src/android/GfxInfo.cpp | 19 ++------ widget/src/android/GfxInfo.h | 26 ++++++++-- widget/src/cocoa/GfxInfo.h | 26 ++++++++-- widget/src/cocoa/GfxInfo.mm | 23 ++------- widget/src/windows/GfxInfo.cpp | 22 --------- widget/src/windows/GfxInfo.h | 27 +++++++++-- widget/src/xpwidgets/GfxInfoBase.cpp | 67 ++++++++++++++++++++++++++ widget/src/xpwidgets/GfxInfoBase.h | 72 ++++++++++++++++++++++++++++ widget/src/xpwidgets/Makefile.in | 1 + 9 files changed, 215 insertions(+), 68 deletions(-) create mode 100644 widget/src/xpwidgets/GfxInfoBase.cpp create mode 100644 widget/src/xpwidgets/GfxInfoBase.h diff --git a/widget/src/android/GfxInfo.cpp b/widget/src/android/GfxInfo.cpp index 3fe53b236f0..7a57f5b77eb 100644 --- a/widget/src/android/GfxInfo.cpp +++ b/widget/src/android/GfxInfo.cpp @@ -34,7 +34,6 @@ * ***** END LICENSE BLOCK ***** */ #include "GfxInfo.h" -#include "GfxInfoWebGL.h" #include "nsUnicharUtils.h" #include "nsPrintfCString.h" #include "mozilla/FunctionTimer.h" @@ -194,11 +193,13 @@ GfxInfo::AddCrashReportAnnotations() #endif } -NS_IMETHODIMP -GfxInfo::GetFeatureStatus(PRInt32 aFeature, PRInt32 *aStatus) +nsresult +GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion) { PRInt32 status = nsIGfxInfo::FEATURE_NO_INFO; + aSuggestedDriverVersion.SetIsVoid(PR_TRUE); + if (aFeature == FEATURE_OPENGL_LAYERS) { nsAutoString str; /* Whitelist Galaxy S phones */ @@ -212,15 +213,3 @@ GfxInfo::GetFeatureStatus(PRInt32 aFeature, PRInt32 *aStatus) *aStatus = status; return NS_OK; } - -NS_IMETHODIMP -GfxInfo::GetFeatureSuggestedDriverVersion(PRInt32 aFeature, nsAString& aSuggestedDriverVersion) -{ - return NS_OK; -} - -NS_IMETHODIMP -GfxInfo::GetWebGLParameter(const nsAString& aParam, nsAString& aResult) -{ - return GfxInfoWebGL::GetWebGLParameter(aParam, aResult); -} diff --git a/widget/src/android/GfxInfo.h b/widget/src/android/GfxInfo.h index 366d388d4ca..39a06f89d0d 100644 --- a/widget/src/android/GfxInfo.h +++ b/widget/src/android/GfxInfo.h @@ -40,21 +40,39 @@ #ifndef __mozilla_widget_GfxInfo_h__ #define __mozilla_widget_GfxInfo_h__ -#include +#include "GfxInfoBase.h" #include "nsString.h" namespace mozilla { namespace widget { -class GfxInfo : public nsIGfxInfo +class GfxInfo : public GfxInfoBase { public: GfxInfo() {Init();} virtual ~GfxInfo() {} - NS_DECL_ISUPPORTS - NS_DECL_NSIGFXINFO + // We only declare the subset of nsIGfxInfo that we actually implement. The + // rest is brought forward from GfxInfoBase. + NS_SCRIPTABLE NS_IMETHOD GetD2DEnabled(PRBool *aD2DEnabled); + NS_SCRIPTABLE NS_IMETHOD GetDWriteEnabled(PRBool *aDWriteEnabled); + NS_SCRIPTABLE NS_IMETHOD GetDWriteVersion(nsAString & aDwriteVersion); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDescription(nsAString & aAdapterDescription); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDriver(nsAString & aAdapterDriver); + NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID(PRUint32 *aAdapterVendorID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID(PRUint32 *aAdapterDeviceID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterRAM(nsAString & aAdapterRAM); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverVersion(nsAString & aAdapterDriverVersion); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverDate(nsAString & aAdapterDriverDate); + using GfxInfoBase::GetFeatureStatus; + using GfxInfoBase::GetFeatureSuggestedDriverVersion; + using GfxInfoBase::GetWebGLParameter; + +protected: + + virtual nsresult GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion); + private: void Init(); diff --git a/widget/src/cocoa/GfxInfo.h b/widget/src/cocoa/GfxInfo.h index 366d388d4ca..39a06f89d0d 100644 --- a/widget/src/cocoa/GfxInfo.h +++ b/widget/src/cocoa/GfxInfo.h @@ -40,21 +40,39 @@ #ifndef __mozilla_widget_GfxInfo_h__ #define __mozilla_widget_GfxInfo_h__ -#include +#include "GfxInfoBase.h" #include "nsString.h" namespace mozilla { namespace widget { -class GfxInfo : public nsIGfxInfo +class GfxInfo : public GfxInfoBase { public: GfxInfo() {Init();} virtual ~GfxInfo() {} - NS_DECL_ISUPPORTS - NS_DECL_NSIGFXINFO + // We only declare the subset of nsIGfxInfo that we actually implement. The + // rest is brought forward from GfxInfoBase. + NS_SCRIPTABLE NS_IMETHOD GetD2DEnabled(PRBool *aD2DEnabled); + NS_SCRIPTABLE NS_IMETHOD GetDWriteEnabled(PRBool *aDWriteEnabled); + NS_SCRIPTABLE NS_IMETHOD GetDWriteVersion(nsAString & aDwriteVersion); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDescription(nsAString & aAdapterDescription); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDriver(nsAString & aAdapterDriver); + NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID(PRUint32 *aAdapterVendorID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID(PRUint32 *aAdapterDeviceID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterRAM(nsAString & aAdapterRAM); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverVersion(nsAString & aAdapterDriverVersion); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverDate(nsAString & aAdapterDriverDate); + using GfxInfoBase::GetFeatureStatus; + using GfxInfoBase::GetFeatureSuggestedDriverVersion; + using GfxInfoBase::GetWebGLParameter; + +protected: + + virtual nsresult GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion); + private: void Init(); diff --git a/widget/src/cocoa/GfxInfo.mm b/widget/src/cocoa/GfxInfo.mm index 3f4eeffb2e6..d11bf055861 100644 --- a/widget/src/cocoa/GfxInfo.mm +++ b/widget/src/cocoa/GfxInfo.mm @@ -40,7 +40,6 @@ #include #include "GfxInfo.h" -#include "GfxInfoWebGL.h" #include "nsUnicharUtils.h" #include "mozilla/FunctionTimer.h" @@ -51,11 +50,8 @@ #include "nsIPrefService.h" #endif - using namespace mozilla::widget; -NS_IMPL_ISUPPORTS1(GfxInfo, nsIGfxInfo) - void GfxInfo::Init() { @@ -187,11 +183,14 @@ GfxInfo::AddCrashReportAnnotations() #endif } -NS_IMETHODIMP -GfxInfo::GetFeatureStatus(PRInt32 aFeature, PRInt32 *aStatus) +nsresult +GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, PRInt32* aStatus, + nsAString& aSuggestedDriverVersion) { NS_ENSURE_ARG_POINTER(aStatus); + aSuggestedDriverVersion.SetIsVoid(PR_TRUE); + PRInt32 status = nsIGfxInfo::FEATURE_NO_INFO; if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS) { @@ -236,15 +235,3 @@ GfxInfo::GetFeatureStatus(PRInt32 aFeature, PRInt32 *aStatus) *aStatus = status; return NS_OK; } - -NS_IMETHODIMP -GfxInfo::GetFeatureSuggestedDriverVersion(PRInt32 aFeature, nsAString& aSuggestedDriverVersion) -{ - return NS_OK; -} - -NS_IMETHODIMP -GfxInfo::GetWebGLParameter(const nsAString& aParam, nsAString& aResult) -{ - return GfxInfoWebGL::GetWebGLParameter(aParam, aResult); -} diff --git a/widget/src/windows/GfxInfo.cpp b/widget/src/windows/GfxInfo.cpp index 3c5e5bcdeb5..40732adb4f2 100644 --- a/widget/src/windows/GfxInfo.cpp +++ b/widget/src/windows/GfxInfo.cpp @@ -57,8 +57,6 @@ using namespace mozilla::widget; -NS_IMPL_ISUPPORTS1(GfxInfo, nsIGfxInfo) - /* GetD2DEnabled and GetDwriteEnabled shouldn't be called until after gfxPlatform initialization * has occurred because they depend on it for information. (See bug 591561) */ nsresult @@ -722,23 +720,3 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aS return NS_OK; } - -NS_IMETHODIMP -GfxInfo::GetFeatureStatus(PRInt32 aFeature, PRInt32 *aStatus) -{ - nsString s; - return GetFeatureStatusImpl(aFeature, aStatus, s); -} - -NS_IMETHODIMP -GfxInfo::GetFeatureSuggestedDriverVersion(PRInt32 aFeature, nsAString& aSuggestedDriverVersion) -{ - PRInt32 i; - return GetFeatureStatusImpl(aFeature, &i, aSuggestedDriverVersion); -} - -NS_IMETHODIMP -GfxInfo::GetWebGLParameter(const nsAString& aParam, nsAString& aResult) -{ - return GfxInfoWebGL::GetWebGLParameter(aParam, aResult); -} diff --git a/widget/src/windows/GfxInfo.h b/widget/src/windows/GfxInfo.h index 294eeb7db31..b0310cacf31 100644 --- a/widget/src/windows/GfxInfo.h +++ b/widget/src/windows/GfxInfo.h @@ -40,19 +40,37 @@ #ifndef __mozilla_widget_GfxInfo_h__ #define __mozilla_widget_GfxInfo_h__ -#include +#include "GfxInfoBase.h" namespace mozilla { namespace widget { -class GfxInfo : public nsIGfxInfo +class GfxInfo : public GfxInfoBase { public: GfxInfo() {Init();} virtual ~GfxInfo() {} - NS_DECL_ISUPPORTS - NS_DECL_NSIGFXINFO + // We only declare the subset of nsIGfxInfo that we actually implement. The + // rest is brought forward from GfxInfoBase. + NS_SCRIPTABLE NS_IMETHOD GetD2DEnabled(PRBool *aD2DEnabled); + NS_SCRIPTABLE NS_IMETHOD GetDWriteEnabled(PRBool *aDWriteEnabled); + NS_SCRIPTABLE NS_IMETHOD GetDWriteVersion(nsAString & aDwriteVersion); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDescription(nsAString & aAdapterDescription); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDriver(nsAString & aAdapterDriver); + NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID(PRUint32 *aAdapterVendorID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID(PRUint32 *aAdapterDeviceID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterRAM(nsAString & aAdapterRAM); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverVersion(nsAString & aAdapterDriverVersion); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverDate(nsAString & aAdapterDriverDate); + using GfxInfoBase::GetFeatureStatus; + using GfxInfoBase::GetFeatureSuggestedDriverVersion; + using GfxInfoBase::GetWebGLParameter; + +protected: + + virtual nsresult GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion); + private: void Init(); @@ -64,7 +82,6 @@ private: nsString mDeviceKey; nsString mDeviceKeyDebug; - nsresult GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion); }; } // namespace widget diff --git a/widget/src/xpwidgets/GfxInfoBase.cpp b/widget/src/xpwidgets/GfxInfoBase.cpp new file mode 100644 index 00000000000..56122c715ec --- /dev/null +++ b/widget/src/xpwidgets/GfxInfoBase.cpp @@ -0,0 +1,67 @@ +/* vim: se cin sw=2 ts=2 et : */ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "GfxInfoBase.h" +#include "GfxInfoWebGL.h" + +using namespace mozilla::widget; + +NS_IMPL_ISUPPORTS1(GfxInfoBase, nsIGfxInfo) + +NS_IMETHODIMP +GfxInfoBase::GetFeatureStatus(PRInt32 aFeature, PRInt32* aStatus NS_OUTPARAM) +{ + nsString version; + return GetFeatureStatusImpl(aFeature, aStatus, version); +} + +NS_IMETHODIMP +GfxInfoBase::GetFeatureSuggestedDriverVersion(PRInt32 aFeature, + nsAString& aVersion NS_OUTPARAM) +{ + PRInt32 status; + return GetFeatureStatusImpl(aFeature, &status, aVersion); +} + +NS_IMETHODIMP +GfxInfoBase::GetWebGLParameter(const nsAString& aParam, + nsAString& aResult NS_OUTPARAM) +{ + return GfxInfoWebGL::GetWebGLParameter(aParam, aResult); +} diff --git a/widget/src/xpwidgets/GfxInfoBase.h b/widget/src/xpwidgets/GfxInfoBase.h new file mode 100644 index 00000000000..f65b91d2e12 --- /dev/null +++ b/widget/src/xpwidgets/GfxInfoBase.h @@ -0,0 +1,72 @@ +/* vim: se cin sw=2 ts=2 et : */ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef __mozilla_widget_GfxInfoBase_h__ +#define __mozilla_widget_GfxInfoBase_h__ + +#include + +namespace mozilla { +namespace widget { + +class GfxInfoBase : public nsIGfxInfo +{ +public: + NS_DECL_ISUPPORTS + + // We only declare a subset of the nsIGfxInfo interface. It's up to derived + // classes to implement the rest of the interface. + // Derived classes need to use + // using GfxInfoBase::GetFeatureStatus; + // using GfxInfoBase::GetFeatureSuggestedDriverVersion; + // using GfxInfoBase::GetWebGLParameter; + // to import the relevant methods into their namespace. + NS_SCRIPTABLE NS_IMETHOD GetFeatureStatus(PRInt32 aFeature, PRInt32 *_retval NS_OUTPARAM); + NS_SCRIPTABLE NS_IMETHOD GetFeatureSuggestedDriverVersion(PRInt32 aFeature, nsAString & _retval NS_OUTPARAM); + NS_SCRIPTABLE NS_IMETHOD GetWebGLParameter(const nsAString & aParam, nsAString & _retval NS_OUTPARAM); + +protected: + virtual nsresult GetFeatureStatusImpl(PRInt32 aFeature, PRInt32* aStatus, + nsAString& aSuggestedDriverVersion) = 0; +}; + +}; +}; + +#endif /* __mozilla_widget_GfxInfoBase_h__ */ diff --git a/widget/src/xpwidgets/Makefile.in b/widget/src/xpwidgets/Makefile.in index ca1df7c66df..d1cb06a3bdc 100644 --- a/widget/src/xpwidgets/Makefile.in +++ b/widget/src/xpwidgets/Makefile.in @@ -70,6 +70,7 @@ CPPSRCS = \ nsClipboardPrivacyHandler.cpp \ GfxInfoWebGL.cpp \ GfxDriverInfo.cpp \ + GfxInfoBase.cpp \ $(NULL) ifdef MOZ_IPC