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

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

Issue 1492013002: Reland 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 6d68faaba2df29307afde851c4b63257969c50db..d92a66c0d01553210f24831c756c331b6a5b6c95 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
@@ -168,6 +168,15 @@
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();
}
@@ -527,6 +536,42 @@
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())
@@ -683,6 +728,38 @@
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)
{
@@ -883,11 +960,9 @@
}
}
- if (m_unpackAlignment != 1)
- webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ resetUnpackParameters();
webContext()->texSubImage3D(target, level, xoffset, yoffset, zoffset, imageExtractor.imageWidth(), imageExtractor.imageHeight(), 1, format, type, needConversion ? data.data() : imagePixelData);
- if (m_unpackAlignment != 1)
- webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
+ restoreUnpackParameters();
}
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)
@@ -900,22 +975,17 @@
void* data = pixels->baseAddress();
Vector<uint8_t> tempData;
- bool changeUnpackAlignment = false;
+ bool changeUnpackParameters = false;
if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) {
- 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);
+ // FIXME: WebGLImageConversion needs to be updated to accept image depth.
+ notImplemented();
+ changeUnpackParameters = true;
+ }
+ if (changeUnpackParameters)
+ resetUnpackParameters();
webContext()->texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data);
- if (changeUnpackAlignment)
- webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
+ if (changeUnpackParameters)
+ restoreUnpackParameters();
}
void WebGL2RenderingContextBase::texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLenum format, GLenum type, ImageData* pixels)
@@ -939,11 +1009,9 @@
return;
}
}
- if (m_unpackAlignment != 1)
- webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ resetUnpackParameters();
webContext()->texSubImage3D(target, level, xoffset, yoffset, zoffset, pixels->width(), pixels->height(), 1, format, type, needConversion ? data.data() : pixels->data()->data());
- if (m_unpackAlignment != 1)
- webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
+ restoreUnpackParameters();
}
void WebGL2RenderingContextBase::texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLenum format, GLenum type, HTMLImageElement* image, ExceptionState& exceptionState)
@@ -2541,11 +2609,11 @@
case GL_UNPACK_ROW_LENGTH:
return getIntParameter(scriptState, pname);
case GL_UNPACK_SKIP_IMAGES:
- return getBooleanParameter(scriptState, pname);
+ return getIntParameter(scriptState, pname);
case GL_UNPACK_SKIP_PIXELS:
- return getBooleanParameter(scriptState, pname);
+ return getIntParameter(scriptState, pname);
case GL_UNPACK_SKIP_ROWS:
- return getBooleanParameter(scriptState, pname);
+ return getIntParameter(scriptState, pname);
default:
return WebGLRenderingContextBase::getParameter(scriptState, pname);

Powered by Google App Engine
This is Rietveld 408576698