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

Side by Side Diff: Source/core/html/canvas/WebGLRenderingContextBase.cpp

Issue 1093673002: Removing the dependency on GraphicsContext for drawing images in 2D canvas (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | Annotate | Revision Log
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 3780 matching lines...) Expand 10 before | Expand all | Expand 10 after
3791 3791
3792 PassRefPtr<Image> WebGLRenderingContextBase::videoFrameToImage(HTMLVideoElement* video, BackingStoreCopy backingStoreCopy) 3792 PassRefPtr<Image> WebGLRenderingContextBase::videoFrameToImage(HTMLVideoElement* video, BackingStoreCopy backingStoreCopy)
3793 { 3793 {
3794 IntSize size(video->videoWidth(), video->videoHeight()); 3794 IntSize size(video->videoWidth(), video->videoHeight());
3795 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); 3795 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size);
3796 if (!buf) { 3796 if (!buf) {
3797 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory"); 3797 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory");
3798 return nullptr; 3798 return nullptr;
3799 } 3799 }
3800 IntRect destRect(0, 0, size.width(), size.height()); 3800 IntRect destRect(0, 0, size.width(), size.height());
3801 video->paintCurrentFrameInContext(buf->context(), destRect); 3801 video->paintCurrentFrame(buf->canvas(), destRect, nullptr);
3802 return buf->copyImage(backingStoreCopy); 3802 return buf->copyImage(backingStoreCopy);
3803 } 3803 }
3804 3804
3805 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat, 3805 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat,
3806 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti onState) 3806 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti onState)
3807 { 3807 {
3808 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except ionState) 3808 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except ionState)
3809 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0, format, type, 0, 0)) 3809 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0, format, type, 0, 0))
3810 return; 3810 return;
3811 3811
3812 // Go through the fast path doing a GPU-GPU textures copy without a readback to system memory if possible. 3812 // Go through the fast path doing a GPU-GPU textures copy without a readback to system memory if possible.
3813 // Otherwise, it will fall back to the normal SW path. 3813 // Otherwise, it will fall back to the normal SW path.
3814 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); 3814 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true);
3815 ASSERT(texture); 3815 ASSERT(texture);
3816 if (GL_TEXTURE_2D == target) { 3816 if (GL_TEXTURE_2D == target) {
3817 if (video->copyVideoTextureToPlatformTexture(webContext(), texture->obje ct(), level, internalformat, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 3817 if (video->copyVideoTextureToPlatformTexture(webContext(), texture->obje ct(), level, internalformat, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
3818 texture->setLevelInfo(target, level, internalformat, video->videoWid th(), video->videoHeight(), type); 3818 texture->setLevelInfo(target, level, internalformat, video->videoWid th(), video->videoHeight(), type);
3819 return; 3819 return;
3820 } 3820 }
3821 3821
3822 // Try using an accelerated image buffer, this allows YUV conversion to be done on the GPU. 3822 // Try using an accelerated image buffer, this allows YUV conversion to be done on the GPU.
3823 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBuffer Surface(IntSize(video->videoWidth(), video->videoHeight()))); 3823 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBuffer Surface(IntSize(video->videoWidth(), video->videoHeight())));
3824 if (surface->isValid()) { 3824 if (surface->isValid()) {
3825 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release( ))); 3825 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release( )));
3826 if (imageBuffer) { 3826 if (imageBuffer) {
3827 // The video element paints an RGBA frame into our surface here. By using an AcceleratedImageBufferSurface, 3827 // The video element paints an RGBA frame into our surface here. By using an AcceleratedImageBufferSurface,
3828 // we enable the WebMediaPlayer implementation to do any necessa ry color space conversion on the GPU (though it 3828 // we enable the WebMediaPlayer implementation to do any necessa ry color space conversion on the GPU (though it
3829 // may still do a CPU conversion and upload the results). 3829 // may still do a CPU conversion and upload the results).
3830 video->paintCurrentFrameInContext(imageBuffer->context(), IntRec t(0, 0, video->videoWidth(), video->videoHeight())); 3830 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, vi deo->videoWidth(), video->videoHeight()), nullptr);
3831 imageBuffer->context()->canvas()->flush(); 3831 imageBuffer->context()->canvas()->flush();
3832 3832
3833 // This is a straight GPU-GPU copy, any necessary color space co nversion was handled in the paintCurrentFrameInContext() call. 3833 // This is a straight GPU-GPU copy, any necessary color space co nversion was handled in the paintCurrentFrameInContext() call.
3834 if (imageBuffer->copyToPlatformTexture(webContext(), texture->ob ject(), internalformat, type, 3834 if (imageBuffer->copyToPlatformTexture(webContext(), texture->ob ject(), internalformat, type,
3835 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 3835 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
3836 texture->setLevelInfo(target, level, internalformat, video-> videoWidth(), video->videoHeight(), type); 3836 texture->setLevelInfo(target, level, internalformat, video-> videoWidth(), video->videoHeight(), type);
3837 return; 3837 return;
3838 } 3838 }
3839 } 3839 }
3840 } 3840 }
(...skipping 2252 matching lines...) Expand 10 before | Expand all | Expand 10 after
6093 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0; 6093 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0;
6094 } 6094 }
6095 #else 6095 #else
6096 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const 6096 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const
6097 { 6097 {
6098 return m_drawingBuffer.get(); 6098 return m_drawingBuffer.get();
6099 } 6099 }
6100 #endif 6100 #endif
6101 6101
6102 } // namespace blink 6102 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698