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.
This commit is contained in:
Joe Drew 2011-01-19 20:30:12 -05:00
Родитель 927ca0277f
Коммит 6d3dfbc3a1
9 изменённых файлов: 215 добавлений и 68 удалений

Просмотреть файл

@ -34,7 +34,6 @@
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "GfxInfo.h" #include "GfxInfo.h"
#include "GfxInfoWebGL.h"
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"
#include "nsPrintfCString.h" #include "nsPrintfCString.h"
#include "mozilla/FunctionTimer.h" #include "mozilla/FunctionTimer.h"
@ -194,11 +193,13 @@ GfxInfo::AddCrashReportAnnotations()
#endif #endif
} }
NS_IMETHODIMP nsresult
GfxInfo::GetFeatureStatus(PRInt32 aFeature, PRInt32 *aStatus) GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion)
{ {
PRInt32 status = nsIGfxInfo::FEATURE_NO_INFO; PRInt32 status = nsIGfxInfo::FEATURE_NO_INFO;
aSuggestedDriverVersion.SetIsVoid(PR_TRUE);
if (aFeature == FEATURE_OPENGL_LAYERS) { if (aFeature == FEATURE_OPENGL_LAYERS) {
nsAutoString str; nsAutoString str;
/* Whitelist Galaxy S phones */ /* Whitelist Galaxy S phones */
@ -212,15 +213,3 @@ GfxInfo::GetFeatureStatus(PRInt32 aFeature, PRInt32 *aStatus)
*aStatus = status; *aStatus = status;
return NS_OK; 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);
}

Просмотреть файл

@ -40,21 +40,39 @@
#ifndef __mozilla_widget_GfxInfo_h__ #ifndef __mozilla_widget_GfxInfo_h__
#define __mozilla_widget_GfxInfo_h__ #define __mozilla_widget_GfxInfo_h__
#include <nsIGfxInfo.h> #include "GfxInfoBase.h"
#include "nsString.h" #include "nsString.h"
namespace mozilla { namespace mozilla {
namespace widget { namespace widget {
class GfxInfo : public nsIGfxInfo class GfxInfo : public GfxInfoBase
{ {
public: public:
GfxInfo() {Init();} GfxInfo() {Init();}
virtual ~GfxInfo() {} virtual ~GfxInfo() {}
NS_DECL_ISUPPORTS // We only declare the subset of nsIGfxInfo that we actually implement. The
NS_DECL_NSIGFXINFO // 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: private:
void Init(); void Init();

Просмотреть файл

@ -40,21 +40,39 @@
#ifndef __mozilla_widget_GfxInfo_h__ #ifndef __mozilla_widget_GfxInfo_h__
#define __mozilla_widget_GfxInfo_h__ #define __mozilla_widget_GfxInfo_h__
#include <nsIGfxInfo.h> #include "GfxInfoBase.h"
#include "nsString.h" #include "nsString.h"
namespace mozilla { namespace mozilla {
namespace widget { namespace widget {
class GfxInfo : public nsIGfxInfo class GfxInfo : public GfxInfoBase
{ {
public: public:
GfxInfo() {Init();} GfxInfo() {Init();}
virtual ~GfxInfo() {} virtual ~GfxInfo() {}
NS_DECL_ISUPPORTS // We only declare the subset of nsIGfxInfo that we actually implement. The
NS_DECL_NSIGFXINFO // 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: private:
void Init(); void Init();

Просмотреть файл

@ -40,7 +40,6 @@
#include <OpenGL/CGLRenderers.h> #include <OpenGL/CGLRenderers.h>
#include "GfxInfo.h" #include "GfxInfo.h"
#include "GfxInfoWebGL.h"
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"
#include "mozilla/FunctionTimer.h" #include "mozilla/FunctionTimer.h"
@ -51,11 +50,8 @@
#include "nsIPrefService.h" #include "nsIPrefService.h"
#endif #endif
using namespace mozilla::widget; using namespace mozilla::widget;
NS_IMPL_ISUPPORTS1(GfxInfo, nsIGfxInfo)
void void
GfxInfo::Init() GfxInfo::Init()
{ {
@ -187,11 +183,14 @@ GfxInfo::AddCrashReportAnnotations()
#endif #endif
} }
NS_IMETHODIMP nsresult
GfxInfo::GetFeatureStatus(PRInt32 aFeature, PRInt32 *aStatus) GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, PRInt32* aStatus,
nsAString& aSuggestedDriverVersion)
{ {
NS_ENSURE_ARG_POINTER(aStatus); NS_ENSURE_ARG_POINTER(aStatus);
aSuggestedDriverVersion.SetIsVoid(PR_TRUE);
PRInt32 status = nsIGfxInfo::FEATURE_NO_INFO; PRInt32 status = nsIGfxInfo::FEATURE_NO_INFO;
if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS) { if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS) {
@ -236,15 +235,3 @@ GfxInfo::GetFeatureStatus(PRInt32 aFeature, PRInt32 *aStatus)
*aStatus = status; *aStatus = status;
return NS_OK; 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);
}

Просмотреть файл

@ -57,8 +57,6 @@
using namespace mozilla::widget; using namespace mozilla::widget;
NS_IMPL_ISUPPORTS1(GfxInfo, nsIGfxInfo)
/* GetD2DEnabled and GetDwriteEnabled shouldn't be called until after gfxPlatform initialization /* GetD2DEnabled and GetDwriteEnabled shouldn't be called until after gfxPlatform initialization
* has occurred because they depend on it for information. (See bug 591561) */ * has occurred because they depend on it for information. (See bug 591561) */
nsresult nsresult
@ -722,23 +720,3 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aS
return NS_OK; 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);
}

Просмотреть файл

@ -40,19 +40,37 @@
#ifndef __mozilla_widget_GfxInfo_h__ #ifndef __mozilla_widget_GfxInfo_h__
#define __mozilla_widget_GfxInfo_h__ #define __mozilla_widget_GfxInfo_h__
#include <nsIGfxInfo.h> #include "GfxInfoBase.h"
namespace mozilla { namespace mozilla {
namespace widget { namespace widget {
class GfxInfo : public nsIGfxInfo class GfxInfo : public GfxInfoBase
{ {
public: public:
GfxInfo() {Init();} GfxInfo() {Init();}
virtual ~GfxInfo() {} virtual ~GfxInfo() {}
NS_DECL_ISUPPORTS // We only declare the subset of nsIGfxInfo that we actually implement. The
NS_DECL_NSIGFXINFO // 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: private:
void Init(); void Init();
@ -64,7 +82,6 @@ private:
nsString mDeviceKey; nsString mDeviceKey;
nsString mDeviceKeyDebug; nsString mDeviceKeyDebug;
nsresult GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion);
}; };
} // namespace widget } // namespace widget

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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 <nsIGfxInfo.h>
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__ */

Просмотреть файл

@ -70,6 +70,7 @@ CPPSRCS = \
nsClipboardPrivacyHandler.cpp \ nsClipboardPrivacyHandler.cpp \
GfxInfoWebGL.cpp \ GfxInfoWebGL.cpp \
GfxDriverInfo.cpp \ GfxDriverInfo.cpp \
GfxInfoBase.cpp \
$(NULL) $(NULL)
ifdef MOZ_IPC ifdef MOZ_IPC