2016-04-29 07:52:54 +03:00
|
|
|
/* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set sts=2 ts=8 sw=2 tw=99 et: */
|
|
|
|
/* 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_gfxFeature_h
|
|
|
|
#define mozilla_gfx_config_gfxFeature_h
|
|
|
|
|
2016-11-28 19:03:53 +03:00
|
|
|
#include <functional>
|
2016-04-29 07:52:54 +03:00
|
|
|
#include <stdint.h>
|
|
|
|
#include "gfxTelemetry.h"
|
|
|
|
#include "mozilla/Assertions.h"
|
2016-06-03 21:54:56 +03:00
|
|
|
#include "nsString.h"
|
2016-04-29 07:52:54 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
#define GFX_FEATURE_MAP(_) \
|
|
|
|
/* Name, Type, Description */ \
|
|
|
|
_(HW_COMPOSITING, Feature, "Compositing") \
|
2016-04-29 07:52:55 +03:00
|
|
|
_(D3D11_COMPOSITING, Feature, "Direct3D11 Compositing") \
|
2016-06-20 19:29:47 +03:00
|
|
|
_(OPENGL_COMPOSITING, Feature, "OpenGL Compositing") \
|
2016-04-29 07:52:56 +03:00
|
|
|
_(DIRECT2D, Feature, "Direct2D") \
|
2016-08-24 01:18:55 +03:00
|
|
|
_(D3D11_HW_ANGLE, Feature, "Direct3D11 hardware ANGLE") \
|
|
|
|
_(DIRECT_DRAW, Feature, "DirectDraw") \
|
2016-06-11 05:27:24 +03:00
|
|
|
_(GPU_PROCESS, Feature, "GPU Process") \
|
2017-02-09 09:33:54 +03:00
|
|
|
_(WEBRENDER, Feature, "WebRender") \
|
2017-06-06 23:18:00 +03:00
|
|
|
_(OMTP, Feature, "Off Main Thread Painting") \
|
2017-06-24 00:23:12 +03:00
|
|
|
_(ADVANCED_LAYERS, Feature, "Advanced Layers") \
|
2016-04-29 07:52:54 +03:00
|
|
|
/* Add new entries above this comment */
|
|
|
|
|
|
|
|
enum class Feature : uint32_t {
|
|
|
|
#define MAKE_ENUM(name, type, desc) name,
|
|
|
|
GFX_FEATURE_MAP(MAKE_ENUM)
|
|
|
|
#undef MAKE_ENUM
|
|
|
|
NumValues
|
|
|
|
};
|
|
|
|
|
|
|
|
class FeatureState
|
|
|
|
{
|
2016-04-29 07:52:55 +03:00
|
|
|
friend class gfxConfig;
|
|
|
|
|
2016-04-29 07:52:54 +03:00
|
|
|
public:
|
2016-04-29 07:52:55 +03:00
|
|
|
bool IsEnabled() const;
|
2016-04-29 07:52:54 +03:00
|
|
|
FeatureStatus GetValue() const;
|
|
|
|
|
|
|
|
void EnableByDefault();
|
2016-06-03 21:54:56 +03:00
|
|
|
void DisableByDefault(FeatureStatus aStatus, const char* aMessage, const nsACString& aFailureId);
|
2016-04-29 07:52:55 +03:00
|
|
|
bool SetDefault(bool aEnable, FeatureStatus aDisableStatus, const char* aDisableMessage);
|
|
|
|
bool InitOrUpdate(bool aEnable,
|
|
|
|
FeatureStatus aDisableStatus,
|
|
|
|
const char* aMessage);
|
2016-04-29 07:52:56 +03:00
|
|
|
void SetDefaultFromPref(const char* aPrefName,
|
|
|
|
bool aIsEnablePref,
|
|
|
|
bool aDefaultValue);
|
2016-04-29 07:52:55 +03:00
|
|
|
void UserEnable(const char* aMessage);
|
|
|
|
void UserForceEnable(const char* aMessage);
|
2016-06-03 21:54:56 +03:00
|
|
|
void UserDisable(const char* aMessage, const nsACString& aFailureId);
|
|
|
|
void Disable(FeatureStatus aStatus, const char* aMessage, const nsACString& aFailureId);
|
|
|
|
void ForceDisable(FeatureStatus aStatus, const char* aMessage, const nsACString& aFailureId) {
|
|
|
|
SetFailed(aStatus, aMessage, aFailureId);
|
2016-04-29 07:52:55 +03:00
|
|
|
}
|
2016-06-03 21:54:56 +03:00
|
|
|
void SetFailed(FeatureStatus aStatus, const char* aMessage, const nsACString& aFailureId);
|
|
|
|
bool MaybeSetFailed(bool aEnable, FeatureStatus aStatus, const char* aMessage, const nsACString& aFailureId);
|
|
|
|
bool MaybeSetFailed(FeatureStatus aStatus, const char* aMessage, const nsACString& aFailureId);
|
2016-04-29 07:52:55 +03:00
|
|
|
|
2016-04-29 07:52:56 +03:00
|
|
|
// aType is "base", "user", "env", or "runtime".
|
|
|
|
// aMessage may be null.
|
2016-11-28 19:03:53 +03:00
|
|
|
typedef std::function<void(const char* aType,
|
|
|
|
FeatureStatus aStatus,
|
|
|
|
const char* aMessage)> StatusIterCallback;
|
2016-04-29 07:52:56 +03:00
|
|
|
void ForEachStatusChange(const StatusIterCallback& aCallback) const;
|
|
|
|
|
2016-08-21 06:59:11 +03:00
|
|
|
const char* GetFailureMessage() const;
|
|
|
|
const nsCString& GetFailureId() const;
|
|
|
|
|
|
|
|
bool DisabledByDefault() const;
|
2016-06-03 21:54:56 +03:00
|
|
|
|
2016-04-29 07:52:55 +03:00
|
|
|
private:
|
2016-04-29 07:52:54 +03:00
|
|
|
void SetUser(FeatureStatus aStatus, const char* aMessage);
|
2016-04-29 07:52:55 +03:00
|
|
|
void SetEnvironment(FeatureStatus aStatus, const char* aMessage);
|
2016-04-29 07:52:54 +03:00
|
|
|
void SetRuntime(FeatureStatus aStatus, const char* aMessage);
|
|
|
|
bool IsForcedOnByUser() const;
|
2016-04-29 07:52:55 +03:00
|
|
|
const char* GetRuntimeMessage() const;
|
2016-04-29 07:52:55 +03:00
|
|
|
bool IsInitialized() const {
|
2016-04-29 07:52:56 +03:00
|
|
|
return mDefault.IsInitialized();
|
2016-04-29 07:52:55 +03:00
|
|
|
}
|
2016-04-29 07:52:54 +03:00
|
|
|
|
|
|
|
void AssertInitialized() const {
|
2016-04-29 07:52:55 +03:00
|
|
|
MOZ_ASSERT(IsInitialized());
|
2016-04-29 07:52:54 +03:00
|
|
|
}
|
|
|
|
|
2016-08-21 06:59:11 +03:00
|
|
|
// Clear all state.
|
|
|
|
void Reset();
|
|
|
|
|
2016-04-29 07:52:54 +03:00
|
|
|
private:
|
2016-06-03 21:54:56 +03:00
|
|
|
void SetFailureId(const nsACString& aFailureId);
|
|
|
|
|
2016-04-29 07:52:54 +03:00
|
|
|
struct Instance {
|
|
|
|
char mMessage[64];
|
|
|
|
FeatureStatus mStatus;
|
|
|
|
|
|
|
|
void Set(FeatureStatus aStatus, const char* aMessage = nullptr);
|
2016-04-29 07:52:56 +03:00
|
|
|
bool IsInitialized() const {
|
|
|
|
return mStatus != FeatureStatus::Unused;
|
|
|
|
}
|
|
|
|
const char* MessageOrNull() const {
|
|
|
|
return mMessage[0] != '\0' ? mMessage : nullptr;
|
|
|
|
}
|
|
|
|
const char* Message() const {
|
|
|
|
MOZ_ASSERT(MessageOrNull());
|
|
|
|
return mMessage;
|
|
|
|
}
|
2016-04-29 07:52:54 +03:00
|
|
|
};
|
|
|
|
|
2016-04-29 07:52:55 +03:00
|
|
|
// The default state is the state we decide on startup, based on the operating
|
|
|
|
// system or a base preference.
|
2016-04-29 07:52:54 +03:00
|
|
|
//
|
|
|
|
// The user state factors in any changes to preferences that the user made.
|
|
|
|
//
|
2016-04-29 07:52:55 +03:00
|
|
|
// The environment state factors in any additional decisions made, such as
|
|
|
|
// availability or blacklisting.
|
|
|
|
//
|
2016-04-29 07:52:54 +03:00
|
|
|
// The runtime state factors in any problems discovered at runtime.
|
|
|
|
Instance mDefault;
|
|
|
|
Instance mUser;
|
2016-04-29 07:52:55 +03:00
|
|
|
Instance mEnvironment;
|
2016-04-29 07:52:54 +03:00
|
|
|
Instance mRuntime;
|
2016-06-03 21:54:56 +03:00
|
|
|
|
|
|
|
// Store the first reported failureId for now but we might want to track this
|
|
|
|
// by instance later if we need a specific breakdown.
|
|
|
|
nsCString mFailureId;
|
2016-04-29 07:52:54 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_gfx_config_gfxFeature_h
|