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" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 | 276 |
277 DVLOG_IF(1, gpu_memory_buffers_.empty()) << " Skipping ingress frame, 0 GMBs"; | 277 DVLOG_IF(1, gpu_memory_buffers_.empty()) << " Skipping ingress frame, 0 GMBs"; |
278 if (gpu_memory_buffers_.empty()) | 278 if (gpu_memory_buffers_.empty()) |
279 return; | 279 return; |
280 | 280 |
281 linked_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer = | 281 linked_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer = |
282 gpu_memory_buffers_.front(); | 282 gpu_memory_buffers_.front(); |
283 gpu_memory_buffers_.pop(); | 283 gpu_memory_buffers_.pop(); |
284 DCHECK(gpu_memory_buffer.get()); | 284 DCHECK(gpu_memory_buffer.get()); |
285 | 285 |
286 uint8* mapped_buffer = static_cast<uint8*>(gpu_memory_buffer->Map()); | 286 void* mapped_buffers[gpu_memory_buffer->GetNumberOfPlanes()]; |
287 bool map_completed = gpu_memory_buffer->Map(mapped_buffers); | |
288 DCHECK(map_completed); | |
289 | |
290 uint8* mapped_buffer = static_cast<uint8*>(mapped_buffers[0]); | |
reveman
2015/03/23 22:24:01
If you're assuming one plane then you might as wel
emircan
2015/03/24 16:52:26
Done. I wasn't sure if these functions would be su
| |
287 DCHECK(mapped_buffer); | 291 DCHECK(mapped_buffer); |
288 libyuv::ARGBCopy( | 292 libyuv::ARGBCopy( |
289 reinterpret_cast<uint8*>(argb_buffer->data()), frame_size.width() * 4, | 293 reinterpret_cast<uint8*>(argb_buffer->data()), frame_size.width() * 4, |
290 mapped_buffer, frame_size.width() * 4, | 294 mapped_buffer, frame_size.width() * 4, |
reveman
2015/03/23 22:24:01
btw, should "frame_size.width() * 4" be the buffer
emircan
2015/03/24 16:52:26
Done.
| |
291 frame_size.width(), frame_size.height()); | 295 frame_size.width(), frame_size.height()); |
292 gpu_memory_buffer->Unmap(); | 296 gpu_memory_buffer->Unmap(); |
293 | 297 |
294 gpu::gles2::GLES2Interface* gl = capture_thread_context_->ContextGL(); | 298 gpu::gles2::GLES2Interface* gl = capture_thread_context_->ContextGL(); |
295 GLuint image_id = gl->CreateImageCHROMIUM(gpu_memory_buffer->AsClientBuffer(), | 299 GLuint image_id = gl->CreateImageCHROMIUM(gpu_memory_buffer->AsClientBuffer(), |
296 frame_size.width(), | 300 frame_size.width(), |
297 frame_size.height(), | 301 frame_size.height(), |
298 GL_RGBA); | 302 GL_RGBA); |
299 DCHECK(image_id); | 303 DCHECK(image_id); |
300 | 304 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
448 void VideoCaptureTextureWrapper::TextureWrapperDelegate::OnError( | 452 void VideoCaptureTextureWrapper::TextureWrapperDelegate::OnError( |
449 const std::string& message) { | 453 const std::string& message) { |
450 DCHECK(capture_task_runner_->BelongsToCurrentThread()); | 454 DCHECK(capture_task_runner_->BelongsToCurrentThread()); |
451 DLOG(ERROR) << message; | 455 DLOG(ERROR) << message; |
452 BrowserThread::PostTask( | 456 BrowserThread::PostTask( |
453 BrowserThread::IO, FROM_HERE, | 457 BrowserThread::IO, FROM_HERE, |
454 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); | 458 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); |
455 } | 459 } |
456 | 460 |
457 } // namespace content | 461 } // namespace content |
OLD | NEW |