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