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/browser/gpu/browser_gpu_channel_host_factory.h" | 5 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/profiler/scoped_tracker.h" | 10 #include "base/profiler/scoped_tracker.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
15 #include "base/trace_event/memory_dump_manager.h" | 15 #include "base/trace_event/memory_dump_manager.h" |
16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 18 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
19 #include "content/browser/gpu/gpu_data_manager_impl.h" | 19 #include "content/browser/gpu/gpu_data_manager_impl.h" |
20 #include "content/browser/gpu/gpu_process_host.h" | 20 #include "content/browser/gpu/gpu_process_host.h" |
21 #include "content/browser/gpu/gpu_surface_tracker.h" | 21 #include "content/browser/gpu/gpu_surface_tracker.h" |
22 #include "content/browser/gpu/shader_disk_cache.h" | 22 #include "content/browser/gpu/shader_disk_cache.h" |
23 #include "content/common/child_process_host_impl.h" | 23 #include "content/common/child_process_host_impl.h" |
| 24 #include "content/common/gpu/client/ipc/chrome/chrome_gpu_channel_host_ipc_trans
port.h" |
| 25 #include "content/common/gpu/gpu_create_command_buffer_config.h" |
24 #include "content/common/gpu/gpu_messages.h" | 26 #include "content/common/gpu/gpu_messages.h" |
25 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/browser/content_browser_client.h" | 28 #include "content/public/browser/content_browser_client.h" |
27 #include "content/public/browser/gpu_data_manager.h" | 29 #include "content/public/browser/gpu_data_manager.h" |
28 #include "content/public/common/content_client.h" | 30 #include "content/public/common/content_client.h" |
29 #include "gpu/command_buffer/service/gpu_switches.h" | 31 #include "gpu/command_buffer/service/gpu_switches.h" |
30 #include "ipc/ipc_channel_handle.h" | 32 #include "ipc/ipc_channel_handle.h" |
31 #include "ipc/message_filter.h" | 33 #include "ipc/message_filter.h" |
32 | 34 |
33 namespace content { | 35 namespace content { |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 BrowserGpuChannelHostFactory::AllocateSharedMemory(size_t size) { | 288 BrowserGpuChannelHostFactory::AllocateSharedMemory(size_t size) { |
287 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); | 289 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); |
288 if (!shm->CreateAnonymous(size)) | 290 if (!shm->CreateAnonymous(size)) |
289 return scoped_ptr<base::SharedMemory>(); | 291 return scoped_ptr<base::SharedMemory>(); |
290 return shm; | 292 return shm; |
291 } | 293 } |
292 | 294 |
293 void BrowserGpuChannelHostFactory::CreateViewCommandBufferOnIO( | 295 void BrowserGpuChannelHostFactory::CreateViewCommandBufferOnIO( |
294 CreateRequest* request, | 296 CreateRequest* request, |
295 int32_t surface_id, | 297 int32_t surface_id, |
296 const GPUCreateCommandBufferConfig& init_params) { | 298 const GpuCreateCommandBufferConfig& init_params) { |
297 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); | 299 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); |
298 if (!host) { | 300 if (!host) { |
299 request->event.Signal(); | 301 request->event.Signal(); |
300 return; | 302 return; |
301 } | 303 } |
302 | 304 |
303 gfx::GLSurfaceHandle surface = | 305 gfx::GLSurfaceHandle surface = |
304 GpuSurfaceTracker::Get()->GetSurfaceHandle(surface_id); | 306 GpuSurfaceTracker::Get()->GetSurfaceHandle(surface_id); |
305 | 307 |
306 host->CreateViewCommandBuffer( | 308 host->CreateViewCommandBuffer( |
307 surface, | 309 surface, |
308 gpu_client_id_, | 310 gpu_client_id_, |
309 init_params, | 311 init_params, |
310 request->route_id, | 312 request->route_id, |
311 base::Bind(&BrowserGpuChannelHostFactory::CommandBufferCreatedOnIO, | 313 base::Bind(&BrowserGpuChannelHostFactory::CommandBufferCreatedOnIO, |
312 request)); | 314 request)); |
313 } | 315 } |
314 | 316 |
315 // static | 317 // static |
316 void BrowserGpuChannelHostFactory::CommandBufferCreatedOnIO( | 318 void BrowserGpuChannelHostFactory::CommandBufferCreatedOnIO( |
317 CreateRequest* request, CreateCommandBufferResult result) { | 319 CreateRequest* request, CreateCommandBufferResult result) { |
318 request->result = result; | 320 request->result = result; |
319 request->event.Signal(); | 321 request->event.Signal(); |
320 } | 322 } |
321 | 323 |
322 CreateCommandBufferResult BrowserGpuChannelHostFactory::CreateViewCommandBuffer( | 324 CreateCommandBufferResult BrowserGpuChannelHostFactory::CreateViewCommandBuffer( |
323 int32_t surface_id, | 325 int32_t surface_id, |
324 const GPUCreateCommandBufferConfig& init_params, | 326 const GpuCreateCommandBufferConfig& init_params, |
325 int32_t route_id) { | 327 int32_t route_id) { |
326 CreateRequest request(route_id); | 328 CreateRequest request(route_id); |
327 GetIOThreadTaskRunner()->PostTask( | 329 GetIOThreadTaskRunner()->PostTask( |
328 FROM_HERE, | 330 FROM_HERE, |
329 base::Bind(&BrowserGpuChannelHostFactory::CreateViewCommandBufferOnIO, | 331 base::Bind(&BrowserGpuChannelHostFactory::CreateViewCommandBufferOnIO, |
330 base::Unretained(this), &request, surface_id, init_params)); | 332 base::Unretained(this), &request, surface_id, init_params)); |
331 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed. | 333 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed. |
332 tracked_objects::ScopedTracker tracking_profile( | 334 tracked_objects::ScopedTracker tracking_profile( |
333 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 335 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
334 "125248 BrowserGpuChannelHostFactory::CreateViewCommandBuffer")); | 336 "125248 BrowserGpuChannelHostFactory::CreateViewCommandBuffer")); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 DCHECK(pending_request_.get()); | 399 DCHECK(pending_request_.get()); |
398 if (pending_request_->channel_handle().name.empty()) { | 400 if (pending_request_->channel_handle().name.empty()) { |
399 DCHECK(!gpu_channel_.get()); | 401 DCHECK(!gpu_channel_.get()); |
400 } else { | 402 } else { |
401 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/466866 | 403 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/466866 |
402 // is fixed. | 404 // is fixed. |
403 tracked_objects::ScopedTracker tracking_profile1( | 405 tracked_objects::ScopedTracker tracking_profile1( |
404 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 406 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
405 "466866 BrowserGpuChannelHostFactory::GpuChannelEstablished1")); | 407 "466866 BrowserGpuChannelHostFactory::GpuChannelEstablished1")); |
406 GetContentClient()->SetGpuInfo(pending_request_->gpu_info()); | 408 GetContentClient()->SetGpuInfo(pending_request_->gpu_info()); |
407 gpu_channel_ = GpuChannelHost::Create( | 409 scoped_ptr<GpuChannelHostIPCTransport> transport( |
408 this, gpu_client_id_, pending_request_->gpu_info(), | 410 GpuHostIPCTransportFactory::Get()->CreateGpuChannelHostIPCTransport()); |
409 pending_request_->channel_handle(), shutdown_event_.get(), | 411 static_cast<ChromeGpuChannelHostIPCTransport*>(transport.get()) |
410 gpu_memory_buffer_manager_.get()); | 412 ->BindToService(this, gpu_client_id_, |
| 413 pending_request_->channel_handle(), |
| 414 shutdown_event_.get()); |
| 415 gpu_channel_ = GpuChannelHost::Create(std::move(transport), |
| 416 pending_request_->gpu_info(), |
| 417 gpu_memory_buffer_manager_.get()); |
411 } | 418 } |
412 gpu_host_id_ = pending_request_->gpu_host_id(); | 419 gpu_host_id_ = pending_request_->gpu_host_id(); |
413 pending_request_ = NULL; | 420 pending_request_ = NULL; |
414 | 421 |
415 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/466866 is | 422 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/466866 is |
416 // fixed. | 423 // fixed. |
417 tracked_objects::ScopedTracker tracking_profile2( | 424 tracked_objects::ScopedTracker tracking_profile2( |
418 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 425 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
419 "466866 BrowserGpuChannelHostFactory::GpuChannelEstablished2")); | 426 "466866 BrowserGpuChannelHostFactory::GpuChannelEstablished2")); |
420 | 427 |
(...skipping 15 matching lines...) Expand all Loading... |
436 } | 443 } |
437 | 444 |
438 // static | 445 // static |
439 void BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO( | 446 void BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO( |
440 int gpu_client_id, | 447 int gpu_client_id, |
441 const base::FilePath& cache_dir) { | 448 const base::FilePath& cache_dir) { |
442 ShaderCacheFactory::GetInstance()->SetCacheInfo(gpu_client_id, cache_dir); | 449 ShaderCacheFactory::GetInstance()->SetCacheInfo(gpu_client_id, cache_dir); |
443 } | 450 } |
444 | 451 |
445 } // namespace content | 452 } // namespace content |
OLD | NEW |