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