| 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" | |
| 19 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 20 #include "content/common/gpu/gpu_memory_uma_stats.h" | 19 #include "content/common/gpu/gpu_memory_uma_stats.h" |
| 21 #include "content/common/gpu/gpu_process_launch_causes.h" | 20 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 22 #include "content/common/gpu/gpu_result_codes.h" | 21 #include "content/common/gpu/gpu_result_codes.h" |
| 23 #include "content/public/browser/browser_child_process_host_delegate.h" | 22 #include "content/public/browser/browser_child_process_host_delegate.h" |
| 24 #include "content/public/browser/gpu_data_manager.h" | 23 #include "content/public/browser/gpu_data_manager.h" |
| 25 #include "gpu/command_buffer/common/constants.h" | 24 #include "gpu/command_buffer/common/constants.h" |
| 26 #include "gpu/config/gpu_info.h" | 25 #include "gpu/config/gpu_info.h" |
| 27 #include "ipc/ipc_sender.h" | 26 #include "ipc/ipc_sender.h" |
| 28 #include "ipc/message_filter.h" | 27 #include "ipc/message_filter.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 bool Send(IPC::Message* msg) override; | 103 bool Send(IPC::Message* msg) override; |
| 105 | 104 |
| 106 // Adds a message filter to the GpuProcessHost's channel. | 105 // Adds a message filter to the GpuProcessHost's channel. |
| 107 void AddFilter(IPC::MessageFilter* filter); | 106 void AddFilter(IPC::MessageFilter* filter); |
| 108 | 107 |
| 109 // Tells the GPU process to create a new channel for communication with a | 108 // Tells the GPU process to create a new channel for communication with a |
| 110 // client. Once the GPU process responds asynchronously with the IPC handle | 109 // client. Once the GPU process responds asynchronously with the IPC handle |
| 111 // and GPUInfo, we call the callback. | 110 // and GPUInfo, we call the callback. |
| 112 void EstablishGpuChannel(int client_id, | 111 void EstablishGpuChannel(int client_id, |
| 113 uint64_t client_tracing_id, | 112 uint64_t client_tracing_id, |
| 114 bool share_context, | 113 bool preempts, |
| 114 bool preempted, |
| 115 bool allow_future_sync_points, | 115 bool allow_future_sync_points, |
| 116 bool allow_real_time_streams, | 116 bool allow_real_time_streams, |
| 117 const EstablishChannelCallback& callback); | 117 const EstablishChannelCallback& callback); |
| 118 | 118 |
| 119 // Tells the GPU process to create a new command buffer that draws into the | 119 // Tells the GPU process to create a new command buffer that draws into the |
| 120 // given surface. | 120 // given surface. |
| 121 void CreateViewCommandBuffer( | 121 void CreateViewCommandBuffer( |
| 122 const gfx::GLSurfaceHandle& compositing_surface, | 122 const gfx::GLSurfaceHandle& compositing_surface, |
| 123 int surface_id, | |
| 124 int client_id, | 123 int client_id, |
| 125 const GPUCreateCommandBufferConfig& init_params, | 124 const GPUCreateCommandBufferConfig& init_params, |
| 126 int route_id, | 125 int route_id, |
| 127 const CreateCommandBufferCallback& callback); | 126 const CreateCommandBufferCallback& callback); |
| 128 | 127 |
| 129 // Tells the GPU process to create a new GPU memory buffer. | 128 // Tells the GPU process to create a new GPU memory buffer. |
| 130 void CreateGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 129 void CreateGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
| 131 const gfx::Size& size, | 130 const gfx::Size& size, |
| 132 gfx::BufferFormat format, | 131 gfx::BufferFormat format, |
| 133 gfx::BufferUsage usage, | 132 gfx::BufferUsage usage, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 bool OnMessageReceived(const IPC::Message& message) override; | 169 bool OnMessageReceived(const IPC::Message& message) override; |
| 171 void OnChannelConnected(int32 peer_pid) override; | 170 void OnChannelConnected(int32 peer_pid) override; |
| 172 void OnProcessLaunched() override; | 171 void OnProcessLaunched() override; |
| 173 void OnProcessLaunchFailed() override; | 172 void OnProcessLaunchFailed() override; |
| 174 void OnProcessCrashed(int exit_code) override; | 173 void OnProcessCrashed(int exit_code) override; |
| 175 | 174 |
| 176 // Message handlers. | 175 // Message handlers. |
| 177 void OnInitialized(bool result, const gpu::GPUInfo& gpu_info); | 176 void OnInitialized(bool result, const gpu::GPUInfo& gpu_info); |
| 178 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); | 177 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); |
| 179 void OnCommandBufferCreated(CreateCommandBufferResult result); | 178 void OnCommandBufferCreated(CreateCommandBufferResult result); |
| 180 void OnDestroyCommandBuffer(int32 surface_id); | |
| 181 void OnGpuMemoryBufferCreated(const gfx::GpuMemoryBufferHandle& handle); | 179 void OnGpuMemoryBufferCreated(const gfx::GpuMemoryBufferHandle& handle); |
| 182 void OnDidCreateOffscreenContext(const GURL& url); | 180 void OnDidCreateOffscreenContext(const GURL& url); |
| 183 void OnDidLoseContext(bool offscreen, | 181 void OnDidLoseContext(bool offscreen, |
| 184 gpu::error::ContextLostReason reason, | 182 gpu::error::ContextLostReason reason, |
| 185 const GURL& url); | 183 const GURL& url); |
| 186 void OnDidDestroyOffscreenContext(const GURL& url); | 184 void OnDidDestroyOffscreenContext(const GURL& url); |
| 187 void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats); | 185 void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats); |
| 188 #if defined(OS_MACOSX) | 186 #if defined(OS_MACOSX) |
| 189 void OnAcceleratedSurfaceBuffersSwapped(const IPC::Message& message); | 187 void OnAcceleratedSurfaceBuffersSwapped(const IPC::Message& message); |
| 190 #endif | 188 #endif |
| (...skipping 20 matching lines...) Expand all Loading... |
| 211 // These are the channel requests that we have already sent to | 209 // These are the channel requests that we have already sent to |
| 212 // the GPU process, but haven't heard back about yet. | 210 // the GPU process, but haven't heard back about yet. |
| 213 std::queue<EstablishChannelCallback> channel_requests_; | 211 std::queue<EstablishChannelCallback> channel_requests_; |
| 214 | 212 |
| 215 // The pending create command buffer requests we need to reply to. | 213 // The pending create command buffer requests we need to reply to. |
| 216 std::queue<CreateCommandBufferCallback> create_command_buffer_requests_; | 214 std::queue<CreateCommandBufferCallback> create_command_buffer_requests_; |
| 217 | 215 |
| 218 // The pending create gpu memory buffer requests we need to reply to. | 216 // The pending create gpu memory buffer requests we need to reply to. |
| 219 std::queue<CreateGpuMemoryBufferCallback> create_gpu_memory_buffer_requests_; | 217 std::queue<CreateGpuMemoryBufferCallback> create_gpu_memory_buffer_requests_; |
| 220 | 218 |
| 221 // Surface ids for pending gpu memory buffer request refs. | |
| 222 std::queue<int32> create_gpu_memory_buffer_surface_refs_; | |
| 223 | |
| 224 // Qeueud messages to send when the process launches. | 219 // Qeueud messages to send when the process launches. |
| 225 std::queue<IPC::Message*> queued_messages_; | 220 std::queue<IPC::Message*> queued_messages_; |
| 226 | 221 |
| 227 // Whether the GPU process is valid, set to false after Send() failed. | 222 // Whether the GPU process is valid, set to false after Send() failed. |
| 228 bool valid_; | 223 bool valid_; |
| 229 | 224 |
| 230 // Whether we are running a GPU thread inside the browser process instead | 225 // Whether we are running a GPU thread inside the browser process instead |
| 231 // of a separate GPU process. | 226 // of a separate GPU process. |
| 232 bool in_process_; | 227 bool in_process_; |
| 233 | 228 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // Statics kept around to send to UMA histograms on GPU process lost. | 264 // Statics kept around to send to UMA histograms on GPU process lost. |
| 270 bool uma_memory_stats_received_; | 265 bool uma_memory_stats_received_; |
| 271 GPUMemoryUmaStats uma_memory_stats_; | 266 GPUMemoryUmaStats uma_memory_stats_; |
| 272 | 267 |
| 273 typedef std::map<int32, scoped_refptr<ShaderDiskCache> > | 268 typedef std::map<int32, scoped_refptr<ShaderDiskCache> > |
| 274 ClientIdToShaderCacheMap; | 269 ClientIdToShaderCacheMap; |
| 275 ClientIdToShaderCacheMap client_id_to_shader_cache_; | 270 ClientIdToShaderCacheMap client_id_to_shader_cache_; |
| 276 | 271 |
| 277 std::string shader_prefix_key_; | 272 std::string shader_prefix_key_; |
| 278 | 273 |
| 279 // Keep an extra reference to the SurfaceRef stored in the GpuSurfaceTracker | |
| 280 // in this map so that we don't destroy it whilst the GPU process is | |
| 281 // drawing to it. | |
| 282 typedef std::multimap<int, scoped_refptr<GpuSurfaceTracker::SurfaceRef> > | |
| 283 SurfaceRefMap; | |
| 284 SurfaceRefMap surface_refs_; | |
| 285 | |
| 286 #if defined(OS_MACOSX) && !defined(OS_IOS) | 274 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 287 // Unique unguessable token that the GPU process is using to register | 275 // Unique unguessable token that the GPU process is using to register |
| 288 // IOSurfaces. | 276 // IOSurfaces. |
| 289 IOSurfaceManagerToken io_surface_manager_token_; | 277 IOSurfaceManagerToken io_surface_manager_token_; |
| 290 #endif | 278 #endif |
| 291 | 279 |
| 292 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 280 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
| 293 }; | 281 }; |
| 294 | 282 |
| 295 } // namespace content | 283 } // namespace content |
| 296 | 284 |
| 297 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 285 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
| OLD | NEW |