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