2011-01-20 01:30:12 +00:00
|
|
|
/* vim: se cin sw=2 ts=2 et : */
|
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-01-20 01:30:12 +00:00
|
|
|
|
|
|
|
#ifndef __mozilla_widget_GfxInfoBase_h__
|
|
|
|
#define __mozilla_widget_GfxInfoBase_h__
|
|
|
|
|
2011-01-20 01:35:51 +00:00
|
|
|
#include "GfxDriverInfo.h"
|
2011-11-02 20:53:59 +00:00
|
|
|
#include "GfxInfoCollector.h"
|
2016-04-29 04:52:56 +00:00
|
|
|
#include "gfxFeature.h"
|
2016-05-09 17:44:21 +00:00
|
|
|
#include "gfxTelemetry.h"
|
2013-09-19 20:02:03 +00:00
|
|
|
#include "js/Value.h"
|
2013-11-18 13:38:17 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2016-05-09 17:44:21 +00:00
|
|
|
#include "mozilla/Maybe.h"
|
|
|
|
#include "mozilla/Mutex.h"
|
2020-08-07 21:38:18 +00:00
|
|
|
#include "mozilla/StaticPtr.h"
|
2020-08-07 21:31:48 +00:00
|
|
|
#include "mozilla/gfx/GraphicsMessages.h"
|
2016-05-09 17:44:21 +00:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIGfxInfo.h"
|
|
|
|
#include "nsIGfxInfoDebug.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsWeakReference.h"
|
2011-01-20 01:30:12 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
|
2011-01-20 01:33:51 +00:00
|
|
|
class GfxInfoBase : public nsIGfxInfo,
|
|
|
|
public nsIObserver,
|
|
|
|
public nsSupportsWeakReference
|
2011-12-15 05:04:35 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
,
|
|
|
|
public nsIGfxInfoDebug
|
|
|
|
#endif
|
2011-01-20 01:30:12 +00:00
|
|
|
{
|
|
|
|
public:
|
2011-01-20 01:33:51 +00:00
|
|
|
GfxInfoBase();
|
|
|
|
|
2013-07-19 02:24:15 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2011-01-20 01:33:51 +00:00
|
|
|
NS_DECL_NSIOBSERVER
|
2011-01-20 01:30:12 +00:00
|
|
|
|
|
|
|
// We only declare a subset of the nsIGfxInfo interface. It's up to derived
|
|
|
|
// classes to implement the rest of the interface.
|
|
|
|
// Derived classes need to use
|
|
|
|
// using GfxInfoBase::GetFeatureStatus;
|
|
|
|
// using GfxInfoBase::GetFeatureSuggestedDriverVersion;
|
|
|
|
// to import the relevant methods into their namespace.
|
2016-04-13 21:12:47 +00:00
|
|
|
NS_IMETHOD GetFeatureStatus(int32_t aFeature, nsACString& aFailureId,
|
|
|
|
int32_t* _retval) override;
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetFeatureSuggestedDriverVersion(int32_t aFeature,
|
|
|
|
nsAString& _retval) override;
|
2024-10-05 15:10:32 +00:00
|
|
|
NS_IMETHOD GetFeatureStatusStr(const nsAString& aFeature,
|
|
|
|
nsACString& aFailureId,
|
|
|
|
nsAString& _retval) override;
|
|
|
|
NS_IMETHOD GetFeatureSuggestedDriverVersionStr(const nsAString& aFeature,
|
|
|
|
nsAString& _retval) override;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2015-07-13 08:12:26 +00:00
|
|
|
NS_IMETHOD GetMonitors(JSContext* cx,
|
2022-07-04 20:57:18 +00:00
|
|
|
JS::MutableHandle<JS::Value> _retval) override;
|
2019-06-07 20:13:56 +00:00
|
|
|
NS_IMETHOD GetFailures(nsTArray<int32_t>& indices,
|
|
|
|
nsTArray<nsCString>& failures) override;
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD_(void) LogFailure(const nsACString& failure) override;
|
|
|
|
NS_IMETHOD GetInfo(JSContext*, JS::MutableHandle<JS::Value>) override;
|
2015-07-19 21:50:35 +00:00
|
|
|
NS_IMETHOD GetFeatures(JSContext*, JS::MutableHandle<JS::Value>) override;
|
2016-04-29 04:52:56 +00:00
|
|
|
NS_IMETHOD GetFeatureLog(JSContext*, JS::MutableHandle<JS::Value>) override;
|
2016-05-10 18:49:16 +00:00
|
|
|
NS_IMETHOD GetActiveCrashGuards(JSContext*,
|
|
|
|
JS::MutableHandle<JS::Value>) override;
|
2024-02-05 21:19:16 +00:00
|
|
|
NS_IMETHOD GetFontVisibilityDetermination(
|
|
|
|
nsIGfxInfo::FontVisibilityDeviceDetermination*
|
|
|
|
aFontVisibilityDetermination) override;
|
|
|
|
NS_IMETHOD GetFontVisibilityDeterminationStr(
|
|
|
|
nsAString& aFontVisibilityDeterminationStr) override;
|
2016-09-12 23:23:28 +00:00
|
|
|
NS_IMETHOD GetContentBackend(nsAString& aContentBackend) override;
|
2021-04-27 15:17:12 +00:00
|
|
|
NS_IMETHOD GetAzureCanvasBackend(nsAString& aBackend) override;
|
|
|
|
NS_IMETHOD GetAzureContentBackend(nsAString& aBackend) override;
|
2016-11-14 23:02:02 +00:00
|
|
|
NS_IMETHOD GetUsingGPUProcess(bool* aOutValue) override;
|
2024-03-28 14:50:20 +00:00
|
|
|
NS_IMETHOD GetUsingRemoteCanvas(bool* aOutValue) override;
|
|
|
|
NS_IMETHOD GetUsingAcceleratedCanvas(bool* aOutValue) override;
|
2017-07-03 22:39:16 +00:00
|
|
|
NS_IMETHOD GetIsHeadless(bool* aIsHeadless) override;
|
2019-01-08 15:48:24 +00:00
|
|
|
NS_IMETHOD GetTargetFrameRate(uint32_t* aTargetFrameRate) override;
|
2022-07-22 23:08:08 +00:00
|
|
|
NS_IMETHOD GetCodecSupportInfo(nsACString& aCodecSupportInfo) override;
|
2011-02-07 19:44:48 +00:00
|
|
|
|
2019-11-09 02:21:18 +00:00
|
|
|
// Non-XPCOM method to get IPC data:
|
2020-08-07 21:31:53 +00:00
|
|
|
nsTArray<mozilla::gfx::GfxInfoFeatureStatus> GetAllFeatures();
|
2019-11-09 02:21:18 +00:00
|
|
|
|
2011-01-20 01:33:51 +00:00
|
|
|
// Initialization function. If you override this, you must call this class's
|
|
|
|
// version of Init first.
|
2011-01-20 21:27:22 +00:00
|
|
|
// We need Init to be called separately from the constructor so we can
|
|
|
|
// register as an observer after all derived classes have been constructed
|
|
|
|
// and we know we have a non-zero refcount.
|
2011-01-20 01:33:51 +00:00
|
|
|
// Ideally, Init() would be void-return, but the rules of
|
|
|
|
// NS_GENERIC_FACTORY_CONSTRUCTOR_INIT require it be nsresult return.
|
|
|
|
virtual nsresult Init();
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2020-02-13 15:51:32 +00:00
|
|
|
NS_IMETHOD_(void) GetData() override;
|
2022-05-06 23:37:25 +00:00
|
|
|
NS_IMETHOD_(int32_t) GetMaxRefreshRate(bool* aMixed) override;
|
2024-07-21 08:43:07 +00:00
|
|
|
NS_IMETHOD GetTextScaleFactor(float* aOutValue) override;
|
2011-01-20 01:33:51 +00:00
|
|
|
|
2011-11-02 20:53:59 +00:00
|
|
|
static void AddCollector(GfxInfoCollectorBase* collector);
|
|
|
|
static void RemoveCollector(GfxInfoCollectorBase* collector);
|
|
|
|
|
2018-05-14 15:16:50 +00:00
|
|
|
static nsTArray<GfxDriverInfo>* sDriverInfo;
|
2020-08-07 21:38:18 +00:00
|
|
|
static StaticAutoPtr<nsTArray<mozilla::gfx::GfxInfoFeatureStatus>>
|
|
|
|
sFeatureStatus;
|
2018-05-14 15:16:50 +00:00
|
|
|
static bool sDriverInfoObserverInitialized;
|
|
|
|
static bool sShutdownOccurred;
|
2011-11-02 20:53:59 +00:00
|
|
|
|
2020-09-23 15:17:15 +00:00
|
|
|
virtual nsString Model() { return u""_ns; }
|
|
|
|
virtual nsString Hardware() { return u""_ns; }
|
|
|
|
virtual nsString Product() { return u""_ns; }
|
|
|
|
virtual nsString Manufacturer() { return u""_ns; }
|
2013-11-15 16:28:42 +00:00
|
|
|
virtual uint32_t OperatingSystemVersion() { return 0; }
|
2020-02-13 15:51:32 +00:00
|
|
|
virtual uint32_t OperatingSystemBuild() { return 0; }
|
2012-11-01 21:13:10 +00:00
|
|
|
|
2015-05-15 14:42:10 +00:00
|
|
|
// Convenience to get the application version
|
|
|
|
static const nsCString& GetApplicationVersion();
|
|
|
|
|
2022-07-04 20:57:18 +00:00
|
|
|
virtual nsresult FindMonitors(JSContext* cx, JS::Handle<JSObject*> array);
|
2015-06-18 06:11:55 +00:00
|
|
|
|
2017-01-17 04:05:46 +00:00
|
|
|
static void SetFeatureStatus(
|
2020-08-07 21:31:53 +00:00
|
|
|
nsTArray<mozilla::gfx::GfxInfoFeatureStatus>&& aFS);
|
2017-01-17 04:05:46 +00:00
|
|
|
|
2024-01-05 22:23:25 +00:00
|
|
|
static bool OnlyAllowFeatureOnKnownConfig(int32_t aFeature);
|
|
|
|
|
2011-01-20 01:30:12 +00:00
|
|
|
protected:
|
2014-06-24 16:36:44 +00:00
|
|
|
virtual ~GfxInfoBase();
|
|
|
|
|
2022-10-27 01:12:50 +00:00
|
|
|
virtual OperatingSystem GetOperatingSystem() = 0;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual nsresult GetFeatureStatusImpl(
|
2011-01-20 01:35:51 +00:00
|
|
|
int32_t aFeature, int32_t* aStatus, nsAString& aSuggestedDriverVersion,
|
2011-12-15 05:02:59 +00:00
|
|
|
const nsTArray<GfxDriverInfo>& aDriverInfo, nsACString& aFailureId,
|
2012-07-30 14:20:58 +00:00
|
|
|
OperatingSystem* aOS = nullptr);
|
2011-01-20 01:35:51 +00:00
|
|
|
|
2011-12-15 05:02:59 +00:00
|
|
|
// Gets the driver info table. Used by GfxInfoBase to check for general cases
|
|
|
|
// (while subclasses check for more specific ones).
|
|
|
|
virtual const nsTArray<GfxDriverInfo>& GetGfxDriverInfo() = 0;
|
|
|
|
|
2015-07-19 21:50:35 +00:00
|
|
|
virtual void DescribeFeatures(JSContext* aCx, JS::Handle<JSObject*> obj);
|
2019-02-08 19:36:08 +00:00
|
|
|
|
2020-02-10 14:21:30 +00:00
|
|
|
virtual bool DoesWindowProtocolMatch(
|
|
|
|
const nsAString& aBlocklistWindowProtocol,
|
|
|
|
const nsAString& aWindowProtocol);
|
|
|
|
|
2019-04-30 20:29:18 +00:00
|
|
|
bool DoesVendorMatch(const nsAString& aBlocklistVendor,
|
|
|
|
const nsAString& aAdapterVendor);
|
|
|
|
|
|
|
|
virtual bool DoesDriverVendorMatch(const nsAString& aBlocklistVendor,
|
|
|
|
const nsAString& aDriverVendor);
|
2019-02-08 19:36:08 +00:00
|
|
|
|
2015-07-19 21:50:35 +00:00
|
|
|
bool InitFeatureObject(JSContext* aCx, JS::Handle<JSObject*> aContainer,
|
|
|
|
const char* aName,
|
2020-04-15 22:11:19 +00:00
|
|
|
mozilla::gfx::FeatureState& aFeatureState,
|
2015-07-19 21:50:35 +00:00
|
|
|
JS::MutableHandle<JSObject*> aOutObj);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2017-01-27 00:35:55 +00:00
|
|
|
NS_IMETHOD ControlGPUProcessForXPCShell(bool aEnable, bool* _retval) override;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2022-01-07 13:27:49 +00:00
|
|
|
NS_IMETHOD KillGPUProcessForTests() override;
|
2021-12-08 19:08:17 +00:00
|
|
|
NS_IMETHOD CrashGPUProcessForTests() override;
|
|
|
|
|
2020-02-13 15:51:32 +00:00
|
|
|
// Total number of pixels for all detected screens at startup.
|
|
|
|
int64_t mScreenPixels;
|
|
|
|
|
2011-01-20 01:35:51 +00:00
|
|
|
private:
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual int32_t FindBlocklistedDeviceInList(
|
|
|
|
const nsTArray<GfxDriverInfo>& aDriverInfo, nsAString& aSuggestedVersion,
|
2020-02-13 16:06:41 +00:00
|
|
|
int32_t aFeature, nsACString& aFailureId, OperatingSystem os,
|
|
|
|
bool aForAllowing);
|
|
|
|
|
2024-02-05 21:19:16 +00:00
|
|
|
std::pair<nsIGfxInfo::FontVisibilityDeviceDetermination, nsString>*
|
|
|
|
GetFontVisibilityDeterminationPair();
|
|
|
|
|
2020-02-13 16:06:41 +00:00
|
|
|
bool IsFeatureAllowlisted(int32_t aFeature) const;
|
2011-01-20 01:35:51 +00:00
|
|
|
|
2020-06-23 15:20:33 +00:00
|
|
|
void EvaluateDownloadedBlocklist(nsTArray<GfxDriverInfo>& aDriverInfo);
|
2011-01-20 01:35:51 +00:00
|
|
|
|
2016-04-29 04:52:56 +00:00
|
|
|
bool BuildFeatureStateLog(JSContext* aCx, const gfx::FeatureState& aFeature,
|
|
|
|
JS::MutableHandle<JS::Value> aOut);
|
|
|
|
|
2022-03-16 18:47:08 +00:00
|
|
|
Mutex mMutex MOZ_UNANNOTATED;
|
2011-01-20 01:30:12 +00:00
|
|
|
};
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|
2011-01-20 01:30:12 +00:00
|
|
|
|
|
|
|
#endif /* __mozilla_widget_GfxInfoBase_h__ */
|