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/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 base::Unretained(&request))); | 406 base::Unretained(&request))); |
407 | 407 |
408 // We're blocking the UI thread, which is generally undesirable. | 408 // We're blocking the UI thread, which is generally undesirable. |
409 TRACE_EVENT0("browser", | 409 TRACE_EVENT0("browser", |
410 "BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer"); | 410 "BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer"); |
411 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 411 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
412 request.event.Wait(); | 412 request.event.Wait(); |
413 return request.result.Pass(); | 413 return request.result.Pass(); |
414 } | 414 } |
415 | 415 |
416 void BrowserGpuChannelHostFactory::DeleteGpuMemoryBuffer( | |
417 scoped_ptr<gfx::GpuMemoryBuffer> buffer) { | |
418 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
419 | |
420 GetIOLoopProxy()->PostTask( | |
421 FROM_HERE, | |
422 base::Bind(&BrowserGpuChannelHostFactory::DeleteGpuMemoryBufferOnIO, | |
423 base::Passed(&buffer))); | |
424 } | |
425 | |
426 // static | 416 // static |
427 void BrowserGpuChannelHostFactory::AddFilterOnIO( | 417 void BrowserGpuChannelHostFactory::AddFilterOnIO( |
428 int host_id, | 418 int host_id, |
429 scoped_refptr<IPC::MessageFilter> filter) { | 419 scoped_refptr<IPC::MessageFilter> filter) { |
430 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 420 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
431 | 421 |
432 GpuProcessHost* host = GpuProcessHost::FromID(host_id); | 422 GpuProcessHost* host = GpuProcessHost::FromID(host_id); |
433 if (host) | 423 if (host) |
434 host->AddFilter(filter.get()); | 424 host->AddFilter(filter.get()); |
435 } | 425 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 GpuMemoryBufferImpl::Create( | 460 GpuMemoryBufferImpl::Create( |
471 gfx::Size(request->width, request->height), | 461 gfx::Size(request->width, request->height), |
472 request->internalformat, | 462 request->internalformat, |
473 request->usage, | 463 request->usage, |
474 request->client_id, | 464 request->client_id, |
475 base::Bind(&BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated, | 465 base::Bind(&BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated, |
476 base::Unretained(request))); | 466 base::Unretained(request))); |
477 } | 467 } |
478 | 468 |
479 // static | 469 // static |
480 void BrowserGpuChannelHostFactory::DeleteGpuMemoryBufferOnIO( | |
481 scoped_ptr<gfx::GpuMemoryBuffer> buffer) { | |
482 } | |
483 | |
484 // static | |
485 void BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated( | 470 void BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated( |
486 AllocateGpuMemoryBufferRequest* request, | 471 AllocateGpuMemoryBufferRequest* request, |
487 scoped_ptr<GpuMemoryBufferImpl> buffer) { | 472 scoped_ptr<GpuMemoryBufferImpl> buffer) { |
488 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 473 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
489 | 474 |
490 request->result = buffer.PassAs<gfx::GpuMemoryBuffer>(); | 475 request->result = buffer.PassAs<gfx::GpuMemoryBuffer>(); |
491 request->event.Signal(); | 476 request->event.Signal(); |
492 } | 477 } |
493 | 478 |
494 } // namespace content | 479 } // namespace content |
OLD | NEW |