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