gecko/widget/xpwidgets/GfxDriverInfo.h
Ehsan Akhgari 0fd9123eac Bug 579517 - Part 1: Automated conversion of NSPR numeric types to stdint types in Gecko; r=bsmedberg
This patch was generated by a script.  Here's the source of the script for
future reference:

function convert() {
echo "Converting $1 to $2..."
find . ! -wholename "*nsprpub*" \
       ! -wholename "*security/nss*" \
       ! -wholename "*/.hg*" \
       ! -wholename "obj-ff-dbg*" \
       ! -name nsXPCOMCID.h \
       ! -name prtypes.h \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.c" \
         -o -iname "*.cc" \
         -o -iname "*.idl" \
         -o -iname "*.ipdl" \
         -o -iname "*.ipdlh" \
         -o -iname "*.mm" \) | \
    xargs -n 1 sed -i -e "s/\b$1\b/$2/g"
}

convert PRInt8 int8_t
convert PRUint8 uint8_t
convert PRInt16 int16_t
convert PRUint16 uint16_t
convert PRInt32 int32_t
convert PRUint32 uint32_t
convert PRInt64 int64_t
convert PRUint64 uint64_t

convert PRIntn int
convert PRUintn unsigned

convert PRSize size_t

convert PROffset32 int32_t
convert PROffset64 int64_t

convert PRPtrdiff ptrdiff_t

convert PRFloat64 double
2012-08-22 11:56:38 -04:00

152 lines
4.7 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "prtypes.h"
#include "nsString.h"
#ifndef __mozilla_widget_GfxDriverInfo_h__
#define __mozilla_widget_GfxDriverInfo_h__
#define V(a,b,c,d) GFX_DRIVER_VERSION(a,b,c,d)
// Macros for adding a blocklist item to the static list.
#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))
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,
DRIVER_OS_LINUX,
DRIVER_OS_OS_X_10_5,
DRIVER_OS_OS_X_10_6,
DRIVER_OS_OS_X_10_7,
DRIVER_OS_ANDROID,
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
DRIVER_COMPARISON_IGNORED
};
enum DeviceFamily {
IntelGMA500,
IntelGMA900,
IntelGMA950,
IntelGMA3150,
IntelGMAX3000,
IntelGMAX4500HD,
NvidiaBlockD3D9Layers,
RadeonX1000,
Geforce7300GT,
DeviceFamilyMax
};
enum DeviceVendor {
VendorAll,
VendorIntel,
VendorNVIDIA,
VendorAMD,
VendorATI,
DeviceVendorMax
};
/* Array of devices to match, or an empty array for all devices */
typedef nsTArray<nsString> GfxDeviceFamily;
struct GfxDriverInfo
{
// If |ownDevices| is true, you are transferring ownership of the devices
// array, and it will be deleted when this GfxDriverInfo is destroyed.
GfxDriverInfo(OperatingSystem os, nsAString& vendor, GfxDeviceFamily* devices,
int32_t feature, int32_t featureStatus, VersionComparisonOp op,
uint64_t driverVersion, const char *suggestedVersion = nullptr,
bool ownDevices = false);
GfxDriverInfo();
GfxDriverInfo(const GfxDriverInfo&);
~GfxDriverInfo();
OperatingSystem mOperatingSystem;
nsString mAdapterVendor;
static GfxDeviceFamily* const allDevices;
GfxDeviceFamily* mDevices;
// Whether the mDevices array should be deleted when this structure is
// deallocated. False by default.
bool mDeleteDevices;
/* A feature from nsIGfxInfo, or all features */
int32_t mFeature;
static int32_t allFeatures;
/* A feature status from nsIGfxInfo */
int32_t mFeatureStatus;
VersionComparisonOp mComparisonOp;
/* versions are assumed to be A.B.C.D packed as 0xAAAABBBBCCCCDDDD */
uint64_t mDriverVersion;
uint64_t mDriverVersionMax;
static uint64_t allDriverVersions;
const char *mSuggestedVersion;
static const GfxDeviceFamily* GetDeviceFamily(DeviceFamily id);
static GfxDeviceFamily* mDeviceFamilies[DeviceFamilyMax];
static const nsAString& GetDeviceVendor(DeviceVendor id);
static nsAString* mDeviceVendors[DeviceVendorMax];
};
#define GFX_DRIVER_VERSION(a,b,c,d) \
((uint64_t(a)<<48) | (uint64_t(b)<<32) | (uint64_t(c)<<16) | uint64_t(d))
inline bool
ParseDriverVersion(nsAString& aVersion, uint64_t *aNumericVersion)
{
#if defined(XP_WIN)
int a, b, c, d;
/* honestly, why do I even bother */
if (sscanf(NS_LossyConvertUTF16toASCII(aVersion).get(),
"%d.%d.%d.%d", &a, &b, &c, &d) != 4)
return false;
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);
#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
return true;
}
}
}
#endif /*__mozilla_widget_GfxDriverInfo_h__ */