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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 GL_COMPRESSED_RG11_EAC, | 99 GL_COMPRESSED_RG11_EAC, |
100 GL_COMPRESSED_SIGNED_RG11_EAC, | 100 GL_COMPRESSED_SIGNED_RG11_EAC, |
101 GL_COMPRESSED_RGB8_ETC2, | 101 GL_COMPRESSED_RGB8_ETC2, |
102 GL_COMPRESSED_SRGB8_ETC2, | 102 GL_COMPRESSED_SRGB8_ETC2, |
103 GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, | 103 GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, |
104 GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, | 104 GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, |
105 GL_COMPRESSED_RGBA8_ETC2_EAC, | 105 GL_COMPRESSED_RGBA8_ETC2_EAC, |
106 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, | 106 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, |
107 }; | 107 }; |
108 | 108 |
109 const GLenum kCompressedTextureFormatsETC2EAC[] = { | |
110 GL_COMPRESSED_R11_EAC, | |
111 GL_COMPRESSED_SIGNED_R11_EAC, | |
112 GL_COMPRESSED_RG11_EAC, | |
113 GL_COMPRESSED_SIGNED_RG11_EAC, | |
114 GL_COMPRESSED_RGB8_ETC2, | |
115 GL_COMPRESSED_SRGB8_ETC2, | |
116 GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, | |
117 GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, | |
118 GL_COMPRESSED_RGBA8_ETC2_EAC, | |
119 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, | |
120 }; | |
121 | |
109 WebGL2RenderingContextBase::WebGL2RenderingContextBase(HTMLCanvasElement* passed Canvas, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& requestedAttributes) | 122 WebGL2RenderingContextBase::WebGL2RenderingContextBase(HTMLCanvasElement* passed Canvas, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& requestedAttributes) |
110 : WebGLRenderingContextBase(passedCanvas, context, requestedAttributes) | 123 : WebGLRenderingContextBase(passedCanvas, context, requestedAttributes) |
111 { | 124 { |
112 m_supportedInternalFormatsStorage.insert(kSupportedInternalFormatsStorage, k SupportedInternalFormatsStorage + arraysize(kSupportedInternalFormatsStorage)); | 125 m_supportedInternalFormatsStorage.insert(kSupportedInternalFormatsStorage, k SupportedInternalFormatsStorage + arraysize(kSupportedInternalFormatsStorage)); |
126 m_compressedTextureFormatsETC2EAC.insert(kCompressedTextureFormatsETC2EAC, k CompressedTextureFormatsETC2EAC + arraysize(kCompressedTextureFormatsETC2EAC)); | |
113 } | 127 } |
114 | 128 |
115 WebGL2RenderingContextBase::~WebGL2RenderingContextBase() | 129 WebGL2RenderingContextBase::~WebGL2RenderingContextBase() |
116 { | 130 { |
117 m_readFramebufferBinding = nullptr; | 131 m_readFramebufferBinding = nullptr; |
118 | 132 |
119 m_boundCopyReadBuffer = nullptr; | 133 m_boundCopyReadBuffer = nullptr; |
120 m_boundCopyWriteBuffer = nullptr; | 134 m_boundCopyWriteBuffer = nullptr; |
121 m_boundPixelPackBuffer = nullptr; | 135 m_boundPixelPackBuffer = nullptr; |
122 m_boundPixelUnpackBuffer = nullptr; | 136 m_boundPixelUnpackBuffer = nullptr; |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
578 if (target != GL_TEXTURE_3D && target != GL_TEXTURE_2D_ARRAY) { | 592 if (target != GL_TEXTURE_3D && target != GL_TEXTURE_2D_ARRAY) { |
579 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid 3D target" ); | 593 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid 3D target" ); |
580 return false; | 594 return false; |
581 } | 595 } |
582 } | 596 } |
583 | 597 |
584 WebGLTexture* tex = validateTextureBinding(functionName, target, false); | 598 WebGLTexture* tex = validateTextureBinding(functionName, target, false); |
585 if (!tex) | 599 if (!tex) |
586 return false; | 600 return false; |
587 | 601 |
602 if (functionType == TexStorageType3D && target == GL_TEXTURE_3D && m_compres sedTextureFormatsETC2EAC.find(internalformat) != m_compressedTextureFormatsETC2E AC.end()) { | |
603 synthesizeGLError(GL_INVALID_OPERATION, functionName, "invalid ETC2/EAC internalformat for TexStorage3D if target is not TEXTURE_2D_ARRAY"); | |
604 return false; | |
605 } | |
bajones
2015/11/19 19:16:21
A couple of really minor nits here: Could you chan
qiankun
2015/11/19 22:54:08
Done.
| |
606 | |
588 if (m_supportedInternalFormatsStorage.find(internalformat) == m_supportedInt ernalFormatsStorage.end()) { | 607 if (m_supportedInternalFormatsStorage.find(internalformat) == m_supportedInt ernalFormatsStorage.end()) { |
589 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid internalformat "); | 608 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid internalformat "); |
590 return false; | 609 return false; |
591 } | 610 } |
592 | 611 |
593 if (tex->isImmutable()) { | 612 if (tex->isImmutable()) { |
594 synthesizeGLError(GL_INVALID_OPERATION, functionName, "attempted to modi fy immutable texture"); | 613 synthesizeGLError(GL_INVALID_OPERATION, functionName, "attempted to modi fy immutable texture"); |
595 return false; | 614 return false; |
596 } | 615 } |
597 | 616 |
(...skipping 2480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3078 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() | 3097 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() |
3079 { | 3098 { |
3080 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) | 3099 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) |
3081 return m_readFramebufferBinding->colorBufferFormat(); | 3100 return m_readFramebufferBinding->colorBufferFormat(); |
3082 if (m_requestedAttributes.alpha()) | 3101 if (m_requestedAttributes.alpha()) |
3083 return GL_RGBA; | 3102 return GL_RGBA; |
3084 return GL_RGB; | 3103 return GL_RGB; |
3085 } | 3104 } |
3086 | 3105 |
3087 } // namespace blink | 3106 } // namespace blink |
OLD | NEW |