зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1771374 - Use {bool, T} instead of Maybe<T> for now. r=gfx-reviewers,lsalzman
`Maybe` isn't is_trivially_copyable, and std::optional isn't either on the old libstdc++ we use from gcc7 still. I'm working on more robust approach to serialization but that's beyond the scope of this bug. Differential Revision: https://phabricator.services.mozilla.com/D151421
This commit is contained in:
Родитель
0bd05e8c5c
Коммит
5702c0640c
|
@ -897,9 +897,10 @@ ClientWebGLContext::SetContextOptions(JSContext* cx,
|
|||
if (attributes.mAntialias.WasPassed()) {
|
||||
newOpts.antialias = attributes.mAntialias.Value();
|
||||
}
|
||||
|
||||
newOpts.ignoreColorSpace = true;
|
||||
if (attributes.mColorSpace.WasPassed()) {
|
||||
newOpts.colorSpace = Some(attributes.mColorSpace.Value());
|
||||
newOpts.ignoreColorSpace = false;
|
||||
newOpts.colorSpace = attributes.mColorSpace.Value();
|
||||
}
|
||||
|
||||
// Don't do antialiasing if we've disabled MSAA.
|
||||
|
|
|
@ -106,21 +106,6 @@ WebGLContextOptions::WebGLContextOptions() {
|
|||
antialias = StaticPrefs::webgl_default_antialias();
|
||||
}
|
||||
|
||||
bool WebGLContextOptions::operator==(const WebGLContextOptions& r) const {
|
||||
bool eq = true;
|
||||
eq &= (alpha == r.alpha);
|
||||
eq &= (depth == r.depth);
|
||||
eq &= (stencil == r.stencil);
|
||||
eq &= (premultipliedAlpha == r.premultipliedAlpha);
|
||||
eq &= (antialias == r.antialias);
|
||||
eq &= (preserveDrawingBuffer == r.preserveDrawingBuffer);
|
||||
eq &= (failIfMajorPerformanceCaveat == r.failIfMajorPerformanceCaveat);
|
||||
eq &= (xrCompatible == r.xrCompatible);
|
||||
eq &= (powerPreference == r.powerPreference);
|
||||
eq &= (colorSpace == r.colorSpace);
|
||||
return eq;
|
||||
}
|
||||
|
||||
StaticMutex WebGLContext::sLruMutex;
|
||||
std::list<WebGLContext*> WebGLContext::sLru;
|
||||
|
||||
|
@ -913,8 +898,8 @@ inline gfx::ColorSpace2 ToColorSpace2(const WebGLContextOptions& options) {
|
|||
if (StaticPrefs::gfx_color_management_native_srgb()) {
|
||||
ret = gfx::ColorSpace2::SRGB;
|
||||
}
|
||||
if (options.colorSpace) {
|
||||
ret = gfx::ToColorSpace2(*options.colorSpace);
|
||||
if (!options.ignoreColorSpace) {
|
||||
ret = gfx::ToColorSpace2(options.colorSpace);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -249,9 +249,7 @@ struct ParamTraits<mozilla::WebGLContextOptions> final
|
|||
static bool Validate(const T& val) {
|
||||
bool ok = true;
|
||||
ok &= ValidateParam(val.powerPreference);
|
||||
if (val.colorSpace) {
|
||||
ok &= ValidateParam(*val.colorSpace);
|
||||
}
|
||||
ok &= ValidateParam(val.colorSpace);
|
||||
return ok;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
@ -348,28 +349,57 @@ struct FloatOrInt final // For TexParameter[fi] and friends.
|
|||
explicit FloatOrInt(GLfloat x) : isFloat(true), f(x), i(roundf(x)) {}
|
||||
};
|
||||
|
||||
struct WebGLContextOptions {
|
||||
struct WebGLContextOptions final {
|
||||
bool alpha = true;
|
||||
bool depth = true;
|
||||
bool stencil = false;
|
||||
bool premultipliedAlpha = true;
|
||||
|
||||
bool antialias = true;
|
||||
bool preserveDrawingBuffer = false;
|
||||
bool failIfMajorPerformanceCaveat = false;
|
||||
bool xrCompatible = false;
|
||||
|
||||
dom::WebGLPowerPreference powerPreference =
|
||||
dom::WebGLPowerPreference::Default;
|
||||
Maybe<dom::PredefinedColorSpace> colorSpace;
|
||||
bool ignoreColorSpace = true;
|
||||
dom::PredefinedColorSpace colorSpace = dom::PredefinedColorSpace::Srgb;
|
||||
bool shouldResistFingerprinting = true;
|
||||
|
||||
bool enableDebugRendererInfo = false;
|
||||
|
||||
// -
|
||||
|
||||
WebGLContextOptions();
|
||||
WebGLContextOptions(const WebGLContextOptions&) = default;
|
||||
|
||||
bool operator==(const WebGLContextOptions&) const;
|
||||
bool operator!=(const WebGLContextOptions& rhs) const {
|
||||
return !(*this == rhs);
|
||||
auto Fields() const {
|
||||
// clang-format off
|
||||
return std::tie(
|
||||
alpha,
|
||||
depth,
|
||||
stencil,
|
||||
premultipliedAlpha,
|
||||
|
||||
antialias,
|
||||
preserveDrawingBuffer,
|
||||
failIfMajorPerformanceCaveat,
|
||||
xrCompatible,
|
||||
|
||||
powerPreference,
|
||||
ignoreColorSpace,
|
||||
colorSpace,
|
||||
shouldResistFingerprinting,
|
||||
|
||||
enableDebugRendererInfo);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
using Self = WebGLContextOptions;
|
||||
friend bool operator==(const Self& a, const Self& b) {
|
||||
return a.Fields() == b.Fields();
|
||||
}
|
||||
friend bool operator!=(const Self& a, const Self& b) { return !(a == b); }
|
||||
};
|
||||
|
||||
namespace gfx {
|
||||
|
|
Загрузка…
Ссылка в новой задаче