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 4377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4388 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEA
REST); | 4388 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEA
REST); |
4389 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEA
REST); | 4389 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEA
REST); |
4390 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_T
O_EDGE); | 4390 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_T
O_EDGE); |
4391 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_T
O_EDGE); | 4391 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_T
O_EDGE); |
4392 webContext()->texImage2D(GL_TEXTURE_2D, 0, targetInternalformat, canvas-
>width(), | 4392 webContext()->texImage2D(GL_TEXTURE_2D, 0, targetInternalformat, canvas-
>width(), |
4393 canvas->height(), 0, GL_RGBA, targetType, 0); | 4393 canvas->height(), 0, GL_RGBA, targetType, 0); |
4394 } | 4394 } |
4395 | 4395 |
4396 if (!canvas->is3D()) { | 4396 if (!canvas->is3D()) { |
4397 ImageBuffer* buffer = canvas->buffer(); | 4397 ImageBuffer* buffer = canvas->buffer(); |
4398 if (!buffer->copyToPlatformTexture(webContext(), targetTexture, targetIn
ternalformat, targetType, | 4398 if (!buffer->copyToPlatformTexture(webContext(), GL_TEXTURE_2D, targetTe
xture, targetInternalformat, targetType, |
4399 targetLevel, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 4399 targetLevel, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
4400 ASSERT_NOT_REACHED(); | 4400 ASSERT_NOT_REACHED(); |
4401 } | 4401 } |
4402 } else { | 4402 } else { |
4403 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->rend
eringContext()); | 4403 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->rend
eringContext()); |
4404 ScopedTexture2DRestorer restorer(gl); | 4404 ScopedTexture2DRestorer restorer(gl); |
4405 if (!gl->drawingBuffer()->copyToPlatformTexture(webContext(), targetText
ure, targetInternalformat, targetType, | 4405 if (!gl->drawingBuffer()->copyToPlatformTexture(webContext(), targetText
ure, targetInternalformat, targetType, |
4406 targetLevel, m_unpackPremultiplyAlpha, !m_unpackFlipY, BackBuffer))
{ | 4406 targetLevel, m_unpackPremultiplyAlpha, !m_unpackFlipY, BackBuffer))
{ |
4407 ASSERT_NOT_REACHED(); | 4407 ASSERT_NOT_REACHED(); |
4408 } | 4408 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4464 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) | 4464 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) |
4465 { | 4465 { |
4466 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except
ionState) | 4466 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except
ionState) |
4467 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme
nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0,
format, type, 0, 0)) | 4467 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme
nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0,
format, type, 0, 0)) |
4468 return; | 4468 return; |
4469 | 4469 |
4470 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. | 4470 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. |
4471 // Otherwise, it will fall back to the normal SW path. | 4471 // Otherwise, it will fall back to the normal SW path. |
4472 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); | 4472 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); |
4473 ASSERT(texture); | 4473 ASSERT(texture); |
4474 if (GL_TEXTURE_2D == target) { | 4474 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, type
, level) |
4475 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat,
type, level) | 4475 && video->copyVideoTextureToPlatformTexture(webContext(), |
4476 && video->copyVideoTextureToPlatformTexture(webContext(), texture->o
bject(), internalformat, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 4476 WebMediaPlayer::CopyVideoTextureParams( |
4477 texture->setLevelInfo(target, level, internalformat, video->videoWid
th(), video->videoHeight(), 1, type); | 4477 WebMediaPlayer::CopyVideoTextureParams::FullCopy, target, texture->o
bject(), |
4478 return; | 4478 internalformat, type, level, 0, 0, m_unpackPremultiplyAlpha, m_unpac
kFlipY |
4479 } | 4479 ))) { |
| 4480 texture->setLevelInfo(target, level, internalformat, video->videoWidth()
, video->videoHeight(), 1, type); |
| 4481 return; |
| 4482 } |
4480 | 4483 |
4481 // Try using an accelerated image buffer, this allows YUV conversion to
be done on the GPU. | 4484 // Try using an accelerated image buffer, this allows YUV conversion to be d
one on the GPU. |
4482 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBuffer
Surface(IntSize(video->videoWidth(), video->videoHeight()))); | 4485 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBufferSurf
ace(IntSize(video->videoWidth(), video->videoHeight()))); |
4483 if (surface->isValid()) { | 4486 if (surface->isValid()) { |
4484 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release(
))); | 4487 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release())); |
4485 if (imageBuffer) { | 4488 if (imageBuffer) { |
4486 // The video element paints an RGBA frame into our surface here.
By using an AcceleratedImageBufferSurface, | 4489 // The video element paints an RGBA frame into our surface here. By
using an AcceleratedImageBufferSurface, |
4487 // we enable the WebMediaPlayer implementation to do any necessa
ry color space conversion on the GPU (though it | 4490 // we enable the WebMediaPlayer implementation to do any necessary c
olor space conversion on the GPU (though it |
4488 // may still do a CPU conversion and upload the results). | 4491 // may still do a CPU conversion and upload the results). |
4489 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, vi
deo->videoWidth(), video->videoHeight()), nullptr); | 4492 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, video-
>videoWidth(), video->videoHeight()), nullptr); |
4490 imageBuffer->canvas()->flush(); | 4493 imageBuffer->canvas()->flush(); |
4491 | 4494 |
4492 // This is a straight GPU-GPU copy, any necessary color space co
nversion was handled in the paintCurrentFrameInContext() call. | 4495 // This is a straight GPU-GPU copy, any necessary color space conver
sion was handled in the paintCurrentFrameInContext() call. |
4493 if (imageBuffer->copyToPlatformTexture(webContext(), texture->ob
ject(), internalformat, type, | 4496 if (imageBuffer->copyToPlatformTexture(webContext(), target, texture
->object(), internalformat, type, |
4494 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 4497 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
4495 texture->setLevelInfo(target, level, internalformat, video->
videoWidth(), video->videoHeight(), 1, type); | 4498 texture->setLevelInfo(target, level, internalformat, video->vide
oWidth(), video->videoHeight(), 1, type); |
4496 return; | 4499 return; |
4497 } | |
4498 } | 4500 } |
4499 } | 4501 } |
4500 } | 4502 } |
4501 | 4503 |
4502 // Normal pure SW path. | 4504 // Normal pure SW path. |
4503 RefPtr<Image> image = videoFrameToImage(video); | 4505 RefPtr<Image> image = videoFrameToImage(video); |
4504 if (!image) | 4506 if (!image) |
4505 return; | 4507 return; |
4506 texImage2DImpl(target, level, internalformat, format, type, image.get(), Web
GLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha); | 4508 texImage2DImpl(target, level, internalformat, format, type, image.get(), Web
GLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha); |
4507 } | 4509 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4705 texImage2DCanvasByGPU(TexSubImage2D, texture, target, level, GL_RGBA, type,
xoffset, yoffset, canvas); | 4707 texImage2DCanvasByGPU(TexSubImage2D, texture, target, level, GL_RGBA, type,
xoffset, yoffset, canvas); |
4706 } | 4708 } |
4707 | 4709 |
4708 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, | 4710 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, |
4709 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) | 4711 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) |
4710 { | 4712 { |
4711 if (isContextLost() || !validateHTMLVideoElement("texSubImage2D", video, exc
eptionState) | 4713 if (isContextLost() || !validateHTMLVideoElement("texSubImage2D", video, exc
eptionState) |
4712 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLVideoEleme
nt, target, level, 0, video->videoWidth(), video->videoHeight(), 0, format, type
, xoffset, yoffset)) | 4714 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLVideoEleme
nt, target, level, 0, video->videoWidth(), video->videoHeight(), 0, format, type
, xoffset, yoffset)) |
4713 return; | 4715 return; |
4714 | 4716 |
| 4717 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. |
| 4718 // Otherwise, it will fall back to the normal SW path. |
| 4719 WebGLTexture* texture = validateTextureBinding("texSubImage2D", target, true
); |
| 4720 ASSERT(texture); |
| 4721 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, GL_RGBA, type, level
) |
| 4722 && video->copyVideoTextureToPlatformTexture(webContext(), |
| 4723 WebMediaPlayer::CopyVideoTextureParams( |
| 4724 WebMediaPlayer::CopyVideoTextureParams::SubCopy, target, texture->ob
ject(), |
| 4725 GL_FALSE, GL_FALSE, level, xoffset, yoffset, m_unpackPremultiplyAlph
a, m_unpackFlipY |
| 4726 ))) { |
| 4727 return; |
| 4728 } |
| 4729 |
| 4730 // Try using an accelerated image buffer, this allows YUV conversion to be d
one on the GPU. |
| 4731 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBufferSurf
ace(IntSize(video->videoWidth(), video->videoHeight()))); |
| 4732 if (surface->isValid()) { |
| 4733 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release())); |
| 4734 if (imageBuffer) { |
| 4735 // The video element paints an RGBA frame into our surface here. By
using an AcceleratedImageBufferSurface, |
| 4736 // we enable the WebMediaPlayer implementation to do any necessary c
olor space conversion on the GPU (though it |
| 4737 // may still do a CPU conversion and upload the results). |
| 4738 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, video-
>videoWidth(), video->videoHeight()), nullptr); |
| 4739 imageBuffer->canvas()->flush(); |
| 4740 |
| 4741 // This is a straight GPU-GPU copy, any necessary color space conver
sion was handled in the paintCurrentFrameInContext() call. |
| 4742 if (imageBuffer->copySubToPlatformTexture(webContext(), target, text
ure->object(), level, |
| 4743 xoffset, yoffset, video->videoWidth(), video->videoHeight(), m_u
npackPremultiplyAlpha, m_unpackFlipY)) { |
| 4744 return; |
| 4745 } |
| 4746 } |
| 4747 } |
| 4748 |
4715 RefPtr<Image> image = videoFrameToImage(video); | 4749 RefPtr<Image> image = videoFrameToImage(video); |
4716 if (!image) | 4750 if (!image) |
4717 return; | 4751 return; |
4718 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get()
, WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha); | 4752 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get()
, WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha); |
4719 } | 4753 } |
4720 | 4754 |
4721 void WebGLRenderingContextBase::uniform1f(const WebGLUniformLocation* location,
GLfloat x) | 4755 void WebGLRenderingContextBase::uniform1f(const WebGLUniformLocation* location,
GLfloat x) |
4722 { | 4756 { |
4723 if (isContextLost() || !location) | 4757 if (isContextLost() || !location) |
4724 return; | 4758 return; |
(...skipping 2190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6915 | 6949 |
6916 return totalBytesPerPixel; | 6950 return totalBytesPerPixel; |
6917 } | 6951 } |
6918 | 6952 |
6919 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6953 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
6920 { | 6954 { |
6921 return m_drawingBuffer.get(); | 6955 return m_drawingBuffer.get(); |
6922 } | 6956 } |
6923 | 6957 |
6924 } // namespace blink | 6958 } // namespace blink |
OLD | NEW |