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/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "content/browser/gpu/gpu_data_manager_impl.h" | 10 #include "content/browser/gpu/gpu_data_manager_impl.h" |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 386 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
387 | 387 |
388 scoped_ptr<GpuMemoryBufferImplShm> buffer( | 388 scoped_ptr<GpuMemoryBufferImplShm> buffer( |
389 new GpuMemoryBufferImplShm(gfx::Size(width, height), internalformat)); | 389 new GpuMemoryBufferImplShm(gfx::Size(width, height), internalformat)); |
390 if (!buffer->InitializeFromSharedMemory(shm.Pass())) | 390 if (!buffer->InitializeFromSharedMemory(shm.Pass())) |
391 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 391 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
392 | 392 |
393 return buffer.PassAs<gfx::GpuMemoryBuffer>(); | 393 return buffer.PassAs<gfx::GpuMemoryBuffer>(); |
394 } | 394 } |
395 | 395 |
| 396 void BrowserGpuChannelHostFactory::CreateSurfaceTextureOnIO( |
| 397 int32 surface_texture_id, |
| 398 base::ProcessHandle process_handle, |
| 399 const CreateSurfaceTextureCallback& callback) { |
| 400 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); |
| 401 if (!host) { |
| 402 SurfaceTextureCreatedOnIO(callback); |
| 403 return; |
| 404 } |
| 405 |
| 406 host->CreateSurfaceTexture( |
| 407 surface_texture_id, |
| 408 process_handle, |
| 409 base::Bind(&BrowserGpuChannelHostFactory::SurfaceTextureCreatedOnIO, |
| 410 callback)); |
| 411 } |
| 412 |
| 413 // static |
| 414 void BrowserGpuChannelHostFactory::SurfaceTextureCreatedOnIO( |
| 415 const CreateSurfaceTextureCallback& callback) { |
| 416 BrowserThread::PostTask( |
| 417 BrowserThread::UI, |
| 418 FROM_HERE, |
| 419 base::Bind(&BrowserGpuChannelHostFactory::OnSurfaceTextureCreated, |
| 420 callback)); |
| 421 } |
| 422 |
| 423 // static |
| 424 void BrowserGpuChannelHostFactory::OnSurfaceTextureCreated( |
| 425 const CreateSurfaceTextureCallback& callback) { |
| 426 callback.Run(); |
| 427 } |
| 428 |
| 429 void BrowserGpuChannelHostFactory::CreateSurfaceTexture( |
| 430 int32 surface_texture_id, |
| 431 base::ProcessHandle process_handle, |
| 432 const CreateSurfaceTextureCallback& callback) { |
| 433 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 434 GetIOLoopProxy()->PostTask(FROM_HERE, base::Bind( |
| 435 &BrowserGpuChannelHostFactory::CreateSurfaceTextureOnIO, |
| 436 base::Unretained(this), |
| 437 surface_texture_id, |
| 438 process_handle, |
| 439 callback)); |
| 440 } |
| 441 |
396 // static | 442 // static |
397 void BrowserGpuChannelHostFactory::AddFilterOnIO( | 443 void BrowserGpuChannelHostFactory::AddFilterOnIO( |
398 int host_id, | 444 int host_id, |
399 scoped_refptr<IPC::ChannelProxy::MessageFilter> filter) { | 445 scoped_refptr<IPC::ChannelProxy::MessageFilter> filter) { |
400 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 446 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
401 | 447 |
402 GpuProcessHost* host = GpuProcessHost::FromID(host_id); | 448 GpuProcessHost* host = GpuProcessHost::FromID(host_id); |
403 if (host) | 449 if (host) |
404 host->AddFilter(filter.get()); | 450 host->AddFilter(filter.get()); |
405 } | 451 } |
(...skipping 15 matching lines...) Expand all Loading... |
421 filter->AddRoute(MSG_ROUTING_CONTROL, handler); | 467 filter->AddRoute(MSG_ROUTING_CONTROL, handler); |
422 | 468 |
423 GetIOLoopProxy()->PostTask( | 469 GetIOLoopProxy()->PostTask( |
424 FROM_HERE, | 470 FROM_HERE, |
425 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, | 471 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, |
426 gpu_host_id_, | 472 gpu_host_id_, |
427 filter)); | 473 filter)); |
428 } | 474 } |
429 | 475 |
430 } // namespace content | 476 } // namespace content |
OLD | NEW |