| 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> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 base::ProcessHandle, | 59 base::ProcessHandle, |
| 60 const GPUInfo&>::Type | 60 const GPUInfo&>::Type |
| 61 EstablishChannelCallback; | 61 EstablishChannelCallback; |
| 62 | 62 |
| 63 // Tells the GPU process to create a new channel for communication with a | 63 // Tells the GPU process to create a new channel for communication with a |
| 64 // renderer. Once the GPU process responds asynchronously with the IPC handle | 64 // renderer. Once the GPU process responds asynchronously with the IPC handle |
| 65 // and GPUInfo, we call the callback. | 65 // and GPUInfo, we call the callback. |
| 66 void EstablishGpuChannel( | 66 void EstablishGpuChannel( |
| 67 int renderer_id, EstablishChannelCallback* callback); | 67 int renderer_id, EstablishChannelCallback* callback); |
| 68 | 68 |
| 69 typedef Callback0::Type SynchronizeCallback; | |
| 70 | |
| 71 // Sends a reply message later when the next GpuHostMsg_SynchronizeReply comes | |
| 72 // in. | |
| 73 void Synchronize(SynchronizeCallback* callback); | |
| 74 | |
| 75 typedef Callback1<int32>::Type CreateCommandBufferCallback; | 69 typedef Callback1<int32>::Type CreateCommandBufferCallback; |
| 76 | 70 |
| 77 // Tells the GPU process to create a new command buffer that draws into the | 71 // Tells the GPU process to create a new command buffer that draws into the |
| 78 // window associated with the given renderer. | 72 // window associated with the given renderer. |
| 79 void CreateViewCommandBuffer( | 73 void CreateViewCommandBuffer( |
| 80 gfx::PluginWindowHandle compositing_surface, | 74 gfx::PluginWindowHandle compositing_surface, |
| 81 int32 render_view_id, | 75 int32 render_view_id, |
| 82 int32 renderer_id, | 76 int32 renderer_id, |
| 83 const GPUCreateCommandBufferConfig& init_params, | 77 const GPUCreateCommandBufferConfig& init_params, |
| 84 CreateCommandBufferCallback* callback); | 78 CreateCommandBufferCallback* callback); |
| 85 | 79 |
| 86 private: | 80 private: |
| 87 GpuProcessHost(int host_id); | 81 GpuProcessHost(int host_id); |
| 88 virtual ~GpuProcessHost(); | 82 virtual ~GpuProcessHost(); |
| 89 | 83 |
| 90 bool Init(); | 84 bool Init(); |
| 91 | 85 |
| 92 // Post an IPC message to the UI shim's message handler on the UI thread. | 86 // Post an IPC message to the UI shim's message handler on the UI thread. |
| 93 void RouteOnUIThread(const IPC::Message& message); | 87 void RouteOnUIThread(const IPC::Message& message); |
| 94 | 88 |
| 95 virtual bool CanShutdown(); | 89 virtual bool CanShutdown(); |
| 96 virtual void OnProcessLaunched(); | 90 virtual void OnProcessLaunched(); |
| 97 virtual void OnChildDied(); | 91 virtual void OnChildDied(); |
| 98 virtual void OnProcessCrashed(int exit_code); | 92 virtual void OnProcessCrashed(int exit_code); |
| 99 | 93 |
| 100 // Message handlers. | 94 // Message handlers. |
| 101 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); | 95 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); |
| 102 void OnSynchronizeReply(); | |
| 103 void OnCommandBufferCreated(const int32 route_id); | 96 void OnCommandBufferCreated(const int32 route_id); |
| 104 void OnDestroyCommandBuffer( | 97 void OnDestroyCommandBuffer( |
| 105 gfx::PluginWindowHandle window, int32 renderer_id, int32 render_view_id); | 98 gfx::PluginWindowHandle window, int32 renderer_id, int32 render_view_id); |
| 106 void OnGraphicsInfoCollected(const GPUInfo& gpu_info); | 99 void OnGraphicsInfoCollected(const GPUInfo& gpu_info); |
| 107 | 100 |
| 108 bool LaunchGpuProcess(); | 101 bool LaunchGpuProcess(); |
| 109 | 102 |
| 110 void SendOutstandingReplies(); | 103 void SendOutstandingReplies(); |
| 111 void EstablishChannelError( | 104 void EstablishChannelError( |
| 112 EstablishChannelCallback* callback, | 105 EstablishChannelCallback* callback, |
| 113 const IPC::ChannelHandle& channel_handle, | 106 const IPC::ChannelHandle& channel_handle, |
| 114 base::ProcessHandle renderer_process_for_gpu, | 107 base::ProcessHandle renderer_process_for_gpu, |
| 115 const GPUInfo& gpu_info); | 108 const GPUInfo& gpu_info); |
| 116 void CreateCommandBufferError(CreateCommandBufferCallback* callback, | 109 void CreateCommandBufferError(CreateCommandBufferCallback* callback, |
| 117 int32 route_id); | 110 int32 route_id); |
| 118 void SynchronizeError(SynchronizeCallback* callback); | |
| 119 | 111 |
| 120 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. | 112 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. |
| 121 int host_id_; | 113 int host_id_; |
| 122 | 114 |
| 123 // These are the channel requests that we have already sent to | 115 // These are the channel requests that we have already sent to |
| 124 // the GPU process, but haven't heard back about yet. | 116 // the GPU process, but haven't heard back about yet. |
| 125 std::queue<linked_ptr<EstablishChannelCallback> > channel_requests_; | 117 std::queue<linked_ptr<EstablishChannelCallback> > channel_requests_; |
| 126 | 118 |
| 127 // The pending synchronization requests we need to reply to. | |
| 128 std::queue<linked_ptr<SynchronizeCallback> > synchronize_requests_; | |
| 129 | |
| 130 // The pending create command buffer requests we need to reply to. | 119 // The pending create command buffer requests we need to reply to. |
| 131 std::queue<linked_ptr<CreateCommandBufferCallback> > | 120 std::queue<linked_ptr<CreateCommandBufferCallback> > |
| 132 create_command_buffer_requests_; | 121 create_command_buffer_requests_; |
| 133 | 122 |
| 134 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) | 123 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) |
| 135 typedef std::pair<int32 /* renderer_id */, | 124 typedef std::pair<int32 /* renderer_id */, |
| 136 int32 /* render_view_id */> ViewID; | 125 int32 /* render_view_id */> ViewID; |
| 137 | 126 |
| 138 // Encapsulates surfaces that we lock when creating view command buffers. | 127 // Encapsulates surfaces that we lock when creating view command buffers. |
| 139 // We release this lock once the command buffer (or associated GPU process) | 128 // We release this lock once the command buffer (or associated GPU process) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 156 // Whether we are running a GPU thread inside the browser process instead | 145 // Whether we are running a GPU thread inside the browser process instead |
| 157 // of a separate GPU process. | 146 // of a separate GPU process. |
| 158 bool in_process_; | 147 bool in_process_; |
| 159 | 148 |
| 160 scoped_ptr<GpuMainThread> in_process_gpu_thread_; | 149 scoped_ptr<GpuMainThread> in_process_gpu_thread_; |
| 161 | 150 |
| 162 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 151 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
| 163 }; | 152 }; |
| 164 | 153 |
| 165 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 154 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
| OLD | NEW |