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 4266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4277 SkPaint paint; | 4277 SkPaint paint; |
4278 image->draw(buf->canvas(), paint, destRect, srcRect, DoNotRespectImageOrient ation, Image::DoNotClampImageToSourceRect); | 4278 image->draw(buf->canvas(), paint, destRect, srcRect, DoNotRespectImageOrient ation, Image::DoNotClampImageToSourceRect); |
4279 return buf->newImageSnapshot(); | 4279 return buf->newImageSnapshot(); |
4280 } | 4280 } |
4281 | 4281 |
4282 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat, | 4282 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat, |
4283 GLsizei width, GLsizei height, GLint border, | 4283 GLsizei width, GLsizei height, GLint border, |
4284 GLenum format, GLenum type, DOMArrayBufferView* pixels) | 4284 GLenum format, GLenum type, DOMArrayBufferView* pixels) |
4285 { | 4285 { |
4286 if (isContextLost() || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour ceArrayBufferView, target, level, internalformat, width, height, border, format, type, 0, 0) | 4286 if (isContextLost() || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour ceArrayBufferView, target, level, internalformat, width, height, border, format, type, 0, 0) |
4287 || !validateTexFuncData("texImage2D", level, width, height, format, type , pixels, NullAllowed)) | 4287 || !validateTexFuncData("texImage2D", level, width, height, 1, format, t ype, pixels, NullAllowed)) |
4288 return; | 4288 return; |
4289 void* data = pixels ? pixels->baseAddress() : 0; | 4289 void* data = pixels ? pixels->baseAddress() : 0; |
4290 Vector<uint8_t> tempData; | 4290 Vector<uint8_t> tempData; |
4291 bool changeUnpackAlignment = false; | 4291 bool changeUnpackAlignment = false; |
4292 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { | 4292 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { |
4293 if (!WebGLImageConversion::extractTextureData(width, height, format, typ e, m_unpackAlignment, m_unpackFlipY, m_unpackPremultiplyAlpha, data, tempData)) | 4293 if (!WebGLImageConversion::extractTextureData(width, height, format, typ e, m_unpackAlignment, m_unpackFlipY, m_unpackPremultiplyAlpha, data, tempData)) |
4294 return; | 4294 return; |
4295 data = tempData.data(); | 4295 data = tempData.data(); |
4296 changeUnpackAlignment = true; | 4296 changeUnpackAlignment = true; |
4297 } | 4297 } |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4601 webContext()->texSubImage2D(target, level, xoffset, yoffset, imageExtractor. imageWidth(), imageExtractor.imageHeight(), format, type, needConversion ? data .data() : imagePixelData); | 4601 webContext()->texSubImage2D(target, level, xoffset, yoffset, imageExtractor. imageWidth(), imageExtractor.imageHeight(), format, type, needConversion ? data .data() : imagePixelData); |
4602 if (m_unpackAlignment != 1) | 4602 if (m_unpackAlignment != 1) |
4603 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 4603 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
4604 } | 4604 } |
4605 | 4605 |
4606 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 4606 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
4607 GLsizei width, GLsizei height, | 4607 GLsizei width, GLsizei height, |
4608 GLenum format, GLenum type, DOMArrayBufferView* pixels) | 4608 GLenum format, GLenum type, DOMArrayBufferView* pixels) |
4609 { | 4609 { |
4610 if (isContextLost() || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour ceArrayBufferView, target, level, 0, width, height, 0, format, type, xoffset, yo ffset) | 4610 if (isContextLost() || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour ceArrayBufferView, target, level, 0, width, height, 0, format, type, xoffset, yo ffset) |
4611 || !validateTexFuncData("texSubImage2D", level, width, height, format, t ype, pixels, NullNotAllowed)) | 4611 || !validateTexFuncData("texSubImage2D", level, width, height, 1, format , type, pixels, NullNotAllowed)) |
4612 return; | 4612 return; |
4613 void* data = pixels->baseAddress(); | 4613 void* data = pixels->baseAddress(); |
4614 Vector<uint8_t> tempData; | 4614 Vector<uint8_t> tempData; |
4615 bool changeUnpackAlignment = false; | 4615 bool changeUnpackAlignment = false; |
4616 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { | 4616 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { |
4617 if (!WebGLImageConversion::extractTextureData(width, height, format, typ e, | 4617 if (!WebGLImageConversion::extractTextureData(width, height, format, typ e, |
4618 m_unpackAlignment, m_unpackFlipY, m_unpackPremultiplyAlpha, data, te mpData)) | 4618 m_unpackAlignment, m_unpackFlipY, m_unpackPremultiplyAlpha, data, te mpData)) |
4619 return; | 4619 return; |
4620 data = tempData.data(); | 4620 data = tempData.data(); |
4621 changeUnpackAlignment = true; | 4621 changeUnpackAlignment = true; |
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5692 return false; | 5692 return false; |
5693 | 5693 |
5694 if (border) { | 5694 if (border) { |
5695 synthesizeGLError(GL_INVALID_VALUE, functionName, "border != 0"); | 5695 synthesizeGLError(GL_INVALID_VALUE, functionName, "border != 0"); |
5696 return false; | 5696 return false; |
5697 } | 5697 } |
5698 | 5698 |
5699 return true; | 5699 return true; |
5700 } | 5700 } |
5701 | 5701 |
5702 bool WebGLRenderingContextBase::validateTexFuncData(const char* functionName, GL int level, GLsizei width, GLsizei height, GLenum format, GLenum type, DOMArrayBu fferView* pixels, NullDisposition disposition) | 5702 bool WebGLRenderingContextBase::validateTexFuncData(const char* functionName, GL int level, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum t ype, DOMArrayBufferView* pixels, NullDisposition disposition) |
5703 { | 5703 { |
5704 // All calling functions check isContextLost, so a duplicate check is not ne eded here. | 5704 // All calling functions check isContextLost, so a duplicate check is not ne eded here. |
5705 if (!pixels) { | 5705 if (!pixels) { |
5706 if (disposition == NullAllowed) | 5706 if (disposition == NullAllowed) |
5707 return true; | 5707 return true; |
5708 synthesizeGLError(GL_INVALID_VALUE, functionName, "no pixels"); | 5708 synthesizeGLError(GL_INVALID_VALUE, functionName, "no pixels"); |
5709 return false; | 5709 return false; |
5710 } | 5710 } |
5711 | 5711 |
5712 if (!validateSettableTexFormat(functionName, format)) | 5712 if (!validateSettableTexFormat(functionName, format)) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5770 synthesizeGLError(GL_INVALID_OPERATION, functionName, "type HALF_FLO AT_OES but ArrayBufferView is not NULL and not Uint16Array"); | 5770 synthesizeGLError(GL_INVALID_OPERATION, functionName, "type HALF_FLO AT_OES but ArrayBufferView is not NULL and not Uint16Array"); |
5771 return false; | 5771 return false; |
5772 } | 5772 } |
5773 break; | 5773 break; |
5774 default: | 5774 default: |
5775 ASSERT_NOT_REACHED(); | 5775 ASSERT_NOT_REACHED(); |
5776 } | 5776 } |
5777 | 5777 |
5778 unsigned totalBytesRequired; | 5778 unsigned totalBytesRequired; |
5779 GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, w idth, height, m_unpackAlignment, &totalBytesRequired, 0); | 5779 GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, w idth, height, m_unpackAlignment, &totalBytesRequired, 0); |
5780 totalBytesRequired *= depth; | |
Zhenyao Mo
2015/11/12 02:01:20
This is a bad hack. You should add the |depth| in
qiankun
2015/11/12 05:46:19
Thanks. I passed depth to WebGLImageConversion::c
| |
5780 if (error != GL_NO_ERROR) { | 5781 if (error != GL_NO_ERROR) { |
5781 synthesizeGLError(error, functionName, "invalid texture dimensions"); | 5782 synthesizeGLError(error, functionName, "invalid texture dimensions"); |
5782 return false; | 5783 return false; |
5783 } | 5784 } |
5784 if (pixels->byteLength() < totalBytesRequired) { | 5785 if (pixels->byteLength() < totalBytesRequired) { |
5785 if (m_unpackAlignment != 1) { | 5786 if (m_unpackAlignment != 1) { |
5786 error = WebGLImageConversion::computeImageSizeInBytes(format, type, width, height, 1, &totalBytesRequired, 0); | 5787 error = WebGLImageConversion::computeImageSizeInBytes(format, type, width, height, 1, &totalBytesRequired, 0); |
5788 totalBytesRequired *= depth; | |
5787 if (pixels->byteLength() == totalBytesRequired) { | 5789 if (pixels->byteLength() == totalBytesRequired) { |
5788 synthesizeGLError(GL_INVALID_OPERATION, functionName, "ArrayBuff erView not big enough for request with UNPACK_ALIGNMENT > 1"); | 5790 synthesizeGLError(GL_INVALID_OPERATION, functionName, "ArrayBuff erView not big enough for request with UNPACK_ALIGNMENT > 1"); |
5789 return false; | 5791 return false; |
5790 } | 5792 } |
5791 } | 5793 } |
5792 synthesizeGLError(GL_INVALID_OPERATION, functionName, "ArrayBufferView n ot big enough for request"); | 5794 synthesizeGLError(GL_INVALID_OPERATION, functionName, "ArrayBufferView n ot big enough for request"); |
5793 return false; | 5795 return false; |
5794 } | 5796 } |
5795 return true; | 5797 return true; |
5796 } | 5798 } |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6913 | 6915 |
6914 return totalBytesPerPixel; | 6916 return totalBytesPerPixel; |
6915 } | 6917 } |
6916 | 6918 |
6917 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6919 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
6918 { | 6920 { |
6919 return m_drawingBuffer.get(); | 6921 return m_drawingBuffer.get(); |
6920 } | 6922 } |
6921 | 6923 |
6922 } // namespace blink | 6924 } // namespace blink |
OLD | NEW |