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

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

Issue 2458943002: Support 2D texture sub-source uploads from HTMLImageElement. (Closed)
Patch Set: Fixed bug in computation of default image sub-rectangle. Created 4 years, 2 months 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 5f13e053cdf2969f783e20dd724b0375fd121ffd..b93ad380644b303da9804b8045d021c3aedf5b28 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
@@ -1104,30 +1104,30 @@ void WebGL2RenderingContextBase::renderbufferStorageMultisample(
void WebGL2RenderingContextBase::resetUnpackParameters() {
WebGLRenderingContextBase::resetUnpackParameters();
- if (!m_unpackRowLength)
+ if (m_unpackRowLength)
contextGL()->PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- if (!m_unpackImageHeight)
+ if (m_unpackImageHeight)
contextGL()->PixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0);
- if (!m_unpackSkipPixels)
+ if (m_unpackSkipPixels)
contextGL()->PixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
- if (!m_unpackSkipRows)
+ if (m_unpackSkipRows)
contextGL()->PixelStorei(GL_UNPACK_SKIP_ROWS, 0);
- if (!m_unpackSkipImages)
+ if (m_unpackSkipImages)
contextGL()->PixelStorei(GL_UNPACK_SKIP_IMAGES, 0);
}
void WebGL2RenderingContextBase::restoreUnpackParameters() {
WebGLRenderingContextBase::restoreUnpackParameters();
- if (!m_unpackRowLength)
+ if (m_unpackRowLength)
contextGL()->PixelStorei(GL_UNPACK_ROW_LENGTH, m_unpackRowLength);
- if (!m_unpackImageHeight)
+ if (m_unpackImageHeight)
contextGL()->PixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_unpackImageHeight);
- if (!m_unpackSkipPixels)
+ if (m_unpackSkipPixels)
contextGL()->PixelStorei(GL_UNPACK_SKIP_PIXELS, m_unpackSkipPixels);
- if (!m_unpackSkipRows)
+ if (m_unpackSkipRows)
contextGL()->PixelStorei(GL_UNPACK_SKIP_ROWS, m_unpackSkipRows);
- if (!m_unpackSkipImages)
+ if (m_unpackSkipImages)
contextGL()->PixelStorei(GL_UNPACK_SKIP_IMAGES, m_unpackSkipImages);
}
@@ -1305,7 +1305,15 @@ void WebGL2RenderingContextBase::texImage2D(GLenum target,
GLenum type,
HTMLImageElement* image,
ExceptionState& exceptionState) {
- // TODO(zmo): To be implemented.
+ IntRect sourceImageRect;
+ if (image) {
+ sourceImageRect.setLocation(IntPoint(m_unpackSkipPixels, m_unpackSkipRows));
+ sourceImageRect.setSize(IntSize(width, height));
+ }
+
+ texImageHelperHTMLImageElement(TexImage2D, target, level, internalformat,
+ format, type, 0, 0, 0, image, sourceImageRect,
+ exceptionState);
}
void WebGL2RenderingContextBase::texImage2D(GLenum target,
@@ -1451,7 +1459,15 @@ void WebGL2RenderingContextBase::texSubImage2D(GLenum target,
GLenum type,
HTMLImageElement* image,
ExceptionState& exceptionState) {
- // TODO(zmo): To be implemente.
+ IntRect sourceImageRect;
+ if (image) {
+ sourceImageRect.setLocation(IntPoint(m_unpackSkipPixels, m_unpackSkipRows));
+ sourceImageRect.setSize(IntSize(width, height));
+ }
+
+ texImageHelperHTMLImageElement(TexSubImage2D, target, level, 0, format, type,
+ xoffset, yoffset, 0, image, sourceImageRect,
+ exceptionState);
}
void WebGL2RenderingContextBase::texSubImage2D(GLenum target,
@@ -1858,7 +1874,7 @@ void WebGL2RenderingContextBase::texSubImage3D(GLenum target,
ExceptionState& exceptionState) {
texImageHelperHTMLImageElement(TexSubImage3D, target, level, 0, format, type,
xoffset, yoffset, zoffset, image,
- exceptionState);
+ sentinelEmptyRect(), exceptionState);
}
void WebGL2RenderingContextBase::texSubImage3D(GLenum target,

Powered by Google App Engine
This is Rietveld 408576698