| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 GLint zoffset, | 1015 GLint zoffset, |
| 1016 GLenum format, | 1016 GLenum format, |
| 1017 GLenum type, | 1017 GLenum type, |
| 1018 Image*, | 1018 Image*, |
| 1019 WebGLImageConversion::ImageHtmlDomSource, | 1019 WebGLImageConversion::ImageHtmlDomSource, |
| 1020 bool flipY, | 1020 bool flipY, |
| 1021 bool premultiplyAlpha, | 1021 bool premultiplyAlpha, |
| 1022 const IntRect&, | 1022 const IntRect&, |
| 1023 GLsizei depth, | 1023 GLsizei depth, |
| 1024 GLint unpackImageHeight); | 1024 GLint unpackImageHeight); |
| 1025 template <typename T> |
| 1026 bool validateTexImageSubRectangle(const char* functionName, |
| 1027 T* image, |
| 1028 const IntRect& subRect, |
| 1029 bool* selectingSubRectangle) { |
| 1030 *selectingSubRectangle = image && |
| 1031 !(subRect.x() == 0 && subRect.y() == 0 && |
| 1032 subRect.width() == image->width() && |
| 1033 subRect.height() == image->height()); |
| 1034 // If the source image rect selects anything except the entire |
| 1035 // contents of the image, assert that we're running WebGL 2.0 or |
| 1036 // higher, since this should never happen for WebGL 1.0 (even though |
| 1037 // the code could support it). If the image is null, that will be |
| 1038 // signaled as an error later. |
| 1039 DCHECK(!*selectingSubRectangle || isWebGL2OrHigher()) |
| 1040 << "subRect = (" << subRect.width() << " x " << subRect.height() |
| 1041 << ") @ (" << subRect.x() << ", " << subRect.y() << "), image = (" |
| 1042 << (image ? image->width() : -1) << " x " |
| 1043 << (image ? image->height() : -1) << ")"; |
| 1044 |
| 1045 if (subRect.x() < 0 || subRect.y() < 0 || subRect.maxX() > image->width() || |
| 1046 subRect.maxY() > image->height() || subRect.width() < 0 || |
| 1047 subRect.height() < 0) { |
| 1048 synthesizeGLError(GL_INVALID_OPERATION, functionName, |
| 1049 "source sub-rectangle specified via pixel unpack " |
| 1050 "parameters is invalid"); |
| 1051 return false; |
| 1052 } |
| 1053 return true; |
| 1054 } |
| 1025 | 1055 |
| 1026 // Copy from the source directly to the texture via the gpu, without a | 1056 // Copy from the source directly to the texture via the gpu, without a |
| 1027 // read-back to system memory. Souce could be canvas or imageBitmap. | 1057 // read-back to system memory. Souce could be canvas or imageBitmap. |
| 1028 void texImageByGPU(TexImageByGPUType, | 1058 void texImageByGPU(TexImageByGPUType, |
| 1029 WebGLTexture*, | 1059 WebGLTexture*, |
| 1030 GLenum target, | 1060 GLenum target, |
| 1031 GLint level, | 1061 GLint level, |
| 1032 GLint internalformat, | 1062 GLint internalformat, |
| 1033 GLenum type, | 1063 GLenum type, |
| 1034 GLint xoffset, | 1064 GLint xoffset, |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 GLenum, | 1503 GLenum, |
| 1474 GLint, | 1504 GLint, |
| 1475 GLint, | 1505 GLint, |
| 1476 GLint, | 1506 GLint, |
| 1477 GLenum, | 1507 GLenum, |
| 1478 GLenum, | 1508 GLenum, |
| 1479 GLsizei, | 1509 GLsizei, |
| 1480 GLint, | 1510 GLint, |
| 1481 GLint, | 1511 GLint, |
| 1482 GLint, | 1512 GLint, |
| 1483 ImageData*); | 1513 ImageData*, |
| 1514 const IntRect&); |
| 1484 void texImageHelperHTMLImageElement(TexImageFunctionID, | 1515 void texImageHelperHTMLImageElement(TexImageFunctionID, |
| 1485 GLenum, | 1516 GLenum, |
| 1486 GLint, | 1517 GLint, |
| 1487 GLint, | 1518 GLint, |
| 1488 GLenum, | 1519 GLenum, |
| 1489 GLenum, | 1520 GLenum, |
| 1490 GLint, | 1521 GLint, |
| 1491 GLint, | 1522 GLint, |
| 1492 GLint, | 1523 GLint, |
| 1493 HTMLImageElement*, | 1524 HTMLImageElement*, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1524 GLenum, | 1555 GLenum, |
| 1525 GLenum, | 1556 GLenum, |
| 1526 GLint, | 1557 GLint, |
| 1527 GLint, | 1558 GLint, |
| 1528 GLint, | 1559 GLint, |
| 1529 ImageBitmap*, | 1560 ImageBitmap*, |
| 1530 ExceptionState&); | 1561 ExceptionState&); |
| 1531 static const char* getTexImageFunctionName(TexImageFunctionID); | 1562 static const char* getTexImageFunctionName(TexImageFunctionID); |
| 1532 IntRect sentinelEmptyRect(); | 1563 IntRect sentinelEmptyRect(); |
| 1533 IntRect safeGetImageSize(Image*); | 1564 IntRect safeGetImageSize(Image*); |
| 1565 IntRect getImageDataSize(ImageData*); |
| 1534 | 1566 |
| 1535 // Helper implementing readPixels for WebGL 1.0 and 2.0. | 1567 // Helper implementing readPixels for WebGL 1.0 and 2.0. |
| 1536 void readPixelsHelper(GLint x, | 1568 void readPixelsHelper(GLint x, |
| 1537 GLint y, | 1569 GLint y, |
| 1538 GLsizei width, | 1570 GLsizei width, |
| 1539 GLsizei height, | 1571 GLsizei height, |
| 1540 GLenum format, | 1572 GLenum format, |
| 1541 GLenum type, | 1573 GLenum type, |
| 1542 DOMArrayBufferView* pixels, | 1574 DOMArrayBufferView* pixels, |
| 1543 GLuint offset); | 1575 GLuint offset); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1566 context, | 1598 context, |
| 1567 context->is3d(), | 1599 context->is3d(), |
| 1568 context.is3d()); | 1600 context.is3d()); |
| 1569 | 1601 |
| 1570 } // namespace blink | 1602 } // namespace blink |
| 1571 | 1603 |
| 1572 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS( | 1604 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS( |
| 1573 blink::WebGLRenderingContextBase::TextureUnitState); | 1605 blink::WebGLRenderingContextBase::TextureUnitState); |
| 1574 | 1606 |
| 1575 #endif // WebGLRenderingContextBase_h | 1607 #endif // WebGLRenderingContextBase_h |
| OLD | NEW |