Chromium Code Reviews| 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 5267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| 5281 // Note that neither | 5281 // Note that neither |
| 5282 // HTMLVideoElement::copyVideoTextureToPlatformTexture nor | 5282 // HTMLVideoElement::copyVideoTextureToPlatformTexture nor |
| 5283 // ImageBuffer::copyToPlatformTexture allocate the destination texture | 5283 // ImageBuffer::copyToPlatformTexture allocate the destination texture |
| 5284 // any more. | 5284 // any more. |
| 5285 texImage2DBase(target, level, internalformat, video->videoWidth(), | 5285 texImage2DBase(target, level, internalformat, video->videoWidth(), |
| 5286 video->videoHeight(), 0, format, type, nullptr); | 5286 video->videoHeight(), 0, format, type, nullptr); |
| 5287 | 5287 |
| 5288 if (video->copyVideoTextureToPlatformTexture(contextGL(), texture->object(), | 5288 if (video->copyVideoTextureToPlatformTexture(contextGL(), texture->object(), |
|
DaleCurtis
2017/03/17 21:47:52
Sorry, can you instead add the parameters you want
Kai Ninomiya
2017/03/18 01:08:58
Hm, adding it to copyVideoTextureToPlatformTexture
DaleCurtis
2017/03/20 17:58:13
Is there any other way to upload a frame? Also 6 c
Ken Russell (switch to Gerrit)
2017/03/20 19:14:14
Dale, there are three different entry points on HT
DaleCurtis
2017/03/20 21:59:54
Yes, this all sounds reasonable to me for the expe
| |
| 5289 m_unpackPremultiplyAlpha, | 5289 m_unpackPremultiplyAlpha, |
| 5290 m_unpackFlipY)) { | 5290 m_unpackFlipY)) { |
| 5291 texture->videoUpdateLastUploaded(video->webMediaPlayer()); | |
| 5291 return; | 5292 return; |
| 5292 } | 5293 } |
| 5293 | 5294 |
| 5294 // Try using an accelerated image buffer, this allows YUV conversion to be | 5295 // Try using an accelerated image buffer, this allows YUV conversion to be |
| 5295 // done on the GPU. | 5296 // done on the GPU. |
| 5296 std::unique_ptr<ImageBufferSurface> surface = | 5297 std::unique_ptr<ImageBufferSurface> surface = |
| 5297 WTF::wrapUnique(new AcceleratedImageBufferSurface( | 5298 WTF::wrapUnique(new AcceleratedImageBufferSurface( |
| 5298 IntSize(video->videoWidth(), video->videoHeight()))); | 5299 IntSize(video->videoWidth(), video->videoHeight()))); |
| 5299 if (surface->isValid()) { | 5300 if (surface->isValid()) { |
| 5300 std::unique_ptr<ImageBuffer> imageBuffer( | 5301 std::unique_ptr<ImageBuffer> imageBuffer( |
| 5301 ImageBuffer::create(std::move(surface))); | 5302 ImageBuffer::create(std::move(surface))); |
| 5302 if (imageBuffer) { | 5303 if (imageBuffer) { |
| 5303 // The video element paints an RGBA frame into our surface here. By | 5304 // The video element paints an RGBA frame into our surface here. By |
| 5304 // using an AcceleratedImageBufferSurface, we enable the WebMediaPlayer | 5305 // using an AcceleratedImageBufferSurface, we enable the WebMediaPlayer |
| 5305 // implementation to do any necessary color space conversion on the GPU | 5306 // implementation to do any necessary color space conversion on the GPU |
| 5306 // (though it may still do a CPU conversion and upload the results). | 5307 // (though it may still do a CPU conversion and upload the results). |
| 5307 video->paintCurrentFrame( | 5308 video->paintCurrentFrame( |
| 5308 imageBuffer->canvas(), | 5309 imageBuffer->canvas(), |
| 5309 IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr); | 5310 IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr); |
| 5310 | 5311 |
| 5311 // This is a straight GPU-GPU copy, any necessary color space conversion | 5312 // This is a straight GPU-GPU copy, any necessary color space conversion |
| 5312 // was handled in the paintCurrentFrameInContext() call. | 5313 // was handled in the paintCurrentFrameInContext() call. |
| 5313 | 5314 |
| 5314 if (imageBuffer->copyToPlatformTexture( | 5315 if (imageBuffer->copyToPlatformTexture( |
| 5315 functionIDToSnapshotReason(functionID), contextGL(), | 5316 functionIDToSnapshotReason(functionID), contextGL(), |
| 5316 texture->object(), internalformat, type, level, | 5317 texture->object(), internalformat, type, level, |
| 5317 m_unpackPremultiplyAlpha, m_unpackFlipY, IntPoint(0, 0), | 5318 m_unpackPremultiplyAlpha, m_unpackFlipY, IntPoint(0, 0), |
| 5318 IntRect(0, 0, video->videoWidth(), video->videoHeight()))) { | 5319 IntRect(0, 0, video->videoWidth(), video->videoHeight()))) { |
| 5320 texture->videoUpdateLastUploaded(video->webMediaPlayer()); | |
| 5319 return; | 5321 return; |
| 5320 } | 5322 } |
| 5321 } | 5323 } |
| 5322 } | 5324 } |
| 5323 } | 5325 } |
| 5324 | 5326 |
| 5325 if (sourceImageRectIsDefault) { | 5327 if (sourceImageRectIsDefault) { |
| 5326 // Try using optimized CPU-GPU path for some formats: e.g. Y16 and Y8. It | 5328 // Try using optimized CPU-GPU path for some formats: e.g. Y16 and Y8. It |
| 5327 // leaves early for other formats or if frame is stored on GPU. | 5329 // leaves early for other formats or if frame is stored on GPU. |
| 5328 ScopedUnpackParametersResetRestore( | 5330 ScopedUnpackParametersResetRestore( |
| 5329 this, m_unpackFlipY || m_unpackPremultiplyAlpha); | 5331 this, m_unpackFlipY || m_unpackPremultiplyAlpha); |
| 5330 if (video->texImageImpl( | 5332 if (video->texImageImpl( |
| 5331 static_cast<WebMediaPlayer::TexImageFunctionID>(functionID), target, | 5333 static_cast<WebMediaPlayer::TexImageFunctionID>(functionID), target, |
| 5332 contextGL(), level, convertTexInternalFormat(internalformat, type), | 5334 contextGL(), level, convertTexInternalFormat(internalformat, type), |
| 5333 format, type, xoffset, yoffset, zoffset, m_unpackFlipY, | 5335 format, type, xoffset, yoffset, zoffset, m_unpackFlipY, |
| 5334 m_unpackPremultiplyAlpha && | 5336 m_unpackPremultiplyAlpha && |
| 5335 m_unpackColorspaceConversion == GL_NONE)) | 5337 m_unpackColorspaceConversion == GL_NONE)) { |
| 5338 texture->videoUpdateLastUploaded(video->webMediaPlayer()); | |
| 5336 return; | 5339 return; |
| 5340 } | |
| 5337 } | 5341 } |
| 5338 | 5342 |
| 5339 RefPtr<Image> image = videoFrameToImage(video); | 5343 RefPtr<Image> image = videoFrameToImage(video); |
| 5340 if (!image) | 5344 if (!image) |
| 5341 return; | 5345 return; |
| 5342 texImageImpl(functionID, target, level, internalformat, xoffset, yoffset, | 5346 texImageImpl(functionID, target, level, internalformat, xoffset, yoffset, |
| 5343 zoffset, format, type, image.get(), | 5347 zoffset, format, type, image.get(), |
| 5344 WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, | 5348 WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, |
| 5345 m_unpackPremultiplyAlpha, sourceImageRect, depth, | 5349 m_unpackPremultiplyAlpha, sourceImageRect, depth, |
| 5346 unpackImageHeight); | 5350 unpackImageHeight); |
| 5351 texture->videoUpdateLastUploaded(video->webMediaPlayer()); | |
| 5347 } | 5352 } |
| 5348 | 5353 |
| 5349 void WebGLRenderingContextBase::texImageBitmapByGPU(ImageBitmap* bitmap, | 5354 void WebGLRenderingContextBase::texImageBitmapByGPU(ImageBitmap* bitmap, |
| 5350 GLuint targetTexture, | 5355 GLuint targetTexture, |
| 5351 GLenum targetInternalformat, | 5356 GLenum targetInternalformat, |
| 5352 GLenum targetType, | 5357 GLenum targetType, |
| 5353 GLint targetLevel, | 5358 GLint targetLevel, |
| 5354 bool flipY) { | 5359 bool flipY) { |
| 5355 bitmap->bitmapImage()->copyToTexture(drawingBuffer()->contextProvider(), | 5360 bitmap->bitmapImage()->copyToTexture(drawingBuffer()->contextProvider(), |
| 5356 targetTexture, targetInternalformat, | 5361 targetTexture, targetInternalformat, |
| (...skipping 2483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7840 | 7845 |
| 7841 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7846 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
| 7842 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7847 HTMLCanvasElementOrOffscreenCanvas& result) const { |
| 7843 if (canvas()) | 7848 if (canvas()) |
| 7844 result.setHTMLCanvasElement(canvas()); | 7849 result.setHTMLCanvasElement(canvas()); |
| 7845 else | 7850 else |
| 7846 result.setOffscreenCanvas(offscreenCanvas()); | 7851 result.setOffscreenCanvas(offscreenCanvas()); |
| 7847 } | 7852 } |
| 7848 | 7853 |
| 7849 } // namespace blink | 7854 } // namespace blink |
| OLD | NEW |