Bug 1559285 - Add webgl.default-antialias. r=mccr8,lsalzman

Default to false on Android, matching existing behavior.

Differential Revision: https://phabricator.services.mozilla.com/D34985

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jeff Gilbert 2019-06-14 19:29:15 +00:00
Родитель 81848f2228
Коммит f16e991a1d
4 изменённых файлов: 28 добавлений и 16 удалений

Просмотреть файл

@ -98,7 +98,8 @@ using namespace mozilla::layers;
WebGLContextOptions::WebGLContextOptions() {
// Set default alpha state based on preference.
if (StaticPrefs::WebGLDefaultNoAlpha()) alpha = false;
alpha = !StaticPrefs::WebGLDefaultNoAlpha();
antialias = StaticPrefs::WebGLDefaultAntialias();
}
bool WebGLContextOptions::operator==(const WebGLContextOptions& r) const {
@ -349,7 +350,6 @@ WebGLContext::SetContextOptions(JSContext* cx, JS::Handle<JS::Value> options,
newOpts.stencil = attributes.mStencil;
newOpts.depth = attributes.mDepth;
newOpts.premultipliedAlpha = attributes.mPremultipliedAlpha;
newOpts.antialias = attributes.mAntialias;
newOpts.preserveDrawingBuffer = attributes.mPreserveDrawingBuffer;
newOpts.failIfMajorPerformanceCaveat =
attributes.mFailIfMajorPerformanceCaveat;
@ -358,13 +358,16 @@ WebGLContext::SetContextOptions(JSContext* cx, JS::Handle<JS::Value> options,
if (attributes.mAlpha.WasPassed()) {
newOpts.alpha = attributes.mAlpha.Value();
}
if (attributes.mAntialias.WasPassed()) {
newOpts.antialias = attributes.mAntialias.Value();
}
// Don't do antialiasing if we've disabled MSAA.
if (!StaticPrefs::MSAALevel()) {
if (!mMsaaSamples) {
newOpts.antialias = false;
}
if (!StaticPrefs::WebGLForceMSAA()) {
if (newOpts.antialias && !StaticPrefs::WebGLForceMSAA()) {
const nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
nsCString blocklistId;
@ -1272,7 +1275,7 @@ void WebGLContext::GetContextAttributes(
result.mAlpha.Construct(mOptions.alpha);
result.mDepth = mOptions.depth;
result.mStencil = mOptions.stencil;
result.mAntialias = mOptions.antialias;
result.mAntialias.Construct(mOptions.antialias);
result.mPremultipliedAlpha = mOptions.premultipliedAlpha;
result.mPreserveDrawingBuffer = mOptions.preserveDrawingBuffer;
result.mFailIfMajorPerformanceCaveat = mOptions.failIfMajorPerformanceCaveat;

Просмотреть файл

@ -37,13 +37,15 @@ typedef unsigned long long GLuint64EXT;
enum WebGLPowerPreference { "default", "low-power", "high-performance" };
dictionary WebGLContextAttributes {
// boolean alpha = true;
// We deviate from the spec here.
// If alpha isn't specified, we rely on a pref ("webgl.default-no-alpha")
GLboolean alpha;
// We deviate from the spec for alpha and antialias:
// * alpha: Historically, we might use rgb565 instead of rgb(x)8, for
// memory bandwidth optimization.
// * antialias: On Android, DPI is high and mem-bandwidth is low, so we
// default to antialias:false if it's not set.
GLboolean alpha; // = true; // Default is controlled by webgl.default-no-alpha.
GLboolean depth = true;
GLboolean stencil = false;
GLboolean antialias = true;
GLboolean antialias; // = true; // Default is controlled by webgl.default-antialias.
GLboolean premultipliedAlpha = true;
GLboolean preserveDrawingBuffer = false;
GLboolean failIfMajorPerformanceCaveat = false;

Просмотреть файл

@ -7228,6 +7228,19 @@ VARCACHE_PREF(
RelaxedAtomicBool, true
)
#ifdef MOZ_WIDGET_ANDROID
# define PREF_VALUE false
#else
# define PREF_VALUE true
#endif
VARCACHE_PREF(
Live,
"webgl.default-antialias",
WebGLDefaultAntialias,
RelaxedAtomicBool, PREF_VALUE
)
#undef PREF_VALUE
VARCACHE_PREF(
Live,
"webgl.default-low-power",

Просмотреть файл

@ -4632,12 +4632,6 @@ pref("image.webp.enabled", true);
pref("canvas.image.cache.limit", 0);
// WebGL prefs
#ifdef ANDROID
// Disable MSAA on mobile.
pref("gl.msaa-level", 0);
#else
pref("gl.msaa-level", 2);
#endif
pref("gl.require-hardware", false);
#ifdef XP_MACOSX
pref("gl.multithreaded", true);