Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: content/common/gpu/media/gpu_video_decode_accelerator.h

Issue 1784193003: content gpu refactor: get rid of gpu related content switches. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the compile problem on windows Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/shared_memory.h" 16 #include "base/memory/shared_memory.h"
17 #include "base/synchronization/waitable_event.h" 17 #include "base/synchronization/waitable_event.h"
18 #include "content/common/gpu/gpu_command_buffer_stub.h" 18 #include "content/common/gpu/gpu_command_buffer_stub.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 "ipc/ipc_listener.h" 21 #include "ipc/ipc_listener.h"
22 #include "ipc/ipc_sender.h" 22 #include "ipc/ipc_sender.h"
23 #include "media/video/video_decode_accelerator.h" 23 #include "media/video/video_decode_accelerator.h"
24 #include "ui/gfx/geometry/size.h" 24 #include "ui/gfx/geometry/size.h"
25 25
26 namespace gpu {
27 struct GpuPreferences;
28 } // namespace gpu
29
26 namespace content { 30 namespace content {
27 31
28 class GpuVideoDecodeAccelerator 32 class GpuVideoDecodeAccelerator
29 : public IPC::Listener, 33 : public IPC::Listener,
30 public IPC::Sender, 34 public IPC::Sender,
31 public media::VideoDecodeAccelerator::Client, 35 public media::VideoDecodeAccelerator::Client,
32 public GpuCommandBufferStub::DestructionObserver { 36 public GpuCommandBufferStub::DestructionObserver {
33 public: 37 public:
34 // Each of the arguments to the constructor must outlive this object. 38 // Each of the arguments to the constructor must outlive this object.
35 // |stub->decoder()| will be made current around any operation that touches 39 // |stub->decoder()| will be made current around any operation that touches
36 // the underlying VDA so that it can make GL calls safely. 40 // the underlying VDA so that it can make GL calls safely.
37 GpuVideoDecodeAccelerator( 41 GpuVideoDecodeAccelerator(
38 int32_t host_route_id, 42 int32_t host_route_id,
39 GpuCommandBufferStub* stub, 43 GpuCommandBufferStub* stub,
40 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); 44 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
41 45
42 // Static query for the capabilities, which includes the supported profiles. 46 // Static query for the capabilities, which includes the supported profiles.
43 // This query calls the appropriate platform-specific version. The returned 47 // This query calls the appropriate platform-specific version. The returned
44 // capabilities will not contain duplicate supported profile entries. 48 // capabilities will not contain duplicate supported profile entries.
45 static gpu::VideoDecodeAcceleratorCapabilities GetCapabilities(); 49 static gpu::VideoDecodeAcceleratorCapabilities GetCapabilities(
50 const gpu::GpuPreferences& gpu_preferences);
46 51
47 // IPC::Listener implementation. 52 // IPC::Listener implementation.
48 bool OnMessageReceived(const IPC::Message& message) override; 53 bool OnMessageReceived(const IPC::Message& message) override;
49 54
50 // media::VideoDecodeAccelerator::Client implementation. 55 // media::VideoDecodeAccelerator::Client implementation.
51 void NotifyCdmAttached(bool success) override; 56 void NotifyCdmAttached(bool success) override;
52 void ProvidePictureBuffers(uint32_t requested_num_of_buffers, 57 void ProvidePictureBuffers(uint32_t requested_num_of_buffers,
53 const gfx::Size& dimensions, 58 const gfx::Size& dimensions,
54 uint32_t texture_target) override; 59 uint32_t texture_target) override;
55 void DismissPictureBuffer(int32_t picture_buffer_id) override; 60 void DismissPictureBuffer(int32_t picture_buffer_id) override;
56 void PictureReady(const media::Picture& picture) override; 61 void PictureReady(const media::Picture& picture) override;
57 void NotifyEndOfBitstreamBuffer(int32_t bitstream_buffer_id) override; 62 void NotifyEndOfBitstreamBuffer(int32_t bitstream_buffer_id) override;
58 void NotifyFlushDone() override; 63 void NotifyFlushDone() override;
59 void NotifyResetDone() override; 64 void NotifyResetDone() override;
60 void NotifyError(media::VideoDecodeAccelerator::Error error) override; 65 void NotifyError(media::VideoDecodeAccelerator::Error error) override;
61 66
62 // GpuCommandBufferStub::DestructionObserver implementation. 67 // GpuCommandBufferStub::DestructionObserver implementation.
63 void OnWillDestroyStub() override; 68 void OnWillDestroyStub() override;
64 69
65 // Function to delegate sending to actual sender. 70 // Function to delegate sending to actual sender.
66 bool Send(IPC::Message* message) override; 71 bool Send(IPC::Message* message) override;
67 72
68 // Initialize VDAs from the set of VDAs supported for current platform until 73 // Initialize VDAs from the set of VDAs supported for current platform until
69 // one of them succeeds for given |config|. Send the |init_done_msg| when 74 // one of them succeeds for given |config|. Send the |init_done_msg| when
70 // done. filter_ is passed to GpuCommandBufferStub channel only if the chosen 75 // done. filter_ is passed to GpuCommandBufferStub channel only if the chosen
71 // VDA can decode on IO thread. 76 // VDA can decode on IO thread.
72 bool Initialize(const media::VideoDecodeAccelerator::Config& config); 77 bool Initialize(const media::VideoDecodeAccelerator::Config& config);
73 78
74 private: 79 private:
75 typedef scoped_ptr<media::VideoDecodeAccelerator>( 80 typedef scoped_ptr<media::VideoDecodeAccelerator> (
76 GpuVideoDecodeAccelerator::*CreateVDAFp)(); 81 GpuVideoDecodeAccelerator::*CreateVDAFp)();
77 82
78 class MessageFilter; 83 class MessageFilter;
79 84
85 #if defined(OS_WIN)
80 scoped_ptr<media::VideoDecodeAccelerator> CreateDXVAVDA(); 86 scoped_ptr<media::VideoDecodeAccelerator> CreateDXVAVDA();
87 #endif
88 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC)
81 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2VDA(); 89 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2VDA();
82 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2SliceVDA(); 90 scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2SliceVDA();
91 #endif
92 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
83 scoped_ptr<media::VideoDecodeAccelerator> CreateVaapiVDA(); 93 scoped_ptr<media::VideoDecodeAccelerator> CreateVaapiVDA();
94 #endif
95 #if defined(OS_MACOSX)
84 scoped_ptr<media::VideoDecodeAccelerator> CreateVTVDA(); 96 scoped_ptr<media::VideoDecodeAccelerator> CreateVTVDA();
97 #endif
98 #if !defined(OS_CHROMEOS) && defined(USE_OZONE)
85 scoped_ptr<media::VideoDecodeAccelerator> CreateOzoneVDA(); 99 scoped_ptr<media::VideoDecodeAccelerator> CreateOzoneVDA();
100 #endif
101 #if defined(OS_ANDROID)
86 scoped_ptr<media::VideoDecodeAccelerator> CreateAndroidVDA(); 102 scoped_ptr<media::VideoDecodeAccelerator> CreateAndroidVDA();
103 #endif
87 104
88 // We only allow self-delete, from OnWillDestroyStub(), after cleanup there. 105 // We only allow self-delete, from OnWillDestroyStub(), after cleanup there.
89 ~GpuVideoDecodeAccelerator() override; 106 ~GpuVideoDecodeAccelerator() override;
90 107
91 // Handlers for IPC messages. 108 // Handlers for IPC messages.
92 void OnSetCdm(int cdm_id); 109 void OnSetCdm(int cdm_id);
93 void OnDecode(const media::BitstreamBuffer& bitstream_buffer); 110 void OnDecode(const media::BitstreamBuffer& bitstream_buffer);
94 void OnAssignPictureBuffers(const std::vector<int32_t>& buffer_ids, 111 void OnAssignPictureBuffers(const std::vector<int32_t>& buffer_ids,
95 const std::vector<uint32_t>& texture_ids); 112 const std::vector<uint32_t>& texture_ids);
96 void OnReusePictureBuffer(int32_t picture_buffer_id); 113 void OnReusePictureBuffer(int32_t picture_buffer_id);
97 void OnFlush(); 114 void OnFlush();
98 void OnReset(); 115 void OnReset();
99 void OnDestroy(); 116 void OnDestroy();
100 117
101 // Called on IO thread when |filter_| has been removed. 118 // Called on IO thread when |filter_| has been removed.
102 void OnFilterRemoved(); 119 void OnFilterRemoved();
103 120
104 // Sets the texture to cleared. 121 // Sets the texture to cleared.
105 void SetTextureCleared(const media::Picture& picture); 122 void SetTextureCleared(const media::Picture& picture);
106 123
124 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX)
107 // Helper to bind |image| to the texture specified by |client_texture_id|. 125 // Helper to bind |image| to the texture specified by |client_texture_id|.
108 void BindImage(uint32_t client_texture_id, 126 void BindImage(uint32_t client_texture_id,
109 uint32_t texture_target, 127 uint32_t texture_target,
110 scoped_refptr<gl::GLImage> image); 128 scoped_refptr<gl::GLImage> image);
129 #endif
111 130
112 // Helper function to call NotifyError in the |child_task_runner_| thread. 131 // Helper function to call NotifyError in the |child_task_runner_| thread.
113 void CallOrPostNotifyError(media::VideoDecodeAccelerator::Error error); 132 void CallOrPostNotifyError(media::VideoDecodeAccelerator::Error error);
114 133
115 // Route ID to communicate with the host. 134 // Route ID to communicate with the host.
116 const int32_t host_route_id_; 135 const int32_t host_route_id_;
117 136
118 // Unowned pointer to the underlying GpuCommandBufferStub. |this| is 137 // Unowned pointer to the underlying GpuCommandBufferStub. |this| is
119 // registered as a DestuctionObserver of |stub_| and will self-delete when 138 // registered as a DestuctionObserver of |stub_| and will self-delete when
120 // |stub_| is destroyed. 139 // |stub_| is destroyed.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 175
157 // A map from picture buffer ID to TextureRef that have not been cleared. 176 // A map from picture buffer ID to TextureRef that have not been cleared.
158 std::map<int32_t, scoped_refptr<gpu::gles2::TextureRef>> uncleared_textures_; 177 std::map<int32_t, scoped_refptr<gpu::gles2::TextureRef>> uncleared_textures_;
159 178
160 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); 179 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator);
161 }; 180 };
162 181
163 } // namespace content 182 } // namespace content
164 183
165 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ 184 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698