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 "modules/webgl/WebGL2RenderingContextBase.h" | 5 #include "modules/webgl/WebGL2RenderingContextBase.h" |
6 | 6 |
7 #include "bindings/modules/v8/WebGLAny.h" | 7 #include "bindings/modules/v8/WebGLAny.h" |
8 #include "core/html/HTMLCanvasElement.h" | 8 #include "core/html/HTMLCanvasElement.h" |
9 #include "core/html/HTMLImageElement.h" | 9 #include "core/html/HTMLImageElement.h" |
10 #include "core/html/HTMLVideoElement.h" | 10 #include "core/html/HTMLVideoElement.h" |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 void WebGL2RenderingContextBase::texStorage3D(GLenum target, GLsizei levels, GLe
num internalformat, GLsizei width, GLsizei height, GLsizei depth) | 848 void WebGL2RenderingContextBase::texStorage3D(GLenum target, GLsizei levels, GLe
num internalformat, GLsizei width, GLsizei height, GLsizei depth) |
849 { | 849 { |
850 if (isContextLost() || !validateTexStorage("texStorage3D", target, levels, i
nternalformat, width, height, depth, TexStorageType3D)) | 850 if (isContextLost() || !validateTexStorage("texStorage3D", target, levels, i
nternalformat, width, height, depth, TexStorageType3D)) |
851 return; | 851 return; |
852 | 852 |
853 WebGLTexture* tex = validateTextureBinding("texStorage3D", target, false); | 853 WebGLTexture* tex = validateTextureBinding("texStorage3D", target, false); |
854 webContext()->texStorage3D(target, levels, internalformat, width, height, de
pth); | 854 webContext()->texStorage3D(target, levels, internalformat, width, height, de
pth); |
855 tex->setTexStorageInfo(target, levels, internalformat, width, height, depth)
; | 855 tex->setTexStorageInfo(target, levels, internalformat, width, height, depth)
; |
856 } | 856 } |
857 | 857 |
858 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) | |
859 { | |
860 if (!validateTexFunc3DTarget(functionName, target)) | |
861 return false; | |
862 | |
863 if (!validateTexFuncLevel(functionName, target, level)) | |
864 return false; | |
865 | |
866 if (!validateTexFuncParameters(functionName, NotTexSubImage2D, target, level
, internalformat, width, height, depth, border, format, type)) | |
867 return false; | |
868 | |
869 return true; | |
870 } | |
871 | |
872 void WebGL2RenderingContextBase::texImage3D(GLenum target, GLint level, GLint in
ternalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum
format, GLenum type, DOMArrayBufferView* pixels) | 858 void WebGL2RenderingContextBase::texImage3D(GLenum target, GLint level, GLint in
ternalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum
format, GLenum type, DOMArrayBufferView* pixels) |
873 { | 859 { |
874 if (isContextLost() || !validateTexImage3D("texImage3D", target, level, inte
rnalformat, width, height, depth, border, format, type) | 860 if (isContextLost() || !validateTexFunc3DTarget("texImage3D", target) |
| 861 || !validateTexFunc("texImage3D", NotTexSubImage2D, SourceArrayBufferVie
w, target, level, internalformat, width, height, depth, border, format, type, 0,
0, 0) |
875 || !validateTexFuncData("texImage3D", level, width, height, depth, forma
t, type, pixels, NullAllowed)) | 862 || !validateTexFuncData("texImage3D", level, width, height, depth, forma
t, type, pixels, NullAllowed)) |
876 return; | 863 return; |
877 | 864 |
878 void* data = pixels ? pixels->baseAddress() : 0; | 865 void* data = pixels ? pixels->baseAddress() : 0; |
879 Vector<uint8_t> tempData; | 866 Vector<uint8_t> tempData; |
880 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { | 867 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { |
881 // FIXME: WebGLImageConversion needs to be updated to accept image depth
. | 868 // FIXME: WebGLImageConversion needs to be updated to accept image depth
. |
882 notImplemented(); | 869 notImplemented(); |
883 return; | 870 return; |
884 } | 871 } |
885 | 872 |
886 WebGLTexture* tex = validateTextureBinding("texImage3D", target, true); | 873 WebGLTexture* tex = validateTextureBinding("texImage3D", target, true); |
887 if (!tex) | 874 ASSERT(tex); |
888 return; | |
889 | |
890 if (tex->isImmutable()) { | |
891 synthesizeGLError(GL_INVALID_OPERATION, "texImage3D", "attempted to modi
fy immutable texture"); | |
892 return; | |
893 } | |
894 | |
895 webContext()->texImage3D(target, level, convertTexInternalFormat(internalfor
mat, type), width, height, depth, border, format, type, data); | 875 webContext()->texImage3D(target, level, convertTexInternalFormat(internalfor
mat, type), width, height, depth, border, format, type, data); |
896 tex->setLevelInfo(target, level, internalformat, width, height, depth, type)
; | 876 tex->setLevelInfo(target, level, internalformat, width, height, depth, type)
; |
897 } | 877 } |
898 | 878 |
899 bool WebGL2RenderingContextBase::validateTexSubImage3D(const char* functionName,
GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, | 879 bool WebGL2RenderingContextBase::validateTexSubImage3D(const char* functionName,
GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, |
900 GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth) | 880 GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth) |
901 { | 881 { |
902 if (!validateTexFunc3DTarget(functionName, target)) | 882 if (!validateTexFunc3DTarget(functionName, target)) |
903 return false; | 883 return false; |
904 | 884 |
(...skipping 2587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3492 | 3472 |
3493 WebGLSampler* sampler = m_samplerUnits[unit]; | 3473 WebGLSampler* sampler = m_samplerUnits[unit]; |
3494 | 3474 |
3495 if (sampler) | 3475 if (sampler) |
3496 return sampler->getSamplerState(); | 3476 return sampler->getSamplerState(); |
3497 | 3477 |
3498 return WebGLRenderingContextBase::getTextureUnitSamplerState(target, unit); | 3478 return WebGLRenderingContextBase::getTextureUnitSamplerState(target, unit); |
3499 } | 3479 } |
3500 | 3480 |
3501 } // namespace blink | 3481 } // namespace blink |
OLD | NEW |