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

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

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

Powered by Google App Engine
This is Rietveld 408576698