| 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 MEDIA_GPU_IPC_SERVICE_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef MEDIA_GPU_IPC_SERVICE_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
| 6 #define MEDIA_GPU_IPC_SERVICE_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define MEDIA_GPU_IPC_SERVICE_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/shared_memory.h" | 17 #include "base/memory/shared_memory.h" |
| 18 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
| 19 #include "gpu/command_buffer/service/texture_manager.h" | 19 #include "gpu/command_buffer/service/texture_manager.h" |
| 20 #include "gpu/config/gpu_info.h" | 20 #include "gpu/config/gpu_info.h" |
| 21 #include "gpu/ipc/service/gpu_command_buffer_stub.h" | 21 #include "gpu/ipc/service/gpu_command_buffer_stub.h" |
| 22 #include "ipc/ipc_listener.h" | 22 #include "ipc/ipc_listener.h" |
| 23 #include "ipc/ipc_sender.h" | 23 #include "ipc/ipc_sender.h" |
| 24 #include "media/base/android_overlay_mojo_factory.h" |
| 24 #include "media/gpu/gpu_video_decode_accelerator_helpers.h" | 25 #include "media/gpu/gpu_video_decode_accelerator_helpers.h" |
| 25 #include "media/video/video_decode_accelerator.h" | 26 #include "media/video/video_decode_accelerator.h" |
| 26 #include "ui/gfx/geometry/size.h" | 27 #include "ui/gfx/geometry/size.h" |
| 27 | 28 |
| 28 namespace gpu { | 29 namespace gpu { |
| 29 class GpuDriverBugWorkarounds; | 30 class GpuDriverBugWorkarounds; |
| 30 struct GpuPreferences; | 31 struct GpuPreferences; |
| 31 } // namespace gpu | 32 } // namespace gpu |
| 32 | 33 |
| 33 namespace media { | 34 namespace media { |
| 34 | 35 |
| 35 class GpuVideoDecodeAccelerator | 36 class GpuVideoDecodeAccelerator |
| 36 : public IPC::Listener, | 37 : public IPC::Listener, |
| 37 public IPC::Sender, | 38 public IPC::Sender, |
| 38 public VideoDecodeAccelerator::Client, | 39 public VideoDecodeAccelerator::Client, |
| 39 public gpu::GpuCommandBufferStub::DestructionObserver { | 40 public gpu::GpuCommandBufferStub::DestructionObserver { |
| 40 public: | 41 public: |
| 41 // Each of the arguments to the constructor must outlive this object. | 42 // Each of the arguments to the constructor must outlive this object. |
| 42 // |stub->decoder()| will be made current around any operation that touches | 43 // |stub->decoder()| will be made current around any operation that touches |
| 43 // the underlying VDA so that it can make GL calls safely. | 44 // the underlying VDA so that it can make GL calls safely. |
| 44 GpuVideoDecodeAccelerator( | 45 GpuVideoDecodeAccelerator( |
| 45 int32_t host_route_id, | 46 int32_t host_route_id, |
| 46 gpu::GpuCommandBufferStub* stub, | 47 gpu::GpuCommandBufferStub* stub, |
| 47 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | 48 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
| 49 const AndroidOverlayMojoFactoryCB& factory); |
| 48 | 50 |
| 49 // Static query for the capabilities, which includes the supported profiles. | 51 // Static query for the capabilities, which includes the supported profiles. |
| 50 // This query calls the appropriate platform-specific version. The returned | 52 // This query calls the appropriate platform-specific version. The returned |
| 51 // capabilities will not contain duplicate supported profile entries. | 53 // capabilities will not contain duplicate supported profile entries. |
| 52 static gpu::VideoDecodeAcceleratorCapabilities GetCapabilities( | 54 static gpu::VideoDecodeAcceleratorCapabilities GetCapabilities( |
| 53 const gpu::GpuPreferences& gpu_preferences, | 55 const gpu::GpuPreferences& gpu_preferences, |
| 54 const gpu::GpuDriverBugWorkarounds& workarounds); | 56 const gpu::GpuDriverBugWorkarounds& workarounds); |
| 55 | 57 |
| 56 // IPC::Listener implementation. | 58 // IPC::Listener implementation. |
| 57 bool OnMessageReceived(const IPC::Message& message) override; | 59 bool OnMessageReceived(const IPC::Message& message) override; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // Used to wait on for |filter_| to be removed, before we can safely | 146 // Used to wait on for |filter_| to be removed, before we can safely |
| 145 // destroy the VDA. | 147 // destroy the VDA. |
| 146 base::WaitableEvent filter_removed_; | 148 base::WaitableEvent filter_removed_; |
| 147 | 149 |
| 148 // GPU child thread task runner. | 150 // GPU child thread task runner. |
| 149 const scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_; | 151 const scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_; |
| 150 | 152 |
| 151 // GPU IO thread task runner. | 153 // GPU IO thread task runner. |
| 152 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 154 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 153 | 155 |
| 156 // Optional factory for mojo-based android overlays. |
| 157 AndroidOverlayMojoFactoryCB overlay_factory_cb_; |
| 158 |
| 154 // Weak pointers will be invalidated on IO thread. | 159 // Weak pointers will be invalidated on IO thread. |
| 155 base::WeakPtrFactory<Client> weak_factory_for_io_; | 160 base::WeakPtrFactory<Client> weak_factory_for_io_; |
| 156 | 161 |
| 157 // Protects |uncleared_textures_| when DCHECK is on. This is for debugging | 162 // Protects |uncleared_textures_| when DCHECK is on. This is for debugging |
| 158 // only. We don't want to hold a lock on IO thread. When DCHECK is off, | 163 // only. We don't want to hold a lock on IO thread. When DCHECK is off, |
| 159 // |uncleared_textures_| is only accessed from the child thread. | 164 // |uncleared_textures_| is only accessed from the child thread. |
| 160 base::Lock debug_uncleared_textures_lock_; | 165 base::Lock debug_uncleared_textures_lock_; |
| 161 | 166 |
| 162 // A map from picture buffer ID to set of TextureRefs that have not been | 167 // A map from picture buffer ID to set of TextureRefs that have not been |
| 163 // cleared. | 168 // cleared. |
| 164 std::map<int32_t, std::vector<scoped_refptr<gpu::gles2::TextureRef>>> | 169 std::map<int32_t, std::vector<scoped_refptr<gpu::gles2::TextureRef>>> |
| 165 uncleared_textures_; | 170 uncleared_textures_; |
| 166 | 171 |
| 167 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); | 172 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); |
| 168 }; | 173 }; |
| 169 | 174 |
| 170 } // namespace media | 175 } // namespace media |
| 171 | 176 |
| 172 #endif // MEDIA_GPU_IPC_SERVICE_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 177 #endif // MEDIA_GPU_IPC_SERVICE_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |