Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 11 |
| 12 #include "base/callback_old.h" | 12 #include "base/callback_old.h" |
| 13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
| 15 #include "content/browser/browser_child_process_host.h" | 15 #include "content/browser/browser_child_process_host.h" |
| 16 #include "content/common/gpu/gpu_info.h" | 16 #include "content/common/gpu/gpu_info.h" |
| 17 #include "content/common/gpu/gpu_process_launch_causes.h" | 17 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 18 #include "ui/gfx/native_widget_types.h" | 18 #include "ui/gfx/native_widget_types.h" |
| 19 | 19 |
| 20 struct GPUCreateCommandBufferConfig; | 20 struct GPUCreateCommandBufferConfig; |
| 21 | 21 |
| 22 namespace IPC { | 22 namespace IPC { |
| 23 class Message; | 23 class Message; |
| 24 } | 24 } |
| 25 | 25 |
| 26 class GpuThreadWrapper; | |
|
jam
2011/05/26 01:15:24
nit: can you call this GpuMainThread for consisten
| |
| 27 | |
| 26 class GpuProcessHost : public BrowserChildProcessHost, | 28 class GpuProcessHost : public BrowserChildProcessHost, |
| 27 public base::NonThreadSafe { | 29 public base::NonThreadSafe { |
| 28 public: | 30 public: |
| 29 // Creates a new GpuProcessHost or gets one for a particular | 31 // Creates a new GpuProcessHost or gets one for a particular |
| 30 // renderer process, resulting in the launching of a GPU process if required. | 32 // renderer process, resulting in the launching of a GPU process if required. |
| 31 // Returns null on failure. It is not safe to store the pointer once control | 33 // Returns null on failure. It is not safe to store the pointer once control |
| 32 // has returned to the message loop as it can be destroyed. Instead store the | 34 // has returned to the message loop as it can be destroyed. Instead store the |
| 33 // associated GPU host ID. A renderer ID of zero means the browser process. | 35 // associated GPU host ID. A renderer ID of zero means the browser process. |
| 34 // This could return NULL if GPU access is not allowed (blacklisted). | 36 // This could return NULL if GPU access is not allowed (blacklisted). |
| 35 static GpuProcessHost* GetForRenderer(int renderer_id, | 37 static GpuProcessHost* GetForRenderer(int renderer_id, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 // Tells the GPU process to create a new command buffer that draws into the | 77 // Tells the GPU process to create a new command buffer that draws into the |
| 76 // window associated with the given renderer. | 78 // window associated with the given renderer. |
| 77 void CreateViewCommandBuffer( | 79 void CreateViewCommandBuffer( |
| 78 gfx::PluginWindowHandle compositing_surface, | 80 gfx::PluginWindowHandle compositing_surface, |
| 79 int32 render_view_id, | 81 int32 render_view_id, |
| 80 int32 renderer_id, | 82 int32 renderer_id, |
| 81 const GPUCreateCommandBufferConfig& init_params, | 83 const GPUCreateCommandBufferConfig& init_params, |
| 82 CreateCommandBufferCallback* callback); | 84 CreateCommandBufferCallback* callback); |
| 83 | 85 |
| 84 private: | 86 private: |
| 85 GpuProcessHost(int host_id); | 87 GpuProcessHost(int host_id, bool in_process); |
| 86 virtual ~GpuProcessHost(); | 88 virtual ~GpuProcessHost(); |
| 87 | 89 |
| 88 bool Init(); | 90 bool Init(); |
| 89 | 91 |
| 90 // Post an IPC message to the UI shim's message handler on the UI thread. | 92 // Post an IPC message to the UI shim's message handler on the UI thread. |
| 91 void RouteOnUIThread(const IPC::Message& message); | 93 void RouteOnUIThread(const IPC::Message& message); |
| 92 | 94 |
| 93 virtual bool CanShutdown(); | 95 virtual bool CanShutdown(); |
| 94 virtual void OnProcessLaunched(); | 96 virtual void OnProcessLaunched(); |
| 95 virtual void OnChildDied(); | 97 virtual void OnChildDied(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 typedef std::multimap<ViewID, linked_ptr<SurfaceRef> > SurfaceRefMap; | 146 typedef std::multimap<ViewID, linked_ptr<SurfaceRef> > SurfaceRefMap; |
| 145 SurfaceRefMap surface_refs_; | 147 SurfaceRefMap surface_refs_; |
| 146 #endif | 148 #endif |
| 147 | 149 |
| 148 // Qeueud messages to send when the process launches. | 150 // Qeueud messages to send when the process launches. |
| 149 std::queue<IPC::Message*> queued_messages_; | 151 std::queue<IPC::Message*> queued_messages_; |
| 150 | 152 |
| 151 // The handle for the GPU process or null if it is not known to be launched. | 153 // The handle for the GPU process or null if it is not known to be launched. |
| 152 base::ProcessHandle gpu_process_; | 154 base::ProcessHandle gpu_process_; |
| 153 | 155 |
| 156 // Whether we are running a GPU thread inside the browser process instead | |
| 157 // of a separate GPU process. | |
| 158 bool in_process_; | |
| 159 | |
| 160 scoped_ptr<GpuThreadWrapper> in_process_gpu_thread_; | |
| 161 | |
| 154 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 162 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
| 155 }; | 163 }; |
| 156 | 164 |
| 157 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 165 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
| OLD | NEW |