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

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: fixup Created 5 years, 6 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 3896 matching lines...) Expand 10 before | Expand all | Expand 10 after
3907 3907
3908 PassRefPtr<Image> WebGLRenderingContextBase::videoFrameToImage(HTMLVideoElement* video, BackingStoreCopy backingStoreCopy) 3908 PassRefPtr<Image> WebGLRenderingContextBase::videoFrameToImage(HTMLVideoElement* video, BackingStoreCopy backingStoreCopy)
3909 { 3909 {
3910 IntSize size(video->videoWidth(), video->videoHeight()); 3910 IntSize size(video->videoWidth(), video->videoHeight());
3911 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); 3911 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size);
3912 if (!buf) { 3912 if (!buf) {
3913 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory"); 3913 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory");
3914 return nullptr; 3914 return nullptr;
3915 } 3915 }
3916 IntRect destRect(0, 0, size.width(), size.height()); 3916 IntRect destRect(0, 0, size.width(), size.height());
3917 video->paintCurrentFrameInContext(buf->context(), destRect); 3917 video->paintCurrentFrame(buf->canvas(), destRect, nullptr);
3918 return buf->copyImage(backingStoreCopy); 3918 return buf->copyImage(backingStoreCopy);
3919 } 3919 }
3920 3920
3921 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat, 3921 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat,
3922 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti onState) 3922 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti onState)
3923 { 3923 {
3924 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except ionState) 3924 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except ionState)
3925 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0, format, type, 0, 0)) 3925 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0, format, type, 0, 0))
3926 return; 3926 return;
3927 3927
3928 // Go through the fast path doing a GPU-GPU textures copy without a readback to system memory if possible. 3928 // Go through the fast path doing a GPU-GPU textures copy without a readback to system memory if possible.
3929 // Otherwise, it will fall back to the normal SW path. 3929 // Otherwise, it will fall back to the normal SW path.
3930 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); 3930 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true);
3931 ASSERT(texture); 3931 ASSERT(texture);
3932 if (GL_TEXTURE_2D == target) { 3932 if (GL_TEXTURE_2D == target) {
3933 if (video->copyVideoTextureToPlatformTexture(webContext(), texture->obje ct(), level, internalformat, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 3933 if (video->copyVideoTextureToPlatformTexture(webContext(), texture->obje ct(), level, internalformat, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
3934 texture->setLevelInfo(target, level, internalformat, video->videoWid th(), video->videoHeight(), 1, type); 3934 texture->setLevelInfo(target, level, internalformat, video->videoWid th(), video->videoHeight(), 1, type);
3935 return; 3935 return;
3936 } 3936 }
3937 3937
3938 // Try using an accelerated image buffer, this allows YUV conversion to be done on the GPU. 3938 // Try using an accelerated image buffer, this allows YUV conversion to be done on the GPU.
3939 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBuffer Surface(IntSize(video->videoWidth(), video->videoHeight()))); 3939 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBuffer Surface(IntSize(video->videoWidth(), video->videoHeight())));
3940 if (surface->isValid()) { 3940 if (surface->isValid()) {
3941 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release( ))); 3941 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release( )));
3942 if (imageBuffer) { 3942 if (imageBuffer) {
3943 // The video element paints an RGBA frame into our surface here. By using an AcceleratedImageBufferSurface, 3943 // The video element paints an RGBA frame into our surface here. By using an AcceleratedImageBufferSurface,
3944 // we enable the WebMediaPlayer implementation to do any necessa ry color space conversion on the GPU (though it 3944 // we enable the WebMediaPlayer implementation to do any necessa ry color space conversion on the GPU (though it
3945 // may still do a CPU conversion and upload the results). 3945 // may still do a CPU conversion and upload the results).
3946 video->paintCurrentFrameInContext(imageBuffer->context(), IntRec t(0, 0, video->videoWidth(), video->videoHeight())); 3946 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, vi deo->videoWidth(), video->videoHeight()), nullptr);
3947 imageBuffer->context()->canvas()->flush(); 3947 imageBuffer->context()->canvas()->flush();
3948 3948
3949 // This is a straight GPU-GPU copy, any necessary color space co nversion was handled in the paintCurrentFrameInContext() call. 3949 // This is a straight GPU-GPU copy, any necessary color space co nversion was handled in the paintCurrentFrameInContext() call.
3950 if (imageBuffer->copyToPlatformTexture(webContext(), texture->ob ject(), internalformat, type, 3950 if (imageBuffer->copyToPlatformTexture(webContext(), texture->ob ject(), internalformat, type,
3951 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 3951 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
3952 texture->setLevelInfo(target, level, internalformat, video-> videoWidth(), video->videoHeight(), 1, type); 3952 texture->setLevelInfo(target, level, internalformat, video-> videoWidth(), video->videoHeight(), 1, type);
3953 return; 3953 return;
3954 } 3954 }
3955 } 3955 }
3956 } 3956 }
(...skipping 2283 matching lines...) Expand 10 before | Expand all | Expand 10 after
6240 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0; 6240 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0;
6241 } 6241 }
6242 #else 6242 #else
6243 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const 6243 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const
6244 { 6244 {
6245 return m_drawingBuffer.get(); 6245 return m_drawingBuffer.get();
6246 } 6246 }
6247 #endif 6247 #endif
6248 6248
6249 } // namespace blink 6249 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698