2011-01-20 04:21:07 +03:00
|
|
|
/* -*- 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:21:07 +03:00
|
|
|
|
|
|
|
#ifndef __mozilla_widget_GfxDriverInfo_h__
|
|
|
|
#define __mozilla_widget_GfxDriverInfo_h__
|
|
|
|
|
2013-03-17 11:55:16 +04:00
|
|
|
#include "mozilla/Util.h" // ArrayLength
|
|
|
|
#include "nsString.h"
|
|
|
|
|
2011-12-15 09:03:01 +04:00
|
|
|
// Macros for adding a blocklist item to the static list.
|
2011-12-15 09:02:59 +04:00
|
|
|
#define APPEND_TO_DRIVER_BLOCKLIST(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion, suggestedVersion) \
|
|
|
|
mDriverInfo->AppendElement(GfxDriverInfo(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion, suggestedVersion))
|
|
|
|
#define APPEND_TO_DRIVER_BLOCKLIST2(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion) \
|
|
|
|
mDriverInfo->AppendElement(GfxDriverInfo(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion))
|
|
|
|
|
2013-03-20 04:44:10 +04:00
|
|
|
#define APPEND_TO_DRIVER_BLOCKLIST_RANGE(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion, driverVersionMax, suggestedVersion) \
|
|
|
|
do { \
|
|
|
|
MOZ_ASSERT(driverComparator == DRIVER_BETWEEN_EXCLUSIVE || \
|
|
|
|
driverComparator == DRIVER_BETWEEN_INCLUSIVE || \
|
|
|
|
driverComparator == DRIVER_BETWEEN_INCLUSIVE_START); \
|
|
|
|
GfxDriverInfo info(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion, suggestedVersion); \
|
|
|
|
info.mDriverVersionMax = driverVersionMax; \
|
|
|
|
mDriverInfo->AppendElement(info); \
|
|
|
|
} while (false)
|
|
|
|
|
2011-01-20 04:21:07 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
|
|
|
|
enum OperatingSystem {
|
|
|
|
DRIVER_OS_UNKNOWN = 0,
|
|
|
|
DRIVER_OS_WINDOWS_XP,
|
|
|
|
DRIVER_OS_WINDOWS_SERVER_2003,
|
|
|
|
DRIVER_OS_WINDOWS_VISTA,
|
|
|
|
DRIVER_OS_WINDOWS_7,
|
2012-08-31 20:42:07 +04:00
|
|
|
DRIVER_OS_WINDOWS_8,
|
2011-01-20 04:21:07 +03:00
|
|
|
DRIVER_OS_LINUX,
|
|
|
|
DRIVER_OS_OS_X_10_5,
|
|
|
|
DRIVER_OS_OS_X_10_6,
|
2011-11-03 18:50:40 +04:00
|
|
|
DRIVER_OS_OS_X_10_7,
|
2012-08-31 20:42:07 +04:00
|
|
|
DRIVER_OS_OS_X_10_8,
|
2011-11-03 18:50:40 +04:00
|
|
|
DRIVER_OS_ANDROID,
|
2011-01-20 04:21:07 +03:00
|
|
|
DRIVER_OS_ALL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum VersionComparisonOp {
|
|
|
|
DRIVER_LESS_THAN, // driver < version
|
|
|
|
DRIVER_LESS_THAN_OR_EQUAL, // driver <= version
|
|
|
|
DRIVER_GREATER_THAN, // driver > version
|
|
|
|
DRIVER_GREATER_THAN_OR_EQUAL, // driver >= version
|
|
|
|
DRIVER_EQUAL, // driver == version
|
|
|
|
DRIVER_NOT_EQUAL, // driver != version
|
|
|
|
DRIVER_BETWEEN_EXCLUSIVE, // driver > version && driver < versionMax
|
|
|
|
DRIVER_BETWEEN_INCLUSIVE, // driver >= version && driver <= versionMax
|
|
|
|
DRIVER_BETWEEN_INCLUSIVE_START, // driver >= version && driver < versionMax
|
2012-05-04 23:33:59 +04:00
|
|
|
DRIVER_COMPARISON_IGNORED
|
2011-01-20 04:21:07 +03:00
|
|
|
};
|
|
|
|
|
2011-12-15 09:02:59 +04:00
|
|
|
enum DeviceFamily {
|
|
|
|
IntelGMA500,
|
|
|
|
IntelGMA900,
|
|
|
|
IntelGMA950,
|
|
|
|
IntelGMA3150,
|
|
|
|
IntelGMAX3000,
|
|
|
|
IntelGMAX4500HD,
|
2013-03-12 23:40:29 +04:00
|
|
|
IntelMobileHDGraphics,
|
2011-12-15 09:03:01 +04:00
|
|
|
NvidiaBlockD3D9Layers,
|
2011-12-15 09:03:06 +04:00
|
|
|
RadeonX1000,
|
|
|
|
Geforce7300GT,
|
2011-12-15 09:03:01 +04:00
|
|
|
DeviceFamilyMax
|
2011-11-03 18:50:40 +04:00
|
|
|
};
|
|
|
|
|
2011-12-15 09:03:01 +04:00
|
|
|
enum DeviceVendor {
|
|
|
|
VendorAll,
|
|
|
|
VendorIntel,
|
|
|
|
VendorNVIDIA,
|
|
|
|
VendorAMD,
|
|
|
|
VendorATI,
|
2013-06-14 23:34:41 +04:00
|
|
|
VendorMicrosoft,
|
2011-12-15 09:03:01 +04:00
|
|
|
DeviceVendorMax
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Array of devices to match, or an empty array for all devices */
|
|
|
|
typedef nsTArray<nsString> GfxDeviceFamily;
|
2011-01-20 04:21:07 +03:00
|
|
|
|
|
|
|
struct GfxDriverInfo
|
|
|
|
{
|
2011-01-20 04:33:51 +03:00
|
|
|
// If |ownDevices| is true, you are transferring ownership of the devices
|
|
|
|
// array, and it will be deleted when this GfxDriverInfo is destroyed.
|
2011-12-15 09:03:01 +04:00
|
|
|
GfxDriverInfo(OperatingSystem os, nsAString& vendor, GfxDeviceFamily* devices,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t feature, int32_t featureStatus, VersionComparisonOp op,
|
|
|
|
uint64_t driverVersion, const char *suggestedVersion = nullptr,
|
2011-01-29 05:12:25 +03:00
|
|
|
bool ownDevices = false);
|
2011-01-20 04:33:51 +03:00
|
|
|
|
|
|
|
GfxDriverInfo();
|
|
|
|
GfxDriverInfo(const GfxDriverInfo&);
|
|
|
|
~GfxDriverInfo();
|
|
|
|
|
2011-01-20 04:21:07 +03:00
|
|
|
OperatingSystem mOperatingSystem;
|
2012-11-02 01:13:10 +04:00
|
|
|
uint32_t mOperatingSystemVersion;
|
2011-01-20 04:21:07 +03:00
|
|
|
|
2011-12-15 09:03:01 +04:00
|
|
|
nsString mAdapterVendor;
|
2011-01-20 04:21:07 +03:00
|
|
|
|
2011-12-15 09:03:01 +04:00
|
|
|
static GfxDeviceFamily* const allDevices;
|
|
|
|
GfxDeviceFamily* mDevices;
|
2011-01-20 04:21:07 +03:00
|
|
|
|
2011-01-20 04:33:51 +03:00
|
|
|
// Whether the mDevices array should be deleted when this structure is
|
|
|
|
// deallocated. False by default.
|
|
|
|
bool mDeleteDevices;
|
|
|
|
|
2011-01-20 04:21:07 +03:00
|
|
|
/* A feature from nsIGfxInfo, or all features */
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mFeature;
|
|
|
|
static int32_t allFeatures;
|
2011-01-20 04:21:07 +03:00
|
|
|
|
|
|
|
/* A feature status from nsIGfxInfo */
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mFeatureStatus;
|
2011-01-20 04:21:07 +03:00
|
|
|
|
|
|
|
VersionComparisonOp mComparisonOp;
|
|
|
|
|
|
|
|
/* versions are assumed to be A.B.C.D packed as 0xAAAABBBBCCCCDDDD */
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t mDriverVersion;
|
|
|
|
uint64_t mDriverVersionMax;
|
|
|
|
static uint64_t allDriverVersions;
|
2011-11-03 18:50:40 +04:00
|
|
|
|
2011-01-29 05:12:25 +03:00
|
|
|
const char *mSuggestedVersion;
|
2011-12-15 09:02:59 +04:00
|
|
|
|
2011-12-15 09:03:01 +04:00
|
|
|
static const GfxDeviceFamily* GetDeviceFamily(DeviceFamily id);
|
|
|
|
static GfxDeviceFamily* mDeviceFamilies[DeviceFamilyMax];
|
|
|
|
|
|
|
|
static const nsAString& GetDeviceVendor(DeviceVendor id);
|
|
|
|
static nsAString* mDeviceVendors[DeviceVendorMax];
|
2012-11-02 01:13:10 +04:00
|
|
|
|
|
|
|
nsString mModel, mHardware, mProduct, mManufacturer;
|
2011-01-20 04:21:07 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#define GFX_DRIVER_VERSION(a,b,c,d) \
|
2012-08-22 19:56:38 +04:00
|
|
|
((uint64_t(a)<<48) | (uint64_t(b)<<32) | (uint64_t(c)<<16) | uint64_t(d))
|
2011-01-20 04:21:07 +03:00
|
|
|
|
2012-12-05 08:51:52 +04:00
|
|
|
inline uint64_t
|
2012-09-18 00:50:38 +04:00
|
|
|
V(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
|
|
|
|
{
|
|
|
|
// We make sure every driver number is padded by 0s, this will allow us the
|
|
|
|
// easiest 'compare as if decimals' approach. See ParseDriverVersion for a
|
|
|
|
// more extensive explanation of this approach.
|
|
|
|
while (b > 0 && b < 1000) {
|
|
|
|
b *= 10;
|
|
|
|
}
|
|
|
|
while (c > 0 && c < 1000) {
|
|
|
|
c *= 10;
|
|
|
|
}
|
|
|
|
while (d > 0 && d < 1000) {
|
|
|
|
d *= 10;
|
|
|
|
}
|
|
|
|
return GFX_DRIVER_VERSION(a, b, c, d);
|
|
|
|
}
|
|
|
|
|
|
|
|
// All destination string storage needs to have at least 5 bytes available.
|
2012-12-05 08:51:52 +04:00
|
|
|
inline bool SplitDriverVersion(const char *aSource, char *aAStr, char *aBStr, char *aCStr, char *aDStr)
|
2012-09-18 00:50:38 +04:00
|
|
|
{
|
|
|
|
// sscanf doesn't do what we want here to we parse this manually.
|
|
|
|
int len = strlen(aSource);
|
|
|
|
char *dest[4] = { aAStr, aBStr, aCStr, aDStr };
|
2012-12-22 21:29:04 +04:00
|
|
|
unsigned destIdx = 0;
|
|
|
|
unsigned destPos = 0;
|
2012-09-18 00:50:38 +04:00
|
|
|
|
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
if (destIdx > ArrayLength(dest)) {
|
|
|
|
// Invalid format found. Ensure we don't access dest beyond bounds.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aSource[i] == '.') {
|
|
|
|
dest[destIdx++][destPos] = 0;
|
|
|
|
destPos = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (destPos > 3) {
|
|
|
|
// Ignore more than 4 chars. Ensure we never access dest[destIdx]
|
|
|
|
// beyond its bounds.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
dest[destIdx][destPos++] = aSource[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add last terminator.
|
|
|
|
dest[destIdx][destPos] = 0;
|
|
|
|
|
|
|
|
if (destIdx != ArrayLength(dest) - 1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-12-05 08:51:52 +04:00
|
|
|
// This allows us to pad driver version 'substrings' with 0s, this
|
2012-09-18 00:50:38 +04:00
|
|
|
// effectively allows us to treat the version numbers as 'decimals'. This is
|
|
|
|
// a little strange but this method seems to do the right thing for all
|
|
|
|
// different vendor's driver strings. i.e. .98 will become 9800, which is
|
|
|
|
// larger than .978 which would become 9780.
|
2012-12-05 08:51:52 +04:00
|
|
|
inline void PadDriverDecimal(char *aString)
|
2012-09-18 00:50:38 +04:00
|
|
|
{
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
if (!aString[i]) {
|
|
|
|
for (int c = i; c < 4; c++) {
|
|
|
|
aString[c] = '0';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aString[4] = 0;
|
|
|
|
}
|
|
|
|
|
2011-01-20 04:21:07 +03:00
|
|
|
inline bool
|
2013-08-06 06:00:42 +04:00
|
|
|
ParseDriverVersion(const nsAString& aVersion, uint64_t *aNumericVersion)
|
2011-01-20 04:21:07 +03:00
|
|
|
{
|
2011-12-15 09:03:03 +04:00
|
|
|
#if defined(XP_WIN)
|
2011-01-20 04:21:07 +03:00
|
|
|
int a, b, c, d;
|
2012-09-18 00:50:38 +04:00
|
|
|
char aStr[8], bStr[8], cStr[8], dStr[8];
|
2011-01-20 04:21:07 +03:00
|
|
|
/* honestly, why do I even bother */
|
2012-09-18 00:50:38 +04:00
|
|
|
if (!SplitDriverVersion(NS_LossyConvertUTF16toASCII(aVersion).get(), aStr, bStr, cStr, dStr))
|
2011-01-20 04:21:07 +03:00
|
|
|
return false;
|
2012-09-18 00:50:38 +04:00
|
|
|
|
|
|
|
PadDriverDecimal(bStr);
|
|
|
|
PadDriverDecimal(cStr);
|
|
|
|
PadDriverDecimal(dStr);
|
|
|
|
|
|
|
|
a = atoi(aStr);
|
|
|
|
b = atoi(bStr);
|
|
|
|
c = atoi(cStr);
|
|
|
|
d = atoi(dStr);
|
|
|
|
|
2011-01-20 04:21:07 +03:00
|
|
|
if (a < 0 || a > 0xffff) return false;
|
|
|
|
if (b < 0 || b > 0xffff) return false;
|
|
|
|
if (c < 0 || c > 0xffff) return false;
|
|
|
|
if (d < 0 || d > 0xffff) return false;
|
|
|
|
|
|
|
|
*aNumericVersion = GFX_DRIVER_VERSION(a, b, c, d);
|
2011-12-15 09:03:03 +04:00
|
|
|
#elif defined(ANDROID)
|
|
|
|
// Can't use aVersion.ToInteger() because that's not compiled into our code
|
|
|
|
// unless we have XPCOM_GLUE_AVOID_NSPR disabled.
|
|
|
|
*aNumericVersion = atoi(NS_LossyConvertUTF16toASCII(aVersion).get());
|
|
|
|
#endif
|
2011-01-20 04:21:07 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-01-20 11:38:05 +03:00
|
|
|
}
|
|
|
|
}
|
2011-01-20 04:21:07 +03:00
|
|
|
|
|
|
|
#endif /*__mozilla_widget_GfxDriverInfo_h__ */
|