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 #include "content/common/gpu/client/gpu_channel_host.h" | 5 #include "content/common/gpu/client/gpu_channel_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 CommandBufferProxyImpl* share_group, | 130 CommandBufferProxyImpl* share_group, |
131 const std::string& allowed_extensions, | 131 const std::string& allowed_extensions, |
132 const std::vector<int32>& attribs, | 132 const std::vector<int32>& attribs, |
133 const GURL& active_url, | 133 const GURL& active_url, |
134 gfx::GpuPreference gpu_preference) { | 134 gfx::GpuPreference gpu_preference) { |
135 TRACE_EVENT1("gpu", | 135 TRACE_EVENT1("gpu", |
136 "GpuChannelHost::CreateViewCommandBuffer", | 136 "GpuChannelHost::CreateViewCommandBuffer", |
137 "surface_id", | 137 "surface_id", |
138 surface_id); | 138 surface_id); |
139 | 139 |
140 #if defined(ENABLE_GPU) | |
141 AutoLock lock(context_lock_); | 140 AutoLock lock(context_lock_); |
142 // An error occurred. Need to get the host again to reinitialize it. | 141 // An error occurred. Need to get the host again to reinitialize it. |
143 if (!channel_.get()) | 142 if (!channel_.get()) |
144 return NULL; | 143 return NULL; |
145 | 144 |
146 GPUCreateCommandBufferConfig init_params; | 145 GPUCreateCommandBufferConfig init_params; |
147 init_params.share_group_id = | 146 init_params.share_group_id = |
148 share_group ? share_group->GetRouteID() : MSG_ROUTING_NONE; | 147 share_group ? share_group->GetRouteID() : MSG_ROUTING_NONE; |
149 init_params.allowed_extensions = allowed_extensions; | 148 init_params.allowed_extensions = allowed_extensions; |
150 init_params.attribs = attribs; | 149 init_params.attribs = attribs; |
151 init_params.active_url = active_url; | 150 init_params.active_url = active_url; |
152 init_params.gpu_preference = gpu_preference; | 151 init_params.gpu_preference = gpu_preference; |
153 int32 route_id = factory_->CreateViewCommandBuffer(surface_id, init_params); | 152 int32 route_id = factory_->CreateViewCommandBuffer(surface_id, init_params); |
154 if (route_id == MSG_ROUTING_NONE) | 153 if (route_id == MSG_ROUTING_NONE) |
155 return NULL; | 154 return NULL; |
156 | 155 |
157 CommandBufferProxyImpl* command_buffer = | 156 CommandBufferProxyImpl* command_buffer = |
158 new CommandBufferProxyImpl(this, route_id); | 157 new CommandBufferProxyImpl(this, route_id); |
159 AddRoute(route_id, command_buffer->AsWeakPtr()); | 158 AddRoute(route_id, command_buffer->AsWeakPtr()); |
160 proxies_[route_id] = command_buffer; | 159 proxies_[route_id] = command_buffer; |
161 return command_buffer; | 160 return command_buffer; |
162 #else | |
163 return NULL; | |
164 #endif | |
165 } | 161 } |
166 | 162 |
167 CommandBufferProxyImpl* GpuChannelHost::CreateOffscreenCommandBuffer( | 163 CommandBufferProxyImpl* GpuChannelHost::CreateOffscreenCommandBuffer( |
168 const gfx::Size& size, | 164 const gfx::Size& size, |
169 CommandBufferProxyImpl* share_group, | 165 CommandBufferProxyImpl* share_group, |
170 const std::string& allowed_extensions, | 166 const std::string& allowed_extensions, |
171 const std::vector<int32>& attribs, | 167 const std::vector<int32>& attribs, |
172 const GURL& active_url, | 168 const GURL& active_url, |
173 gfx::GpuPreference gpu_preference) { | 169 gfx::GpuPreference gpu_preference) { |
174 TRACE_EVENT0("gpu", "GpuChannelHost::CreateOffscreenCommandBuffer"); | 170 TRACE_EVENT0("gpu", "GpuChannelHost::CreateOffscreenCommandBuffer"); |
175 | 171 |
176 #if defined(ENABLE_GPU) | |
177 AutoLock lock(context_lock_); | 172 AutoLock lock(context_lock_); |
178 // An error occurred. Need to get the host again to reinitialize it. | 173 // An error occurred. Need to get the host again to reinitialize it. |
179 if (!channel_.get()) | 174 if (!channel_.get()) |
180 return NULL; | 175 return NULL; |
181 | 176 |
182 GPUCreateCommandBufferConfig init_params; | 177 GPUCreateCommandBufferConfig init_params; |
183 init_params.share_group_id = | 178 init_params.share_group_id = |
184 share_group ? share_group->GetRouteID() : MSG_ROUTING_NONE; | 179 share_group ? share_group->GetRouteID() : MSG_ROUTING_NONE; |
185 init_params.allowed_extensions = allowed_extensions; | 180 init_params.allowed_extensions = allowed_extensions; |
186 init_params.attribs = attribs; | 181 init_params.attribs = attribs; |
187 init_params.active_url = active_url; | 182 init_params.active_url = active_url; |
188 init_params.gpu_preference = gpu_preference; | 183 init_params.gpu_preference = gpu_preference; |
189 int32 route_id; | 184 int32 route_id; |
190 if (!Send(new GpuChannelMsg_CreateOffscreenCommandBuffer(size, | 185 if (!Send(new GpuChannelMsg_CreateOffscreenCommandBuffer(size, |
191 init_params, | 186 init_params, |
192 &route_id))) { | 187 &route_id))) { |
193 return NULL; | 188 return NULL; |
194 } | 189 } |
195 | 190 |
196 if (route_id == MSG_ROUTING_NONE) | 191 if (route_id == MSG_ROUTING_NONE) |
197 return NULL; | 192 return NULL; |
198 | 193 |
199 CommandBufferProxyImpl* command_buffer = | 194 CommandBufferProxyImpl* command_buffer = |
200 new CommandBufferProxyImpl(this, route_id); | 195 new CommandBufferProxyImpl(this, route_id); |
201 AddRoute(route_id, command_buffer->AsWeakPtr()); | 196 AddRoute(route_id, command_buffer->AsWeakPtr()); |
202 proxies_[route_id] = command_buffer; | 197 proxies_[route_id] = command_buffer; |
203 return command_buffer; | 198 return command_buffer; |
204 #else | |
205 return NULL; | |
206 #endif | |
207 } | 199 } |
208 | 200 |
209 GpuVideoDecodeAcceleratorHost* GpuChannelHost::CreateVideoDecoder( | 201 GpuVideoDecodeAcceleratorHost* GpuChannelHost::CreateVideoDecoder( |
210 int command_buffer_route_id, | 202 int command_buffer_route_id, |
211 media::VideoCodecProfile profile, | 203 media::VideoCodecProfile profile, |
212 media::VideoDecodeAccelerator::Client* client) { | 204 media::VideoDecodeAccelerator::Client* client) { |
213 AutoLock lock(context_lock_); | 205 AutoLock lock(context_lock_); |
214 ProxyMap::iterator it = proxies_.find(command_buffer_route_id); | 206 ProxyMap::iterator it = proxies_.find(command_buffer_route_id); |
215 DCHECK(it != proxies_.end()); | 207 DCHECK(it != proxies_.end()); |
216 CommandBufferProxyImpl* proxy = it->second; | 208 CommandBufferProxyImpl* proxy = it->second; |
217 return proxy->CreateVideoDecoder(profile, client); | 209 return proxy->CreateVideoDecoder(profile, client); |
218 } | 210 } |
219 | 211 |
220 void GpuChannelHost::DestroyCommandBuffer( | 212 void GpuChannelHost::DestroyCommandBuffer( |
221 CommandBufferProxyImpl* command_buffer) { | 213 CommandBufferProxyImpl* command_buffer) { |
222 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); | 214 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); |
223 | 215 |
224 #if defined(ENABLE_GPU) | |
225 AutoLock lock(context_lock_); | 216 AutoLock lock(context_lock_); |
226 int route_id = command_buffer->GetRouteID(); | 217 int route_id = command_buffer->GetRouteID(); |
227 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); | 218 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); |
228 // Check the proxy has not already been removed after a channel error. | 219 // Check the proxy has not already been removed after a channel error. |
229 if (proxies_.find(route_id) != proxies_.end()) | 220 if (proxies_.find(route_id) != proxies_.end()) |
230 proxies_.erase(route_id); | 221 proxies_.erase(route_id); |
231 RemoveRoute(route_id); | 222 RemoveRoute(route_id); |
232 delete command_buffer; | 223 delete command_buffer; |
233 #endif | |
234 } | 224 } |
235 | 225 |
236 bool GpuChannelHost::CollectRenderingStatsForSurface( | 226 bool GpuChannelHost::CollectRenderingStatsForSurface( |
237 int surface_id, GpuRenderingStats* stats) { | 227 int surface_id, GpuRenderingStats* stats) { |
238 TRACE_EVENT0("gpu", "GpuChannelHost::CollectRenderingStats"); | 228 TRACE_EVENT0("gpu", "GpuChannelHost::CollectRenderingStats"); |
239 | 229 |
240 return Send(new GpuChannelMsg_CollectRenderingStatsForSurface(surface_id, | 230 return Send(new GpuChannelMsg_CollectRenderingStatsForSurface(surface_id, |
241 stats)); | 231 stats)); |
242 } | 232 } |
243 | 233 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 const GpuListenerInfo& info = it->second; | 390 const GpuListenerInfo& info = it->second; |
401 info.loop->PostTask( | 391 info.loop->PostTask( |
402 FROM_HERE, | 392 FROM_HERE, |
403 base::Bind(&IPC::Listener::OnChannelError, info.listener)); | 393 base::Bind(&IPC::Listener::OnChannelError, info.listener)); |
404 } | 394 } |
405 | 395 |
406 listeners_.clear(); | 396 listeners_.clear(); |
407 } | 397 } |
408 | 398 |
409 } // namespace content | 399 } // namespace content |
OLD | NEW |