Chromium Code Reviews| 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 3585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3596 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat, | 3596 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat, |
| 3597 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep tionState) | 3597 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep tionState) |
| 3598 { | 3598 { |
| 3599 if (isContextLost() || !validateHTMLCanvasElement("texImage2D", canvas, exce ptionState) || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLCanvas Element, target, level, internalformat, canvas->width(), canvas->height(), 0, fo rmat, type, 0, 0)) | 3599 if (isContextLost() || !validateHTMLCanvasElement("texImage2D", canvas, exce ptionState) || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLCanvas Element, target, level, internalformat, canvas->width(), canvas->height(), 0, fo rmat, type, 0, 0)) |
| 3600 return; | 3600 return; |
| 3601 | 3601 |
| 3602 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); | 3602 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); |
| 3603 | 3603 |
| 3604 // If possible, copy from the canvas element directly to the texture | 3604 // If possible, copy from the canvas element directly to the texture |
| 3605 // via the GPU, without a read-back to system memory. | 3605 // via the GPU, without a read-back to system memory. |
| 3606 if (GL_TEXTURE_2D == target && texture) { | 3606 if (canvas->renderingContext() && GL_TEXTURE_2D == target && texture) { |
| 3607 ScopedTexture2DRestorer restorer(this); | 3607 ScopedTexture2DRestorer restorer(this); |
| 3608 | 3608 |
| 3609 if (!canvas->is3D()) { | 3609 if (!canvas->is3D()) { |
| 3610 ImageBuffer* buffer = canvas->buffer(); | 3610 ImageBuffer* buffer = canvas->buffer(); |
| 3611 if (buffer && buffer->copyToPlatformTexture(webContext(), texture->o bject(), internalformat, type, | 3611 if (buffer && buffer->copyToPlatformTexture(webContext(), texture->o bject(), internalformat, type, |
| 3612 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 3612 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| 3613 texture->setLevelInfo(target, level, internalformat, canvas->wid th(), canvas->height(), type); | 3613 texture->setLevelInfo(target, level, internalformat, canvas->wid th(), canvas->height(), type); |
| 3614 return; | 3614 return; |
| 3615 } | 3615 } |
| 3616 } else { | 3616 } else { |
| 3617 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas-> renderingContext()); | 3617 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas-> renderingContext()); |
| 3618 ScopedTexture2DRestorer restorer(gl); | 3618 ScopedTexture2DRestorer restorer(gl); |
| 3619 if (gl && gl->drawingBuffer()->copyToPlatformTexture(webContext(), t exture->object(), internalformat, type, | 3619 if (gl->drawingBuffer()->copyToPlatformTexture(webContext(), texture ->object(), internalformat, type, |
| 3620 level, m_unpackPremultiplyAlpha, !m_unpackFlipY, BackBuffer)) { | 3620 level, m_unpackPremultiplyAlpha, !m_unpackFlipY, BackBuffer)) { |
| 3621 texture->setLevelInfo(target, level, internalformat, canvas->wid th(), canvas->height(), type); | 3621 texture->setLevelInfo(target, level, internalformat, canvas->wid th(), canvas->height(), type); |
| 3622 return; | 3622 return; |
| 3623 } | 3623 } |
| 3624 } | 3624 } |
| 3625 } | 3625 } |
| 3626 | 3626 |
| 3627 texImage2DImpl(target, level, internalformat, format, type, canvas->copiedIm age(BackBuffer), WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPre multiplyAlpha, exceptionState); | 3627 texImage2DImpl(target, level, internalformat, format, type, canvas->copiedIm age(BackBuffer).get(), WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unp ackPremultiplyAlpha, exceptionState); |
|
Ken Russell (switch to Gerrit)
2014/12/03 02:59:54
In general a returned PassRefPtr is supposed to be
| |
| 3628 } | 3628 } |
| 3629 | 3629 |
| 3630 PassRefPtr<Image> WebGLRenderingContextBase::videoFrameToImage(HTMLVideoElement* video, BackingStoreCopy backingStoreCopy) | 3630 PassRefPtr<Image> WebGLRenderingContextBase::videoFrameToImage(HTMLVideoElement* video, BackingStoreCopy backingStoreCopy) |
| 3631 { | 3631 { |
| 3632 IntSize size(video->videoWidth(), video->videoHeight()); | 3632 IntSize size(video->videoWidth(), video->videoHeight()); |
| 3633 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); | 3633 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); |
| 3634 if (!buf) { | 3634 if (!buf) { |
| 3635 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory"); | 3635 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory"); |
| 3636 return nullptr; | 3636 return nullptr; |
| 3637 } | 3637 } |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3851 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen der.get(), WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultipl yAlpha, exceptionState); | 3851 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen der.get(), WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultipl yAlpha, exceptionState); |
| 3852 } | 3852 } |
| 3853 | 3853 |
| 3854 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 3854 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
| 3855 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep tionState) | 3855 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep tionState) |
| 3856 { | 3856 { |
| 3857 if (isContextLost() || !validateHTMLCanvasElement("texSubImage2D", canvas, e xceptionState) | 3857 if (isContextLost() || !validateHTMLCanvasElement("texSubImage2D", canvas, e xceptionState) |
| 3858 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLCanvasElem ent, target, level, format, canvas->width(), canvas->height(), 0, format, type, xoffset, yoffset)) | 3858 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLCanvasElem ent, target, level, format, canvas->width(), canvas->height(), 0, format, type, xoffset, yoffset)) |
| 3859 return; | 3859 return; |
| 3860 | 3860 |
| 3861 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas->cop iedImage(BackBuffer), WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpa ckPremultiplyAlpha, exceptionState); | 3861 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas->cop iedImage(BackBuffer).get(), WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyAlpha, exceptionState); |
| 3862 } | 3862 } |
| 3863 | 3863 |
| 3864 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 3864 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
| 3865 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti onState) | 3865 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti onState) |
| 3866 { | 3866 { |
| 3867 if (isContextLost() || !validateHTMLVideoElement("texSubImage2D", video, exc eptionState) | 3867 if (isContextLost() || !validateHTMLVideoElement("texSubImage2D", video, exc eptionState) |
| 3868 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLVideoEleme nt, target, level, format, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset)) | 3868 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLVideoEleme nt, target, level, format, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset)) |
| 3869 return; | 3869 return; |
| 3870 | 3870 |
| 3871 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod e()); | 3871 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod e()); |
| (...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5359 | 5359 |
| 5360 if (wouldTaintOrigin(image)) { | 5360 if (wouldTaintOrigin(image)) { |
| 5361 exceptionState.throwSecurityError("The cross-origin image at " + url.eli dedString() + " may not be loaded."); | 5361 exceptionState.throwSecurityError("The cross-origin image at " + url.eli dedString() + " may not be loaded."); |
| 5362 return false; | 5362 return false; |
| 5363 } | 5363 } |
| 5364 return true; | 5364 return true; |
| 5365 } | 5365 } |
| 5366 | 5366 |
| 5367 bool WebGLRenderingContextBase::validateHTMLCanvasElement(const char* functionNa me, HTMLCanvasElement* canvas, ExceptionState& exceptionState) | 5367 bool WebGLRenderingContextBase::validateHTMLCanvasElement(const char* functionNa me, HTMLCanvasElement* canvas, ExceptionState& exceptionState) |
| 5368 { | 5368 { |
| 5369 if (!canvas || !canvas->buffer()) { | 5369 if (!canvas || !canvas->isPaintable()) { |
| 5370 synthesizeGLError(GL_INVALID_VALUE, functionName, "no canvas"); | 5370 synthesizeGLError(GL_INVALID_VALUE, functionName, "no canvas"); |
| 5371 return false; | 5371 return false; |
| 5372 } | 5372 } |
| 5373 if (wouldTaintOrigin(canvas)) { | 5373 if (wouldTaintOrigin(canvas)) { |
| 5374 exceptionState.throwSecurityError("Tainted canvases may not be loaded.") ; | 5374 exceptionState.throwSecurityError("Tainted canvases may not be loaded.") ; |
| 5375 return false; | 5375 return false; |
| 5376 } | 5376 } |
| 5377 return true; | 5377 return true; |
| 5378 } | 5378 } |
| 5379 | 5379 |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5866 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0; | 5866 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0; |
| 5867 } | 5867 } |
| 5868 #else | 5868 #else |
| 5869 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 5869 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
| 5870 { | 5870 { |
| 5871 return m_drawingBuffer.get(); | 5871 return m_drawingBuffer.get(); |
| 5872 } | 5872 } |
| 5873 #endif | 5873 #endif |
| 5874 | 5874 |
| 5875 } // namespace blink | 5875 } // namespace blink |
| OLD | NEW |