| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "content/browser/gpu/shader_disk_cache.h" | 21 #include "content/browser/gpu/shader_disk_cache.h" |
| 22 #include "content/common/child_process_host_impl.h" | 22 #include "content/common/child_process_host_impl.h" |
| 23 #include "content/common/gpu/gpu_messages.h" | 23 #include "content/common/gpu/gpu_messages.h" |
| 24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/browser/content_browser_client.h" | 25 #include "content/public/browser/content_browser_client.h" |
| 26 #include "content/public/browser/gpu_data_manager.h" | 26 #include "content/public/browser/gpu_data_manager.h" |
| 27 #include "content/public/common/content_client.h" | 27 #include "content/public/common/content_client.h" |
| 28 #include "gpu/command_buffer/service/gpu_switches.h" | 28 #include "gpu/command_buffer/service/gpu_switches.h" |
| 29 #include "ipc/ipc_channel_handle.h" | 29 #include "ipc/ipc_channel_handle.h" |
| 30 #include "ipc/message_filter.h" | 30 #include "ipc/message_filter.h" |
| 31 #include "ui/base/window_resize_helper.h" |
| 31 | 32 |
| 32 namespace content { | 33 namespace content { |
| 33 | 34 |
| 34 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; | 35 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; |
| 35 | 36 |
| 36 struct BrowserGpuChannelHostFactory::CreateRequest { | 37 struct BrowserGpuChannelHostFactory::CreateRequest { |
| 37 CreateRequest(int32 route_id) | 38 CreateRequest(int32 route_id) |
| 38 : event(true, false), | 39 : event(true, false), |
| 39 gpu_host_id(0), | 40 gpu_host_id(0), |
| 40 route_id(route_id), | 41 route_id(route_id), |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 // In this case we need to wait for this before we can show any UI /anyway/, | 338 // In this case we need to wait for this before we can show any UI /anyway/, |
| 338 // so it won't cause additional jank. | 339 // so it won't cause additional jank. |
| 339 // TODO(piman): Make this asynchronous (http://crbug.com/125248). | 340 // TODO(piman): Make this asynchronous (http://crbug.com/125248). |
| 340 TRACE_EVENT0("browser", | 341 TRACE_EVENT0("browser", |
| 341 "BrowserGpuChannelHostFactory::CreateViewCommandBuffer"); | 342 "BrowserGpuChannelHostFactory::CreateViewCommandBuffer"); |
| 342 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 343 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 343 request.event.Wait(); | 344 request.event.Wait(); |
| 344 return request.result; | 345 return request.result; |
| 345 } | 346 } |
| 346 | 347 |
| 348 scoped_refptr<base::SingleThreadTaskRunner> |
| 349 BrowserGpuChannelHostFactory::TaskRunner() { |
| 350 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 351 // If we're adding a route to the main UI thread, we need to use the |
| 352 // WindowResizeHelper's task runner, otherwise Gpu Channel messages will be |
| 353 // blocked during a resize and we won't recieve the swap complete signal. |
| 354 return ui::WindowResizeHelper::Get()->task_runner(); |
| 355 #else |
| 356 return base::ThreadTaskRunnerHandle::Get(); |
| 357 #endif |
| 358 } |
| 359 |
| 347 // Blocking the UI thread to open a GPU channel is not supported on Android. | 360 // Blocking the UI thread to open a GPU channel is not supported on Android. |
| 348 // (Opening the initial channel to a child process involves handling a reply | 361 // (Opening the initial channel to a child process involves handling a reply |
| 349 // task on the UI thread first, so we cannot block here.) | 362 // task on the UI thread first, so we cannot block here.) |
| 350 #if !defined(OS_ANDROID) | 363 #if !defined(OS_ANDROID) |
| 351 GpuChannelHost* BrowserGpuChannelHostFactory::EstablishGpuChannelSync( | 364 GpuChannelHost* BrowserGpuChannelHostFactory::EstablishGpuChannelSync( |
| 352 CauseForGpuLaunch cause_for_gpu_launch) { | 365 CauseForGpuLaunch cause_for_gpu_launch) { |
| 353 EstablishGpuChannel(cause_for_gpu_launch, base::Closure()); | 366 EstablishGpuChannel(cause_for_gpu_launch, base::Closure()); |
| 354 | 367 |
| 355 if (pending_request_.get()) | 368 if (pending_request_.get()) |
| 356 pending_request_->Wait(); | 369 pending_request_->Wait(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 } | 449 } |
| 437 | 450 |
| 438 // static | 451 // static |
| 439 void BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO( | 452 void BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO( |
| 440 int gpu_client_id, | 453 int gpu_client_id, |
| 441 const base::FilePath& cache_dir) { | 454 const base::FilePath& cache_dir) { |
| 442 ShaderCacheFactory::GetInstance()->SetCacheInfo(gpu_client_id, cache_dir); | 455 ShaderCacheFactory::GetInstance()->SetCacheInfo(gpu_client_id, cache_dir); |
| 443 } | 456 } |
| 444 | 457 |
| 445 } // namespace content | 458 } // namespace content |
| OLD | NEW |