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 #if defined(OS_WIN) | 5 #if defined(OS_WIN) |
6 #include <windows.h> | 6 #include <windows.h> |
7 #endif | 7 #endif |
8 | 8 |
9 #include "content/browser/renderer_host/gpu_message_filter.h" | 9 #include "content/browser/renderer_host/gpu_message_filter.h" |
10 | 10 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 frame_subscription_list.swap(frame_subscription_list_); | 96 frame_subscription_list.swap(frame_subscription_list_); |
97 for (FrameSubscriptionList::iterator it = frame_subscription_list.begin(); | 97 for (FrameSubscriptionList::iterator it = frame_subscription_list.begin(); |
98 it != frame_subscription_list.end(); ++it) { | 98 it != frame_subscription_list.end(); ++it) { |
99 if ((*it)->route_id != route_id) | 99 if ((*it)->route_id != route_id) |
100 frame_subscription_list_.push_back(*it); | 100 frame_subscription_list_.push_back(*it); |
101 else | 101 else |
102 EndFrameSubscriptionInternal(*it); | 102 EndFrameSubscriptionInternal(*it); |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 GpuProcessHost* GpuMessageFilter::GetGpuProcessHost( | |
107 CauseForGpuLaunch cause_for_gpu_launch) { | |
108 GpuProcessHost* host = GpuProcessHost::FromID(gpu_process_id_); | |
109 if (!host) { | |
110 host = GpuProcessHost::Get(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | |
111 cause_for_gpu_launch); | |
112 if (!host) { | |
113 return NULL; | |
114 } | |
115 | |
116 gpu_process_id_ = host->host_id(); | |
117 | |
118 // Apply all frame subscriptions to the new GpuProcessHost. | |
119 BeginAllFrameSubscriptions(); | |
120 } | |
121 | |
122 return host; | |
123 } | |
124 | |
106 void GpuMessageFilter::OnEstablishGpuChannel( | 125 void GpuMessageFilter::OnEstablishGpuChannel( |
107 CauseForGpuLaunch cause_for_gpu_launch, | 126 CauseForGpuLaunch cause_for_gpu_launch, |
108 IPC::Message* reply_ptr) { | 127 IPC::Message* reply_ptr) { |
109 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 128 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
110 scoped_ptr<IPC::Message> reply(reply_ptr); | 129 scoped_ptr<IPC::Message> reply(reply_ptr); |
111 | 130 |
112 // TODO(apatrick): Eventually, this will return the route ID of a | 131 // TODO(apatrick): Eventually, this will return the route ID of a |
113 // GpuProcessStub, from which the renderer process will create a | 132 // GpuProcessStub, from which the renderer process will create a |
114 // GpuProcessProxy. The renderer will use the proxy for all subsequent | 133 // GpuProcessProxy. The renderer will use the proxy for all subsequent |
115 // communication with the GPU process. This means if the GPU process | 134 // communication with the GPU process. This means if the GPU process |
116 // terminates, the renderer process will not find itself unknowingly sending | 135 // terminates, the renderer process will not find itself unknowingly sending |
117 // IPCs to a newly launched GPU process. Also, I will rename this function | 136 // IPCs to a newly launched GPU process. Also, I will rename this function |
118 // to something like OnCreateGpuProcess. | 137 // to something like OnCreateGpuProcess. |
119 GpuProcessHost* host = GpuProcessHost::FromID(gpu_process_id_); | 138 GpuProcessHost* host = GetGpuProcessHost(cause_for_gpu_launch); |
120 if (!host) { | 139 if (!host) { |
121 host = GpuProcessHost::Get(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 140 reply->set_reply_error(); |
122 cause_for_gpu_launch); | 141 Send(reply.release()); |
123 if (!host) { | 142 return; |
124 reply->set_reply_error(); | |
125 Send(reply.release()); | |
126 return; | |
127 } | |
128 | |
129 gpu_process_id_ = host->host_id(); | |
130 | |
131 // Apply all frame subscriptions to the new GpuProcessHost. | |
132 BeginAllFrameSubscriptions(); | |
133 } | 143 } |
134 | 144 |
135 bool share_contexts = true; | 145 bool share_contexts = true; |
136 host->EstablishGpuChannel( | 146 host->EstablishGpuChannel( |
137 render_process_id_, | 147 render_process_id_, |
138 share_contexts, | 148 share_contexts, |
139 base::Bind(&GpuMessageFilter::EstablishChannelCallback, | 149 base::Bind(&GpuMessageFilter::EstablishChannelCallback, |
140 weak_ptr_factory_.GetWeakPtr(), | 150 weak_ptr_factory_.GetWeakPtr(), |
141 base::Passed(&reply))); | 151 base::Passed(&reply))); |
142 } | 152 } |
(...skipping 19 matching lines...) Expand all Loading... | |
162 DLOG(ERROR) << "Renderer " << render_process_id_ | 172 DLOG(ERROR) << "Renderer " << render_process_id_ |
163 << " tried to access a surface for renderer " << renderer_id; | 173 << " tried to access a surface for renderer " << renderer_id; |
164 } | 174 } |
165 | 175 |
166 if (compositing_surface.parent_client_id && | 176 if (compositing_surface.parent_client_id && |
167 !GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { | 177 !GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { |
168 // For the renderer to fall back to software also. | 178 // For the renderer to fall back to software also. |
169 compositing_surface = gfx::GLSurfaceHandle(); | 179 compositing_surface = gfx::GLSurfaceHandle(); |
170 } | 180 } |
171 | 181 |
172 GpuProcessHost* host = GpuProcessHost::FromID(gpu_process_id_); | 182 GpuProcessHost* host = GetGpuProcessHost( |
183 // This is currently the only creator of a view command buffer. | |
184 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE); | |
piman
2014/05/08 03:29:21
So, relaunching the GPU process is not actually go
Ken Russell (switch to Gerrit)
2014/05/09 01:36:13
Thanks for the feedback. I'll redo this as a check
| |
173 if (!host || compositing_surface.is_null()) { | 185 if (!host || compositing_surface.is_null()) { |
174 // TODO(apatrick): Eventually, this IPC message will be routed to a | 186 // TODO(apatrick): Eventually, this IPC message will be routed to a |
175 // GpuProcessStub with a particular routing ID. The error will be set if | 187 // GpuProcessStub with a particular routing ID. The error will be set if |
176 // the GpuProcessStub with that routing ID is not in the MessageRouter. | 188 // the GpuProcessStub with that routing ID is not in the MessageRouter. |
177 reply->set_reply_error(); | 189 reply->set_reply_error(); |
178 Send(reply.release()); | 190 Send(reply.release()); |
179 return; | 191 return; |
180 } | 192 } |
181 | 193 |
182 host->CreateViewCommandBuffer( | 194 host->CreateViewCommandBuffer( |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 // so it is not necessary to end it. | 270 // so it is not necessary to end it. |
259 if (!host || !subscription->surface_id) | 271 if (!host || !subscription->surface_id) |
260 return; | 272 return; |
261 | 273 |
262 // Note that GpuProcessHost here might not be the same one that frame | 274 // Note that GpuProcessHost here might not be the same one that frame |
263 // subscription has applied. | 275 // subscription has applied. |
264 host->EndFrameSubscription(subscription->surface_id); | 276 host->EndFrameSubscription(subscription->surface_id); |
265 } | 277 } |
266 | 278 |
267 } // namespace content | 279 } // namespace content |
OLD | NEW |