/src/mozilla-central/widget/GfxInfoBase.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* vim: se cin sw=2 ts=2 et : */ |
2 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
3 | | * |
4 | | * This Source Code Form is subject to the terms of the Mozilla Public |
5 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
6 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
7 | | |
8 | | #ifndef __mozilla_widget_GfxInfoBase_h__ |
9 | | #define __mozilla_widget_GfxInfoBase_h__ |
10 | | |
11 | | #include "GfxDriverInfo.h" |
12 | | #include "GfxInfoCollector.h" |
13 | | #include "gfxFeature.h" |
14 | | #include "gfxTelemetry.h" |
15 | | #include "js/Value.h" |
16 | | #include "mozilla/Attributes.h" |
17 | | #include "mozilla/Maybe.h" |
18 | | #include "mozilla/Mutex.h" |
19 | | #include "mozilla/dom/PContentParent.h" |
20 | | #include "nsCOMPtr.h" |
21 | | #include "nsIGfxInfo.h" |
22 | | #include "nsIGfxInfoDebug.h" |
23 | | #include "nsIObserver.h" |
24 | | #include "nsString.h" |
25 | | #include "nsTArray.h" |
26 | | #include "nsWeakReference.h" |
27 | | |
28 | | namespace mozilla { |
29 | | namespace widget { |
30 | | |
31 | | class GfxInfoBase : public nsIGfxInfo, |
32 | | public nsIObserver, |
33 | | public nsSupportsWeakReference |
34 | | #ifdef DEBUG |
35 | | , public nsIGfxInfoDebug |
36 | | #endif |
37 | | { |
38 | | public: |
39 | | GfxInfoBase(); |
40 | | |
41 | | NS_DECL_THREADSAFE_ISUPPORTS |
42 | | NS_DECL_NSIOBSERVER |
43 | | |
44 | | // We only declare a subset of the nsIGfxInfo interface. It's up to derived |
45 | | // classes to implement the rest of the interface. |
46 | | // Derived classes need to use |
47 | | // using GfxInfoBase::GetFeatureStatus; |
48 | | // using GfxInfoBase::GetFeatureSuggestedDriverVersion; |
49 | | // to import the relevant methods into their namespace. |
50 | | NS_IMETHOD GetFeatureStatus(int32_t aFeature, nsACString& aFailureId, int32_t *_retval) override; |
51 | | NS_IMETHOD GetFeatureSuggestedDriverVersion(int32_t aFeature, nsAString & _retval) override; |
52 | | |
53 | | NS_IMETHOD GetMonitors(JSContext* cx, JS::MutableHandleValue _retval) override; |
54 | | NS_IMETHOD GetFailures(uint32_t *failureCount, int32_t** indices, char ***failures) override; |
55 | | NS_IMETHOD_(void) LogFailure(const nsACString &failure) override; |
56 | | NS_IMETHOD GetInfo(JSContext*, JS::MutableHandle<JS::Value>) override; |
57 | | NS_IMETHOD GetFeatures(JSContext*, JS::MutableHandle<JS::Value>) override; |
58 | | NS_IMETHOD GetFeatureLog(JSContext*, JS::MutableHandle<JS::Value>) override; |
59 | | NS_IMETHOD GetActiveCrashGuards(JSContext*, JS::MutableHandle<JS::Value>) override; |
60 | | NS_IMETHOD GetContentBackend(nsAString & aContentBackend) override; |
61 | | NS_IMETHOD GetUsingGPUProcess(bool *aOutValue) override; |
62 | | NS_IMETHOD GetWebRenderEnabled(bool* aWebRenderEnabled) override; |
63 | | NS_IMETHOD GetIsHeadless(bool* aIsHeadless) override; |
64 | | NS_IMETHOD GetUsesTiling(bool* aUsesTiling) override; |
65 | | NS_IMETHOD GetContentUsesTiling(bool* aUsesTiling) override; |
66 | | NS_IMETHOD GetOffMainThreadPaintEnabled(bool* aOffMainThreadPaintEnabled) override; |
67 | | NS_IMETHOD GetOffMainThreadPaintWorkerCount(int32_t* aOffMainThreadPaintWorkerCount) override; |
68 | | |
69 | | // Initialization function. If you override this, you must call this class's |
70 | | // version of Init first. |
71 | | // We need Init to be called separately from the constructor so we can |
72 | | // register as an observer after all derived classes have been constructed |
73 | | // and we know we have a non-zero refcount. |
74 | | // Ideally, Init() would be void-return, but the rules of |
75 | | // NS_GENERIC_FACTORY_CONSTRUCTOR_INIT require it be nsresult return. |
76 | | virtual nsresult Init(); |
77 | | |
78 | | // only useful on X11 |
79 | 0 | NS_IMETHOD_(void) GetData() override { } |
80 | | |
81 | | static void AddCollector(GfxInfoCollectorBase* collector); |
82 | | static void RemoveCollector(GfxInfoCollectorBase* collector); |
83 | | |
84 | | static nsTArray<GfxDriverInfo>* sDriverInfo; |
85 | | static nsTArray<mozilla::dom::GfxInfoFeatureStatus>* sFeatureStatus; |
86 | | static bool sDriverInfoObserverInitialized; |
87 | | static bool sShutdownOccurred; |
88 | | |
89 | 0 | virtual nsString Model() { return EmptyString(); } |
90 | 0 | virtual nsString Hardware() { return EmptyString(); } |
91 | 0 | virtual nsString Product() { return EmptyString(); } |
92 | 0 | virtual nsString Manufacturer() { return EmptyString(); } |
93 | 0 | virtual uint32_t OperatingSystemVersion() { return 0; } |
94 | | |
95 | | // Convenience to get the application version |
96 | | static const nsCString& GetApplicationVersion(); |
97 | | |
98 | 0 | virtual nsresult FindMonitors(JSContext* cx, JS::HandleObject array) { |
99 | 0 | return NS_ERROR_NOT_IMPLEMENTED; |
100 | 0 | } |
101 | | |
102 | | static void SetFeatureStatus( |
103 | | const nsTArray<mozilla::dom::GfxInfoFeatureStatus>& aFS); |
104 | | |
105 | | protected: |
106 | | |
107 | | virtual ~GfxInfoBase(); |
108 | | |
109 | | virtual nsresult GetFeatureStatusImpl(int32_t aFeature, int32_t* aStatus, |
110 | | nsAString& aSuggestedDriverVersion, |
111 | | const nsTArray<GfxDriverInfo>& aDriverInfo, |
112 | | nsACString& aFailureId, |
113 | | OperatingSystem* aOS = nullptr); |
114 | | |
115 | | // Gets the driver info table. Used by GfxInfoBase to check for general cases |
116 | | // (while subclasses check for more specific ones). |
117 | | virtual const nsTArray<GfxDriverInfo>& GetGfxDriverInfo() = 0; |
118 | | |
119 | | virtual void DescribeFeatures(JSContext* aCx, JS::Handle<JSObject*> obj); |
120 | | bool InitFeatureObject( |
121 | | JSContext* aCx, |
122 | | JS::Handle<JSObject*> aContainer, |
123 | | const char* aName, |
124 | | mozilla::gfx::FeatureStatus& aKnownStatus, |
125 | | JS::MutableHandle<JSObject*> aOutObj); |
126 | | |
127 | | NS_IMETHOD ControlGPUProcessForXPCShell(bool aEnable, bool *_retval) override; |
128 | | |
129 | | private: |
130 | | virtual int32_t FindBlocklistedDeviceInList(const nsTArray<GfxDriverInfo>& aDriverInfo, |
131 | | nsAString& aSuggestedVersion, |
132 | | int32_t aFeature, |
133 | | nsACString &aFailureId, |
134 | | OperatingSystem os); |
135 | | |
136 | | void EvaluateDownloadedBlacklist(nsTArray<GfxDriverInfo>& aDriverInfo); |
137 | | |
138 | | bool BuildFeatureStateLog(JSContext* aCx, const gfx::FeatureState& aFeature, |
139 | | JS::MutableHandle<JS::Value> aOut); |
140 | | |
141 | | Mutex mMutex; |
142 | | |
143 | | }; |
144 | | |
145 | | } // namespace widget |
146 | | } // namespace mozilla |
147 | | |
148 | | #endif /* __mozilla_widget_GfxInfoBase_h__ */ |