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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 GL_RGB10_A2UI, | 87 GL_RGB10_A2UI, |
88 GL_RGBA16UI, | 88 GL_RGBA16UI, |
89 GL_RGBA16I, | 89 GL_RGBA16I, |
90 GL_RGBA32UI, | 90 GL_RGBA32UI, |
91 GL_RGBA32I, | 91 GL_RGBA32I, |
92 GL_DEPTH_COMPONENT16, | 92 GL_DEPTH_COMPONENT16, |
93 GL_DEPTH_COMPONENT24, | 93 GL_DEPTH_COMPONENT24, |
94 GL_DEPTH_COMPONENT32F, | 94 GL_DEPTH_COMPONENT32F, |
95 GL_DEPTH24_STENCIL8, | 95 GL_DEPTH24_STENCIL8, |
96 GL_DEPTH32F_STENCIL8, | 96 GL_DEPTH32F_STENCIL8, |
| 97 }; |
| 98 |
| 99 const GLenum kCompressedTextureFormatsETC2EAC[] = { |
97 GL_COMPRESSED_R11_EAC, | 100 GL_COMPRESSED_R11_EAC, |
98 GL_COMPRESSED_SIGNED_R11_EAC, | 101 GL_COMPRESSED_SIGNED_R11_EAC, |
99 GL_COMPRESSED_RG11_EAC, | 102 GL_COMPRESSED_RG11_EAC, |
100 GL_COMPRESSED_SIGNED_RG11_EAC, | 103 GL_COMPRESSED_SIGNED_RG11_EAC, |
101 GL_COMPRESSED_RGB8_ETC2, | 104 GL_COMPRESSED_RGB8_ETC2, |
102 GL_COMPRESSED_SRGB8_ETC2, | 105 GL_COMPRESSED_SRGB8_ETC2, |
103 GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, | 106 GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, |
104 GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, | 107 GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, |
105 GL_COMPRESSED_RGBA8_ETC2_EAC, | 108 GL_COMPRESSED_RGBA8_ETC2_EAC, |
106 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, | 109 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, |
107 }; | 110 }; |
108 | 111 |
109 WebGL2RenderingContextBase::WebGL2RenderingContextBase(HTMLCanvasElement* passed
Canvas, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes&
requestedAttributes) | 112 WebGL2RenderingContextBase::WebGL2RenderingContextBase(HTMLCanvasElement* passed
Canvas, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes&
requestedAttributes) |
110 : WebGLRenderingContextBase(passedCanvas, context, requestedAttributes) | 113 : WebGLRenderingContextBase(passedCanvas, context, requestedAttributes) |
111 { | 114 { |
112 m_supportedInternalFormatsStorage.insert(kSupportedInternalFormatsStorage, k
SupportedInternalFormatsStorage + arraysize(kSupportedInternalFormatsStorage)); | 115 m_supportedInternalFormatsStorage.insert(kSupportedInternalFormatsStorage, k
SupportedInternalFormatsStorage + arraysize(kSupportedInternalFormatsStorage)); |
| 116 m_supportedInternalFormatsStorage.insert(kCompressedTextureFormatsETC2EAC, k
CompressedTextureFormatsETC2EAC + arraysize(kCompressedTextureFormatsETC2EAC)); |
| 117 m_compressedTextureFormatsETC2EAC.insert(kCompressedTextureFormatsETC2EAC, k
CompressedTextureFormatsETC2EAC + arraysize(kCompressedTextureFormatsETC2EAC)); |
113 } | 118 } |
114 | 119 |
115 WebGL2RenderingContextBase::~WebGL2RenderingContextBase() | 120 WebGL2RenderingContextBase::~WebGL2RenderingContextBase() |
116 { | 121 { |
117 m_readFramebufferBinding = nullptr; | 122 m_readFramebufferBinding = nullptr; |
118 | 123 |
119 m_boundCopyReadBuffer = nullptr; | 124 m_boundCopyReadBuffer = nullptr; |
120 m_boundCopyWriteBuffer = nullptr; | 125 m_boundCopyWriteBuffer = nullptr; |
121 m_boundPixelPackBuffer = nullptr; | 126 m_boundPixelPackBuffer = nullptr; |
122 m_boundPixelUnpackBuffer = nullptr; | 127 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) { | 583 if (target != GL_TEXTURE_3D && target != GL_TEXTURE_2D_ARRAY) { |
579 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid 3D target"
); | 584 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid 3D target"
); |
580 return false; | 585 return false; |
581 } | 586 } |
582 } | 587 } |
583 | 588 |
584 WebGLTexture* tex = validateTextureBinding(functionName, target, false); | 589 WebGLTexture* tex = validateTextureBinding(functionName, target, false); |
585 if (!tex) | 590 if (!tex) |
586 return false; | 591 return false; |
587 | 592 |
| 593 if (functionType == TexStorageType3D && target != GL_TEXTURE_2D_ARRAY && m_c
ompressedTextureFormatsETC2EAC.find(internalformat) != m_compressedTextureFormat
sETC2EAC.end()) { |
| 594 synthesizeGLError(GL_INVALID_OPERATION, functionName, "target for ETC2/E
AC internal formats must be TEXTURE_2D_ARRAY"); |
| 595 return false; |
| 596 } |
| 597 |
588 if (m_supportedInternalFormatsStorage.find(internalformat) == m_supportedInt
ernalFormatsStorage.end()) { | 598 if (m_supportedInternalFormatsStorage.find(internalformat) == m_supportedInt
ernalFormatsStorage.end()) { |
589 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid internalformat
"); | 599 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid internalformat
"); |
590 return false; | 600 return false; |
591 } | 601 } |
592 | 602 |
593 if (tex->isImmutable()) { | 603 if (tex->isImmutable()) { |
594 synthesizeGLError(GL_INVALID_OPERATION, functionName, "attempted to modi
fy immutable texture"); | 604 synthesizeGLError(GL_INVALID_OPERATION, functionName, "attempted to modi
fy immutable texture"); |
595 return false; | 605 return false; |
596 } | 606 } |
597 | 607 |
(...skipping 2480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3078 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() | 3088 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() |
3079 { | 3089 { |
3080 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) | 3090 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) |
3081 return m_readFramebufferBinding->colorBufferFormat(); | 3091 return m_readFramebufferBinding->colorBufferFormat(); |
3082 if (m_requestedAttributes.alpha()) | 3092 if (m_requestedAttributes.alpha()) |
3083 return GL_RGBA; | 3093 return GL_RGBA; |
3084 return GL_RGB; | 3094 return GL_RGB; |
3085 } | 3095 } |
3086 | 3096 |
3087 } // namespace blink | 3097 } // namespace blink |
OLD | NEW |