Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(470)

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 2815793002: [SharedArrayBuffer] Add "AllowShared" extended attribute, used for WebGL (Closed)
Patch Set: add layout tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
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
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
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
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 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
5561 5562
5562 void WebGLRenderingContextBase::texSubImage2D( 5563 void WebGLRenderingContextBase::texSubImage2D(
5563 GLenum target, 5564 GLenum target,
5564 GLint level, 5565 GLint level,
5565 GLint xoffset, 5566 GLint xoffset,
5566 GLint yoffset, 5567 GLint yoffset,
5567 GLsizei width, 5568 GLsizei width,
5568 GLsizei height, 5569 GLsizei height,
5569 GLenum format, 5570 GLenum format,
5570 GLenum type, 5571 GLenum type,
5571 NotShared<DOMArrayBufferView> pixels) { 5572 MaybeShared<DOMArrayBufferView> pixels) {
5572 TexImageHelperDOMArrayBufferView(kTexSubImage2D, target, level, 0, width, 5573 TexImageHelperDOMArrayBufferView(kTexSubImage2D, target, level, 0, width,
5573 height, 1, 0, format, type, xoffset, yoffset, 5574 height, 1, 0, format, type, xoffset, yoffset,
5574 0, pixels.View(), kNullNotAllowed, 0); 5575 0, pixels.View(), kNullNotAllowed, 0);
5575 } 5576 }
5576 5577
5577 void WebGLRenderingContextBase::texSubImage2D(GLenum target, 5578 void WebGLRenderingContextBase::texSubImage2D(GLenum target,
5578 GLint level, 5579 GLint level,
5579 GLint xoffset, 5580 GLint xoffset,
5580 GLint yoffset, 5581 GLint yoffset,
5581 GLenum format, 5582 GLenum format,
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
5918 !ValidateUniformParameters("uniform4iv", location, v.Data(), v.size(), 4, 5919 !ValidateUniformParameters("uniform4iv", location, v.Data(), v.size(), 4,
5919 0, v.size())) 5920 0, v.size()))
5920 return; 5921 return;
5921 5922
5922 ContextGL()->Uniform4iv(location->Location(), v.size() >> 2, v.Data()); 5923 ContextGL()->Uniform4iv(location->Location(), v.size() >> 2, v.Data());
5923 } 5924 }
5924 5925
5925 void WebGLRenderingContextBase::uniformMatrix2fv( 5926 void WebGLRenderingContextBase::uniformMatrix2fv(
5926 const WebGLUniformLocation* location, 5927 const WebGLUniformLocation* location,
5927 GLboolean transpose, 5928 GLboolean transpose,
5928 NotShared<DOMFloat32Array> v) { 5929 MaybeShared<DOMFloat32Array> v) {
5929 if (isContextLost() || 5930 if (isContextLost() ||
5930 !ValidateUniformMatrixParameters("uniformMatrix2fv", location, transpose, 5931 !ValidateUniformMatrixParameters("uniformMatrix2fv", location, transpose,
5931 v.View(), 4, 0, v.View()->length())) 5932 v.View(), 4, 0, v.View()->length()))
5932 return; 5933 return;
5933 ContextGL()->UniformMatrix2fv(location->Location(), v.View()->length() >> 2, 5934 ContextGL()->UniformMatrix2fv(location->Location(), v.View()->length() >> 2,
5934 transpose, v.View()->Data()); 5935 transpose, v.View()->DataMaybeShared());
5935 } 5936 }
5936 5937
5937 void WebGLRenderingContextBase::uniformMatrix2fv( 5938 void WebGLRenderingContextBase::uniformMatrix2fv(
5938 const WebGLUniformLocation* location, 5939 const WebGLUniformLocation* location,
5939 GLboolean transpose, 5940 GLboolean transpose,
5940 Vector<GLfloat>& v) { 5941 Vector<GLfloat>& v) {
5941 if (isContextLost() || 5942 if (isContextLost() ||
5942 !ValidateUniformMatrixParameters("uniformMatrix2fv", location, transpose, 5943 !ValidateUniformMatrixParameters("uniformMatrix2fv", location, transpose,
5943 v.Data(), v.size(), 4, 0, v.size())) 5944 v.Data(), v.size(), 4, 0, v.size()))
5944 return; 5945 return;
5945 ContextGL()->UniformMatrix2fv(location->Location(), v.size() >> 2, transpose, 5946 ContextGL()->UniformMatrix2fv(location->Location(), v.size() >> 2, transpose,
5946 v.Data()); 5947 v.Data());
5947 } 5948 }
5948 5949
5949 void WebGLRenderingContextBase::uniformMatrix3fv( 5950 void WebGLRenderingContextBase::uniformMatrix3fv(
5950 const WebGLUniformLocation* location, 5951 const WebGLUniformLocation* location,
5951 GLboolean transpose, 5952 GLboolean transpose,
5952 NotShared<DOMFloat32Array> v) { 5953 MaybeShared<DOMFloat32Array> v) {
5953 if (isContextLost() || 5954 if (isContextLost() ||
5954 !ValidateUniformMatrixParameters("uniformMatrix3fv", location, transpose, 5955 !ValidateUniformMatrixParameters("uniformMatrix3fv", location, transpose,
5955 v.View(), 9, 0, v.View()->length())) 5956 v.View(), 9, 0, v.View()->length()))
5956 return; 5957 return;
5957 ContextGL()->UniformMatrix3fv(location->Location(), v.View()->length() / 9, 5958 ContextGL()->UniformMatrix3fv(location->Location(), v.View()->length() / 9,
5958 transpose, v.View()->Data()); 5959 transpose, v.View()->DataMaybeShared());
5959 } 5960 }
5960 5961
5961 void WebGLRenderingContextBase::uniformMatrix3fv( 5962 void WebGLRenderingContextBase::uniformMatrix3fv(
5962 const WebGLUniformLocation* location, 5963 const WebGLUniformLocation* location,
5963 GLboolean transpose, 5964 GLboolean transpose,
5964 Vector<GLfloat>& v) { 5965 Vector<GLfloat>& v) {
5965 if (isContextLost() || 5966 if (isContextLost() ||
5966 !ValidateUniformMatrixParameters("uniformMatrix3fv", location, transpose, 5967 !ValidateUniformMatrixParameters("uniformMatrix3fv", location, transpose,
5967 v.Data(), v.size(), 9, 0, v.size())) 5968 v.Data(), v.size(), 9, 0, v.size()))
5968 return; 5969 return;
5969 ContextGL()->UniformMatrix3fv(location->Location(), v.size() / 9, transpose, 5970 ContextGL()->UniformMatrix3fv(location->Location(), v.size() / 9, transpose,
5970 v.Data()); 5971 v.Data());
5971 } 5972 }
5972 5973
5973 void WebGLRenderingContextBase::uniformMatrix4fv( 5974 void WebGLRenderingContextBase::uniformMatrix4fv(
5974 const WebGLUniformLocation* location, 5975 const WebGLUniformLocation* location,
5975 GLboolean transpose, 5976 GLboolean transpose,
5976 NotShared<DOMFloat32Array> v) { 5977 MaybeShared<DOMFloat32Array> v) {
5977 if (isContextLost() || 5978 if (isContextLost() ||
5978 !ValidateUniformMatrixParameters("uniformMatrix4fv", location, transpose, 5979 !ValidateUniformMatrixParameters("uniformMatrix4fv", location, transpose,
5979 v.View(), 16, 0, v.View()->length())) 5980 v.View(), 16, 0, v.View()->length()))
5980 return; 5981 return;
5981 ContextGL()->UniformMatrix4fv(location->Location(), v.View()->length() >> 4, 5982 ContextGL()->UniformMatrix4fv(location->Location(), v.View()->length() >> 4,
5982 transpose, v.View()->Data()); 5983 transpose, v.View()->DataMaybeShared());
5983 } 5984 }
5984 5985
5985 void WebGLRenderingContextBase::uniformMatrix4fv( 5986 void WebGLRenderingContextBase::uniformMatrix4fv(
5986 const WebGLUniformLocation* location, 5987 const WebGLUniformLocation* location,
5987 GLboolean transpose, 5988 GLboolean transpose,
5988 Vector<GLfloat>& v) { 5989 Vector<GLfloat>& v) {
5989 if (isContextLost() || 5990 if (isContextLost() ||
5990 !ValidateUniformMatrixParameters("uniformMatrix4fv", location, transpose, 5991 !ValidateUniformMatrixParameters("uniformMatrix4fv", location, transpose,
5991 v.Data(), v.size(), 16, 0, v.size())) 5992 v.Data(), v.size(), 16, 0, v.size()))
5992 return; 5993 return;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
6030 6031
6031 void WebGLRenderingContextBase::vertexAttrib1f(GLuint index, GLfloat v0) { 6032 void WebGLRenderingContextBase::vertexAttrib1f(GLuint index, GLfloat v0) {
6032 if (isContextLost()) 6033 if (isContextLost())
6033 return; 6034 return;
6034 ContextGL()->VertexAttrib1f(index, v0); 6035 ContextGL()->VertexAttrib1f(index, v0);
6035 SetVertexAttribType(index, kFloat32ArrayType); 6036 SetVertexAttribType(index, kFloat32ArrayType);
6036 } 6037 }
6037 6038
6038 void WebGLRenderingContextBase::vertexAttrib1fv( 6039 void WebGLRenderingContextBase::vertexAttrib1fv(
6039 GLuint index, 6040 GLuint index,
6040 NotShared<const DOMFloat32Array> v) { 6041 MaybeShared<const DOMFloat32Array> v) {
6041 if (isContextLost()) 6042 if (isContextLost())
6042 return; 6043 return;
6043 if (!v.View() || v.View()->length() < 1) { 6044 if (!v.View() || v.View()->length() < 1) {
6044 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib1fv", "invalid array"); 6045 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib1fv", "invalid array");
6045 return; 6046 return;
6046 } 6047 }
6047 ContextGL()->VertexAttrib1fv(index, v.View()->Data()); 6048 ContextGL()->VertexAttrib1fv(index, v.View()->DataMaybeShared());
6048 SetVertexAttribType(index, kFloat32ArrayType); 6049 SetVertexAttribType(index, kFloat32ArrayType);
6049 } 6050 }
6050 6051
6051 void WebGLRenderingContextBase::vertexAttrib1fv(GLuint index, 6052 void WebGLRenderingContextBase::vertexAttrib1fv(GLuint index,
6052 const Vector<GLfloat>& v) { 6053 const Vector<GLfloat>& v) {
6053 if (isContextLost()) 6054 if (isContextLost())
6054 return; 6055 return;
6055 if (v.size() < 1) { 6056 if (v.size() < 1) {
6056 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib1fv", "invalid array"); 6057 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib1fv", "invalid array");
6057 return; 6058 return;
6058 } 6059 }
6059 ContextGL()->VertexAttrib1fv(index, v.Data()); 6060 ContextGL()->VertexAttrib1fv(index, v.Data());
6060 SetVertexAttribType(index, kFloat32ArrayType); 6061 SetVertexAttribType(index, kFloat32ArrayType);
6061 } 6062 }
6062 6063
6063 void WebGLRenderingContextBase::vertexAttrib2f(GLuint index, 6064 void WebGLRenderingContextBase::vertexAttrib2f(GLuint index,
6064 GLfloat v0, 6065 GLfloat v0,
6065 GLfloat v1) { 6066 GLfloat v1) {
6066 if (isContextLost()) 6067 if (isContextLost())
6067 return; 6068 return;
6068 ContextGL()->VertexAttrib2f(index, v0, v1); 6069 ContextGL()->VertexAttrib2f(index, v0, v1);
6069 SetVertexAttribType(index, kFloat32ArrayType); 6070 SetVertexAttribType(index, kFloat32ArrayType);
6070 } 6071 }
6071 6072
6072 void WebGLRenderingContextBase::vertexAttrib2fv( 6073 void WebGLRenderingContextBase::vertexAttrib2fv(
6073 GLuint index, 6074 GLuint index,
6074 NotShared<const DOMFloat32Array> v) { 6075 MaybeShared<const DOMFloat32Array> v) {
6075 if (isContextLost()) 6076 if (isContextLost())
6076 return; 6077 return;
6077 if (!v.View() || v.View()->length() < 2) { 6078 if (!v.View() || v.View()->length() < 2) {
6078 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib2fv", "invalid array"); 6079 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib2fv", "invalid array");
6079 return; 6080 return;
6080 } 6081 }
6081 ContextGL()->VertexAttrib2fv(index, v.View()->Data()); 6082 ContextGL()->VertexAttrib2fv(index, v.View()->DataMaybeShared());
6082 SetVertexAttribType(index, kFloat32ArrayType); 6083 SetVertexAttribType(index, kFloat32ArrayType);
6083 } 6084 }
6084 6085
6085 void WebGLRenderingContextBase::vertexAttrib2fv(GLuint index, 6086 void WebGLRenderingContextBase::vertexAttrib2fv(GLuint index,
6086 const Vector<GLfloat>& v) { 6087 const Vector<GLfloat>& v) {
6087 if (isContextLost()) 6088 if (isContextLost())
6088 return; 6089 return;
6089 if (v.size() < 2) { 6090 if (v.size() < 2) {
6090 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib2fv", "invalid array"); 6091 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib2fv", "invalid array");
6091 return; 6092 return;
6092 } 6093 }
6093 ContextGL()->VertexAttrib2fv(index, v.Data()); 6094 ContextGL()->VertexAttrib2fv(index, v.Data());
6094 SetVertexAttribType(index, kFloat32ArrayType); 6095 SetVertexAttribType(index, kFloat32ArrayType);
6095 } 6096 }
6096 6097
6097 void WebGLRenderingContextBase::vertexAttrib3f(GLuint index, 6098 void WebGLRenderingContextBase::vertexAttrib3f(GLuint index,
6098 GLfloat v0, 6099 GLfloat v0,
6099 GLfloat v1, 6100 GLfloat v1,
6100 GLfloat v2) { 6101 GLfloat v2) {
6101 if (isContextLost()) 6102 if (isContextLost())
6102 return; 6103 return;
6103 ContextGL()->VertexAttrib3f(index, v0, v1, v2); 6104 ContextGL()->VertexAttrib3f(index, v0, v1, v2);
6104 SetVertexAttribType(index, kFloat32ArrayType); 6105 SetVertexAttribType(index, kFloat32ArrayType);
6105 } 6106 }
6106 6107
6107 void WebGLRenderingContextBase::vertexAttrib3fv( 6108 void WebGLRenderingContextBase::vertexAttrib3fv(
6108 GLuint index, 6109 GLuint index,
6109 NotShared<const DOMFloat32Array> v) { 6110 MaybeShared<const DOMFloat32Array> v) {
6110 if (isContextLost()) 6111 if (isContextLost())
6111 return; 6112 return;
6112 if (!v.View() || v.View()->length() < 3) { 6113 if (!v.View() || v.View()->length() < 3) {
6113 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib3fv", "invalid array"); 6114 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib3fv", "invalid array");
6114 return; 6115 return;
6115 } 6116 }
6116 ContextGL()->VertexAttrib3fv(index, v.View()->Data()); 6117 ContextGL()->VertexAttrib3fv(index, v.View()->DataMaybeShared());
6117 SetVertexAttribType(index, kFloat32ArrayType); 6118 SetVertexAttribType(index, kFloat32ArrayType);
6118 } 6119 }
6119 6120
6120 void WebGLRenderingContextBase::vertexAttrib3fv(GLuint index, 6121 void WebGLRenderingContextBase::vertexAttrib3fv(GLuint index,
6121 const Vector<GLfloat>& v) { 6122 const Vector<GLfloat>& v) {
6122 if (isContextLost()) 6123 if (isContextLost())
6123 return; 6124 return;
6124 if (v.size() < 3) { 6125 if (v.size() < 3) {
6125 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib3fv", "invalid array"); 6126 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib3fv", "invalid array");
6126 return; 6127 return;
6127 } 6128 }
6128 ContextGL()->VertexAttrib3fv(index, v.Data()); 6129 ContextGL()->VertexAttrib3fv(index, v.Data());
6129 SetVertexAttribType(index, kFloat32ArrayType); 6130 SetVertexAttribType(index, kFloat32ArrayType);
6130 } 6131 }
6131 6132
6132 void WebGLRenderingContextBase::vertexAttrib4f(GLuint index, 6133 void WebGLRenderingContextBase::vertexAttrib4f(GLuint index,
6133 GLfloat v0, 6134 GLfloat v0,
6134 GLfloat v1, 6135 GLfloat v1,
6135 GLfloat v2, 6136 GLfloat v2,
6136 GLfloat v3) { 6137 GLfloat v3) {
6137 if (isContextLost()) 6138 if (isContextLost())
6138 return; 6139 return;
6139 ContextGL()->VertexAttrib4f(index, v0, v1, v2, v3); 6140 ContextGL()->VertexAttrib4f(index, v0, v1, v2, v3);
6140 SetVertexAttribType(index, kFloat32ArrayType); 6141 SetVertexAttribType(index, kFloat32ArrayType);
6141 } 6142 }
6142 6143
6143 void WebGLRenderingContextBase::vertexAttrib4fv( 6144 void WebGLRenderingContextBase::vertexAttrib4fv(
6144 GLuint index, 6145 GLuint index,
6145 NotShared<const DOMFloat32Array> v) { 6146 MaybeShared<const DOMFloat32Array> v) {
6146 if (isContextLost()) 6147 if (isContextLost())
6147 return; 6148 return;
6148 if (!v.View() || v.View()->length() < 4) { 6149 if (!v.View() || v.View()->length() < 4) {
6149 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib4fv", "invalid array"); 6150 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib4fv", "invalid array");
6150 return; 6151 return;
6151 } 6152 }
6152 ContextGL()->VertexAttrib4fv(index, v.View()->Data()); 6153 ContextGL()->VertexAttrib4fv(index, v.View()->DataMaybeShared());
6153 SetVertexAttribType(index, kFloat32ArrayType); 6154 SetVertexAttribType(index, kFloat32ArrayType);
6154 } 6155 }
6155 6156
6156 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, 6157 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index,
6157 const Vector<GLfloat>& v) { 6158 const Vector<GLfloat>& v) {
6158 if (isContextLost()) 6159 if (isContextLost())
6159 return; 6160 return;
6160 if (v.size() < 4) { 6161 if (v.size() < 4) {
6161 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib4fv", "invalid array"); 6162 SynthesizeGLError(GL_INVALID_VALUE, "vertexAttrib4fv", "invalid array");
6162 return; 6163 return;
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
7197 GLboolean transpose, 7198 GLboolean transpose,
7198 DOMFloat32Array* v, 7199 DOMFloat32Array* v,
7199 GLsizei required_min_size, 7200 GLsizei required_min_size,
7200 GLuint src_offset, 7201 GLuint src_offset,
7201 GLuint src_length) { 7202 GLuint src_length) {
7202 if (!v) { 7203 if (!v) {
7203 SynthesizeGLError(GL_INVALID_VALUE, function_name, "no array"); 7204 SynthesizeGLError(GL_INVALID_VALUE, function_name, "no array");
7204 return false; 7205 return false;
7205 } 7206 }
7206 return ValidateUniformMatrixParameters( 7207 return ValidateUniformMatrixParameters(
7207 function_name, location, transpose, v->Data(), v->length(), 7208 function_name, location, transpose, v->DataMaybeShared(), v->length(),
7208 required_min_size, src_offset, src_length); 7209 required_min_size, src_offset, src_length);
7209 } 7210 }
7210 7211
7211 bool WebGLRenderingContextBase::ValidateUniformMatrixParameters( 7212 bool WebGLRenderingContextBase::ValidateUniformMatrixParameters(
7212 const char* function_name, 7213 const char* function_name,
7213 const WebGLUniformLocation* location, 7214 const WebGLUniformLocation* location,
7214 GLboolean transpose, 7215 GLboolean transpose,
7215 void* v, 7216 void* v,
7216 GLsizei size, 7217 GLsizei size,
7217 GLsizei required_min_size, 7218 GLsizei required_min_size,
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
7817 7818
7818 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( 7819 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(
7819 HTMLCanvasElementOrOffscreenCanvas& result) const { 7820 HTMLCanvasElementOrOffscreenCanvas& result) const {
7820 if (canvas()) 7821 if (canvas())
7821 result.setHTMLCanvasElement(canvas()); 7822 result.setHTMLCanvasElement(canvas());
7822 else 7823 else
7823 result.setOffscreenCanvas(offscreenCanvas()); 7824 result.setOffscreenCanvas(offscreenCanvas());
7824 } 7825 }
7825 7826
7826 } // namespace blink 7827 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698