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

Side by Side Diff: content/common/gpu/gpu_channel_manager.h

Issue 1711533002: Decouple browser-specific GPU IPC messages from GPU service IPCs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed another Windows Build issue Created 4 years, 10 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_GPU_CHANNEL_MANAGER_H_ 5 #ifndef CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_
6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ 6 #define CONTENT_COMMON_GPU_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" 20 #include "content/common/content_export.h"
21 #include "content/common/content_param_traits.h" 21 #include "content/common/content_param_traits.h"
22 #include "content/common/gpu/gpu_memory_manager.h" 22 #include "content/common/gpu/gpu_memory_manager.h"
23 #include "gpu/command_buffer/common/constants.h"
23 #include "ipc/ipc_listener.h" 24 #include "ipc/ipc_listener.h"
24 #include "ipc/ipc_sender.h" 25 #include "ipc/ipc_sender.h"
no sievers 2016/02/22 21:57:42 unused ipc/ includes, yay... you need to fwd decla
Fady Samuel 2016/02/23 04:45:27 Done.
25 #include "ipc/message_router.h" 26 #include "ipc/message_router.h"
26 #include "ui/gfx/gpu_memory_buffer.h" 27 #include "ui/gfx/gpu_memory_buffer.h"
27 #include "ui/gfx/native_widget_types.h" 28 #include "ui/gfx/native_widget_types.h"
28 #include "ui/gl/gl_surface.h" 29 #include "ui/gl/gl_surface.h"
30 #include "url/gurl.h"
29 31
30 namespace base { 32 namespace base {
31 class WaitableEvent; 33 class WaitableEvent;
32 } 34 }
33 35
34 namespace gfx { 36 namespace gfx {
35 class GLShareGroup; 37 class GLShareGroup;
36 } 38 }
37 39
38 namespace gpu { 40 namespace gpu {
39 class PreemptionFlag; 41 class PreemptionFlag;
40 class SyncPointClient; 42 class SyncPointClient;
41 class SyncPointManager; 43 class SyncPointManager;
42 struct SyncToken; 44 struct SyncToken;
43 union ValueState; 45 union ValueState;
44 namespace gles2 { 46 namespace gles2 {
45 class FramebufferCompletenessCache; 47 class FramebufferCompletenessCache;
46 class MailboxManager; 48 class MailboxManager;
47 class ProgramCache; 49 class ProgramCache;
48 class ShaderTranslatorCache; 50 class ShaderTranslatorCache;
49 } 51 }
50 } 52 }
51 53
52 namespace IPC { 54 namespace IPC {
53 struct ChannelHandle; 55 struct ChannelHandle;
54 class SyncChannel;
55 } 56 }
56 57
57 struct GPUCreateCommandBufferConfig;
58 struct GpuMsg_EstablishChannel_Params;
59
60 namespace content { 58 namespace content {
61 class GpuChannel; 59 class GpuChannel;
60 class GpuChannelManagerDelegate;
62 class GpuMemoryBufferFactory; 61 class GpuMemoryBufferFactory;
63 class GpuWatchdog; 62 class GpuWatchdog;
63 class ImageTransportHelper;
64 struct EstablishChannelParams;
65 #if defined(OS_MACOSX)
66 struct BufferPresentedParams;
67 #endif
64 68
65 // A GpuChannelManager is a thread responsible for issuing rendering commands 69 // A GpuChannelManager is a thread responsible for issuing rendering commands
66 // managing the lifetimes of GPU channels and forwarding IPC requests from the 70 // managing the lifetimes of GPU channels and forwarding IPC requests from the
67 // browser process to them based on the corresponding renderer ID. 71 // browser process to them based on the corresponding renderer ID.
68 class CONTENT_EXPORT GpuChannelManager : public IPC::Listener, 72 class CONTENT_EXPORT GpuChannelManager {
69 public IPC::Sender {
70 public: 73 public:
71 GpuChannelManager(IPC::SyncChannel* channel, 74 GpuChannelManager(GpuChannelManagerDelegate* delegate,
72 GpuWatchdog* watchdog, 75 GpuWatchdog* watchdog,
73 base::SingleThreadTaskRunner* task_runner, 76 base::SingleThreadTaskRunner* task_runner,
74 base::SingleThreadTaskRunner* io_task_runner, 77 base::SingleThreadTaskRunner* io_task_runner,
75 base::WaitableEvent* shutdown_event, 78 base::WaitableEvent* shutdown_event,
76 gpu::SyncPointManager* sync_point_manager, 79 gpu::SyncPointManager* sync_point_manager,
77 GpuMemoryBufferFactory* gpu_memory_buffer_factory); 80 GpuMemoryBufferFactory* gpu_memory_buffer_factory);
78 ~GpuChannelManager() override; 81 virtual ~GpuChannelManager();
82
83 GpuChannelManagerDelegate* delegate() { return delegate_; }
84 const GpuChannelManagerDelegate* delegate() const { return delegate_; }
no sievers 2016/02/22 21:57:42 nit: why two getters? you just need one getter tha
Fady Samuel 2016/02/23 04:45:27 This is a pattern we've been using in Mus, but it'
85
86 void EstablishChannel(const EstablishChannelParams& params);
87 void CloseChannel(const IPC::ChannelHandle& channel_handle);
88 void PopulateShaderCache(const std::string& shader);
89 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
90 int client_id,
91 const gpu::SyncToken& sync_token);
92 void UpdateValueState(int client_id,
93 unsigned int target,
94 const gpu::ValueState& state);
95 #if defined(OS_ANDROID)
96 void WakeUpGpu();
97 #endif
98 void DestroyAllChannels();
79 99
80 // Remove the channel for a particular renderer. 100 // Remove the channel for a particular renderer.
81 void RemoveChannel(int client_id); 101 void RemoveChannel(int client_id);
82 102
83 // Listener overrides.
84 bool OnMessageReceived(const IPC::Message& msg) override;
85
86 // Sender overrides.
87 bool Send(IPC::Message* msg) override;
88
89 void LoseAllContexts(); 103 void LoseAllContexts();
90 104
91 int GenerateRouteID(); 105 int GenerateRouteID();
92 void AddRoute(int32_t routing_id, IPC::Listener* listener); 106 void AddImageTransportSurface(int32_t routing_id,
93 void RemoveRoute(int32_t routing_id); 107 ImageTransportHelper* image_transport_helper);
108 void RemoveImageTransportSurface(int32_t routing_id);
109 #if defined(OS_MACOSX)
110 void BufferPresented(int32_t routing_id, const BufferPresentedParams& params);
111 #endif
94 112
95 gpu::gles2::ProgramCache* program_cache(); 113 gpu::gles2::ProgramCache* program_cache();
96 gpu::gles2::ShaderTranslatorCache* shader_translator_cache(); 114 gpu::gles2::ShaderTranslatorCache* shader_translator_cache();
97 gpu::gles2::FramebufferCompletenessCache* framebuffer_completeness_cache(); 115 gpu::gles2::FramebufferCompletenessCache* framebuffer_completeness_cache();
98 116
99 GpuMemoryManager* gpu_memory_manager() { return &gpu_memory_manager_; } 117 GpuMemoryManager* gpu_memory_manager() { return &gpu_memory_manager_; }
100 118
101 GpuChannel* LookupChannel(int32_t client_id) const; 119 GpuChannel* LookupChannel(int32_t client_id) const;
102 120
103 gfx::GLSurface* GetDefaultOffscreenSurface(); 121 gfx::GLSurface* GetDefaultOffscreenSurface();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 158
141 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 159 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
142 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 160 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
143 161
144 // These objects manage channels to individual renderer processes there is 162 // These objects manage channels to individual renderer processes there is
145 // one channel for each renderer process that has connected to this GPU 163 // one channel for each renderer process that has connected to this GPU
146 // process. 164 // process.
147 base::ScopedPtrHashMap<int32_t, scoped_ptr<GpuChannel>> gpu_channels_; 165 base::ScopedPtrHashMap<int32_t, scoped_ptr<GpuChannel>> gpu_channels_;
148 166
149 private: 167 private:
150 // Message handlers. 168 void InternalDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id);
151 bool OnControlMessageReceived(const IPC::Message& msg); 169 void InternalDestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id,
152 void OnEstablishChannel(const GpuMsg_EstablishChannel_Params& params); 170 int client_id);
153 void OnCloseChannel(const IPC::ChannelHandle& channel_handle);
154 void OnVisibilityChanged(int32_t render_view_id,
155 int32_t client_id,
156 bool visible);
157 void OnLoadedShader(const std::string& shader);
158 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id);
159 void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, int client_id);
160 void OnDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
161 int client_id,
162 const gpu::SyncToken& sync_token);
163
164 void OnUpdateValueState(int client_id,
165 unsigned int target,
166 const gpu::ValueState& state);
167 #if defined(OS_ANDROID) 171 #if defined(OS_ANDROID)
168 void OnWakeUpGpu();
169 void ScheduleWakeUpGpu(); 172 void ScheduleWakeUpGpu();
170 void DoWakeUpGpu(); 173 void DoWakeUpGpu();
171 #endif 174 #endif
172 void OnLoseAllContexts();
173 175
174 // Used to send and receive IPC messages from the browser process. 176 GpuChannelManagerDelegate* const delegate_;
175 IPC::SyncChannel* const channel_; 177 IDMap<ImageTransportHelper> image_transport_map_;
176 IPC::MessageRouter router_;
177 178
178 GpuWatchdog* watchdog_; 179 GpuWatchdog* watchdog_;
179 180
180 base::WaitableEvent* shutdown_event_; 181 base::WaitableEvent* shutdown_event_;
181 182
182 scoped_refptr<gfx::GLShareGroup> share_group_; 183 scoped_refptr<gfx::GLShareGroup> share_group_;
183 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; 184 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_;
184 scoped_refptr<gpu::PreemptionFlag> preemption_flag_; 185 scoped_refptr<gpu::PreemptionFlag> preemption_flag_;
185 GpuMemoryManager gpu_memory_manager_; 186 GpuMemoryManager gpu_memory_manager_;
186 // SyncPointManager guaranteed to outlive running MessageLoop. 187 // SyncPointManager guaranteed to outlive running MessageLoop.
(...skipping 16 matching lines...) Expand all
203 // that any WeakPtrs to Controller are invalidated before its members 204 // that any WeakPtrs to Controller are invalidated before its members
204 // variable's destructors are executed, rendering them invalid. 205 // variable's destructors are executed, rendering them invalid.
205 base::WeakPtrFactory<GpuChannelManager> weak_factory_; 206 base::WeakPtrFactory<GpuChannelManager> weak_factory_;
206 207
207 DISALLOW_COPY_AND_ASSIGN(GpuChannelManager); 208 DISALLOW_COPY_AND_ASSIGN(GpuChannelManager);
208 }; 209 };
209 210
210 } // namespace content 211 } // namespace content
211 212
212 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ 213 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698