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