2017-10-28 01:55:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2017-10-28 02:10:06 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2016-08-04 21:33:42 +03: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 21:33:44 +03:00
|
|
|
_(BrowserTabsRemoteAutostart, bool, false) \
|
2016-08-04 21:33:44 +03:00
|
|
|
_(ContentBackend, BackendType, BackendType::NONE) \
|
2017-03-28 17:35:55 +03:00
|
|
|
_(SoftwareBackend, BackendType, BackendType::NONE) \
|
2016-08-04 21:33:43 +03:00
|
|
|
_(TileSize, IntSize, IntSize(-1, -1)) \
|
2016-08-04 21:33:44 +03:00
|
|
|
_(UseXRender, bool, false) \
|
2016-08-24 21:02:00 +03:00
|
|
|
_(OffscreenFormat, gfxImageFormat, mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32) \
|
2016-08-24 21:03:00 +03:00
|
|
|
_(RequiresAcceleratedGLContextForCompositorOGL, bool, false) \
|
2016-08-25 06:48:35 +03:00
|
|
|
_(CanUseHardwareVideoDecoding, bool, false) \
|
2016-11-02 23:57:18 +03:00
|
|
|
_(PDMWMFDisableD3D11Dlls, nsCString, nsCString()) \
|
|
|
|
_(PDMWMFDisableD3D9Dlls, nsCString, nsCString()) \
|
2016-11-15 01:13:40 +03:00
|
|
|
_(DXInterop2Blocked, bool, false) \
|
2018-05-17 06:07:20 +03:00
|
|
|
_(DXNV12Blocked, bool, false) \
|
2017-02-07 06:22:36 +03:00
|
|
|
_(UseWebRender, bool, false) \
|
2017-03-29 17:14:19 +03:00
|
|
|
_(UseWebRenderANGLE, bool, false) \
|
2018-03-29 05:23:31 +03:00
|
|
|
_(UseWebRenderDCompWin, bool, false) \
|
2017-11-24 14:58:24 +03:00
|
|
|
_(UseWebRenderProgramBinary, bool, false) \
|
2018-05-31 09:07:34 +03:00
|
|
|
_(UseWebRenderProgramBinaryDisk, bool, false) \
|
2017-08-23 13:00:37 +03:00
|
|
|
_(WebRenderDebugFlags, int32_t, 0) \
|
2017-03-29 17:14:19 +03:00
|
|
|
_(ScreenDepth, int32_t, 0) \
|
2017-12-16 18:13:30 +03:00
|
|
|
_(GREDirectory, nsString, nsString()) \
|
2018-05-31 09:07:34 +03:00
|
|
|
_(ProfDirectory, nsString, nsString()) \
|
2017-06-06 23:18:00 +03:00
|
|
|
_(UseOMTP, bool, false) \
|
2017-07-25 21:02:36 +03:00
|
|
|
_(AllowD3D11KeyedMutex, bool, false) \
|
2016-08-24 21:03:00 +03:00
|
|
|
|
2016-08-04 21:33:42 +03: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
|
|
|
|
// this. Its function is similar to gfxPrefs, except rather than hold
|
|
|
|
// 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-28 00:04:17 +03: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 06:13:31 +03:00
|
|
|
static void Initialize();
|
2016-08-04 21:33:42 +03: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;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
size_t mIndex;
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
static StaticAutoPtr<gfxVars> sInstance;
|
|
|
|
static StaticAutoPtr<nsTArray<VarBase*>> sVarList;
|
|
|
|
|
|
|
|
template <typename T, T Default()>
|
|
|
|
class VarImpl final : public VarBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VarImpl()
|
|
|
|
: mValue(Default())
|
|
|
|
{}
|
|
|
|
void SetValue(const GfxVarValue& aValue) override {
|
|
|
|
aValue.get(&mValue);
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
T mValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define GFX_VAR_DECL(CxxName, DataType, DefaultValue) \
|
|
|
|
private: \
|
|
|
|
static DataType Get##CxxName##Default() { \
|
|
|
|
return DefaultValue; \
|
|
|
|
} \
|
|
|
|
VarImpl<DataType, Get##CxxName##Default> mVar##CxxName; \
|
|
|
|
public: \
|
|
|
|
static const DataType& CxxName() { \
|
|
|
|
return sInstance->mVar##CxxName.Get(); \
|
|
|
|
} \
|
2018-02-16 17:50:40 +03:00
|
|
|
static DataType Get##CxxName##OrDefault() { \
|
|
|
|
if (!sInstance) { \
|
|
|
|
return DefaultValue; \
|
|
|
|
} \
|
|
|
|
return sInstance->mVar##CxxName.Get(); \
|
|
|
|
} \
|
2016-08-04 21:33:42 +03:00
|
|
|
static void Set##CxxName(const DataType& aValue) { \
|
|
|
|
if (sInstance->mVar##CxxName.Set(aValue)) { \
|
|
|
|
sInstance->NotifyReceivers(&sInstance->mVar##CxxName); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|