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 4495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4506 | 4506 |
4507 PassRefPtr<Image> WebGLRenderingContextBase::videoFrameToImage(HTMLVideoElement*
video) | 4507 PassRefPtr<Image> WebGLRenderingContextBase::videoFrameToImage(HTMLVideoElement*
video) |
4508 { | 4508 { |
4509 IntSize size(video->videoWidth(), video->videoHeight()); | 4509 IntSize size(video->videoWidth(), video->videoHeight()); |
4510 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); | 4510 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); |
4511 if (!buf) { | 4511 if (!buf) { |
4512 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory"); | 4512 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory"); |
4513 return nullptr; | 4513 return nullptr; |
4514 } | 4514 } |
4515 IntRect destRect(0, 0, size.width(), size.height()); | 4515 IntRect destRect(0, 0, size.width(), size.height()); |
4516 video->paintCurrentFrame(buf->canvas(), destRect, nullptr); | 4516 video->paintCurrentFrame(buf->canvas(), destRect, nullptr, nullptr); |
4517 return buf->newImageSnapshot(); | 4517 return buf->newImageSnapshot(); |
4518 } | 4518 } |
4519 | 4519 |
4520 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLint int
ernalformat, | 4520 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLint int
ernalformat, |
4521 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) | 4521 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) |
4522 { | 4522 { |
4523 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except
ionState) | 4523 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except
ionState) |
4524 || !validateTexFunc("texImage2D", TexImage, SourceHTMLVideoElement, targ
et, level, internalformat, video->videoWidth(), video->videoHeight(), 1, 0, form
at, type, 0, 0, 0)) | 4524 || !validateTexFunc("texImage2D", TexImage, SourceHTMLVideoElement, targ
et, level, internalformat, video->videoWidth(), video->videoHeight(), 1, 0, form
at, type, 0, 0, 0)) |
4525 return; | 4525 return; |
4526 | 4526 |
4527 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. | 4527 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. |
4528 // Otherwise, it will fall back to the normal SW path. | 4528 // Otherwise, it will fall back to the normal SW path. |
4529 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); | 4529 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); |
4530 ASSERT(texture); | 4530 ASSERT(texture); |
4531 if (GL_TEXTURE_2D == target) { | 4531 if (GL_TEXTURE_2D == target) { |
4532 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat,
type, level) | 4532 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat,
type, level) |
4533 && video->copyVideoTextureToPlatformTexture(webContext(), texture->o
bject(), internalformat, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 4533 && video->copyVideoTextureToPlatformTexture(webContext(), texture->o
bject(), internalformat, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
4534 texture->setLevelInfo(target, level, internalformat, video->videoWid
th(), video->videoHeight(), 1, type); | 4534 texture->setLevelInfo(target, level, internalformat, video->videoWid
th(), video->videoHeight(), 1, type); |
4535 return; | 4535 return; |
4536 } | 4536 } |
4537 | 4537 |
4538 // Try using an accelerated image buffer, this allows YUV conversion to
be done on the GPU. | 4538 // Try using an accelerated image buffer, this allows YUV conversion to
be done on the GPU. |
4539 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBuffer
Surface(IntSize(video->videoWidth(), video->videoHeight()))); | 4539 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBuffer
Surface(IntSize(video->videoWidth(), video->videoHeight()))); |
4540 if (surface->isValid()) { | 4540 if (surface->isValid()) { |
4541 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release(
))); | 4541 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release(
))); |
4542 if (imageBuffer) { | 4542 if (imageBuffer) { |
4543 // The video element paints an RGBA frame into our surface here.
By using an AcceleratedImageBufferSurface, | 4543 // The video element paints an RGBA frame into our surface here.
By using an AcceleratedImageBufferSurface, |
4544 // we enable the WebMediaPlayer implementation to do any necessa
ry color space conversion on the GPU (though it | 4544 // we enable the WebMediaPlayer implementation to do any necessa
ry color space conversion on the GPU (though it |
4545 // may still do a CPU conversion and upload the results). | 4545 // may still do a CPU conversion and upload the results). |
4546 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, vi
deo->videoWidth(), video->videoHeight()), nullptr); | 4546 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, vi
deo->videoWidth(), video->videoHeight()), nullptr, nullptr); |
4547 | 4547 |
4548 // This is a straight GPU-GPU copy, any necessary color space co
nversion was handled in the paintCurrentFrameInContext() call. | 4548 // This is a straight GPU-GPU copy, any necessary color space co
nversion was handled in the paintCurrentFrameInContext() call. |
4549 if (imageBuffer->copyToPlatformTexture(webContext(), texture->ob
ject(), internalformat, type, | 4549 if (imageBuffer->copyToPlatformTexture(webContext(), texture->ob
ject(), internalformat, type, |
4550 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 4550 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
4551 texture->setLevelInfo(target, level, internalformat, video->
videoWidth(), video->videoHeight(), 1, type); | 4551 texture->setLevelInfo(target, level, internalformat, video->
videoWidth(), video->videoHeight(), 1, type); |
4552 return; | 4552 return; |
4553 } | 4553 } |
4554 } | 4554 } |
4555 } | 4555 } |
4556 } | 4556 } |
(...skipping 2443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7000 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 7000 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); |
7001 } | 7001 } |
7002 | 7002 |
7003 void WebGLRenderingContextBase::restoreUnpackParameters() | 7003 void WebGLRenderingContextBase::restoreUnpackParameters() |
7004 { | 7004 { |
7005 if (m_unpackAlignment != 1) | 7005 if (m_unpackAlignment != 1) |
7006 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 7006 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
7007 } | 7007 } |
7008 | 7008 |
7009 } // namespace blink | 7009 } // namespace blink |
OLD | NEW |