OLD | NEW |
---|---|
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 "config.h" | 5 #include "config.h" |
6 #include "modules/webgl/WebGL2RenderingContextBase.h" | 6 #include "modules/webgl/WebGL2RenderingContextBase.h" |
7 | 7 |
8 #include "bindings/modules/v8/WebGLAny.h" | 8 #include "bindings/modules/v8/WebGLAny.h" |
9 #include "core/html/HTMLCanvasElement.h" | 9 #include "core/html/HTMLCanvasElement.h" |
10 #include "core/html/HTMLImageElement.h" | 10 #include "core/html/HTMLImageElement.h" |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
838 void WebGL2RenderingContextBase::texStorage3D(GLenum target, GLsizei levels, GLe num internalformat, GLsizei width, GLsizei height, GLsizei depth) | 838 void WebGL2RenderingContextBase::texStorage3D(GLenum target, GLsizei levels, GLe num internalformat, GLsizei width, GLsizei height, GLsizei depth) |
839 { | 839 { |
840 if (isContextLost() || !validateTexStorage("texStorage3D", target, levels, i nternalformat, width, height, depth, TexStorageType3D)) | 840 if (isContextLost() || !validateTexStorage("texStorage3D", target, levels, i nternalformat, width, height, depth, TexStorageType3D)) |
841 return; | 841 return; |
842 | 842 |
843 WebGLTexture* tex = validateTextureBinding("texStorage3D", target, false); | 843 WebGLTexture* tex = validateTextureBinding("texStorage3D", target, false); |
844 webContext()->texStorage3D(target, levels, internalformat, width, height, de pth); | 844 webContext()->texStorage3D(target, levels, internalformat, width, height, de pth); |
845 tex->setTexStorageInfo(target, levels, internalformat, width, height, depth) ; | 845 tex->setTexStorageInfo(target, levels, internalformat, width, height, depth) ; |
846 } | 846 } |
847 | 847 |
848 bool WebGL2RenderingContextBase::validateTexImage3D(const char* functionName, GL enum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type) | |
849 { | |
850 if (!validateTexFunc3DTarget(functionName, target)) | |
851 return false; | |
852 | |
853 if (!validateTexFuncLevel(functionName, target, level)) | |
854 return false; | |
855 | |
856 if (!validateTexFuncParameters(functionName, NotTexSubImage2D, target, level , internalformat, width, height, depth, border, format, type)) | |
857 return false; | |
858 | |
859 return true; | |
860 } | |
861 | |
862 void WebGL2RenderingContextBase::texImage3D(GLenum target, GLint level, GLint in ternalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, DOMArrayBufferView* pixels) | 848 void WebGL2RenderingContextBase::texImage3D(GLenum target, GLint level, GLint in ternalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, DOMArrayBufferView* pixels) |
863 { | 849 { |
864 if (isContextLost() || !validateTexImage3D("texImage3D", target, level, inte rnalformat, width, height, depth, border, format, type) | 850 if (isContextLost() || !validateTexFunc3DTarget("texImage3D", target) |
851 || !validateTexFunc("texImage3D", NotTexSubImage2D, SourceArrayBufferVie w, target, level, internalformat, width, height, depth, border, format, type, 0, 0) | |
865 || !validateTexFuncData("texImage3D", level, width, height, depth, forma t, type, pixels, NullAllowed)) | 852 || !validateTexFuncData("texImage3D", level, width, height, depth, forma t, type, pixels, NullAllowed)) |
866 return; | 853 return; |
867 | 854 |
868 void* data = pixels ? pixels->baseAddress() : 0; | 855 void* data = pixels ? pixels->baseAddress() : 0; |
869 Vector<uint8_t> tempData; | 856 Vector<uint8_t> tempData; |
870 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { | 857 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { |
871 // FIXME: WebGLImageConversion needs to be updated to accept image depth . | 858 // FIXME: WebGLImageConversion needs to be updated to accept image depth . |
872 notImplemented(); | 859 notImplemented(); |
873 return; | 860 return; |
874 } | 861 } |
875 | 862 |
876 WebGLTexture* tex = validateTextureBinding("texImage3D", target, true); | 863 WebGLTexture* tex = validateTextureBinding("texImage3D", target, true); |
Zhenyao Mo
2015/12/28 19:30:27
This is done in validateTexFunc().
qiankun
2015/12/29 16:16:58
Add an assert(tex). tex is used below.
| |
877 if (!tex) | 864 if (!tex) |
878 return; | 865 return; |
879 | 866 |
880 if (tex->isImmutable()) { | 867 if (tex->isImmutable()) { |
Zhenyao Mo
2015/12/28 19:30:27
This is also done in validateTexFunc().
qiankun
2015/12/29 16:16:58
Done.
| |
881 synthesizeGLError(GL_INVALID_OPERATION, "texImage3D", "attempted to modi fy immutable texture"); | 868 synthesizeGLError(GL_INVALID_OPERATION, "texImage3D", "attempted to modi fy immutable texture"); |
882 return; | 869 return; |
883 } | 870 } |
884 | 871 |
885 webContext()->texImage3D(target, level, convertTexInternalFormat(internalfor mat, type), width, height, depth, border, format, type, data); | 872 webContext()->texImage3D(target, level, convertTexInternalFormat(internalfor mat, type), width, height, depth, border, format, type, data); |
886 tex->setLevelInfo(target, level, internalformat, width, height, depth, type) ; | 873 tex->setLevelInfo(target, level, internalformat, width, height, depth, type) ; |
887 } | 874 } |
888 | 875 |
889 bool WebGL2RenderingContextBase::validateTexSubImage3D(const char* functionName, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, | 876 bool WebGL2RenderingContextBase::validateTexSubImage3D(const char* functionName, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, |
890 GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth) | 877 GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth) |
(...skipping 2534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3425 | 3412 |
3426 WebGLSampler* sampler = m_samplerUnits[unit]; | 3413 WebGLSampler* sampler = m_samplerUnits[unit]; |
3427 | 3414 |
3428 if (sampler) | 3415 if (sampler) |
3429 return sampler->getSamplerState(); | 3416 return sampler->getSamplerState(); |
3430 | 3417 |
3431 return WebGLRenderingContextBase::getTextureUnitSamplerState(target, unit); | 3418 return WebGLRenderingContextBase::getTextureUnitSamplerState(target, unit); |
3432 } | 3419 } |
3433 | 3420 |
3434 } // namespace blink | 3421 } // namespace blink |
OLD | NEW |