2011-01-20 04:30:12 +03:00
|
|
|
/* vim: se cin sw=2 ts=2 et : */
|
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* 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/. */
|
2011-01-20 04:30:12 +03:00
|
|
|
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2011-01-20 04:30:12 +03:00
|
|
|
#include "GfxInfoBase.h"
|
2011-01-20 04:33:51 +03:00
|
|
|
|
2011-01-20 04:30:12 +03:00
|
|
|
#include "GfxInfoWebGL.h"
|
2011-01-20 04:33:51 +03:00
|
|
|
#include "GfxDriverInfo.h"
|
2011-01-20 04:30:15 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2011-01-20 04:33:51 +03:00
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2011-01-20 04:30:15 +03:00
|
|
|
#include "nsString.h"
|
2012-02-21 23:49:06 +04:00
|
|
|
#include "nsUnicharUtils.h"
|
2015-05-15 17:42:10 +03:00
|
|
|
#include "nsVersionComparator.h"
|
2011-01-20 04:33:51 +03:00
|
|
|
#include "mozilla/Services.h"
|
2011-12-15 09:02:59 +04:00
|
|
|
#include "mozilla/Observer.h"
|
2011-01-20 04:33:51 +03:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsIDOMElement.h"
|
2012-09-26 18:17:47 +04:00
|
|
|
#include "nsIDOMHTMLCollection.h"
|
2011-01-20 04:33:51 +03:00
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsIDOMNodeList.h"
|
|
|
|
#include "nsTArray.h"
|
2014-01-11 05:09:20 +04:00
|
|
|
#include "nsXULAppAPI.h"
|
2015-05-15 17:42:10 +03:00
|
|
|
#include "nsIXULAppInfo.h"
|
2011-05-23 18:54:03 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2014-01-11 05:09:20 +04:00
|
|
|
#include "mozilla/dom/ContentChild.h"
|
2015-01-14 05:19:25 +03:00
|
|
|
#include "mozilla/gfx/2D.h"
|
|
|
|
#include "mozilla/gfx/Logging.h"
|
2015-05-28 18:54:07 +03:00
|
|
|
#include "gfxPrefs.h"
|
2011-01-20 04:30:12 +03:00
|
|
|
|
2011-05-23 20:54:47 +04:00
|
|
|
#if defined(MOZ_CRASHREPORTER)
|
2011-02-02 01:49:29 +03:00
|
|
|
#include "nsExceptionHandler.h"
|
|
|
|
#endif
|
|
|
|
|
2011-12-15 09:02:59 +04:00
|
|
|
using namespace mozilla::widget;
|
2011-10-11 09:50:08 +04:00
|
|
|
using namespace mozilla;
|
2013-02-25 18:07:16 +04:00
|
|
|
using mozilla::MutexAutoLock;
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2011-12-15 09:02:59 +04:00
|
|
|
nsTArray<GfxDriverInfo>* GfxInfoBase::mDriverInfo;
|
|
|
|
bool GfxInfoBase::mDriverInfoObserverInitialized;
|
|
|
|
|
|
|
|
// Observes for shutdown so that the child GfxDriverInfo list is freed.
|
|
|
|
class ShutdownObserver : public nsIObserver
|
|
|
|
{
|
2014-06-24 20:36:44 +04:00
|
|
|
virtual ~ShutdownObserver() {}
|
|
|
|
|
2011-12-15 09:02:59 +04:00
|
|
|
public:
|
|
|
|
ShutdownObserver() {}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
NS_IMETHOD Observe(nsISupports *subject, const char *aTopic,
|
2015-03-21 19:28:04 +03:00
|
|
|
const char16_t *aData) override
|
2011-12-15 09:02:59 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0);
|
2011-12-15 09:03:01 +04:00
|
|
|
|
|
|
|
delete GfxInfoBase::mDriverInfo;
|
2012-07-30 18:20:58 +04:00
|
|
|
GfxInfoBase::mDriverInfo = nullptr;
|
2011-12-15 09:03:01 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < DeviceFamilyMax; i++)
|
2011-12-15 09:03:01 +04:00
|
|
|
delete GfxDriverInfo::mDeviceFamilies[i];
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < DeviceVendorMax; i++)
|
2011-12-15 09:03:01 +04:00
|
|
|
delete GfxDriverInfo::mDeviceVendors[i];
|
|
|
|
|
2011-12-15 09:02:59 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(ShutdownObserver, nsIObserver)
|
2011-12-15 09:02:59 +04:00
|
|
|
|
|
|
|
void InitGfxDriverInfoShutdownObserver()
|
|
|
|
{
|
|
|
|
if (GfxInfoBase::mDriverInfoObserverInitialized)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GfxInfoBase::mDriverInfoObserverInitialized = true;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
|
|
|
|
if (!observerService) {
|
|
|
|
NS_WARNING("Could not get observer service!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ShutdownObserver *obs = new ShutdownObserver();
|
|
|
|
observerService->AddObserver(obs, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
|
|
|
}
|
|
|
|
|
2011-01-20 04:30:12 +03:00
|
|
|
using namespace mozilla::widget;
|
2015-01-14 05:19:25 +03:00
|
|
|
using namespace mozilla::gfx;
|
2011-05-23 18:54:03 +04:00
|
|
|
using namespace mozilla;
|
2011-01-20 04:30:12 +03:00
|
|
|
|
2014-11-22 03:23:09 +03:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
NS_IMPL_ISUPPORTS(GfxInfoBase, nsIGfxInfo, nsIGfxInfo2, nsIObserver, nsISupportsWeakReference)
|
|
|
|
#else
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(GfxInfoBase, nsIGfxInfo, nsIObserver, nsISupportsWeakReference)
|
2014-11-22 03:23:09 +03:00
|
|
|
#endif
|
2011-01-20 04:30:12 +03:00
|
|
|
|
2011-01-20 04:30:15 +03:00
|
|
|
#define BLACKLIST_PREF_BRANCH "gfx.blacklist."
|
|
|
|
#define SUGGESTED_VERSION_PREF BLACKLIST_PREF_BRANCH "suggested-driver-version"
|
2011-01-20 04:33:51 +03:00
|
|
|
#define BLACKLIST_ENTRY_TAG_NAME "gfxBlacklistEntry"
|
2011-01-20 04:30:15 +03:00
|
|
|
|
|
|
|
static const char*
|
2012-08-22 19:56:38 +04:00
|
|
|
GetPrefNameForFeature(int32_t aFeature)
|
2011-01-20 04:30:15 +03:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
const char* name = nullptr;
|
2011-01-20 04:30:15 +03:00
|
|
|
switch(aFeature) {
|
|
|
|
case nsIGfxInfo::FEATURE_DIRECT2D:
|
|
|
|
name = BLACKLIST_PREF_BRANCH "direct2d";
|
|
|
|
break;
|
|
|
|
case nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS:
|
|
|
|
name = BLACKLIST_PREF_BRANCH "layers.direct3d9";
|
|
|
|
break;
|
|
|
|
case nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS:
|
|
|
|
name = BLACKLIST_PREF_BRANCH "layers.direct3d10";
|
|
|
|
break;
|
|
|
|
case nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS:
|
|
|
|
name = BLACKLIST_PREF_BRANCH "layers.direct3d10-1";
|
|
|
|
break;
|
2014-05-16 20:16:21 +04:00
|
|
|
case nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS:
|
|
|
|
name = BLACKLIST_PREF_BRANCH "layers.direct3d11";
|
|
|
|
break;
|
2015-04-10 23:17:27 +03:00
|
|
|
case nsIGfxInfo::FEATURE_DIRECT3D_11_ANGLE:
|
|
|
|
name = BLACKLIST_PREF_BRANCH "direct3d11angle";
|
|
|
|
break;
|
2015-04-01 06:06:56 +03:00
|
|
|
case nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING:
|
|
|
|
name = BLACKLIST_PREF_BRANCH "hardwarevideodecoding";
|
2015-01-26 03:34:28 +03:00
|
|
|
break;
|
2011-01-20 04:30:15 +03:00
|
|
|
case nsIGfxInfo::FEATURE_OPENGL_LAYERS:
|
|
|
|
name = BLACKLIST_PREF_BRANCH "layers.opengl";
|
|
|
|
break;
|
|
|
|
case nsIGfxInfo::FEATURE_WEBGL_OPENGL:
|
|
|
|
name = BLACKLIST_PREF_BRANCH "webgl.opengl";
|
|
|
|
break;
|
|
|
|
case nsIGfxInfo::FEATURE_WEBGL_ANGLE:
|
|
|
|
name = BLACKLIST_PREF_BRANCH "webgl.angle";
|
|
|
|
break;
|
2011-11-03 18:50:40 +04:00
|
|
|
case nsIGfxInfo::FEATURE_WEBGL_MSAA:
|
|
|
|
name = BLACKLIST_PREF_BRANCH "webgl.msaa";
|
|
|
|
break;
|
2012-11-02 01:13:10 +04:00
|
|
|
case nsIGfxInfo::FEATURE_STAGEFRIGHT:
|
|
|
|
name = BLACKLIST_PREF_BRANCH "stagefright";
|
|
|
|
break;
|
2015-05-15 17:42:10 +03:00
|
|
|
case nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION:
|
|
|
|
name = BLACKLIST_PREF_BRANCH "webrtc.hw.acceleration";
|
|
|
|
break;
|
2011-01-20 04:30:15 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the value of the pref for the relevant feature in aValue.
|
|
|
|
// If the pref doesn't exist, aValue is not touched, and returns false.
|
|
|
|
static bool
|
2012-08-22 19:56:38 +04:00
|
|
|
GetPrefValueForFeature(int32_t aFeature, int32_t& aValue)
|
2011-01-20 04:30:15 +03:00
|
|
|
{
|
|
|
|
const char *prefname = GetPrefNameForFeature(aFeature);
|
|
|
|
if (!prefname)
|
|
|
|
return false;
|
|
|
|
|
2015-05-28 18:54:07 +03:00
|
|
|
aValue = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
|
2011-05-23 18:54:03 +04:00
|
|
|
return NS_SUCCEEDED(Preferences::GetInt(prefname, &aValue));
|
2011-01-20 04:30:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-08-22 19:56:38 +04:00
|
|
|
SetPrefValueForFeature(int32_t aFeature, int32_t aValue)
|
2011-01-20 04:30:15 +03:00
|
|
|
{
|
|
|
|
const char *prefname = GetPrefNameForFeature(aFeature);
|
|
|
|
if (!prefname)
|
|
|
|
return;
|
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
Preferences::SetInt(prefname, aValue);
|
2011-01-20 04:30:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-08-22 19:56:38 +04:00
|
|
|
RemovePrefForFeature(int32_t aFeature)
|
2011-01-20 04:30:15 +03:00
|
|
|
{
|
|
|
|
const char *prefname = GetPrefNameForFeature(aFeature);
|
|
|
|
if (!prefname)
|
|
|
|
return;
|
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
Preferences::ClearUser(prefname);
|
2011-01-20 04:30:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
2011-05-23 18:54:03 +04:00
|
|
|
GetPrefValueForDriverVersion(nsCString& aVersion)
|
2011-01-20 04:30:15 +03:00
|
|
|
{
|
2011-05-27 08:53:03 +04:00
|
|
|
return NS_SUCCEEDED(Preferences::GetCString(SUGGESTED_VERSION_PREF,
|
|
|
|
&aVersion));
|
2011-01-20 04:30:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-05-27 08:53:03 +04:00
|
|
|
SetPrefValueForDriverVersion(const nsAString& aVersion)
|
2011-01-20 04:30:15 +03:00
|
|
|
{
|
2011-05-27 08:53:03 +04:00
|
|
|
Preferences::SetString(SUGGESTED_VERSION_PREF, aVersion);
|
2011-01-20 04:30:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
RemovePrefForDriverVersion()
|
|
|
|
{
|
2011-05-23 18:54:03 +04:00
|
|
|
Preferences::ClearUser(SUGGESTED_VERSION_PREF);
|
2011-01-20 04:30:15 +03:00
|
|
|
}
|
|
|
|
|
2011-01-20 04:33:51 +03:00
|
|
|
// <foo>Hello</foo> - "Hello" is stored as a child text node of the foo node.
|
|
|
|
static bool
|
|
|
|
BlacklistNodeToTextValue(nsIDOMNode *aBlacklistNode, nsAString& aValue)
|
|
|
|
{
|
|
|
|
nsAutoString value;
|
2011-06-14 11:56:48 +04:00
|
|
|
if (NS_FAILED(aBlacklistNode->GetTextContent(value)))
|
2011-01-20 04:33:51 +03:00
|
|
|
return false;
|
|
|
|
|
|
|
|
value.Trim(" \t\r\n");
|
|
|
|
aValue = value;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-05-15 17:42:10 +03:00
|
|
|
// <foo attr=Hello/> finds "Hello" if the aAttrName is "attr".
|
|
|
|
static bool
|
|
|
|
BlacklistAttrToTextValue(nsIDOMNode *aBlacklistNode,
|
|
|
|
const nsAString& aAttrName,
|
|
|
|
nsAString& aValue)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aBlacklistNode);
|
|
|
|
if (!element) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString value;
|
|
|
|
if (NS_FAILED(element->GetAttribute(aAttrName, value))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
value.Trim(" \t\r\n");
|
|
|
|
aValue = value;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-20 04:33:51 +03:00
|
|
|
static OperatingSystem
|
|
|
|
BlacklistOSToOperatingSystem(const nsAString& os)
|
|
|
|
{
|
2014-05-22 07:48:50 +04:00
|
|
|
if (os.EqualsLiteral("WINNT 5.1"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_OS_WINDOWS_XP;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (os.EqualsLiteral("WINNT 5.2"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_OS_WINDOWS_SERVER_2003;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (os.EqualsLiteral("WINNT 6.0"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_OS_WINDOWS_VISTA;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (os.EqualsLiteral("WINNT 6.1"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_OS_WINDOWS_7;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (os.EqualsLiteral("WINNT 6.2"))
|
2012-08-31 20:42:07 +04:00
|
|
|
return DRIVER_OS_WINDOWS_8;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (os.EqualsLiteral("WINNT 6.3"))
|
2013-09-13 22:08:05 +04:00
|
|
|
return DRIVER_OS_WINDOWS_8_1;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (os.EqualsLiteral("Linux"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_OS_LINUX;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (os.EqualsLiteral("Darwin 9"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_OS_OS_X_10_5;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (os.EqualsLiteral("Darwin 10"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_OS_OS_X_10_6;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (os.EqualsLiteral("Darwin 11"))
|
2011-11-03 18:50:40 +04:00
|
|
|
return DRIVER_OS_OS_X_10_7;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (os.EqualsLiteral("Darwin 12"))
|
2012-08-31 20:42:07 +04:00
|
|
|
return DRIVER_OS_OS_X_10_8;
|
2014-11-29 01:28:59 +03:00
|
|
|
else if (os.EqualsLiteral("Darwin 13"))
|
|
|
|
return DRIVER_OS_OS_X_10_9;
|
|
|
|
else if (os.EqualsLiteral("Darwin 14"))
|
|
|
|
return DRIVER_OS_OS_X_10_10;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (os.EqualsLiteral("Android"))
|
2011-11-03 18:50:40 +04:00
|
|
|
return DRIVER_OS_ANDROID;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (os.EqualsLiteral("All"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_OS_ALL;
|
|
|
|
|
|
|
|
return DRIVER_OS_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2011-12-15 09:03:01 +04:00
|
|
|
static GfxDeviceFamily*
|
2012-09-26 18:17:47 +04:00
|
|
|
BlacklistDevicesToDeviceFamily(nsIDOMHTMLCollection* aDevices)
|
2011-01-20 04:33:51 +03:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t length;
|
2011-01-20 04:33:51 +03:00
|
|
|
if (NS_FAILED(aDevices->GetLength(&length)))
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2011-01-20 04:33:51 +03:00
|
|
|
|
2011-12-15 09:03:01 +04:00
|
|
|
// For each <device>, get its device ID, and return a freshly-allocated
|
|
|
|
// GfxDeviceFamily with the contents of that array.
|
|
|
|
GfxDeviceFamily* deviceIds = new GfxDeviceFamily;
|
2011-01-20 04:33:51 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < length; ++i) {
|
2011-01-20 04:33:51 +03:00
|
|
|
nsCOMPtr<nsIDOMNode> node;
|
|
|
|
if (NS_FAILED(aDevices->Item(i, getter_AddRefs(node))) || !node)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
nsAutoString deviceValue;
|
|
|
|
if (!BlacklistNodeToTextValue(node, deviceValue))
|
|
|
|
continue;
|
|
|
|
|
2011-12-15 09:03:01 +04:00
|
|
|
deviceIds->AppendElement(deviceValue);
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
2011-12-15 09:03:01 +04:00
|
|
|
return deviceIds;
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t
|
2011-01-20 04:33:51 +03:00
|
|
|
BlacklistFeatureToGfxFeature(const nsAString& aFeature)
|
|
|
|
{
|
2015-05-15 17:42:11 +03:00
|
|
|
MOZ_ASSERT(!aFeature.IsEmpty());
|
2014-05-22 07:48:50 +04:00
|
|
|
if (aFeature.EqualsLiteral("DIRECT2D"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_DIRECT2D;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("DIRECT3D_9_LAYERS"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("DIRECT3D_10_LAYERS"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("DIRECT3D_10_1_LAYERS"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("DIRECT3D_11_LAYERS"))
|
2014-05-16 20:16:21 +04:00
|
|
|
return nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS;
|
2015-04-10 23:17:27 +03:00
|
|
|
else if (aFeature.EqualsLiteral("DIRECT3D_11_ANGLE"))
|
|
|
|
return nsIGfxInfo::FEATURE_DIRECT3D_11_ANGLE;
|
2015-04-01 06:06:56 +03:00
|
|
|
else if (aFeature.EqualsLiteral("HARDWARE_VIDEO_DECODING"))
|
|
|
|
return nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("OPENGL_LAYERS"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_OPENGL_LAYERS;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("WEBGL_OPENGL"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_WEBGL_OPENGL;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("WEBGL_ANGLE"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_WEBGL_ANGLE;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("WEBGL_MSAA"))
|
2011-11-03 18:50:40 +04:00
|
|
|
return nsIGfxInfo::FEATURE_WEBGL_MSAA;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("STAGEFRIGHT"))
|
2012-11-02 01:13:10 +04:00
|
|
|
return nsIGfxInfo::FEATURE_STAGEFRIGHT;
|
2015-05-15 17:42:10 +03:00
|
|
|
else if (aFeature.EqualsLiteral("WEBRTC_HW_ACCELERATION"))
|
|
|
|
return nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION;
|
2015-05-15 17:42:11 +03:00
|
|
|
|
|
|
|
// If we don't recognize the feature, it may be new, and something
|
|
|
|
// this version doesn't understand. So, nothing to do. This is
|
|
|
|
// different from feature not being specified at all, in which case
|
|
|
|
// this method should not get called and we should continue with the
|
|
|
|
// "all features" blocklisting.
|
|
|
|
return -1;
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t
|
2011-01-20 04:33:51 +03:00
|
|
|
BlacklistFeatureStatusToGfxFeatureStatus(const nsAString& aStatus)
|
|
|
|
{
|
2014-07-02 01:44:09 +04:00
|
|
|
if (aStatus.EqualsLiteral("STATUS_OK"))
|
|
|
|
return nsIGfxInfo::FEATURE_STATUS_OK;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aStatus.EqualsLiteral("BLOCKED_DRIVER_VERSION"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aStatus.EqualsLiteral("BLOCKED_DEVICE"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aStatus.EqualsLiteral("DISCOURAGED"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_DISCOURAGED;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aStatus.EqualsLiteral("BLOCKED_OS_VERSION"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION;
|
|
|
|
|
2015-05-15 20:43:38 +03:00
|
|
|
// Do not allow it to set STATUS_UNKNOWN. Also, we are not
|
|
|
|
// expecting the "mismatch" status showing up here.
|
2011-12-15 09:02:59 +04:00
|
|
|
|
2014-07-02 01:44:09 +04:00
|
|
|
return nsIGfxInfo::FEATURE_STATUS_OK;
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static VersionComparisonOp
|
|
|
|
BlacklistComparatorToComparisonOp(const nsAString& op)
|
|
|
|
{
|
2014-05-22 07:48:50 +04:00
|
|
|
if (op.EqualsLiteral("LESS_THAN"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_LESS_THAN;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (op.EqualsLiteral("LESS_THAN_OR_EQUAL"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_LESS_THAN_OR_EQUAL;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (op.EqualsLiteral("GREATER_THAN"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_GREATER_THAN;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (op.EqualsLiteral("GREATER_THAN_OR_EQUAL"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_GREATER_THAN_OR_EQUAL;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (op.EqualsLiteral("EQUAL"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_EQUAL;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (op.EqualsLiteral("NOT_EQUAL"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_NOT_EQUAL;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (op.EqualsLiteral("BETWEEN_EXCLUSIVE"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_BETWEEN_EXCLUSIVE;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (op.EqualsLiteral("BETWEEN_INCLUSIVE"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_BETWEEN_INCLUSIVE;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (op.EqualsLiteral("BETWEEN_INCLUSIVE_START"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_BETWEEN_INCLUSIVE_START;
|
|
|
|
|
2012-05-04 23:33:59 +04:00
|
|
|
return DRIVER_COMPARISON_IGNORED;
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Arbitrarily returns the first |tagname| child of |element|.
|
|
|
|
static bool
|
|
|
|
BlacklistNodeGetChildByName(nsIDOMElement *element,
|
|
|
|
const nsAString& tagname,
|
|
|
|
nsIDOMNode** firstchild)
|
|
|
|
{
|
2012-09-26 18:17:47 +04:00
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> nodelist;
|
2011-01-20 04:33:51 +03:00
|
|
|
if (NS_FAILED(element->GetElementsByTagName(tagname,
|
|
|
|
getter_AddRefs(nodelist))) ||
|
|
|
|
!nodelist) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> node;
|
|
|
|
if (NS_FAILED(nodelist->Item(0, getter_AddRefs(node))) || !node)
|
|
|
|
return false;
|
|
|
|
|
2014-03-15 23:00:15 +04:00
|
|
|
node.forget(firstchild);
|
2011-01-20 04:33:51 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
<gfxBlacklistEntry>
|
|
|
|
<os>WINNT 6.0</os>
|
|
|
|
<vendor>0x8086</vendor>
|
|
|
|
<devices>
|
|
|
|
<device>0x2582</device>
|
|
|
|
<device>0x2782</device>
|
|
|
|
</devices>
|
|
|
|
<feature> DIRECT3D_10_LAYERS </feature>
|
|
|
|
<featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
|
|
|
|
<driverVersion> 8.52.322.2202 </driverVersion>
|
|
|
|
<driverVersionComparator> LESS_THAN_OR_EQUAL </driverVersionComparator>
|
|
|
|
</gfxBlacklistEntry>
|
|
|
|
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
BlacklistEntryToDriverInfo(nsIDOMNode* aBlacklistEntry,
|
|
|
|
GfxDriverInfo& aDriverInfo)
|
|
|
|
{
|
|
|
|
nsAutoString nodename;
|
|
|
|
if (NS_FAILED(aBlacklistEntry->GetNodeName(nodename)) ||
|
|
|
|
nodename != NS_LITERAL_STRING(BLACKLIST_ENTRY_TAG_NAME)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aBlacklistEntry);
|
|
|
|
if (!element)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> dataNode;
|
|
|
|
nsAutoString dataValue;
|
|
|
|
|
2015-05-15 17:42:10 +03:00
|
|
|
// If we get an application version to be zero, something is not working
|
|
|
|
// and we are not going to bother checking the blocklist versions.
|
|
|
|
// See TestGfxWidgets.cpp for how version comparison works.
|
|
|
|
// <versionRange minVersion="42.0a1" maxVersion="45.0"></versionRange>
|
|
|
|
static mozilla::Version zeroV("0");
|
|
|
|
static mozilla::Version appV(GfxInfoBase::GetApplicationVersion().get());
|
|
|
|
if (appV <= zeroV) {
|
|
|
|
gfxCriticalErrorOnce(gfxCriticalError::DefaultOptions(false)) << "Invalid application version " << GfxInfoBase::GetApplicationVersion().get();
|
|
|
|
} else if (BlacklistNodeGetChildByName(element,
|
|
|
|
NS_LITERAL_STRING("versionRange"),
|
|
|
|
getter_AddRefs(dataNode))) {
|
|
|
|
if (BlacklistAttrToTextValue(dataNode,
|
|
|
|
NS_LITERAL_STRING("minVersion"),
|
|
|
|
dataValue)) {
|
|
|
|
mozilla::Version minV(NS_ConvertUTF16toUTF8(dataValue).get());
|
|
|
|
if (minV > zeroV && appV < minV) {
|
|
|
|
// The version of the application is less than the minimal version
|
|
|
|
// this blocklist entry applies to, so we can just ignore it by
|
|
|
|
// returning false and letting the caller deal with it.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BlacklistAttrToTextValue(dataNode,
|
|
|
|
NS_LITERAL_STRING("maxVersion"),
|
|
|
|
dataValue)) {
|
|
|
|
mozilla::Version maxV(NS_ConvertUTF16toUTF8(dataValue).get());
|
|
|
|
if (maxV > zeroV && appV > maxV) {
|
|
|
|
// The version of the application is more than the maximal version
|
|
|
|
// this blocklist entry applies to, so we can just ignore it by
|
|
|
|
// returning false and letting the caller deal with it.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-20 04:33:51 +03:00
|
|
|
// <os>WINNT 6.0</os>
|
|
|
|
if (BlacklistNodeGetChildByName(element, NS_LITERAL_STRING("os"),
|
|
|
|
getter_AddRefs(dataNode))) {
|
|
|
|
BlacklistNodeToTextValue(dataNode, dataValue);
|
|
|
|
aDriverInfo.mOperatingSystem = BlacklistOSToOperatingSystem(dataValue);
|
|
|
|
}
|
|
|
|
|
2012-11-02 01:13:10 +04:00
|
|
|
// <osversion>14</osversion> currently only used for Android
|
|
|
|
if (BlacklistNodeGetChildByName(element, NS_LITERAL_STRING("osversion"),
|
|
|
|
getter_AddRefs(dataNode))) {
|
|
|
|
BlacklistNodeToTextValue(dataNode, dataValue);
|
2013-10-28 18:05:51 +04:00
|
|
|
aDriverInfo.mOperatingSystemVersion = strtoul(NS_LossyConvertUTF16toASCII(dataValue).get(),
|
|
|
|
nullptr, 10);
|
2012-11-02 01:13:10 +04:00
|
|
|
}
|
|
|
|
|
2011-01-20 04:33:51 +03:00
|
|
|
// <vendor>0x8086</vendor>
|
|
|
|
if (BlacklistNodeGetChildByName(element, NS_LITERAL_STRING("vendor"),
|
|
|
|
getter_AddRefs(dataNode))) {
|
|
|
|
BlacklistNodeToTextValue(dataNode, dataValue);
|
2011-12-15 09:03:01 +04:00
|
|
|
aDriverInfo.mAdapterVendor = dataValue;
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// <devices>
|
|
|
|
// <device>0x2582</device>
|
|
|
|
// <device>0x2782</device>
|
|
|
|
// </devices>
|
|
|
|
if (BlacklistNodeGetChildByName(element, NS_LITERAL_STRING("devices"),
|
|
|
|
getter_AddRefs(dataNode))) {
|
|
|
|
nsCOMPtr<nsIDOMElement> devicesElement = do_QueryInterface(dataNode);
|
|
|
|
if (devicesElement) {
|
|
|
|
|
|
|
|
// Get only the <device> nodes, because BlacklistDevicesToDeviceFamily
|
|
|
|
// assumes it is passed no other nodes.
|
2012-09-26 18:17:47 +04:00
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> devices;
|
2011-01-20 04:33:51 +03:00
|
|
|
if (NS_SUCCEEDED(devicesElement->GetElementsByTagName(NS_LITERAL_STRING("device"),
|
|
|
|
getter_AddRefs(devices)))) {
|
2011-12-15 09:03:01 +04:00
|
|
|
GfxDeviceFamily* deviceIds = BlacklistDevicesToDeviceFamily(devices);
|
2011-01-20 04:33:51 +03:00
|
|
|
if (deviceIds) {
|
|
|
|
// Get GfxDriverInfo to adopt the devices array we created.
|
|
|
|
aDriverInfo.mDeleteDevices = true;
|
|
|
|
aDriverInfo.mDevices = deviceIds;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// <feature> DIRECT3D_10_LAYERS </feature>
|
|
|
|
if (BlacklistNodeGetChildByName(element, NS_LITERAL_STRING("feature"),
|
|
|
|
getter_AddRefs(dataNode))) {
|
|
|
|
BlacklistNodeToTextValue(dataNode, dataValue);
|
|
|
|
aDriverInfo.mFeature = BlacklistFeatureToGfxFeature(dataValue);
|
2015-05-15 17:42:11 +03:00
|
|
|
if (aDriverInfo.mFeature < 0) {
|
|
|
|
// If we don't recognize the feature, we do not want to proceed.
|
|
|
|
gfxWarning() << "Unrecognized feature " << NS_ConvertUTF16toUTF8(dataValue).get();
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
|
|
|
|
if (BlacklistNodeGetChildByName(element, NS_LITERAL_STRING("featureStatus"),
|
|
|
|
getter_AddRefs(dataNode))) {
|
|
|
|
BlacklistNodeToTextValue(dataNode, dataValue);
|
|
|
|
aDriverInfo.mFeatureStatus = BlacklistFeatureStatusToGfxFeatureStatus(dataValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
// <driverVersion> 8.52.322.2202 </driverVersion>
|
|
|
|
if (BlacklistNodeGetChildByName(element, NS_LITERAL_STRING("driverVersion"),
|
|
|
|
getter_AddRefs(dataNode))) {
|
|
|
|
BlacklistNodeToTextValue(dataNode, dataValue);
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t version;
|
2011-01-20 04:33:51 +03:00
|
|
|
if (ParseDriverVersion(dataValue, &version))
|
|
|
|
aDriverInfo.mDriverVersion = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
// <driverVersionComparator> LESS_THAN_OR_EQUAL </driverVersionComparator>
|
|
|
|
if (BlacklistNodeGetChildByName(element, NS_LITERAL_STRING("driverVersionComparator"),
|
|
|
|
getter_AddRefs(dataNode))) {
|
|
|
|
BlacklistNodeToTextValue(dataNode, dataValue);
|
|
|
|
aDriverInfo.mComparisonOp = BlacklistComparatorToComparisonOp(dataValue);
|
|
|
|
}
|
|
|
|
|
2012-11-02 01:13:10 +04:00
|
|
|
// <model>foo</model>
|
|
|
|
if (BlacklistNodeGetChildByName(element, NS_LITERAL_STRING("model"),
|
|
|
|
getter_AddRefs(dataNode))) {
|
|
|
|
BlacklistNodeToTextValue(dataNode, dataValue);
|
|
|
|
aDriverInfo.mModel = dataValue;
|
|
|
|
}
|
|
|
|
// <product>foo</product>
|
|
|
|
if (BlacklistNodeGetChildByName(element, NS_LITERAL_STRING("product"),
|
|
|
|
getter_AddRefs(dataNode))) {
|
|
|
|
BlacklistNodeToTextValue(dataNode, dataValue);
|
|
|
|
aDriverInfo.mProduct = dataValue;
|
|
|
|
}
|
|
|
|
// <manufacturer>foo</manufacturer>
|
|
|
|
if (BlacklistNodeGetChildByName(element, NS_LITERAL_STRING("manufacturer"),
|
|
|
|
getter_AddRefs(dataNode))) {
|
|
|
|
BlacklistNodeToTextValue(dataNode, dataValue);
|
|
|
|
aDriverInfo.mManufacturer = dataValue;
|
|
|
|
}
|
|
|
|
// <hardware>foo</hardware>
|
|
|
|
if (BlacklistNodeGetChildByName(element, NS_LITERAL_STRING("hardware"),
|
|
|
|
getter_AddRefs(dataNode))) {
|
|
|
|
BlacklistNodeToTextValue(dataNode, dataValue);
|
|
|
|
aDriverInfo.mHardware = dataValue;
|
|
|
|
}
|
|
|
|
|
2011-01-20 04:33:51 +03:00
|
|
|
// We explicitly ignore unknown elements.
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-09-26 18:17:47 +04:00
|
|
|
BlacklistEntriesToDriverInfo(nsIDOMHTMLCollection* aBlacklistEntries,
|
2011-01-20 04:33:51 +03:00
|
|
|
nsTArray<GfxDriverInfo>& aDriverInfo)
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t length;
|
2011-01-20 04:33:51 +03:00
|
|
|
if (NS_FAILED(aBlacklistEntries->GetLength(&length)))
|
|
|
|
return;
|
|
|
|
|
2011-12-15 09:03:01 +04:00
|
|
|
aDriverInfo.Clear();
|
|
|
|
aDriverInfo.SetLength(length);
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < length; ++i) {
|
2011-01-20 04:33:51 +03:00
|
|
|
nsCOMPtr<nsIDOMNode> blacklistEntry;
|
|
|
|
if (NS_SUCCEEDED(aBlacklistEntries->Item(i,
|
|
|
|
getter_AddRefs(blacklistEntry))) &&
|
|
|
|
blacklistEntry) {
|
|
|
|
GfxDriverInfo di;
|
|
|
|
if (BlacklistEntryToDriverInfo(blacklistEntry, di)) {
|
2011-12-15 09:03:01 +04:00
|
|
|
aDriverInfo[i] = di;
|
2015-05-15 17:42:10 +03:00
|
|
|
// Prevent di falling out of scope from destroying the devices.
|
|
|
|
di.mDeleteDevices = false;
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GfxInfoBase::Observe(nsISupports* aSubject, const char* aTopic,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* aData)
|
2011-01-20 04:33:51 +03:00
|
|
|
{
|
|
|
|
if (strcmp(aTopic, "blocklist-data-gfxItems") == 0) {
|
|
|
|
nsCOMPtr<nsIDOMElement> gfxItems = do_QueryInterface(aSubject);
|
|
|
|
if (gfxItems) {
|
2012-09-26 18:17:47 +04:00
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> blacklistEntries;
|
2011-01-20 04:33:51 +03:00
|
|
|
if (NS_SUCCEEDED(gfxItems->
|
|
|
|
GetElementsByTagName(NS_LITERAL_STRING(BLACKLIST_ENTRY_TAG_NAME),
|
|
|
|
getter_AddRefs(blacklistEntries))) &&
|
|
|
|
blacklistEntries)
|
|
|
|
{
|
|
|
|
nsTArray<GfxDriverInfo> driverInfo;
|
|
|
|
BlacklistEntriesToDriverInfo(blacklistEntries, driverInfo);
|
2011-01-20 04:35:51 +03:00
|
|
|
EvaluateDownloadedBlacklist(driverInfo);
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
GfxInfoBase::GfxInfoBase()
|
2015-01-14 05:19:25 +03:00
|
|
|
: mMutex("GfxInfoBase")
|
2011-01-20 04:33:51 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GfxInfoBase::~GfxInfoBase()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
GfxInfoBase::Init()
|
|
|
|
{
|
2011-12-15 09:03:01 +04:00
|
|
|
InitGfxDriverInfoShutdownObserver();
|
2015-06-17 01:49:26 +03:00
|
|
|
gfxPrefs::GetSingleton();
|
2011-12-15 09:03:01 +04:00
|
|
|
|
2011-01-20 04:33:51 +03:00
|
|
|
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
|
|
|
if (os) {
|
2011-10-17 18:59:28 +04:00
|
|
|
os->AddObserver(this, "blocklist-data-gfxItems", true);
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 04:30:12 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
GfxInfoBase::GetFeatureStatus(int32_t aFeature, int32_t* aStatus)
|
2011-01-20 04:30:12 +03:00
|
|
|
{
|
2015-05-28 18:54:07 +03:00
|
|
|
int32_t blocklistAll = gfxPrefs::BlocklistAll();
|
|
|
|
if (blocklistAll > 0) {
|
|
|
|
gfxCriticalErrorOnce(gfxCriticalError::DefaultOptions(false)) << "Forcing blocklisting all features";
|
|
|
|
*aStatus = FEATURE_BLOCKED_DEVICE;
|
|
|
|
return NS_OK;
|
|
|
|
} else if (blocklistAll < 0) {
|
|
|
|
gfxCriticalErrorOnce(gfxCriticalError::DefaultOptions(false)) << "Ignoring any feature blocklisting.";
|
|
|
|
*aStatus = FEATURE_STATUS_OK;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 04:30:15 +03:00
|
|
|
if (GetPrefValueForFeature(aFeature, *aStatus))
|
|
|
|
return NS_OK;
|
|
|
|
|
2014-01-11 05:09:20 +04:00
|
|
|
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
|
|
|
// Delegate to the parent process.
|
|
|
|
mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton();
|
|
|
|
bool success;
|
|
|
|
cc->SendGetGraphicsFeatureStatus(aFeature, aStatus, &success);
|
|
|
|
return success ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2011-01-20 04:30:12 +03:00
|
|
|
nsString version;
|
2011-12-15 09:02:59 +04:00
|
|
|
nsTArray<GfxDriverInfo> driverInfo;
|
|
|
|
return GetFeatureStatusImpl(aFeature, aStatus, version, driverInfo);
|
2011-01-20 04:30:12 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
2011-12-15 09:02:59 +04:00
|
|
|
GfxInfoBase::FindBlocklistedDeviceInList(const nsTArray<GfxDriverInfo>& info,
|
|
|
|
nsAString& aSuggestedVersion,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aFeature,
|
2011-12-15 09:02:59 +04:00
|
|
|
OperatingSystem os)
|
2011-11-03 18:50:40 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t status = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
|
2011-11-03 18:50:40 +04:00
|
|
|
|
2015-03-21 22:37:00 +03:00
|
|
|
uint32_t i = 0;
|
|
|
|
for (; i < info.Length(); i++) {
|
2015-05-15 17:42:10 +03:00
|
|
|
// Do the operating system check first, no point in getting the driver
|
2015-05-15 17:42:10 +03:00
|
|
|
// info if we won't need to use it. Note we also catch and skips the
|
2015-05-15 17:42:10 +03:00
|
|
|
// application version mismatches that would leave operating system
|
|
|
|
// set to unknown.
|
2015-05-15 17:42:10 +03:00
|
|
|
if (info[i].mOperatingSystem == DRIVER_OS_UNKNOWN ||
|
|
|
|
(info[i].mOperatingSystem != DRIVER_OS_ALL &&
|
|
|
|
info[i].mOperatingSystem != os))
|
2015-05-15 17:42:10 +03:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info[i].mOperatingSystemVersion && info[i].mOperatingSystemVersion != OperatingSystemVersion()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-03-21 22:37:00 +03:00
|
|
|
// XXX: it would be better not to do this everytime round the loop
|
|
|
|
nsAutoString adapterVendorID;
|
|
|
|
nsAutoString adapterDeviceID;
|
|
|
|
nsAutoString adapterDriverVersionString;
|
|
|
|
if (info[i].mGpu2) {
|
|
|
|
if (NS_FAILED(GetAdapterVendorID2(adapterVendorID)) ||
|
|
|
|
NS_FAILED(GetAdapterDeviceID2(adapterDeviceID)) ||
|
|
|
|
NS_FAILED(GetAdapterDriverVersion2(adapterDriverVersionString)))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (NS_FAILED(GetAdapterVendorID(adapterVendorID)) ||
|
|
|
|
NS_FAILED(GetAdapterDeviceID(adapterDeviceID)) ||
|
|
|
|
NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString)))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2011-11-03 18:50:40 +04:00
|
|
|
|
2014-05-06 10:38:24 +04:00
|
|
|
#if defined(XP_WIN) || defined(ANDROID)
|
2015-03-21 22:37:00 +03:00
|
|
|
uint64_t driverVersion;
|
|
|
|
ParseDriverVersion(adapterDriverVersionString, &driverVersion);
|
2014-05-06 10:38:24 +04:00
|
|
|
#endif
|
2011-11-03 18:50:40 +04:00
|
|
|
|
2012-02-21 23:49:06 +04:00
|
|
|
if (!info[i].mAdapterVendor.Equals(GfxDriverInfo::GetDeviceVendor(VendorAll), nsCaseInsensitiveStringComparator()) &&
|
|
|
|
!info[i].mAdapterVendor.Equals(adapterVendorID, nsCaseInsensitiveStringComparator())) {
|
2011-11-03 18:50:40 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-12-15 09:03:01 +04:00
|
|
|
if (info[i].mDevices != GfxDriverInfo::allDevices && info[i].mDevices->Length()) {
|
2011-11-03 18:50:40 +04:00
|
|
|
bool deviceMatches = false;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t j = 0; j < info[i].mDevices->Length(); j++) {
|
2012-02-21 23:49:06 +04:00
|
|
|
if ((*info[i].mDevices)[j].Equals(adapterDeviceID, nsCaseInsensitiveStringComparator())) {
|
2011-11-03 18:50:40 +04:00
|
|
|
deviceMatches = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!deviceMatches) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool match = false;
|
|
|
|
|
2012-11-02 01:13:10 +04:00
|
|
|
if (!info[i].mHardware.IsEmpty() && !info[i].mHardware.Equals(Hardware())) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!info[i].mModel.IsEmpty() && !info[i].mModel.Equals(Model())) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!info[i].mProduct.IsEmpty() && !info[i].mProduct.Equals(Product())) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!info[i].mManufacturer.IsEmpty() && !info[i].mManufacturer.Equals(Manufacturer())) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-12-15 09:03:03 +04:00
|
|
|
#if defined(XP_WIN) || defined(ANDROID)
|
2011-12-15 09:02:59 +04:00
|
|
|
switch (info[i].mComparisonOp) {
|
2011-11-03 18:50:40 +04:00
|
|
|
case DRIVER_LESS_THAN:
|
2011-12-15 09:02:59 +04:00
|
|
|
match = driverVersion < info[i].mDriverVersion;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
case DRIVER_LESS_THAN_OR_EQUAL:
|
2011-12-15 09:02:59 +04:00
|
|
|
match = driverVersion <= info[i].mDriverVersion;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
case DRIVER_GREATER_THAN:
|
2011-12-15 09:02:59 +04:00
|
|
|
match = driverVersion > info[i].mDriverVersion;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
case DRIVER_GREATER_THAN_OR_EQUAL:
|
2011-12-15 09:02:59 +04:00
|
|
|
match = driverVersion >= info[i].mDriverVersion;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
case DRIVER_EQUAL:
|
2011-12-15 09:02:59 +04:00
|
|
|
match = driverVersion == info[i].mDriverVersion;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
case DRIVER_NOT_EQUAL:
|
2011-12-15 09:02:59 +04:00
|
|
|
match = driverVersion != info[i].mDriverVersion;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
case DRIVER_BETWEEN_EXCLUSIVE:
|
2011-12-15 09:02:59 +04:00
|
|
|
match = driverVersion > info[i].mDriverVersion && driverVersion < info[i].mDriverVersionMax;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
case DRIVER_BETWEEN_INCLUSIVE:
|
2011-12-15 09:02:59 +04:00
|
|
|
match = driverVersion >= info[i].mDriverVersion && driverVersion <= info[i].mDriverVersionMax;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
case DRIVER_BETWEEN_INCLUSIVE_START:
|
2011-12-15 09:02:59 +04:00
|
|
|
match = driverVersion >= info[i].mDriverVersion && driverVersion < info[i].mDriverVersionMax;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
2012-05-04 23:33:59 +04:00
|
|
|
case DRIVER_COMPARISON_IGNORED:
|
|
|
|
// We don't have a comparison op, so we match everything.
|
|
|
|
match = true;
|
|
|
|
break;
|
2011-11-03 18:50:40 +04:00
|
|
|
default:
|
|
|
|
NS_WARNING("Bogus op in GfxDriverInfo");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
// We don't care what driver version it was. We only check OS version and if
|
|
|
|
// the device matches.
|
|
|
|
match = true;
|
|
|
|
#endif
|
|
|
|
|
2011-12-15 09:03:03 +04:00
|
|
|
if (match || info[i].mDriverVersion == GfxDriverInfo::allDriverVersions) {
|
2011-12-15 09:02:59 +04:00
|
|
|
if (info[i].mFeature == GfxDriverInfo::allFeatures ||
|
|
|
|
info[i].mFeature == aFeature)
|
2011-11-03 18:50:40 +04:00
|
|
|
{
|
2011-12-15 09:02:59 +04:00
|
|
|
status = info[i].mFeatureStatus;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-13 08:25:13 +04:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
// As a very special case, we block D2D on machines with an NVidia 310M GPU
|
|
|
|
// as either the primary or secondary adapter. D2D is also blocked when the
|
|
|
|
// NV 310M is the primary adapter (using the standard blocklisting mechanism).
|
|
|
|
// If the primary GPU already matched something in the blocklist then we
|
|
|
|
// ignore this special rule. See bug 1008759.
|
|
|
|
if (status == nsIGfxInfo::FEATURE_STATUS_UNKNOWN &&
|
|
|
|
(aFeature == nsIGfxInfo::FEATURE_DIRECT2D)) {
|
|
|
|
nsAutoString adapterVendorID2;
|
|
|
|
nsAutoString adapterDeviceID2;
|
|
|
|
if ((!NS_FAILED(GetAdapterVendorID2(adapterVendorID2))) &&
|
|
|
|
(!NS_FAILED(GetAdapterDeviceID2(adapterDeviceID2))))
|
|
|
|
{
|
|
|
|
nsAString &nvVendorID = (nsAString &)GfxDriverInfo::GetDeviceVendor(VendorNVIDIA);
|
|
|
|
const nsString nv310mDeviceId = NS_LITERAL_STRING("0x0A70");
|
|
|
|
if (nvVendorID.Equals(adapterVendorID2, nsCaseInsensitiveStringComparator()) &&
|
|
|
|
nv310mDeviceId.Equals(adapterDeviceID2, nsCaseInsensitiveStringComparator())) {
|
|
|
|
status = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-03 18:50:40 +04:00
|
|
|
// Depends on Windows driver versioning. We don't pass a GfxDriverInfo object
|
|
|
|
// back to the Windows handler, so we must handle this here.
|
|
|
|
if (status == FEATURE_BLOCKED_DRIVER_VERSION) {
|
2011-12-15 09:02:59 +04:00
|
|
|
if (info[i].mSuggestedVersion) {
|
|
|
|
aSuggestedVersion.AppendPrintf("%s", info[i].mSuggestedVersion);
|
|
|
|
} else if (info[i].mComparisonOp == DRIVER_LESS_THAN &&
|
|
|
|
info[i].mDriverVersion != GfxDriverInfo::allDriverVersions)
|
2011-11-03 18:50:40 +04:00
|
|
|
{
|
2011-12-15 09:02:59 +04:00
|
|
|
aSuggestedVersion.AppendPrintf("%lld.%lld.%lld.%lld",
|
|
|
|
(info[i].mDriverVersion & 0xffff000000000000) >> 48,
|
|
|
|
(info[i].mDriverVersion & 0x0000ffff00000000) >> 32,
|
|
|
|
(info[i].mDriverVersion & 0x00000000ffff0000) >> 16,
|
|
|
|
(info[i].mDriverVersion & 0x000000000000ffff));
|
2011-11-03 18:50:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-12-15 09:02:59 +04:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
GfxInfoBase::GetFeatureStatusImpl(int32_t aFeature,
|
|
|
|
int32_t* aStatus,
|
2011-12-15 09:02:59 +04:00
|
|
|
nsAString& aSuggestedVersion,
|
|
|
|
const nsTArray<GfxDriverInfo>& aDriverInfo,
|
2012-07-30 18:20:58 +04:00
|
|
|
OperatingSystem* aOS /* = nullptr */)
|
2011-12-15 09:02:59 +04:00
|
|
|
{
|
2015-05-15 19:55:53 +03:00
|
|
|
if (aFeature <= 0) {
|
|
|
|
gfxWarning() << "Invalid feature <= 0";
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-12-15 09:02:59 +04:00
|
|
|
if (*aStatus != nsIGfxInfo::FEATURE_STATUS_UNKNOWN) {
|
|
|
|
// Terminate now with the status determined by the derived type (OS-specific
|
|
|
|
// code).
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If an operating system was provided by the derived GetFeatureStatusImpl,
|
|
|
|
// grab it here. Otherwise, the OS is unknown.
|
|
|
|
OperatingSystem os = DRIVER_OS_UNKNOWN;
|
|
|
|
if (aOS)
|
|
|
|
os = *aOS;
|
|
|
|
|
2011-12-15 09:03:01 +04:00
|
|
|
nsAutoString adapterVendorID;
|
|
|
|
nsAutoString adapterDeviceID;
|
2011-12-15 09:02:59 +04:00
|
|
|
nsAutoString adapterDriverVersionString;
|
2011-12-15 09:03:01 +04:00
|
|
|
if (NS_FAILED(GetAdapterVendorID(adapterVendorID)) ||
|
|
|
|
NS_FAILED(GetAdapterDeviceID(adapterDeviceID)) ||
|
2011-12-15 09:02:59 +04:00
|
|
|
NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString)))
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the device is blocked from the downloaded blocklist. If not, check
|
|
|
|
// the static list after that. This order is used so that we can later escape
|
|
|
|
// out of static blocks (i.e. if we were wrong or something was patched, we
|
|
|
|
// can back out our static block without doing a release).
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t status;
|
2011-12-15 09:03:01 +04:00
|
|
|
if (aDriverInfo.Length()) {
|
|
|
|
status = FindBlocklistedDeviceInList(aDriverInfo, aSuggestedVersion, aFeature, os);
|
|
|
|
} else {
|
|
|
|
if (!mDriverInfo) {
|
|
|
|
mDriverInfo = new nsTArray<GfxDriverInfo>();
|
|
|
|
}
|
2011-12-15 09:02:59 +04:00
|
|
|
status = FindBlocklistedDeviceInList(GetGfxDriverInfo(), aSuggestedVersion, aFeature, os);
|
|
|
|
}
|
|
|
|
|
2014-07-02 01:44:09 +04:00
|
|
|
// It's now done being processed. It's safe to set the status to STATUS_OK.
|
2011-12-15 09:02:59 +04:00
|
|
|
if (status == nsIGfxInfo::FEATURE_STATUS_UNKNOWN) {
|
2014-07-02 01:44:09 +04:00
|
|
|
*aStatus = nsIGfxInfo::FEATURE_STATUS_OK;
|
2011-12-15 09:02:59 +04:00
|
|
|
} else {
|
|
|
|
*aStatus = status;
|
|
|
|
}
|
|
|
|
|
2011-11-03 18:50:40 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 04:30:12 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
GfxInfoBase::GetFeatureSuggestedDriverVersion(int32_t aFeature,
|
2012-07-07 00:14:07 +04:00
|
|
|
nsAString& aVersion)
|
2011-01-20 04:30:12 +03:00
|
|
|
{
|
2011-01-20 04:30:15 +03:00
|
|
|
nsCString version;
|
|
|
|
if (GetPrefValueForDriverVersion(version)) {
|
|
|
|
aVersion = NS_ConvertASCIItoUTF16(version);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t status;
|
2011-12-15 09:02:59 +04:00
|
|
|
nsTArray<GfxDriverInfo> driverInfo;
|
|
|
|
return GetFeatureStatusImpl(aFeature, &status, aVersion, driverInfo);
|
2011-01-20 04:30:12 +03:00
|
|
|
}
|
|
|
|
|
2011-01-20 04:30:15 +03:00
|
|
|
|
2011-01-20 04:30:12 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GfxInfoBase::GetWebGLParameter(const nsAString& aParam,
|
2012-07-07 00:14:07 +04:00
|
|
|
nsAString& aResult)
|
2011-01-20 04:30:12 +03:00
|
|
|
{
|
|
|
|
return GfxInfoWebGL::GetWebGLParameter(aParam, aResult);
|
|
|
|
}
|
2011-01-20 04:35:51 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
GfxInfoBase::EvaluateDownloadedBlacklist(nsTArray<GfxDriverInfo>& aDriverInfo)
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t features[] = {
|
2011-01-20 04:35:51 +03:00
|
|
|
nsIGfxInfo::FEATURE_DIRECT2D,
|
|
|
|
nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS,
|
|
|
|
nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS,
|
|
|
|
nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS,
|
2014-05-16 20:16:21 +04:00
|
|
|
nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
|
2015-04-10 23:17:27 +03:00
|
|
|
nsIGfxInfo::FEATURE_DIRECT3D_11_ANGLE,
|
2015-04-01 06:06:56 +03:00
|
|
|
nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
|
2011-01-20 04:35:51 +03:00
|
|
|
nsIGfxInfo::FEATURE_OPENGL_LAYERS,
|
|
|
|
nsIGfxInfo::FEATURE_WEBGL_OPENGL,
|
|
|
|
nsIGfxInfo::FEATURE_WEBGL_ANGLE,
|
2011-11-03 18:50:40 +04:00
|
|
|
nsIGfxInfo::FEATURE_WEBGL_MSAA,
|
2012-11-02 01:13:10 +04:00
|
|
|
nsIGfxInfo::FEATURE_STAGEFRIGHT,
|
2015-05-15 17:42:10 +03:00
|
|
|
nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION,
|
2011-01-20 04:35:51 +03:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
// For every feature we know about, we evaluate whether this blacklist has a
|
2014-07-02 01:44:09 +04:00
|
|
|
// non-STATUS_OK status. If it does, we set the pref we evaluate in
|
2011-01-20 04:35:51 +03:00
|
|
|
// GetFeatureStatus above, so we don't need to hold on to this blacklist
|
|
|
|
// anywhere permanent.
|
|
|
|
int i = 0;
|
|
|
|
while (features[i]) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t status;
|
2011-01-20 04:35:51 +03:00
|
|
|
nsAutoString suggestedVersion;
|
|
|
|
if (NS_SUCCEEDED(GetFeatureStatusImpl(features[i], &status,
|
|
|
|
suggestedVersion,
|
2011-12-15 09:02:59 +04:00
|
|
|
aDriverInfo))) {
|
2011-01-20 04:35:51 +03:00
|
|
|
switch (status) {
|
|
|
|
default:
|
2014-07-02 01:44:09 +04:00
|
|
|
case nsIGfxInfo::FEATURE_STATUS_OK:
|
2011-01-20 04:35:51 +03:00
|
|
|
RemovePrefForFeature(features[i]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION:
|
|
|
|
if (!suggestedVersion.IsEmpty()) {
|
|
|
|
SetPrefValueForDriverVersion(suggestedVersion);
|
|
|
|
} else {
|
|
|
|
RemovePrefForDriverVersion();
|
|
|
|
}
|
|
|
|
// FALLTHROUGH
|
|
|
|
|
2015-05-15 20:43:38 +03:00
|
|
|
case nsIGfxInfo::FEATURE_BLOCKED_MISMATCHED_VERSION:
|
2011-01-20 04:35:51 +03:00
|
|
|
case nsIGfxInfo::FEATURE_BLOCKED_DEVICE:
|
|
|
|
case nsIGfxInfo::FEATURE_DISCOURAGED:
|
|
|
|
case nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION:
|
|
|
|
SetPrefValueForFeature(features[i], status);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
2011-02-07 22:44:48 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP_(void)
|
|
|
|
GfxInfoBase::LogFailure(const nsACString &failure)
|
|
|
|
{
|
2015-01-14 05:19:25 +03:00
|
|
|
// gfxCriticalError has a mutex lock of its own, so we may not actually
|
|
|
|
// need this lock. ::GetFailures() accesses the data but the LogForwarder
|
|
|
|
// will not return the copy of the logs unless it can get the same lock
|
|
|
|
// that gfxCriticalError uses. Still, that is so much of an implementation
|
|
|
|
// detail that it's nicer to just add an extra lock here and in ::GetFailures()
|
2013-02-25 18:07:16 +04:00
|
|
|
MutexAutoLock lock(mMutex);
|
2011-02-09 18:32:24 +03:00
|
|
|
|
2015-01-14 05:19:25 +03:00
|
|
|
// By default, gfxCriticalError asserts; make it not assert in this case.
|
|
|
|
gfxCriticalError(CriticalLog::DefaultOptions(false)) << "(LF) " << failure.BeginReading();
|
2011-02-07 22:44:48 +03:00
|
|
|
}
|
|
|
|
|
2015-01-14 05:19:25 +03:00
|
|
|
/* void getFailures (out unsigned long failureCount, [optional, array, size_is (failureCount)] out long indices, [array, size_is (failureCount), retval] out string failures); */
|
2015-03-27 03:01:12 +03:00
|
|
|
/* XPConnect method of returning arrays is very ugly. Would not recommend. */
|
2015-01-14 05:19:25 +03:00
|
|
|
NS_IMETHODIMP GfxInfoBase::GetFailures(uint32_t* failureCount,
|
2015-05-15 17:42:10 +03:00
|
|
|
int32_t** indices,
|
|
|
|
char ***failures)
|
2011-02-07 22:44:48 +03:00
|
|
|
{
|
2015-01-14 05:19:25 +03:00
|
|
|
MutexAutoLock lock(mMutex);
|
2011-02-07 22:44:48 +03:00
|
|
|
|
|
|
|
NS_ENSURE_ARG_POINTER(failureCount);
|
|
|
|
NS_ENSURE_ARG_POINTER(failures);
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
*failures = nullptr;
|
2015-01-14 05:19:25 +03:00
|
|
|
*failureCount = 0;
|
|
|
|
|
|
|
|
// indices is "allowed" to be null, the caller may not care about them,
|
|
|
|
// although calling from JS doesn't seem to get us there.
|
|
|
|
if (indices) *indices = nullptr;
|
|
|
|
|
|
|
|
LogForwarder* logForwarder = Factory::GetLogForwarder();
|
|
|
|
if (!logForwarder) {
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// There are two stirng copies in this method, starting with this one. We are
|
|
|
|
// assuming this is not a big deal, as the size of the array should be small
|
|
|
|
// and the strings in it should be small as well (the error messages in the
|
|
|
|
// code.) The second copy happens with the Clone() calls. Technically,
|
|
|
|
// we don't need the mutex lock after the StringVectorCopy() call.
|
|
|
|
std::vector<std::pair<int32_t,std::string> > loggedStrings = logForwarder->StringsVectorCopy();
|
|
|
|
*failureCount = loggedStrings.size();
|
2011-02-07 22:44:48 +03:00
|
|
|
|
|
|
|
if (*failureCount != 0) {
|
2015-03-27 03:01:12 +03:00
|
|
|
*failures = (char**)moz_xmalloc(*failureCount * sizeof(char*));
|
2015-01-14 05:19:25 +03:00
|
|
|
if (!(*failures)) {
|
2011-02-07 22:44:48 +03:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2015-01-14 05:19:25 +03:00
|
|
|
}
|
|
|
|
if (indices) {
|
2015-03-27 03:01:12 +03:00
|
|
|
*indices = (int32_t*)moz_xmalloc(*failureCount * sizeof(int32_t));
|
2015-01-14 05:19:25 +03:00
|
|
|
if (!(*indices)) {
|
2015-03-27 03:01:12 +03:00
|
|
|
free(*failures);
|
2015-01-14 05:19:25 +03:00
|
|
|
*failures = nullptr;
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
2011-02-07 22:44:48 +03:00
|
|
|
|
|
|
|
/* copy over the failure messages into the array we just allocated */
|
2015-01-14 05:19:25 +03:00
|
|
|
std::vector<std::pair<int32_t, std::string> >::const_iterator it;
|
|
|
|
uint32_t i=0;
|
|
|
|
for(it = loggedStrings.begin() ; it != loggedStrings.end(); ++it, i++) {
|
|
|
|
(*failures)[i] = (char*)nsMemory::Clone((*it).second.c_str(), (*it).second.size() + 1);
|
|
|
|
if (indices) (*indices)[i] = (*it).first;
|
2011-02-07 22:44:48 +03:00
|
|
|
|
|
|
|
if (!(*failures)[i]) {
|
|
|
|
/* <sarcasm> I'm too afraid to use an inline function... </sarcasm> */
|
|
|
|
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(i, (*failures));
|
2015-05-15 17:42:10 +03:00
|
|
|
*failureCount = i;
|
2011-02-07 22:44:48 +03:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-11-03 00:53:59 +04:00
|
|
|
|
|
|
|
nsTArray<GfxInfoCollectorBase*> *sCollectors;
|
|
|
|
|
|
|
|
static void
|
|
|
|
InitCollectors()
|
|
|
|
{
|
|
|
|
if (!sCollectors)
|
|
|
|
sCollectors = new nsTArray<GfxInfoCollectorBase*>;
|
|
|
|
}
|
|
|
|
|
2014-01-09 21:39:36 +04:00
|
|
|
nsresult GfxInfoBase::GetInfo(JSContext* aCx, JS::MutableHandle<JS::Value> aResult)
|
2011-11-03 00:53:59 +04:00
|
|
|
{
|
|
|
|
InitCollectors();
|
|
|
|
InfoObject obj(aCx);
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < sCollectors->Length(); i++) {
|
2011-11-03 00:53:59 +04:00
|
|
|
(*sCollectors)[i]->GetInfo(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Some example property definitions
|
|
|
|
// obj.DefineProperty("wordCacheSize", gfxTextRunWordCache::Count());
|
|
|
|
// obj.DefineProperty("renderer", mRendererIDsString);
|
|
|
|
// obj.DefineProperty("five", 5);
|
|
|
|
|
|
|
|
if (!obj.mOk) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2014-01-09 21:39:36 +04:00
|
|
|
aResult.setObject(*obj.mObj);
|
2011-11-03 00:53:59 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-15 17:42:10 +03:00
|
|
|
const nsCString&
|
|
|
|
GfxInfoBase::GetApplicationVersion()
|
|
|
|
{
|
|
|
|
static nsAutoCString version;
|
|
|
|
static bool versionInitialized = false;
|
|
|
|
if (!versionInitialized) {
|
|
|
|
// If we fail to get the version, we will not try again.
|
|
|
|
versionInitialized = true;
|
|
|
|
|
|
|
|
// Get the version from xpcom/system/nsIXULAppInfo.idl
|
|
|
|
nsCOMPtr<nsIXULAppInfo> app = do_GetService("@mozilla.org/xre/app-info;1");
|
|
|
|
if (app) {
|
|
|
|
app->GetVersion(version);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
2011-11-03 00:53:59 +04:00
|
|
|
void
|
|
|
|
GfxInfoBase::AddCollector(GfxInfoCollectorBase* collector)
|
|
|
|
{
|
|
|
|
InitCollectors();
|
|
|
|
sCollectors->AppendElement(collector);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GfxInfoBase::RemoveCollector(GfxInfoCollectorBase* collector)
|
|
|
|
{
|
|
|
|
InitCollectors();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < sCollectors->Length(); i++) {
|
2011-11-03 00:53:59 +04:00
|
|
|
if ((*sCollectors)[i] == collector) {
|
|
|
|
sCollectors->RemoveElementAt(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-11-18 08:00:38 +04:00
|
|
|
if (sCollectors->IsEmpty()) {
|
|
|
|
delete sCollectors;
|
2012-07-30 18:20:58 +04:00
|
|
|
sCollectors = nullptr;
|
2011-11-18 08:00:38 +04:00
|
|
|
}
|
2011-11-03 00:53:59 +04:00
|
|
|
}
|
|
|
|
|
2015-06-18 09:11:55 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GfxInfoBase::GetMonitors(JSContext* aCx, JS::MutableHandleValue aResult)
|
|
|
|
{
|
|
|
|
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0));
|
|
|
|
|
|
|
|
nsresult rv = FindMonitors(aCx, array);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
aResult.setObject(*array);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-11-03 00:53:59 +04:00
|
|
|
GfxInfoCollectorBase::GfxInfoCollectorBase()
|
|
|
|
{
|
|
|
|
GfxInfoBase::AddCollector(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
GfxInfoCollectorBase::~GfxInfoCollectorBase()
|
|
|
|
{
|
|
|
|
GfxInfoBase::RemoveCollector(this);
|
|
|
|
}
|