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 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
728 gfx::GpuMemoryBufferId id, | 728 gfx::GpuMemoryBufferId id, |
729 const gfx::Size& size, | 729 const gfx::Size& size, |
730 gfx::BufferFormat format, | 730 gfx::BufferFormat format, |
731 gfx::BufferUsage usage, | 731 gfx::BufferUsage usage, |
732 int client_id, | 732 int client_id, |
733 gpu::SurfaceHandle surface_handle, | 733 gpu::SurfaceHandle surface_handle, |
734 const CreateGpuMemoryBufferCallback& callback) { | 734 const CreateGpuMemoryBufferCallback& callback) { |
735 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); | 735 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); |
736 | 736 |
737 DCHECK(CalledOnValidThread()); | 737 DCHECK(CalledOnValidThread()); |
738 create_gpu_memory_buffer_requests_.push(callback); | 738 DCHECK(create_gpu_memory_buffer_requests_.find(id) == |
739 create_gpu_memory_buffer_requests_.end()); | |
740 create_gpu_memory_buffer_requests_[id] = callback; | |
739 gpu_service_ptr_->CreateGpuMemoryBuffer( | 741 gpu_service_ptr_->CreateGpuMemoryBuffer( |
740 id, size, format, usage, client_id, surface_handle, | 742 id, size, format, usage, client_id, surface_handle, |
741 base::Bind(&GpuProcessHost::OnGpuMemoryBufferCreated, | 743 base::Bind(&GpuProcessHost::OnGpuMemoryBufferCreated, |
742 weak_ptr_factory_.GetWeakPtr())); | 744 weak_ptr_factory_.GetWeakPtr())); |
743 } | 745 } |
744 | 746 |
745 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 747 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
746 int client_id, | 748 int client_id, |
747 const gpu::SyncToken& sync_token) { | 749 const gpu::SyncToken& sync_token) { |
748 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); | 750 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
785 | 787 |
786 callback.Run(IPC::ChannelHandle(channel_handle.release()), gpu_info_, | 788 callback.Run(IPC::ChannelHandle(channel_handle.release()), gpu_info_, |
787 EstablishChannelStatus::SUCCESS); | 789 EstablishChannelStatus::SUCCESS); |
788 } | 790 } |
789 | 791 |
790 void GpuProcessHost::OnGpuMemoryBufferCreated( | 792 void GpuProcessHost::OnGpuMemoryBufferCreated( |
791 const gfx::GpuMemoryBufferHandle& handle) { | 793 const gfx::GpuMemoryBufferHandle& handle) { |
792 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); | 794 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); |
793 | 795 |
794 DCHECK(!create_gpu_memory_buffer_requests_.empty()); | 796 DCHECK(!create_gpu_memory_buffer_requests_.empty()); |
795 auto callback = create_gpu_memory_buffer_requests_.front(); | 797 DCHECK(create_gpu_memory_buffer_requests_.find(handle.id) != |
796 create_gpu_memory_buffer_requests_.pop(); | 798 create_gpu_memory_buffer_requests_.end()); |
piman
2017/05/11 18:04:43
Actually, because we shouldn't trust the GPU proce
dshwang
2017/05/11 20:29:59
Done.
| |
799 auto callback = create_gpu_memory_buffer_requests_[handle.id]; | |
800 create_gpu_memory_buffer_requests_.erase(handle.id); | |
797 callback.Run(handle, BufferCreationStatus::SUCCESS); | 801 callback.Run(handle, BufferCreationStatus::SUCCESS); |
798 } | 802 } |
799 | 803 |
800 #if defined(OS_ANDROID) | 804 #if defined(OS_ANDROID) |
801 void GpuProcessHost::OnDestroyingVideoSurfaceAck() { | 805 void GpuProcessHost::OnDestroyingVideoSurfaceAck() { |
802 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceAck"); | 806 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceAck"); |
803 if (!send_destroying_video_surface_done_cb_.is_null()) | 807 if (!send_destroying_video_surface_done_cb_.is_null()) |
804 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); | 808 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); |
805 } | 809 } |
806 #endif | 810 #endif |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1069 valid_ = false; | 1073 valid_ = false; |
1070 | 1074 |
1071 // First send empty channel handles for all EstablishChannel requests. | 1075 // First send empty channel handles for all EstablishChannel requests. |
1072 while (!channel_requests_.empty()) { | 1076 while (!channel_requests_.empty()) { |
1073 auto callback = channel_requests_.front(); | 1077 auto callback = channel_requests_.front(); |
1074 channel_requests_.pop(); | 1078 channel_requests_.pop(); |
1075 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo(), | 1079 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo(), |
1076 EstablishChannelStatus::GPU_HOST_INVALID); | 1080 EstablishChannelStatus::GPU_HOST_INVALID); |
1077 } | 1081 } |
1078 | 1082 |
1079 while (!create_gpu_memory_buffer_requests_.empty()) { | 1083 for (auto& pair : create_gpu_memory_buffer_requests_) { |
1080 auto callback = create_gpu_memory_buffer_requests_.front(); | 1084 auto callback = pair.second; |
1081 create_gpu_memory_buffer_requests_.pop(); | |
1082 callback.Run(gfx::GpuMemoryBufferHandle(), | 1085 callback.Run(gfx::GpuMemoryBufferHandle(), |
1083 BufferCreationStatus::GPU_HOST_INVALID); | 1086 BufferCreationStatus::GPU_HOST_INVALID); |
1084 } | 1087 } |
1088 create_gpu_memory_buffer_requests_.clear(); | |
1085 | 1089 |
1086 if (!send_destroying_video_surface_done_cb_.is_null()) | 1090 if (!send_destroying_video_surface_done_cb_.is_null()) |
1087 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); | 1091 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); |
1088 } | 1092 } |
1089 | 1093 |
1090 void GpuProcessHost::BlockLiveOffscreenContexts() { | 1094 void GpuProcessHost::BlockLiveOffscreenContexts() { |
1091 for (std::multiset<GURL>::iterator iter = | 1095 for (std::multiset<GURL>::iterator iter = |
1092 urls_with_live_offscreen_contexts_.begin(); | 1096 urls_with_live_offscreen_contexts_.begin(); |
1093 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { | 1097 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { |
1094 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( | 1098 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1206 if (!cache.get()) | 1210 if (!cache.get()) |
1207 return; | 1211 return; |
1208 | 1212 |
1209 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, | 1213 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, |
1210 weak_ptr_factory_.GetWeakPtr())); | 1214 weak_ptr_factory_.GetWeakPtr())); |
1211 | 1215 |
1212 client_id_to_shader_cache_[client_id] = cache; | 1216 client_id_to_shader_cache_[client_id] = cache; |
1213 } | 1217 } |
1214 | 1218 |
1215 } // namespace content | 1219 } // namespace content |
OLD | NEW |