1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
19 * Portions created by the Initial Developer are Copyright (C) 2011
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 #include "nsPrintfCString.h"
41 #ifndef __mozilla_widget_GfxDriverInfo_h__
42 #define __mozilla_widget_GfxDriverInfo_h__
47 enum OperatingSystem
{
48 DRIVER_OS_UNKNOWN
= 0,
49 DRIVER_OS_WINDOWS_2000
,
51 DRIVER_OS_WINDOWS_SERVER_2003
,
52 DRIVER_OS_WINDOWS_VISTA
,
60 enum VersionComparisonOp
{
61 DRIVER_LESS_THAN
, // driver < version
62 DRIVER_LESS_THAN_OR_EQUAL
, // driver <= version
63 DRIVER_GREATER_THAN
, // driver > version
64 DRIVER_GREATER_THAN_OR_EQUAL
, // driver >= version
65 DRIVER_EQUAL
, // driver == version
66 DRIVER_NOT_EQUAL
, // driver != version
67 DRIVER_BETWEEN_EXCLUSIVE
, // driver > version && driver < versionMax
68 DRIVER_BETWEEN_INCLUSIVE
, // driver >= version && driver <= versionMax
69 DRIVER_BETWEEN_INCLUSIVE_START
, // driver >= version && driver < versionMax
70 DRIVER_UNKNOWN_COMPARISON
73 /* A zero-terminated array of devices to match, or all devices */
74 typedef PRUint32
*GfxDeviceFamily
;
78 // If |ownDevices| is true, you are transferring ownership of the devices
79 // array, and it will be deleted when this GfxDriverInfo is destroyed.
80 GfxDriverInfo(OperatingSystem os
, PRUint32 vendor
, GfxDeviceFamily devices
,
81 PRInt32 feature
, PRInt32 featureStatus
, VersionComparisonOp op
,
82 PRUint64 driverVersion
, const char *suggestedVersion
= nsnull
,
83 bool ownDevices
= false);
86 GfxDriverInfo(const GfxDriverInfo
&);
89 OperatingSystem mOperatingSystem
;
91 PRUint32 mAdapterVendor
;
92 static PRUint32 allAdapterVendors
;
94 GfxDeviceFamily mDevices
;
95 static GfxDeviceFamily allDevices
;
97 // Whether the mDevices array should be deleted when this structure is
98 // deallocated. False by default.
101 /* A feature from nsIGfxInfo, or all features */
103 static PRInt32 allFeatures
;
105 /* A feature status from nsIGfxInfo */
106 PRInt32 mFeatureStatus
;
108 VersionComparisonOp mComparisonOp
;
110 /* versions are assumed to be A.B.C.D packed as 0xAAAABBBBCCCCDDDD */
111 PRUint64 mDriverVersion
;
112 PRUint64 mDriverVersionMax
;
114 const char *mSuggestedVersion
;
117 #define GFX_DRIVER_VERSION(a,b,c,d) \
118 ((PRUint64(a)<<48) | (PRUint64(b)<<32) | (PRUint64(c)<<16) | PRUint64(d))
121 ParseDriverVersion(nsAString
& aVersion
, PRUint64
*aNumericVersion
)
124 /* honestly, why do I even bother */
125 if (sscanf(nsPromiseFlatCString(NS_LossyConvertUTF16toASCII(aVersion
)).get(),
126 "%d.%d.%d.%d", &a
, &b
, &c
, &d
) != 4)
128 if (a
< 0 || a
> 0xffff) return false;
129 if (b
< 0 || b
> 0xffff) return false;
130 if (c
< 0 || c
> 0xffff) return false;
131 if (d
< 0 || d
> 0xffff) return false;
133 *aNumericVersion
= GFX_DRIVER_VERSION(a
, b
, c
, d
);
140 #endif /*__mozilla_widget_GfxDriverInfo_h__ */