Bug 1306172 - Don't pass LINE_WIDTH>1.0 to core profiles. - r=jerry
authorJeff Gilbert <jdashg@gmail.com>
Tue, 27 Sep 2016 20:54:46 -0700
changeset 315916 0cc441ce2c8c394767c8f3161fad0047555dbaac
parent 315915 42a1e4dd9f789675c3d8656b4a340a162ec590e1
child 315917 282b5fdbd98b40b96bc8568294fc500aa2f06838
push id30757
push usercbook@mozilla.com
push dateFri, 30 Sep 2016 10:02:43 +0000
treeherdermozilla-central@5ffed033557e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjerry
bugs1306172
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1306172 - Don't pass LINE_WIDTH>1.0 to core profiles. - r=jerry
dom/canvas/WebGLContext.h
dom/canvas/WebGLContextGL.cpp
dom/canvas/WebGLContextState.cpp
dom/canvas/WebGLContextValidate.cpp
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -1518,16 +1518,18 @@ protected:
     GLfloat mDepthClearValue;
 
     GLint mViewportX;
     GLint mViewportY;
     GLsizei mViewportWidth;
     GLsizei mViewportHeight;
     bool mAlreadyWarnedAboutViewportLargerThanDest;
 
+    GLfloat mLineWidth;
+
     WebGLContextLossHandler mContextLossHandler;
     bool mAllowContextRestore;
     bool mLastLossWasSimulated;
     ContextStatus mContextStatus;
     bool mContextLostErrorSet;
 
     // Used for some hardware (particularly Tegra 2 and 4) that likes to
     // be Flushed while doing hundreds of draw calls.
--- a/dom/canvas/WebGLContextGL.cpp
+++ b/dom/canvas/WebGLContextGL.cpp
@@ -2403,16 +2403,22 @@ WebGLContext::LineWidth(GLfloat width)
 
     // Doing it this way instead of `if (width <= 0.0)` handles NaNs.
     const bool isValid = width > 0.0;
     if (!isValid) {
         ErrorInvalidValue("lineWidth: `width` must be positive and non-zero.");
         return;
     }
 
+    mLineWidth = width;
+
+    if (gl->IsCoreProfile() && width > 1.0) {
+        width = 1.0;
+    }
+
     MakeContextCurrent();
     gl->fLineWidth(width);
 }
 
 void
 WebGLContext::PolygonOffset(GLfloat factor, GLfloat units) {
     if (IsContextLost())
         return;
--- a/dom/canvas/WebGLContextState.cpp
+++ b/dom/canvas/WebGLContextState.cpp
@@ -504,18 +504,20 @@ WebGLContext::GetParameter(JSContext* cx
 
         case LOCAL_GL_STENCIL_VALUE_MASK:
             return JS::DoubleValue(mStencilValueMaskFront);
 
         case LOCAL_GL_STENCIL_WRITEMASK:
             return JS::DoubleValue(mStencilWriteMaskFront);
 
         // float
+        case LOCAL_GL_LINE_WIDTH:
+            return JS::DoubleValue(mLineWidth);
+
         case LOCAL_GL_DEPTH_CLEAR_VALUE:
-        case LOCAL_GL_LINE_WIDTH:
         case LOCAL_GL_POLYGON_OFFSET_FACTOR:
         case LOCAL_GL_POLYGON_OFFSET_UNITS:
         case LOCAL_GL_SAMPLE_COVERAGE_VALUE: {
             GLfloat f = 0.f;
             gl->fGetFloatv(pname, &f);
             return JS::DoubleValue(f);
         }
 
--- a/dom/canvas/WebGLContextValidate.cpp
+++ b/dom/canvas/WebGLContextValidate.cpp
@@ -667,16 +667,18 @@ WebGLContext::InitAndValidateGL(FailureR
     mColorClearValue[1] = 0.f;
     mColorClearValue[2] = 0.f;
     mColorClearValue[3] = 0.f;
     mDepthClearValue = 1.f;
     mStencilClearValue = 0;
     mStencilRefFront = 0;
     mStencilRefBack = 0;
 
+    mLineWidth = 1.0;
+
     /*
     // Technically, we should be setting mStencil[...] values to
     // `allOnes`, but either ANGLE breaks or the SGX540s on Try break.
     GLuint stencilBits = 0;
     gl->GetUIntegerv(LOCAL_GL_STENCIL_BITS, &stencilBits);
     GLuint allOnes = ~(UINT32_MAX << stencilBits);
     mStencilValueMaskFront = allOnes;
     mStencilValueMaskBack  = allOnes;