CLOSED TREE: TraceMonkey merge head. (a=blockers)
[mozilla-central.git] / widget / src / xpwidgets / GfxDriverInfo.cpp
blob445fd375fc75faeb51e5e034eda37fcc6271445e
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
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Mozilla Foundation.
19 * Portions created by the Initial Developer are Copyright (C) 2011
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
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 ***** */
38 #include "GfxDriverInfo.h"
39 #include "nsIGfxInfo.h"
41 using namespace mozilla::widget;
43 PRUint32 GfxDriverInfo::allAdapterVendors = 0;
44 PRInt32 GfxDriverInfo::allFeatures = 0;
45 GfxDeviceFamily GfxDriverInfo::allDevices = nsnull;
47 GfxDriverInfo::GfxDriverInfo()
48 : mOperatingSystem(DRIVER_OS_UNKNOWN),
49 mAdapterVendor(allAdapterVendors),
50 mDevices(allDevices),
51 mDeleteDevices(false),
52 mFeature(allFeatures),
53 mFeatureStatus(nsIGfxInfo::FEATURE_NO_INFO),
54 mComparisonOp(DRIVER_UNKNOWN_COMPARISON),
55 mDriverVersion(0),
56 mDriverVersionMax(0),
57 mSuggestedVersion(nsnull)
60 GfxDriverInfo::GfxDriverInfo(OperatingSystem os, PRUint32 vendor,
61 GfxDeviceFamily devices,
62 PRInt32 feature, PRInt32 featureStatus,
63 VersionComparisonOp op,
64 PRUint64 driverVersion,
65 const char *suggestedVersion /* = nsnull */,
66 bool ownDevices /* = false */)
67 : mOperatingSystem(os),
68 mAdapterVendor(vendor),
69 mDevices(devices),
70 mDeleteDevices(ownDevices),
71 mFeature(feature),
72 mFeatureStatus(featureStatus),
73 mComparisonOp(op),
74 mDriverVersion(driverVersion),
75 mDriverVersionMax(0),
76 mSuggestedVersion(suggestedVersion)
79 GfxDriverInfo::GfxDriverInfo(const GfxDriverInfo& aOrig)
80 : mOperatingSystem(aOrig.mOperatingSystem),
81 mAdapterVendor(aOrig.mAdapterVendor),
82 mFeature(aOrig.mFeature),
83 mFeatureStatus(aOrig.mFeatureStatus),
84 mComparisonOp(aOrig.mComparisonOp),
85 mDriverVersion(aOrig.mDriverVersion),
86 mDriverVersionMax(aOrig.mDriverVersionMax),
87 mSuggestedVersion(aOrig.mSuggestedVersion)
89 // If we're managing the lifetime of the devices array, we have to make a
90 // copy of the original's array.
91 if (aOrig.mDeleteDevices) {
92 PRUint32 count = 0;
93 const PRUint32 *device = aOrig.mDevices;
94 while (*device) {
95 count++;
96 device++;
99 mDevices = new PRUint32[count + 1];
100 memcpy(mDevices, aOrig.mDevices, sizeof(PRUint32) * (count + 1));
101 } else {
102 mDevices = aOrig.mDevices;
105 mDeleteDevices = aOrig.mDeleteDevices;
108 GfxDriverInfo::~GfxDriverInfo()
110 if (mDeleteDevices)
111 delete[] mDevices;