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 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 | 1618 |
1619 void WebGLRenderingContextBase::bufferSubDataImpl(GLenum target, long long offse
t, GLsizeiptr size, const void* data) | 1619 void WebGLRenderingContextBase::bufferSubDataImpl(GLenum target, long long offse
t, GLsizeiptr size, const void* data) |
1620 { | 1620 { |
1621 WebGLBuffer* buffer = validateBufferDataTarget("bufferSubData", target); | 1621 WebGLBuffer* buffer = validateBufferDataTarget("bufferSubData", target); |
1622 if (!buffer) | 1622 if (!buffer) |
1623 return; | 1623 return; |
1624 if (!validateValueFitNonNegInt32("bufferSubData", "offset", offset)) | 1624 if (!validateValueFitNonNegInt32("bufferSubData", "offset", offset)) |
1625 return; | 1625 return; |
1626 if (!data) | 1626 if (!data) |
1627 return; | 1627 return; |
| 1628 if (offset + static_cast<long long>(size) > buffer->getSize()) { |
| 1629 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "buffer overflow"); |
| 1630 return; |
| 1631 } |
1628 | 1632 |
1629 webContext()->bufferSubData(target, static_cast<GLintptr>(offset), size, dat
a); | 1633 webContext()->bufferSubData(target, static_cast<GLintptr>(offset), size, dat
a); |
1630 } | 1634 } |
1631 | 1635 |
1632 void WebGLRenderingContextBase::bufferSubData(GLenum target, long long offset, D
OMArrayBuffer* data) | 1636 void WebGLRenderingContextBase::bufferSubData(GLenum target, long long offset, D
OMArrayBuffer* data) |
1633 { | 1637 { |
1634 if (isContextLost()) | 1638 if (isContextLost()) |
1635 return; | 1639 return; |
1636 if (!data) | 1640 if (!data) |
1637 return; | 1641 return; |
(...skipping 4252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5890 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: | 5894 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
5891 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: | 5895 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
5892 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: | 5896 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: |
5893 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: { | 5897 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: { |
5894 const int kBlockWidth = 4; | 5898 const int kBlockWidth = 4; |
5895 const int kBlockHeight = 4; | 5899 const int kBlockHeight = 4; |
5896 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { | 5900 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { |
5897 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset or yo
ffset not multiple of 4"); | 5901 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset or yo
ffset not multiple of 4"); |
5898 return false; | 5902 return false; |
5899 } | 5903 } |
5900 if (width - xoffset > tex->getWidth(target, level) | 5904 // Before checking if it is in the range, check if overflow happens firs
t. |
5901 || height - yoffset > tex->getHeight(target, level)) { | 5905 Checked<GLint, RecordOverflow> maxX = xoffset, maxY = yoffset; |
5902 synthesizeGLError(GL_INVALID_OPERATION, functionName, "dimensions ou
t of range"); | 5906 maxX += width; |
| 5907 maxY += height; |
| 5908 if (maxX.hasOverflowed() || maxY.hasOverflowed() || maxX.unsafeGet() > t
ex->getWidth(target, level) |
| 5909 || maxY.unsafeGet() > tex->getHeight(target, level)) { |
| 5910 synthesizeGLError(GL_INVALID_VALUE, functionName, "dimensions out of
range"); |
5903 return false; | 5911 return false; |
5904 } | 5912 } |
5905 return validateCompressedTexDimensions(functionName, TexSubImage2D, targ
et, level, width, height, format); | 5913 return validateCompressedTexDimensions(functionName, TexSubImage2D, targ
et, level, width, height, format); |
5906 } | 5914 } |
5907 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: | 5915 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: |
5908 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: | 5916 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: |
5909 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: | 5917 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: |
5910 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: { | 5918 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: { |
5911 if ((xoffset != 0) || (yoffset != 0)) { | 5919 if ((xoffset != 0) || (yoffset != 0)) { |
5912 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset and y
offset must be zero"); | 5920 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset and y
offset must be zero"); |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6721 | 6729 |
6722 return totalBytesPerPixel; | 6730 return totalBytesPerPixel; |
6723 } | 6731 } |
6724 | 6732 |
6725 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6733 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
6726 { | 6734 { |
6727 return m_drawingBuffer.get(); | 6735 return m_drawingBuffer.get(); |
6728 } | 6736 } |
6729 | 6737 |
6730 } // namespace blink | 6738 } // namespace blink |
OLD | NEW |