michael@0: /* vim: se cin sw=2 ts=2 et : */ michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef __mozilla_widget_GfxInfoBase_h__ michael@0: #define __mozilla_widget_GfxInfoBase_h__ michael@0: michael@0: #include "nsIGfxInfo.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsIObserver.h" michael@0: #include "nsWeakReference.h" michael@0: #include "GfxDriverInfo.h" michael@0: #include "nsTArray.h" michael@0: #include "nsString.h" michael@0: #include "GfxInfoCollector.h" michael@0: #include "nsIGfxInfoDebug.h" michael@0: #include "mozilla/Mutex.h" michael@0: #include "js/Value.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: namespace mozilla { michael@0: namespace widget { michael@0: michael@0: class GfxInfoBase : public nsIGfxInfo, michael@0: public nsIObserver, michael@0: public nsSupportsWeakReference michael@0: #ifdef DEBUG michael@0: , public nsIGfxInfoDebug michael@0: #endif michael@0: { michael@0: public: michael@0: GfxInfoBase(); michael@0: virtual ~GfxInfoBase(); michael@0: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIOBSERVER michael@0: michael@0: // We only declare a subset of the nsIGfxInfo interface. It's up to derived michael@0: // classes to implement the rest of the interface. michael@0: // Derived classes need to use michael@0: // using GfxInfoBase::GetFeatureStatus; michael@0: // using GfxInfoBase::GetFeatureSuggestedDriverVersion; michael@0: // using GfxInfoBase::GetWebGLParameter; michael@0: // to import the relevant methods into their namespace. michael@0: NS_IMETHOD GetFeatureStatus(int32_t aFeature, int32_t *_retval); michael@0: NS_IMETHOD GetFeatureSuggestedDriverVersion(int32_t aFeature, nsAString & _retval); michael@0: NS_IMETHOD GetWebGLParameter(const nsAString & aParam, nsAString & _retval); michael@0: michael@0: NS_IMETHOD GetFailures(uint32_t *failureCount, char ***failures); michael@0: NS_IMETHOD_(void) LogFailure(const nsACString &failure); michael@0: NS_IMETHOD GetInfo(JSContext*, JS::MutableHandle); michael@0: michael@0: // Initialization function. If you override this, you must call this class's michael@0: // version of Init first. michael@0: // We need Init to be called separately from the constructor so we can michael@0: // register as an observer after all derived classes have been constructed michael@0: // and we know we have a non-zero refcount. michael@0: // Ideally, Init() would be void-return, but the rules of michael@0: // NS_GENERIC_FACTORY_CONSTRUCTOR_INIT require it be nsresult return. michael@0: virtual nsresult Init(); michael@0: michael@0: // only useful on X11 michael@0: NS_IMETHOD_(void) GetData() { } michael@0: michael@0: static void AddCollector(GfxInfoCollectorBase* collector); michael@0: static void RemoveCollector(GfxInfoCollectorBase* collector); michael@0: michael@0: static nsTArray* mDriverInfo; michael@0: static bool mDriverInfoObserverInitialized; michael@0: michael@0: virtual nsString Model() { return EmptyString(); } michael@0: virtual nsString Hardware() { return EmptyString(); } michael@0: virtual nsString Product() { return EmptyString(); } michael@0: virtual nsString Manufacturer() { return EmptyString(); } michael@0: virtual uint32_t OperatingSystemVersion() { return 0; } michael@0: michael@0: protected: michael@0: michael@0: virtual nsresult GetFeatureStatusImpl(int32_t aFeature, int32_t* aStatus, michael@0: nsAString& aSuggestedDriverVersion, michael@0: const nsTArray& aDriverInfo, michael@0: OperatingSystem* aOS = nullptr); michael@0: michael@0: // Gets the driver info table. Used by GfxInfoBase to check for general cases michael@0: // (while subclasses check for more specific ones). michael@0: virtual const nsTArray& GetGfxDriverInfo() = 0; michael@0: michael@0: private: michael@0: virtual int32_t FindBlocklistedDeviceInList(const nsTArray& aDriverInfo, michael@0: nsAString& aSuggestedVersion, michael@0: int32_t aFeature, michael@0: OperatingSystem os); michael@0: michael@0: void EvaluateDownloadedBlacklist(nsTArray& aDriverInfo); michael@0: michael@0: nsCString mFailures[9]; // The choice of 9 is Ehsan's michael@0: uint32_t mFailureCount; michael@0: Mutex mMutex; michael@0: michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif /* __mozilla_widget_GfxInfoBase_h__ */