1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_gfx_config_gfxConfigManager_h
7 #define mozilla_gfx_config_gfxConfigManager_h
8 
9 #include "gfxFeature.h"
10 #include "gfxTypes.h"
11 #include "nsCOMPtr.h"
12 
13 class nsIGfxInfo;
14 
15 namespace mozilla {
16 namespace gfx {
17 
18 class gfxConfigManager {
19  public:
gfxConfigManager()20   gfxConfigManager()
21       : mFeatureWr(nullptr),
22         mFeatureWrQualified(nullptr),
23         mFeatureWrCompositor(nullptr),
24         mFeatureWrAngle(nullptr),
25         mFeatureWrDComp(nullptr),
26         mFeatureWrPartial(nullptr),
27         mFeatureWrShaderCache(nullptr),
28         mFeatureWrOptimizedShaders(nullptr),
29         mFeatureWrSoftware(nullptr),
30         mFeatureHwCompositing(nullptr),
31         mFeatureD3D11HwAngle(nullptr),
32         mFeatureD3D11Compositing(nullptr),
33         mFeatureGPUProcess(nullptr),
34         mWrForceEnabled(false),
35         mWrForceDisabled(false),
36         mWrSoftwareForceEnabled(false),
37         mWrCompositorForceEnabled(false),
38         mWrForceAngle(false),
39         mWrForceAngleNoGPUProcess(false),
40         mWrDCompWinEnabled(false),
41         mWrCompositorDCompRequired(false),
42         mWrPartialPresent(false),
43         mWrOptimizedShaders(false),
44         mGPUProcessAllowSoftware(false),
45         mXRenderEnabled(false),
46         mWrEnvForceEnabled(false),
47         mWrEnvForceDisabled(false),
48         mScaledResolution(false),
49         mDisableHwCompositingNoWr(false),
50         mIsNightly(false),
51         mIsEarlyBetaOrEarlier(false),
52         mSafeMode(false),
53         mIsWin10OrLater(false),
54         mHasWrSoftwareBlocklist(false) {}
55 
56   void Init();
57 
58   void ConfigureWebRender();
59   void ConfigureFromBlocklist(long aFeature, FeatureState* aFeatureState);
60 
61  protected:
62   void EmplaceUserPref(const char* aPrefName, Maybe<bool>& aValue);
63   void ConfigureWebRenderQualified();
64   void ConfigureWebRenderSoftware();
65 
66   nsCOMPtr<nsIGfxInfo> mGfxInfo;
67 
68   FeatureState* mFeatureWr;
69   FeatureState* mFeatureWrQualified;
70   FeatureState* mFeatureWrCompositor;
71   FeatureState* mFeatureWrAngle;
72   FeatureState* mFeatureWrDComp;
73   FeatureState* mFeatureWrPartial;
74   FeatureState* mFeatureWrShaderCache;
75   FeatureState* mFeatureWrOptimizedShaders;
76   FeatureState* mFeatureWrSoftware;
77 
78   FeatureState* mFeatureHwCompositing;
79   FeatureState* mFeatureD3D11HwAngle;
80   FeatureState* mFeatureD3D11Compositing;
81   FeatureState* mFeatureGPUProcess;
82 
83   /**
84    * Prefs
85    */
86   Maybe<bool> mWrCompositorEnabled;
87   bool mWrForceEnabled;
88   bool mWrForceDisabled;
89   bool mWrSoftwareForceEnabled;
90   bool mWrCompositorForceEnabled;
91   bool mWrForceAngle;
92   bool mWrForceAngleNoGPUProcess;
93   bool mWrDCompWinEnabled;
94   bool mWrCompositorDCompRequired;
95   bool mWrPartialPresent;
96   Maybe<bool> mWrShaderCache;
97   bool mWrOptimizedShaders;
98   bool mGPUProcessAllowSoftware;
99   bool mXRenderEnabled;
100 
101   /**
102    * Environment variables
103    */
104   bool mWrEnvForceEnabled;
105   bool mWrEnvForceDisabled;
106 
107   /**
108    * System support
109    */
110   HwStretchingSupport mHwStretchingSupport;
111   bool mScaledResolution;
112   bool mDisableHwCompositingNoWr;
113   bool mIsNightly;
114   bool mIsEarlyBetaOrEarlier;
115   bool mSafeMode;
116   bool mIsWin10OrLater;
117   bool mHasWrSoftwareBlocklist;
118 };
119 
120 }  // namespace gfx
121 }  // namespace mozilla
122 
123 #endif  // mozilla_gfx_config_gfxConfigParams_h
124