| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #include "modules/webgl/WebGLRenderingContextBase.h" | 26 #include "modules/webgl/WebGLRenderingContextBase.h" |
| 27 | 27 |
| 28 #include <memory> | 28 #include <memory> |
| 29 #include "bindings/core/v8/ExceptionMessages.h" | 29 #include "bindings/core/v8/ExceptionMessages.h" |
| 30 #include "bindings/core/v8/ExceptionState.h" | 30 #include "bindings/core/v8/ExceptionState.h" |
| 31 #include "bindings/core/v8/ScriptWrappableVisitor.h" | 31 #include "bindings/core/v8/ScriptWrappableVisitor.h" |
| 32 #include "bindings/core/v8/V8BindingMacros.h" | 32 #include "bindings/core/v8/V8BindingMacros.h" |
| 33 #include "bindings/modules/v8/HTMLCanvasElementOrOffscreenCanvas.h" | 33 #include "bindings/modules/v8/HTMLCanvasElementOrOffscreenCanvas.h" |
| 34 #include "bindings/modules/v8/WebGLAny.h" | 34 #include "bindings/modules/v8/WebGLAny.h" |
| 35 #include "core/dom/ArrayBufferViewHelpers.h" |
| 35 #include "core/dom/DOMArrayBuffer.h" | 36 #include "core/dom/DOMArrayBuffer.h" |
| 36 #include "core/dom/DOMTypedArray.h" | 37 #include "core/dom/DOMTypedArray.h" |
| 37 #include "core/dom/ExecutionContext.h" | 38 #include "core/dom/ExecutionContext.h" |
| 38 #include "core/dom/FlexibleArrayBufferView.h" | 39 #include "core/dom/FlexibleArrayBufferView.h" |
| 39 #include "core/dom/TaskRunnerHelper.h" | 40 #include "core/dom/TaskRunnerHelper.h" |
| 40 #include "core/frame/ImageBitmap.h" | 41 #include "core/frame/ImageBitmap.h" |
| 41 #include "core/frame/LocalFrame.h" | 42 #include "core/frame/LocalFrame.h" |
| 42 #include "core/frame/LocalFrameClient.h" | 43 #include "core/frame/LocalFrameClient.h" |
| 43 #include "core/frame/Settings.h" | 44 #include "core/frame/Settings.h" |
| 44 #include "core/html/HTMLCanvasElement.h" | 45 #include "core/html/HTMLCanvasElement.h" |
| (...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1897 if (isContextLost()) | 1898 if (isContextLost()) |
| 1898 return; | 1899 return; |
| 1899 if (!data) { | 1900 if (!data) { |
| 1900 SynthesizeGLError(GL_INVALID_VALUE, "bufferData", "no data"); | 1901 SynthesizeGLError(GL_INVALID_VALUE, "bufferData", "no data"); |
| 1901 return; | 1902 return; |
| 1902 } | 1903 } |
| 1903 BufferDataImpl(target, data->ByteLength(), data->Data(), usage); | 1904 BufferDataImpl(target, data->ByteLength(), data->Data(), usage); |
| 1904 } | 1905 } |
| 1905 | 1906 |
| 1906 void WebGLRenderingContextBase::bufferData(GLenum target, | 1907 void WebGLRenderingContextBase::bufferData(GLenum target, |
| 1907 NotShared<DOMArrayBufferView> data, | 1908 MaybeShared<DOMArrayBufferView> data, |
| 1908 GLenum usage) { | 1909 GLenum usage) { |
| 1909 if (isContextLost()) | 1910 if (isContextLost()) |
| 1910 return; | 1911 return; |
| 1911 DCHECK(data); | 1912 DCHECK(data); |
| 1912 BufferDataImpl(target, data.View()->byteLength(), data.View()->BaseAddress(), | 1913 BufferDataImpl(target, data.View()->byteLength(), |
| 1913 usage); | 1914 data.View()->BaseAddressMaybeShared(), usage); |
| 1914 } | 1915 } |
| 1915 | 1916 |
| 1916 void WebGLRenderingContextBase::BufferSubDataImpl(GLenum target, | 1917 void WebGLRenderingContextBase::BufferSubDataImpl(GLenum target, |
| 1917 long long offset, | 1918 long long offset, |
| 1918 GLsizeiptr size, | 1919 GLsizeiptr size, |
| 1919 const void* data) { | 1920 const void* data) { |
| 1920 WebGLBuffer* buffer = ValidateBufferDataTarget("bufferSubData", target); | 1921 WebGLBuffer* buffer = ValidateBufferDataTarget("bufferSubData", target); |
| 1921 if (!buffer) | 1922 if (!buffer) |
| 1922 return; | 1923 return; |
| 1923 if (!ValidateValueFitNonNegInt32("bufferSubData", "offset", offset)) | 1924 if (!ValidateValueFitNonNegInt32("bufferSubData", "offset", offset)) |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2077 ContextGL()->CompileShader(ObjectOrZero(shader)); | 2078 ContextGL()->CompileShader(ObjectOrZero(shader)); |
| 2078 } | 2079 } |
| 2079 | 2080 |
| 2080 void WebGLRenderingContextBase::compressedTexImage2D( | 2081 void WebGLRenderingContextBase::compressedTexImage2D( |
| 2081 GLenum target, | 2082 GLenum target, |
| 2082 GLint level, | 2083 GLint level, |
| 2083 GLenum internalformat, | 2084 GLenum internalformat, |
| 2084 GLsizei width, | 2085 GLsizei width, |
| 2085 GLsizei height, | 2086 GLsizei height, |
| 2086 GLint border, | 2087 GLint border, |
| 2087 NotShared<DOMArrayBufferView> data) { | 2088 MaybeShared<DOMArrayBufferView> data) { |
| 2088 if (isContextLost()) | 2089 if (isContextLost()) |
| 2089 return; | 2090 return; |
| 2090 if (!ValidateTexture2DBinding("compressedTexImage2D", target)) | 2091 if (!ValidateTexture2DBinding("compressedTexImage2D", target)) |
| 2091 return; | 2092 return; |
| 2092 if (!ValidateCompressedTexFormat("compressedTexImage2D", internalformat)) | 2093 if (!ValidateCompressedTexFormat("compressedTexImage2D", internalformat)) |
| 2093 return; | 2094 return; |
| 2094 ContextGL()->CompressedTexImage2D(target, level, internalformat, width, | 2095 ContextGL()->CompressedTexImage2D(target, level, internalformat, width, |
| 2095 height, border, data.View()->byteLength(), | 2096 height, border, data.View()->byteLength(), |
| 2096 data.View()->BaseAddress()); | 2097 data.View()->BaseAddressMaybeShared()); |
| 2097 } | 2098 } |
| 2098 | 2099 |
| 2099 void WebGLRenderingContextBase::compressedTexSubImage2D( | 2100 void WebGLRenderingContextBase::compressedTexSubImage2D( |
| 2100 GLenum target, | 2101 GLenum target, |
| 2101 GLint level, | 2102 GLint level, |
| 2102 GLint xoffset, | 2103 GLint xoffset, |
| 2103 GLint yoffset, | 2104 GLint yoffset, |
| 2104 GLsizei width, | 2105 GLsizei width, |
| 2105 GLsizei height, | 2106 GLsizei height, |
| 2106 GLenum format, | 2107 GLenum format, |
| 2107 NotShared<DOMArrayBufferView> data) { | 2108 MaybeShared<DOMArrayBufferView> data) { |
| 2108 if (isContextLost()) | 2109 if (isContextLost()) |
| 2109 return; | 2110 return; |
| 2110 if (!ValidateTexture2DBinding("compressedTexSubImage2D", target)) | 2111 if (!ValidateTexture2DBinding("compressedTexSubImage2D", target)) |
| 2111 return; | 2112 return; |
| 2112 if (!ValidateCompressedTexFormat("compressedTexSubImage2D", format)) | 2113 if (!ValidateCompressedTexFormat("compressedTexSubImage2D", format)) |
| 2113 return; | 2114 return; |
| 2114 ContextGL()->CompressedTexSubImage2D( | 2115 ContextGL()->CompressedTexSubImage2D( |
| 2115 target, level, xoffset, yoffset, width, height, format, | 2116 target, level, xoffset, yoffset, width, height, format, |
| 2116 data.View()->byteLength(), data.View()->BaseAddress()); | 2117 data.View()->byteLength(), data.View()->BaseAddressMaybeShared()); |
| 2117 } | 2118 } |
| 2118 | 2119 |
| 2119 bool WebGLRenderingContextBase::ValidateSettableTexFormat( | 2120 bool WebGLRenderingContextBase::ValidateSettableTexFormat( |
| 2120 const char* function_name, | 2121 const char* function_name, |
| 2121 GLenum format) { | 2122 GLenum format) { |
| 2122 if (IsWebGL2OrHigher()) | 2123 if (IsWebGL2OrHigher()) |
| 2123 return true; | 2124 return true; |
| 2124 | 2125 |
| 2125 if (WebGLImageConversion::GetChannelBitsByFormat(format) & | 2126 if (WebGLImageConversion::GetChannelBitsByFormat(format) & |
| 2126 WebGLImageConversion::kChannelDepthStencil) { | 2127 WebGLImageConversion::kChannelDepthStencil) { |
| (...skipping 1982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4109 return true; | 4110 return true; |
| 4110 } | 4111 } |
| 4111 | 4112 |
| 4112 void WebGLRenderingContextBase::readPixels( | 4113 void WebGLRenderingContextBase::readPixels( |
| 4113 GLint x, | 4114 GLint x, |
| 4114 GLint y, | 4115 GLint y, |
| 4115 GLsizei width, | 4116 GLsizei width, |
| 4116 GLsizei height, | 4117 GLsizei height, |
| 4117 GLenum format, | 4118 GLenum format, |
| 4118 GLenum type, | 4119 GLenum type, |
| 4119 NotShared<DOMArrayBufferView> pixels) { | 4120 MaybeShared<DOMArrayBufferView> pixels) { |
| 4120 ReadPixelsHelper(x, y, width, height, format, type, pixels.View(), 0); | 4121 ReadPixelsHelper(x, y, width, height, format, type, pixels.View(), 0); |
| 4121 } | 4122 } |
| 4122 | 4123 |
| 4123 void WebGLRenderingContextBase::ReadPixelsHelper(GLint x, | 4124 void WebGLRenderingContextBase::ReadPixelsHelper(GLint x, |
| 4124 GLint y, | 4125 GLint y, |
| 4125 GLsizei width, | 4126 GLsizei width, |
| 4126 GLsizei height, | 4127 GLsizei height, |
| 4127 GLenum format, | 4128 GLenum format, |
| 4128 GLenum type, | 4129 GLenum type, |
| 4129 DOMArrayBufferView* pixels, | 4130 DOMArrayBufferView* pixels, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 4159 if (!buffer_size.IsValid()) { | 4160 if (!buffer_size.IsValid()) { |
| 4160 SynthesizeGLError(GL_INVALID_VALUE, "readPixels", | 4161 SynthesizeGLError(GL_INVALID_VALUE, "readPixels", |
| 4161 "destination offset out of range"); | 4162 "destination offset out of range"); |
| 4162 return; | 4163 return; |
| 4163 } | 4164 } |
| 4164 if (!ValidateReadPixelsFuncParameters(width, height, format, type, pixels, | 4165 if (!ValidateReadPixelsFuncParameters(width, height, format, type, pixels, |
| 4165 buffer_size.ValueOrDie())) { | 4166 buffer_size.ValueOrDie())) { |
| 4166 return; | 4167 return; |
| 4167 } | 4168 } |
| 4168 ClearIfComposited(); | 4169 ClearIfComposited(); |
| 4169 uint8_t* data = static_cast<uint8_t*>(pixels->BaseAddress()) + | 4170 uint8_t* data = static_cast<uint8_t*>(pixels->BaseAddressMaybeShared()) + |
| 4170 offset_in_bytes.ValueOrDie(); | 4171 offset_in_bytes.ValueOrDie(); |
| 4171 { | 4172 { |
| 4172 ScopedDrawingBufferBinder binder(GetDrawingBuffer(), framebuffer); | 4173 ScopedDrawingBufferBinder binder(GetDrawingBuffer(), framebuffer); |
| 4173 ContextGL()->ReadPixels(x, y, width, height, format, type, data); | 4174 ContextGL()->ReadPixels(x, y, width, height, format, type, data); |
| 4174 } | 4175 } |
| 4175 } | 4176 } |
| 4176 | 4177 |
| 4177 void WebGLRenderingContextBase::RenderbufferStorageImpl( | 4178 void WebGLRenderingContextBase::RenderbufferStorageImpl( |
| 4178 GLenum target, | 4179 GLenum target, |
| 4179 GLsizei samples, | 4180 GLsizei samples, |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4675 return; | 4676 return; |
| 4676 TexImageDimension source_type; | 4677 TexImageDimension source_type; |
| 4677 if (function_id == kTexImage2D || function_id == kTexSubImage2D) | 4678 if (function_id == kTexImage2D || function_id == kTexSubImage2D) |
| 4678 source_type = kTex2D; | 4679 source_type = kTex2D; |
| 4679 else | 4680 else |
| 4680 source_type = kTex3D; | 4681 source_type = kTex3D; |
| 4681 if (!ValidateTexFuncData(func_name, source_type, level, width, height, depth, | 4682 if (!ValidateTexFuncData(func_name, source_type, level, width, height, depth, |
| 4682 format, type, pixels, null_disposition, src_offset)) | 4683 format, type, pixels, null_disposition, src_offset)) |
| 4683 return; | 4684 return; |
| 4684 uint8_t* data = | 4685 uint8_t* data = |
| 4685 reinterpret_cast<uint8_t*>(pixels ? pixels->BaseAddress() : 0); | 4686 reinterpret_cast<uint8_t*>(pixels ? pixels->BaseAddressMaybeShared() : 0); |
| 4686 if (src_offset) { | 4687 if (src_offset) { |
| 4687 DCHECK(pixels); | 4688 DCHECK(pixels); |
| 4688 // No need to check overflow because validateTexFuncData() already did. | 4689 // No need to check overflow because validateTexFuncData() already did. |
| 4689 data += src_offset * pixels->TypeSize(); | 4690 data += src_offset * pixels->TypeSize(); |
| 4690 } | 4691 } |
| 4691 Vector<uint8_t> temp_data; | 4692 Vector<uint8_t> temp_data; |
| 4692 bool change_unpack_alignment = false; | 4693 bool change_unpack_alignment = false; |
| 4693 if (data && (unpack_flip_y_ || unpack_premultiply_alpha_)) { | 4694 if (data && (unpack_flip_y_ || unpack_premultiply_alpha_)) { |
| 4694 if (source_type == kTex2D) { | 4695 if (source_type == kTex2D) { |
| 4695 if (!WebGLImageConversion::ExtractTextureData( | 4696 if (!WebGLImageConversion::ExtractTextureData( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4726 | 4727 |
| 4727 void WebGLRenderingContextBase::texImage2D( | 4728 void WebGLRenderingContextBase::texImage2D( |
| 4728 GLenum target, | 4729 GLenum target, |
| 4729 GLint level, | 4730 GLint level, |
| 4730 GLint internalformat, | 4731 GLint internalformat, |
| 4731 GLsizei width, | 4732 GLsizei width, |
| 4732 GLsizei height, | 4733 GLsizei height, |
| 4733 GLint border, | 4734 GLint border, |
| 4734 GLenum format, | 4735 GLenum format, |
| 4735 GLenum type, | 4736 GLenum type, |
| 4736 NotShared<DOMArrayBufferView> pixels) { | 4737 MaybeShared<DOMArrayBufferView> pixels) { |
| 4737 TexImageHelperDOMArrayBufferView(kTexImage2D, target, level, internalformat, | 4738 TexImageHelperDOMArrayBufferView(kTexImage2D, target, level, internalformat, |
| 4738 width, height, 1, border, format, type, 0, 0, | 4739 width, height, 1, border, format, type, 0, 0, |
| 4739 0, pixels.View(), kNullAllowed, 0); | 4740 0, pixels.View(), kNullAllowed, 0); |
| 4740 } | 4741 } |
| 4741 | 4742 |
| 4742 void WebGLRenderingContextBase::TexImageHelperImageData( | 4743 void WebGLRenderingContextBase::TexImageHelperImageData( |
| 4743 TexImageFunctionID function_id, | 4744 TexImageFunctionID function_id, |
| 4744 GLenum target, | 4745 GLenum target, |
| 4745 GLint level, | 4746 GLint level, |
| 4746 GLint internalformat, | 4747 GLint internalformat, |
| (...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5593 | 5594 |
| 5594 void WebGLRenderingContextBase::texSubImage2D( | 5595 void WebGLRenderingContextBase::texSubImage2D( |
| 5595 GLenum target, | 5596 GLenum target, |
| 5596 GLint level, | 5597 GLint level, |
| 5597 GLint xoffset, | 5598 GLint xoffset, |
| 5598 GLint yoffset, | 5599 GLint yoffset, |
| 5599 GLsizei width, | 5600 GLsizei width, |
| 5600 GLsizei height, | 5601 GLsizei height, |
| 5601 GLenum format, | 5602 GLenum format, |
| 5602 GLenum type, | 5603 GLenum type, |
| 5603 NotShared<DOMArrayBufferView> pixels) { | 5604 MaybeShared<DOMArrayBufferView> pixels) { |
| 5604 TexImageHelperDOMArrayBufferView(kTexSubImage2D, target, level, 0, width, | 5605 TexImageHelperDOMArrayBufferView(kTexSubImage2D, target, level, 0, width, |
| 5605 height, 1, 0, format, type, xoffset, yoffset, | 5606 height, 1, 0, format, type, xoffset, yoffset, |
| 5606 0, pixels.View(), kNullNotAllowed, 0); | 5607 0, pixels.View(), kNullNotAllowed, 0); |
| 5607 } | 5608 } |
| 5608 | 5609 |
| 5609 void WebGLRenderingContextBase::texSubImage2D(GLenum target, | 5610 void WebGLRenderingContextBase::texSubImage2D(GLenum target, |
| 5610 GLint level, | 5611 GLint level, |
| 5611 GLint xoffset, | 5612 GLint xoffset, |
| 5612 GLint yoffset, | 5613 GLint yoffset, |
| 5613 GLenum format, | 5614 GLenum format, |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5959 !ValidateUniformParameters("uniform4iv", location, v.Data(), v.size(), 4, | 5960 !ValidateUniformParameters("uniform4iv", location, v.Data(), v.size(), 4, |
| 5960 0, v.size())) | 5961 0, v.size())) |
| 5961 return; | 5962 return; |
| 5962 | 5963 |
| 5963 ContextGL()->Uniform4iv(location->Location(), v.size() >> 2, v.Data()); | 5964 ContextGL()->Uniform4iv(location->Location(), v.size() >> 2, v.Data()); |
| 5964 } | 5965 } |
| 5965 | 5966 |
| 5966 void WebGLRenderingContextBase::uniformMatrix2fv( | 5967 void WebGLRenderingContextBase::uniformMatrix2fv( |
| 5967 const WebGLUniformLocation* location, | 5968 const WebGLUniformLocation* location, |
| 5968 GLboolean transpose, | 5969 GLboolean transpose, |
| 5969 NotShared<DOMFloat32Array> v) { | 5970 MaybeShared<DOMFloat32Array> v) { |
| 5970 if (isContextLost() || | 5971 if (isContextLost() || |
| 5971 !ValidateUniformMatrixParameters("uniformMatrix2fv", location, transpose, | 5972 !ValidateUniformMatrixParameters("uniformMatrix2fv", location, transpose, |
| 5972 v.View(), 4, 0, v.View()->length())) | 5973 v.View(), 4, 0, v.View()->length())) |
| 5973 return; | 5974 return; |
| 5974 ContextGL()->UniformMatrix2fv(location->Location(), v.View()->length() >> 2, | 5975 ContextGL()->UniformMatrix2fv(location->Location(), v.View()->length() >> 2, |
| 5975 transpose, v.View()->Data()); | 5976 transpose, v.View()->DataMaybeShared()); |
| 5976 } | 5977 } |
| 5977 | 5978 |
| 5978 void WebGLRenderingContextBase::uniformMatrix2fv( | 5979 void WebGLRenderingContextBase::uniformMatrix2fv( |
| 5979 const WebGLUniformLocation* location, | 5980 const WebGLUniformLocation* location, |
| 5980 GLboolean transpose, | 5981 GLboolean transpose, |
| 5981 Vector<GLfloat>& v) { | 5982 Vector<GLfloat>& v) { |
| 5982 if (isContextLost() || | 5983 if (isContextLost() || |
| 5983 !ValidateUniformMatrixParameters("uniformMatrix2fv", location, transpose, | 5984 !ValidateUniformMatrixParameters("uniformMatrix2fv", location, transpose, |
| 5984 v.Data(), v.size(), 4, 0, v.size())) | 5985 v.Data(), v.size(), 4, 0, v.size())) |
| 5985 return; | 5986 return; |
| 5986 ContextGL()->UniformMatrix2fv(location->Location(), v.size() >> 2, transpose, | 5987 ContextGL()->UniformMatrix2fv(location->Location(), v.size() >> 2, transpose, |
| 5987 v.Data()); | 5988 v.Data()); |
| 5988 } | 5989 } |
| 5989 | 5990 |
| 5990 void WebGLRenderingContextBase::uniformMatrix3fv( | 5991 void WebGLRenderingContextBase::uniformMatrix3fv( |
| 5991 const WebGLUniformLocation* location, | 5992 const WebGLUniformLocation* location, |
| 5992 GLboolean transpose, | 5993 GLboolean transpose, |
| 5993 NotShared<DOMFloat32Array> v) { | 5994 MaybeShared<DOMFloat32Array> v) { |
| 5994 if (isContextLost() || | 5995 if (isContextLost() || |
| 5995 !ValidateUniformMatrixParameters("uniformMatrix3fv", location, transpose, | 5996 !ValidateUniformMatrixParameters("uniformMatrix3fv", location, transpose, |
| 5996 v.View(), 9, 0, v.View()->length())) | 5997 v.View(), 9, 0, v.View()->length())) |
| 5997 return; | 5998 return; |
| 5998 ContextGL()->UniformMatrix3fv(location->Location(), v.View()->length() / 9, | 5999 ContextGL()->UniformMatrix3fv(location->Location(), v.View()->length() / 9, |
| 5999 transpose, v.View()->Data()); | 6000 transpose, v.View()->DataMaybeShared()); |
| 6000 } | 6001 } |
| 6001 | 6002 |
| 6002 void WebGLRenderingContextBase::uniformMatrix3fv( | 6003 void WebGLRenderingContextBase::uniformMatrix3fv( |
| 6003 const WebGLUniformLocation* location, | 6004 const WebGLUniformLocation* location, |
| 6004 GLboolean transpose, | 6005 GLboolean transpose, |
| 6005 Vector<GLfloat>& v) { | 6006 Vector<GLfloat>& v) { |
| 6006 if (isContextLost() || | 6007 if (isContextLost() || |
| 6007 !ValidateUniformMatrixParameters("uniformMatrix3fv", location, transpose, | 6008 !ValidateUniformMatrixParameters("uniformMatrix3fv", location, transpose, |
| 6008 v.Data(), v.size(), 9, 0, v.size())) | 6009 v.Data(), v.size(), 9, 0, v.size())) |
| 6009 return; | 6010 return; |
| 6010 ContextGL()->UniformMatrix3fv(location->Location(), v.size() / 9, transpose, | 6011 ContextGL()->UniformMatrix3fv(location->Location(), v.size() / 9, transpose, |
| 6011 v.Data()); | 6012 v.Data()); |
| 6012 } | 6013 } |
| 6013 | 6014 |
| 6014 void WebGLRenderingContextBase::uniformMatrix4fv( | 6015 void WebGLRenderingContextBase::uniformMatrix4fv( |
| 6015 const WebGLUniformLocation* location, | 6016 const WebGLUniformLocation* location, |
| 6016 GLboolean transpose, | 6017 GLboolean transpose, |
| 6017 NotShared<DOMFloat32Array> v) { | 6018 MaybeShared<DOMFloat32Array> v) { |
| 6018 if (isContextLost() || | 6019 if (isContextLost() || |
| 6019 !ValidateUniformMatrixParameters("uniformMatrix4fv", location, transpose, | 6020 !ValidateUniformMatrixParameters("uniformMatrix4fv", location, transpose, |
| 6020 v.View(), 16, 0, v.View()->length())) | 6021 v.View(), 16, 0, v.View()->length())) |
| 6021 return; | 6022 return; |
| 6022 ContextGL()->UniformMatrix4fv(location->Location(), v.View()->length() >> 4, | 6023 ContextGL()->UniformMatrix4fv(location->Location(), v.View()->length() >> 4, |
| 6023 transpose, v.View()->Data()); | 6024 transpose, v.View()->DataMaybeShared()); |
| 6024 } | 6025 } |
| 6025 | 6026 |
| 6026 void WebGLRenderingContextBase::uniformMatrix4fv( | 6027 void WebGLRenderingContextBase::uniformMatrix4fv( |
| 6027 const WebGLUniformLocation* location, | 6028 const WebGLUniformLocation* location, |
| 6028 GLboolean transpose, | 6029 GLboolean transpose, |
| 6029 Vector<GLfloat>& v) { | 6030 Vector<GLfloat>& v) { |
| 6030 if (isContextLost() || | 6031 if (isContextLost() || |
| 6031 !ValidateUniformMatrixParameters("uniformMatrix4fv", location, transpose, | 6032 !ValidateUniformMatrixParameters("uniformMatrix4fv", location, transpose, |
| 6032 v.Data(), v.size(), 16, 0, v.size())) | 6033 v.Data(), v.size(), 16, 0, v.size())) |
| 6033 return; | 6034 return; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6071 | 6072 |
| 6072 void WebGLRenderingContextBase::vertexAttrib1f(GLuint index, GLfloat v0) { | 6073 void WebGLRenderingContextBase::vertexAttrib1f(GLuint index, GLfloat v0) { |
| 6073 if (isContextLost()) | 6074 if (isContextLost()) |
| 6074 return; | 6075 return; |
| 6075 ContextGL()->VertexAttrib1f(index, v0); | 6076 ContextGL()->VertexAttrib1f(index, v0); |
| 6076 SetVertexAttribType(index, kFloat32ArrayType); | 6077 SetVertexAttribType(index, kFloat32ArrayType); |
| 6077 } | 6078 } |
| 6078 | 6079 |
| 6079 void WebGLRenderingContextBase::vertexAttrib1fv( | 6080 void WebGLRenderingContextBase::vertexAttrib1fv( |
| 6080 GLuint index, | 6081 GLuint index, |
| 6081 NotShared<const DOMFloat32Array> v) { | 6082 MaybeShared<const DOMFloat32Array> v) { |
| 6082 if (isContextLost()) | 6083 if (isContextLost()) |
| 6083 return; | 6084 return; |
| 6084 if (!v.View() || v.View()->length() < 1) { | 6085 if (!v.View() || v.View()->length() < 1) { |
| 6085 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib1fv", "invalid array"); | 6086 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib1fv", "invalid array"); |
| 6086 return; | 6087 return; |
| 6087 } | 6088 } |
| 6088 ContextGL()->VertexAttrib1fv(index, v.View()->Data()); | 6089 ContextGL()->VertexAttrib1fv(index, v.View()->DataMaybeShared()); |
| 6089 SetVertexAttribType(index, kFloat32ArrayType); | 6090 SetVertexAttribType(index, kFloat32ArrayType); |
| 6090 } | 6091 } |
| 6091 | 6092 |
| 6092 void WebGLRenderingContextBase::vertexAttrib1fv(GLuint index, | 6093 void WebGLRenderingContextBase::vertexAttrib1fv(GLuint index, |
| 6093 const Vector<GLfloat>& v) { | 6094 const Vector<GLfloat>& v) { |
| 6094 if (isContextLost()) | 6095 if (isContextLost()) |
| 6095 return; | 6096 return; |
| 6096 if (v.size() < 1) { | 6097 if (v.size() < 1) { |
| 6097 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib1fv", "invalid array"); | 6098 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib1fv", "invalid array"); |
| 6098 return; | 6099 return; |
| 6099 } | 6100 } |
| 6100 ContextGL()->VertexAttrib1fv(index, v.Data()); | 6101 ContextGL()->VertexAttrib1fv(index, v.Data()); |
| 6101 SetVertexAttribType(index, kFloat32ArrayType); | 6102 SetVertexAttribType(index, kFloat32ArrayType); |
| 6102 } | 6103 } |
| 6103 | 6104 |
| 6104 void WebGLRenderingContextBase::vertexAttrib2f(GLuint index, | 6105 void WebGLRenderingContextBase::vertexAttrib2f(GLuint index, |
| 6105 GLfloat v0, | 6106 GLfloat v0, |
| 6106 GLfloat v1) { | 6107 GLfloat v1) { |
| 6107 if (isContextLost()) | 6108 if (isContextLost()) |
| 6108 return; | 6109 return; |
| 6109 ContextGL()->VertexAttrib2f(index, v0, v1); | 6110 ContextGL()->VertexAttrib2f(index, v0, v1); |
| 6110 SetVertexAttribType(index, kFloat32ArrayType); | 6111 SetVertexAttribType(index, kFloat32ArrayType); |
| 6111 } | 6112 } |
| 6112 | 6113 |
| 6113 void WebGLRenderingContextBase::vertexAttrib2fv( | 6114 void WebGLRenderingContextBase::vertexAttrib2fv( |
| 6114 GLuint index, | 6115 GLuint index, |
| 6115 NotShared<const DOMFloat32Array> v) { | 6116 MaybeShared<const DOMFloat32Array> v) { |
| 6116 if (isContextLost()) | 6117 if (isContextLost()) |
| 6117 return; | 6118 return; |
| 6118 if (!v.View() || v.View()->length() < 2) { | 6119 if (!v.View() || v.View()->length() < 2) { |
| 6119 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib2fv", "invalid array"); | 6120 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib2fv", "invalid array"); |
| 6120 return; | 6121 return; |
| 6121 } | 6122 } |
| 6122 ContextGL()->VertexAttrib2fv(index, v.View()->Data()); | 6123 ContextGL()->VertexAttrib2fv(index, v.View()->DataMaybeShared()); |
| 6123 SetVertexAttribType(index, kFloat32ArrayType); | 6124 SetVertexAttribType(index, kFloat32ArrayType); |
| 6124 } | 6125 } |
| 6125 | 6126 |
| 6126 void WebGLRenderingContextBase::vertexAttrib2fv(GLuint index, | 6127 void WebGLRenderingContextBase::vertexAttrib2fv(GLuint index, |
| 6127 const Vector<GLfloat>& v) { | 6128 const Vector<GLfloat>& v) { |
| 6128 if (isContextLost()) | 6129 if (isContextLost()) |
| 6129 return; | 6130 return; |
| 6130 if (v.size() < 2) { | 6131 if (v.size() < 2) { |
| 6131 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib2fv", "invalid array"); | 6132 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib2fv", "invalid array"); |
| 6132 return; | 6133 return; |
| 6133 } | 6134 } |
| 6134 ContextGL()->VertexAttrib2fv(index, v.Data()); | 6135 ContextGL()->VertexAttrib2fv(index, v.Data()); |
| 6135 SetVertexAttribType(index, kFloat32ArrayType); | 6136 SetVertexAttribType(index, kFloat32ArrayType); |
| 6136 } | 6137 } |
| 6137 | 6138 |
| 6138 void WebGLRenderingContextBase::vertexAttrib3f(GLuint index, | 6139 void WebGLRenderingContextBase::vertexAttrib3f(GLuint index, |
| 6139 GLfloat v0, | 6140 GLfloat v0, |
| 6140 GLfloat v1, | 6141 GLfloat v1, |
| 6141 GLfloat v2) { | 6142 GLfloat v2) { |
| 6142 if (isContextLost()) | 6143 if (isContextLost()) |
| 6143 return; | 6144 return; |
| 6144 ContextGL()->VertexAttrib3f(index, v0, v1, v2); | 6145 ContextGL()->VertexAttrib3f(index, v0, v1, v2); |
| 6145 SetVertexAttribType(index, kFloat32ArrayType); | 6146 SetVertexAttribType(index, kFloat32ArrayType); |
| 6146 } | 6147 } |
| 6147 | 6148 |
| 6148 void WebGLRenderingContextBase::vertexAttrib3fv( | 6149 void WebGLRenderingContextBase::vertexAttrib3fv( |
| 6149 GLuint index, | 6150 GLuint index, |
| 6150 NotShared<const DOMFloat32Array> v) { | 6151 MaybeShared<const DOMFloat32Array> v) { |
| 6151 if (isContextLost()) | 6152 if (isContextLost()) |
| 6152 return; | 6153 return; |
| 6153 if (!v.View() || v.View()->length() < 3) { | 6154 if (!v.View() || v.View()->length() < 3) { |
| 6154 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib3fv", "invalid array"); | 6155 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib3fv", "invalid array"); |
| 6155 return; | 6156 return; |
| 6156 } | 6157 } |
| 6157 ContextGL()->VertexAttrib3fv(index, v.View()->Data()); | 6158 ContextGL()->VertexAttrib3fv(index, v.View()->DataMaybeShared()); |
| 6158 SetVertexAttribType(index, kFloat32ArrayType); | 6159 SetVertexAttribType(index, kFloat32ArrayType); |
| 6159 } | 6160 } |
| 6160 | 6161 |
| 6161 void WebGLRenderingContextBase::vertexAttrib3fv(GLuint index, | 6162 void WebGLRenderingContextBase::vertexAttrib3fv(GLuint index, |
| 6162 const Vector<GLfloat>& v) { | 6163 const Vector<GLfloat>& v) { |
| 6163 if (isContextLost()) | 6164 if (isContextLost()) |
| 6164 return; | 6165 return; |
| 6165 if (v.size() < 3) { | 6166 if (v.size() < 3) { |
| 6166 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib3fv", "invalid array"); | 6167 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib3fv", "invalid array"); |
| 6167 return; | 6168 return; |
| 6168 } | 6169 } |
| 6169 ContextGL()->VertexAttrib3fv(index, v.Data()); | 6170 ContextGL()->VertexAttrib3fv(index, v.Data()); |
| 6170 SetVertexAttribType(index, kFloat32ArrayType); | 6171 SetVertexAttribType(index, kFloat32ArrayType); |
| 6171 } | 6172 } |
| 6172 | 6173 |
| 6173 void WebGLRenderingContextBase::vertexAttrib4f(GLuint index, | 6174 void WebGLRenderingContextBase::vertexAttrib4f(GLuint index, |
| 6174 GLfloat v0, | 6175 GLfloat v0, |
| 6175 GLfloat v1, | 6176 GLfloat v1, |
| 6176 GLfloat v2, | 6177 GLfloat v2, |
| 6177 GLfloat v3) { | 6178 GLfloat v3) { |
| 6178 if (isContextLost()) | 6179 if (isContextLost()) |
| 6179 return; | 6180 return; |
| 6180 ContextGL()->VertexAttrib4f(index, v0, v1, v2, v3); | 6181 ContextGL()->VertexAttrib4f(index, v0, v1, v2, v3); |
| 6181 SetVertexAttribType(index, kFloat32ArrayType); | 6182 SetVertexAttribType(index, kFloat32ArrayType); |
| 6182 } | 6183 } |
| 6183 | 6184 |
| 6184 void WebGLRenderingContextBase::vertexAttrib4fv( | 6185 void WebGLRenderingContextBase::vertexAttrib4fv( |
| 6185 GLuint index, | 6186 GLuint index, |
| 6186 NotShared<const DOMFloat32Array> v) { | 6187 MaybeShared<const DOMFloat32Array> v) { |
| 6187 if (isContextLost()) | 6188 if (isContextLost()) |
| 6188 return; | 6189 return; |
| 6189 if (!v.View() || v.View()->length() < 4) { | 6190 if (!v.View() || v.View()->length() < 4) { |
| 6190 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib4fv", "invalid array"); | 6191 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib4fv", "invalid array"); |
| 6191 return; | 6192 return; |
| 6192 } | 6193 } |
| 6193 ContextGL()->VertexAttrib4fv(index, v.View()->Data()); | 6194 ContextGL()->VertexAttrib4fv(index, v.View()->DataMaybeShared()); |
| 6194 SetVertexAttribType(index, kFloat32ArrayType); | 6195 SetVertexAttribType(index, kFloat32ArrayType); |
| 6195 } | 6196 } |
| 6196 | 6197 |
| 6197 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, | 6198 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, |
| 6198 const Vector<GLfloat>& v) { | 6199 const Vector<GLfloat>& v) { |
| 6199 if (isContextLost()) | 6200 if (isContextLost()) |
| 6200 return; | 6201 return; |
| 6201 if (v.size() < 4) { | 6202 if (v.size() < 4) { |
| 6202 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib4fv", "invalid array"); | 6203 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib4fv", "invalid array"); |
| 6203 return; | 6204 return; |
| (...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7238 GLboolean transpose, | 7239 GLboolean transpose, |
| 7239 DOMFloat32Array* v, | 7240 DOMFloat32Array* v, |
| 7240 GLsizei required_min_size, | 7241 GLsizei required_min_size, |
| 7241 GLuint src_offset, | 7242 GLuint src_offset, |
| 7242 GLuint src_length) { | 7243 GLuint src_length) { |
| 7243 if (!v) { | 7244 if (!v) { |
| 7244 SynthesizeGLError(GL_INVALID_VALUE, function_name, "no array"); | 7245 SynthesizeGLError(GL_INVALID_VALUE, function_name, "no array"); |
| 7245 return false; | 7246 return false; |
| 7246 } | 7247 } |
| 7247 return ValidateUniformMatrixParameters( | 7248 return ValidateUniformMatrixParameters( |
| 7248 function_name, location, transpose, v->Data(), v->length(), | 7249 function_name, location, transpose, v->DataMaybeShared(), v->length(), |
| 7249 required_min_size, src_offset, src_length); | 7250 required_min_size, src_offset, src_length); |
| 7250 } | 7251 } |
| 7251 | 7252 |
| 7252 bool WebGLRenderingContextBase::ValidateUniformMatrixParameters( | 7253 bool WebGLRenderingContextBase::ValidateUniformMatrixParameters( |
| 7253 const char* function_name, | 7254 const char* function_name, |
| 7254 const WebGLUniformLocation* location, | 7255 const WebGLUniformLocation* location, |
| 7255 GLboolean transpose, | 7256 GLboolean transpose, |
| 7256 void* v, | 7257 void* v, |
| 7257 GLsizei size, | 7258 GLsizei size, |
| 7258 GLsizei required_min_size, | 7259 GLsizei required_min_size, |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7862 | 7863 |
| 7863 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7864 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
| 7864 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7865 HTMLCanvasElementOrOffscreenCanvas& result) const { |
| 7865 if (canvas()) | 7866 if (canvas()) |
| 7866 result.setHTMLCanvasElement(canvas()); | 7867 result.setHTMLCanvasElement(canvas()); |
| 7867 else | 7868 else |
| 7868 result.setOffscreenCanvas(offscreenCanvas()); | 7869 result.setOffscreenCanvas(offscreenCanvas()); |
| 7869 } | 7870 } |
| 7870 | 7871 |
| 7871 } // namespace blink | 7872 } // namespace blink |
| OLD | NEW |