Bumping manifests a=b2g-bump
[gecko.git] / widget / GfxInfoBase.h
blob626689dba32ede887067c544ca025eae50ca2d4f
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"
14 #endif
15 #include "nsCOMPtr.h"
16 #include "nsIObserver.h"
17 #include "nsWeakReference.h"
18 #include "GfxDriverInfo.h"
19 #include "nsTArray.h"
20 #include "nsString.h"
21 #include "GfxInfoCollector.h"
22 #include "nsIGfxInfoDebug.h"
23 #include "mozilla/Mutex.h"
24 #include "js/Value.h"
25 #include "mozilla/Attributes.h"
27 namespace mozilla {
28 namespace widget {
30 class GfxInfoBase : public nsIGfxInfo,
31 #if defined(XP_MACOSX) || defined(XP_WIN)
32 public nsIGfxInfo2,
33 #endif
34 public nsIObserver,
35 public nsSupportsWeakReference
36 #ifdef DEBUG
37 , public nsIGfxInfoDebug
38 #endif
40 public:
41 GfxInfoBase();
43 NS_DECL_THREADSAFE_ISUPPORTS
44 NS_DECL_NSIOBSERVER
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) MOZ_OVERRIDE;
54 NS_IMETHOD GetFeatureSuggestedDriverVersion(int32_t aFeature, nsAString & _retval) MOZ_OVERRIDE;
55 NS_IMETHOD GetWebGLParameter(const nsAString & aParam, nsAString & _retval) MOZ_OVERRIDE;
57 NS_IMETHOD GetFailures(uint32_t *failureCount, char ***failures) MOZ_OVERRIDE;
58 NS_IMETHOD_(void) LogFailure(const nsACString &failure) MOZ_OVERRIDE;
59 NS_IMETHOD GetInfo(JSContext*, JS::MutableHandle<JS::Value>) MOZ_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();
70 // only useful on X11
71 NS_IMETHOD_(void) GetData() MOZ_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; }
85 protected:
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;
98 private:
99 virtual int32_t FindBlocklistedDeviceInList(const nsTArray<GfxDriverInfo>& aDriverInfo,
100 nsAString& aSuggestedVersion,
101 int32_t aFeature,
102 OperatingSystem os);
104 void EvaluateDownloadedBlacklist(nsTArray<GfxDriverInfo>& aDriverInfo);
106 nsCString mFailures[9]; // The choice of 9 is Ehsan's
107 uint32_t mFailureCount;
108 Mutex mMutex;
115 #endif /* __mozilla_widget_GfxInfoBase_h__ */