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/message_loop/message_loop_proxy.h" | 12 #include "base/message_loop/message_loop_proxy.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 | 14 |
15 #include "content/common/gpu/gpu_channel.h" | 15 #include "content/common/gpu/gpu_channel.h" |
16 #include "content/common/gpu/gpu_messages.h" | 16 #include "content/common/gpu/gpu_messages.h" |
17 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
18 #include "gpu/command_buffer/common/command_buffer.h" | 18 #include "gpu/command_buffer/common/command_buffer.h" |
19 #include "ipc/ipc_message_macros.h" | 19 #include "ipc/ipc_message_macros.h" |
20 #include "ipc/ipc_message_utils.h" | 20 #include "ipc/ipc_message_utils.h" |
21 #include "ipc/message_filter.h" | 21 #include "ipc/message_filter.h" |
22 #include "media/base/limits.h" | 22 #include "media/base/limits.h" |
23 #include "ui/gl/gl_context.h" | 23 #include "ui/gl/gl_context.h" |
24 #include "ui/gl/gl_surface_egl.h" | 24 #include "ui/gl/gl_surface_egl.h" |
25 | 25 |
26 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
27 #include "base/win/windows_version.h" | 27 #include "base/win/windows_version.h" |
28 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" | 28 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
29 #elif defined(OS_MACOSX) | |
30 #include "content/common/gpu/media/vt_video_decode_accelerator.h" | |
29 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) | 31 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) |
30 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" | 32 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" |
31 #include "content/common/gpu/media/v4l2_video_device.h" | 33 #include "content/common/gpu/media/v4l2_video_device.h" |
32 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) | 34 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) |
33 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" | 35 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" |
34 #include "ui/gl/gl_context_glx.h" | 36 #include "ui/gl/gl_context_glx.h" |
35 #include "ui/gl/gl_implementation.h" | 37 #include "ui/gl/gl_implementation.h" |
36 #elif defined(OS_ANDROID) | 38 #elif defined(OS_ANDROID) |
37 #include "content/common/gpu/media/android_video_decode_accelerator.h" | 39 #include "content/common/gpu/media/android_video_decode_accelerator.h" |
38 #endif | 40 #endif |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 | 246 |
245 #if defined(OS_WIN) | 247 #if defined(OS_WIN) |
246 if (base::win::GetVersion() < base::win::VERSION_WIN7) { | 248 if (base::win::GetVersion() < base::win::VERSION_WIN7) { |
247 NOTIMPLEMENTED() << "HW video decode acceleration not available."; | 249 NOTIMPLEMENTED() << "HW video decode acceleration not available."; |
248 SendCreateDecoderReply(init_done_msg, false); | 250 SendCreateDecoderReply(init_done_msg, false); |
249 return; | 251 return; |
250 } | 252 } |
251 DVLOG(0) << "Initializing DXVA HW decoder for windows."; | 253 DVLOG(0) << "Initializing DXVA HW decoder for windows."; |
252 video_decode_accelerator_.reset( | 254 video_decode_accelerator_.reset( |
253 new DXVAVideoDecodeAccelerator(make_context_current_)); | 255 new DXVAVideoDecodeAccelerator(make_context_current_)); |
256 #elif defined(OS_MACOSX) | |
257 video_decode_accelerator_.reset(new VTVideoDecodeAccelerator( | |
258 static_cast<CGLContextObj>( | |
259 stub_->decoder()->GetGLContext()->GetHandle()))); | |
254 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) | 260 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) |
255 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); | 261 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); |
256 if (!device.get()) { | 262 if (!device.get()) { |
257 SendCreateDecoderReply(init_done_msg, false); | 263 SendCreateDecoderReply(init_done_msg, false); |
258 return; | 264 return; |
259 } | 265 } |
260 video_decode_accelerator_.reset(new V4L2VideoDecodeAccelerator( | 266 video_decode_accelerator_.reset(new V4L2VideoDecodeAccelerator( |
261 gfx::GLSurfaceEGL::GetHardwareDisplay(), | 267 gfx::GLSurfaceEGL::GetHardwareDisplay(), |
262 stub_->decoder()->GetGLContext()->GetHandle(), | 268 stub_->decoder()->GetGLContext()->GetHandle(), |
263 weak_factory_for_io_.GetWeakPtr(), | 269 weak_factory_for_io_.GetWeakPtr(), |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); | 352 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); |
347 return; | 353 return; |
348 } | 354 } |
349 gpu::gles2::Texture* info = texture_ref->texture(); | 355 gpu::gles2::Texture* info = texture_ref->texture(); |
350 if (info->target() != texture_target_) { | 356 if (info->target() != texture_target_) { |
351 DLOG(ERROR) << "Texture target mismatch for texture id " | 357 DLOG(ERROR) << "Texture target mismatch for texture id " |
352 << texture_ids[i]; | 358 << texture_ids[i]; |
353 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); | 359 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); |
354 return; | 360 return; |
355 } | 361 } |
356 if (texture_target_ == GL_TEXTURE_EXTERNAL_OES) { | 362 if (texture_target_ == GL_TEXTURE_EXTERNAL_OES || |
357 // GL_TEXTURE_EXTERNAL_OES textures have their dimensions defined by the | 363 texture_target_ == GL_TEXTURE_RECTANGLE) { |
scherkus (not reviewing)
2014/06/09 16:02:06
do we need this change right now?
in general I pr
sandersd (OOO until July 31)
2014/06/10 01:02:44
Done.
| |
364 // These textures have their dimensions defined by the | |
358 // underlying EGLImage. Use |texture_dimensions_| for this size. | 365 // underlying EGLImage. Use |texture_dimensions_| for this size. |
359 texture_manager->SetLevelInfo(texture_ref, | 366 texture_manager->SetLevelInfo(texture_ref, |
360 GL_TEXTURE_EXTERNAL_OES, | 367 texture_target_, |
361 0, | 368 0, |
362 0, | 369 0, |
363 texture_dimensions_.width(), | 370 texture_dimensions_.width(), |
364 texture_dimensions_.height(), | 371 texture_dimensions_.height(), |
365 1, | 372 1, |
366 0, | 373 0, |
367 0, | 374 0, |
368 0, | 375 0, |
369 false); | 376 false); |
370 } else { | 377 } else { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 // So we have to wait for the RemoveFilter callback here instead and remove | 459 // So we have to wait for the RemoveFilter callback here instead and remove |
453 // the VDA after it arrives and before returning. | 460 // the VDA after it arrives and before returning. |
454 if (filter_.get()) { | 461 if (filter_.get()) { |
455 stub_->channel()->RemoveFilter(filter_.get()); | 462 stub_->channel()->RemoveFilter(filter_.get()); |
456 filter_removed_.Wait(); | 463 filter_removed_.Wait(); |
457 } | 464 } |
458 | 465 |
459 stub_->channel()->RemoveRoute(host_route_id_); | 466 stub_->channel()->RemoveRoute(host_route_id_); |
460 stub_->RemoveDestructionObserver(this); | 467 stub_->RemoveDestructionObserver(this); |
461 | 468 |
462 video_decode_accelerator_.reset(); | |
scherkus (not reviewing)
2014/06/09 16:02:06
ditto
sandersd (OOO until July 31)
2014/06/10 01:02:44
More bad merging :-(
| |
463 delete this; | 469 delete this; |
464 } | 470 } |
465 | 471 |
466 void GpuVideoDecodeAccelerator::SetTextureCleared( | 472 void GpuVideoDecodeAccelerator::SetTextureCleared( |
467 const media::Picture& picture) { | 473 const media::Picture& picture) { |
468 DCHECK(child_message_loop_->BelongsToCurrentThread()); | 474 DCHECK(child_message_loop_->BelongsToCurrentThread()); |
469 DebugAutoLock auto_lock(debug_uncleared_textures_lock_); | 475 DebugAutoLock auto_lock(debug_uncleared_textures_lock_); |
470 std::map<int32, scoped_refptr<gpu::gles2::TextureRef> >::iterator it; | 476 std::map<int32, scoped_refptr<gpu::gles2::TextureRef> >::iterator it; |
471 it = uncleared_textures_.find(picture.picture_buffer_id()); | 477 it = uncleared_textures_.find(picture.picture_buffer_id()); |
472 if (it == uncleared_textures_.end()) | 478 if (it == uncleared_textures_.end()) |
(...skipping 15 matching lines...) Expand all Loading... | |
488 return stub_->channel()->Send(message); | 494 return stub_->channel()->Send(message); |
489 } | 495 } |
490 | 496 |
491 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, | 497 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, |
492 bool succeeded) { | 498 bool succeeded) { |
493 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); | 499 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); |
494 Send(message); | 500 Send(message); |
495 } | 501 } |
496 | 502 |
497 } // namespace content | 503 } // namespace content |
OLD | NEW |