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/gpu_process_host.h" | 5 #include "content/browser/gpu/gpu_process_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
729 gfx::GpuMemoryBufferId id, | 729 gfx::GpuMemoryBufferId id, |
730 const gfx::Size& size, | 730 const gfx::Size& size, |
731 gfx::BufferFormat format, | 731 gfx::BufferFormat format, |
732 gfx::BufferUsage usage, | 732 gfx::BufferUsage usage, |
733 int client_id, | 733 int client_id, |
734 gpu::SurfaceHandle surface_handle, | 734 gpu::SurfaceHandle surface_handle, |
735 const CreateGpuMemoryBufferCallback& callback) { | 735 const CreateGpuMemoryBufferCallback& callback) { |
736 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); | 736 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); |
737 | 737 |
738 DCHECK(CalledOnValidThread()); | 738 DCHECK(CalledOnValidThread()); |
739 create_gpu_memory_buffer_requests_.push(callback); | 739 DCHECK(create_gpu_memory_buffer_requests_.find(id) == |
Daniele Castagna
2017/05/12 19:19:15
DS, do you know if this is the DCHECK that was goi
dshwang
2017/05/12 21:35:57
I'm surprising the DCHECK fails. I tested just CHE
| |
740 create_gpu_memory_buffer_requests_.end()); | |
741 create_gpu_memory_buffer_requests_[id] = callback; | |
740 gpu_service_ptr_->CreateGpuMemoryBuffer( | 742 gpu_service_ptr_->CreateGpuMemoryBuffer( |
741 id, size, format, usage, client_id, surface_handle, | 743 id, size, format, usage, client_id, surface_handle, |
742 base::Bind(&GpuProcessHost::OnGpuMemoryBufferCreated, | 744 base::Bind(&GpuProcessHost::OnGpuMemoryBufferCreated, |
743 weak_ptr_factory_.GetWeakPtr())); | 745 weak_ptr_factory_.GetWeakPtr())); |
744 } | 746 } |
745 | 747 |
746 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 748 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
747 int client_id, | 749 int client_id, |
748 const gpu::SyncToken& sync_token) { | 750 const gpu::SyncToken& sync_token) { |
749 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); | 751 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
785 } | 787 } |
786 | 788 |
787 callback.Run(IPC::ChannelHandle(channel_handle.release()), gpu_info_, | 789 callback.Run(IPC::ChannelHandle(channel_handle.release()), gpu_info_, |
788 EstablishChannelStatus::SUCCESS); | 790 EstablishChannelStatus::SUCCESS); |
789 } | 791 } |
790 | 792 |
791 void GpuProcessHost::OnGpuMemoryBufferCreated( | 793 void GpuProcessHost::OnGpuMemoryBufferCreated( |
792 const gfx::GpuMemoryBufferHandle& handle) { | 794 const gfx::GpuMemoryBufferHandle& handle) { |
793 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); | 795 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); |
794 | 796 |
795 DCHECK(!create_gpu_memory_buffer_requests_.empty()); | 797 if (create_gpu_memory_buffer_requests_.find(handle.id) == |
796 auto callback = create_gpu_memory_buffer_requests_.front(); | 798 create_gpu_memory_buffer_requests_.end()) { |
797 create_gpu_memory_buffer_requests_.pop(); | 799 DVLOG(1) << "GpuMemoryBuffer creation fails due to missing callback."; |
800 return; | |
801 } | |
802 | |
803 auto callback = create_gpu_memory_buffer_requests_[handle.id]; | |
804 create_gpu_memory_buffer_requests_.erase(handle.id); | |
798 callback.Run(handle, BufferCreationStatus::SUCCESS); | 805 callback.Run(handle, BufferCreationStatus::SUCCESS); |
799 } | 806 } |
800 | 807 |
801 #if defined(OS_ANDROID) | 808 #if defined(OS_ANDROID) |
802 void GpuProcessHost::OnDestroyingVideoSurfaceAck() { | 809 void GpuProcessHost::OnDestroyingVideoSurfaceAck() { |
803 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceAck"); | 810 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceAck"); |
804 if (!send_destroying_video_surface_done_cb_.is_null()) | 811 if (!send_destroying_video_surface_done_cb_.is_null()) |
805 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); | 812 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); |
806 } | 813 } |
807 #endif | 814 #endif |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1070 valid_ = false; | 1077 valid_ = false; |
1071 | 1078 |
1072 // First send empty channel handles for all EstablishChannel requests. | 1079 // First send empty channel handles for all EstablishChannel requests. |
1073 while (!channel_requests_.empty()) { | 1080 while (!channel_requests_.empty()) { |
1074 auto callback = channel_requests_.front(); | 1081 auto callback = channel_requests_.front(); |
1075 channel_requests_.pop(); | 1082 channel_requests_.pop(); |
1076 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo(), | 1083 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo(), |
1077 EstablishChannelStatus::GPU_HOST_INVALID); | 1084 EstablishChannelStatus::GPU_HOST_INVALID); |
1078 } | 1085 } |
1079 | 1086 |
1080 while (!create_gpu_memory_buffer_requests_.empty()) { | 1087 for (auto& pair : create_gpu_memory_buffer_requests_) { |
1081 auto callback = create_gpu_memory_buffer_requests_.front(); | 1088 auto callback = pair.second; |
1082 create_gpu_memory_buffer_requests_.pop(); | |
1083 callback.Run(gfx::GpuMemoryBufferHandle(), | 1089 callback.Run(gfx::GpuMemoryBufferHandle(), |
1084 BufferCreationStatus::GPU_HOST_INVALID); | 1090 BufferCreationStatus::GPU_HOST_INVALID); |
1085 } | 1091 } |
1092 create_gpu_memory_buffer_requests_.clear(); | |
1086 | 1093 |
1087 if (!send_destroying_video_surface_done_cb_.is_null()) | 1094 if (!send_destroying_video_surface_done_cb_.is_null()) |
1088 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); | 1095 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); |
1089 } | 1096 } |
1090 | 1097 |
1091 void GpuProcessHost::BlockLiveOffscreenContexts() { | 1098 void GpuProcessHost::BlockLiveOffscreenContexts() { |
1092 for (std::multiset<GURL>::iterator iter = | 1099 for (std::multiset<GURL>::iterator iter = |
1093 urls_with_live_offscreen_contexts_.begin(); | 1100 urls_with_live_offscreen_contexts_.begin(); |
1094 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { | 1101 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { |
1095 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( | 1102 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1207 if (!cache.get()) | 1214 if (!cache.get()) |
1208 return; | 1215 return; |
1209 | 1216 |
1210 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, | 1217 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, |
1211 weak_ptr_factory_.GetWeakPtr())); | 1218 weak_ptr_factory_.GetWeakPtr())); |
1212 | 1219 |
1213 client_id_to_shader_cache_[client_id] = cache; | 1220 client_id_to_shader_cache_[client_id] = cache; |
1214 } | 1221 } |
1215 | 1222 |
1216 } // namespace content | 1223 } // namespace content |
OLD | NEW |