| 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/frame/ImageBitmap.h" | 8 #include "core/frame/ImageBitmap.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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, | 148 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 WebGL2RenderingContextBase::WebGL2RenderingContextBase( | 151 WebGL2RenderingContextBase::WebGL2RenderingContextBase( |
| 152 HTMLCanvasElement* passedCanvas, | 152 HTMLCanvasElement* passedCanvas, |
| 153 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, | 153 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, |
| 154 const CanvasContextCreationAttributes& requestedAttributes) | 154 const CanvasContextCreationAttributes& requestedAttributes) |
| 155 : WebGLRenderingContextBase(passedCanvas, | 155 : WebGLRenderingContextBase(passedCanvas, |
| 156 std::move(contextProvider), | 156 std::move(contextProvider), |
| 157 requestedAttributes, | 157 requestedAttributes, |
| 158 2) { | 158 2), |
| 159 m_readFramebufferBinding(this, nullptr), |
| 160 m_transformFeedbackBinding(this, nullptr), |
| 161 m_boundCopyReadBuffer(this, nullptr), |
| 162 m_boundCopyWriteBuffer(this, nullptr), |
| 163 m_boundPixelPackBuffer(this, nullptr), |
| 164 m_boundPixelUnpackBuffer(this, nullptr), |
| 165 m_boundTransformFeedbackBuffer(this, nullptr), |
| 166 m_boundUniformBuffer(this, nullptr), |
| 167 m_currentBooleanOcclusionQuery(this, nullptr), |
| 168 m_currentTransformFeedbackPrimitivesWrittenQuery(this, nullptr) { |
| 159 m_supportedInternalFormatsStorage.insert( | 169 m_supportedInternalFormatsStorage.insert( |
| 160 kSupportedInternalFormatsStorage, | 170 kSupportedInternalFormatsStorage, |
| 161 kSupportedInternalFormatsStorage + | 171 kSupportedInternalFormatsStorage + |
| 162 WTF_ARRAY_LENGTH(kSupportedInternalFormatsStorage)); | 172 WTF_ARRAY_LENGTH(kSupportedInternalFormatsStorage)); |
| 163 m_supportedInternalFormatsStorage.insert( | 173 m_supportedInternalFormatsStorage.insert( |
| 164 kCompressedTextureFormatsETC2EAC, | 174 kCompressedTextureFormatsETC2EAC, |
| 165 kCompressedTextureFormatsETC2EAC + | 175 kCompressedTextureFormatsETC2EAC + |
| 166 WTF_ARRAY_LENGTH(kCompressedTextureFormatsETC2EAC)); | 176 WTF_ARRAY_LENGTH(kCompressedTextureFormatsETC2EAC)); |
| 167 m_compressedTextureFormatsETC2EAC.insert( | 177 m_compressedTextureFormatsETC2EAC.insert( |
| 168 kCompressedTextureFormatsETC2EAC, | 178 kCompressedTextureFormatsETC2EAC, |
| (...skipping 2531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2700 "attempted to bind a deleted sampler"); | 2710 "attempted to bind a deleted sampler"); |
| 2701 return; | 2711 return; |
| 2702 } | 2712 } |
| 2703 | 2713 |
| 2704 if (unit >= m_samplerUnits.size()) { | 2714 if (unit >= m_samplerUnits.size()) { |
| 2705 synthesizeGLError(GL_INVALID_VALUE, "bindSampler", | 2715 synthesizeGLError(GL_INVALID_VALUE, "bindSampler", |
| 2706 "texture unit out of range"); | 2716 "texture unit out of range"); |
| 2707 return; | 2717 return; |
| 2708 } | 2718 } |
| 2709 | 2719 |
| 2710 m_samplerUnits[unit] = sampler; | 2720 m_samplerUnits[unit] = TraceWrapperMember<WebGLSampler>(this, sampler); |
| 2711 | 2721 |
| 2712 contextGL()->BindSampler(unit, objectOrZero(sampler)); | 2722 contextGL()->BindSampler(unit, objectOrZero(sampler)); |
| 2713 } | 2723 } |
| 2714 | 2724 |
| 2715 void WebGL2RenderingContextBase::samplerParameter(WebGLSampler* sampler, | 2725 void WebGL2RenderingContextBase::samplerParameter(WebGLSampler* sampler, |
| 2716 GLenum pname, | 2726 GLenum pname, |
| 2717 GLfloat paramf, | 2727 GLfloat paramf, |
| 2718 GLint parami, | 2728 GLint parami, |
| 2719 bool isFloat) { | 2729 bool isFloat) { |
| 2720 if (isContextLost() || !validateWebGLObject("samplerParameter", sampler)) | 2730 if (isContextLost() || !validateWebGLObject("samplerParameter", sampler)) |
| (...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3893 if (buffer && | 3903 if (buffer && |
| 3894 !validateBufferTargetCompatibility(functionName, target, buffer)) | 3904 !validateBufferTargetCompatibility(functionName, target, buffer)) |
| 3895 return false; | 3905 return false; |
| 3896 | 3906 |
| 3897 switch (target) { | 3907 switch (target) { |
| 3898 case GL_TRANSFORM_FEEDBACK_BUFFER: | 3908 case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 3899 if (index >= m_boundIndexedTransformFeedbackBuffers.size()) { | 3909 if (index >= m_boundIndexedTransformFeedbackBuffers.size()) { |
| 3900 synthesizeGLError(GL_INVALID_VALUE, functionName, "index out of range"); | 3910 synthesizeGLError(GL_INVALID_VALUE, functionName, "index out of range"); |
| 3901 return false; | 3911 return false; |
| 3902 } | 3912 } |
| 3903 m_boundIndexedTransformFeedbackBuffers[index] = buffer; | 3913 m_boundIndexedTransformFeedbackBuffers[index] = |
| 3914 TraceWrapperMember<WebGLBuffer>(this, buffer); |
| 3904 m_boundTransformFeedbackBuffer = buffer; | 3915 m_boundTransformFeedbackBuffer = buffer; |
| 3905 break; | 3916 break; |
| 3906 case GL_UNIFORM_BUFFER: | 3917 case GL_UNIFORM_BUFFER: |
| 3907 if (index >= m_boundIndexedUniformBuffers.size()) { | 3918 if (index >= m_boundIndexedUniformBuffers.size()) { |
| 3908 synthesizeGLError(GL_INVALID_VALUE, functionName, "index out of range"); | 3919 synthesizeGLError(GL_INVALID_VALUE, functionName, "index out of range"); |
| 3909 return false; | 3920 return false; |
| 3910 } | 3921 } |
| 3911 m_boundIndexedUniformBuffers[index] = buffer; | 3922 m_boundIndexedUniformBuffers[index] = |
| 3923 TraceWrapperMember<WebGLBuffer>(this, buffer); |
| 3912 m_boundUniformBuffer = buffer; | 3924 m_boundUniformBuffer = buffer; |
| 3913 | 3925 |
| 3914 // Keep track of what the maximum bound uniform buffer index is | 3926 // Keep track of what the maximum bound uniform buffer index is |
| 3915 if (buffer) { | 3927 if (buffer) { |
| 3916 if (index > m_maxBoundUniformBufferIndex) | 3928 if (index > m_maxBoundUniformBufferIndex) |
| 3917 m_maxBoundUniformBufferIndex = index; | 3929 m_maxBoundUniformBufferIndex = index; |
| 3918 } else if (m_maxBoundUniformBufferIndex > 0 && | 3930 } else if (m_maxBoundUniformBufferIndex > 0 && |
| 3919 index == m_maxBoundUniformBufferIndex) { | 3931 index == m_maxBoundUniformBufferIndex) { |
| 3920 size_t i = m_maxBoundUniformBufferIndex - 1; | 3932 size_t i = m_maxBoundUniformBufferIndex - 1; |
| 3921 for (; i > 0; --i) { | 3933 for (; i > 0; --i) { |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4505 params.skipPixels = m_unpackSkipPixels; | 4517 params.skipPixels = m_unpackSkipPixels; |
| 4506 params.skipRows = m_unpackSkipRows; | 4518 params.skipRows = m_unpackSkipRows; |
| 4507 if (dimension == Tex3D) { | 4519 if (dimension == Tex3D) { |
| 4508 params.imageHeight = m_unpackImageHeight; | 4520 params.imageHeight = m_unpackImageHeight; |
| 4509 params.skipImages = m_unpackSkipImages; | 4521 params.skipImages = m_unpackSkipImages; |
| 4510 } | 4522 } |
| 4511 return params; | 4523 return params; |
| 4512 } | 4524 } |
| 4513 | 4525 |
| 4514 } // namespace blink | 4526 } // namespace blink |
| OLD | NEW |