| Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
|
| diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
|
| index 3c910122869fceaa697e4caee925d4a34671c312..52ab7a8cdf423802205757b611cefb852b8f1224 100644
|
| --- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
|
| +++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
|
| @@ -4179,11 +4179,9 @@ void WebGLRenderingContextBase::texImage2DImpl(GLenum target, GLint level, GLenu
|
| }
|
| }
|
|
|
| - if (m_unpackAlignment != 1)
|
| - webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
| + resetUnpackParameters();
|
| texImage2DBase(target, level, internalformat, imageExtractor.imageWidth(), imageExtractor.imageHeight(), 0, format, type, needConversion ? data.data() : imagePixelData);
|
| - if (m_unpackAlignment != 1)
|
| - webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
|
| + restoreUnpackParameters();
|
| }
|
|
|
| bool WebGLRenderingContextBase::validateTexFunc(const char* functionName, TexImageFunctionType functionType, TexFuncValidationSourceType sourceType, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLint xoffset, GLint yoffset)
|
| @@ -4302,10 +4300,10 @@ void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
|
| changeUnpackAlignment = true;
|
| }
|
| if (changeUnpackAlignment)
|
| - webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
| + resetUnpackParameters();
|
| texImage2DBase(target, level, internalformat, width, height, border, format, type, data);
|
| if (changeUnpackAlignment)
|
| - webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
|
| + restoreUnpackParameters();
|
| }
|
|
|
| void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum internalformat,
|
| @@ -4333,11 +4331,9 @@ void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
|
| return;
|
| }
|
| }
|
| - if (m_unpackAlignment != 1)
|
| - webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
| + resetUnpackParameters();
|
| texImage2DBase(target, level, internalformat, pixels->width(), pixels->height(), 0, format, type, needConversion ? data.data() : pixels->data()->data());
|
| - if (m_unpackAlignment != 1)
|
| - webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
|
| + restoreUnpackParameters();
|
| }
|
|
|
| void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum internalformat,
|
| @@ -4602,11 +4598,9 @@ void WebGLRenderingContextBase::texSubImage2DImpl(GLenum target, GLint level, GL
|
| }
|
| }
|
|
|
| - if (m_unpackAlignment != 1)
|
| - webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
| + resetUnpackParameters();
|
| webContext()->texSubImage2D(target, level, xoffset, yoffset, imageExtractor.imageWidth(), imageExtractor.imageHeight(), format, type, needConversion ? data.data() : imagePixelData);
|
| - if (m_unpackAlignment != 1)
|
| - webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
|
| + restoreUnpackParameters();
|
| }
|
|
|
| void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
|
| @@ -4627,10 +4621,10 @@ void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
|
| changeUnpackAlignment = true;
|
| }
|
| if (changeUnpackAlignment)
|
| - webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
| + resetUnpackParameters();
|
| webContext()->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, data);
|
| if (changeUnpackAlignment)
|
| - webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
|
| + restoreUnpackParameters();
|
| }
|
|
|
| void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
|
| @@ -4658,11 +4652,9 @@ void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
|
| return;
|
| }
|
| }
|
| - if (m_unpackAlignment != 1)
|
| - webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
| + resetUnpackParameters();
|
| webContext()->texSubImage2D(target, level, xoffset, yoffset, pixels->width(), pixels->height(), format, type, needConversion ? data.data() : pixels->data()->data());
|
| - if (m_unpackAlignment != 1)
|
| - webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
|
| + restoreUnpackParameters();
|
| }
|
|
|
| void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
|
| @@ -6934,4 +6926,16 @@ DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const
|
| return m_drawingBuffer.get();
|
| }
|
|
|
| +void WebGLRenderingContextBase::resetUnpackParameters()
|
| +{
|
| + if (m_unpackAlignment != 1)
|
| + webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
| +}
|
| +
|
| +void WebGLRenderingContextBase::restoreUnpackParameters()
|
| +{
|
| + if (m_unpackAlignment != 1)
|
| + webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
|
| +}
|
| +
|
| } // namespace blink
|
|
|