| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <queue> | 10 #include <queue> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
| 15 #include "base/process.h" | 15 #include "base/process.h" |
| 16 #include "base/threading/non_thread_safe.h" | 16 #include "base/threading/non_thread_safe.h" |
| 17 #include "base/time.h" | 17 #include "base/time.h" |
| 18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 19 #include "content/common/gpu/gpu_process_launch_causes.h" | 19 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 20 #include "content/public/browser/browser_child_process_host_delegate.h" | 20 #include "content/public/browser/browser_child_process_host_delegate.h" |
| 21 #include "content/public/common/gpu_info.h" | 21 #include "content/public/common/gpu_info.h" |
| 22 #include "content/public/common/gpu_mem_stats.h" |
| 22 #include "ipc/ipc_sender.h" | 23 #include "ipc/ipc_sender.h" |
| 23 #include "ui/gfx/native_widget_types.h" | 24 #include "ui/gfx/native_widget_types.h" |
| 24 | 25 |
| 25 class GpuMainThread; | 26 class GpuMainThread; |
| 26 struct GPUCreateCommandBufferConfig; | 27 struct GPUCreateCommandBufferConfig; |
| 27 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; | 28 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; |
| 28 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; | 29 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; |
| 29 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; | 30 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; |
| 30 | 31 |
| 31 class BrowserChildProcessHostImpl; | 32 class BrowserChildProcessHostImpl; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 43 GPU_PROCESS_KIND_SANDBOXED, | 44 GPU_PROCESS_KIND_SANDBOXED, |
| 44 GPU_PROCESS_KIND_COUNT | 45 GPU_PROCESS_KIND_COUNT |
| 45 }; | 46 }; |
| 46 | 47 |
| 47 typedef base::Callback<void(const IPC::ChannelHandle&, | 48 typedef base::Callback<void(const IPC::ChannelHandle&, |
| 48 const content::GPUInfo&)> | 49 const content::GPUInfo&)> |
| 49 EstablishChannelCallback; | 50 EstablishChannelCallback; |
| 50 | 51 |
| 51 typedef base::Callback<void(int32)> CreateCommandBufferCallback; | 52 typedef base::Callback<void(int32)> CreateCommandBufferCallback; |
| 52 | 53 |
| 54 typedef base::Callback<void (const content::GpuMemStats& mem_stats)> |
| 55 OnMemStatsCallback; |
| 56 |
| 57 // Specify a callback to make when an OnMemStats message is received. |
| 58 // Note that this function is to be called exactly once before every |
| 59 // GpuHostMsg_MemStats message from the GPU process. |
| 60 void SetOnMemStatsCallback(OnMemStatsCallback callback); |
| 61 |
| 53 static bool gpu_enabled() { return gpu_enabled_; } | 62 static bool gpu_enabled() { return gpu_enabled_; } |
| 54 | 63 |
| 55 // Creates a new GpuProcessHost or gets an existing one, resulting in the | 64 // Creates a new GpuProcessHost or gets an existing one, resulting in the |
| 56 // launching of a GPU process if required. Returns null on failure. It | 65 // launching of a GPU process if required. Returns null on failure. It |
| 57 // is not safe to store the pointer once control has returned to the message | 66 // is not safe to store the pointer once control has returned to the message |
| 58 // loop as it can be destroyed. Instead store the associated GPU host ID. | 67 // loop as it can be destroyed. Instead store the associated GPU host ID. |
| 59 // This could return NULL if GPU access is not allowed (blacklisted). | 68 // This could return NULL if GPU access is not allowed (blacklisted). |
| 60 static GpuProcessHost* Get(GpuProcessKind kind, | 69 static GpuProcessHost* Get(GpuProcessKind kind, |
| 61 content::CauseForGpuLaunch cause); | 70 content::CauseForGpuLaunch cause); |
| 62 | 71 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // BrowserChildProcessHostDelegate implementation. | 122 // BrowserChildProcessHostDelegate implementation. |
| 114 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 123 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 115 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 124 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
| 116 virtual void OnProcessLaunched() OVERRIDE; | 125 virtual void OnProcessLaunched() OVERRIDE; |
| 117 virtual void OnProcessCrashed(int exit_code) OVERRIDE; | 126 virtual void OnProcessCrashed(int exit_code) OVERRIDE; |
| 118 | 127 |
| 119 // Message handlers. | 128 // Message handlers. |
| 120 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); | 129 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); |
| 121 void OnCommandBufferCreated(const int32 route_id); | 130 void OnCommandBufferCreated(const int32 route_id); |
| 122 void OnDestroyCommandBuffer(int32 surface_id); | 131 void OnDestroyCommandBuffer(int32 surface_id); |
| 132 void OnMemStats(content::GpuMemStats mem_stats); |
| 123 | 133 |
| 124 #if defined(OS_MACOSX) | 134 #if defined(OS_MACOSX) |
| 125 void OnAcceleratedSurfaceBuffersSwapped( | 135 void OnAcceleratedSurfaceBuffersSwapped( |
| 126 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); | 136 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); |
| 127 #endif | 137 #endif |
| 128 #if defined(OS_WIN) && !defined(USE_AURA) | 138 #if defined(OS_WIN) && !defined(USE_AURA) |
| 129 void OnAcceleratedSurfaceBuffersSwapped( | 139 void OnAcceleratedSurfaceBuffersSwapped( |
| 130 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); | 140 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); |
| 131 void OnAcceleratedSurfacePostSubBuffer( | 141 void OnAcceleratedSurfacePostSubBuffer( |
| 132 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params); | 142 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // Time Init started. Used to log total GPU process startup time to UMA. | 197 // Time Init started. Used to log total GPU process startup time to UMA. |
| 188 base::TimeTicks init_start_time_; | 198 base::TimeTicks init_start_time_; |
| 189 | 199 |
| 190 // Master switch for enabling/disabling GPU acceleration for the current | 200 // Master switch for enabling/disabling GPU acceleration for the current |
| 191 // browser session. It does not change the acceleration settings for | 201 // browser session. It does not change the acceleration settings for |
| 192 // existing tabs, just the future ones. | 202 // existing tabs, just the future ones. |
| 193 static bool gpu_enabled_; | 203 static bool gpu_enabled_; |
| 194 | 204 |
| 195 static bool hardware_gpu_enabled_; | 205 static bool hardware_gpu_enabled_; |
| 196 | 206 |
| 207 OnMemStatsCallback on_mem_stats_callback_; |
| 208 |
| 197 scoped_ptr<BrowserChildProcessHostImpl> process_; | 209 scoped_ptr<BrowserChildProcessHostImpl> process_; |
| 198 | 210 |
| 199 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 211 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
| 200 }; | 212 }; |
| 201 | 213 |
| 202 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 214 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
| OLD | NEW |