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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp

Issue 2500433003: support 3d texture sub-source uploads from ImageData (Closed)
Patch Set: use unpackImageHeight correctly and add/deduplicate validation 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 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 GLsizei height, 1308 GLsizei height,
1309 GLint border, 1309 GLint border,
1310 GLenum format, 1310 GLenum format,
1311 GLenum type, 1311 GLenum type,
1312 ImageData* pixels) { 1312 ImageData* pixels) {
1313 DCHECK(pixels); 1313 DCHECK(pixels);
1314 IntRect sourceImageRect; 1314 IntRect sourceImageRect;
1315 sourceImageRect.setLocation(IntPoint(m_unpackSkipPixels, m_unpackSkipRows)); 1315 sourceImageRect.setLocation(IntPoint(m_unpackSkipPixels, m_unpackSkipRows));
1316 sourceImageRect.setSize(IntSize(width, height)); 1316 sourceImageRect.setSize(IntSize(width, height));
1317 texImageHelperImageData(TexImage2D, target, level, internalformat, 0, format, 1317 texImageHelperImageData(TexImage2D, target, level, internalformat, 0, format,
1318 type, 1, 0, 0, 0, pixels, sourceImageRect); 1318 type, 1, 0, 0, 0, pixels, sourceImageRect,
1319 m_unpackImageHeight);
1319 } 1320 }
1320 1321
1321 void WebGL2RenderingContextBase::texImage2D(GLenum target, 1322 void WebGL2RenderingContextBase::texImage2D(GLenum target,
1322 GLint level, 1323 GLint level,
1323 GLint internalformat, 1324 GLint internalformat,
1324 GLsizei width, 1325 GLsizei width,
1325 GLsizei height, 1326 GLsizei height,
1326 GLint border, 1327 GLint border,
1327 GLenum format, 1328 GLenum format,
1328 GLenum type, 1329 GLenum type,
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 GLsizei width, 1468 GLsizei width,
1468 GLsizei height, 1469 GLsizei height,
1469 GLenum format, 1470 GLenum format,
1470 GLenum type, 1471 GLenum type,
1471 ImageData* pixels) { 1472 ImageData* pixels) {
1472 DCHECK(pixels); 1473 DCHECK(pixels);
1473 IntRect sourceImageRect; 1474 IntRect sourceImageRect;
1474 sourceImageRect.setLocation(IntPoint(m_unpackSkipPixels, m_unpackSkipRows)); 1475 sourceImageRect.setLocation(IntPoint(m_unpackSkipPixels, m_unpackSkipRows));
1475 sourceImageRect.setSize(IntSize(width, height)); 1476 sourceImageRect.setSize(IntSize(width, height));
1476 texImageHelperImageData(TexSubImage2D, target, level, 0, 0, format, type, 1, 1477 texImageHelperImageData(TexSubImage2D, target, level, 0, 0, format, type, 1,
1477 xoffset, yoffset, 0, pixels, sourceImageRect); 1478 xoffset, yoffset, 0, pixels, sourceImageRect,
1479 m_unpackImageHeight);
1478 } 1480 }
1479 1481
1480 void WebGL2RenderingContextBase::texSubImage2D(GLenum target, 1482 void WebGL2RenderingContextBase::texSubImage2D(GLenum target,
1481 GLint level, 1483 GLint level,
1482 GLint xoffset, 1484 GLint xoffset,
1483 GLint yoffset, 1485 GLint yoffset,
1484 GLsizei width, 1486 GLsizei width,
1485 GLsizei height, 1487 GLsizei height,
1486 GLenum format, 1488 GLenum format,
1487 GLenum type, 1489 GLenum type,
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 1691
1690 void WebGL2RenderingContextBase::texImage3D(GLenum target, 1692 void WebGL2RenderingContextBase::texImage3D(GLenum target,
1691 GLint level, 1693 GLint level,
1692 GLint internalformat, 1694 GLint internalformat,
1693 GLsizei width, 1695 GLsizei width,
1694 GLsizei height, 1696 GLsizei height,
1695 GLsizei depth, 1697 GLsizei depth,
1696 GLint border, 1698 GLint border,
1697 GLenum format, 1699 GLenum format,
1698 GLenum type, 1700 GLenum type,
1699 ImageData* imageData) { 1701 ImageData* pixels) {
1700 // TODO(zmo): To be implemented. 1702 DCHECK(pixels);
1703 IntRect sourceImageRect;
1704 sourceImageRect.setLocation(IntPoint(m_unpackSkipPixels, m_unpackSkipRows));
1705 sourceImageRect.setSize(IntSize(width, height));
1706 texImageHelperImageData(TexImage3D, target, level, internalformat, 0, format,
1707 type, depth, 0, 0, 0, pixels, sourceImageRect,
1708 m_unpackImageHeight);
1701 } 1709 }
1702 1710
1703 void WebGL2RenderingContextBase::texImage3D(GLenum target, 1711 void WebGL2RenderingContextBase::texImage3D(GLenum target,
1704 GLint level, 1712 GLint level,
1705 GLint internalformat, 1713 GLint internalformat,
1706 GLsizei width, 1714 GLsizei width,
1707 GLsizei height, 1715 GLsizei height,
1708 GLsizei depth, 1716 GLsizei depth,
1709 GLint border, 1717 GLint border,
1710 GLenum format, 1718 GLenum format,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1817 GLint level, 1825 GLint level,
1818 GLint xoffset, 1826 GLint xoffset,
1819 GLint yoffset, 1827 GLint yoffset,
1820 GLint zoffset, 1828 GLint zoffset,
1821 GLsizei width, 1829 GLsizei width,
1822 GLsizei height, 1830 GLsizei height,
1823 GLsizei depth, 1831 GLsizei depth,
1824 GLenum format, 1832 GLenum format,
1825 GLenum type, 1833 GLenum type,
1826 ImageData* pixels) { 1834 ImageData* pixels) {
1827 // TODO(zmo): To be implemented. 1835 DCHECK(pixels);
1836 IntRect sourceImageRect;
1837 sourceImageRect.setLocation(IntPoint(m_unpackSkipPixels, m_unpackSkipRows));
1838 sourceImageRect.setSize(IntSize(width, height));
1839 texImageHelperImageData(TexSubImage3D, target, level, 0, 0, format, type,
1840 depth, xoffset, yoffset, zoffset, pixels,
1841 sourceImageRect, m_unpackImageHeight);
1828 } 1842 }
1829 1843
1830 void WebGL2RenderingContextBase::texSubImage3D(GLenum target, 1844 void WebGL2RenderingContextBase::texSubImage3D(GLenum target,
1831 GLint level, 1845 GLint level,
1832 GLint xoffset, 1846 GLint xoffset,
1833 GLint yoffset, 1847 GLint yoffset,
1834 GLint zoffset, 1848 GLint zoffset,
1835 GLsizei width, 1849 GLsizei width,
1836 GLsizei height, 1850 GLsizei height,
1837 GLsizei depth, 1851 GLsizei depth,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1895 // TODO(zmo): To be implemented. 1909 // TODO(zmo): To be implemented.
1896 } 1910 }
1897 1911
1898 void WebGL2RenderingContextBase::texSubImage3D(GLenum target, 1912 void WebGL2RenderingContextBase::texSubImage3D(GLenum target,
1899 GLint level, 1913 GLint level,
1900 GLint xoffset, 1914 GLint xoffset,
1901 GLint yoffset, 1915 GLint yoffset,
1902 GLint zoffset, 1916 GLint zoffset,
1903 GLenum format, 1917 GLenum format,
1904 GLenum type, 1918 GLenum type,
1905 ImageData* pixels) {
1906 texImageHelperImageData(TexSubImage3D, target, level, 0, 0, format, type, 1,
1907 xoffset, yoffset, zoffset, pixels,
1908 getImageDataSize(pixels));
1909 }
1910
1911 void WebGL2RenderingContextBase::texSubImage3D(GLenum target,
1912 GLint level,
1913 GLint xoffset,
1914 GLint yoffset,
1915 GLint zoffset,
1916 GLenum format,
1917 GLenum type,
1918 HTMLCanvasElement* canvas, 1919 HTMLCanvasElement* canvas,
1919 ExceptionState& exceptionState) { 1920 ExceptionState& exceptionState) {
1920 texImageHelperHTMLCanvasElement(TexSubImage3D, target, level, 0, format, type, 1921 texImageHelperHTMLCanvasElement(TexSubImage3D, target, level, 0, format, type,
1921 xoffset, yoffset, zoffset, canvas, 1922 xoffset, yoffset, zoffset, canvas,
1922 exceptionState); 1923 exceptionState);
1923 } 1924 }
1924 1925
1925 void WebGL2RenderingContextBase::texSubImage3D(GLenum target, 1926 void WebGL2RenderingContextBase::texSubImage3D(GLenum target,
1926 GLint level, 1927 GLint level,
1927 GLint xoffset, 1928 GLint xoffset,
(...skipping 3037 matching lines...) Expand 10 before | Expand all | Expand 10 after
4965 4966
4966 void WebGL2RenderingContextBase:: 4967 void WebGL2RenderingContextBase::
4967 DrawingBufferClientRestorePixelUnpackBufferBinding() { 4968 DrawingBufferClientRestorePixelUnpackBufferBinding() {
4968 if (!contextGL()) 4969 if (!contextGL())
4969 return; 4970 return;
4970 contextGL()->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 4971 contextGL()->BindBuffer(GL_PIXEL_UNPACK_BUFFER,
4971 objectOrZero(m_boundPixelUnpackBuffer.get())); 4972 objectOrZero(m_boundPixelUnpackBuffer.get()));
4972 } 4973 }
4973 4974
4974 } // namespace blink 4975 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698