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

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

Issue 2495953002: Support uploads of sub-rectangles of canvases to 2D and 3D textures. (Closed)
Patch Set: Fixed regression in accelerated video-to-texture uploads. Marked Mac Intel failures. 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 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 default: 756 default:
757 synthesizeGLError(GL_INVALID_ENUM, functionName, 757 synthesizeGLError(GL_INVALID_ENUM, functionName,
758 "invalid attachment"); 758 "invalid attachment");
759 return false; 759 return false;
760 } 760 }
761 } 761 }
762 } 762 }
763 return true; 763 return true;
764 } 764 }
765 765
766 IntRect WebGL2RenderingContextBase::getTextureSourceSubRectangle(
767 GLsizei width,
768 GLsizei height) {
769 return IntRect(m_unpackSkipPixels, m_unpackSkipRows, width, height);
770 }
771
766 bool WebGL2RenderingContextBase::canUseTexImageByGPU( 772 bool WebGL2RenderingContextBase::canUseTexImageByGPU(
767 TexImageFunctionID functionID, 773 TexImageFunctionID functionID,
768 GLint internalformat, 774 GLint internalformat,
769 GLenum type) { 775 GLenum type) {
770 switch (internalformat) { 776 switch (internalformat) {
771 case GL_RGB565: 777 case GL_RGB565:
772 case GL_RGBA4: 778 case GL_RGBA4:
773 case GL_RGB5_A1: 779 case GL_RGB5_A1:
774 // FIXME: ES3 limitation that CopyTexImage with sized internalformat, 780 // FIXME: ES3 limitation that CopyTexImage with sized internalformat,
775 // component sizes have to match the source color format. 781 // component sizes have to match the source color format.
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 void WebGL2RenderingContextBase::texImage2D(GLenum target, 1310 void WebGL2RenderingContextBase::texImage2D(GLenum target,
1305 GLint level, 1311 GLint level,
1306 GLint internalformat, 1312 GLint internalformat,
1307 GLsizei width, 1313 GLsizei width,
1308 GLsizei height, 1314 GLsizei height,
1309 GLint border, 1315 GLint border,
1310 GLenum format, 1316 GLenum format,
1311 GLenum type, 1317 GLenum type,
1312 ImageData* pixels) { 1318 ImageData* pixels) {
1313 DCHECK(pixels); 1319 DCHECK(pixels);
1314 IntRect sourceImageRect;
1315 sourceImageRect.setLocation(IntPoint(m_unpackSkipPixels, m_unpackSkipRows));
1316 sourceImageRect.setSize(IntSize(width, height));
1317 texImageHelperImageData(TexImage2D, target, level, internalformat, 0, format, 1320 texImageHelperImageData(TexImage2D, target, level, internalformat, 0, format,
1318 type, 1, 0, 0, 0, pixels, sourceImageRect, 0); 1321 type, 1, 0, 0, 0, pixels,
1322 getTextureSourceSubRectangle(width, height), 0);
1319 } 1323 }
1320 1324
1321 void WebGL2RenderingContextBase::texImage2D(GLenum target, 1325 void WebGL2RenderingContextBase::texImage2D(GLenum target,
1322 GLint level, 1326 GLint level,
1323 GLint internalformat, 1327 GLint internalformat,
1324 GLsizei width, 1328 GLsizei width,
1325 GLsizei height, 1329 GLsizei height,
1326 GLint border, 1330 GLint border,
1327 GLenum format, 1331 GLenum format,
1328 GLenum type, 1332 GLenum type,
1329 HTMLImageElement* image, 1333 HTMLImageElement* image,
1330 ExceptionState& exceptionState) { 1334 ExceptionState& exceptionState) {
1331 IntRect sourceImageRect;
1332 if (image) {
1333 sourceImageRect.setLocation(IntPoint(m_unpackSkipPixels, m_unpackSkipRows));
1334 sourceImageRect.setSize(IntSize(width, height));
1335 }
1336
1337 texImageHelperHTMLImageElement(TexImage2D, target, level, internalformat, 1335 texImageHelperHTMLImageElement(TexImage2D, target, level, internalformat,
1338 format, type, 0, 0, 0, image, sourceImageRect, 1336 format, type, 0, 0, 0, image,
1339 1, m_unpackImageHeight, exceptionState); 1337 getTextureSourceSubRectangle(width, height), 1,
1338 m_unpackImageHeight, exceptionState);
1340 } 1339 }
1341 1340
1342 void WebGL2RenderingContextBase::texImage2D(GLenum target, 1341 void WebGL2RenderingContextBase::texImage2D(GLenum target,
1343 GLint level, 1342 GLint level,
1344 GLint internalformat, 1343 GLint internalformat,
1345 GLsizei width, 1344 GLsizei width,
1346 GLsizei height, 1345 GLsizei height,
1347 GLint border, 1346 GLint border,
1348 GLenum format, 1347 GLenum format,
1349 GLenum type, 1348 GLenum type,
1350 HTMLCanvasElement* canvas, 1349 HTMLCanvasElement* canvas,
1351 ExceptionState& exceptionState) { 1350 ExceptionState& exceptionState) {
1352 // TODO(zmo): To be implemented. 1351 texImageHelperHTMLCanvasElement(
1352 TexImage2D, target, level, internalformat, format, type, 0, 0, 0, canvas,
1353 getTextureSourceSubRectangle(width, height), 1, 0, exceptionState);
1353 } 1354 }
1354 1355
1355 void WebGL2RenderingContextBase::texImage2D(GLenum target, 1356 void WebGL2RenderingContextBase::texImage2D(GLenum target,
1356 GLint level, 1357 GLint level,
1357 GLint internalformat, 1358 GLint internalformat,
1358 GLsizei width, 1359 GLsizei width,
1359 GLsizei height, 1360 GLsizei height,
1360 GLint border, 1361 GLint border,
1361 GLenum format, 1362 GLenum format,
1362 GLenum type, 1363 GLenum type,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 void WebGL2RenderingContextBase::texSubImage2D(GLenum target, 1464 void WebGL2RenderingContextBase::texSubImage2D(GLenum target,
1464 GLint level, 1465 GLint level,
1465 GLint xoffset, 1466 GLint xoffset,
1466 GLint yoffset, 1467 GLint yoffset,
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 sourceImageRect.setLocation(IntPoint(m_unpackSkipPixels, m_unpackSkipRows));
1475 sourceImageRect.setSize(IntSize(width, height));
1476 texImageHelperImageData(TexSubImage2D, target, level, 0, 0, format, type, 1, 1474 texImageHelperImageData(TexSubImage2D, target, level, 0, 0, format, type, 1,
1477 xoffset, yoffset, 0, pixels, sourceImageRect, 0); 1475 xoffset, yoffset, 0, pixels,
1476 getTextureSourceSubRectangle(width, height), 0);
1478 } 1477 }
1479 1478
1480 void WebGL2RenderingContextBase::texSubImage2D(GLenum target, 1479 void WebGL2RenderingContextBase::texSubImage2D(GLenum target,
1481 GLint level, 1480 GLint level,
1482 GLint xoffset, 1481 GLint xoffset,
1483 GLint yoffset, 1482 GLint yoffset,
1484 GLsizei width, 1483 GLsizei width,
1485 GLsizei height, 1484 GLsizei height,
1486 GLenum format, 1485 GLenum format,
1487 GLenum type, 1486 GLenum type,
1488 HTMLImageElement* image, 1487 HTMLImageElement* image,
1489 ExceptionState& exceptionState) { 1488 ExceptionState& exceptionState) {
1490 IntRect sourceImageRect;
1491 if (image) {
1492 sourceImageRect.setLocation(IntPoint(m_unpackSkipPixels, m_unpackSkipRows));
1493 sourceImageRect.setSize(IntSize(width, height));
1494 }
1495
1496 texImageHelperHTMLImageElement(TexSubImage2D, target, level, 0, format, type, 1489 texImageHelperHTMLImageElement(TexSubImage2D, target, level, 0, format, type,
1497 xoffset, yoffset, 0, image, sourceImageRect, 1, 1490 xoffset, yoffset, 0, image,
1491 getTextureSourceSubRectangle(width, height), 1,
1498 m_unpackImageHeight, exceptionState); 1492 m_unpackImageHeight, exceptionState);
1499 } 1493 }
1500 1494
1501 void WebGL2RenderingContextBase::texSubImage2D(GLenum target, 1495 void WebGL2RenderingContextBase::texSubImage2D(GLenum target,
1502 GLint level, 1496 GLint level,
1503 GLint xoffset, 1497 GLint xoffset,
1504 GLint yoffset, 1498 GLint yoffset,
1505 GLsizei width, 1499 GLsizei width,
1506 GLsizei height, 1500 GLsizei height,
1507 GLenum format, 1501 GLenum format,
1508 GLenum type, 1502 GLenum type,
1509 HTMLCanvasElement* canvas, 1503 HTMLCanvasElement* canvas,
1510 ExceptionState& exceptionState) { 1504 ExceptionState& exceptionState) {
1511 // TODO(zmo): To be implemented. 1505 texImageHelperHTMLCanvasElement(TexSubImage2D, target, level, 0, format, type,
1506 xoffset, yoffset, 0, canvas,
1507 getTextureSourceSubRectangle(width, height),
1508 1, 0, exceptionState);
1512 } 1509 }
1513 1510
1514 void WebGL2RenderingContextBase::texSubImage2D(GLenum target, 1511 void WebGL2RenderingContextBase::texSubImage2D(GLenum target,
1515 GLint level, 1512 GLint level,
1516 GLint xoffset, 1513 GLint xoffset,
1517 GLint yoffset, 1514 GLint yoffset,
1518 GLsizei width, 1515 GLsizei width,
1519 GLsizei height, 1516 GLsizei height,
1520 GLenum format, 1517 GLenum format,
1521 GLenum type, 1518 GLenum type,
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 GLint level, 1707 GLint level,
1711 GLint internalformat, 1708 GLint internalformat,
1712 GLsizei width, 1709 GLsizei width,
1713 GLsizei height, 1710 GLsizei height,
1714 GLsizei depth, 1711 GLsizei depth,
1715 GLint border, 1712 GLint border,
1716 GLenum format, 1713 GLenum format,
1717 GLenum type, 1714 GLenum type,
1718 HTMLImageElement* image, 1715 HTMLImageElement* image,
1719 ExceptionState& exceptionState) { 1716 ExceptionState& exceptionState) {
1720 IntRect sourceImageRect;
1721 if (image) {
1722 sourceImageRect.setLocation(IntPoint(m_unpackSkipPixels, m_unpackSkipRows));
1723 sourceImageRect.setSize(IntSize(width, height));
1724 }
1725
1726 texImageHelperHTMLImageElement(TexImage3D, target, level, internalformat, 1717 texImageHelperHTMLImageElement(TexImage3D, target, level, internalformat,
1727 format, type, 0, 0, 0, image, sourceImageRect, 1718 format, type, 0, 0, 0, image,
1719 getTextureSourceSubRectangle(width, height),
1728 depth, m_unpackImageHeight, exceptionState); 1720 depth, m_unpackImageHeight, exceptionState);
1729 } 1721 }
1730 1722
1731 void WebGL2RenderingContextBase::texImage3D(GLenum target, 1723 void WebGL2RenderingContextBase::texImage3D(GLenum target,
1732 GLint level, 1724 GLint level,
1733 GLint internalformat, 1725 GLint internalformat,
1734 GLsizei width, 1726 GLsizei width,
1735 GLsizei height, 1727 GLsizei height,
1736 GLsizei depth, 1728 GLsizei depth,
1737 GLint border, 1729 GLint border,
1738 GLenum format, 1730 GLenum format,
1739 GLenum type, 1731 GLenum type,
1740 HTMLCanvasElement* canvas, 1732 HTMLCanvasElement* canvas,
1741 ExceptionState& exceptionState) { 1733 ExceptionState& exceptionState) {
1742 // TODO(zmo): To be implemented. 1734 texImageHelperHTMLCanvasElement(TexImage3D, target, level, internalformat,
1735 format, type, 0, 0, 0, canvas,
1736 getTextureSourceSubRectangle(width, height),
1737 depth, m_unpackImageHeight, exceptionState);
1743 } 1738 }
1744 1739
1745 void WebGL2RenderingContextBase::texImage3D(GLenum target, 1740 void WebGL2RenderingContextBase::texImage3D(GLenum target,
1746 GLint level, 1741 GLint level,
1747 GLint internalformat, 1742 GLint internalformat,
1748 GLsizei width, 1743 GLsizei width,
1749 GLsizei height, 1744 GLsizei height,
1750 GLsizei depth, 1745 GLsizei depth,
1751 GLint border, 1746 GLint border,
1752 GLenum format, 1747 GLenum format,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 GLint xoffset, 1839 GLint xoffset,
1845 GLint yoffset, 1840 GLint yoffset,
1846 GLint zoffset, 1841 GLint zoffset,
1847 GLsizei width, 1842 GLsizei width,
1848 GLsizei height, 1843 GLsizei height,
1849 GLsizei depth, 1844 GLsizei depth,
1850 GLenum format, 1845 GLenum format,
1851 GLenum type, 1846 GLenum type,
1852 HTMLImageElement* image, 1847 HTMLImageElement* image,
1853 ExceptionState& exceptionState) { 1848 ExceptionState& exceptionState) {
1854 IntRect sourceImageRect; 1849 texImageHelperHTMLImageElement(TexSubImage3D, target, level, 0, format, type,
1855 if (image) { 1850 xoffset, yoffset, zoffset, image,
1856 sourceImageRect.setLocation(IntPoint(m_unpackSkipPixels, m_unpackSkipRows)); 1851 getTextureSourceSubRectangle(width, height),
1857 sourceImageRect.setSize(IntSize(width, height)); 1852 depth, m_unpackImageHeight, exceptionState);
1858 }
1859
1860 texImageHelperHTMLImageElement(
1861 TexSubImage3D, target, level, 0, format, type, xoffset, yoffset, zoffset,
1862 image, sourceImageRect, depth, m_unpackImageHeight, exceptionState);
1863 } 1853 }
1864 1854
1865 void WebGL2RenderingContextBase::texSubImage3D(GLenum target, 1855 void WebGL2RenderingContextBase::texSubImage3D(GLenum target,
1866 GLint level, 1856 GLint level,
1867 GLint xoffset, 1857 GLint xoffset,
1868 GLint yoffset, 1858 GLint yoffset,
1869 GLint zoffset, 1859 GLint zoffset,
1870 GLsizei width, 1860 GLsizei width,
1871 GLsizei height, 1861 GLsizei height,
1872 GLsizei depth, 1862 GLsizei depth,
1873 GLenum format, 1863 GLenum format,
1874 GLenum type, 1864 GLenum type,
1875 HTMLCanvasElement* canvas, 1865 HTMLCanvasElement* canvas,
1876 ExceptionState& exceptionState) { 1866 ExceptionState& exceptionState) {
1877 // TODO(zmo): To be implemented. 1867 texImageHelperHTMLCanvasElement(TexSubImage3D, target, level, 0, format, type,
1868 xoffset, yoffset, zoffset, canvas,
1869 getTextureSourceSubRectangle(width, height),
1870 depth, m_unpackImageHeight, exceptionState);
1878 } 1871 }
1879 1872
1880 void WebGL2RenderingContextBase::texSubImage3D(GLenum target, 1873 void WebGL2RenderingContextBase::texSubImage3D(GLenum target,
1881 GLint level, 1874 GLint level,
1882 GLint xoffset, 1875 GLint xoffset,
1883 GLint yoffset, 1876 GLint yoffset,
1884 GLint zoffset, 1877 GLint zoffset,
1885 GLsizei width, 1878 GLsizei width,
1886 GLsizei height, 1879 GLsizei height,
1887 GLsizei depth, 1880 GLsizei depth,
(...skipping 19 matching lines...) Expand all
1907 // TODO(zmo): To be implemented. 1900 // TODO(zmo): To be implemented.
1908 } 1901 }
1909 1902
1910 void WebGL2RenderingContextBase::texSubImage3D(GLenum target, 1903 void WebGL2RenderingContextBase::texSubImage3D(GLenum target,
1911 GLint level, 1904 GLint level,
1912 GLint xoffset, 1905 GLint xoffset,
1913 GLint yoffset, 1906 GLint yoffset,
1914 GLint zoffset, 1907 GLint zoffset,
1915 GLenum format, 1908 GLenum format,
1916 GLenum type, 1909 GLenum type,
1917 HTMLCanvasElement* canvas,
1918 ExceptionState& exceptionState) {
1919 texImageHelperHTMLCanvasElement(TexSubImage3D, target, level, 0, format, type,
1920 xoffset, yoffset, zoffset, canvas,
1921 exceptionState);
1922 }
1923
1924 void WebGL2RenderingContextBase::texSubImage3D(GLenum target,
1925 GLint level,
1926 GLint xoffset,
1927 GLint yoffset,
1928 GLint zoffset,
1929 GLenum format,
1930 GLenum type,
1931 HTMLVideoElement* video, 1910 HTMLVideoElement* video,
1932 ExceptionState& exceptionState) { 1911 ExceptionState& exceptionState) {
1933 texImageHelperHTMLVideoElement(TexSubImage3D, target, level, 0, format, type, 1912 texImageHelperHTMLVideoElement(TexSubImage3D, target, level, 0, format, type,
1934 xoffset, yoffset, zoffset, video, 1913 xoffset, yoffset, zoffset, video,
1935 exceptionState); 1914 exceptionState);
1936 } 1915 }
1937 1916
1938 void WebGL2RenderingContextBase::texSubImage3D(GLenum target, 1917 void WebGL2RenderingContextBase::texSubImage3D(GLenum target,
1939 GLint level, 1918 GLint level,
1940 GLint xoffset, 1919 GLint xoffset,
(...skipping 3027 matching lines...) Expand 10 before | Expand all | Expand 10 after
4968 4947
4969 void WebGL2RenderingContextBase:: 4948 void WebGL2RenderingContextBase::
4970 DrawingBufferClientRestorePixelUnpackBufferBinding() { 4949 DrawingBufferClientRestorePixelUnpackBufferBinding() {
4971 if (!contextGL()) 4950 if (!contextGL())
4972 return; 4951 return;
4973 contextGL()->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 4952 contextGL()->BindBuffer(GL_PIXEL_UNPACK_BUFFER,
4974 objectOrZero(m_boundPixelUnpackBuffer.get())); 4953 objectOrZero(m_boundPixelUnpackBuffer.get()));
4975 } 4954 }
4976 4955
4977 } // namespace blink 4956 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698