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 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" |
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; | 56 class SyncChannel; |
55 } | 57 } |
56 | 58 |
57 struct GPUCreateCommandBufferConfig; | |
58 struct GpuMsg_EstablishChannel_Params; | |
59 | |
60 namespace content { | 59 namespace content { |
61 class GpuChannel; | 60 class GpuChannel; |
61 class GpuChannelManagerDelegate; | |
62 class GpuMemoryBufferFactory; | 62 class GpuMemoryBufferFactory; |
63 class GpuWatchdog; | 63 class GpuWatchdog; |
64 struct EstablishChannelParams; | |
64 | 65 |
65 // A GpuChannelManager is a thread responsible for issuing rendering commands | 66 // A GpuChannelManager is a thread responsible for issuing rendering commands |
66 // 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 |
67 // browser process to them based on the corresponding renderer ID. | 68 // browser process to them based on the corresponding renderer ID. |
68 class CONTENT_EXPORT GpuChannelManager : public IPC::Listener, | 69 class CONTENT_EXPORT GpuChannelManager : public IPC::Listener { |
69 public IPC::Sender { | |
70 public: | 70 public: |
71 GpuChannelManager(IPC::SyncChannel* channel, | 71 GpuChannelManager(GpuChannelManagerDelegate* delegate, |
72 IPC::SyncChannel* channel, | |
72 GpuWatchdog* watchdog, | 73 GpuWatchdog* watchdog, |
73 base::SingleThreadTaskRunner* task_runner, | 74 base::SingleThreadTaskRunner* task_runner, |
74 base::SingleThreadTaskRunner* io_task_runner, | 75 base::SingleThreadTaskRunner* io_task_runner, |
75 base::WaitableEvent* shutdown_event, | 76 base::WaitableEvent* shutdown_event, |
76 gpu::SyncPointManager* sync_point_manager, | 77 gpu::SyncPointManager* sync_point_manager, |
77 GpuMemoryBufferFactory* gpu_memory_buffer_factory); | 78 GpuMemoryBufferFactory* gpu_memory_buffer_factory); |
78 ~GpuChannelManager() override; | 79 ~GpuChannelManager() override; |
79 | 80 |
81 GpuChannelManagerDelegate* delegate() { return delegate_; } | |
82 const GpuChannelManagerDelegate* delegate() const { return delegate_; } | |
83 | |
84 void EstablishChannel(const EstablishChannelParams& params); | |
85 void CloseChannel(const IPC::ChannelHandle& channel_handle); | |
86 void PopulateShaderCache(const std::string& shader); | |
87 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | |
88 int client_id, | |
89 const gpu::SyncToken& sync_token); | |
90 void UpdateValueState(int client_id, | |
91 unsigned int target, | |
92 const gpu::ValueState& state); | |
93 #if defined(OS_ANDROID) | |
94 void WakeUpGpu(); | |
95 #endif | |
96 void DestroyAllChannels(); | |
97 | |
80 // Remove the channel for a particular renderer. | 98 // Remove the channel for a particular renderer. |
81 void RemoveChannel(int client_id); | 99 void RemoveChannel(int client_id); |
82 | 100 |
83 // Listener overrides. | 101 // Listener overrides. |
84 bool OnMessageReceived(const IPC::Message& msg) override; | 102 bool OnMessageReceived(const IPC::Message& msg) override; |
85 | 103 |
86 // Sender overrides. | |
87 bool Send(IPC::Message* msg) override; | |
88 | |
89 void LoseAllContexts(); | 104 void LoseAllContexts(); |
90 | 105 |
91 int GenerateRouteID(); | 106 int GenerateRouteID(); |
92 void AddRoute(int32_t routing_id, IPC::Listener* listener); | 107 void AddRoute(int32_t routing_id, IPC::Listener* listener); |
93 void RemoveRoute(int32_t routing_id); | 108 void RemoveRoute(int32_t routing_id); |
94 | 109 |
95 gpu::gles2::ProgramCache* program_cache(); | 110 gpu::gles2::ProgramCache* program_cache(); |
96 gpu::gles2::ShaderTranslatorCache* shader_translator_cache(); | 111 gpu::gles2::ShaderTranslatorCache* shader_translator_cache(); |
97 gpu::gles2::FramebufferCompletenessCache* framebuffer_completeness_cache(); | 112 gpu::gles2::FramebufferCompletenessCache* framebuffer_completeness_cache(); |
98 | 113 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 | 155 |
141 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 156 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
142 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 157 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
143 | 158 |
144 // These objects manage channels to individual renderer processes there is | 159 // These objects manage channels to individual renderer processes there is |
145 // one channel for each renderer process that has connected to this GPU | 160 // one channel for each renderer process that has connected to this GPU |
146 // process. | 161 // process. |
147 base::ScopedPtrHashMap<int32_t, scoped_ptr<GpuChannel>> gpu_channels_; | 162 base::ScopedPtrHashMap<int32_t, scoped_ptr<GpuChannel>> gpu_channels_; |
148 | 163 |
149 private: | 164 private: |
150 // Message handlers. | 165 void InternalDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id); |
151 bool OnControlMessageReceived(const IPC::Message& msg); | 166 void InternalDestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, |
152 void OnEstablishChannel(const GpuMsg_EstablishChannel_Params& params); | 167 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) | 168 #if defined(OS_ANDROID) |
168 void OnWakeUpGpu(); | |
169 void ScheduleWakeUpGpu(); | 169 void ScheduleWakeUpGpu(); |
170 void DoWakeUpGpu(); | 170 void DoWakeUpGpu(); |
171 #endif | 171 #endif |
172 void OnLoseAllContexts(); | |
173 | 172 |
173 GpuChannelManagerDelegate* const delegate_; | |
174 // Used to send and receive IPC messages from the browser process. | 174 // Used to send and receive IPC messages from the browser process. |
175 IPC::SyncChannel* const channel_; | 175 IPC::SyncChannel* const channel_; |
no sievers
2016/02/19 19:46:23
You can remove |channel_| now.
Fady Samuel
2016/02/19 20:33:30
Done.
| |
176 IPC::MessageRouter router_; | 176 IPC::MessageRouter router_; |
177 | 177 |
178 GpuWatchdog* watchdog_; | 178 GpuWatchdog* watchdog_; |
179 | 179 |
180 base::WaitableEvent* shutdown_event_; | 180 base::WaitableEvent* shutdown_event_; |
181 | 181 |
182 scoped_refptr<gfx::GLShareGroup> share_group_; | 182 scoped_refptr<gfx::GLShareGroup> share_group_; |
183 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; | 183 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; |
184 scoped_refptr<gpu::PreemptionFlag> preemption_flag_; | 184 scoped_refptr<gpu::PreemptionFlag> preemption_flag_; |
185 GpuMemoryManager gpu_memory_manager_; | 185 GpuMemoryManager gpu_memory_manager_; |
(...skipping 17 matching lines...) Expand all Loading... | |
203 // that any WeakPtrs to Controller are invalidated before its members | 203 // that any WeakPtrs to Controller are invalidated before its members |
204 // variable's destructors are executed, rendering them invalid. | 204 // variable's destructors are executed, rendering them invalid. |
205 base::WeakPtrFactory<GpuChannelManager> weak_factory_; | 205 base::WeakPtrFactory<GpuChannelManager> weak_factory_; |
206 | 206 |
207 DISALLOW_COPY_AND_ASSIGN(GpuChannelManager); | 207 DISALLOW_COPY_AND_ASSIGN(GpuChannelManager); |
208 }; | 208 }; |
209 | 209 |
210 } // namespace content | 210 } // namespace content |
211 | 211 |
212 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ | 212 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ |
OLD | NEW |