Bug 1306172 - Don't pass LINE_WIDTH>1.0 to core profiles. - r=jerry
--- 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;