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 4206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4217 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEA
REST); | 4217 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEA
REST); |
4218 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEA
REST); | 4218 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEA
REST); |
4219 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_T
O_EDGE); | 4219 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_T
O_EDGE); |
4220 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_T
O_EDGE); | 4220 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_T
O_EDGE); |
4221 webContext()->texImage2D(GL_TEXTURE_2D, 0, targetInternalformat, canvas-
>width(), | 4221 webContext()->texImage2D(GL_TEXTURE_2D, 0, targetInternalformat, canvas-
>width(), |
4222 canvas->height(), 0, GL_RGBA, targetType, 0); | 4222 canvas->height(), 0, GL_RGBA, targetType, 0); |
4223 } | 4223 } |
4224 | 4224 |
4225 if (!canvas->is3D()) { | 4225 if (!canvas->is3D()) { |
4226 ImageBuffer* buffer = canvas->buffer(); | 4226 ImageBuffer* buffer = canvas->buffer(); |
4227 if (!buffer->copyToPlatformTexture(webContext(), targetTexture, targetIn
ternalformat, targetType, | 4227 if (!buffer->copyToPlatformTexture(webContext(), target, targetTexture,
targetInternalformat, targetType, |
4228 targetLevel, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 4228 targetLevel, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
4229 ASSERT_NOT_REACHED(); | 4229 ASSERT_NOT_REACHED(); |
4230 } | 4230 } |
4231 } else { | 4231 } else { |
4232 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->rend
eringContext()); | 4232 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->rend
eringContext()); |
4233 ScopedTexture2DRestorer restorer(gl); | 4233 ScopedTexture2DRestorer restorer(gl); |
4234 if (!gl->drawingBuffer()->copyToPlatformTexture(webContext(), targetText
ure, targetInternalformat, targetType, | 4234 if (!gl->drawingBuffer()->copyToPlatformTexture(webContext(), targetText
ure, targetInternalformat, targetType, |
4235 targetLevel, m_unpackPremultiplyAlpha, !m_unpackFlipY, BackBuffer))
{ | 4235 targetLevel, m_unpackPremultiplyAlpha, !m_unpackFlipY, BackBuffer))
{ |
4236 ASSERT_NOT_REACHED(); | 4236 ASSERT_NOT_REACHED(); |
4237 } | 4237 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4293 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) | 4293 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) |
4294 { | 4294 { |
4295 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except
ionState) | 4295 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except
ionState) |
4296 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme
nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0,
format, type, 0, 0)) | 4296 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme
nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0,
format, type, 0, 0)) |
4297 return; | 4297 return; |
4298 | 4298 |
4299 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. | 4299 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. |
4300 // Otherwise, it will fall back to the normal SW path. | 4300 // Otherwise, it will fall back to the normal SW path. |
4301 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); | 4301 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); |
4302 ASSERT(texture); | 4302 ASSERT(texture); |
4303 if (GL_TEXTURE_2D == target) { | 4303 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, type
, level) |
4304 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat,
type, level) | 4304 && video->copyVideoTextureToPlatformTexture(webContext(), target, texture->o
bject(), internalformat, type, level, m_unpackPremultiplyAlpha, m_unpackFlipY))
{ |
4305 && video->copyVideoTextureToPlatformTexture(webContext(), texture->o
bject(), internalformat, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 4305 texture->setLevelInfo(target, level, internalformat, video->videoWidth()
, video->videoHeight(), 1, type); |
4306 texture->setLevelInfo(target, level, internalformat, video->videoWid
th(), video->videoHeight(), 1, type); | 4306 return; |
4307 return; | 4307 } |
4308 } | |
4309 | 4308 |
4310 // Try using an accelerated image buffer, this allows YUV conversion to
be done on the GPU. | 4309 // Try using an accelerated image buffer, this allows YUV conversion to be d
one on the GPU. |
4311 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBuffer
Surface(IntSize(video->videoWidth(), video->videoHeight()))); | 4310 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBufferSurf
ace(IntSize(video->videoWidth(), video->videoHeight()))); |
4312 if (surface->isValid()) { | 4311 if (surface->isValid()) { |
4313 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release(
))); | 4312 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release())); |
4314 if (imageBuffer) { | 4313 if (imageBuffer) { |
4315 // The video element paints an RGBA frame into our surface here.
By using an AcceleratedImageBufferSurface, | 4314 // The video element paints an RGBA frame into our surface here. By
using an AcceleratedImageBufferSurface, |
4316 // we enable the WebMediaPlayer implementation to do any necessa
ry color space conversion on the GPU (though it | 4315 // we enable the WebMediaPlayer implementation to do any necessary c
olor space conversion on the GPU (though it |
4317 // may still do a CPU conversion and upload the results). | 4316 // may still do a CPU conversion and upload the results). |
4318 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, vi
deo->videoWidth(), video->videoHeight()), nullptr); | 4317 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, video-
>videoWidth(), video->videoHeight()), nullptr); |
4319 imageBuffer->canvas()->flush(); | 4318 imageBuffer->canvas()->flush(); |
4320 | 4319 |
4321 // This is a straight GPU-GPU copy, any necessary color space co
nversion was handled in the paintCurrentFrameInContext() call. | 4320 // This is a straight GPU-GPU copy, any necessary color space conver
sion was handled in the paintCurrentFrameInContext() call. |
4322 if (imageBuffer->copyToPlatformTexture(webContext(), texture->ob
ject(), internalformat, type, | 4321 if (imageBuffer->copyToPlatformTexture(webContext(), target, texture
->object(), internalformat, type, |
4323 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 4322 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
4324 texture->setLevelInfo(target, level, internalformat, video->
videoWidth(), video->videoHeight(), 1, type); | 4323 texture->setLevelInfo(target, level, internalformat, video->vide
oWidth(), video->videoHeight(), 1, type); |
4325 return; | 4324 return; |
4326 } | |
4327 } | 4325 } |
4328 } | 4326 } |
4329 } | 4327 } |
4330 | 4328 |
4331 // Normal pure SW path. | 4329 // Normal pure SW path. |
4332 RefPtr<Image> image = videoFrameToImage(video); | 4330 RefPtr<Image> image = videoFrameToImage(video); |
4333 if (!image) | 4331 if (!image) |
4334 return; | 4332 return; |
4335 texImage2DImpl(target, level, internalformat, format, type, image.get(), Web
GLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha); | 4333 texImage2DImpl(target, level, internalformat, format, type, image.get(), Web
GLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha); |
4336 } | 4334 } |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4544 texImage2DCanvasByGPU(TexSubImage2D, texture, target, level, GL_RGBA, type,
xoffset, yoffset, canvas); | 4542 texImage2DCanvasByGPU(TexSubImage2D, texture, target, level, GL_RGBA, type,
xoffset, yoffset, canvas); |
4545 } | 4543 } |
4546 | 4544 |
4547 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, | 4545 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, |
4548 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) | 4546 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) |
4549 { | 4547 { |
4550 if (isContextLost() || !validateHTMLVideoElement("texSubImage2D", video, exc
eptionState) | 4548 if (isContextLost() || !validateHTMLVideoElement("texSubImage2D", video, exc
eptionState) |
4551 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLVideoEleme
nt, target, level, 0, video->videoWidth(), video->videoHeight(), 0, format, type
, xoffset, yoffset)) | 4549 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLVideoEleme
nt, target, level, 0, video->videoWidth(), video->videoHeight(), 0, format, type
, xoffset, yoffset)) |
4552 return; | 4550 return; |
4553 | 4551 |
| 4552 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. |
| 4553 // Otherwise, it will fall back to the normal SW path. |
| 4554 WebGLTexture* texture = validateTextureBinding("texSubImage2D", target, true
); |
| 4555 ASSERT(texture); |
| 4556 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, GL_RGBA, type, level
) |
| 4557 && video->copyVideoSubTextureToPlatformTexture(webContext(), target, texture
->object(), |
| 4558 level, xoffset, yoffset, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| 4559 return; |
| 4560 } |
| 4561 |
| 4562 // Try using an accelerated image buffer, this allows YUV conversion to be d
one on the GPU. |
| 4563 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBufferSurf
ace(IntSize(video->videoWidth(), video->videoHeight()))); |
| 4564 if (surface->isValid()) { |
| 4565 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release())); |
| 4566 if (imageBuffer) { |
| 4567 // The video element paints an RGBA frame into our surface here. By
using an AcceleratedImageBufferSurface, |
| 4568 // we enable the WebMediaPlayer implementation to do any necessary c
olor space conversion on the GPU (though it |
| 4569 // may still do a CPU conversion and upload the results). |
| 4570 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, video-
>videoWidth(), video->videoHeight()), nullptr); |
| 4571 imageBuffer->canvas()->flush(); |
| 4572 |
| 4573 // This is a straight GPU-GPU copy, any necessary color space conver
sion was handled in the paintCurrentFrameInContext() call. |
| 4574 if (imageBuffer->copySubToPlatformTexture(webContext(), target, text
ure->object(), level, |
| 4575 xoffset, yoffset, video->videoWidth(), video->videoHeight(), m_u
npackPremultiplyAlpha, m_unpackFlipY)) { |
| 4576 return; |
| 4577 } |
| 4578 } |
| 4579 } |
| 4580 |
4554 RefPtr<Image> image = videoFrameToImage(video); | 4581 RefPtr<Image> image = videoFrameToImage(video); |
4555 if (!image) | 4582 if (!image) |
4556 return; | 4583 return; |
4557 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get()
, WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha); | 4584 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get()
, WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha); |
4558 } | 4585 } |
4559 | 4586 |
4560 void WebGLRenderingContextBase::uniform1f(const WebGLUniformLocation* location,
GLfloat x) | 4587 void WebGLRenderingContextBase::uniform1f(const WebGLUniformLocation* location,
GLfloat x) |
4561 { | 4588 { |
4562 if (isContextLost() || !location) | 4589 if (isContextLost() || !location) |
4563 return; | 4590 return; |
(...skipping 2138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6702 | 6729 |
6703 return totalBytesPerPixel; | 6730 return totalBytesPerPixel; |
6704 } | 6731 } |
6705 | 6732 |
6706 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6733 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
6707 { | 6734 { |
6708 return m_drawingBuffer.get(); | 6735 return m_drawingBuffer.get(); |
6709 } | 6736 } |
6710 | 6737 |
6711 } // namespace blink | 6738 } // namespace blink |
OLD | NEW |