Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: content/browser/gpu/gpu_process_host.cc

Issue 2701233002: gpu: Use mojom.GpuService API for memory allocation. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 653
654 void GpuProcessHost::AddFilter(IPC::MessageFilter* filter) { 654 void GpuProcessHost::AddFilter(IPC::MessageFilter* filter) {
655 DCHECK(CalledOnValidThread()); 655 DCHECK(CalledOnValidThread());
656 process_->GetHost()->AddFilter(filter); 656 process_->GetHost()->AddFilter(filter);
657 } 657 }
658 658
659 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { 659 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) {
660 DCHECK(CalledOnValidThread()); 660 DCHECK(CalledOnValidThread());
661 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) 661 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message)
662 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) 662 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized)
663 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryBufferCreated,
664 OnGpuMemoryBufferCreated)
665 #if defined(OS_ANDROID) 663 #if defined(OS_ANDROID)
666 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyingVideoSurfaceAck, 664 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyingVideoSurfaceAck,
667 OnDestroyingVideoSurfaceAck) 665 OnDestroyingVideoSurfaceAck)
668 #endif 666 #endif
669 IPC_MESSAGE_HANDLER(GpuHostMsg_FieldTrialActivated, OnFieldTrialActivated); 667 IPC_MESSAGE_HANDLER(GpuHostMsg_FieldTrialActivated, OnFieldTrialActivated);
670 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) 668 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message))
671 IPC_END_MESSAGE_MAP() 669 IPC_END_MESSAGE_MAP()
672 670
673 return true; 671 return true;
674 } 672 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 gfx::GpuMemoryBufferId id, 717 gfx::GpuMemoryBufferId id,
720 const gfx::Size& size, 718 const gfx::Size& size,
721 gfx::BufferFormat format, 719 gfx::BufferFormat format,
722 gfx::BufferUsage usage, 720 gfx::BufferUsage usage,
723 int client_id, 721 int client_id,
724 gpu::SurfaceHandle surface_handle, 722 gpu::SurfaceHandle surface_handle,
725 const CreateGpuMemoryBufferCallback& callback) { 723 const CreateGpuMemoryBufferCallback& callback) {
726 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); 724 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer");
727 725
728 DCHECK(CalledOnValidThread()); 726 DCHECK(CalledOnValidThread());
729 727 create_gpu_memory_buffer_requests_.push(callback);
730 GpuMsg_CreateGpuMemoryBuffer_Params params; 728 gpu_service_ptr_->CreateGpuMemoryBuffer(
731 params.id = id; 729 id, size, format, usage, client_id, surface_handle,
732 params.size = size; 730 base::Bind(&GpuProcessHost::OnGpuMemoryBufferCreated,
733 params.format = format; 731 weak_ptr_factory_.GetWeakPtr()));
734 params.usage = usage;
735 params.client_id = client_id;
736 params.surface_handle = surface_handle;
737 if (Send(new GpuMsg_CreateGpuMemoryBuffer(params))) {
738 create_gpu_memory_buffer_requests_.push(callback);
739 } else {
740 callback.Run(gfx::GpuMemoryBufferHandle());
741 }
742 } 732 }
743 733
744 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, 734 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
745 int client_id, 735 int client_id,
746 const gpu::SyncToken& sync_token) { 736 const gpu::SyncToken& sync_token) {
747 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); 737 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer");
748 738 gpu_service_ptr_->DestroyGpuMemoryBuffer(id, client_id, sync_token);
749 DCHECK(CalledOnValidThread());
750
751 Send(new GpuMsg_DestroyGpuMemoryBuffer(id, client_id, sync_token));
752 } 739 }
753 740
754 #if defined(OS_ANDROID) 741 #if defined(OS_ANDROID)
755 void GpuProcessHost::SendDestroyingVideoSurface(int surface_id, 742 void GpuProcessHost::SendDestroyingVideoSurface(int surface_id,
756 const base::Closure& done_cb) { 743 const base::Closure& done_cb) {
757 TRACE_EVENT0("gpu", "GpuProcessHost::SendDestroyingVideoSurface"); 744 TRACE_EVENT0("gpu", "GpuProcessHost::SendDestroyingVideoSurface");
758 DCHECK(send_destroying_video_surface_done_cb_.is_null()); 745 DCHECK(send_destroying_video_surface_done_cb_.is_null());
759 DCHECK(!done_cb.is_null()); 746 DCHECK(!done_cb.is_null());
760 if (Send(new GpuMsg_DestroyingVideoSurface(surface_id))) { 747 if (Send(new GpuMsg_DestroyingVideoSurface(surface_id))) {
761 send_destroying_video_surface_done_cb_ = done_cb; 748 send_destroying_video_surface_done_cb_ = done_cb;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 return; 789 return;
803 } 790 }
804 791
805 callback.Run(IPC::ChannelHandle(channel_handle.release()), gpu_info_); 792 callback.Run(IPC::ChannelHandle(channel_handle.release()), gpu_info_);
806 } 793 }
807 794
808 void GpuProcessHost::OnGpuMemoryBufferCreated( 795 void GpuProcessHost::OnGpuMemoryBufferCreated(
809 const gfx::GpuMemoryBufferHandle& handle) { 796 const gfx::GpuMemoryBufferHandle& handle) {
810 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); 797 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated");
811 798
812 if (create_gpu_memory_buffer_requests_.empty()) 799 DCHECK(!create_gpu_memory_buffer_requests_.empty());
813 return; 800 auto callback = create_gpu_memory_buffer_requests_.front();
814
815 CreateGpuMemoryBufferCallback callback =
816 create_gpu_memory_buffer_requests_.front();
817 create_gpu_memory_buffer_requests_.pop(); 801 create_gpu_memory_buffer_requests_.pop();
818 callback.Run(handle); 802 callback.Run(handle);
819 } 803 }
820 804
821 #if defined(OS_ANDROID) 805 #if defined(OS_ANDROID)
822 void GpuProcessHost::OnDestroyingVideoSurfaceAck(int surface_id) { 806 void GpuProcessHost::OnDestroyingVideoSurfaceAck(int surface_id) {
823 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceAck"); 807 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceAck");
824 if (!send_destroying_video_surface_done_cb_.is_null()) 808 if (!send_destroying_video_surface_done_cb_.is_null())
825 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); 809 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run();
826 } 810 }
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 valid_ = false; 1043 valid_ = false;
1060 1044
1061 // First send empty channel handles for all EstablishChannel requests. 1045 // First send empty channel handles for all EstablishChannel requests.
1062 while (!channel_requests_.empty()) { 1046 while (!channel_requests_.empty()) {
1063 auto callback = channel_requests_.front(); 1047 auto callback = channel_requests_.front();
1064 channel_requests_.pop(); 1048 channel_requests_.pop();
1065 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); 1049 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo());
1066 } 1050 }
1067 1051
1068 while (!create_gpu_memory_buffer_requests_.empty()) { 1052 while (!create_gpu_memory_buffer_requests_.empty()) {
1069 CreateGpuMemoryBufferCallback callback = 1053 auto callback = create_gpu_memory_buffer_requests_.front();
1070 create_gpu_memory_buffer_requests_.front();
1071 create_gpu_memory_buffer_requests_.pop(); 1054 create_gpu_memory_buffer_requests_.pop();
1072 callback.Run(gfx::GpuMemoryBufferHandle()); 1055 callback.Run(gfx::GpuMemoryBufferHandle());
1073 } 1056 }
1074 1057
1075 if (!send_destroying_video_surface_done_cb_.is_null()) 1058 if (!send_destroying_video_surface_done_cb_.is_null())
1076 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); 1059 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run();
1077 } 1060 }
1078 1061
1079 void GpuProcessHost::BlockLiveOffscreenContexts() { 1062 void GpuProcessHost::BlockLiveOffscreenContexts() {
1080 for (std::multiset<GURL>::iterator iter = 1063 for (std::multiset<GURL>::iterator iter =
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 GetShaderCacheFactorySingleton()->Get(client_id); 1168 GetShaderCacheFactorySingleton()->Get(client_id);
1186 if (!cache.get()) 1169 if (!cache.get())
1187 return; 1170 return;
1188 1171
1189 cache->set_shader_loaded_callback(base::Bind(&HostLoadedShader, host_id_)); 1172 cache->set_shader_loaded_callback(base::Bind(&HostLoadedShader, host_id_));
1190 1173
1191 client_id_to_shader_cache_[client_id] = cache; 1174 client_id_to_shader_cache_[client_id] = cache;
1192 } 1175 }
1193 1176
1194 } // namespace content 1177 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698