Commit e17baa4e authored by dongseong.hwang's avatar dongseong.hwang Committed by Commit bot

gpu: guarantee to match pending GBM buffer request to actual GBM handle

This CL makes |gpu_proecess_host| select the right callback by GMB id, not
brute-force FIFO. It becomes more stable code for the future change.
e.g. reordering IPC for priotization

BUG=475633, 629521

Review-Url: https://codereview.chromium.org/2878573002
Cr-Commit-Position: refs/heads/master@{#471116}
parent bfb116be
......@@ -737,7 +737,9 @@ void GpuProcessHost::CreateGpuMemoryBuffer(
TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer");
DCHECK(CalledOnValidThread());
create_gpu_memory_buffer_requests_.push(callback);
DCHECK(create_gpu_memory_buffer_requests_.find(id) ==
create_gpu_memory_buffer_requests_.end());
create_gpu_memory_buffer_requests_[id] = callback;
gpu_service_ptr_->CreateGpuMemoryBuffer(
id, size, format, usage, client_id, surface_handle,
base::Bind(&GpuProcessHost::OnGpuMemoryBufferCreated,
......@@ -793,9 +795,14 @@ void GpuProcessHost::OnGpuMemoryBufferCreated(
const gfx::GpuMemoryBufferHandle& handle) {
TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated");
DCHECK(!create_gpu_memory_buffer_requests_.empty());
auto callback = create_gpu_memory_buffer_requests_.front();
create_gpu_memory_buffer_requests_.pop();
if (create_gpu_memory_buffer_requests_.find(handle.id) ==
create_gpu_memory_buffer_requests_.end()) {
DVLOG(1) << "GpuMemoryBuffer creation fails due to missing callback.";
return;
}
auto callback = create_gpu_memory_buffer_requests_[handle.id];
create_gpu_memory_buffer_requests_.erase(handle.id);
callback.Run(handle, BufferCreationStatus::SUCCESS);
}
......@@ -1078,12 +1085,12 @@ void GpuProcessHost::SendOutstandingReplies() {
EstablishChannelStatus::GPU_HOST_INVALID);
}
while (!create_gpu_memory_buffer_requests_.empty()) {
auto callback = create_gpu_memory_buffer_requests_.front();
create_gpu_memory_buffer_requests_.pop();
for (auto& pair : create_gpu_memory_buffer_requests_) {
auto callback = pair.second;
callback.Run(gfx::GpuMemoryBufferHandle(),
BufferCreationStatus::GPU_HOST_INVALID);
}
create_gpu_memory_buffer_requests_.clear();
if (!send_destroying_video_surface_done_cb_.is_null())
base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run();
......
......@@ -231,7 +231,8 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
std::queue<EstablishChannelCallback> channel_requests_;
// The pending create gpu memory buffer requests we need to reply to.
std::queue<CreateGpuMemoryBufferCallback> create_gpu_memory_buffer_requests_;
base::flat_map<gfx::GpuMemoryBufferId, CreateGpuMemoryBufferCallback>
create_gpu_memory_buffer_requests_;
// A callback to signal the completion of a SendDestroyingVideoSurface call.
base::Closure send_destroying_video_surface_done_cb_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment