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