Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp

Issue 1494553002: Revert of Upgrade PixelStorei to ES3/WebGL2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
index d92a66c0d01553210f24831c756c331b6a5b6c95..6d68faaba2df29307afde851c4b63257969c50db 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
@@ -168,15 +168,6 @@
m_boundIndexedUniformBuffers.resize(maxUniformBufferBindings);
m_maxBoundUniformBufferIndex = 0;
- m_packRowLength = 0;
- m_packSkipPixels = 0;
- m_packSkipRows = 0;
- m_unpackRowLength = 0;
- m_unpackImageHeight = 0;
- m_unpackSkipPixels = 0;
- m_unpackSkipRows = 0;
- m_unpackSkipImages = 0;
-
WebGLRenderingContextBase::initializeNewContext();
}
@@ -536,42 +527,6 @@
webContext()->readBuffer(mode);
}
-void WebGL2RenderingContextBase::pixelStorei(GLenum pname, GLint param)
-{
- if (isContextLost())
- return;
- switch (pname) {
- case GL_PACK_ROW_LENGTH:
- m_packRowLength = param;
- break;
- case GL_PACK_SKIP_PIXELS:
- m_packSkipPixels = param;
- break;
- case GL_PACK_SKIP_ROWS:
- m_packSkipRows = param;
- break;
- case GL_UNPACK_ROW_LENGTH:
- m_unpackRowLength = param;
- break;
- case GL_UNPACK_IMAGE_HEIGHT:
- m_unpackImageHeight = param;
- break;
- case GL_UNPACK_SKIP_PIXELS:
- m_unpackSkipPixels = param;
- break;
- case GL_UNPACK_SKIP_ROWS:
- m_unpackSkipRows = param;
- break;
- case GL_UNPACK_SKIP_IMAGES:
- m_unpackSkipImages = param;
- break;
- default:
- WebGLRenderingContextBase::pixelStorei(pname, param);
- return;
- }
- webContext()->pixelStorei(pname, param);
-}
-
void WebGL2RenderingContextBase::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, DOMArrayBufferView* pixels)
{
if (isContextLost())
@@ -728,38 +683,6 @@
applyStencilTest();
}
-void WebGL2RenderingContextBase::resetUnpackParameters()
-{
- WebGLRenderingContextBase::resetUnpackParameters();
-
- if (!m_unpackRowLength)
- webContext()->pixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- if (!m_unpackImageHeight)
- webContext()->pixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0);
- if (!m_unpackSkipPixels)
- webContext()->pixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
- if (!m_unpackSkipRows)
- webContext()->pixelStorei(GL_UNPACK_SKIP_ROWS, 0);
- if (!m_unpackSkipImages)
- webContext()->pixelStorei(GL_UNPACK_SKIP_IMAGES, 0);
-}
-
-void WebGL2RenderingContextBase::restoreUnpackParameters()
-{
- WebGLRenderingContextBase::restoreUnpackParameters();
-
- if (!m_unpackRowLength)
- webContext()->pixelStorei(GL_UNPACK_ROW_LENGTH, m_unpackRowLength);
- if (!m_unpackImageHeight)
- webContext()->pixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_unpackImageHeight);
- if (!m_unpackSkipPixels)
- webContext()->pixelStorei(GL_UNPACK_SKIP_PIXELS, m_unpackSkipPixels);
- if (!m_unpackSkipRows)
- webContext()->pixelStorei(GL_UNPACK_SKIP_ROWS, m_unpackSkipRows);
- if (!m_unpackSkipImages)
- webContext()->pixelStorei(GL_UNPACK_SKIP_IMAGES, m_unpackSkipImages);
-}
-
/* Texture objects */
bool WebGL2RenderingContextBase::validateTexStorage(const char* functionName, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, TexStorageType functionType)
{
@@ -960,9 +883,11 @@
}
}
- resetUnpackParameters();
+ if (m_unpackAlignment != 1)
+ webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
webContext()->texSubImage3D(target, level, xoffset, yoffset, zoffset, imageExtractor.imageWidth(), imageExtractor.imageHeight(), 1, format, type, needConversion ? data.data() : imagePixelData);
- restoreUnpackParameters();
+ if (m_unpackAlignment != 1)
+ webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
}
void WebGL2RenderingContextBase::texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, DOMArrayBufferView* pixels)
@@ -975,17 +900,22 @@
void* data = pixels->baseAddress();
Vector<uint8_t> tempData;
- bool changeUnpackParameters = false;
+ bool changeUnpackAlignment = false;
if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) {
- // FIXME: WebGLImageConversion needs to be updated to accept image depth.
- notImplemented();
- changeUnpackParameters = true;
- }
- if (changeUnpackParameters)
- resetUnpackParameters();
+ if (!WebGLImageConversion::extractTextureData(width, height, format, type,
+ m_unpackAlignment,
+ m_unpackFlipY, m_unpackPremultiplyAlpha,
+ data,
+ tempData))
+ return;
+ data = tempData.data();
+ changeUnpackAlignment = true;
+ }
+ if (changeUnpackAlignment)
+ webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
webContext()->texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data);
- if (changeUnpackParameters)
- restoreUnpackParameters();
+ if (changeUnpackAlignment)
+ webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
}
void WebGL2RenderingContextBase::texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLenum format, GLenum type, ImageData* pixels)
@@ -1009,9 +939,11 @@
return;
}
}
- resetUnpackParameters();
+ if (m_unpackAlignment != 1)
+ webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
webContext()->texSubImage3D(target, level, xoffset, yoffset, zoffset, pixels->width(), pixels->height(), 1, format, type, needConversion ? data.data() : pixels->data()->data());
- restoreUnpackParameters();
+ if (m_unpackAlignment != 1)
+ webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
}
void WebGL2RenderingContextBase::texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLenum format, GLenum type, HTMLImageElement* image, ExceptionState& exceptionState)
@@ -2609,11 +2541,11 @@
case GL_UNPACK_ROW_LENGTH:
return getIntParameter(scriptState, pname);
case GL_UNPACK_SKIP_IMAGES:
- return getIntParameter(scriptState, pname);
+ return getBooleanParameter(scriptState, pname);
case GL_UNPACK_SKIP_PIXELS:
- return getIntParameter(scriptState, pname);
+ return getBooleanParameter(scriptState, pname);
case GL_UNPACK_SKIP_ROWS:
- return getIntParameter(scriptState, pname);
+ return getBooleanParameter(scriptState, pname);
default:
return WebGLRenderingContextBase::getParameter(scriptState, pname);

Powered by Google App Engine
This is Rietveld 408576698