| 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/dom/DOMException.h" | 8 #include "core/dom/DOMException.h" |
| 9 #include "core/frame/ImageBitmap.h" | 9 #include "core/frame/ImageBitmap.h" |
| 10 #include "core/html/HTMLCanvasElement.h" | 10 #include "core/html/HTMLCanvasElement.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "wtf/PtrUtil.h" | 31 #include "wtf/PtrUtil.h" |
| 32 #include "wtf/text/WTFString.h" | 32 #include "wtf/text/WTFString.h" |
| 33 #include <memory> | 33 #include <memory> |
| 34 | 34 |
| 35 using WTF::String; | 35 using WTF::String; |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 namespace { | 39 namespace { |
| 40 | 40 |
| 41 const GLuint64 kMaxClientWaitTimeout = 0u; |
| 42 |
| 41 GLsync syncObjectOrZero(const WebGLSync* object) { | 43 GLsync syncObjectOrZero(const WebGLSync* object) { |
| 42 return object ? object->object() : nullptr; | 44 return object ? object->object() : nullptr; |
| 43 } | 45 } |
| 44 | 46 |
| 45 // TODO(kainino): Change outByteLength to GLuint and change the associated | 47 // TODO(kainino): Change outByteLength to GLuint and change the associated |
| 46 // range checking (and all uses) - overflow becomes possible in cases below | 48 // range checking (and all uses) - overflow becomes possible in cases below |
| 47 bool validateSubSourceAndGetData(DOMArrayBufferView* view, | 49 bool validateSubSourceAndGetData(DOMArrayBufferView* view, |
| 48 GLuint subOffset, | 50 GLuint subOffset, |
| 49 GLuint subLength, | 51 GLuint subLength, |
| 50 void** outBaseAddress, | 52 void** outBaseAddress, |
| (...skipping 3028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3079 | 3081 |
| 3080 return contextGL()->IsSync(sync->object()); | 3082 return contextGL()->IsSync(sync->object()); |
| 3081 } | 3083 } |
| 3082 | 3084 |
| 3083 void WebGL2RenderingContextBase::deleteSync(WebGLSync* sync) { | 3085 void WebGL2RenderingContextBase::deleteSync(WebGLSync* sync) { |
| 3084 deleteObject(sync); | 3086 deleteObject(sync); |
| 3085 } | 3087 } |
| 3086 | 3088 |
| 3087 GLenum WebGL2RenderingContextBase::clientWaitSync(WebGLSync* sync, | 3089 GLenum WebGL2RenderingContextBase::clientWaitSync(WebGLSync* sync, |
| 3088 GLbitfield flags, | 3090 GLbitfield flags, |
| 3089 GLint64 timeout) { | 3091 GLuint64 timeout) { |
| 3090 if (isContextLost() || !validateWebGLObject("clientWaitSync", sync)) | 3092 if (isContextLost() || !validateWebGLObject("clientWaitSync", sync)) |
| 3091 return GL_WAIT_FAILED; | 3093 return GL_WAIT_FAILED; |
| 3092 | 3094 |
| 3093 if (timeout < -1) { | 3095 if (timeout > kMaxClientWaitTimeout) { |
| 3094 synthesizeGLError(GL_INVALID_VALUE, "clientWaitSync", "timeout < -1"); | 3096 synthesizeGLError(GL_INVALID_OPERATION, "clientWaitSync", |
| 3097 "timeout > MAX_CLIENT_WAIT_TIMEOUT_WEBGL"); |
| 3095 return GL_WAIT_FAILED; | 3098 return GL_WAIT_FAILED; |
| 3096 } | 3099 } |
| 3097 | 3100 |
| 3098 GLuint64 timeout64 = | 3101 return contextGL()->ClientWaitSync(syncObjectOrZero(sync), flags, timeout); |
| 3099 timeout == -1 ? GL_TIMEOUT_IGNORED : static_cast<GLuint64>(timeout); | |
| 3100 return contextGL()->ClientWaitSync(syncObjectOrZero(sync), flags, timeout64); | |
| 3101 } | 3102 } |
| 3102 | 3103 |
| 3103 void WebGL2RenderingContextBase::waitSync(WebGLSync* sync, | 3104 void WebGL2RenderingContextBase::waitSync(WebGLSync* sync, |
| 3104 GLbitfield flags, | 3105 GLbitfield flags, |
| 3105 GLint64 timeout) { | 3106 GLint64 timeout) { |
| 3106 if (isContextLost() || !validateWebGLObject("waitSync", sync)) | 3107 if (isContextLost() || !validateWebGLObject("waitSync", sync)) |
| 3107 return; | 3108 return; |
| 3108 | 3109 |
| 3109 if (timeout < -1) { | 3110 if (flags) { |
| 3110 synthesizeGLError(GL_INVALID_VALUE, "waitSync", "timeout < -1"); | 3111 synthesizeGLError(GL_INVALID_VALUE, "waitSync", "invalid flags"); |
| 3111 return; | 3112 return; |
| 3112 } | 3113 } |
| 3113 | 3114 |
| 3114 GLuint64 timeout64 = | 3115 if (timeout != -1) { |
| 3115 timeout == -1 ? GL_TIMEOUT_IGNORED : static_cast<GLuint64>(timeout); | 3116 synthesizeGLError(GL_INVALID_VALUE, "waitSync", "invalid timeout"); |
| 3116 contextGL()->WaitSync(syncObjectOrZero(sync), flags, timeout64); | 3117 return; |
| 3118 } |
| 3119 |
| 3120 // This is intentionally changed to an no-op in WebGL2. |
| 3117 } | 3121 } |
| 3118 | 3122 |
| 3119 ScriptValue WebGL2RenderingContextBase::getSyncParameter( | 3123 ScriptValue WebGL2RenderingContextBase::getSyncParameter( |
| 3120 ScriptState* scriptState, | 3124 ScriptState* scriptState, |
| 3121 WebGLSync* sync, | 3125 WebGLSync* sync, |
| 3122 GLenum pname) { | 3126 GLenum pname) { |
| 3123 if (isContextLost() || !validateWebGLObject("getSyncParameter", sync)) | 3127 if (isContextLost() || !validateWebGLObject("getSyncParameter", sync)) |
| 3124 return ScriptValue::createNull(scriptState); | 3128 return ScriptValue::createNull(scriptState); |
| 3125 | 3129 |
| 3126 switch (pname) { | 3130 switch (pname) { |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3779 return WebGLAny(scriptState, m_boundCopyWriteBuffer.get()); | 3783 return WebGLAny(scriptState, m_boundCopyWriteBuffer.get()); |
| 3780 case GL_DRAW_FRAMEBUFFER_BINDING: | 3784 case GL_DRAW_FRAMEBUFFER_BINDING: |
| 3781 return WebGLAny(scriptState, m_framebufferBinding.get()); | 3785 return WebGLAny(scriptState, m_framebufferBinding.get()); |
| 3782 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT: | 3786 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT: |
| 3783 return getUnsignedIntParameter(scriptState, pname); | 3787 return getUnsignedIntParameter(scriptState, pname); |
| 3784 case GL_MAX_3D_TEXTURE_SIZE: | 3788 case GL_MAX_3D_TEXTURE_SIZE: |
| 3785 return getIntParameter(scriptState, pname); | 3789 return getIntParameter(scriptState, pname); |
| 3786 case GL_MAX_ARRAY_TEXTURE_LAYERS: | 3790 case GL_MAX_ARRAY_TEXTURE_LAYERS: |
| 3787 return getIntParameter(scriptState, pname); | 3791 return getIntParameter(scriptState, pname); |
| 3788 case GC3D_MAX_CLIENT_WAIT_TIMEOUT_WEBGL: | 3792 case GC3D_MAX_CLIENT_WAIT_TIMEOUT_WEBGL: |
| 3789 return WebGLAny(scriptState, 0u); | 3793 return WebGLAny(scriptState, kMaxClientWaitTimeout); |
| 3790 case GL_MAX_COLOR_ATTACHMENTS: | 3794 case GL_MAX_COLOR_ATTACHMENTS: |
| 3791 return getIntParameter(scriptState, pname); | 3795 return getIntParameter(scriptState, pname); |
| 3792 case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: | 3796 case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: |
| 3793 return getInt64Parameter(scriptState, pname); | 3797 return getInt64Parameter(scriptState, pname); |
| 3794 case GL_MAX_COMBINED_UNIFORM_BLOCKS: | 3798 case GL_MAX_COMBINED_UNIFORM_BLOCKS: |
| 3795 return getIntParameter(scriptState, pname); | 3799 return getIntParameter(scriptState, pname); |
| 3796 case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: | 3800 case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: |
| 3797 return getInt64Parameter(scriptState, pname); | 3801 return getInt64Parameter(scriptState, pname); |
| 3798 case GL_MAX_DRAW_BUFFERS: | 3802 case GL_MAX_DRAW_BUFFERS: |
| 3799 return getIntParameter(scriptState, pname); | 3803 return getIntParameter(scriptState, pname); |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4805 | 4809 |
| 4806 void WebGL2RenderingContextBase:: | 4810 void WebGL2RenderingContextBase:: |
| 4807 DrawingBufferClientRestorePixelUnpackBufferBinding() { | 4811 DrawingBufferClientRestorePixelUnpackBufferBinding() { |
| 4808 if (!contextGL()) | 4812 if (!contextGL()) |
| 4809 return; | 4813 return; |
| 4810 contextGL()->BindBuffer(GL_PIXEL_UNPACK_BUFFER, | 4814 contextGL()->BindBuffer(GL_PIXEL_UNPACK_BUFFER, |
| 4811 objectOrZero(m_boundPixelUnpackBuffer.get())); | 4815 objectOrZero(m_boundPixelUnpackBuffer.get())); |
| 4812 } | 4816 } |
| 4813 | 4817 |
| 4814 } // namespace blink | 4818 } // namespace blink |
| OLD | NEW |