| 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 3823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3834 WebGLFramebuffer* readFramebufferBinding = nullptr; | 3834 WebGLFramebuffer* readFramebufferBinding = nullptr; |
| 3835 GLenum readBufferInternalFormat = 0, readBufferType = 0; | 3835 GLenum readBufferInternalFormat = 0, readBufferType = 0; |
| 3836 if (!validateReadBufferAndGetInfo("readPixels", readFramebufferBinding, &rea
dBufferInternalFormat, &readBufferType)) | 3836 if (!validateReadBufferAndGetInfo("readPixels", readFramebufferBinding, &rea
dBufferInternalFormat, &readBufferType)) |
| 3837 return false; | 3837 return false; |
| 3838 if (!validateReadPixelsFormatTypeCombination(format, type, readBufferInterna
lFormat, readBufferType)) | 3838 if (!validateReadPixelsFormatTypeCombination(format, type, readBufferInterna
lFormat, readBufferType)) |
| 3839 return false; | 3839 return false; |
| 3840 | 3840 |
| 3841 // Calculate array size, taking into consideration of PACK_ALIGNMENT. | 3841 // Calculate array size, taking into consideration of PACK_ALIGNMENT. |
| 3842 unsigned totalBytesRequired = 0; | 3842 unsigned totalBytesRequired = 0; |
| 3843 unsigned padding = 0; | 3843 unsigned padding = 0; |
| 3844 GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, w
idth, height, m_packAlignment, &totalBytesRequired, &padding); | 3844 GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, w
idth, height, 1, m_packAlignment, &totalBytesRequired, &padding); |
| 3845 if (error != GL_NO_ERROR) { | 3845 if (error != GL_NO_ERROR) { |
| 3846 synthesizeGLError(error, "readPixels", "invalid dimensions"); | 3846 synthesizeGLError(error, "readPixels", "invalid dimensions"); |
| 3847 return false; | 3847 return false; |
| 3848 } | 3848 } |
| 3849 if (bufferSize < static_cast<long long>(totalBytesRequired)) { | 3849 if (bufferSize < static_cast<long long>(totalBytesRequired)) { |
| 3850 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "buffer is not lar
ge enough for dimensions"); | 3850 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "buffer is not lar
ge enough for dimensions"); |
| 3851 return false; | 3851 return false; |
| 3852 } | 3852 } |
| 3853 return true; | 3853 return true; |
| 3854 } | 3854 } |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4283 SkPaint paint; | 4283 SkPaint paint; |
| 4284 image->draw(buf->canvas(), paint, destRect, srcRect, DoNotRespectImageOrient
ation, Image::DoNotClampImageToSourceRect); | 4284 image->draw(buf->canvas(), paint, destRect, srcRect, DoNotRespectImageOrient
ation, Image::DoNotClampImageToSourceRect); |
| 4285 return buf->newImageSnapshot(); | 4285 return buf->newImageSnapshot(); |
| 4286 } | 4286 } |
| 4287 | 4287 |
| 4288 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, | 4288 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, |
| 4289 GLsizei width, GLsizei height, GLint border, | 4289 GLsizei width, GLsizei height, GLint border, |
| 4290 GLenum format, GLenum type, DOMArrayBufferView* pixels) | 4290 GLenum format, GLenum type, DOMArrayBufferView* pixels) |
| 4291 { | 4291 { |
| 4292 if (isContextLost() || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour
ceArrayBufferView, target, level, internalformat, width, height, border, format,
type, 0, 0) | 4292 if (isContextLost() || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour
ceArrayBufferView, target, level, internalformat, width, height, border, format,
type, 0, 0) |
| 4293 || !validateTexFuncData("texImage2D", level, width, height, format, type
, pixels, NullAllowed)) | 4293 || !validateTexFuncData("texImage2D", level, width, height, 1, format, t
ype, pixels, NullAllowed)) |
| 4294 return; | 4294 return; |
| 4295 void* data = pixels ? pixels->baseAddress() : 0; | 4295 void* data = pixels ? pixels->baseAddress() : 0; |
| 4296 Vector<uint8_t> tempData; | 4296 Vector<uint8_t> tempData; |
| 4297 bool changeUnpackAlignment = false; | 4297 bool changeUnpackAlignment = false; |
| 4298 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { | 4298 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { |
| 4299 if (!WebGLImageConversion::extractTextureData(width, height, format, typ
e, m_unpackAlignment, m_unpackFlipY, m_unpackPremultiplyAlpha, data, tempData)) | 4299 if (!WebGLImageConversion::extractTextureData(width, height, format, typ
e, m_unpackAlignment, m_unpackFlipY, m_unpackPremultiplyAlpha, data, tempData)) |
| 4300 return; | 4300 return; |
| 4301 data = tempData.data(); | 4301 data = tempData.data(); |
| 4302 changeUnpackAlignment = true; | 4302 changeUnpackAlignment = true; |
| 4303 } | 4303 } |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4607 webContext()->texSubImage2D(target, level, xoffset, yoffset, imageExtractor.
imageWidth(), imageExtractor.imageHeight(), format, type, needConversion ? data
.data() : imagePixelData); | 4607 webContext()->texSubImage2D(target, level, xoffset, yoffset, imageExtractor.
imageWidth(), imageExtractor.imageHeight(), format, type, needConversion ? data
.data() : imagePixelData); |
| 4608 if (m_unpackAlignment != 1) | 4608 if (m_unpackAlignment != 1) |
| 4609 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 4609 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 4610 } | 4610 } |
| 4611 | 4611 |
| 4612 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, | 4612 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, |
| 4613 GLsizei width, GLsizei height, | 4613 GLsizei width, GLsizei height, |
| 4614 GLenum format, GLenum type, DOMArrayBufferView* pixels) | 4614 GLenum format, GLenum type, DOMArrayBufferView* pixels) |
| 4615 { | 4615 { |
| 4616 if (isContextLost() || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour
ceArrayBufferView, target, level, 0, width, height, 0, format, type, xoffset, yo
ffset) | 4616 if (isContextLost() || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour
ceArrayBufferView, target, level, 0, width, height, 0, format, type, xoffset, yo
ffset) |
| 4617 || !validateTexFuncData("texSubImage2D", level, width, height, format, t
ype, pixels, NullNotAllowed)) | 4617 || !validateTexFuncData("texSubImage2D", level, width, height, 1, format
, type, pixels, NullNotAllowed)) |
| 4618 return; | 4618 return; |
| 4619 void* data = pixels->baseAddress(); | 4619 void* data = pixels->baseAddress(); |
| 4620 Vector<uint8_t> tempData; | 4620 Vector<uint8_t> tempData; |
| 4621 bool changeUnpackAlignment = false; | 4621 bool changeUnpackAlignment = false; |
| 4622 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { | 4622 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { |
| 4623 if (!WebGLImageConversion::extractTextureData(width, height, format, typ
e, | 4623 if (!WebGLImageConversion::extractTextureData(width, height, format, typ
e, |
| 4624 m_unpackAlignment, m_unpackFlipY, m_unpackPremultiplyAlpha, data, te
mpData)) | 4624 m_unpackAlignment, m_unpackFlipY, m_unpackPremultiplyAlpha, data, te
mpData)) |
| 4625 return; | 4625 return; |
| 4626 data = tempData.data(); | 4626 data = tempData.data(); |
| 4627 changeUnpackAlignment = true; | 4627 changeUnpackAlignment = true; |
| (...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5707 return false; | 5707 return false; |
| 5708 | 5708 |
| 5709 if (border) { | 5709 if (border) { |
| 5710 synthesizeGLError(GL_INVALID_VALUE, functionName, "border != 0"); | 5710 synthesizeGLError(GL_INVALID_VALUE, functionName, "border != 0"); |
| 5711 return false; | 5711 return false; |
| 5712 } | 5712 } |
| 5713 | 5713 |
| 5714 return true; | 5714 return true; |
| 5715 } | 5715 } |
| 5716 | 5716 |
| 5717 bool WebGLRenderingContextBase::validateTexFuncData(const char* functionName, GL
int level, GLsizei width, GLsizei height, GLenum format, GLenum type, DOMArrayBu
fferView* pixels, NullDisposition disposition) | 5717 bool WebGLRenderingContextBase::validateTexFuncData(const char* functionName, GL
int level, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum t
ype, DOMArrayBufferView* pixels, NullDisposition disposition) |
| 5718 { | 5718 { |
| 5719 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. | 5719 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. |
| 5720 if (!pixels) { | 5720 if (!pixels) { |
| 5721 if (disposition == NullAllowed) | 5721 if (disposition == NullAllowed) |
| 5722 return true; | 5722 return true; |
| 5723 synthesizeGLError(GL_INVALID_VALUE, functionName, "no pixels"); | 5723 synthesizeGLError(GL_INVALID_VALUE, functionName, "no pixels"); |
| 5724 return false; | 5724 return false; |
| 5725 } | 5725 } |
| 5726 | 5726 |
| 5727 if (!validateSettableTexFormat(functionName, format)) | 5727 if (!validateSettableTexFormat(functionName, format)) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5784 if (pixels->type() != DOMArrayBufferView::TypeUint16) { | 5784 if (pixels->type() != DOMArrayBufferView::TypeUint16) { |
| 5785 synthesizeGLError(GL_INVALID_OPERATION, functionName, "type HALF_FLO
AT_OES but ArrayBufferView is not NULL and not Uint16Array"); | 5785 synthesizeGLError(GL_INVALID_OPERATION, functionName, "type HALF_FLO
AT_OES but ArrayBufferView is not NULL and not Uint16Array"); |
| 5786 return false; | 5786 return false; |
| 5787 } | 5787 } |
| 5788 break; | 5788 break; |
| 5789 default: | 5789 default: |
| 5790 ASSERT_NOT_REACHED(); | 5790 ASSERT_NOT_REACHED(); |
| 5791 } | 5791 } |
| 5792 | 5792 |
| 5793 unsigned totalBytesRequired; | 5793 unsigned totalBytesRequired; |
| 5794 GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, w
idth, height, m_unpackAlignment, &totalBytesRequired, 0); | 5794 GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, w
idth, height, depth, m_unpackAlignment, &totalBytesRequired, 0); |
| 5795 if (error != GL_NO_ERROR) { | 5795 if (error != GL_NO_ERROR) { |
| 5796 synthesizeGLError(error, functionName, "invalid texture dimensions"); | 5796 synthesizeGLError(error, functionName, "invalid texture dimensions"); |
| 5797 return false; | 5797 return false; |
| 5798 } | 5798 } |
| 5799 if (pixels->byteLength() < totalBytesRequired) { | 5799 if (pixels->byteLength() < totalBytesRequired) { |
| 5800 if (m_unpackAlignment != 1) { | 5800 if (m_unpackAlignment != 1) { |
| 5801 error = WebGLImageConversion::computeImageSizeInBytes(format, type,
width, height, 1, &totalBytesRequired, 0); | 5801 error = WebGLImageConversion::computeImageSizeInBytes(format, type,
width, height, depth, 1, &totalBytesRequired, 0); |
| 5802 if (pixels->byteLength() == totalBytesRequired) { | 5802 if (pixels->byteLength() == totalBytesRequired) { |
| 5803 synthesizeGLError(GL_INVALID_OPERATION, functionName, "ArrayBuff
erView not big enough for request with UNPACK_ALIGNMENT > 1"); | 5803 synthesizeGLError(GL_INVALID_OPERATION, functionName, "ArrayBuff
erView not big enough for request with UNPACK_ALIGNMENT > 1"); |
| 5804 return false; | 5804 return false; |
| 5805 } | 5805 } |
| 5806 } | 5806 } |
| 5807 synthesizeGLError(GL_INVALID_OPERATION, functionName, "ArrayBufferView n
ot big enough for request"); | 5807 synthesizeGLError(GL_INVALID_OPERATION, functionName, "ArrayBufferView n
ot big enough for request"); |
| 5808 return false; | 5808 return false; |
| 5809 } | 5809 } |
| 5810 return true; | 5810 return true; |
| 5811 } | 5811 } |
| (...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6928 | 6928 |
| 6929 return totalBytesPerPixel; | 6929 return totalBytesPerPixel; |
| 6930 } | 6930 } |
| 6931 | 6931 |
| 6932 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6932 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
| 6933 { | 6933 { |
| 6934 return m_drawingBuffer.get(); | 6934 return m_drawingBuffer.get(); |
| 6935 } | 6935 } |
| 6936 | 6936 |
| 6937 } // namespace blink | 6937 } // namespace blink |
| OLD | NEW |