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

Side by Side 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, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/webgl/WebGL2RenderingContextBase.h" 5 #include "modules/webgl/WebGL2RenderingContextBase.h"
6 6
7 #include "bindings/modules/v8/WebGLAny.h" 7 #include "bindings/modules/v8/WebGLAny.h"
8 #include "core/dom/DOMException.h" 8 #include "core/dom/DOMException.h"
9 #include "core/frame/ImageBitmap.h" 9 #include "core/frame/ImageBitmap.h"
10 #include "core/html/HTMLCanvasElement.h" 10 #include "core/html/HTMLCanvasElement.h"
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 return; 1097 return;
1098 } 1098 }
1099 renderbufferStorageImpl(target, samples, internalformat, width, height, 1099 renderbufferStorageImpl(target, samples, internalformat, width, height,
1100 functionName); 1100 functionName);
1101 applyStencilTest(); 1101 applyStencilTest();
1102 } 1102 }
1103 1103
1104 void WebGL2RenderingContextBase::resetUnpackParameters() { 1104 void WebGL2RenderingContextBase::resetUnpackParameters() {
1105 WebGLRenderingContextBase::resetUnpackParameters(); 1105 WebGLRenderingContextBase::resetUnpackParameters();
1106 1106
1107 if (!m_unpackRowLength) 1107 if (m_unpackRowLength)
1108 contextGL()->PixelStorei(GL_UNPACK_ROW_LENGTH, 0); 1108 contextGL()->PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
1109 if (!m_unpackImageHeight) 1109 if (m_unpackImageHeight)
1110 contextGL()->PixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0); 1110 contextGL()->PixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0);
1111 if (!m_unpackSkipPixels) 1111 if (m_unpackSkipPixels)
1112 contextGL()->PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); 1112 contextGL()->PixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
1113 if (!m_unpackSkipRows) 1113 if (m_unpackSkipRows)
1114 contextGL()->PixelStorei(GL_UNPACK_SKIP_ROWS, 0); 1114 contextGL()->PixelStorei(GL_UNPACK_SKIP_ROWS, 0);
1115 if (!m_unpackSkipImages) 1115 if (m_unpackSkipImages)
1116 contextGL()->PixelStorei(GL_UNPACK_SKIP_IMAGES, 0); 1116 contextGL()->PixelStorei(GL_UNPACK_SKIP_IMAGES, 0);
1117 } 1117 }
1118 1118
1119 void WebGL2RenderingContextBase::restoreUnpackParameters() { 1119 void WebGL2RenderingContextBase::restoreUnpackParameters() {
1120 WebGLRenderingContextBase::restoreUnpackParameters(); 1120 WebGLRenderingContextBase::restoreUnpackParameters();
1121 1121
1122 if (!m_unpackRowLength) 1122 if (m_unpackRowLength)
1123 contextGL()->PixelStorei(GL_UNPACK_ROW_LENGTH, m_unpackRowLength); 1123 contextGL()->PixelStorei(GL_UNPACK_ROW_LENGTH, m_unpackRowLength);
1124 if (!m_unpackImageHeight) 1124 if (m_unpackImageHeight)
1125 contextGL()->PixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_unpackImageHeight); 1125 contextGL()->PixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_unpackImageHeight);
1126 if (!m_unpackSkipPixels) 1126 if (m_unpackSkipPixels)
1127 contextGL()->PixelStorei(GL_UNPACK_SKIP_PIXELS, m_unpackSkipPixels); 1127 contextGL()->PixelStorei(GL_UNPACK_SKIP_PIXELS, m_unpackSkipPixels);
1128 if (!m_unpackSkipRows) 1128 if (m_unpackSkipRows)
1129 contextGL()->PixelStorei(GL_UNPACK_SKIP_ROWS, m_unpackSkipRows); 1129 contextGL()->PixelStorei(GL_UNPACK_SKIP_ROWS, m_unpackSkipRows);
1130 if (!m_unpackSkipImages) 1130 if (m_unpackSkipImages)
1131 contextGL()->PixelStorei(GL_UNPACK_SKIP_IMAGES, m_unpackSkipImages); 1131 contextGL()->PixelStorei(GL_UNPACK_SKIP_IMAGES, m_unpackSkipImages);
1132 } 1132 }
1133 1133
1134 /* Texture objects */ 1134 /* Texture objects */
1135 bool WebGL2RenderingContextBase::validateTexStorage( 1135 bool WebGL2RenderingContextBase::validateTexStorage(
1136 const char* functionName, 1136 const char* functionName,
1137 GLenum target, 1137 GLenum target,
1138 GLsizei levels, 1138 GLsizei levels,
1139 GLenum internalformat, 1139 GLenum internalformat,
1140 GLsizei width, 1140 GLsizei width,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 void WebGL2RenderingContextBase::texImage2D(GLenum target, 1298 void WebGL2RenderingContextBase::texImage2D(GLenum target,
1299 GLint level, 1299 GLint level,
1300 GLint internalformat, 1300 GLint internalformat,
1301 GLsizei width, 1301 GLsizei width,
1302 GLsizei height, 1302 GLsizei height,
1303 GLint border, 1303 GLint border,
1304 GLenum format, 1304 GLenum format,
1305 GLenum type, 1305 GLenum type,
1306 HTMLImageElement* image, 1306 HTMLImageElement* image,
1307 ExceptionState& exceptionState) { 1307 ExceptionState& exceptionState) {
1308 // TODO(zmo): To be implemented. 1308 IntRect sourceImageRect;
1309 if (image) {
1310 sourceImageRect.setLocation(IntPoint(m_unpackSkipPixels, m_unpackSkipRows));
1311 sourceImageRect.setSize(IntSize(width, height));
1312 }
1313
1314 texImageHelperHTMLImageElement(TexImage2D, target, level, internalformat,
1315 format, type, 0, 0, 0, image, sourceImageRect,
1316 exceptionState);
1309 } 1317 }
1310 1318
1311 void WebGL2RenderingContextBase::texImage2D(GLenum target, 1319 void WebGL2RenderingContextBase::texImage2D(GLenum target,
1312 GLint level, 1320 GLint level,
1313 GLint internalformat, 1321 GLint internalformat,
1314 GLsizei width, 1322 GLsizei width,
1315 GLsizei height, 1323 GLsizei height,
1316 GLint border, 1324 GLint border,
1317 GLenum format, 1325 GLenum format,
1318 GLenum type, 1326 GLenum type,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 void WebGL2RenderingContextBase::texSubImage2D(GLenum target, 1452 void WebGL2RenderingContextBase::texSubImage2D(GLenum target,
1445 GLint level, 1453 GLint level,
1446 GLint xoffset, 1454 GLint xoffset,
1447 GLint yoffset, 1455 GLint yoffset,
1448 GLsizei width, 1456 GLsizei width,
1449 GLsizei height, 1457 GLsizei height,
1450 GLenum format, 1458 GLenum format,
1451 GLenum type, 1459 GLenum type,
1452 HTMLImageElement* image, 1460 HTMLImageElement* image,
1453 ExceptionState& exceptionState) { 1461 ExceptionState& exceptionState) {
1454 // TODO(zmo): To be implemente. 1462 IntRect sourceImageRect;
1463 if (image) {
1464 sourceImageRect.setLocation(IntPoint(m_unpackSkipPixels, m_unpackSkipRows));
1465 sourceImageRect.setSize(IntSize(width, height));
1466 }
1467
1468 texImageHelperHTMLImageElement(TexSubImage2D, target, level, 0, format, type,
1469 xoffset, yoffset, 0, image, sourceImageRect,
1470 exceptionState);
1455 } 1471 }
1456 1472
1457 void WebGL2RenderingContextBase::texSubImage2D(GLenum target, 1473 void WebGL2RenderingContextBase::texSubImage2D(GLenum target,
1458 GLint level, 1474 GLint level,
1459 GLint xoffset, 1475 GLint xoffset,
1460 GLint yoffset, 1476 GLint yoffset,
1461 GLsizei width, 1477 GLsizei width,
1462 GLsizei height, 1478 GLsizei height,
1463 GLenum format, 1479 GLenum format,
1464 GLenum type, 1480 GLenum type,
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1851 GLint level, 1867 GLint level,
1852 GLint xoffset, 1868 GLint xoffset,
1853 GLint yoffset, 1869 GLint yoffset,
1854 GLint zoffset, 1870 GLint zoffset,
1855 GLenum format, 1871 GLenum format,
1856 GLenum type, 1872 GLenum type,
1857 HTMLImageElement* image, 1873 HTMLImageElement* image,
1858 ExceptionState& exceptionState) { 1874 ExceptionState& exceptionState) {
1859 texImageHelperHTMLImageElement(TexSubImage3D, target, level, 0, format, type, 1875 texImageHelperHTMLImageElement(TexSubImage3D, target, level, 0, format, type,
1860 xoffset, yoffset, zoffset, image, 1876 xoffset, yoffset, zoffset, image,
1861 exceptionState); 1877 sentinelEmptyRect(), exceptionState);
1862 } 1878 }
1863 1879
1864 void WebGL2RenderingContextBase::texSubImage3D(GLenum target, 1880 void WebGL2RenderingContextBase::texSubImage3D(GLenum target,
1865 GLint level, 1881 GLint level,
1866 GLint xoffset, 1882 GLint xoffset,
1867 GLint yoffset, 1883 GLint yoffset,
1868 GLint zoffset, 1884 GLint zoffset,
1869 GLenum format, 1885 GLenum format,
1870 GLenum type, 1886 GLenum type,
1871 HTMLCanvasElement* canvas, 1887 HTMLCanvasElement* canvas,
(...skipping 2937 matching lines...) Expand 10 before | Expand all | Expand 10 after
4809 4825
4810 void WebGL2RenderingContextBase:: 4826 void WebGL2RenderingContextBase::
4811 DrawingBufferClientRestorePixelUnpackBufferBinding() { 4827 DrawingBufferClientRestorePixelUnpackBufferBinding() {
4812 if (!contextGL()) 4828 if (!contextGL())
4813 return; 4829 return;
4814 contextGL()->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 4830 contextGL()->BindBuffer(GL_PIXEL_UNPACK_BUFFER,
4815 objectOrZero(m_boundPixelUnpackBuffer.get())); 4831 objectOrZero(m_boundPixelUnpackBuffer.get()));
4816 } 4832 }
4817 4833
4818 } // namespace blink 4834 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698