| Index: services/ui/public/cpp/gpu/client_gpu_memory_buffer_manager.cc
|
| diff --git a/services/ui/public/cpp/gpu/client_gpu_memory_buffer_manager.cc b/services/ui/public/cpp/gpu/client_gpu_memory_buffer_manager.cc
|
| index e91fce823c9a275b56d5c4d4c2ac701edd965d31..efff978265a194c569cf66a21390ef61eb3c0bee 100644
|
| --- a/services/ui/public/cpp/gpu/client_gpu_memory_buffer_manager.cc
|
| +++ b/services/ui/public/cpp/gpu/client_gpu_memory_buffer_manager.cc
|
| @@ -22,13 +22,6 @@ namespace ui {
|
|
|
| namespace {
|
|
|
| -void OnGpuMemoryBufferAllocated(gfx::GpuMemoryBufferHandle* ret_handle,
|
| - base::WaitableEvent* wait,
|
| - const gfx::GpuMemoryBufferHandle& handle) {
|
| - *ret_handle = handle;
|
| - wait->Signal();
|
| -}
|
| -
|
| void NotifyDestructionOnCorrectThread(
|
| scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
| const DestructionCallback& callback,
|
| @@ -58,12 +51,24 @@ ClientGpuMemoryBufferManager::~ClientGpuMemoryBufferManager() {
|
|
|
| void ClientGpuMemoryBufferManager::InitThread(mojom::GpuPtrInfo gpu_info) {
|
| gpu_.Bind(std::move(gpu_info));
|
| + gpu_.set_connection_error_handler(
|
| + base::Bind(&ClientGpuMemoryBufferManager::DisconnectGpuOnThread,
|
| + base::Unretained(this)));
|
| weak_ptr_ = weak_ptr_factory_.GetWeakPtr();
|
| }
|
|
|
| void ClientGpuMemoryBufferManager::TearDownThread() {
|
| weak_ptr_factory_.InvalidateWeakPtrs();
|
| + DisconnectGpuOnThread();
|
| +}
|
| +
|
| +void ClientGpuMemoryBufferManager::DisconnectGpuOnThread() {
|
| + if (!gpu_.is_bound())
|
| + return;
|
| gpu_.reset();
|
| + for (auto& waiter : pending_allocation_waiters_)
|
| + waiter->Signal();
|
| + pending_allocation_waiters_.clear();
|
| }
|
|
|
| void ClientGpuMemoryBufferManager::AllocateGpuMemoryBufferOnThread(
|
| @@ -76,9 +81,24 @@ void ClientGpuMemoryBufferManager::AllocateGpuMemoryBufferOnThread(
|
| // |handle| and |wait| are both on the stack, and will be alive until |wait|
|
| // is signaled. So it is safe for OnGpuMemoryBufferAllocated() to operate on
|
| // these.
|
| + pending_allocation_waiters_.insert(wait);
|
| gpu_->CreateGpuMemoryBuffer(
|
| gfx::GpuMemoryBufferId(++counter_), size, format, usage,
|
| - base::Bind(&OnGpuMemoryBufferAllocated, handle, wait));
|
| + base::Bind(
|
| + &ClientGpuMemoryBufferManager::OnGpuMemoryBufferAllocatedOnThread,
|
| + base::Unretained(this), handle, wait));
|
| +}
|
| +
|
| +void ClientGpuMemoryBufferManager::OnGpuMemoryBufferAllocatedOnThread(
|
| + gfx::GpuMemoryBufferHandle* ret_handle,
|
| + base::WaitableEvent* wait,
|
| + const gfx::GpuMemoryBufferHandle& handle) {
|
| + auto it = pending_allocation_waiters_.find(wait);
|
| + DCHECK(it != pending_allocation_waiters_.end());
|
| + pending_allocation_waiters_.erase(it);
|
| +
|
| + *ret_handle = handle;
|
| + wait->Signal();
|
| }
|
|
|
| void ClientGpuMemoryBufferManager::DeletedGpuMemoryBuffer(
|
|
|