| 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 5263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5274 IntRect(0, 0, video->videoWidth(), video->videoHeight()); | 5274 IntRect(0, 0, video->videoWidth(), video->videoHeight()); |
| 5275 if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1 && | 5275 if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1 && |
| 5276 GL_TEXTURE_2D == target && Extensions3DUtil::canUseCopyTextureCHROMIUM( | 5276 GL_TEXTURE_2D == target && Extensions3DUtil::canUseCopyTextureCHROMIUM( |
| 5277 target, internalformat, type, level)) { | 5277 target, internalformat, type, level)) { |
| 5278 DCHECK_EQ(xoffset, 0); | 5278 DCHECK_EQ(xoffset, 0); |
| 5279 DCHECK_EQ(yoffset, 0); | 5279 DCHECK_EQ(yoffset, 0); |
| 5280 DCHECK_EQ(zoffset, 0); | 5280 DCHECK_EQ(zoffset, 0); |
| 5281 // Go through the fast path doing a GPU-GPU textures copy without a readback | 5281 // Go through the fast path doing a GPU-GPU textures copy without a readback |
| 5282 // to system memory if possible. Otherwise, it will fall back to the normal | 5282 // to system memory if possible. Otherwise, it will fall back to the normal |
| 5283 // SW path. | 5283 // SW path. |
| 5284 | 5284 if (video->copyVideoTextureToPlatformTexture( |
| 5285 // Note that neither | 5285 contextGL(), texture->object(), internalformat, type, |
| 5286 // HTMLVideoElement::copyVideoTextureToPlatformTexture nor | 5286 m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| 5287 // ImageBuffer::copyToPlatformTexture allocate the destination texture | |
| 5288 // any more. | |
| 5289 texImage2DBase(target, level, internalformat, video->videoWidth(), | |
| 5290 video->videoHeight(), 0, format, type, nullptr); | |
| 5291 | |
| 5292 if (video->copyVideoTextureToPlatformTexture(contextGL(), texture->object(), | |
| 5293 m_unpackPremultiplyAlpha, | |
| 5294 m_unpackFlipY)) { | |
| 5295 texture->updateLastUploadedVideo(video->webMediaPlayer()); | 5287 texture->updateLastUploadedVideo(video->webMediaPlayer()); |
| 5296 return; | 5288 return; |
| 5297 } | 5289 } |
| 5298 | 5290 |
| 5299 // Try using an accelerated image buffer, this allows YUV conversion to be | 5291 // Try using an accelerated image buffer, this allows YUV conversion to be |
| 5300 // done on the GPU. | 5292 // done on the GPU. |
| 5301 std::unique_ptr<ImageBufferSurface> surface = | 5293 std::unique_ptr<ImageBufferSurface> surface = |
| 5302 WTF::wrapUnique(new AcceleratedImageBufferSurface( | 5294 WTF::wrapUnique(new AcceleratedImageBufferSurface( |
| 5303 IntSize(video->videoWidth(), video->videoHeight()))); | 5295 IntSize(video->videoWidth(), video->videoHeight()))); |
| 5304 if (surface->isValid()) { | 5296 if (surface->isValid()) { |
| 5305 std::unique_ptr<ImageBuffer> imageBuffer( | 5297 std::unique_ptr<ImageBuffer> imageBuffer( |
| 5306 ImageBuffer::create(std::move(surface))); | 5298 ImageBuffer::create(std::move(surface))); |
| 5307 if (imageBuffer) { | 5299 if (imageBuffer) { |
| 5308 // The video element paints an RGBA frame into our surface here. By | 5300 // The video element paints an RGBA frame into our surface here. By |
| 5309 // using an AcceleratedImageBufferSurface, we enable the WebMediaPlayer | 5301 // using an AcceleratedImageBufferSurface, we enable the WebMediaPlayer |
| 5310 // implementation to do any necessary color space conversion on the GPU | 5302 // implementation to do any necessary color space conversion on the GPU |
| 5311 // (though it may still do a CPU conversion and upload the results). | 5303 // (though it may still do a CPU conversion and upload the results). |
| 5312 video->paintCurrentFrame( | 5304 video->paintCurrentFrame( |
| 5313 imageBuffer->canvas(), | 5305 imageBuffer->canvas(), |
| 5314 IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr); | 5306 IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr); |
| 5315 | 5307 |
| 5316 // This is a straight GPU-GPU copy, any necessary color space conversion | 5308 // This is a straight GPU-GPU copy, any necessary color space conversion |
| 5317 // was handled in the paintCurrentFrameInContext() call. | 5309 // was handled in the paintCurrentFrameInContext() call. |
| 5318 | 5310 |
| 5311 // Note that copyToPlatformTexture no longer allocates the destination |
| 5312 // texture. |
| 5313 texImage2DBase(target, level, internalformat, video->videoWidth(), |
| 5314 video->videoHeight(), 0, format, type, nullptr); |
| 5315 |
| 5319 if (imageBuffer->copyToPlatformTexture( | 5316 if (imageBuffer->copyToPlatformTexture( |
| 5320 functionIDToSnapshotReason(functionID), contextGL(), | 5317 functionIDToSnapshotReason(functionID), contextGL(), |
| 5321 texture->object(), internalformat, type, level, | 5318 texture->object(), internalformat, type, level, |
| 5322 m_unpackPremultiplyAlpha, m_unpackFlipY, IntPoint(0, 0), | 5319 m_unpackPremultiplyAlpha, m_unpackFlipY, IntPoint(0, 0), |
| 5323 IntRect(0, 0, video->videoWidth(), video->videoHeight()))) { | 5320 IntRect(0, 0, video->videoWidth(), video->videoHeight()))) { |
| 5324 texture->updateLastUploadedVideo(video->webMediaPlayer()); | 5321 texture->updateLastUploadedVideo(video->webMediaPlayer()); |
| 5325 return; | 5322 return; |
| 5326 } | 5323 } |
| 5327 } | 5324 } |
| 5328 } | 5325 } |
| (...skipping 2520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7849 | 7846 |
| 7850 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7847 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
| 7851 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7848 HTMLCanvasElementOrOffscreenCanvas& result) const { |
| 7852 if (canvas()) | 7849 if (canvas()) |
| 7853 result.setHTMLCanvasElement(canvas()); | 7850 result.setHTMLCanvasElement(canvas()); |
| 7854 else | 7851 else |
| 7855 result.setOffscreenCanvas(offscreenCanvas()); | 7852 result.setOffscreenCanvas(offscreenCanvas()); |
| 7856 } | 7853 } |
| 7857 | 7854 |
| 7858 } // namespace blink | 7855 } // namespace blink |
| OLD | NEW |