| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/profiler/scoped_tracker.h" | 10 #include "base/profiler/scoped_tracker.h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 if (gpu_channel_) { | 298 if (gpu_channel_) { |
| 299 gpu_channel_->DestroyChannel(); | 299 gpu_channel_->DestroyChannel(); |
| 300 gpu_channel_ = NULL; | 300 gpu_channel_ = NULL; |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 | 303 |
| 304 bool BrowserGpuChannelHostFactory::IsMainThread() { | 304 bool BrowserGpuChannelHostFactory::IsMainThread() { |
| 305 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 305 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
| 306 } | 306 } |
| 307 | 307 |
| 308 scoped_refptr<base::SingleThreadTaskRunner> | 308 scoped_refptr<base::MessageLoopProxy> |
| 309 BrowserGpuChannelHostFactory::GetIOThreadTaskRunner() { | 309 BrowserGpuChannelHostFactory::GetIOLoopProxy() { |
| 310 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 310 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 311 } | 311 } |
| 312 | 312 |
| 313 scoped_ptr<base::SharedMemory> | 313 scoped_ptr<base::SharedMemory> |
| 314 BrowserGpuChannelHostFactory::AllocateSharedMemory(size_t size) { | 314 BrowserGpuChannelHostFactory::AllocateSharedMemory(size_t size) { |
| 315 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); | 315 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); |
| 316 if (!shm->CreateAnonymous(size)) | 316 if (!shm->CreateAnonymous(size)) |
| 317 return scoped_ptr<base::SharedMemory>(); | 317 return scoped_ptr<base::SharedMemory>(); |
| 318 return shm.Pass(); | 318 return shm.Pass(); |
| 319 } | 319 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 346 CreateRequest* request, CreateCommandBufferResult result) { | 346 CreateRequest* request, CreateCommandBufferResult result) { |
| 347 request->result = result; | 347 request->result = result; |
| 348 request->event.Signal(); | 348 request->event.Signal(); |
| 349 } | 349 } |
| 350 | 350 |
| 351 CreateCommandBufferResult BrowserGpuChannelHostFactory::CreateViewCommandBuffer( | 351 CreateCommandBufferResult BrowserGpuChannelHostFactory::CreateViewCommandBuffer( |
| 352 int32 surface_id, | 352 int32 surface_id, |
| 353 const GPUCreateCommandBufferConfig& init_params, | 353 const GPUCreateCommandBufferConfig& init_params, |
| 354 int32 route_id) { | 354 int32 route_id) { |
| 355 CreateRequest request(route_id); | 355 CreateRequest request(route_id); |
| 356 GetIOThreadTaskRunner()->PostTask( | 356 GetIOLoopProxy()->PostTask(FROM_HERE, base::Bind( |
| 357 FROM_HERE, | 357 &BrowserGpuChannelHostFactory::CreateViewCommandBufferOnIO, |
| 358 base::Bind(&BrowserGpuChannelHostFactory::CreateViewCommandBufferOnIO, | 358 base::Unretained(this), |
| 359 base::Unretained(this), &request, surface_id, init_params)); | 359 &request, |
| 360 surface_id, |
| 361 init_params)); |
| 360 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed. | 362 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed. |
| 361 tracked_objects::ScopedTracker tracking_profile( | 363 tracked_objects::ScopedTracker tracking_profile( |
| 362 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 364 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 363 "125248 BrowserGpuChannelHostFactory::CreateViewCommandBuffer")); | 365 "125248 BrowserGpuChannelHostFactory::CreateViewCommandBuffer")); |
| 364 | 366 |
| 365 // We're blocking the UI thread, which is generally undesirable. | 367 // We're blocking the UI thread, which is generally undesirable. |
| 366 // In this case we need to wait for this before we can show any UI /anyway/, | 368 // In this case we need to wait for this before we can show any UI /anyway/, |
| 367 // so it won't cause additional jank. | 369 // so it won't cause additional jank. |
| 368 // TODO(piman): Make this asynchronous (http://crbug.com/125248). | 370 // TODO(piman): Make this asynchronous (http://crbug.com/125248). |
| 369 TRACE_EVENT0("browser", | 371 TRACE_EVENT0("browser", |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 560 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 559 | 561 |
| 560 CreateGpuMemoryBufferCallbackMap::iterator iter = | 562 CreateGpuMemoryBufferCallbackMap::iterator iter = |
| 561 create_gpu_memory_buffer_requests_.find(request_id); | 563 create_gpu_memory_buffer_requests_.find(request_id); |
| 562 DCHECK(iter != create_gpu_memory_buffer_requests_.end()); | 564 DCHECK(iter != create_gpu_memory_buffer_requests_.end()); |
| 563 iter->second.Run(handle); | 565 iter->second.Run(handle); |
| 564 create_gpu_memory_buffer_requests_.erase(iter); | 566 create_gpu_memory_buffer_requests_.erase(iter); |
| 565 } | 567 } |
| 566 | 568 |
| 567 } // namespace content | 569 } // namespace content |
| OLD | NEW |