From 9c0d507b0936665fcbf55fe06b360de8e1bc8e81 Mon Sep 17 00:00:00 2001 From: Mike Perry Date: Fri, 19 Jun 2015 20:20:00 -0700 Subject: [PATCH] Bug 16005: Relax minimal mode. Use min values from a 2013 Moto E and a 2009 laptop with integrated graphics. --- dom/canvas/WebGLContext.cpp | 5 ++++- dom/canvas/WebGLContext.h | 29 ++++++++++++++++++-------- dom/canvas/WebGLContextState.cpp | 32 +++++++++++++++++++++++++++++ dom/canvas/WebGLContextValidate.cpp | 3 --- 4 files changed, 57 insertions(+), 12 deletions(-) diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index 176d56f8c5ef4..90f602a34a5ab 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -1432,7 +1432,10 @@ WebGLContext::GetContextAttributes(dom::Nullable& r result.mAlpha.Construct(mOptions.alpha); result.mDepth = mOptions.depth; result.mStencil = mOptions.stencil; - result.mAntialias = mOptions.antialias; + if (MinCapabilityMode()) + result.mAntialias = false; + else + result.mAntialias = mOptions.antialias; result.mPremultipliedAlpha = mOptions.premultipliedAlpha; result.mPreserveDrawingBuffer = mOptions.preserveDrawingBuffer; result.mFailIfMajorPerformanceCaveat = mOptions.failIfMajorPerformanceCaveat; diff --git a/dom/canvas/WebGLContext.h b/dom/canvas/WebGLContext.h index b4d416a330afa..a162f1aa5a106 100644 --- a/dom/canvas/WebGLContext.h +++ b/dom/canvas/WebGLContext.h @@ -60,17 +60,30 @@ class nsIDocShell; * * Exceptions: some of the following values are set to higher values than in the spec because * the values in the spec are ridiculously low. They are explicitly marked below + * + * Tor Browser Modifications: The following values are the minimum between an ancient netbook and a 2013 Moto E */ -#define MINVALUE_GL_MAX_TEXTURE_SIZE 1024 // Different from the spec, which sets it to 64 on page 162 -#define MINVALUE_GL_MAX_CUBE_MAP_TEXTURE_SIZE 512 // Different from the spec, which sets it to 16 on page 162 -#define MINVALUE_GL_MAX_VERTEX_ATTRIBS 8 // Page 164 -#define MINVALUE_GL_MAX_FRAGMENT_UNIFORM_VECTORS 16 // Page 164 -#define MINVALUE_GL_MAX_VERTEX_UNIFORM_VECTORS 128 // Page 164 +#define MINVALUE_GL_MAX_TEXTURE_SIZE 2048 // Different from the spec, which sets it to 64 on page 162 +#define MINVALUE_GL_MAX_CUBE_MAP_TEXTURE_SIZE 2048 // Different from the spec, which sets it to 16 on page 162 +#define MINVALUE_GL_MAX_VERTEX_ATTRIBS 16 // Page 164 +#define MINVALUE_GL_MAX_FRAGMENT_UNIFORM_VECTORS 224 // Page 164 +#define MINVALUE_GL_MAX_VERTEX_UNIFORM_VECTORS 256 // Page 164 #define MINVALUE_GL_MAX_VARYING_VECTORS 8 // Page 164 #define MINVALUE_GL_MAX_TEXTURE_IMAGE_UNITS 8 // Page 164 -#define MINVALUE_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0 // Page 164 -#define MINVALUE_GL_MAX_RENDERBUFFER_SIZE 1024 // Different from the spec, which sets it to 1 on page 164 -#define MINVALUE_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 8 // Page 164 +#define MINVALUE_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 8 // Page 164 +#define MINVALUE_GL_MAX_RENDERBUFFER_SIZE 2048 // Different from the spec, which sets it to 1 on page 164 +#define MINVALUE_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 16 // Page 164 + +/* The following additional values were set specifically for fingerprinting. + * These ranges came from a 2013 Moto E and an old macbook. + * + * These values specify the upper end of the maximum size of line and point + * elements. The lower bounds are 1 in both cases (and the minimum of 1 is + * guaranteed by OpenGL). */ +#define MINVALUE_GL_ALIASED_LINE_WIDTH_RANGE 5 +#define MINVALUE_GL_ALIASED_POINT_SIZE_RANGE 63 +/* This value is used to cap the resolution of the viewport to (MAX x MAX) */ +#define MINVALUE_GL_MAX_VIEWPORT_DIMS 4096 /* * Minimum value constants define in 6.2 State Tables of OpenGL ES - 3.0.4 diff --git a/dom/canvas/WebGLContextState.cpp b/dom/canvas/WebGLContextState.cpp index e0234f5c6116a..ec87992f9f6b6 100644 --- a/dom/canvas/WebGLContextState.cpp +++ b/dom/canvas/WebGLContextState.cpp @@ -226,6 +226,38 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv) case LOCAL_GL_MAX_RENDERBUFFER_SIZE: return JS::Int32Value(MINVALUE_GL_MAX_RENDERBUFFER_SIZE); + case LOCAL_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: + return JS::Int32Value(MINVALUE_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS); + + //case LOCAL_GL_DEPTH_RANGE: + case LOCAL_GL_ALIASED_POINT_SIZE_RANGE: { + GLfloat fv[2] = { 1, MINVALUE_GL_ALIASED_POINT_SIZE_RANGE }; + JSObject* obj = Float32Array::Create(cx, this, 2, fv); + if (!obj) { + rv = NS_ERROR_OUT_OF_MEMORY; + } + return JS::ObjectOrNullValue(obj); + } + + case LOCAL_GL_ALIASED_LINE_WIDTH_RANGE: { + GLfloat fv[2] = { 1, MINVALUE_GL_ALIASED_LINE_WIDTH_RANGE }; + JSObject* obj = Float32Array::Create(cx, this, 2, fv); + if (!obj) { + rv = NS_ERROR_OUT_OF_MEMORY; + } + return JS::ObjectOrNullValue(obj); + } + + case LOCAL_GL_MAX_VIEWPORT_DIMS: { + GLint iv[2] = { MINVALUE_GL_MAX_VIEWPORT_DIMS, MINVALUE_GL_MAX_VIEWPORT_DIMS }; + JSObject* obj = Int32Array::Create(cx, this, 2, iv); + if (!obj) { + rv = NS_ERROR_OUT_OF_MEMORY; + } + return JS::ObjectOrNullValue(obj); + } + + default: // Return the real value; we're not overriding this one break; diff --git a/dom/canvas/WebGLContextValidate.cpp b/dom/canvas/WebGLContextValidate.cpp index ebf0aa8c2d787..28278c004d034 100644 --- a/dom/canvas/WebGLContextValidate.cpp +++ b/dom/canvas/WebGLContextValidate.cpp @@ -465,9 +465,6 @@ WebGLContext::InitAndValidateGL(FailureReason* const out_failReason) mCanLoseContextInForeground = gfxPrefs::WebGLCanLoseContextInForeground(); mRestoreWhenVisible = gfxPrefs::WebGLRestoreWhenVisible(); - if (MinCapabilityMode()) - mDisableFragHighP = true; - // These are the default values, see 6.2 State tables in the // OpenGL ES 2.0.25 spec. mColorWriteMask[0] = 1; -- GitLab