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 5155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5166 IntRect(0, 0, video->videoWidth(), video->videoHeight()); | 5166 IntRect(0, 0, video->videoWidth(), video->videoHeight()); |
5167 if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1 && | 5167 if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1 && |
5168 GL_TEXTURE_2D == target && Extensions3DUtil::canUseCopyTextureCHROMIUM( | 5168 GL_TEXTURE_2D == target && Extensions3DUtil::canUseCopyTextureCHROMIUM( |
5169 target, internalformat, type, level)) { | 5169 target, internalformat, type, level)) { |
5170 DCHECK_EQ(xoffset, 0); | 5170 DCHECK_EQ(xoffset, 0); |
5171 DCHECK_EQ(yoffset, 0); | 5171 DCHECK_EQ(yoffset, 0); |
5172 DCHECK_EQ(zoffset, 0); | 5172 DCHECK_EQ(zoffset, 0); |
5173 // Go through the fast path doing a GPU-GPU textures copy without a readback | 5173 // Go through the fast path doing a GPU-GPU textures copy without a readback |
5174 // to system memory if possible. Otherwise, it will fall back to the normal | 5174 // to system memory if possible. Otherwise, it will fall back to the normal |
5175 // SW path. | 5175 // SW path. |
5176 if (video->copyVideoTextureToPlatformTexture( | 5176 |
5177 contextGL(), texture->object(), internalformat, type, | 5177 // Note that neither |
5178 m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 5178 // HTMLVideoElement::copyVideoTextureToPlatformTexture nor |
| 5179 // ImageBuffer::copyToPlatformTexture allocate the destination texture |
| 5180 // any more. |
| 5181 texImage2DBase(target, level, internalformat, video->videoWidth(), |
| 5182 video->videoHeight(), 0, format, type, nullptr); |
| 5183 |
| 5184 if (video->copyVideoTextureToPlatformTexture(contextGL(), texture->object(), |
| 5185 m_unpackPremultiplyAlpha, |
| 5186 m_unpackFlipY)) { |
5179 return; | 5187 return; |
5180 } | 5188 } |
5181 | 5189 |
5182 // Try using an accelerated image buffer, this allows YUV conversion to be | 5190 // Try using an accelerated image buffer, this allows YUV conversion to be |
5183 // done on the GPU. | 5191 // done on the GPU. |
5184 std::unique_ptr<ImageBufferSurface> surface = | 5192 std::unique_ptr<ImageBufferSurface> surface = |
5185 WTF::wrapUnique(new AcceleratedImageBufferSurface( | 5193 WTF::wrapUnique(new AcceleratedImageBufferSurface( |
5186 IntSize(video->videoWidth(), video->videoHeight()))); | 5194 IntSize(video->videoWidth(), video->videoHeight()))); |
5187 if (surface->isValid()) { | 5195 if (surface->isValid()) { |
5188 std::unique_ptr<ImageBuffer> imageBuffer( | 5196 std::unique_ptr<ImageBuffer> imageBuffer( |
5189 ImageBuffer::create(std::move(surface))); | 5197 ImageBuffer::create(std::move(surface))); |
5190 if (imageBuffer) { | 5198 if (imageBuffer) { |
5191 // The video element paints an RGBA frame into our surface here. By | 5199 // The video element paints an RGBA frame into our surface here. By |
5192 // using an AcceleratedImageBufferSurface, we enable the WebMediaPlayer | 5200 // using an AcceleratedImageBufferSurface, we enable the WebMediaPlayer |
5193 // implementation to do any necessary color space conversion on the GPU | 5201 // implementation to do any necessary color space conversion on the GPU |
5194 // (though it may still do a CPU conversion and upload the results). | 5202 // (though it may still do a CPU conversion and upload the results). |
5195 video->paintCurrentFrame( | 5203 video->paintCurrentFrame( |
5196 imageBuffer->canvas(), | 5204 imageBuffer->canvas(), |
5197 IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr); | 5205 IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr); |
5198 | 5206 |
5199 // This is a straight GPU-GPU copy, any necessary color space conversion | 5207 // This is a straight GPU-GPU copy, any necessary color space conversion |
5200 // was handled in the paintCurrentFrameInContext() call. | 5208 // was handled in the paintCurrentFrameInContext() call. |
5201 | 5209 |
5202 // Note that copyToPlatformTexture no longer allocates the destination | |
5203 // texture. | |
5204 texImage2DBase(target, level, internalformat, video->videoWidth(), | |
5205 video->videoHeight(), 0, format, type, nullptr); | |
5206 | |
5207 if (imageBuffer->copyToPlatformTexture( | 5210 if (imageBuffer->copyToPlatformTexture( |
5208 functionIDToSnapshotReason(functionID), contextGL(), | 5211 functionIDToSnapshotReason(functionID), contextGL(), |
5209 texture->object(), internalformat, type, level, | 5212 texture->object(), internalformat, type, level, |
5210 m_unpackPremultiplyAlpha, m_unpackFlipY, IntPoint(0, 0), | 5213 m_unpackPremultiplyAlpha, m_unpackFlipY, IntPoint(0, 0), |
5211 IntRect(0, 0, video->videoWidth(), video->videoHeight()))) { | 5214 IntRect(0, 0, video->videoWidth(), video->videoHeight()))) { |
5212 return; | 5215 return; |
5213 } | 5216 } |
5214 } | 5217 } |
5215 } | 5218 } |
5216 } | 5219 } |
(...skipping 2558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7775 | 7778 |
7776 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7779 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
7777 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7780 HTMLCanvasElementOrOffscreenCanvas& result) const { |
7778 if (canvas()) | 7781 if (canvas()) |
7779 result.setHTMLCanvasElement(canvas()); | 7782 result.setHTMLCanvasElement(canvas()); |
7780 else | 7783 else |
7781 result.setOffscreenCanvas(getOffscreenCanvas()); | 7784 result.setOffscreenCanvas(getOffscreenCanvas()); |
7782 } | 7785 } |
7783 | 7786 |
7784 } // namespace blink | 7787 } // namespace blink |
OLD | NEW |