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 WIDGET_GTK_GFXINFO_h__
9 #define WIDGET_GTK_GFXINFO_h__
10 
11 #include "GfxInfoBase.h"
12 #include "nsString.h"
13 
14 namespace mozilla {
15 namespace widget {
16 
17 class GfxInfo final : public GfxInfoBase {
18  public:
19   // We only declare the subset of nsIGfxInfo that we actually implement. The
20   // rest is brought forward from GfxInfoBase.
21   NS_IMETHOD GetD2DEnabled(bool* aD2DEnabled) override;
22   NS_IMETHOD GetDWriteEnabled(bool* aDWriteEnabled) override;
23   NS_IMETHOD GetDWriteVersion(nsAString& aDwriteVersion) override;
24   NS_IMETHOD GetEmbeddedInFirefoxReality(
25       bool* aEmbeddedInFirefoxReality) override;
26   NS_IMETHOD GetHasBattery(bool* aHasBattery) override;
27   NS_IMETHOD GetCleartypeParameters(nsAString& aCleartypeParams) override;
28   NS_IMETHOD GetWindowProtocol(nsAString& aWindowProtocol) override;
29   NS_IMETHOD GetDesktopEnvironment(nsAString& aDesktopEnvironment) override;
30   NS_IMETHOD GetTestType(nsAString& aTestType) override;
31   NS_IMETHOD GetAdapterDescription(nsAString& aAdapterDescription) override;
32   NS_IMETHOD GetAdapterDriver(nsAString& aAdapterDriver) override;
33   NS_IMETHOD GetAdapterVendorID(nsAString& aAdapterVendorID) override;
34   NS_IMETHOD GetAdapterDeviceID(nsAString& aAdapterDeviceID) override;
35   NS_IMETHOD GetAdapterSubsysID(nsAString& aAdapterSubsysID) override;
36   NS_IMETHOD GetAdapterRAM(uint32_t* aAdapterRAM) override;
37   NS_IMETHOD GetAdapterDriverVendor(nsAString& aAdapterDriverVendor) override;
38   NS_IMETHOD GetAdapterDriverVersion(nsAString& aAdapterDriverVersion) override;
39   NS_IMETHOD GetAdapterDriverDate(nsAString& aAdapterDriverDate) override;
40   NS_IMETHOD GetAdapterDescription2(nsAString& aAdapterDescription) override;
41   NS_IMETHOD GetAdapterDriver2(nsAString& aAdapterDriver) override;
42   NS_IMETHOD GetAdapterVendorID2(nsAString& aAdapterVendorID) override;
43   NS_IMETHOD GetAdapterDeviceID2(nsAString& aAdapterDeviceID) override;
44   NS_IMETHOD GetAdapterSubsysID2(nsAString& aAdapterSubsysID) override;
45   NS_IMETHOD GetAdapterRAM2(uint32_t* aAdapterRAM) override;
46   NS_IMETHOD GetAdapterDriverVendor2(nsAString& aAdapterDriverVendor) override;
47   NS_IMETHOD GetAdapterDriverVersion2(
48       nsAString& aAdapterDriverVersion) override;
49   NS_IMETHOD GetAdapterDriverDate2(nsAString& aAdapterDriverDate) override;
50   NS_IMETHOD GetIsGPU2Active(bool* aIsGPU2Active) override;
51   NS_IMETHOD GetDisplayInfo(nsTArray<nsString>& aDisplayInfo) override;
52   NS_IMETHOD GetDisplayWidth(nsTArray<uint32_t>& aDisplayWidth) override;
53   NS_IMETHOD GetDisplayHeight(nsTArray<uint32_t>& aDisplayHeight) override;
54   NS_IMETHOD GetDrmRenderDevice(nsACString& aDrmRenderDevice) override;
55   using GfxInfoBase::GetFeatureStatus;
56   using GfxInfoBase::GetFeatureSuggestedDriverVersion;
57 
58   virtual nsresult Init() override;
59 
60   NS_IMETHOD_(void) GetData() override;
61 
62 #ifdef DEBUG
63   NS_DECL_ISUPPORTS_INHERITED
64   NS_DECL_NSIGFXINFODEBUG
65 #endif
66 
67  protected:
68   ~GfxInfo() = default;
69 
70   virtual nsresult GetFeatureStatusImpl(
71       int32_t aFeature, int32_t* aStatus, nsAString& aSuggestedDriverVersion,
72       const nsTArray<GfxDriverInfo>& aDriverInfo, nsACString& aFailureId,
73       OperatingSystem* aOS = nullptr) override;
74   virtual const nsTArray<GfxDriverInfo>& GetGfxDriverInfo() override;
75 
76   virtual bool DoesWindowProtocolMatch(
77       const nsAString& aBlocklistWindowProtocol,
78       const nsAString& aWindowProtocol) override;
79 
80   virtual bool DoesDriverVendorMatch(const nsAString& aBlocklistVendor,
81                                      const nsAString& aDriverVendor) override;
82 
83  private:
84   nsCString mVendorId;
85   nsCString mDeviceId;
86   nsCString mDriverVendor;
87   nsCString mDriverVersion;
88   nsCString mAdapterDescription;
89   uint32_t mAdapterRAM;
90   nsCString mOS;
91   nsCString mOSRelease;
92   nsAutoCStringN<16> mDesktopEnvironment;
93   nsCString mTestType;
94 
95   nsCString mSecondaryVendorId;
96   nsCString mSecondaryDeviceId;
97 
98   nsCString mDrmRenderDevice;
99 
100   nsTArray<nsCString> mDdxDrivers;
101 
102   struct ScreenInfo {
103     uint32_t mWidth;
104     uint32_t mHeight;
105     bool mIsDefault;
106   };
107 
108   nsTArray<ScreenInfo> mScreenInfo;
109   bool mHasTextureFromPixmap;
110   unsigned int mGLMajorVersion, mGLMinorVersion;
111   bool mIsMesa;
112   bool mIsAccelerated;
113   bool mIsWayland;
114   bool mIsXWayland;
115   bool mHasMultipleGPUs;
116   bool mGlxTestError;
117 
118   void AddCrashReportAnnotations();
119 };
120 
121 }  // namespace widget
122 }  // namespace mozilla
123 
124 #endif /* WIDGET_GTK_GFXINFO_h__ */
125