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 4830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4841 GLint internalformat, | 4841 GLint internalformat, |
4842 GLenum format, | 4842 GLenum format, |
4843 GLenum type, | 4843 GLenum type, |
4844 ImageData* pixels) { | 4844 ImageData* pixels) { |
4845 TexImageHelperImageData(kTexImage2D, target, level, internalformat, 0, format, | 4845 TexImageHelperImageData(kTexImage2D, target, level, internalformat, 0, format, |
4846 type, 1, 0, 0, 0, pixels, GetImageDataSize(pixels), | 4846 type, 1, 0, 0, 0, pixels, GetImageDataSize(pixels), |
4847 0); | 4847 0); |
4848 } | 4848 } |
4849 | 4849 |
4850 void WebGLRenderingContextBase::TexImageHelperHTMLImageElement( | 4850 void WebGLRenderingContextBase::TexImageHelperHTMLImageElement( |
| 4851 SecurityOrigin* security_origin, |
4851 TexImageFunctionID function_id, | 4852 TexImageFunctionID function_id, |
4852 GLenum target, | 4853 GLenum target, |
4853 GLint level, | 4854 GLint level, |
4854 GLint internalformat, | 4855 GLint internalformat, |
4855 GLenum format, | 4856 GLenum format, |
4856 GLenum type, | 4857 GLenum type, |
4857 GLint xoffset, | 4858 GLint xoffset, |
4858 GLint yoffset, | 4859 GLint yoffset, |
4859 GLint zoffset, | 4860 GLint zoffset, |
4860 HTMLImageElement* image, | 4861 HTMLImageElement* image, |
4861 const IntRect& source_image_rect, | 4862 const IntRect& source_image_rect, |
4862 GLsizei depth, | 4863 GLsizei depth, |
4863 GLint unpack_image_height, | 4864 GLint unpack_image_height, |
4864 ExceptionState& exception_state) { | 4865 ExceptionState& exception_state) { |
4865 const char* func_name = GetTexImageFunctionName(function_id); | 4866 const char* func_name = GetTexImageFunctionName(function_id); |
4866 if (isContextLost()) | 4867 if (isContextLost()) |
4867 return; | 4868 return; |
4868 if (!ValidateHTMLImageElement(func_name, image, exception_state)) | 4869 |
| 4870 if (!ValidateHTMLImageElement(security_origin, func_name, image, |
| 4871 exception_state)) |
4869 return; | 4872 return; |
4870 if (!ValidateTexImageBinding(func_name, function_id, target)) | 4873 if (!ValidateTexImageBinding(func_name, function_id, target)) |
4871 return; | 4874 return; |
4872 | 4875 |
4873 RefPtr<Image> image_for_render = image->CachedImage()->GetImage(); | 4876 RefPtr<Image> image_for_render = image->CachedImage()->GetImage(); |
4874 if (image_for_render && image_for_render->IsSVGImage()) { | 4877 if (image_for_render && image_for_render->IsSVGImage()) { |
4875 if (canvas()) { | 4878 if (canvas()) { |
4876 UseCounter::Count(canvas()->GetDocument(), UseCounter::kSVGInWebGL); | 4879 UseCounter::Count(canvas()->GetDocument(), UseCounter::kSVGInWebGL); |
4877 } | 4880 } |
4878 image_for_render = DrawImageIntoBuffer( | 4881 image_for_render = DrawImageIntoBuffer( |
(...skipping 12 matching lines...) Expand all Loading... |
4891 xoffset, yoffset, zoffset)) | 4894 xoffset, yoffset, zoffset)) |
4892 return; | 4895 return; |
4893 | 4896 |
4894 TexImageImpl(function_id, target, level, internalformat, xoffset, yoffset, | 4897 TexImageImpl(function_id, target, level, internalformat, xoffset, yoffset, |
4895 zoffset, format, type, image_for_render.Get(), | 4898 zoffset, format, type, image_for_render.Get(), |
4896 WebGLImageConversion::kHtmlDomImage, unpack_flip_y_, | 4899 WebGLImageConversion::kHtmlDomImage, unpack_flip_y_, |
4897 unpack_premultiply_alpha_, source_image_rect, depth, | 4900 unpack_premultiply_alpha_, source_image_rect, depth, |
4898 unpack_image_height); | 4901 unpack_image_height); |
4899 } | 4902 } |
4900 | 4903 |
4901 void WebGLRenderingContextBase::texImage2D(GLenum target, | 4904 void WebGLRenderingContextBase::texImage2D(ExecutionContext* execution_context, |
| 4905 GLenum target, |
4902 GLint level, | 4906 GLint level, |
4903 GLint internalformat, | 4907 GLint internalformat, |
4904 GLenum format, | 4908 GLenum format, |
4905 GLenum type, | 4909 GLenum type, |
4906 HTMLImageElement* image, | 4910 HTMLImageElement* image, |
4907 ExceptionState& exception_state) { | 4911 ExceptionState& exception_state) { |
4908 TexImageHelperHTMLImageElement(kTexImage2D, target, level, internalformat, | 4912 TexImageHelperHTMLImageElement(execution_context->GetSecurityOrigin(), |
| 4913 kTexImage2D, target, level, internalformat, |
4909 format, type, 0, 0, 0, image, | 4914 format, type, 0, 0, 0, image, |
4910 SentinelEmptyRect(), 1, 0, exception_state); | 4915 SentinelEmptyRect(), 1, 0, exception_state); |
4911 } | 4916 } |
4912 | 4917 |
4913 bool WebGLRenderingContextBase::CanUseTexImageByGPU(GLenum type) { | 4918 bool WebGLRenderingContextBase::CanUseTexImageByGPU(GLenum type) { |
4914 #if OS(MACOSX) | 4919 #if OS(MACOSX) |
4915 // RGB5_A1 is not color-renderable on NVIDIA Mac, see crbug.com/676209. | 4920 // RGB5_A1 is not color-renderable on NVIDIA Mac, see crbug.com/676209. |
4916 // Though, glCopyTextureCHROMIUM can handle RGB5_A1 internalformat by doing a | 4921 // Though, glCopyTextureCHROMIUM can handle RGB5_A1 internalformat by doing a |
4917 // fallback path, but it doesn't know the type info. So, we still cannot do | 4922 // fallback path, but it doesn't know the type info. So, we still cannot do |
4918 // the fallback path in glCopyTextureCHROMIUM for | 4923 // the fallback path in glCopyTextureCHROMIUM for |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5055 } | 5060 } |
5056 ContextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 5061 ContextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
5057 GL_TEXTURE_2D, 0, 0); | 5062 GL_TEXTURE_2D, 0, 0); |
5058 RestoreCurrentFramebuffer(); | 5063 RestoreCurrentFramebuffer(); |
5059 ContextGL()->DeleteFramebuffers(1, &tmp_fbo); | 5064 ContextGL()->DeleteFramebuffers(1, &tmp_fbo); |
5060 ContextGL()->DeleteTextures(1, &target_texture); | 5065 ContextGL()->DeleteTextures(1, &target_texture); |
5061 } | 5066 } |
5062 } | 5067 } |
5063 | 5068 |
5064 void WebGLRenderingContextBase::TexImageHelperHTMLCanvasElement( | 5069 void WebGLRenderingContextBase::TexImageHelperHTMLCanvasElement( |
| 5070 SecurityOrigin* security_origin, |
5065 TexImageFunctionID function_id, | 5071 TexImageFunctionID function_id, |
5066 GLenum target, | 5072 GLenum target, |
5067 GLint level, | 5073 GLint level, |
5068 GLint internalformat, | 5074 GLint internalformat, |
5069 GLenum format, | 5075 GLenum format, |
5070 GLenum type, | 5076 GLenum type, |
5071 GLint xoffset, | 5077 GLint xoffset, |
5072 GLint yoffset, | 5078 GLint yoffset, |
5073 GLint zoffset, | 5079 GLint zoffset, |
5074 HTMLCanvasElement* canvas, | 5080 HTMLCanvasElement* canvas, |
5075 const IntRect& source_sub_rectangle, | 5081 const IntRect& source_sub_rectangle, |
5076 GLsizei depth, | 5082 GLsizei depth, |
5077 GLint unpack_image_height, | 5083 GLint unpack_image_height, |
5078 ExceptionState& exception_state) { | 5084 ExceptionState& exception_state) { |
5079 const char* func_name = GetTexImageFunctionName(function_id); | 5085 const char* func_name = GetTexImageFunctionName(function_id); |
5080 if (isContextLost()) | 5086 if (isContextLost()) |
5081 return; | 5087 return; |
5082 if (!ValidateHTMLCanvasElement(func_name, canvas, exception_state)) | 5088 |
| 5089 if (!ValidateHTMLCanvasElement(security_origin, func_name, canvas, |
| 5090 exception_state)) |
5083 return; | 5091 return; |
5084 WebGLTexture* texture = | 5092 WebGLTexture* texture = |
5085 ValidateTexImageBinding(func_name, function_id, target); | 5093 ValidateTexImageBinding(func_name, function_id, target); |
5086 if (!texture) | 5094 if (!texture) |
5087 return; | 5095 return; |
5088 TexImageFunctionType function_type; | 5096 TexImageFunctionType function_type; |
5089 if (function_id == kTexImage2D) | 5097 if (function_id == kTexImage2D) |
5090 function_type = kTexImage; | 5098 function_type = kTexImage; |
5091 else | 5099 else |
5092 function_type = kTexSubImage; | 5100 function_type = kTexSubImage; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5152 canvas | 5160 canvas |
5153 ->CopiedImage(kFrontBuffer, kPreferAcceleration, | 5161 ->CopiedImage(kFrontBuffer, kPreferAcceleration, |
5154 FunctionIDToSnapshotReason(function_id)) | 5162 FunctionIDToSnapshotReason(function_id)) |
5155 .Get(), | 5163 .Get(), |
5156 WebGLImageConversion::kHtmlDomCanvas, unpack_flip_y_, | 5164 WebGLImageConversion::kHtmlDomCanvas, unpack_flip_y_, |
5157 unpack_premultiply_alpha_, source_sub_rectangle, depth, | 5165 unpack_premultiply_alpha_, source_sub_rectangle, depth, |
5158 unpack_image_height); | 5166 unpack_image_height); |
5159 } | 5167 } |
5160 } | 5168 } |
5161 | 5169 |
5162 void WebGLRenderingContextBase::texImage2D(GLenum target, | 5170 void WebGLRenderingContextBase::texImage2D(ExecutionContext* execution_context, |
| 5171 GLenum target, |
5163 GLint level, | 5172 GLint level, |
5164 GLint internalformat, | 5173 GLint internalformat, |
5165 GLenum format, | 5174 GLenum format, |
5166 GLenum type, | 5175 GLenum type, |
5167 HTMLCanvasElement* canvas, | 5176 HTMLCanvasElement* canvas, |
5168 ExceptionState& exception_state) { | 5177 ExceptionState& exception_state) { |
5169 TexImageHelperHTMLCanvasElement( | 5178 TexImageHelperHTMLCanvasElement( |
5170 kTexImage2D, target, level, internalformat, format, type, 0, 0, 0, canvas, | 5179 execution_context->GetSecurityOrigin(), kTexImage2D, target, level, |
| 5180 internalformat, format, type, 0, 0, 0, canvas, |
5171 GetTextureSourceSize(canvas), 1, 0, exception_state); | 5181 GetTextureSourceSize(canvas), 1, 0, exception_state); |
5172 } | 5182 } |
5173 | 5183 |
5174 PassRefPtr<Image> WebGLRenderingContextBase::VideoFrameToImage( | 5184 PassRefPtr<Image> WebGLRenderingContextBase::VideoFrameToImage( |
5175 HTMLVideoElement* video) { | 5185 HTMLVideoElement* video) { |
5176 IntSize size(video->videoWidth(), video->videoHeight()); | 5186 IntSize size(video->videoWidth(), video->videoHeight()); |
5177 ImageBuffer* buf = generated_image_cache_.GetImageBuffer(size); | 5187 ImageBuffer* buf = generated_image_cache_.GetImageBuffer(size); |
5178 if (!buf) { | 5188 if (!buf) { |
5179 SynthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory"); | 5189 SynthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory"); |
5180 return nullptr; | 5190 return nullptr; |
5181 } | 5191 } |
5182 IntRect dest_rect(0, 0, size.Width(), size.Height()); | 5192 IntRect dest_rect(0, 0, size.Width(), size.Height()); |
5183 video->PaintCurrentFrame(buf->Canvas(), dest_rect, nullptr); | 5193 video->PaintCurrentFrame(buf->Canvas(), dest_rect, nullptr); |
5184 return buf->NewImageSnapshot(); | 5194 return buf->NewImageSnapshot(); |
5185 } | 5195 } |
5186 | 5196 |
5187 void WebGLRenderingContextBase::TexImageHelperHTMLVideoElement( | 5197 void WebGLRenderingContextBase::TexImageHelperHTMLVideoElement( |
| 5198 SecurityOrigin* security_origin, |
5188 TexImageFunctionID function_id, | 5199 TexImageFunctionID function_id, |
5189 GLenum target, | 5200 GLenum target, |
5190 GLint level, | 5201 GLint level, |
5191 GLint internalformat, | 5202 GLint internalformat, |
5192 GLenum format, | 5203 GLenum format, |
5193 GLenum type, | 5204 GLenum type, |
5194 GLint xoffset, | 5205 GLint xoffset, |
5195 GLint yoffset, | 5206 GLint yoffset, |
5196 GLint zoffset, | 5207 GLint zoffset, |
5197 HTMLVideoElement* video, | 5208 HTMLVideoElement* video, |
5198 const IntRect& source_image_rect, | 5209 const IntRect& source_image_rect, |
5199 GLsizei depth, | 5210 GLsizei depth, |
5200 GLint unpack_image_height, | 5211 GLint unpack_image_height, |
5201 ExceptionState& exception_state) { | 5212 ExceptionState& exception_state) { |
5202 const char* func_name = GetTexImageFunctionName(function_id); | 5213 const char* func_name = GetTexImageFunctionName(function_id); |
5203 if (isContextLost()) | 5214 if (isContextLost()) |
5204 return; | 5215 return; |
5205 if (!ValidateHTMLVideoElement(func_name, video, exception_state)) | 5216 |
| 5217 if (!ValidateHTMLVideoElement(security_origin, func_name, video, |
| 5218 exception_state)) |
5206 return; | 5219 return; |
5207 WebGLTexture* texture = | 5220 WebGLTexture* texture = |
5208 ValidateTexImageBinding(func_name, function_id, target); | 5221 ValidateTexImageBinding(func_name, function_id, target); |
5209 if (!texture) | 5222 if (!texture) |
5210 return; | 5223 return; |
5211 TexImageFunctionType function_type; | 5224 TexImageFunctionType function_type; |
5212 if (function_id == kTexImage2D || function_id == kTexImage3D) | 5225 if (function_id == kTexImage2D || function_id == kTexImage3D) |
5213 function_type = kTexImage; | 5226 function_type = kTexImage; |
5214 else | 5227 else |
5215 function_type = kTexSubImage; | 5228 function_type = kTexSubImage; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5321 GLuint target_texture, | 5334 GLuint target_texture, |
5322 bool flip_y, | 5335 bool flip_y, |
5323 GLint xoffset, | 5336 GLint xoffset, |
5324 GLint yoffset, | 5337 GLint yoffset, |
5325 const IntRect& source_sub_rect) { | 5338 const IntRect& source_sub_rect) { |
5326 bitmap->BitmapImage()->CopyToTexture( | 5339 bitmap->BitmapImage()->CopyToTexture( |
5327 GetDrawingBuffer()->ContextProvider(), target, target_texture, flip_y, | 5340 GetDrawingBuffer()->ContextProvider(), target, target_texture, flip_y, |
5328 IntPoint(xoffset, yoffset), source_sub_rect); | 5341 IntPoint(xoffset, yoffset), source_sub_rect); |
5329 } | 5342 } |
5330 | 5343 |
5331 void WebGLRenderingContextBase::texImage2D(GLenum target, | 5344 void WebGLRenderingContextBase::texImage2D(ExecutionContext* execution_context, |
| 5345 GLenum target, |
5332 GLint level, | 5346 GLint level, |
5333 GLint internalformat, | 5347 GLint internalformat, |
5334 GLenum format, | 5348 GLenum format, |
5335 GLenum type, | 5349 GLenum type, |
5336 HTMLVideoElement* video, | 5350 HTMLVideoElement* video, |
5337 ExceptionState& exception_state) { | 5351 ExceptionState& exception_state) { |
5338 TexImageHelperHTMLVideoElement(kTexImage2D, target, level, internalformat, | 5352 TexImageHelperHTMLVideoElement(execution_context->GetSecurityOrigin(), |
| 5353 kTexImage2D, target, level, internalformat, |
5339 format, type, 0, 0, 0, video, | 5354 format, type, 0, 0, 0, video, |
5340 SentinelEmptyRect(), 1, 0, exception_state); | 5355 SentinelEmptyRect(), 1, 0, exception_state); |
5341 } | 5356 } |
5342 | 5357 |
5343 void WebGLRenderingContextBase::TexImageHelperImageBitmap( | 5358 void WebGLRenderingContextBase::TexImageHelperImageBitmap( |
5344 TexImageFunctionID function_id, | 5359 TexImageFunctionID function_id, |
5345 GLenum target, | 5360 GLenum target, |
5346 GLint level, | 5361 GLint level, |
5347 GLint internalformat, | 5362 GLint internalformat, |
5348 GLenum format, | 5363 GLenum format, |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5573 GLint xoffset, | 5588 GLint xoffset, |
5574 GLint yoffset, | 5589 GLint yoffset, |
5575 GLenum format, | 5590 GLenum format, |
5576 GLenum type, | 5591 GLenum type, |
5577 ImageData* pixels) { | 5592 ImageData* pixels) { |
5578 TexImageHelperImageData(kTexSubImage2D, target, level, 0, 0, format, type, 1, | 5593 TexImageHelperImageData(kTexSubImage2D, target, level, 0, 0, format, type, 1, |
5579 xoffset, yoffset, 0, pixels, GetImageDataSize(pixels), | 5594 xoffset, yoffset, 0, pixels, GetImageDataSize(pixels), |
5580 0); | 5595 0); |
5581 } | 5596 } |
5582 | 5597 |
5583 void WebGLRenderingContextBase::texSubImage2D(GLenum target, | 5598 void WebGLRenderingContextBase::texSubImage2D( |
5584 GLint level, | 5599 ExecutionContext* execution_context, |
5585 GLint xoffset, | 5600 GLenum target, |
5586 GLint yoffset, | 5601 GLint level, |
5587 GLenum format, | 5602 GLint xoffset, |
5588 GLenum type, | 5603 GLint yoffset, |
5589 HTMLImageElement* image, | 5604 GLenum format, |
5590 ExceptionState& exception_state) { | 5605 GLenum type, |
5591 TexImageHelperHTMLImageElement(kTexSubImage2D, target, level, 0, format, type, | 5606 HTMLImageElement* image, |
| 5607 ExceptionState& exception_state) { |
| 5608 TexImageHelperHTMLImageElement(execution_context->GetSecurityOrigin(), |
| 5609 kTexSubImage2D, target, level, 0, format, type, |
5592 xoffset, yoffset, 0, image, | 5610 xoffset, yoffset, 0, image, |
5593 SentinelEmptyRect(), 1, 0, exception_state); | 5611 SentinelEmptyRect(), 1, 0, exception_state); |
5594 } | 5612 } |
5595 | 5613 |
5596 void WebGLRenderingContextBase::texSubImage2D(GLenum target, | 5614 void WebGLRenderingContextBase::texSubImage2D( |
5597 GLint level, | 5615 ExecutionContext* execution_context, |
5598 GLint xoffset, | 5616 GLenum target, |
5599 GLint yoffset, | 5617 GLint level, |
5600 GLenum format, | 5618 GLint xoffset, |
5601 GLenum type, | 5619 GLint yoffset, |
5602 HTMLCanvasElement* canvas, | 5620 GLenum format, |
5603 ExceptionState& exception_state) { | 5621 GLenum type, |
| 5622 HTMLCanvasElement* canvas, |
| 5623 ExceptionState& exception_state) { |
5604 TexImageHelperHTMLCanvasElement( | 5624 TexImageHelperHTMLCanvasElement( |
5605 kTexSubImage2D, target, level, 0, format, type, xoffset, yoffset, 0, | 5625 execution_context->GetSecurityOrigin(), kTexSubImage2D, target, level, 0, |
5606 canvas, GetTextureSourceSize(canvas), 1, 0, exception_state); | 5626 format, type, xoffset, yoffset, 0, canvas, GetTextureSourceSize(canvas), |
| 5627 1, 0, exception_state); |
5607 } | 5628 } |
5608 | 5629 |
5609 void WebGLRenderingContextBase::texSubImage2D(GLenum target, | 5630 void WebGLRenderingContextBase::texSubImage2D( |
5610 GLint level, | 5631 ExecutionContext* execution_context, |
5611 GLint xoffset, | 5632 GLenum target, |
5612 GLint yoffset, | 5633 GLint level, |
5613 GLenum format, | 5634 GLint xoffset, |
5614 GLenum type, | 5635 GLint yoffset, |
5615 HTMLVideoElement* video, | 5636 GLenum format, |
5616 ExceptionState& exception_state) { | 5637 GLenum type, |
5617 TexImageHelperHTMLVideoElement(kTexSubImage2D, target, level, 0, format, type, | 5638 HTMLVideoElement* video, |
| 5639 ExceptionState& exception_state) { |
| 5640 TexImageHelperHTMLVideoElement(execution_context->GetSecurityOrigin(), |
| 5641 kTexSubImage2D, target, level, 0, format, type, |
5618 xoffset, yoffset, 0, video, | 5642 xoffset, yoffset, 0, video, |
5619 SentinelEmptyRect(), 1, 0, exception_state); | 5643 SentinelEmptyRect(), 1, 0, exception_state); |
5620 } | 5644 } |
5621 | 5645 |
5622 void WebGLRenderingContextBase::texSubImage2D(GLenum target, | 5646 void WebGLRenderingContextBase::texSubImage2D(GLenum target, |
5623 GLint level, | 5647 GLint level, |
5624 GLint xoffset, | 5648 GLint xoffset, |
5625 GLint yoffset, | 5649 GLint yoffset, |
5626 GLenum format, | 5650 GLenum format, |
5627 GLenum type, | 5651 GLenum type, |
(...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7280 } | 7304 } |
7281 | 7305 |
7282 void WebGLRenderingContextBase::RemoveBoundBuffer(WebGLBuffer* buffer) { | 7306 void WebGLRenderingContextBase::RemoveBoundBuffer(WebGLBuffer* buffer) { |
7283 if (bound_array_buffer_ == buffer) | 7307 if (bound_array_buffer_ == buffer) |
7284 bound_array_buffer_ = nullptr; | 7308 bound_array_buffer_ = nullptr; |
7285 | 7309 |
7286 bound_vertex_array_object_->UnbindBuffer(buffer); | 7310 bound_vertex_array_object_->UnbindBuffer(buffer); |
7287 } | 7311 } |
7288 | 7312 |
7289 bool WebGLRenderingContextBase::ValidateHTMLImageElement( | 7313 bool WebGLRenderingContextBase::ValidateHTMLImageElement( |
| 7314 SecurityOrigin* security_origin, |
7290 const char* function_name, | 7315 const char* function_name, |
7291 HTMLImageElement* image, | 7316 HTMLImageElement* image, |
7292 ExceptionState& exception_state) { | 7317 ExceptionState& exception_state) { |
7293 if (!image || !image->CachedImage()) { | 7318 if (!image || !image->CachedImage()) { |
7294 SynthesizeGLError(GL_INVALID_VALUE, function_name, "no image"); | 7319 SynthesizeGLError(GL_INVALID_VALUE, function_name, "no image"); |
7295 return false; | 7320 return false; |
7296 } | 7321 } |
7297 const KURL& url = image->CachedImage()->GetResponse().Url(); | 7322 const KURL& url = image->CachedImage()->GetResponse().Url(); |
7298 if (url.IsNull() || url.IsEmpty() || !url.IsValid()) { | 7323 if (url.IsNull() || url.IsEmpty() || !url.IsValid()) { |
7299 SynthesizeGLError(GL_INVALID_VALUE, function_name, "invalid image"); | 7324 SynthesizeGLError(GL_INVALID_VALUE, function_name, "invalid image"); |
7300 return false; | 7325 return false; |
7301 } | 7326 } |
7302 | 7327 |
7303 if (WouldTaintOrigin(image)) { | 7328 if (WouldTaintOrigin(image, security_origin)) { |
7304 exception_state.ThrowSecurityError("The cross-origin image at " + | 7329 exception_state.ThrowSecurityError("The cross-origin image at " + |
7305 url.ElidedString() + | 7330 url.ElidedString() + |
7306 " may not be loaded."); | 7331 " may not be loaded."); |
7307 return false; | 7332 return false; |
7308 } | 7333 } |
7309 return true; | 7334 return true; |
7310 } | 7335 } |
7311 | 7336 |
7312 bool WebGLRenderingContextBase::ValidateHTMLCanvasElement( | 7337 bool WebGLRenderingContextBase::ValidateHTMLCanvasElement( |
| 7338 SecurityOrigin* security_origin, |
7313 const char* function_name, | 7339 const char* function_name, |
7314 HTMLCanvasElement* canvas, | 7340 HTMLCanvasElement* canvas, |
7315 ExceptionState& exception_state) { | 7341 ExceptionState& exception_state) { |
7316 if (!canvas || !canvas->IsPaintable()) { | 7342 if (!canvas || !canvas->IsPaintable()) { |
7317 SynthesizeGLError(GL_INVALID_VALUE, function_name, "no canvas"); | 7343 SynthesizeGLError(GL_INVALID_VALUE, function_name, "no canvas"); |
7318 return false; | 7344 return false; |
7319 } | 7345 } |
7320 if (WouldTaintOrigin(canvas)) { | 7346 |
| 7347 if (WouldTaintOrigin(canvas, security_origin)) { |
7321 exception_state.ThrowSecurityError("Tainted canvases may not be loaded."); | 7348 exception_state.ThrowSecurityError("Tainted canvases may not be loaded."); |
7322 return false; | 7349 return false; |
7323 } | 7350 } |
7324 return true; | 7351 return true; |
7325 } | 7352 } |
7326 | 7353 |
7327 bool WebGLRenderingContextBase::ValidateHTMLVideoElement( | 7354 bool WebGLRenderingContextBase::ValidateHTMLVideoElement( |
| 7355 SecurityOrigin* security_origin, |
7328 const char* function_name, | 7356 const char* function_name, |
7329 HTMLVideoElement* video, | 7357 HTMLVideoElement* video, |
7330 ExceptionState& exception_state) { | 7358 ExceptionState& exception_state) { |
7331 if (!video || !video->videoWidth() || !video->videoHeight()) { | 7359 if (!video || !video->videoWidth() || !video->videoHeight()) { |
7332 SynthesizeGLError(GL_INVALID_VALUE, function_name, "no video"); | 7360 SynthesizeGLError(GL_INVALID_VALUE, function_name, "no video"); |
7333 return false; | 7361 return false; |
7334 } | 7362 } |
7335 | 7363 |
7336 if (WouldTaintOrigin(video)) { | 7364 if (WouldTaintOrigin(video, security_origin)) { |
7337 exception_state.ThrowSecurityError( | 7365 exception_state.ThrowSecurityError( |
7338 "The video element contains cross-origin data, and may not be loaded."); | 7366 "The video element contains cross-origin data, and may not be loaded."); |
7339 return false; | 7367 return false; |
7340 } | 7368 } |
7341 return true; | 7369 return true; |
7342 } | 7370 } |
7343 | 7371 |
7344 bool WebGLRenderingContextBase::ValidateImageBitmap( | 7372 bool WebGLRenderingContextBase::ValidateImageBitmap( |
7345 const char* function_name, | 7373 const char* function_name, |
7346 ImageBitmap* bitmap, | 7374 ImageBitmap* bitmap, |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7807 | 7835 |
7808 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7836 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
7809 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7837 HTMLCanvasElementOrOffscreenCanvas& result) const { |
7810 if (canvas()) | 7838 if (canvas()) |
7811 result.setHTMLCanvasElement(canvas()); | 7839 result.setHTMLCanvasElement(canvas()); |
7812 else | 7840 else |
7813 result.setOffscreenCanvas(offscreenCanvas()); | 7841 result.setOffscreenCanvas(offscreenCanvas()); |
7814 } | 7842 } |
7815 | 7843 |
7816 } // namespace blink | 7844 } // namespace blink |
OLD | NEW |