1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 
6 #include "GfxInfo.h"
7 #include "nsServiceManagerUtils.h"
8 
9 namespace mozilla {
10 namespace widget {
11 
12 #ifdef DEBUG
NS_IMPL_ISUPPORTS_INHERITED(GfxInfo,GfxInfoBase,nsIGfxInfoDebug)13 NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug)
14 #endif
15 
16 GfxInfo::GfxInfo() {}
17 
~GfxInfo()18 GfxInfo::~GfxInfo() {}
19 
GetD2DEnabled(bool * aEnabled)20 nsresult GfxInfo::GetD2DEnabled(bool* aEnabled) { return NS_ERROR_FAILURE; }
21 
GetDWriteEnabled(bool * aEnabled)22 nsresult GfxInfo::GetDWriteEnabled(bool* aEnabled) { return NS_ERROR_FAILURE; }
23 
24 NS_IMETHODIMP
GetDWriteVersion(nsAString & aDwriteVersion)25 GfxInfo::GetDWriteVersion(nsAString& aDwriteVersion) {
26   return NS_ERROR_FAILURE;
27 }
28 
29 NS_IMETHODIMP
GetCleartypeParameters(nsAString & aCleartypeParams)30 GfxInfo::GetCleartypeParameters(nsAString& aCleartypeParams) {
31   return NS_ERROR_FAILURE;
32 }
33 
34 NS_IMETHODIMP
GetAdapterDescription(nsAString & aAdapterDescription)35 GfxInfo::GetAdapterDescription(nsAString& aAdapterDescription) {
36   return NS_ERROR_FAILURE;
37 }
38 
39 NS_IMETHODIMP
GetAdapterDescription2(nsAString & aAdapterDescription)40 GfxInfo::GetAdapterDescription2(nsAString& aAdapterDescription) {
41   return NS_ERROR_FAILURE;
42 }
43 
44 NS_IMETHODIMP
GetAdapterRAM(uint32_t * aAdapterRAM)45 GfxInfo::GetAdapterRAM(uint32_t* aAdapterRAM) { return NS_ERROR_FAILURE; }
46 
47 NS_IMETHODIMP
GetAdapterRAM2(uint32_t * aAdapterRAM)48 GfxInfo::GetAdapterRAM2(uint32_t* aAdapterRAM) { return NS_ERROR_FAILURE; }
49 
50 NS_IMETHODIMP
GetAdapterDriver(nsAString & aAdapterDriver)51 GfxInfo::GetAdapterDriver(nsAString& aAdapterDriver) {
52   return NS_ERROR_FAILURE;
53 }
54 
55 NS_IMETHODIMP
GetAdapterDriver2(nsAString & aAdapterDriver)56 GfxInfo::GetAdapterDriver2(nsAString& aAdapterDriver) {
57   return NS_ERROR_FAILURE;
58 }
59 
60 NS_IMETHODIMP
GetAdapterDriverVersion(nsAString & aAdapterDriverVersion)61 GfxInfo::GetAdapterDriverVersion(nsAString& aAdapterDriverVersion) {
62   return NS_ERROR_FAILURE;
63 }
64 
65 NS_IMETHODIMP
GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion)66 GfxInfo::GetAdapterDriverVersion2(nsAString& aAdapterDriverVersion) {
67   return NS_ERROR_FAILURE;
68 }
69 
70 NS_IMETHODIMP
GetAdapterDriverDate(nsAString & aAdapterDriverDate)71 GfxInfo::GetAdapterDriverDate(nsAString& aAdapterDriverDate) {
72   return NS_ERROR_FAILURE;
73 }
74 
75 NS_IMETHODIMP
GetAdapterDriverDate2(nsAString & aAdapterDriverDate)76 GfxInfo::GetAdapterDriverDate2(nsAString& aAdapterDriverDate) {
77   return NS_ERROR_FAILURE;
78 }
79 
80 NS_IMETHODIMP
GetAdapterVendorID(nsAString & aAdapterVendorID)81 GfxInfo::GetAdapterVendorID(nsAString& aAdapterVendorID) {
82   return NS_ERROR_FAILURE;
83 }
84 
85 NS_IMETHODIMP
GetAdapterVendorID2(nsAString & aAdapterVendorID)86 GfxInfo::GetAdapterVendorID2(nsAString& aAdapterVendorID) {
87   return NS_ERROR_FAILURE;
88 }
89 
90 NS_IMETHODIMP
GetAdapterDeviceID(nsAString & aAdapterDeviceID)91 GfxInfo::GetAdapterDeviceID(nsAString& aAdapterDeviceID) {
92   return NS_ERROR_FAILURE;
93   return NS_OK;
94 }
95 
96 NS_IMETHODIMP
GetAdapterDeviceID2(nsAString & aAdapterDeviceID)97 GfxInfo::GetAdapterDeviceID2(nsAString& aAdapterDeviceID) {
98   return NS_ERROR_FAILURE;
99 }
100 
101 NS_IMETHODIMP
GetAdapterSubsysID(nsAString & aAdapterSubsysID)102 GfxInfo::GetAdapterSubsysID(nsAString& aAdapterSubsysID) {
103   return NS_ERROR_FAILURE;
104 }
105 
106 NS_IMETHODIMP
GetAdapterSubsysID2(nsAString & aAdapterSubsysID)107 GfxInfo::GetAdapterSubsysID2(nsAString& aAdapterSubsysID) {
108   return NS_ERROR_FAILURE;
109 }
110 
111 NS_IMETHODIMP
GetIsGPU2Active(bool * aIsGPU2Active)112 GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) { return NS_ERROR_FAILURE; }
113 
GetGfxDriverInfo()114 const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
115   if (sDriverInfo->IsEmpty()) {
116     APPEND_TO_DRIVER_BLOCKLIST2(
117         OperatingSystem::Ios, DeviceFamily::All,
118         nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_STATUS_OK,
119         DRIVER_COMPARISON_IGNORED, GfxDriverInfo::allDriverVersions);
120   }
121 
122   return *sDriverInfo;
123 }
124 
GetFeatureStatusImpl(int32_t aFeature,int32_t * aStatus,nsAString & aSuggestedDriverVersion,const nsTArray<GfxDriverInfo> & aDriverInfo,OperatingSystem * aOS)125 nsresult GfxInfo::GetFeatureStatusImpl(
126     int32_t aFeature, int32_t* aStatus, nsAString& aSuggestedDriverVersion,
127     const nsTArray<GfxDriverInfo>& aDriverInfo,
128     OperatingSystem* aOS /* = nullptr */) {
129   NS_ENSURE_ARG_POINTER(aStatus);
130   aSuggestedDriverVersion.SetIsVoid(true);
131   *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
132   if (aOS) *aOS = OperatingSystem::Ios;
133 
134   if (sShutdownOccurred) {
135     return NS_OK;
136   }
137 
138   // OpenGL layers are never blocklisted on iOS.
139   // This early return is so we avoid potentially slow
140   // GLStrings initialization on startup when we initialize GL layers.
141   if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS ||
142       aFeature == nsIGfxInfo::FEATURE_WEBGL_OPENGL) {
143     *aStatus = nsIGfxInfo::FEATURE_STATUS_OK;
144     return NS_OK;
145   }
146 
147   return GfxInfoBase::GetFeatureStatusImpl(
148       aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, aOS);
149 }
150 
151 #ifdef DEBUG
152 
153 // Implement nsIGfxInfoDebug
154 
SpoofVendorID(const nsAString & aVendorID)155 NS_IMETHODIMP GfxInfo::SpoofVendorID(const nsAString& aVendorID) {
156   return NS_ERROR_FAILURE;
157 }
158 
SpoofDeviceID(const nsAString & aDeviceID)159 NS_IMETHODIMP GfxInfo::SpoofDeviceID(const nsAString& aDeviceID) {
160   return NS_ERROR_FAILURE;
161 }
162 
SpoofDriverVersion(const nsAString & aDriverVersion)163 NS_IMETHODIMP GfxInfo::SpoofDriverVersion(const nsAString& aDriverVersion) {
164   return NS_ERROR_FAILURE;
165 }
166 
SpoofOSVersion(uint32_t aVersion)167 NS_IMETHODIMP GfxInfo::SpoofOSVersion(uint32_t aVersion) {
168   return NS_ERROR_FAILURE;
169 }
170 
171 #endif
172 
173 }  // namespace widget
174 }  // namespace mozilla
175