Bug 1444940 [wpt PR 9917] - Writable streams: test changes to abort() under error...
[gecko.git] / gfx / thebes / gfxPrefs.h
blobbba9a01aef7196ff2dca628bea20d1e2cae75143
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef GFX_PREFS_H
7 #define GFX_PREFS_H
9 #include <cmath> // for M_PI
10 #include <stdint.h>
11 #include <string>
12 #include "mozilla/Assertions.h"
13 #include "mozilla/Atomics.h"
14 #include "mozilla/gfx/LoggingConstants.h"
15 #include "nsTArray.h"
17 // First time gfxPrefs::GetSingleton() needs to be called on the main thread,
18 // before any of the methods accessing the values are used, but after
19 // the Preferences system has been initialized.
21 // The static methods to access the preference value are safe to call
22 // from any thread after that first call.
24 // To register a preference, you need to add a line in this file using
25 // the DECL_GFX_PREF macro.
27 // Update argument controls whether we read the preference value and save it
28 // or connect with a callback. See UpdatePolicy enum below.
29 // Pref is the string with the preference name.
30 // Name argument is the name of the static function to create.
31 // Type is the type of the preference - bool, int32_t, uint32_t.
32 // Default is the default value for the preference.
34 // For example this line in the .h:
35 // DECL_GFX_PREF(Once,"layers.dump",LayersDump,bool,false);
36 // means that you can call
37 // bool var = gfxPrefs::LayersDump();
38 // from any thread, but that you will only get the preference value of
39 // "layers.dump" as it was set at the start of the session (subject to
40 // note 2 below). If the value was not set, the default would be false.
42 // In another example, this line in the .h:
43 // DECL_GFX_PREF(Live,"gl.msaa-level",MSAALevel,uint32_t,2);
44 // means that every time you call
45 // uint32_t var = gfxPrefs::MSAALevel();
46 // from any thread, you will get the most up to date preference value of
47 // "gl.msaa-level". If the value is not set, the default would be 2.
49 // Note 1: Changing a preference from Live to Once is now as simple
50 // as changing the Update argument. If your code worked before, it will
51 // keep working, and behave as if the user never changes the preference.
52 // Things are a bit more complicated and perhaps even dangerous when
53 // going from Once to Live, or indeed setting a preference to be Live
54 // in the first place, so be careful. You need to be ready for the
55 // values changing mid execution, and if you're using those preferences
56 // in any setup and initialization, you may need to do extra work.
58 // Note 2: Prefs can be set by using the corresponding Set method. For
59 // example, if the accessor is Foo() then calling SetFoo(...) will update
60 // the preference and also change the return value of subsequent Foo() calls.
61 // This is true even for 'Once' prefs which otherwise do not change if the
62 // pref is updated after initialization. Changing gfxPrefs values in content
63 // processes will not affect the result in other processes. Changing gfxPrefs
64 // values in the GPU process is not supported at all.
66 #define DECL_GFX_PREF(Update, Prefname, Name, Type, Default) \
67 public: \
68 static Type Name() { MOZ_ASSERT(SingletonExists()); return GetSingleton().mPref##Name.mValue; } \
69 static void Set##Name(Type aVal) { MOZ_ASSERT(SingletonExists()); \
70 GetSingleton().mPref##Name.Set(UpdatePolicy::Update, Get##Name##PrefName(), aVal); } \
71 static const char* Get##Name##PrefName() { return Prefname; } \
72 static Type Get##Name##PrefDefault() { return Default; } \
73 static void Set##Name##ChangeCallback(Pref::ChangeCallback aCallback) { \
74 MOZ_ASSERT(SingletonExists()); \
75 GetSingleton().mPref##Name.SetChangeCallback(aCallback); } \
76 private: \
77 PrefTemplate<UpdatePolicy::Update, Type, Get##Name##PrefDefault, Get##Name##PrefName> mPref##Name
79 // This declares an "override" pref, which is exposed as a "bool" pref by the API,
80 // but is internally stored as a tri-state int pref with three possible values:
81 // - A value of 0 means that it has been force-disabled, and is exposed as a
82 // false-valued bool.
83 // - A value of 1 means that it has been force-enabled, and is exposed as a
84 // true-valued bool.
85 // - A value of 2 (the default) means that it returns the provided BaseValue
86 // as a boolean. The BaseValue may be a constant expression or a function.
87 // If the prefs defined with this macro are listed in prefs files (e.g. all.js),
88 // then they must be listed with an int value (default to 2, but you can use 0
89 // or 1 if you want to force it on or off).
90 #define DECL_OVERRIDE_PREF(Update, Prefname, Name, BaseValue) \
91 public: \
92 static bool Name() { MOZ_ASSERT(SingletonExists()); \
93 int32_t val = GetSingleton().mPref##Name.mValue; \
94 return val == 2 ? !!(BaseValue) : !!val; } \
95 static void Set##Name(bool aVal) { MOZ_ASSERT(SingletonExists()); \
96 GetSingleton().mPref##Name.Set(UpdatePolicy::Update, Get##Name##PrefName(), aVal ? 1 : 0); } \
97 static const char* Get##Name##PrefName() { return Prefname; } \
98 static int32_t Get##Name##PrefDefault() { return 2; } \
99 static void Set##Name##ChangeCallback(Pref::ChangeCallback aCallback) { \
100 MOZ_ASSERT(SingletonExists()); \
101 GetSingleton().mPref##Name.SetChangeCallback(aCallback); } \
102 private: \
103 PrefTemplate<UpdatePolicy::Update, int32_t, Get##Name##PrefDefault, Get##Name##PrefName> mPref##Name
105 namespace mozilla {
106 namespace gfx {
107 class GfxPrefValue; // defined in PGPU.ipdl
108 } // namespace gfx
109 } // namespace mozilla
111 class gfxPrefs;
112 class gfxPrefs final
114 typedef mozilla::gfx::GfxPrefValue GfxPrefValue;
116 typedef mozilla::Atomic<bool, mozilla::Relaxed> AtomicBool;
117 typedef mozilla::Atomic<int32_t, mozilla::Relaxed> AtomicInt32;
118 typedef mozilla::Atomic<uint32_t, mozilla::Relaxed> AtomicUint32;
120 private:
121 // Enums for the update policy.
122 enum class UpdatePolicy {
123 Skip, // Set the value to default, skip any Preferences calls
124 Once, // Evaluate the preference once, unchanged during the session
125 Live // Evaluate the preference and set callback so it stays current/live
128 public:
129 class Pref
131 public:
132 Pref() : mChangeCallback(nullptr)
134 mIndex = sGfxPrefList->Length();
135 sGfxPrefList->AppendElement(this);
138 size_t Index() const { return mIndex; }
139 void OnChange();
141 typedef void (*ChangeCallback)(const GfxPrefValue&);
142 void SetChangeCallback(ChangeCallback aCallback);
144 virtual const char* Name() const = 0;
146 // Returns true if the value is default, false if changed.
147 virtual bool HasDefaultValue() const = 0;
149 // Returns the pref value as a discriminated union.
150 virtual void GetLiveValue(GfxPrefValue* aOutValue) const = 0;
152 // Returns the pref value as a discriminated union.
153 virtual void GetCachedValue(GfxPrefValue* aOutValue) const = 0;
155 // Change the cached value. GfxPrefValue must be a compatible type.
156 virtual void SetCachedValue(const GfxPrefValue& aOutValue) = 0;
158 protected:
159 void FireChangeCallback();
161 private:
162 size_t mIndex;
163 ChangeCallback mChangeCallback;
166 static const nsTArray<Pref*>& all() {
167 return *sGfxPrefList;
170 private:
171 // We split out a base class to reduce the number of virtual function
172 // instantiations that we do, which saves code size.
173 template<class T>
174 class TypedPref : public Pref
176 public:
177 explicit TypedPref(T aValue)
178 : mValue(aValue)
181 void GetCachedValue(GfxPrefValue* aOutValue) const override {
182 CopyPrefValue(&mValue, aOutValue);
184 void SetCachedValue(const GfxPrefValue& aOutValue) override {
185 // This is only used in non-XPCOM processes.
186 MOZ_ASSERT(!IsPrefsServiceAvailable());
188 T newValue;
189 CopyPrefValue(&aOutValue, &newValue);
191 if (mValue != newValue) {
192 mValue = newValue;
193 FireChangeCallback();
197 protected:
198 T GetLiveValueByName(const char* aPrefName) const {
199 if (IsPrefsServiceAvailable()) {
200 return PrefGet(aPrefName, mValue);
202 return mValue;
205 public:
206 T mValue;
209 // Since we cannot use const char*, use a function that returns it.
210 template <UpdatePolicy Update, class T, T Default(void), const char* Prefname(void)>
211 class PrefTemplate final : public TypedPref<T>
213 typedef TypedPref<T> BaseClass;
214 public:
215 PrefTemplate()
216 : BaseClass(Default())
218 // If not using the Preferences service, values are synced over IPC, so
219 // there's no need to register us as a Preferences observer.
220 if (IsPrefsServiceAvailable()) {
221 Register(Update, Prefname());
223 // By default we only watch changes in the parent process, to communicate
224 // changes to the GPU process.
225 if (IsParentProcess() && Update == UpdatePolicy::Live) {
226 WatchChanges(Prefname(), this);
229 ~PrefTemplate() {
230 if (IsParentProcess() && Update == UpdatePolicy::Live) {
231 UnwatchChanges(Prefname(), this);
234 void Register(UpdatePolicy aUpdate, const char* aPreference)
236 AssertMainThread();
237 switch (aUpdate) {
238 case UpdatePolicy::Skip:
239 break;
240 case UpdatePolicy::Once:
241 this->mValue = PrefGet(aPreference, this->mValue);
242 break;
243 case UpdatePolicy::Live:
244 PrefAddVarCache(&this->mValue, aPreference, this->mValue);
245 break;
246 default:
247 MOZ_CRASH("Incomplete switch");
250 void Set(UpdatePolicy aUpdate, const char* aPref, T aValue)
252 AssertMainThread();
253 PrefSet(aPref, aValue);
254 switch (aUpdate) {
255 case UpdatePolicy::Skip:
256 case UpdatePolicy::Live:
257 break;
258 case UpdatePolicy::Once:
259 this->mValue = PrefGet(aPref, this->mValue);
260 break;
261 default:
262 MOZ_CRASH("Incomplete switch");
265 const char *Name() const override {
266 return Prefname();
268 void GetLiveValue(GfxPrefValue* aOutValue) const override {
269 T value = GetLiveValue();
270 CopyPrefValue(&value, aOutValue);
272 // When using the Preferences service, the change callback can be triggered
273 // *before* our cached value is updated, so we expose a method to grab the
274 // true live value.
275 T GetLiveValue() const {
276 return BaseClass::GetLiveValueByName(Prefname());
278 bool HasDefaultValue() const override {
279 return this->mValue == Default();
283 // This is where DECL_GFX_PREF for each of the preferences should go.
284 // We will keep these in an alphabetical order to make it easier to see if
285 // a method accessing a pref already exists. Just add yours in the list.
287 DECL_GFX_PREF(Live, "accessibility.browsewithcaret", AccessibilityBrowseWithCaret, bool, false);
289 // The apz prefs are explained in AsyncPanZoomController.cpp
290 DECL_GFX_PREF(Live, "apz.allow_checkerboarding", APZAllowCheckerboarding, bool, true);
291 DECL_GFX_PREF(Live, "apz.allow_immediate_handoff", APZAllowImmediateHandoff, bool, true);
292 DECL_GFX_PREF(Live, "apz.allow_zooming", APZAllowZooming, bool, false);
293 DECL_GFX_PREF(Live, "apz.autoscroll.enabled", APZAutoscrollEnabled, bool, false);
294 DECL_GFX_PREF(Live, "apz.axis_lock.breakout_angle", APZAxisBreakoutAngle, float, float(M_PI / 8.0) /* 22.5 degrees */);
295 DECL_GFX_PREF(Live, "apz.axis_lock.breakout_threshold", APZAxisBreakoutThreshold, float, 1.0f / 32.0f);
296 DECL_GFX_PREF(Live, "apz.axis_lock.direct_pan_angle", APZAllowedDirectPanAngle, float, float(M_PI / 3.0) /* 60 degrees */);
297 DECL_GFX_PREF(Live, "apz.axis_lock.lock_angle", APZAxisLockAngle, float, float(M_PI / 6.0) /* 30 degrees */);
298 DECL_GFX_PREF(Live, "apz.axis_lock.mode", APZAxisLockMode, int32_t, 0);
299 DECL_GFX_PREF(Live, "apz.content_response_timeout", APZContentResponseTimeout, int32_t, 400);
300 DECL_GFX_PREF(Live, "apz.danger_zone_x", APZDangerZoneX, int32_t, 50);
301 DECL_GFX_PREF(Live, "apz.danger_zone_y", APZDangerZoneY, int32_t, 100);
302 DECL_GFX_PREF(Live, "apz.disable_for_scroll_linked_effects", APZDisableForScrollLinkedEffects, bool, false);
303 DECL_GFX_PREF(Live, "apz.displayport_expiry_ms", APZDisplayPortExpiryTime, uint32_t, 15000);
304 DECL_GFX_PREF(Live, "apz.drag.enabled", APZDragEnabled, bool, false);
305 DECL_GFX_PREF(Live, "apz.drag.initial.enabled", APZDragInitiationEnabled, bool, false);
306 DECL_GFX_PREF(Live, "apz.drag.touch.enabled", APZTouchDragEnabled, bool, false);
307 DECL_GFX_PREF(Live, "apz.enlarge_displayport_when_clipped", APZEnlargeDisplayPortWhenClipped, bool, false);
308 DECL_GFX_PREF(Live, "apz.fling_accel_base_mult", APZFlingAccelBaseMultiplier, float, 1.0f);
309 DECL_GFX_PREF(Live, "apz.fling_accel_interval_ms", APZFlingAccelInterval, int32_t, 500);
310 DECL_GFX_PREF(Live, "apz.fling_accel_supplemental_mult", APZFlingAccelSupplementalMultiplier, float, 1.0f);
311 DECL_GFX_PREF(Live, "apz.fling_accel_min_velocity", APZFlingAccelMinVelocity, float, 1.5f);
312 DECL_GFX_PREF(Once, "apz.fling_curve_function_x1", APZCurveFunctionX1, float, 0.0f);
313 DECL_GFX_PREF(Once, "apz.fling_curve_function_x2", APZCurveFunctionX2, float, 1.0f);
314 DECL_GFX_PREF(Once, "apz.fling_curve_function_y1", APZCurveFunctionY1, float, 0.0f);
315 DECL_GFX_PREF(Once, "apz.fling_curve_function_y2", APZCurveFunctionY2, float, 1.0f);
316 DECL_GFX_PREF(Live, "apz.fling_curve_threshold_inches_per_ms", APZCurveThreshold, float, -1.0f);
317 DECL_GFX_PREF(Live, "apz.fling_friction", APZFlingFriction, float, 0.002f);
318 DECL_GFX_PREF(Live, "apz.fling_min_velocity_threshold", APZFlingMinVelocityThreshold, float, 0.5f);
319 DECL_GFX_PREF(Live, "apz.fling_stop_on_tap_threshold", APZFlingStopOnTapThreshold, float, 0.05f);
320 DECL_GFX_PREF(Live, "apz.fling_stopped_threshold", APZFlingStoppedThreshold, float, 0.01f);
321 DECL_GFX_PREF(Live, "apz.frame_delay.enabled", APZFrameDelayEnabled, bool, false);
322 DECL_GFX_PREF(Once, "apz.keyboard.enabled", APZKeyboardEnabled, bool, false);
323 DECL_GFX_PREF(Live, "apz.keyboard.passive-listeners", APZKeyboardPassiveListeners, bool, false);
324 DECL_GFX_PREF(Live, "apz.max_tap_time", APZMaxTapTime, int32_t, 300);
325 DECL_GFX_PREF(Live, "apz.max_velocity_inches_per_ms", APZMaxVelocity, float, -1.0f);
326 DECL_GFX_PREF(Once, "apz.max_velocity_queue_size", APZMaxVelocityQueueSize, uint32_t, 5);
327 DECL_GFX_PREF(Live, "apz.min_skate_speed", APZMinSkateSpeed, float, 1.0f);
328 DECL_GFX_PREF(Live, "apz.minimap.enabled", APZMinimap, bool, false);
329 DECL_GFX_PREF(Live, "apz.one_touch_pinch.enabled", APZOneTouchPinchEnabled, bool, true);
330 DECL_GFX_PREF(Live, "apz.overscroll.enabled", APZOverscrollEnabled, bool, false);
331 DECL_GFX_PREF(Live, "apz.overscroll.min_pan_distance_ratio", APZMinPanDistanceRatio, float, 1.0f);
332 DECL_GFX_PREF(Live, "apz.overscroll.spring_stiffness", APZOverscrollSpringStiffness, float, 0.001f);
333 DECL_GFX_PREF(Live, "apz.overscroll.stop_distance_threshold", APZOverscrollStopDistanceThreshold, float, 5.0f);
334 DECL_GFX_PREF(Live, "apz.paint_skipping.enabled", APZPaintSkipping, bool, true);
335 DECL_GFX_PREF(Live, "apz.peek_messages.enabled", APZPeekMessages, bool, true);
336 DECL_GFX_PREF(Live, "apz.pinch_lock.mode", APZPinchLockMode, int32_t, 1);
337 DECL_GFX_PREF(Live, "apz.pinch_lock.scroll_lock_threshold", APZPinchLockScrollLockThreshold, float, 1.0f / 32.0f);
338 DECL_GFX_PREF(Live, "apz.pinch_lock.span_breakout_threshold", APZPinchLockSpanBreakoutThreshold, float, 1.0f / 32.0f);
339 DECL_GFX_PREF(Live, "apz.pinch_lock.span_lock_threshold", APZPinchLockSpanLockThreshold, float, 1.0f / 32.0f);
340 DECL_GFX_PREF(Live, "apz.popups.enabled", APZPopupsEnabled, bool, false);
341 DECL_GFX_PREF(Live, "apz.printtree", APZPrintTree, bool, false);
342 DECL_GFX_PREF(Live, "apz.record_checkerboarding", APZRecordCheckerboarding, bool, false);
343 DECL_GFX_PREF(Live, "apz.second_tap_tolerance", APZSecondTapTolerance, float, 0.5f);
344 DECL_GFX_PREF(Live, "apz.test.fails_with_native_injection", APZTestFailsWithNativeInjection, bool, false);
345 DECL_GFX_PREF(Live, "apz.test.logging_enabled", APZTestLoggingEnabled, bool, false);
346 DECL_GFX_PREF(Live, "apz.touch_move_tolerance", APZTouchMoveTolerance, float, 0.1f);
347 DECL_GFX_PREF(Live, "apz.touch_start_tolerance", APZTouchStartTolerance, float, 1.0f/4.5f);
348 DECL_GFX_PREF(Live, "apz.velocity_bias", APZVelocityBias, float, 0.0f);
349 DECL_GFX_PREF(Live, "apz.velocity_relevance_time_ms", APZVelocityRelevanceTime, uint32_t, 150);
350 DECL_GFX_PREF(Live, "apz.x_skate_highmem_adjust", APZXSkateHighMemAdjust, float, 0.0f);
351 DECL_GFX_PREF(Live, "apz.x_skate_size_multiplier", APZXSkateSizeMultiplier, float, 1.5f);
352 DECL_GFX_PREF(Live, "apz.x_stationary_size_multiplier", APZXStationarySizeMultiplier, float, 3.0f);
353 DECL_GFX_PREF(Live, "apz.y_skate_highmem_adjust", APZYSkateHighMemAdjust, float, 0.0f);
354 DECL_GFX_PREF(Live, "apz.y_skate_size_multiplier", APZYSkateSizeMultiplier, float, 2.5f);
355 DECL_GFX_PREF(Live, "apz.y_stationary_size_multiplier", APZYStationarySizeMultiplier, float, 3.5f);
356 DECL_GFX_PREF(Live, "apz.zoom_animation_duration_ms", APZZoomAnimationDuration, int32_t, 250);
357 DECL_GFX_PREF(Live, "apz.scale_repaint_delay_ms", APZScaleRepaintDelay, int32_t, 500);
359 DECL_GFX_PREF(Live, "browser.ui.scroll-toolbar-threshold", ToolbarScrollThreshold, int32_t, 10);
360 DECL_GFX_PREF(Live, "browser.ui.zoom.force-user-scalable", ForceUserScalable, bool, false);
361 DECL_GFX_PREF(Live, "browser.viewport.desktopWidth", DesktopViewportWidth, int32_t, 980);
363 DECL_GFX_PREF(Live, "dom.ipc.plugins.asyncdrawing.enabled", PluginAsyncDrawingEnabled, bool, false);
364 DECL_GFX_PREF(Live, "dom.meta-viewport.enabled", MetaViewportEnabled, bool, false);
365 DECL_GFX_PREF(Once, "dom.vr.enabled", VREnabled, bool, false);
366 DECL_GFX_PREF(Live, "dom.vr.autoactivate.enabled", VRAutoActivateEnabled, bool, false);
367 DECL_GFX_PREF(Live, "dom.vr.controller_trigger_threshold", VRControllerTriggerThreshold, float, 0.1f);
368 DECL_GFX_PREF(Once, "dom.vr.external.enabled", VRExternalEnabled, bool, true);
369 DECL_GFX_PREF(Live, "dom.vr.navigation.timeout", VRNavigationTimeout, int32_t, 1000);
370 DECL_GFX_PREF(Once, "dom.vr.oculus.enabled", VROculusEnabled, bool, true);
371 DECL_GFX_PREF(Live, "dom.vr.oculus.invisible.enabled", VROculusInvisibleEnabled, bool, true);
372 DECL_GFX_PREF(Live, "dom.vr.oculus.present.timeout", VROculusPresentTimeout, int32_t, 500);
373 DECL_GFX_PREF(Live, "dom.vr.oculus.quit.timeout", VROculusQuitTimeout, int32_t, 10000);
374 DECL_GFX_PREF(Once, "dom.vr.openvr.enabled", VROpenVREnabled, bool, false);
375 DECL_GFX_PREF(Once, "dom.vr.osvr.enabled", VROSVREnabled, bool, false);
376 DECL_GFX_PREF(Live, "dom.vr.controller.enumerate.interval", VRControllerEnumerateInterval, int32_t, 1000);
377 DECL_GFX_PREF(Live, "dom.vr.display.enumerate.interval", VRDisplayEnumerateInterval, int32_t, 5000);
378 DECL_GFX_PREF(Live, "dom.vr.inactive.timeout", VRInactiveTimeout, int32_t, 5000);
379 DECL_GFX_PREF(Live, "dom.vr.poseprediction.enabled", VRPosePredictionEnabled, bool, true);
380 DECL_GFX_PREF(Live, "dom.vr.require-gesture", VRRequireGesture, bool, true);
381 DECL_GFX_PREF(Live, "dom.vr.puppet.enabled", VRPuppetEnabled, bool, false);
382 DECL_GFX_PREF(Live, "dom.vr.puppet.submitframe", VRPuppetSubmitFrame, uint32_t, 0);
383 DECL_GFX_PREF(Live, "dom.vr.display.rafMaxDuration", VRDisplayRafMaxDuration, uint32_t, 50);
384 DECL_GFX_PREF(Live, "dom.w3c_pointer_events.enabled", PointerEventsEnabled, bool, false);
386 DECL_GFX_PREF(Live, "general.smoothScroll", SmoothScrollEnabled, bool, true);
387 DECL_GFX_PREF(Live, "general.smoothScroll.currentVelocityWeighting",
388 SmoothScrollCurrentVelocityWeighting, float, 0.25);
389 DECL_GFX_PREF(Live, "general.smoothScroll.durationToIntervalRatio",
390 SmoothScrollDurationToIntervalRatio, int32_t, 200);
391 DECL_GFX_PREF(Live, "general.smoothScroll.lines.durationMaxMS",
392 LineSmoothScrollMaxDurationMs, int32_t, 150);
393 DECL_GFX_PREF(Live, "general.smoothScroll.lines.durationMinMS",
394 LineSmoothScrollMinDurationMs, int32_t, 150);
395 DECL_GFX_PREF(Live, "general.smoothScroll.mouseWheel", WheelSmoothScrollEnabled, bool, true);
396 DECL_GFX_PREF(Live, "general.smoothScroll.mouseWheel.durationMaxMS",
397 WheelSmoothScrollMaxDurationMs, int32_t, 400);
398 DECL_GFX_PREF(Live, "general.smoothScroll.mouseWheel.durationMinMS",
399 WheelSmoothScrollMinDurationMs, int32_t, 200);
400 DECL_GFX_PREF(Live, "general.smoothScroll.other.durationMaxMS",
401 OtherSmoothScrollMaxDurationMs, int32_t, 150);
402 DECL_GFX_PREF(Live, "general.smoothScroll.other.durationMinMS",
403 OtherSmoothScrollMinDurationMs, int32_t, 150);
404 DECL_GFX_PREF(Live, "general.smoothScroll.pages", PageSmoothScrollEnabled, bool, true);
405 DECL_GFX_PREF(Live, "general.smoothScroll.pages.durationMaxMS",
406 PageSmoothScrollMaxDurationMs, int32_t, 150);
407 DECL_GFX_PREF(Live, "general.smoothScroll.pages.durationMinMS",
408 PageSmoothScrollMinDurationMs, int32_t, 150);
409 DECL_GFX_PREF(Live, "general.smoothScroll.pixels.durationMaxMS",
410 PixelSmoothScrollMaxDurationMs, int32_t, 150);
411 DECL_GFX_PREF(Live, "general.smoothScroll.pixels.durationMinMS",
412 PixelSmoothScrollMinDurationMs, int32_t, 150);
413 DECL_GFX_PREF(Live, "general.smoothScroll.stopDecelerationWeighting",
414 SmoothScrollStopDecelerationWeighting, float, 0.4f);
416 DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.enabled",
417 SmoothScrollMSDPhysicsEnabled, bool, false);
418 DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.continuousMotionMaxDeltaMS",
419 SmoothScrollMSDPhysicsContinuousMotionMaxDeltaMS, int32_t, 120);
420 DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.motionBeginSpringConstant",
421 SmoothScrollMSDPhysicsMotionBeginSpringConstant, int32_t, 1250);
422 DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.slowdownMinDeltaMS",
423 SmoothScrollMSDPhysicsSlowdownMinDeltaMS, int32_t, 12);
424 DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.slowdownMinDeltaRatio",
425 SmoothScrollMSDPhysicsSlowdownMinDeltaRatio, float, 1.3f);
426 DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.slowdownSpringConstant",
427 SmoothScrollMSDPhysicsSlowdownSpringConstant, int32_t, 2000);
428 DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.regularSpringConstant",
429 SmoothScrollMSDPhysicsRegularSpringConstant, int32_t, 1000);
431 DECL_GFX_PREF(Once, "gfx.android.rgb16.force", AndroidRGB16Force, bool, false);
432 #if defined(ANDROID)
433 DECL_GFX_PREF(Once, "gfx.apitrace.enabled", UseApitrace, bool, false);
434 #endif
435 #if defined(RELEASE_OR_BETA)
436 // "Skip" means this is locked to the default value in beta and release.
437 DECL_GFX_PREF(Skip, "gfx.blocklist.all", BlocklistAll, int32_t, 0);
438 #else
439 DECL_GFX_PREF(Once, "gfx.blocklist.all", BlocklistAll, int32_t, 0);
440 #endif
441 DECL_GFX_PREF(Live, "gfx.compositor.clearstate", CompositorClearState, bool, false);
442 DECL_GFX_PREF(Live, "gfx.compositor.glcontext.opaque", CompositorGLContextOpaque, bool, false);
443 DECL_GFX_PREF(Live, "gfx.canvas.auto_accelerate.min_calls", CanvasAutoAccelerateMinCalls, int32_t, 4);
444 DECL_GFX_PREF(Live, "gfx.canvas.auto_accelerate.min_frames", CanvasAutoAccelerateMinFrames, int32_t, 30);
445 DECL_GFX_PREF(Live, "gfx.canvas.auto_accelerate.min_seconds", CanvasAutoAccelerateMinSeconds, float, 5.0f);
446 DECL_GFX_PREF(Live, "gfx.canvas.azure.accelerated", CanvasAzureAccelerated, bool, false);
447 DECL_GFX_PREF(Once, "gfx.canvas.azure.accelerated.limit", CanvasAzureAcceleratedLimit, int32_t, 0);
448 // 0x7fff is the maximum supported xlib surface size and is more than enough for canvases.
449 DECL_GFX_PREF(Live, "gfx.canvas.max-size", MaxCanvasSize, int32_t, 0x7fff);
450 DECL_GFX_PREF(Once, "gfx.canvas.skiagl.cache-items", CanvasSkiaGLCacheItems, int32_t, 256);
451 DECL_GFX_PREF(Once, "gfx.canvas.skiagl.cache-size", CanvasSkiaGLCacheSize, int32_t, 96);
452 DECL_GFX_PREF(Once, "gfx.canvas.skiagl.dynamic-cache", CanvasSkiaGLDynamicCache, bool, false);
454 DECL_GFX_PREF(Live, "gfx.color_management.enablev4", CMSEnableV4, bool, false);
455 DECL_GFX_PREF(Live, "gfx.color_management.mode", CMSMode, int32_t,-1);
456 // The zero default here should match QCMS_INTENT_DEFAULT from qcms.h
457 DECL_GFX_PREF(Live, "gfx.color_management.rendering_intent", CMSRenderingIntent, int32_t, 0);
458 DECL_GFX_PREF(Live, "gfx.content.always-paint", AlwaysPaint, bool, false);
459 // Size in megabytes
460 DECL_GFX_PREF(Once, "gfx.content.skia-font-cache-size", SkiaContentFontCacheSize, int32_t, 10);
462 DECL_GFX_PREF(Once, "gfx.device-reset.limit", DeviceResetLimitCount, int32_t, 10);
463 DECL_GFX_PREF(Once, "gfx.device-reset.threshold-ms", DeviceResetThresholdMilliseconds, int32_t, -1);
465 DECL_GFX_PREF(Once, "gfx.direct2d.disabled", Direct2DDisabled, bool, false);
466 DECL_GFX_PREF(Once, "gfx.direct2d.force-enabled", Direct2DForceEnabled, bool, false);
467 DECL_GFX_PREF(Live, "gfx.direct2d.destroy-dt-on-paintthread",Direct2DDestroyDTOnPaintThread, bool, true);
468 DECL_GFX_PREF(Live, "gfx.direct3d11.reuse-decoder-device", Direct3D11ReuseDecoderDevice, int32_t, -1);
469 DECL_GFX_PREF(Live, "gfx.direct3d11.allow-keyed-mutex", Direct3D11AllowKeyedMutex, bool, true);
470 DECL_GFX_PREF(Live, "gfx.direct3d11.use-double-buffering", Direct3D11UseDoubleBuffering, bool, false);
471 DECL_GFX_PREF(Once, "gfx.direct3d11.enable-debug-layer", Direct3D11EnableDebugLayer, bool, false);
472 DECL_GFX_PREF(Once, "gfx.direct3d11.break-on-error", Direct3D11BreakOnError, bool, false);
473 DECL_GFX_PREF(Once, "gfx.direct3d11.sleep-on-create-device", Direct3D11SleepOnCreateDevice, int32_t, 0);
474 DECL_GFX_PREF(Live, "gfx.downloadable_fonts.keep_color_bitmaps", KeepColorBitmaps, bool, false);
475 DECL_GFX_PREF(Live, "gfx.downloadable_fonts.keep_variation_tables", KeepVariationTables, bool, false);
476 DECL_GFX_PREF(Live, "gfx.downloadable_fonts.otl_validation", ValidateOTLTables, bool, true);
477 DECL_GFX_PREF(Live, "gfx.draw-color-bars", CompositorDrawColorBars, bool, false);
478 DECL_GFX_PREF(Once, "gfx.e10s.hide-plugins-for-scroll", HidePluginsForScroll, bool, true);
479 DECL_GFX_PREF(Live, "gfx.layerscope.enabled", LayerScopeEnabled, bool, false);
480 DECL_GFX_PREF(Live, "gfx.layerscope.port", LayerScopePort, int32_t, 23456);
481 // Note that "gfx.logging.level" is defined in Logging.h.
482 DECL_GFX_PREF(Live, "gfx.logging.level", GfxLoggingLevel, int32_t, mozilla::gfx::LOG_DEFAULT);
483 DECL_GFX_PREF(Once, "gfx.logging.crash.length", GfxLoggingCrashLength, uint32_t, 16);
484 DECL_GFX_PREF(Live, "gfx.logging.painted-pixel-count.enabled",GfxLoggingPaintedPixelCountEnabled, bool, false);
485 // The maximums here are quite conservative, we can tighten them if problems show up.
486 DECL_GFX_PREF(Once, "gfx.logging.texture-usage.enabled", GfxLoggingTextureUsageEnabled, bool, false);
487 DECL_GFX_PREF(Once, "gfx.logging.peak-texture-usage.enabled",GfxLoggingPeakTextureUsageEnabled, bool, false);
488 // Use gfxPlatform::MaxAllocSize instead of the pref directly
489 DECL_GFX_PREF(Once, "gfx.max-alloc-size", MaxAllocSizeDoNotUseDirectly, int32_t, (int32_t)500000000);
490 // Use gfxPlatform::MaxTextureSize instead of the pref directly
491 DECL_GFX_PREF(Once, "gfx.max-texture-size", MaxTextureSizeDoNotUseDirectly, int32_t, (int32_t)32767);
492 DECL_GFX_PREF(Live, "gfx.partialpresent.force", PartialPresent, int32_t, 0);
493 DECL_GFX_PREF(Live, "gfx.perf-warnings.enabled", PerfWarnings, bool, false);
494 DECL_GFX_PREF(Live, "gfx.testing.device-reset", DeviceResetForTesting, int32_t, 0);
495 DECL_GFX_PREF(Live, "gfx.testing.device-fail", DeviceFailForTesting, bool, false);
496 DECL_GFX_PREF(Once, "gfx.text.disable-aa", DisableAllTextAA, bool, false);
497 DECL_GFX_PREF(Live, "gfx.ycbcr.accurate-conversion", YCbCrAccurateConversion, bool, false);
499 // Disable surface sharing due to issues with compatible FBConfigs on
500 // NVIDIA drivers as described in bug 1193015.
501 DECL_GFX_PREF(Live, "gfx.use-glx-texture-from-pixmap", UseGLXTextureFromPixmap, bool, false);
502 DECL_GFX_PREF(Once, "gfx.use-iosurface-textures", UseIOSurfaceTextures, bool, false);
503 DECL_GFX_PREF(Once, "gfx.use-mutex-on-present", UseMutexOnPresent, bool, false);
504 DECL_GFX_PREF(Once, "gfx.use-surfacetexture-textures", UseSurfaceTextureTextures, bool, false);
506 DECL_GFX_PREF(Live, "gfx.vsync.collect-scroll-transforms", CollectScrollTransforms, bool, false);
507 DECL_GFX_PREF(Once, "gfx.vsync.compositor.unobserve-count", CompositorUnobserveCount, int32_t, 10);
509 DECL_GFX_PREF(Once, "gfx.webrender.all", WebRenderAll, bool, false);
510 DECL_GFX_PREF(Once, "gfx.webrender.enabled", WebRenderEnabledDoNotUseDirectly, bool, false);
511 DECL_OVERRIDE_PREF(Live, "gfx.webrender.blob-images", WebRenderBlobImages, gfxPrefs::WebRenderAll());
512 DECL_GFX_PREF(Live, "gfx.webrender.blob.invalidation", WebRenderBlobInvalidation, bool, false);
513 DECL_GFX_PREF(Live, "gfx.webrender.highlight-painted-layers",WebRenderHighlightPaintedLayers, bool, false);
514 DECL_GFX_PREF(Live, "gfx.webrender.hit-test", WebRenderHitTest, bool, true);
516 // Use vsync events generated by hardware
517 DECL_GFX_PREF(Once, "gfx.work-around-driver-bugs", WorkAroundDriverBugs, bool, true);
519 DECL_GFX_PREF(Live, "gl.ignore-dx-interop2-blacklist", IgnoreDXInterop2Blacklist, bool, false);
520 DECL_GFX_PREF(Live, "gl.msaa-level", MSAALevel, uint32_t, 2);
521 #if defined(XP_MACOSX)
522 DECL_GFX_PREF(Live, "gl.multithreaded", GLMultithreaded, bool, false);
523 #endif
524 DECL_GFX_PREF(Live, "gl.require-hardware", RequireHardwareGL, bool, false);
525 DECL_GFX_PREF(Live, "gl.use-tls-is-current", UseTLSIsCurrent, int32_t, 0);
527 DECL_GFX_PREF(Live, "image.animated.decode-on-demand.threshold-kb", ImageAnimatedDecodeOnDemandThresholdKB, uint32_t, 20480);
528 DECL_GFX_PREF(Live, "image.animated.decode-on-demand.batch-size", ImageAnimatedDecodeOnDemandBatchSize, uint32_t, 6);
529 DECL_GFX_PREF(Live, "image.cache.factor2.threshold-surfaces", ImageCacheFactor2ThresholdSurfaces, int32_t, -1);
530 DECL_GFX_PREF(Once, "image.cache.size", ImageCacheSize, int32_t, 5*1024*1024);
531 DECL_GFX_PREF(Once, "image.cache.timeweight", ImageCacheTimeWeight, int32_t, 500);
532 DECL_GFX_PREF(Live, "image.decode-immediately.enabled", ImageDecodeImmediatelyEnabled, bool, false);
533 DECL_GFX_PREF(Live, "image.downscale-during-decode.enabled", ImageDownscaleDuringDecodeEnabled, bool, true);
534 DECL_GFX_PREF(Live, "image.infer-src-animation.threshold-ms", ImageInferSrcAnimationThresholdMS, uint32_t, 2000);
535 DECL_GFX_PREF(Live, "image.layout_network_priority", ImageLayoutNetworkPriority, bool, true);
536 DECL_GFX_PREF(Once, "image.mem.decode_bytes_at_a_time", ImageMemDecodeBytesAtATime, uint32_t, 200000);
537 DECL_GFX_PREF(Live, "image.mem.discardable", ImageMemDiscardable, bool, false);
538 DECL_GFX_PREF(Once, "image.mem.animated.discardable", ImageMemAnimatedDiscardable, bool, false);
539 DECL_GFX_PREF(Live, "image.mem.animated.use_heap", ImageMemAnimatedUseHeap, bool, false);
540 DECL_OVERRIDE_PREF(Live, "image.mem.shared", ImageMemShared, gfxPrefs::WebRenderAll());
541 DECL_GFX_PREF(Once, "image.mem.surfacecache.discard_factor", ImageMemSurfaceCacheDiscardFactor, uint32_t, 1);
542 DECL_GFX_PREF(Once, "image.mem.surfacecache.max_size_kb", ImageMemSurfaceCacheMaxSizeKB, uint32_t, 100 * 1024);
543 DECL_GFX_PREF(Once, "image.mem.surfacecache.min_expiration_ms", ImageMemSurfaceCacheMinExpirationMS, uint32_t, 60*1000);
544 DECL_GFX_PREF(Once, "image.mem.surfacecache.size_factor", ImageMemSurfaceCacheSizeFactor, uint32_t, 64);
545 DECL_GFX_PREF(Live, "image.mem.volatile.min_threshold_kb", ImageMemVolatileMinThresholdKB, int32_t, -1);
546 DECL_GFX_PREF(Once, "image.multithreaded_decoding.limit", ImageMTDecodingLimit, int32_t, -1);
547 DECL_GFX_PREF(Once, "image.multithreaded_decoding.idle_timeout", ImageMTDecodingIdleTimeout, int32_t, -1);
549 DECL_GFX_PREF(Once, "layers.acceleration.disabled", LayersAccelerationDisabledDoNotUseDirectly, bool, false);
550 DECL_GFX_PREF(Live, "layers.acceleration.draw-fps", LayersDrawFPS, bool, false);
551 DECL_GFX_PREF(Live, "layers.acceleration.draw-fps.print-histogram", FPSPrintHistogram, bool, false);
552 DECL_GFX_PREF(Live, "layers.acceleration.draw-fps.write-to-file", WriteFPSToFile, bool, false);
553 DECL_GFX_PREF(Once, "layers.acceleration.force-enabled", LayersAccelerationForceEnabledDoNotUseDirectly, bool, false);
554 DECL_GFX_PREF(Live, "layers.advanced.border-layers", LayersAllowBorderLayers, bool, false);
555 DECL_GFX_PREF(Live, "layers.advanced.basic-layer.enabled", LayersAdvancedBasicLayerEnabled, bool, false);
556 DECL_GFX_PREF(Once, "layers.amd-switchable-gfx.enabled", LayersAMDSwitchableGfxEnabled, bool, false);
557 DECL_GFX_PREF(Once, "layers.async-pan-zoom.enabled", AsyncPanZoomEnabledDoNotUseDirectly, bool, true);
558 DECL_GFX_PREF(Once, "layers.async-pan-zoom.separate-event-thread", AsyncPanZoomSeparateEventThread, bool, false);
559 DECL_GFX_PREF(Live, "layers.bench.enabled", LayersBenchEnabled, bool, false);
560 DECL_GFX_PREF(Once, "layers.bufferrotation.enabled", BufferRotationEnabled, bool, true);
561 DECL_GFX_PREF(Live, "layers.child-process-shutdown", ChildProcessShutdown, bool, true);
562 #ifdef MOZ_GFX_OPTIMIZE_MOBILE
563 // If MOZ_GFX_OPTIMIZE_MOBILE is defined, we force component alpha off
564 // and ignore the preference.
565 DECL_GFX_PREF(Skip, "layers.componentalpha.enabled", ComponentAlphaEnabled, bool, false);
566 #else
567 // If MOZ_GFX_OPTIMIZE_MOBILE is not defined, we actually take the
568 // preference value, defaulting to true.
569 DECL_GFX_PREF(Once, "layers.componentalpha.enabled", ComponentAlphaEnabled, bool, true);
570 #endif
571 DECL_GFX_PREF(Once, "layers.d3d11.force-warp", LayersD3D11ForceWARP, bool, false);
572 DECL_GFX_PREF(Live, "layers.deaa.enabled", LayersDEAAEnabled, bool, false);
573 DECL_GFX_PREF(Live, "layers.draw-bigimage-borders", DrawBigImageBorders, bool, false);
574 DECL_GFX_PREF(Live, "layers.draw-borders", DrawLayerBorders, bool, false);
575 DECL_GFX_PREF(Live, "layers.draw-tile-borders", DrawTileBorders, bool, false);
576 DECL_GFX_PREF(Live, "layers.draw-layer-info", DrawLayerInfo, bool, false);
577 DECL_GFX_PREF(Live, "layers.dump", LayersDump, bool, false);
578 DECL_GFX_PREF(Live, "layers.dump-texture", LayersDumpTexture, bool, false);
579 #ifdef MOZ_DUMP_PAINTING
580 DECL_GFX_PREF(Live, "layers.dump-client-layers", DumpClientLayers, bool, false);
581 DECL_GFX_PREF(Live, "layers.dump-decision", LayersDumpDecision, bool, false);
582 DECL_GFX_PREF(Live, "layers.dump-host-layers", DumpHostLayers, bool, false);
583 #endif
585 // 0 is "no change" for contrast, positive values increase it, negative values
586 // decrease it until we hit mid gray at -1 contrast, after that it gets weird.
587 DECL_GFX_PREF(Live, "layers.effect.contrast", LayersEffectContrast, float, 0.0f);
588 DECL_GFX_PREF(Live, "layers.effect.grayscale", LayersEffectGrayscale, bool, false);
589 DECL_GFX_PREF(Live, "layers.effect.invert", LayersEffectInvert, bool, false);
590 DECL_GFX_PREF(Once, "layers.enable-tiles", LayersTilesEnabled, bool, false);
591 DECL_GFX_PREF(Live, "layers.flash-borders", FlashLayerBorders, bool, false);
592 DECL_GFX_PREF(Once, "layers.force-shmem-tiles", ForceShmemTiles, bool, false);
593 DECL_GFX_PREF(Once, "layers.gpu-process.allow-software", GPUProcessAllowSoftware, bool, false);
594 DECL_GFX_PREF(Once, "layers.gpu-process.enabled", GPUProcessEnabled, bool, false);
595 DECL_GFX_PREF(Once, "layers.gpu-process.force-enabled", GPUProcessForceEnabled, bool, false);
596 DECL_GFX_PREF(Once, "layers.gpu-process.ipc_reply_timeout_ms", GPUProcessIPCReplyTimeoutMs, int32_t, 10000);
597 DECL_GFX_PREF(Live, "layers.gpu-process.max_restarts", GPUProcessMaxRestarts, int32_t, 1);
598 // Note: This pref will only be used if it is less than layers.gpu-process.max_restarts.
599 DECL_GFX_PREF(Live, "layers.gpu-process.max_restarts_with_decoder", GPUProcessMaxRestartsWithDecoder, int32_t, 0);
600 DECL_GFX_PREF(Once, "layers.gpu-process.startup_timeout_ms", GPUProcessTimeoutMs, int32_t, 5000);
601 DECL_GFX_PREF(Live, "layers.low-precision-buffer", UseLowPrecisionBuffer, bool, false);
602 DECL_GFX_PREF(Live, "layers.low-precision-opacity", LowPrecisionOpacity, float, 1.0f);
603 DECL_GFX_PREF(Live, "layers.low-precision-resolution", LowPrecisionResolution, float, 0.25f);
604 DECL_GFX_PREF(Live, "layers.max-active", MaxActiveLayers, int32_t, -1);
605 DECL_GFX_PREF(Once, "layers.mlgpu.enabled", AdvancedLayersEnabledDoNotUseDirectly, bool, false);
606 DECL_GFX_PREF(Once, "layers.mlgpu.enable-buffer-cache", AdvancedLayersEnableBufferCache, bool, true);
607 DECL_GFX_PREF(Once, "layers.mlgpu.enable-buffer-sharing", AdvancedLayersEnableBufferSharing, bool, true);
608 DECL_GFX_PREF(Once, "layers.mlgpu.enable-clear-view", AdvancedLayersEnableClearView, bool, true);
609 DECL_GFX_PREF(Once, "layers.mlgpu.enable-cpu-occlusion", AdvancedLayersEnableCPUOcclusion, bool, true);
610 DECL_GFX_PREF(Once, "layers.mlgpu.enable-depth-buffer", AdvancedLayersEnableDepthBuffer, bool, false);
611 DECL_GFX_PREF(Live, "layers.mlgpu.enable-invalidation", AdvancedLayersUseInvalidation, bool, true);
612 DECL_GFX_PREF(Once, "layers.mlgpu.enable-on-windows7", AdvancedLayersEnableOnWindows7, bool, false);
613 DECL_GFX_PREF(Once, "layers.mlgpu.enable-container-resizing", AdvancedLayersEnableContainerResizing, bool, true);
614 DECL_GFX_PREF(Once, "layers.offmainthreadcomposition.force-disabled", LayersOffMainThreadCompositionForceDisabled, bool, false);
615 DECL_GFX_PREF(Live, "layers.offmainthreadcomposition.frame-rate", LayersCompositionFrameRate, int32_t,-1);
616 DECL_GFX_PREF(Live, "layers.omtp.dump-capture", LayersOMTPDumpCapture, bool, false);
617 DECL_GFX_PREF(Live, "layers.omtp.paint-workers", LayersOMTPPaintWorkers, int32_t, 1);
618 DECL_GFX_PREF(Live, "layers.omtp.release-capture-on-main-thread", LayersOMTPReleaseCaptureOnMainThread, bool, false);
619 DECL_GFX_PREF(Live, "layers.orientation.sync.timeout", OrientationSyncMillis, uint32_t, (uint32_t)0);
620 DECL_GFX_PREF(Once, "layers.prefer-opengl", LayersPreferOpenGL, bool, false);
621 DECL_GFX_PREF(Live, "layers.progressive-paint", ProgressivePaint, bool, false);
622 DECL_GFX_PREF(Live, "layers.shared-buffer-provider.enabled", PersistentBufferProviderSharedEnabled, bool, false);
623 DECL_GFX_PREF(Live, "layers.single-tile.enabled", LayersSingleTileEnabled, bool, true);
624 DECL_GFX_PREF(Live, "layers.force-synchronous-resize", LayersForceSynchronousResize, bool, true);
626 // We allow for configurable and rectangular tile size to avoid wasting memory on devices whose
627 // screen size does not align nicely to the default tile size. Although layers can be any size,
628 // they are often the same size as the screen, especially for width.
629 DECL_GFX_PREF(Once, "layers.tile-width", LayersTileWidth, int32_t, 256);
630 DECL_GFX_PREF(Once, "layers.tile-height", LayersTileHeight, int32_t, 256);
631 DECL_GFX_PREF(Once, "layers.tile-initial-pool-size", LayersTileInitialPoolSize, uint32_t, (uint32_t)50);
632 DECL_GFX_PREF(Once, "layers.tile-pool-unused-size", LayersTilePoolUnusedSize, uint32_t, (uint32_t)10);
633 DECL_GFX_PREF(Once, "layers.tile-pool-shrink-timeout", LayersTilePoolShrinkTimeout, uint32_t, (uint32_t)50);
634 DECL_GFX_PREF(Once, "layers.tile-pool-clear-timeout", LayersTilePoolClearTimeout, uint32_t, (uint32_t)5000);
635 DECL_GFX_PREF(Once, "layers.tiles.adjust", LayersTilesAdjust, bool, true);
636 DECL_GFX_PREF(Once, "layers.tiles.edge-padding", TileEdgePaddingEnabled, bool, true);
637 DECL_GFX_PREF(Live, "layers.tiles.fade-in.enabled", LayerTileFadeInEnabled, bool, false);
638 DECL_GFX_PREF(Live, "layers.tiles.fade-in.duration-ms", LayerTileFadeInDuration, uint32_t, 250);
639 DECL_GFX_PREF(Live, "layers.transaction.warning-ms", LayerTransactionWarning, uint32_t, 200);
640 DECL_GFX_PREF(Once, "layers.uniformity-info", UniformityInfo, bool, false);
641 DECL_GFX_PREF(Once, "layers.use-image-offscreen-surfaces", UseImageOffscreenSurfaces, bool, true);
642 DECL_GFX_PREF(Live, "layers.draw-mask-debug", DrawMaskLayer, bool, false);
644 DECL_GFX_PREF(Live, "layers.geometry.opengl.enabled", OGLLayerGeometry, bool, false);
645 DECL_GFX_PREF(Live, "layers.geometry.basic.enabled", BasicLayerGeometry, bool, false);
646 DECL_GFX_PREF(Live, "layers.geometry.d3d11.enabled", D3D11LayerGeometry, bool, false);
648 DECL_GFX_PREF(Live, "layout.animation.prerender.partial", PartiallyPrerenderAnimatedContent, bool, false);
649 DECL_GFX_PREF(Live, "layout.animation.prerender.viewport-ratio-limit-x", AnimationPrerenderViewportRatioLimitX, float, 1.125f);
650 DECL_GFX_PREF(Live, "layout.animation.prerender.viewport-ratio-limit-y", AnimationPrerenderViewportRatioLimitY, float, 1.125f);
651 DECL_GFX_PREF(Live, "layout.animation.prerender.absolute-limit-x", AnimationPrerenderAbsoluteLimitX, uint32_t, 4096);
652 DECL_GFX_PREF(Live, "layout.animation.prerender.absolute-limit-y", AnimationPrerenderAbsoluteLimitY, uint32_t, 4096);
654 DECL_GFX_PREF(Live, "layout.css.paint-order.enabled", PaintOrderEnabled, bool, false);
655 DECL_GFX_PREF(Live, "layout.css.scroll-behavior.damping-ratio", ScrollBehaviorDampingRatio, float, 1.0f);
656 DECL_GFX_PREF(Live, "layout.css.scroll-behavior.enabled", ScrollBehaviorEnabled, bool, true);
657 DECL_GFX_PREF(Live, "layout.css.scroll-behavior.spring-constant", ScrollBehaviorSpringConstant, float, 250.0f);
658 DECL_GFX_PREF(Live, "layout.css.scroll-snap.prediction-max-velocity", ScrollSnapPredictionMaxVelocity, int32_t, 2000);
659 DECL_GFX_PREF(Live, "layout.css.scroll-snap.prediction-sensitivity", ScrollSnapPredictionSensitivity, float, 0.750f);
660 DECL_GFX_PREF(Live, "layout.css.scroll-snap.proximity-threshold", ScrollSnapProximityThreshold, int32_t, 200);
661 DECL_GFX_PREF(Live, "layout.css.touch_action.enabled", TouchActionEnabled, bool, false);
663 DECL_GFX_PREF(Live, "layout.display-list.build-twice", LayoutDisplayListBuildTwice, bool, false);
664 DECL_GFX_PREF(Live, "layout.display-list.retain", LayoutRetainDisplayList, bool, true);
665 DECL_GFX_PREF(Live, "layout.display-list.retain.chrome", LayoutRetainDisplayListChrome, bool, false);
666 DECL_GFX_PREF(Live, "layout.display-list.retain.verify", LayoutVerifyRetainDisplayList, bool, false);
667 DECL_GFX_PREF(Live, "layout.display-list.retain.verify.order", LayoutVerifyRetainDisplayListOrder, bool, false);
668 DECL_GFX_PREF(Live, "layout.display-list.rebuild-frame-limit", LayoutRebuildFrameLimit, uint32_t, 500);
669 DECL_GFX_PREF(Live, "layout.display-list.dump", LayoutDumpDisplayList, bool, false);
670 DECL_GFX_PREF(Live, "layout.display-list.dump-content", LayoutDumpDisplayListContent, bool, false);
671 DECL_GFX_PREF(Live, "layout.display-list.dump-parent", LayoutDumpDisplayListParent, bool, false);
672 DECL_GFX_PREF(Live, "layout.display-list.show-rebuild-area", LayoutDisplayListShowArea, bool, false);
674 DECL_GFX_PREF(Once, "layout.simple-event-region-items", SimpleEventRegionItems, bool, true);
675 DECL_GFX_PREF(Once, "layout.less-event-region-items", LessEventRegionItems, bool, true);
677 DECL_GFX_PREF(Live, "layout.event-regions.enabled", LayoutEventRegionsEnabledDoNotUseDirectly, bool, false);
678 DECL_GFX_PREF(Once, "layout.frame_rate", LayoutFrameRate, int32_t, -1);
679 DECL_GFX_PREF(Live, "layout.min-active-layer-size", LayoutMinActiveLayerSize, int, 64);
680 DECL_GFX_PREF(Once, "layout.paint_rects_separately", LayoutPaintRectsSeparately, bool, true);
682 // This and code dependent on it should be removed once containerless scrolling looks stable.
683 DECL_GFX_PREF(Once, "layout.scroll.root-frame-containers", LayoutUseContainersForRootFrames, bool, true);
684 // This pref is to be set by test code only.
685 DECL_GFX_PREF(Live, "layout.scrollbars.always-layerize-track", AlwaysLayerizeScrollbarTrackTestOnly, bool, false);
686 DECL_GFX_PREF(Live, "layout.smaller-painted-layers", LayoutSmallerPaintedLayers, bool, false);
688 DECL_GFX_PREF(Once, "media.hardware-video-decoding.force-enabled",
689 HardwareVideoDecodingForceEnabled, bool, false);
690 #ifdef XP_WIN
691 DECL_GFX_PREF(Live, "media.wmf.dxva.d3d11.enabled", PDMWMFAllowD3D11, bool, true);
692 DECL_GFX_PREF(Live, "media.wmf.dxva.max-videos", PDMWMFMaxDXVAVideos, uint32_t, 8);
693 DECL_GFX_PREF(Live, "media.wmf.use-nv12-format", PDMWMFUseNV12Format, bool, true);
694 DECL_GFX_PREF(Once, "media.wmf.use-sync-texture", PDMWMFUseSyncTexture, bool, true);
695 DECL_GFX_PREF(Live, "media.wmf.low-latency.enabled", PDMWMFLowLatencyEnabled, bool, false);
696 DECL_GFX_PREF(Live, "media.wmf.skip-blacklist", PDMWMFSkipBlacklist, bool, false);
697 DECL_GFX_PREF(Live, "media.wmf.deblacklisting-for-telemetry-in-gpu-process", PDMWMFDeblacklistingForTelemetryInGPUProcess, bool, false);
698 DECL_GFX_PREF(Live, "media.wmf.amd.vp9.enabled", PDMWMFAMDVP9DecoderEnabled, bool, true);
699 DECL_GFX_PREF(Live, "media.wmf.amd.highres.enabled", PDMWMFAMDHighResEnabled, bool, true);
700 DECL_GFX_PREF(Live, "media.wmf.allow-unsupported-resolutions", PDMWMFAllowUnsupportedResolutions, bool, false);
701 #endif
703 // These affect how line scrolls from wheel events will be accelerated.
704 DECL_GFX_PREF(Live, "mousewheel.acceleration.factor", MouseWheelAccelerationFactor, int32_t, -1);
705 DECL_GFX_PREF(Live, "mousewheel.acceleration.start", MouseWheelAccelerationStart, int32_t, -1);
707 // This affects whether events will be routed through APZ or not.
708 DECL_GFX_PREF(Live, "mousewheel.system_scroll_override_on_root_content.enabled",
709 MouseWheelHasRootScrollDeltaOverride, bool, false);
710 DECL_GFX_PREF(Live, "mousewheel.system_scroll_override_on_root_content.horizontal.factor",
711 MouseWheelRootScrollHorizontalFactor, int32_t, 0);
712 DECL_GFX_PREF(Live, "mousewheel.system_scroll_override_on_root_content.vertical.factor",
713 MouseWheelRootScrollVerticalFactor, int32_t, 0);
714 DECL_GFX_PREF(Live, "mousewheel.transaction.ignoremovedelay",MouseWheelIgnoreMoveDelayMs, int32_t, (int32_t)100);
715 DECL_GFX_PREF(Live, "mousewheel.transaction.timeout", MouseWheelTransactionTimeoutMs, int32_t, (int32_t)1500);
717 DECL_GFX_PREF(Live, "nglayout.debug.widget_update_flashing", WidgetUpdateFlashing, bool, false);
719 DECL_GFX_PREF(Once, "slider.snapMultiplier", SliderSnapMultiplier, int32_t, 0);
721 DECL_GFX_PREF(Live, "test.events.async.enabled", TestEventsAsyncEnabled, bool, false);
722 DECL_GFX_PREF(Live, "test.mousescroll", MouseScrollTestingEnabled, bool, false);
724 DECL_GFX_PREF(Live, "toolkit.scrollbox.horizontalScrollDistance", ToolkitHorizontalScrollDistance, int32_t, 5);
725 DECL_GFX_PREF(Live, "toolkit.scrollbox.verticalScrollDistance", ToolkitVerticalScrollDistance, int32_t, 3);
727 DECL_GFX_PREF(Live, "ui.click_hold_context_menus.delay", UiClickHoldContextMenusDelay, int32_t, 500);
729 // WebGL (for pref access from Worker threads)
730 DECL_GFX_PREF(Live, "webgl.1.allow-core-profiles", WebGL1AllowCoreProfile, bool, false);
732 DECL_GFX_PREF(Live, "webgl.all-angle-options", WebGLAllANGLEOptions, bool, false);
733 DECL_GFX_PREF(Live, "webgl.angle.force-d3d11", WebGLANGLEForceD3D11, bool, false);
734 DECL_GFX_PREF(Live, "webgl.angle.try-d3d11", WebGLANGLETryD3D11, bool, false);
735 DECL_GFX_PREF(Live, "webgl.angle.force-warp", WebGLANGLEForceWARP, bool, false);
736 DECL_GFX_PREF(Live, "webgl.bypass-shader-validation", WebGLBypassShaderValidator, bool, true);
737 DECL_GFX_PREF(Live, "webgl.can-lose-context-in-foreground", WebGLCanLoseContextInForeground, bool, true);
738 DECL_GFX_PREF(Live, "webgl.default-no-alpha", WebGLDefaultNoAlpha, bool, false);
739 DECL_GFX_PREF(Live, "webgl.disable-angle", WebGLDisableANGLE, bool, false);
740 DECL_GFX_PREF(Live, "webgl.disable-wgl", WebGLDisableWGL, bool, false);
741 DECL_GFX_PREF(Live, "webgl.disable-extensions", WebGLDisableExtensions, bool, false);
742 DECL_GFX_PREF(Live, "webgl.dxgl.enabled", WebGLDXGLEnabled, bool, false);
743 DECL_GFX_PREF(Live, "webgl.dxgl.needs-finish", WebGLDXGLNeedsFinish, bool, false);
745 DECL_GFX_PREF(Live, "webgl.disable-fail-if-major-performance-caveat",
746 WebGLDisableFailIfMajorPerformanceCaveat, bool, false);
747 DECL_GFX_PREF(Live, "webgl.disable-DOM-blit-uploads",
748 WebGLDisableDOMBlitUploads, bool, false);
750 DECL_GFX_PREF(Live, "webgl.disabled", WebGLDisabled, bool, false);
752 DECL_GFX_PREF(Live, "webgl.enable-draft-extensions", WebGLDraftExtensionsEnabled, bool, false);
753 DECL_GFX_PREF(Live, "webgl.enable-privileged-extensions", WebGLPrivilegedExtensionsEnabled, bool, false);
754 DECL_GFX_PREF(Live, "webgl.enable-surface-texture", WebGLSurfaceTextureEnabled, bool, false);
755 DECL_GFX_PREF(Live, "webgl.enable-webgl2", WebGL2Enabled, bool, true);
756 DECL_GFX_PREF(Live, "webgl.force-enabled", WebGLForceEnabled, bool, false);
757 DECL_GFX_PREF(Once, "webgl.force-layers-readback", WebGLForceLayersReadback, bool, false);
758 DECL_GFX_PREF(Live, "webgl.force-index-validation", WebGLForceIndexValidation, int32_t, 0);
759 DECL_GFX_PREF(Live, "webgl.lose-context-on-memory-pressure", WebGLLoseContextOnMemoryPressure, bool, false);
760 DECL_GFX_PREF(Live, "webgl.max-contexts", WebGLMaxContexts, uint32_t, 32);
761 DECL_GFX_PREF(Live, "webgl.max-contexts-per-principal", WebGLMaxContextsPerPrincipal, uint32_t, 16);
762 DECL_GFX_PREF(Live, "webgl.max-warnings-per-context", WebGLMaxWarningsPerContext, uint32_t, 32);
763 DECL_GFX_PREF(Live, "webgl.min_capability_mode", WebGLMinCapabilityMode, bool, false);
764 DECL_GFX_PREF(Live, "webgl.msaa-force", WebGLForceMSAA, bool, false);
765 DECL_GFX_PREF(Live, "webgl.msaa-samples", WebGLMsaaSamples, uint32_t, 4);
766 DECL_GFX_PREF(Live, "webgl.prefer-16bpp", WebGLPrefer16bpp, bool, false);
767 DECL_GFX_PREF(Live, "webgl.restore-context-when-visible", WebGLRestoreWhenVisible, bool, true);
768 DECL_GFX_PREF(Live, "webgl.allow-immediate-queries", WebGLImmediateQueries, bool, false);
769 DECL_GFX_PREF(Live, "webgl.allow-fb-invalidation", WebGLFBInvalidation, bool, false);
771 DECL_GFX_PREF(Live, "webgl.perf.max-warnings", WebGLMaxPerfWarnings, int32_t, 0);
772 DECL_GFX_PREF(Live, "webgl.perf.max-acceptable-fb-status-invals", WebGLMaxAcceptableFBStatusInvals, int32_t, 0);
773 DECL_GFX_PREF(Live, "webgl.perf.spew-frame-allocs", WebGLSpewFrameAllocs, bool, true);
776 DECL_GFX_PREF(Live, "webgl.webgl2-compat-mode", WebGL2CompatMode, bool, false);
778 DECL_GFX_PREF(Live, "widget.window-transforms.disabled", WindowTransformsDisabled, bool, false);
780 // WARNING:
781 // Please make sure that you've added your new preference to the list above in alphabetical order.
782 // Please do not just append it to the end of the list.
784 public:
785 // Manage the singleton:
786 static gfxPrefs& GetSingleton()
788 return sInstance ? *sInstance : CreateAndInitializeSingleton();
790 static void DestroySingleton();
791 static bool SingletonExists();
793 private:
794 static gfxPrefs& CreateAndInitializeSingleton();
796 static gfxPrefs* sInstance;
797 static bool sInstanceHasBeenDestroyed;
798 static nsTArray<Pref*>* sGfxPrefList;
800 private:
801 // The constructor cannot access GetSingleton(), since sInstance (necessarily)
802 // has not been assigned yet. Follow-up initialization that needs GetSingleton()
803 // must be added to Init().
804 void Init();
806 static bool IsPrefsServiceAvailable();
807 static bool IsParentProcess();
808 // Creating these to avoid having to include Preferences.h in the .h
809 static void PrefAddVarCache(bool*, const char*, bool);
810 static void PrefAddVarCache(int32_t*, const char*, int32_t);
811 static void PrefAddVarCache(uint32_t*, const char*, uint32_t);
812 static void PrefAddVarCache(float*, const char*, float);
813 static void PrefAddVarCache(std::string*, const char*, std::string);
814 static void PrefAddVarCache(AtomicBool*, const char*, bool);
815 static void PrefAddVarCache(AtomicInt32*, const char*, int32_t);
816 static void PrefAddVarCache(AtomicUint32*, const char*, uint32_t);
817 static bool PrefGet(const char*, bool);
818 static int32_t PrefGet(const char*, int32_t);
819 static uint32_t PrefGet(const char*, uint32_t);
820 static float PrefGet(const char*, float);
821 static std::string PrefGet(const char*, std::string);
822 static void PrefSet(const char* aPref, bool aValue);
823 static void PrefSet(const char* aPref, int32_t aValue);
824 static void PrefSet(const char* aPref, uint32_t aValue);
825 static void PrefSet(const char* aPref, float aValue);
826 static void PrefSet(const char* aPref, std::string aValue);
827 static void WatchChanges(const char* aPrefname, Pref* aPref);
828 static void UnwatchChanges(const char* aPrefname, Pref* aPref);
829 // Creating these to avoid having to include PGPU.h in the .h
830 static void CopyPrefValue(const bool* aValue, GfxPrefValue* aOutValue);
831 static void CopyPrefValue(const int32_t* aValue, GfxPrefValue* aOutValue);
832 static void CopyPrefValue(const uint32_t* aValue, GfxPrefValue* aOutValue);
833 static void CopyPrefValue(const float* aValue, GfxPrefValue* aOutValue);
834 static void CopyPrefValue(const std::string* aValue, GfxPrefValue* aOutValue);
835 static void CopyPrefValue(const GfxPrefValue* aValue, bool* aOutValue);
836 static void CopyPrefValue(const GfxPrefValue* aValue, int32_t* aOutValue);
837 static void CopyPrefValue(const GfxPrefValue* aValue, uint32_t* aOutValue);
838 static void CopyPrefValue(const GfxPrefValue* aValue, float* aOutValue);
839 static void CopyPrefValue(const GfxPrefValue* aValue, std::string* aOutValue);
841 static void AssertMainThread();
843 // Some wrapper functions for the DECL_OVERRIDE_PREF prefs' base values, so
844 // that we don't to include all sorts of header files into this gfxPrefs.h
845 // file.
846 static bool OverrideBase_WebRender();
848 gfxPrefs();
849 ~gfxPrefs();
850 gfxPrefs(const gfxPrefs&) = delete;
851 gfxPrefs& operator=(const gfxPrefs&) = delete;
854 #undef DECL_GFX_PREF /* Don't need it outside of this file */
856 #endif /* GFX_PREFS_H */