1 /* vim: se cin sw=2 ts=2 et : */
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
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/. */
8 #ifndef __mozilla_widget_GfxInfoBase_h__
9 #define __mozilla_widget_GfxInfoBase_h__
11 #include "nsIGfxInfo.h"
12 #if defined(XP_MACOSX) || defined(XP_WIN)
13 #include "nsIGfxInfo2.h"
16 #include "nsIObserver.h"
17 #include "nsWeakReference.h"
18 #include "GfxDriverInfo.h"
21 #include "GfxInfoCollector.h"
22 #include "nsIGfxInfoDebug.h"
23 #include "mozilla/Mutex.h"
25 #include "mozilla/Attributes.h"
30 class GfxInfoBase
: public nsIGfxInfo
,
31 #if defined(XP_MACOSX) || defined(XP_WIN)
35 public nsSupportsWeakReference
37 , public nsIGfxInfoDebug
43 NS_DECL_THREADSAFE_ISUPPORTS
46 // We only declare a subset of the nsIGfxInfo interface. It's up to derived
47 // classes to implement the rest of the interface.
48 // Derived classes need to use
49 // using GfxInfoBase::GetFeatureStatus;
50 // using GfxInfoBase::GetFeatureSuggestedDriverVersion;
51 // using GfxInfoBase::GetWebGLParameter;
52 // to import the relevant methods into their namespace.
53 NS_IMETHOD
GetFeatureStatus(int32_t aFeature
, int32_t *_retval
) override
;
54 NS_IMETHOD
GetFeatureSuggestedDriverVersion(int32_t aFeature
, nsAString
& _retval
) override
;
55 NS_IMETHOD
GetWebGLParameter(const nsAString
& aParam
, nsAString
& _retval
) override
;
57 NS_IMETHOD
GetFailures(uint32_t *failureCount
, int32_t** indices
, char ***failures
) override
;
58 NS_IMETHOD_(void) LogFailure(const nsACString
&failure
) override
;
59 NS_IMETHOD
GetInfo(JSContext
*, JS::MutableHandle
<JS::Value
>) override
;
61 // Initialization function. If you override this, you must call this class's
62 // version of Init first.
63 // We need Init to be called separately from the constructor so we can
64 // register as an observer after all derived classes have been constructed
65 // and we know we have a non-zero refcount.
66 // Ideally, Init() would be void-return, but the rules of
67 // NS_GENERIC_FACTORY_CONSTRUCTOR_INIT require it be nsresult return.
68 virtual nsresult
Init();
71 NS_IMETHOD_(void) GetData() override
{ }
73 static void AddCollector(GfxInfoCollectorBase
* collector
);
74 static void RemoveCollector(GfxInfoCollectorBase
* collector
);
76 static nsTArray
<GfxDriverInfo
>* mDriverInfo
;
77 static bool mDriverInfoObserverInitialized
;
79 virtual nsString
Model() { return EmptyString(); }
80 virtual nsString
Hardware() { return EmptyString(); }
81 virtual nsString
Product() { return EmptyString(); }
82 virtual nsString
Manufacturer() { return EmptyString(); }
83 virtual uint32_t OperatingSystemVersion() { return 0; }
87 virtual ~GfxInfoBase();
89 virtual nsresult
GetFeatureStatusImpl(int32_t aFeature
, int32_t* aStatus
,
90 nsAString
& aSuggestedDriverVersion
,
91 const nsTArray
<GfxDriverInfo
>& aDriverInfo
,
92 OperatingSystem
* aOS
= nullptr);
94 // Gets the driver info table. Used by GfxInfoBase to check for general cases
95 // (while subclasses check for more specific ones).
96 virtual const nsTArray
<GfxDriverInfo
>& GetGfxDriverInfo() = 0;
99 virtual int32_t FindBlocklistedDeviceInList(const nsTArray
<GfxDriverInfo
>& aDriverInfo
,
100 nsAString
& aSuggestedVersion
,
104 void EvaluateDownloadedBlacklist(nsTArray
<GfxDriverInfo
>& aDriverInfo
);
113 #endif /* __mozilla_widget_GfxInfoBase_h__ */