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* data = NULL; |
| 287 bool rv = gpu_memory_buffer->Map(&data); |
| 288 DCHECK(rv); |
| 289 uint32 stride; |
| 290 gpu_memory_buffer->GetStride(&stride); |
| 291 |
| 292 uint8* mapped_buffer = static_cast<uint8*>(data); |
287 DCHECK(mapped_buffer); | 293 DCHECK(mapped_buffer); |
288 libyuv::ARGBCopy( | 294 libyuv::ARGBCopy( |
289 reinterpret_cast<uint8*>(argb_buffer->data()), frame_size.width() * 4, | 295 reinterpret_cast<uint8*>(argb_buffer->data()), frame_size.width() * 4, |
290 mapped_buffer, frame_size.width() * 4, | 296 mapped_buffer, stride, |
291 frame_size.width(), frame_size.height()); | 297 frame_size.width(), frame_size.height()); |
292 gpu_memory_buffer->Unmap(); | 298 gpu_memory_buffer->Unmap(); |
293 | 299 |
294 gpu::gles2::GLES2Interface* gl = capture_thread_context_->ContextGL(); | 300 gpu::gles2::GLES2Interface* gl = capture_thread_context_->ContextGL(); |
295 GLuint image_id = gl->CreateImageCHROMIUM(gpu_memory_buffer->AsClientBuffer(), | 301 GLuint image_id = gl->CreateImageCHROMIUM(gpu_memory_buffer->AsClientBuffer(), |
296 frame_size.width(), | 302 frame_size.width(), |
297 frame_size.height(), | 303 frame_size.height(), |
298 GL_RGBA); | 304 GL_RGBA); |
299 DCHECK(image_id); | 305 DCHECK(image_id); |
300 | 306 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 void VideoCaptureTextureWrapper::TextureWrapperDelegate::OnError( | 454 void VideoCaptureTextureWrapper::TextureWrapperDelegate::OnError( |
449 const std::string& message) { | 455 const std::string& message) { |
450 DCHECK(capture_task_runner_->BelongsToCurrentThread()); | 456 DCHECK(capture_task_runner_->BelongsToCurrentThread()); |
451 DLOG(ERROR) << message; | 457 DLOG(ERROR) << message; |
452 BrowserThread::PostTask( | 458 BrowserThread::PostTask( |
453 BrowserThread::IO, FROM_HERE, | 459 BrowserThread::IO, FROM_HERE, |
454 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); | 460 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); |
455 } | 461 } |
456 | 462 |
457 } // namespace content | 463 } // namespace content |
OLD | NEW |