OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/media/video_capture_texture_wrapper.h" | 5 #include "content/browser/renderer_host/media/video_capture_texture_wrapper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "content/browser/compositor/image_transport_factory.h" | 8 #include "content/browser/compositor/image_transport_factory.h" |
9 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 9 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
10 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 10 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
11 #include "content/browser/gpu/gpu_data_manager_impl.h" | 11 #include "content/browser/gpu/gpu_data_manager_impl.h" |
12 #include "content/browser/renderer_host/media/video_capture_controller.h" | 12 #include "content/browser/renderer_host/media/video_capture_controller.h" |
13 #include "content/common/gpu/client/context_provider_command_buffer.h" | 13 #include "content/common/gpu/client/context_provider_command_buffer.h" |
14 #include "content/common/gpu/client/gl_helper.h" | 14 #include "content/common/gpu/client/gl_helper.h" |
15 #include "content/common/gpu/client/gpu_channel_host.h" | 15 #include "content/common/gpu/client/gpu_channel_host.h" |
16 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 16 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
17 #include "content/common/gpu/gpu_process_launch_causes.h" | 17 #include "content/common/gpu/gpu_process_launch_causes.h" |
18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
19 #include "gpu/command_buffer/common/mailbox_holder.h" | 19 #include "gpu/command_buffer/common/mailbox_holder.h" |
20 #include "media/base/bind_to_current_loop.h" | 20 #include "media/base/bind_to_current_loop.h" |
21 #include "media/base/video_capture_types.h" | 21 #include "media/base/video_capture_types.h" |
22 #include "media/base/video_frame.h" | 22 #include "media/base/video_frame.h" |
| 23 #include "third_party/khronos/GLES2/gl2ext.h" |
23 #include "third_party/libyuv/include/libyuv.h" | 24 #include "third_party/libyuv/include/libyuv.h" |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 // VideoCaptureController has at most 3 capture frames in flight. | 30 // VideoCaptureController has at most 3 capture frames in flight. |
30 const size_t kNumGpuMemoryBuffers = 3; | 31 const size_t kNumGpuMemoryBuffers = 3; |
31 | 32 |
32 uint32 VideoPixelFormatToFourCC(media::VideoPixelFormat pixel_format) { | 33 uint32 VideoPixelFormatToFourCC(media::VideoPixelFormat pixel_format) { |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 DCHECK(mapped_buffer); | 294 DCHECK(mapped_buffer); |
294 libyuv::ARGBCopy( | 295 libyuv::ARGBCopy( |
295 reinterpret_cast<uint8*>(argb_buffer->data()), frame_size.width() * 4, | 296 reinterpret_cast<uint8*>(argb_buffer->data()), frame_size.width() * 4, |
296 mapped_buffer, stride, | 297 mapped_buffer, stride, |
297 frame_size.width(), frame_size.height()); | 298 frame_size.width(), frame_size.height()); |
298 gpu_memory_buffer->Unmap(); | 299 gpu_memory_buffer->Unmap(); |
299 | 300 |
300 gpu::gles2::GLES2Interface* gl = capture_thread_context_->ContextGL(); | 301 gpu::gles2::GLES2Interface* gl = capture_thread_context_->ContextGL(); |
301 GLuint image_id = gl->CreateImageCHROMIUM(gpu_memory_buffer->AsClientBuffer(), | 302 GLuint image_id = gl->CreateImageCHROMIUM(gpu_memory_buffer->AsClientBuffer(), |
302 frame_size.width(), | 303 frame_size.width(), |
303 frame_size.height(), | 304 frame_size.height(), GL_BGRA_EXT); |
304 GL_RGBA); | |
305 DCHECK(image_id); | 305 DCHECK(image_id); |
306 | 306 |
307 GLuint texture_id = gl_helper_->CreateTexture(); | 307 GLuint texture_id = gl_helper_->CreateTexture(); |
308 DCHECK(texture_id); | 308 DCHECK(texture_id); |
309 { | 309 { |
310 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl, texture_id); | 310 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl, texture_id); |
311 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id); | 311 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id); |
312 } | 312 } |
313 | 313 |
314 scoped_ptr<gpu::MailboxHolder> mailbox_holder(new gpu::MailboxHolder( | 314 scoped_ptr<gpu::MailboxHolder> mailbox_holder(new gpu::MailboxHolder( |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 void VideoCaptureTextureWrapper::TextureWrapperDelegate::OnError( | 454 void VideoCaptureTextureWrapper::TextureWrapperDelegate::OnError( |
455 const std::string& message) { | 455 const std::string& message) { |
456 DCHECK(capture_task_runner_->BelongsToCurrentThread()); | 456 DCHECK(capture_task_runner_->BelongsToCurrentThread()); |
457 DLOG(ERROR) << message; | 457 DLOG(ERROR) << message; |
458 BrowserThread::PostTask( | 458 BrowserThread::PostTask( |
459 BrowserThread::IO, FROM_HERE, | 459 BrowserThread::IO, FROM_HERE, |
460 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); | 460 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); |
461 } | 461 } |
462 | 462 |
463 } // namespace content | 463 } // namespace content |
OLD | NEW |