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

Side by Side Diff: gpu/ipc/service/gpu_channel_manager.h

Issue 1845563005: Refactor content/common/gpu into gpu/ipc/service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Drop ref to deleted content_tests_gypi_values.content_unittests_ozone_sources Created 4 years, 8 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
« no previous file with comments | « gpu/ipc/service/gpu_channel.cc ('k') | gpu/ipc/service/gpu_channel_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_GPU_CHANNEL_MANAGER_H_ 5 #ifndef GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_H_
6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ 6 #define GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque> 10 #include <deque>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/containers/scoped_ptr_hash_map.h" 14 #include "base/containers/scoped_ptr_hash_map.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/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "content/common/content_export.h"
21 #include "content/common/gpu/gpu_memory_manager.h"
22 #include "gpu/command_buffer/common/constants.h" 20 #include "gpu/command_buffer/common/constants.h"
21 #include "gpu/gpu_export.h"
22 #include "gpu/ipc/service/gpu_memory_manager.h"
23 #include "ui/gfx/gpu_memory_buffer.h" 23 #include "ui/gfx/gpu_memory_buffer.h"
24 #include "ui/gfx/native_widget_types.h" 24 #include "ui/gfx/native_widget_types.h"
25 #include "ui/gl/gl_surface.h" 25 #include "ui/gl/gl_surface.h"
26 #include "url/gurl.h" 26 #include "url/gurl.h"
27 27
28 #if defined(OS_MACOSX) 28 #if defined(OS_MACOSX)
29 #include "base/callback.h" 29 #include "base/callback.h"
30 #include "base/containers/hash_tables.h" 30 #include "base/containers/hash_tables.h"
31 #endif 31 #endif
32 32
(...skipping 17 matching lines...) Expand all
50 class MailboxManager; 50 class MailboxManager;
51 class ProgramCache; 51 class ProgramCache;
52 class ShaderTranslatorCache; 52 class ShaderTranslatorCache;
53 } 53 }
54 } 54 }
55 55
56 namespace IPC { 56 namespace IPC {
57 struct ChannelHandle; 57 struct ChannelHandle;
58 } 58 }
59 59
60 namespace content { 60 namespace gpu {
61 class GpuChannel; 61 class GpuChannel;
62 class GpuChannelManagerDelegate; 62 class GpuChannelManagerDelegate;
63 class GpuMemoryBufferFactory; 63 class GpuMemoryBufferFactory;
64 class GpuWatchdog; 64 class GpuWatchdog;
65 65
66 // A GpuChannelManager is a thread responsible for issuing rendering commands 66 // A GpuChannelManager is a thread responsible for issuing rendering commands
67 // managing the lifetimes of GPU channels and forwarding IPC requests from the 67 // managing the lifetimes of GPU channels and forwarding IPC requests from the
68 // browser process to them based on the corresponding renderer ID. 68 // browser process to them based on the corresponding renderer ID.
69 class CONTENT_EXPORT GpuChannelManager { 69 class GPU_EXPORT GpuChannelManager {
70 public: 70 public:
71 #if defined(OS_MACOSX) 71 #if defined(OS_MACOSX)
72 typedef base::Callback< 72 typedef base::Callback<
73 void(int32_t, const base::TimeTicks&, const base::TimeDelta&)> 73 void(int32_t, const base::TimeTicks&, const base::TimeDelta&)>
74 BufferPresentedCallback; 74 BufferPresentedCallback;
75 #endif 75 #endif
76 GpuChannelManager(const gpu::GpuPreferences& gpu_preferences, 76 GpuChannelManager(const GpuPreferences& gpu_preferences,
77 GpuChannelManagerDelegate* delegate, 77 GpuChannelManagerDelegate* delegate,
78 GpuWatchdog* watchdog, 78 GpuWatchdog* watchdog,
79 base::SingleThreadTaskRunner* task_runner, 79 base::SingleThreadTaskRunner* task_runner,
80 base::SingleThreadTaskRunner* io_task_runner, 80 base::SingleThreadTaskRunner* io_task_runner,
81 base::WaitableEvent* shutdown_event, 81 base::WaitableEvent* shutdown_event,
82 gpu::SyncPointManager* sync_point_manager, 82 SyncPointManager* sync_point_manager,
83 GpuMemoryBufferFactory* gpu_memory_buffer_factory); 83 GpuMemoryBufferFactory* gpu_memory_buffer_factory);
84 virtual ~GpuChannelManager(); 84 virtual ~GpuChannelManager();
85 85
86 GpuChannelManagerDelegate* delegate() const { return delegate_; } 86 GpuChannelManagerDelegate* delegate() const { return delegate_; }
87 87
88 IPC::ChannelHandle EstablishChannel(int client_id, 88 IPC::ChannelHandle EstablishChannel(int client_id,
89 uint64_t client_tracing_id, 89 uint64_t client_tracing_id,
90 bool preempts, 90 bool preempts,
91 bool allow_view_command_buffers, 91 bool allow_view_command_buffers,
92 bool allow_real_time_streams); 92 bool allow_real_time_streams);
93 93
94 void PopulateShaderCache(const std::string& shader); 94 void PopulateShaderCache(const std::string& shader);
95 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, 95 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
96 int client_id, 96 int client_id,
97 const gpu::SyncToken& sync_token); 97 const SyncToken& sync_token);
98 void UpdateValueState(int client_id, 98 void UpdateValueState(int client_id,
99 unsigned int target, 99 unsigned int target,
100 const gpu::ValueState& state); 100 const ValueState& state);
101 #if defined(OS_ANDROID) 101 #if defined(OS_ANDROID)
102 void WakeUpGpu(); 102 void WakeUpGpu();
103 #endif 103 #endif
104 void DestroyAllChannels(); 104 void DestroyAllChannels();
105 105
106 // Remove the channel for a particular renderer. 106 // Remove the channel for a particular renderer.
107 void RemoveChannel(int client_id); 107 void RemoveChannel(int client_id);
108 108
109 void LoseAllContexts(); 109 void LoseAllContexts();
110 110
111 #if defined(OS_MACOSX) 111 #if defined(OS_MACOSX)
112 void AddBufferPresentedCallback(int32_t routing_id, 112 void AddBufferPresentedCallback(int32_t routing_id,
113 const BufferPresentedCallback& callback); 113 const BufferPresentedCallback& callback);
114 void RemoveBufferPresentedCallback(int32_t routing_id); 114 void RemoveBufferPresentedCallback(int32_t routing_id);
115 void BufferPresented(int32_t surface_id, 115 void BufferPresented(int32_t surface_id,
116 const base::TimeTicks& vsync_timebase, 116 const base::TimeTicks& vsync_timebase,
117 const base::TimeDelta& vsync_interval); 117 const base::TimeDelta& vsync_interval);
118 #endif 118 #endif
119 119
120 const gpu::GpuPreferences& gpu_preferences() const { 120 const GpuPreferences& gpu_preferences() const {
121 return gpu_preferences_; 121 return gpu_preferences_;
122 } 122 }
123 gpu::gles2::ProgramCache* program_cache(); 123 gles2::ProgramCache* program_cache();
124 gpu::gles2::ShaderTranslatorCache* shader_translator_cache(); 124 gles2::ShaderTranslatorCache* shader_translator_cache();
125 gpu::gles2::FramebufferCompletenessCache* framebuffer_completeness_cache(); 125 gles2::FramebufferCompletenessCache* framebuffer_completeness_cache();
126 126
127 GpuMemoryManager* gpu_memory_manager() { return &gpu_memory_manager_; } 127 GpuMemoryManager* gpu_memory_manager() { return &gpu_memory_manager_; }
128 128
129 GpuChannel* LookupChannel(int32_t client_id) const; 129 GpuChannel* LookupChannel(int32_t client_id) const;
130 130
131 gfx::GLSurface* GetDefaultOffscreenSurface(); 131 gfx::GLSurface* GetDefaultOffscreenSurface();
132 132
133 GpuMemoryBufferFactory* gpu_memory_buffer_factory() { 133 GpuMemoryBufferFactory* gpu_memory_buffer_factory() {
134 return gpu_memory_buffer_factory_; 134 return gpu_memory_buffer_factory_;
135 } 135 }
(...skipping 11 matching lines...) Expand all
147 #endif 147 #endif
148 148
149 protected: 149 protected:
150 virtual scoped_ptr<GpuChannel> CreateGpuChannel( 150 virtual scoped_ptr<GpuChannel> CreateGpuChannel(
151 int client_id, 151 int client_id,
152 uint64_t client_tracing_id, 152 uint64_t client_tracing_id,
153 bool preempts, 153 bool preempts,
154 bool allow_view_command_buffers, 154 bool allow_view_command_buffers,
155 bool allow_real_time_streams); 155 bool allow_real_time_streams);
156 156
157 gpu::SyncPointManager* sync_point_manager() const { 157 SyncPointManager* sync_point_manager() const {
158 return sync_point_manager_; 158 return sync_point_manager_;
159 } 159 }
160 160
161 gfx::GLShareGroup* share_group() const { return share_group_.get(); } 161 gfx::GLShareGroup* share_group() const { return share_group_.get(); }
162 gpu::gles2::MailboxManager* mailbox_manager() const { 162 gles2::MailboxManager* mailbox_manager() const {
163 return mailbox_manager_.get(); 163 return mailbox_manager_.get();
164 } 164 }
165 gpu::PreemptionFlag* preemption_flag() const { 165 PreemptionFlag* preemption_flag() const {
166 return preemption_flag_.get(); 166 return preemption_flag_.get();
167 } 167 }
168 168
169 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 169 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
170 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 170 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
171 171
172 // These objects manage channels to individual renderer processes there is 172 // These objects manage channels to individual renderer processes there is
173 // one channel for each renderer process that has connected to this GPU 173 // one channel for each renderer process that has connected to this GPU
174 // process. 174 // process.
175 base::ScopedPtrHashMap<int32_t, scoped_ptr<GpuChannel>> gpu_channels_; 175 base::ScopedPtrHashMap<int32_t, scoped_ptr<GpuChannel>> gpu_channels_;
176 176
177 private: 177 private:
178 void InternalDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id); 178 void InternalDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id);
179 void InternalDestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, 179 void InternalDestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id,
180 int client_id); 180 int client_id);
181 #if defined(OS_ANDROID) 181 #if defined(OS_ANDROID)
182 void ScheduleWakeUpGpu(); 182 void ScheduleWakeUpGpu();
183 void DoWakeUpGpu(); 183 void DoWakeUpGpu();
184 #endif 184 #endif
185 185
186 const gpu::GpuPreferences& gpu_preferences_; 186 const GpuPreferences& gpu_preferences_;
187 187
188 GpuChannelManagerDelegate* const delegate_; 188 GpuChannelManagerDelegate* const delegate_;
189 #if defined(OS_MACOSX) 189 #if defined(OS_MACOSX)
190 base::hash_map<int32_t, BufferPresentedCallback> 190 base::hash_map<int32_t, BufferPresentedCallback>
191 buffer_presented_callback_map_; 191 buffer_presented_callback_map_;
192 #endif 192 #endif
193 193
194 GpuWatchdog* watchdog_; 194 GpuWatchdog* watchdog_;
195 195
196 base::WaitableEvent* shutdown_event_; 196 base::WaitableEvent* shutdown_event_;
197 197
198 scoped_refptr<gfx::GLShareGroup> share_group_; 198 scoped_refptr<gfx::GLShareGroup> share_group_;
199 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; 199 scoped_refptr<gles2::MailboxManager> mailbox_manager_;
200 scoped_refptr<gpu::PreemptionFlag> preemption_flag_; 200 scoped_refptr<PreemptionFlag> preemption_flag_;
201 GpuMemoryManager gpu_memory_manager_; 201 GpuMemoryManager gpu_memory_manager_;
202 // SyncPointManager guaranteed to outlive running MessageLoop. 202 // SyncPointManager guaranteed to outlive running MessageLoop.
203 gpu::SyncPointManager* sync_point_manager_; 203 SyncPointManager* sync_point_manager_;
204 scoped_ptr<gpu::SyncPointClient> sync_point_client_waiter_; 204 scoped_ptr<SyncPointClient> sync_point_client_waiter_;
205 scoped_ptr<gpu::gles2::ProgramCache> program_cache_; 205 scoped_ptr<gles2::ProgramCache> program_cache_;
206 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; 206 scoped_refptr<gles2::ShaderTranslatorCache> shader_translator_cache_;
207 scoped_refptr<gpu::gles2::FramebufferCompletenessCache> 207 scoped_refptr<gles2::FramebufferCompletenessCache>
208 framebuffer_completeness_cache_; 208 framebuffer_completeness_cache_;
209 scoped_refptr<gfx::GLSurface> default_offscreen_surface_; 209 scoped_refptr<gfx::GLSurface> default_offscreen_surface_;
210 GpuMemoryBufferFactory* const gpu_memory_buffer_factory_; 210 GpuMemoryBufferFactory* const gpu_memory_buffer_factory_;
211 #if defined(OS_ANDROID) 211 #if defined(OS_ANDROID)
212 // Last time we know the GPU was powered on. Global for tracking across all 212 // Last time we know the GPU was powered on. Global for tracking across all
213 // transport surfaces. 213 // transport surfaces.
214 base::TimeTicks last_gpu_access_time_; 214 base::TimeTicks last_gpu_access_time_;
215 base::TimeTicks begin_wake_up_time_; 215 base::TimeTicks begin_wake_up_time_;
216 #endif 216 #endif
217 217
218 // Member variables should appear before the WeakPtrFactory, to ensure 218 // Member variables should appear before the WeakPtrFactory, to ensure
219 // that any WeakPtrs to Controller are invalidated before its members 219 // that any WeakPtrs to Controller are invalidated before its members
220 // variable's destructors are executed, rendering them invalid. 220 // variable's destructors are executed, rendering them invalid.
221 base::WeakPtrFactory<GpuChannelManager> weak_factory_; 221 base::WeakPtrFactory<GpuChannelManager> weak_factory_;
222 222
223 DISALLOW_COPY_AND_ASSIGN(GpuChannelManager); 223 DISALLOW_COPY_AND_ASSIGN(GpuChannelManager);
224 }; 224 };
225 225
226 } // namespace content 226 } // namespace gpu
227 227
228 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ 228 #endif // GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_H_
OLDNEW
« no previous file with comments | « gpu/ipc/service/gpu_channel.cc ('k') | gpu/ipc/service/gpu_channel_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698