2017-10-27 22:55:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2017-10-27 23:10:06 +00:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2016-08-04 18:33:42 +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/. */
|
|
|
|
#ifndef mozilla_gfx_config_gfxVars_h
|
|
|
|
#define mozilla_gfx_config_gfxVars_h
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "mozilla/Assertions.h"
|
|
|
|
#include "mozilla/StaticPtr.h"
|
|
|
|
#include "mozilla/gfx/GraphicsMessages.h"
|
|
|
|
#include "mozilla/gfx/Point.h"
|
|
|
|
#include "mozilla/gfx/Types.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsXULAppAPI.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
class gfxVarReceiver;
|
|
|
|
|
|
|
|
// Generator for graphics vars.
|
|
|
|
#define GFX_VARS_LIST(_) \
|
|
|
|
/* C++ Name, Data Type, Default Value */ \
|
2016-08-04 18:33:44 +00:00
|
|
|
_(BrowserTabsRemoteAutostart, bool, false) \
|
2016-08-04 18:33:44 +00:00
|
|
|
_(ContentBackend, BackendType, BackendType::NONE) \
|
2017-03-28 14:35:55 +00:00
|
|
|
_(SoftwareBackend, BackendType, BackendType::NONE) \
|
2016-08-04 18:33:43 +00:00
|
|
|
_(TileSize, IntSize, IntSize(-1, -1)) \
|
2016-08-04 18:33:44 +00:00
|
|
|
_(UseXRender, bool, false) \
|
2016-08-24 18:02:00 +00:00
|
|
|
_(OffscreenFormat, gfxImageFormat, \
|
|
|
|
mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32) \
|
2016-08-24 18:03:00 +00:00
|
|
|
_(RequiresAcceleratedGLContextForCompositorOGL, bool, false) \
|
2016-08-25 03:48:35 +00:00
|
|
|
_(CanUseHardwareVideoDecoding, bool, false) \
|
2016-11-02 20:57:18 +00:00
|
|
|
_(PDMWMFDisableD3D11Dlls, nsCString, nsCString()) \
|
|
|
|
_(PDMWMFDisableD3D9Dlls, nsCString, nsCString()) \
|
2016-11-14 22:13:40 +00:00
|
|
|
_(DXInterop2Blocked, bool, false) \
|
2018-05-17 03:07:20 +00:00
|
|
|
_(DXNV12Blocked, bool, false) \
|
2018-10-11 07:32:35 +00:00
|
|
|
_(DXP010Blocked, bool, false) \
|
|
|
|
_(DXP016Blocked, bool, false) \
|
2017-02-07 03:22:36 +00:00
|
|
|
_(UseWebRender, bool, false) \
|
2017-03-29 14:14:19 +00:00
|
|
|
_(UseWebRenderANGLE, bool, false) \
|
2019-07-19 09:26:03 +00:00
|
|
|
_(UseWebRenderFlipSequentialWin, bool, false) \
|
2018-03-29 02:23:31 +00:00
|
|
|
_(UseWebRenderDCompWin, bool, false) \
|
2019-07-19 09:26:03 +00:00
|
|
|
_(UseWebRenderTripleBufferingWin, bool, false) \
|
2019-12-10 19:16:13 +00:00
|
|
|
_(UseWebRenderCompositor, bool, false) \
|
2018-05-31 06:07:34 +00:00
|
|
|
_(UseWebRenderProgramBinaryDisk, bool, false) \
|
2020-04-21 10:32:15 +00:00
|
|
|
_(UseWebRenderOptimizedShaders, bool, false) \
|
2020-02-05 09:51:14 +00:00
|
|
|
_(UseWebRenderMultithreading, bool, false) \
|
2020-06-08 21:05:03 +00:00
|
|
|
_(UseWebRenderScissoredCacheClears, bool, true) \
|
2019-12-17 05:05:30 +00:00
|
|
|
_(WebRenderMaxPartialPresentRects, int32_t, 0) \
|
2017-08-23 10:00:37 +00:00
|
|
|
_(WebRenderDebugFlags, int32_t, 0) \
|
2020-02-20 03:45:17 +00:00
|
|
|
_(WebRenderBatchingLookback, int32_t, 10) \
|
2020-03-13 18:18:14 +00:00
|
|
|
_(UseSoftwareWebRender, bool, false) \
|
2017-03-29 14:14:19 +00:00
|
|
|
_(ScreenDepth, int32_t, 0) \
|
2017-12-16 15:13:30 +00:00
|
|
|
_(GREDirectory, nsString, nsString()) \
|
2018-05-31 06:07:34 +00:00
|
|
|
_(ProfDirectory, nsString, nsString()) \
|
2017-06-06 20:18:00 +00:00
|
|
|
_(UseOMTP, bool, false) \
|
2017-07-25 18:02:36 +00:00
|
|
|
_(AllowD3D11KeyedMutex, bool, false) \
|
2019-05-26 14:30:57 +00:00
|
|
|
_(SystemTextQuality, int32_t, 5 /* CLEARTYPE_QUALITY */) \
|
2018-11-28 20:44:27 +00:00
|
|
|
_(LayersWindowRecordingPath, nsCString, nsCString()) \
|
2019-07-09 06:37:45 +00:00
|
|
|
_(RemoteCanvasEnabled, bool, false) \
|
2019-08-09 18:57:35 +00:00
|
|
|
_(UseDoubleBufferingWithCompositor, bool, false) \
|
2020-01-10 16:57:55 +00:00
|
|
|
_(UseGLSwizzle, bool, true) \
|
2020-05-16 03:09:57 +00:00
|
|
|
_(ForceSubpixelAAWherePossible, bool, false) \
|
2020-06-25 17:22:20 +00:00
|
|
|
_(DwmCompositionEnabled, bool, true) \
|
2020-07-02 13:43:19 +00:00
|
|
|
_(FxREmbedded, bool, false) \
|
2020-07-22 18:58:11 +00:00
|
|
|
_(UseAHardwareBufferContent, bool, false) \
|
|
|
|
_(UseEGL, bool, false)
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2016-08-04 18:33:42 +00:00
|
|
|
/* Add new entries above this line. */
|
|
|
|
|
|
|
|
// Some graphics settings are computed on the UI process and must be
|
|
|
|
// communicated to content and GPU processes. gfxVars helps facilitate
|
2019-05-26 14:31:53 +00:00
|
|
|
// this. Its function is similar to StaticPrefs, except rather than hold
|
2016-08-04 18:33:42 +00:00
|
|
|
// user preferences, it holds dynamically computed values.
|
|
|
|
//
|
|
|
|
// Each variable in GFX_VARS_LIST exposes the following static methods:
|
|
|
|
//
|
|
|
|
// const DataType& CxxName();
|
|
|
|
// void SetCxxName(const DataType& aValue);
|
|
|
|
//
|
|
|
|
// Note that the setter may only be called in the UI process; a gfxVar must be
|
|
|
|
// a variable that is determined in the UI process and pushed to child
|
|
|
|
// processes.
|
|
|
|
class gfxVars final {
|
|
|
|
public:
|
2017-06-27 21:04:17 +00:00
|
|
|
// These values will be used during the Initialize() call if set. Any
|
|
|
|
// updates that come before initialization will get added to this array.
|
|
|
|
static void SetValuesForInitialize(
|
|
|
|
const nsTArray<GfxVarUpdate>& aInitUpdates);
|
|
|
|
|
2017-04-14 03:13:31 +00:00
|
|
|
static void Initialize();
|
2016-08-04 18:33:42 +00:00
|
|
|
static void Shutdown();
|
|
|
|
|
|
|
|
static void ApplyUpdate(const GfxVarUpdate& aUpdate);
|
|
|
|
static void AddReceiver(gfxVarReceiver* aReceiver);
|
|
|
|
static void RemoveReceiver(gfxVarReceiver* aReceiver);
|
|
|
|
|
|
|
|
// Return a list of updates for all variables with non-default values.
|
|
|
|
static nsTArray<GfxVarUpdate> FetchNonDefaultVars();
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Each variable must expose Set and Get methods for IPDL.
|
|
|
|
class VarBase {
|
|
|
|
public:
|
|
|
|
VarBase();
|
|
|
|
virtual void SetValue(const GfxVarValue& aValue) = 0;
|
|
|
|
virtual void GetValue(GfxVarValue* aOutValue) = 0;
|
|
|
|
virtual bool HasDefaultValue() const = 0;
|
|
|
|
size_t Index() const { return mIndex; }
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2016-08-04 18:33:42 +00:00
|
|
|
private:
|
|
|
|
size_t mIndex;
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
static StaticAutoPtr<gfxVars> sInstance;
|
|
|
|
static StaticAutoPtr<nsTArray<VarBase*>> sVarList;
|
|
|
|
|
2020-05-15 00:12:58 +00:00
|
|
|
template <typename T, T Default(), T GetFrom(const GfxVarValue& aValue)>
|
2016-08-04 18:33:42 +00:00
|
|
|
class VarImpl final : public VarBase {
|
|
|
|
public:
|
|
|
|
VarImpl() : mValue(Default()) {}
|
|
|
|
void SetValue(const GfxVarValue& aValue) override {
|
2020-05-15 00:12:58 +00:00
|
|
|
mValue = GetFrom(aValue);
|
2018-09-13 18:59:27 +00:00
|
|
|
if (mListener) {
|
|
|
|
mListener();
|
|
|
|
}
|
2016-08-04 18:33:42 +00:00
|
|
|
}
|
|
|
|
void GetValue(GfxVarValue* aOutValue) override {
|
|
|
|
*aOutValue = GfxVarValue(mValue);
|
|
|
|
}
|
|
|
|
bool HasDefaultValue() const override { return mValue == Default(); }
|
|
|
|
const T& Get() const { return mValue; }
|
|
|
|
// Return true if the value changed, false otherwise.
|
|
|
|
bool Set(const T& aValue) {
|
|
|
|
MOZ_ASSERT(XRE_IsParentProcess());
|
|
|
|
if (mValue == aValue) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mValue = aValue;
|
2018-09-13 18:59:27 +00:00
|
|
|
if (mListener) {
|
|
|
|
mListener();
|
|
|
|
}
|
2016-08-04 18:33:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-09-13 18:59:27 +00:00
|
|
|
|
|
|
|
void SetListener(const std::function<void()>& aListener) {
|
|
|
|
mListener = aListener;
|
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2016-08-04 18:33:42 +00:00
|
|
|
private:
|
|
|
|
T mValue;
|
2018-09-13 18:59:27 +00:00
|
|
|
std::function<void()> mListener;
|
2016-08-04 18:33:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define GFX_VAR_DECL(CxxName, DataType, DefaultValue) \
|
|
|
|
private: \
|
|
|
|
static DataType Get##CxxName##Default() { return DefaultValue; } \
|
2020-05-15 00:12:58 +00:00
|
|
|
static DataType Get##CxxName##From(const GfxVarValue& aValue) { \
|
|
|
|
return aValue.get_##DataType(); \
|
|
|
|
} \
|
|
|
|
VarImpl<DataType, Get##CxxName##Default, Get##CxxName##From> mVar##CxxName; \
|
2018-11-30 10:46:48 +00:00
|
|
|
\
|
2016-08-04 18:33:42 +00:00
|
|
|
public: \
|
|
|
|
static const DataType& CxxName() { return sInstance->mVar##CxxName.Get(); } \
|
2018-02-16 14:50:40 +00:00
|
|
|
static DataType Get##CxxName##OrDefault() { \
|
|
|
|
if (!sInstance) { \
|
|
|
|
return DefaultValue; \
|
|
|
|
} \
|
|
|
|
return sInstance->mVar##CxxName.Get(); \
|
|
|
|
} \
|
2016-08-04 18:33:42 +00:00
|
|
|
static void Set##CxxName(const DataType& aValue) { \
|
|
|
|
if (sInstance->mVar##CxxName.Set(aValue)) { \
|
|
|
|
sInstance->NotifyReceivers(&sInstance->mVar##CxxName); \
|
2018-09-13 18:59:27 +00:00
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void Set##CxxName##Listener(const std::function<void()>& aListener) { \
|
|
|
|
sInstance->mVar##CxxName.SetListener(aListener); \
|
2016-08-04 18:33:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GFX_VARS_LIST(GFX_VAR_DECL)
|
|
|
|
#undef GFX_VAR_DECL
|
|
|
|
|
|
|
|
private:
|
|
|
|
gfxVars();
|
|
|
|
|
|
|
|
void NotifyReceivers(VarBase* aVar);
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsTArray<gfxVarReceiver*> mReceivers;
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef GFX_VARS_LIST
|
|
|
|
|
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_gfx_config_gfxVars_h
|