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_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 5 #ifndef CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
6 #define CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 6 #define CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <queue> | 9 #include <queue> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/threading/non_thread_safe.h" | 16 #include "base/threading/non_thread_safe.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "content/browser/gpu/gpu_surface_tracker.h" | 18 #include "content/browser/gpu/gpu_surface_tracker.h" |
19 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
20 #include "content/common/gpu/gpu_memory_uma_stats.h" | 20 #include "content/common/gpu/gpu_memory_uma_stats.h" |
21 #include "content/common/gpu/gpu_process_launch_causes.h" | 21 #include "content/common/gpu/gpu_process_launch_causes.h" |
22 #include "content/common/gpu/gpu_result_codes.h" | 22 #include "content/common/gpu/gpu_result_codes.h" |
23 #include "content/public/browser/browser_child_process_host_delegate.h" | 23 #include "content/public/browser/browser_child_process_host_delegate.h" |
24 #include "content/public/browser/gpu_data_manager.h" | 24 #include "content/public/browser/gpu_data_manager.h" |
25 #include "gpu/command_buffer/common/constants.h" | 25 #include "gpu/command_buffer/common/constants.h" |
26 #include "gpu/command_buffer/common/value_state.h" | |
26 #include "gpu/config/gpu_info.h" | 27 #include "gpu/config/gpu_info.h" |
27 #include "ipc/ipc_sender.h" | 28 #include "ipc/ipc_sender.h" |
28 #include "ipc/message_filter.h" | 29 #include "ipc/message_filter.h" |
29 #include "ui/gfx/gpu_memory_buffer.h" | 30 #include "ui/gfx/gpu_memory_buffer.h" |
30 #include "ui/gfx/native_widget_types.h" | 31 #include "ui/gfx/native_widget_types.h" |
31 #include "ui/gfx/size.h" | 32 #include "ui/gfx/size.h" |
32 #include "url/gurl.h" | 33 #include "url/gurl.h" |
33 | 34 |
34 struct GPUCreateCommandBufferConfig; | 35 struct GPUCreateCommandBufferConfig; |
35 | 36 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 static void GetProcessHandles( | 80 static void GetProcessHandles( |
80 const GpuDataManager::GetGpuProcessHandlesCallback& callback); | 81 const GpuDataManager::GetGpuProcessHandlesCallback& callback); |
81 | 82 |
82 // Helper function to send the given message to the GPU process on the IO | 83 // Helper function to send the given message to the GPU process on the IO |
83 // thread. Calls Get and if a host is returned, sends it. Can be called from | 84 // thread. Calls Get and if a host is returned, sends it. Can be called from |
84 // any thread. Deletes the message if it cannot be sent. | 85 // any thread. Deletes the message if it cannot be sent. |
85 CONTENT_EXPORT static void SendOnIO(GpuProcessKind kind, | 86 CONTENT_EXPORT static void SendOnIO(GpuProcessKind kind, |
86 CauseForGpuLaunch cause, | 87 CauseForGpuLaunch cause, |
87 IPC::Message* message); | 88 IPC::Message* message); |
88 | 89 |
90 CONTENT_EXPORT static void SendUpdateValueStateOnIO( | |
Tom Sepez
2014/12/04 22:08:10
nit: I'd prefer if this were named SendUpdateValue
orglofch
2014/12/04 23:37:10
Done.
| |
91 int client_id, unsigned int target, const gpu::ValueState& state); | |
92 | |
89 CONTENT_EXPORT static void RegisterGpuMainThreadFactory( | 93 CONTENT_EXPORT static void RegisterGpuMainThreadFactory( |
90 GpuMainThreadFactoryFunction create); | 94 GpuMainThreadFactoryFunction create); |
91 | 95 |
92 // Get the GPU process host for the GPU process with the given ID. Returns | 96 // Get the GPU process host for the GPU process with the given ID. Returns |
93 // null if the process no longer exists. | 97 // null if the process no longer exists. |
94 static GpuProcessHost* FromID(int host_id); | 98 static GpuProcessHost* FromID(int host_id); |
95 int host_id() const { return host_id_; } | 99 int host_id() const { return host_id_; } |
96 | 100 |
97 // IPC::Sender implementation. | 101 // IPC::Sender implementation. |
98 bool Send(IPC::Message* msg) override; | 102 bool Send(IPC::Message* msg) override; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 GpuProcessKind kind(); | 139 GpuProcessKind kind(); |
136 | 140 |
137 void ForceShutdown(); | 141 void ForceShutdown(); |
138 | 142 |
139 void BeginFrameSubscription( | 143 void BeginFrameSubscription( |
140 int surface_id, | 144 int surface_id, |
141 base::WeakPtr<RenderWidgetHostViewFrameSubscriber> subscriber); | 145 base::WeakPtr<RenderWidgetHostViewFrameSubscriber> subscriber); |
142 void EndFrameSubscription(int surface_id); | 146 void EndFrameSubscription(int surface_id); |
143 void LoadedShader(const std::string& key, const std::string& data); | 147 void LoadedShader(const std::string& key, const std::string& data); |
144 | 148 |
149 void SendUpdateValueState(int client_id, | |
150 unsigned int target, | |
151 const gpu::ValueState& state); | |
152 | |
145 private: | 153 private: |
146 static bool ValidateHost(GpuProcessHost* host); | 154 static bool ValidateHost(GpuProcessHost* host); |
147 | 155 |
148 GpuProcessHost(int host_id, GpuProcessKind kind); | 156 GpuProcessHost(int host_id, GpuProcessKind kind); |
149 ~GpuProcessHost() override; | 157 ~GpuProcessHost() override; |
150 | 158 |
151 bool Init(); | 159 bool Init(); |
152 | 160 |
153 // Post an IPC message to the UI shim's message handler on the UI thread. | 161 // Post an IPC message to the UI shim's message handler on the UI thread. |
154 void RouteOnUIThread(const IPC::Message& message); | 162 void RouteOnUIThread(const IPC::Message& message); |
(...skipping 17 matching lines...) Expand all Loading... | |
172 void OnDidDestroyOffscreenContext(const GURL& url); | 180 void OnDidDestroyOffscreenContext(const GURL& url); |
173 void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats); | 181 void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats); |
174 #if defined(OS_MACOSX) | 182 #if defined(OS_MACOSX) |
175 void OnAcceleratedSurfaceBuffersSwapped(const IPC::Message& message); | 183 void OnAcceleratedSurfaceBuffersSwapped(const IPC::Message& message); |
176 #endif | 184 #endif |
177 | 185 |
178 void CreateChannelCache(int32 client_id); | 186 void CreateChannelCache(int32 client_id); |
179 void OnDestroyChannel(int32 client_id); | 187 void OnDestroyChannel(int32 client_id); |
180 void OnCacheShader(int32 client_id, const std::string& key, | 188 void OnCacheShader(int32 client_id, const std::string& key, |
181 const std::string& shader); | 189 const std::string& shader); |
190 void OnAddSubscription(unsigned int target); | |
191 void OnRemoveSubscription(unsigned int target); | |
182 | 192 |
183 bool LaunchGpuProcess(const std::string& channel_id); | 193 bool LaunchGpuProcess(const std::string& channel_id); |
184 | 194 |
185 void SendOutstandingReplies(); | 195 void SendOutstandingReplies(); |
186 | 196 |
187 void BlockLiveOffscreenContexts(); | 197 void BlockLiveOffscreenContexts(); |
188 | 198 |
189 // Update GPU crash counters. Disable GPU if crash limit is reached. | 199 // Update GPU crash counters. Disable GPU if crash limit is reached. |
190 void RecordProcessCrash(); | 200 void RecordProcessCrash(); |
191 | 201 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 | 279 |
270 std::string shader_prefix_key_; | 280 std::string shader_prefix_key_; |
271 | 281 |
272 // Keep an extra reference to the SurfaceRef stored in the GpuSurfaceTracker | 282 // Keep an extra reference to the SurfaceRef stored in the GpuSurfaceTracker |
273 // in this map so that we don't destroy it whilst the GPU process is | 283 // in this map so that we don't destroy it whilst the GPU process is |
274 // drawing to it. | 284 // drawing to it. |
275 typedef std::multimap<int, scoped_refptr<GpuSurfaceTracker::SurfaceRef> > | 285 typedef std::multimap<int, scoped_refptr<GpuSurfaceTracker::SurfaceRef> > |
276 SurfaceRefMap; | 286 SurfaceRefMap; |
277 SurfaceRefMap surface_refs_; | 287 SurfaceRefMap surface_refs_; |
278 | 288 |
289 // This is a set of all subscription targets valuebuffers in the GPU process | |
290 // are currently subscribed too. Used to prevent sending unnecessary | |
291 // ValueState updates. | |
292 typedef base::hash_set<unsigned int> SubscriptionSet; | |
293 SubscriptionSet subscription_set_; | |
294 | |
279 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 295 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
280 }; | 296 }; |
281 | 297 |
282 } // namespace content | 298 } // namespace content |
283 | 299 |
284 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 300 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
OLD | NEW |