Bug 1306172 - Don't pass LINE_WIDTH>1.0 to core profiles. - r=jerry draft
authorJeff Gilbert <jdashg@gmail.com>
Tue, 27 Sep 2016 20:54:46 -0700
changeset 418729 dfc3b67d0e3b195557563c4bf548ce1e28af585e
parent 418728 841ae2ed4e43701a23c15738f717ab95bd097bac
child 418730 9ee1972825fb427dfc38fd2acfda7d67ff34646d
push id30767
push userbmo:jgilbert@mozilla.com
push dateThu, 29 Sep 2016 01:52:44 +0000
reviewersjerry
bugs1306172
milestone52.0a1
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
@@ -2411,16 +2411,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;