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 5199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5210 IntRect(0, 0, video->videoWidth(), video->videoHeight()); | 5210 IntRect(0, 0, video->videoWidth(), video->videoHeight()); |
5211 if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1 && | 5211 if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1 && |
5212 GL_TEXTURE_2D == target && Extensions3DUtil::canUseCopyTextureCHROMIUM( | 5212 GL_TEXTURE_2D == target && Extensions3DUtil::canUseCopyTextureCHROMIUM( |
5213 target, internalformat, type, level)) { | 5213 target, internalformat, type, level)) { |
5214 DCHECK_EQ(xoffset, 0); | 5214 DCHECK_EQ(xoffset, 0); |
5215 DCHECK_EQ(yoffset, 0); | 5215 DCHECK_EQ(yoffset, 0); |
5216 DCHECK_EQ(zoffset, 0); | 5216 DCHECK_EQ(zoffset, 0); |
5217 // Go through the fast path doing a GPU-GPU textures copy without a readback | 5217 // Go through the fast path doing a GPU-GPU textures copy without a readback |
5218 // to system memory if possible. Otherwise, it will fall back to the normal | 5218 // to system memory if possible. Otherwise, it will fall back to the normal |
5219 // SW path. | 5219 // SW path. |
5220 if (video->copyVideoTextureToPlatformTexture( | 5220 |
5221 contextGL(), texture->object(), internalformat, type, | 5221 // Note that neither |
5222 m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 5222 // HTMLVideoElement::copyVideoTextureToPlatformTexture nor |
| 5223 // ImageBuffer::copyToPlatformTexture allocate the destination texture |
| 5224 // any more. |
| 5225 texImage2DBase(target, level, internalformat, video->videoWidth(), |
| 5226 video->videoHeight(), 0, format, type, nullptr); |
| 5227 |
| 5228 if (video->copyVideoTextureToPlatformTexture(contextGL(), texture->object(), |
| 5229 m_unpackPremultiplyAlpha, |
| 5230 m_unpackFlipY)) { |
5223 return; | 5231 return; |
5224 } | 5232 } |
5225 | 5233 |
5226 // Try using an accelerated image buffer, this allows YUV conversion to be | 5234 // Try using an accelerated image buffer, this allows YUV conversion to be |
5227 // done on the GPU. | 5235 // done on the GPU. |
5228 std::unique_ptr<ImageBufferSurface> surface = | 5236 std::unique_ptr<ImageBufferSurface> surface = |
5229 WTF::wrapUnique(new AcceleratedImageBufferSurface( | 5237 WTF::wrapUnique(new AcceleratedImageBufferSurface( |
5230 IntSize(video->videoWidth(), video->videoHeight()))); | 5238 IntSize(video->videoWidth(), video->videoHeight()))); |
5231 if (surface->isValid()) { | 5239 if (surface->isValid()) { |
5232 std::unique_ptr<ImageBuffer> imageBuffer( | 5240 std::unique_ptr<ImageBuffer> imageBuffer( |
5233 ImageBuffer::create(std::move(surface))); | 5241 ImageBuffer::create(std::move(surface))); |
5234 if (imageBuffer) { | 5242 if (imageBuffer) { |
5235 // The video element paints an RGBA frame into our surface here. By | 5243 // The video element paints an RGBA frame into our surface here. By |
5236 // using an AcceleratedImageBufferSurface, we enable the WebMediaPlayer | 5244 // using an AcceleratedImageBufferSurface, we enable the WebMediaPlayer |
5237 // implementation to do any necessary color space conversion on the GPU | 5245 // implementation to do any necessary color space conversion on the GPU |
5238 // (though it may still do a CPU conversion and upload the results). | 5246 // (though it may still do a CPU conversion and upload the results). |
5239 video->paintCurrentFrame( | 5247 video->paintCurrentFrame( |
5240 imageBuffer->canvas(), | 5248 imageBuffer->canvas(), |
5241 IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr); | 5249 IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr); |
5242 | 5250 |
5243 // This is a straight GPU-GPU copy, any necessary color space conversion | 5251 // This is a straight GPU-GPU copy, any necessary color space conversion |
5244 // was handled in the paintCurrentFrameInContext() call. | 5252 // was handled in the paintCurrentFrameInContext() call. |
5245 | 5253 |
5246 // Note that copyToPlatformTexture no longer allocates the destination | |
5247 // texture. | |
5248 texImage2DBase(target, level, internalformat, video->videoWidth(), | |
5249 video->videoHeight(), 0, format, type, nullptr); | |
5250 | |
5251 if (imageBuffer->copyToPlatformTexture( | 5254 if (imageBuffer->copyToPlatformTexture( |
5252 functionIDToSnapshotReason(functionID), contextGL(), | 5255 functionIDToSnapshotReason(functionID), contextGL(), |
5253 texture->object(), internalformat, type, level, | 5256 texture->object(), internalformat, type, level, |
5254 m_unpackPremultiplyAlpha, m_unpackFlipY, IntPoint(0, 0), | 5257 m_unpackPremultiplyAlpha, m_unpackFlipY, IntPoint(0, 0), |
5255 IntRect(0, 0, video->videoWidth(), video->videoHeight()))) { | 5258 IntRect(0, 0, video->videoWidth(), video->videoHeight()))) { |
5256 return; | 5259 return; |
5257 } | 5260 } |
5258 } | 5261 } |
5259 } | 5262 } |
5260 } | 5263 } |
(...skipping 2557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7818 | 7821 |
7819 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7822 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
7820 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7823 HTMLCanvasElementOrOffscreenCanvas& result) const { |
7821 if (canvas()) | 7824 if (canvas()) |
7822 result.setHTMLCanvasElement(canvas()); | 7825 result.setHTMLCanvasElement(canvas()); |
7823 else | 7826 else |
7824 result.setOffscreenCanvas(offscreenCanvas()); | 7827 result.setOffscreenCanvas(offscreenCanvas()); |
7825 } | 7828 } |
7826 | 7829 |
7827 } // namespace blink | 7830 } // namespace blink |
OLD | NEW |