OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/gpu/media/gpu_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/message_loop/message_loop_proxy.h" | 13 #include "base/message_loop/message_loop_proxy.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 | 15 |
16 #include "content/common/gpu/gpu_channel.h" | 16 #include "content/common/gpu/gpu_channel.h" |
17 #include "content/common/gpu/gpu_messages.h" | 17 #include "content/common/gpu/gpu_messages.h" |
18 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
19 #include "gpu/command_buffer/common/command_buffer.h" | 19 #include "gpu/command_buffer/common/command_buffer.h" |
20 #include "ipc/ipc_message_macros.h" | 20 #include "ipc/ipc_message_macros.h" |
21 #include "ipc/ipc_message_utils.h" | 21 #include "ipc/ipc_message_utils.h" |
22 #include "ipc/message_filter.h" | 22 #include "ipc/message_filter.h" |
23 #include "media/base/limits.h" | 23 #include "media/base/limits.h" |
24 #include "ui/gl/gl_context.h" | 24 #include "ui/gl/gl_context.h" |
| 25 #include "ui/gl/gl_image.h" |
25 #include "ui/gl/gl_surface_egl.h" | 26 #include "ui/gl/gl_surface_egl.h" |
26 | 27 |
27 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
28 #include "base/win/windows_version.h" | 29 #include "base/win/windows_version.h" |
29 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" | 30 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
30 #elif defined(OS_MACOSX) | 31 #elif defined(OS_MACOSX) |
31 #include "content/common/gpu/media/vt_video_decode_accelerator.h" | 32 #include "content/common/gpu/media/vt_video_decode_accelerator.h" |
32 #elif defined(OS_CHROMEOS) | 33 #elif defined(OS_CHROMEOS) |
33 #if defined(ARCH_CPU_ARMEL) | 34 #if defined(ARCH_CPU_ARMEL) |
34 #include "content/common/gpu/media/v4l2_slice_video_decode_accelerator.h" | 35 #include "content/common/gpu/media/v4l2_slice_video_decode_accelerator.h" |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 gfx::GLSurfaceEGL::GetHardwareDisplay(), | 331 gfx::GLSurfaceEGL::GetHardwareDisplay(), |
331 stub_->decoder()->GetGLContext()->GetHandle(), | 332 stub_->decoder()->GetGLContext()->GetHandle(), |
332 weak_factory_for_io_.GetWeakPtr(), | 333 weak_factory_for_io_.GetWeakPtr(), |
333 make_context_current_, | 334 make_context_current_, |
334 io_message_loop_)); | 335 io_message_loop_)); |
335 } | 336 } |
336 #endif | 337 #endif |
337 return decoder.Pass(); | 338 return decoder.Pass(); |
338 } | 339 } |
339 | 340 |
| 341 void GpuVideoDecodeAccelerator::BindImage(uint32 client_texture_id, |
| 342 uint32 texture_target, |
| 343 scoped_refptr<gfx::GLImage> image) { |
| 344 gpu::gles2::GLES2Decoder* command_decoder = stub_->decoder(); |
| 345 gpu::gles2::TextureManager* texture_manager = |
| 346 command_decoder->GetContextGroup()->texture_manager(); |
| 347 gpu::gles2::TextureRef* ref = texture_manager->GetTexture(client_texture_id); |
| 348 if (ref) |
| 349 texture_manager->SetLevelImage(ref, texture_target, 0, image.get()); |
| 350 } |
| 351 |
340 scoped_ptr<media::VideoDecodeAccelerator> | 352 scoped_ptr<media::VideoDecodeAccelerator> |
341 GpuVideoDecodeAccelerator::CreateVaapiVDA() { | 353 GpuVideoDecodeAccelerator::CreateVaapiVDA() { |
342 scoped_ptr<media::VideoDecodeAccelerator> decoder; | 354 scoped_ptr<media::VideoDecodeAccelerator> decoder; |
343 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 355 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
344 decoder.reset(new VaapiVideoDecodeAccelerator(make_context_current_)); | 356 decoder.reset(new VaapiVideoDecodeAccelerator( |
| 357 make_context_current_, base::Bind(&GpuVideoDecodeAccelerator::BindImage, |
| 358 base::Unretained(this)))); |
345 #endif | 359 #endif |
346 return decoder.Pass(); | 360 return decoder.Pass(); |
347 } | 361 } |
348 | 362 |
349 scoped_ptr<media::VideoDecodeAccelerator> | 363 scoped_ptr<media::VideoDecodeAccelerator> |
350 GpuVideoDecodeAccelerator::CreateVTVDA() { | 364 GpuVideoDecodeAccelerator::CreateVTVDA() { |
351 scoped_ptr<media::VideoDecodeAccelerator> decoder; | 365 scoped_ptr<media::VideoDecodeAccelerator> decoder; |
352 #if defined(OS_MACOSX) | 366 #if defined(OS_MACOSX) |
353 decoder.reset(new VTVideoDecodeAccelerator( | 367 decoder.reset(new VTVideoDecodeAccelerator( |
354 static_cast<CGLContextObj>(stub_->decoder()->GetGLContext()->GetHandle()), | 368 static_cast<CGLContextObj>(stub_->decoder()->GetGLContext()->GetHandle()), |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 } | 475 } |
462 | 476 |
463 // TODO(dshwang): after moving to D3D11, remove this. crbug.com/438691 | 477 // TODO(dshwang): after moving to D3D11, remove this. crbug.com/438691 |
464 GLenum format = | 478 GLenum format = |
465 video_decode_accelerator_.get()->GetSurfaceInternalFormat(); | 479 video_decode_accelerator_.get()->GetSurfaceInternalFormat(); |
466 if (format != GL_RGBA) { | 480 if (format != GL_RGBA) { |
467 texture_manager->SetLevelInfo(texture_ref, texture_target_, 0, format, | 481 texture_manager->SetLevelInfo(texture_ref, texture_target_, 0, format, |
468 width, height, 1, 0, format, 0, false); | 482 width, height, 1, 0, format, 0, false); |
469 } | 483 } |
470 } | 484 } |
471 uint32 service_texture_id; | 485 buffers.push_back(media::PictureBuffer(buffer_ids[i], texture_dimensions_, |
472 if (!command_decoder->GetServiceTextureId( | 486 texture_ref->service_id(), |
473 texture_ids[i], &service_texture_id)) { | 487 texture_ids[i])); |
474 DLOG(ERROR) << "Failed to translate texture!"; | |
475 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | |
476 return; | |
477 } | |
478 buffers.push_back(media::PictureBuffer( | |
479 buffer_ids[i], texture_dimensions_, service_texture_id)); | |
480 textures.push_back(texture_ref); | 488 textures.push_back(texture_ref); |
481 } | 489 } |
482 video_decode_accelerator_->AssignPictureBuffers(buffers); | 490 video_decode_accelerator_->AssignPictureBuffers(buffers); |
483 DebugAutoLock auto_lock(debug_uncleared_textures_lock_); | 491 DebugAutoLock auto_lock(debug_uncleared_textures_lock_); |
484 for (uint32 i = 0; i < buffer_ids.size(); ++i) | 492 for (uint32 i = 0; i < buffer_ids.size(); ++i) |
485 uncleared_textures_[buffer_ids[i]] = textures[i]; | 493 uncleared_textures_[buffer_ids[i]] = textures[i]; |
486 } | 494 } |
487 | 495 |
488 void GpuVideoDecodeAccelerator::OnReusePictureBuffer( | 496 void GpuVideoDecodeAccelerator::OnReusePictureBuffer( |
489 int32 picture_buffer_id) { | 497 int32 picture_buffer_id) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 return stub_->channel()->Send(message); | 586 return stub_->channel()->Send(message); |
579 } | 587 } |
580 | 588 |
581 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, | 589 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, |
582 bool succeeded) { | 590 bool succeeded) { |
583 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); | 591 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); |
584 Send(message); | 592 Send(message); |
585 } | 593 } |
586 | 594 |
587 } // namespace content | 595 } // namespace content |
OLD | NEW |