| 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 #ifndef CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
| 6 #define CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
| 14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 15 #include "content/common/gpu/gpu_command_buffer_stub.h" | 15 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 16 #include "gpu/command_buffer/service/texture_manager.h" | 16 #include "gpu/command_buffer/service/texture_manager.h" |
| 17 #include "gpu/config/gpu_info.h" | 17 #include "gpu/config/gpu_info.h" |
| 18 #include "ipc/ipc_listener.h" | 18 #include "ipc/ipc_listener.h" |
| 19 #include "ipc/ipc_sender.h" | 19 #include "ipc/ipc_sender.h" |
| 20 #include "media/video/video_decode_accelerator.h" | 20 #include "media/video/video_decode_accelerator.h" |
| 21 #include "ui/gfx/geometry/size.h" | 21 #include "ui/gfx/geometry/size.h" |
| 22 | 22 |
| 23 namespace base { | |
| 24 class MessageLoopProxy; | |
| 25 } | |
| 26 | |
| 27 namespace content { | 23 namespace content { |
| 28 | 24 |
| 29 class GpuVideoDecodeAccelerator | 25 class GpuVideoDecodeAccelerator |
| 30 : public IPC::Listener, | 26 : public IPC::Listener, |
| 31 public IPC::Sender, | 27 public IPC::Sender, |
| 32 public media::VideoDecodeAccelerator::Client, | 28 public media::VideoDecodeAccelerator::Client, |
| 33 public GpuCommandBufferStub::DestructionObserver { | 29 public GpuCommandBufferStub::DestructionObserver { |
| 34 public: | 30 public: |
| 35 // Each of the arguments to the constructor must outlive this object. | 31 // Each of the arguments to the constructor must outlive this object. |
| 36 // |stub->decoder()| will be made current around any operation that touches | 32 // |stub->decoder()| will be made current around any operation that touches |
| 37 // the underlying VDA so that it can make GL calls safely. | 33 // the underlying VDA so that it can make GL calls safely. |
| 38 GpuVideoDecodeAccelerator( | 34 GpuVideoDecodeAccelerator( |
| 39 int32 host_route_id, | 35 int32 host_route_id, |
| 40 GpuCommandBufferStub* stub, | 36 GpuCommandBufferStub* stub, |
| 41 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); | 37 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
| 42 | 38 |
| 43 // IPC::Listener implementation. | 39 // IPC::Listener implementation. |
| 44 bool OnMessageReceived(const IPC::Message& message) override; | 40 bool OnMessageReceived(const IPC::Message& message) override; |
| 45 | 41 |
| 46 // media::VideoDecodeAccelerator::Client implementation. | 42 // media::VideoDecodeAccelerator::Client implementation. |
| 47 void ProvidePictureBuffers(uint32 requested_num_of_buffers, | 43 void ProvidePictureBuffers(uint32 requested_num_of_buffers, |
| 48 const gfx::Size& dimensions, | 44 const gfx::Size& dimensions, |
| 49 uint32 texture_target) override; | 45 uint32 texture_target) override; |
| 50 void DismissPictureBuffer(int32 picture_buffer_id) override; | 46 void DismissPictureBuffer(int32 picture_buffer_id) override; |
| 51 void PictureReady(const media::Picture& picture) override; | 47 void PictureReady(const media::Picture& picture) override; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // The texture target as requested by ProvidePictureBuffers(). | 129 // The texture target as requested by ProvidePictureBuffers(). |
| 134 uint32 texture_target_; | 130 uint32 texture_target_; |
| 135 | 131 |
| 136 // The message filter to run VDA::Decode on IO thread if VDA supports it. | 132 // The message filter to run VDA::Decode on IO thread if VDA supports it. |
| 137 scoped_refptr<MessageFilter> filter_; | 133 scoped_refptr<MessageFilter> filter_; |
| 138 | 134 |
| 139 // Used to wait on for |filter_| to be removed, before we can safely | 135 // Used to wait on for |filter_| to be removed, before we can safely |
| 140 // destroy the VDA. | 136 // destroy the VDA. |
| 141 base::WaitableEvent filter_removed_; | 137 base::WaitableEvent filter_removed_; |
| 142 | 138 |
| 143 // GPU child message loop. | 139 // GPU child thread task runner. |
| 144 const scoped_refptr<base::MessageLoopProxy> child_message_loop_; | 140 const scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_; |
| 145 | 141 |
| 146 // GPU IO message loop. | 142 // GPU IO thread task runner. |
| 147 const scoped_refptr<base::MessageLoopProxy> io_message_loop_; | 143 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 148 | 144 |
| 149 // Weak pointers will be invalidated on IO thread. | 145 // Weak pointers will be invalidated on IO thread. |
| 150 base::WeakPtrFactory<Client> weak_factory_for_io_; | 146 base::WeakPtrFactory<Client> weak_factory_for_io_; |
| 151 | 147 |
| 152 // Protects |uncleared_textures_| when DCHECK is on. This is for debugging | 148 // Protects |uncleared_textures_| when DCHECK is on. This is for debugging |
| 153 // only. We don't want to hold a lock on IO thread. When DCHECK is off, | 149 // only. We don't want to hold a lock on IO thread. When DCHECK is off, |
| 154 // |uncleared_textures_| is only accessed from the child thread. | 150 // |uncleared_textures_| is only accessed from the child thread. |
| 155 base::Lock debug_uncleared_textures_lock_; | 151 base::Lock debug_uncleared_textures_lock_; |
| 156 | 152 |
| 157 // A map from picture buffer ID to TextureRef that have not been cleared. | 153 // A map from picture buffer ID to TextureRef that have not been cleared. |
| 158 std::map<int32, scoped_refptr<gpu::gles2::TextureRef> > uncleared_textures_; | 154 std::map<int32, scoped_refptr<gpu::gles2::TextureRef> > uncleared_textures_; |
| 159 | 155 |
| 160 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); | 156 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); |
| 161 }; | 157 }; |
| 162 | 158 |
| 163 } // namespace content | 159 } // namespace content |
| 164 | 160 |
| 165 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 161 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |