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

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, 8 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
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | content/common/gpu_host_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 } 696 }
697 697
698 void GpuProcessHost::AddFilter(IPC::MessageFilter* filter) { 698 void GpuProcessHost::AddFilter(IPC::MessageFilter* filter) {
699 DCHECK(CalledOnValidThread()); 699 DCHECK(CalledOnValidThread());
700 process_->GetHost()->AddFilter(filter); 700 process_->GetHost()->AddFilter(filter);
701 } 701 }
702 702
703 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { 703 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) {
704 DCHECK(CalledOnValidThread()); 704 DCHECK(CalledOnValidThread());
705 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) 705 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message)
706 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryBufferCreated,
707 OnGpuMemoryBufferCreated)
708 IPC_MESSAGE_HANDLER(GpuHostMsg_FieldTrialActivated, OnFieldTrialActivated); 706 IPC_MESSAGE_HANDLER(GpuHostMsg_FieldTrialActivated, OnFieldTrialActivated);
709 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) 707 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message))
710 IPC_END_MESSAGE_MAP() 708 IPC_END_MESSAGE_MAP()
711 709
712 return true; 710 return true;
713 } 711 }
714 712
715 void GpuProcessHost::OnChannelConnected(int32_t peer_pid) { 713 void GpuProcessHost::OnChannelConnected(int32_t peer_pid) {
716 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelConnected"); 714 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelConnected");
717 715
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 gfx::GpuMemoryBufferId id, 756 gfx::GpuMemoryBufferId id,
759 const gfx::Size& size, 757 const gfx::Size& size,
760 gfx::BufferFormat format, 758 gfx::BufferFormat format,
761 gfx::BufferUsage usage, 759 gfx::BufferUsage usage,
762 int client_id, 760 int client_id,
763 gpu::SurfaceHandle surface_handle, 761 gpu::SurfaceHandle surface_handle,
764 const CreateGpuMemoryBufferCallback& callback) { 762 const CreateGpuMemoryBufferCallback& callback) {
765 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); 763 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer");
766 764
767 DCHECK(CalledOnValidThread()); 765 DCHECK(CalledOnValidThread());
768 766 create_gpu_memory_buffer_requests_.push(callback);
769 GpuMsg_CreateGpuMemoryBuffer_Params params; 767 gpu_service_ptr_->CreateGpuMemoryBuffer(
770 params.id = id; 768 id, size, format, usage, client_id, surface_handle,
771 params.size = size; 769 base::Bind(&GpuProcessHost::OnGpuMemoryBufferCreated,
772 params.format = format; 770 weak_ptr_factory_.GetWeakPtr()));
773 params.usage = usage;
774 params.client_id = client_id;
775 params.surface_handle = surface_handle;
776 if (Send(new GpuMsg_CreateGpuMemoryBuffer(params))) {
777 create_gpu_memory_buffer_requests_.push(callback);
778 } else {
779 callback.Run(gfx::GpuMemoryBufferHandle());
780 }
781 } 771 }
782 772
783 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, 773 void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
784 int client_id, 774 int client_id,
785 const gpu::SyncToken& sync_token) { 775 const gpu::SyncToken& sync_token) {
786 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); 776 TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer");
787 777 gpu_service_ptr_->DestroyGpuMemoryBuffer(id, client_id, sync_token);
788 DCHECK(CalledOnValidThread());
789
790 Send(new GpuMsg_DestroyGpuMemoryBuffer(id, client_id, sync_token));
791 } 778 }
792 779
793 #if defined(OS_ANDROID) 780 #if defined(OS_ANDROID)
794 void GpuProcessHost::SendDestroyingVideoSurface(int surface_id, 781 void GpuProcessHost::SendDestroyingVideoSurface(int surface_id,
795 const base::Closure& done_cb) { 782 const base::Closure& done_cb) {
796 TRACE_EVENT0("gpu", "GpuProcessHost::SendDestroyingVideoSurface"); 783 TRACE_EVENT0("gpu", "GpuProcessHost::SendDestroyingVideoSurface");
797 DCHECK(send_destroying_video_surface_done_cb_.is_null()); 784 DCHECK(send_destroying_video_surface_done_cb_.is_null());
798 DCHECK(!done_cb.is_null()); 785 DCHECK(!done_cb.is_null());
799 send_destroying_video_surface_done_cb_ = done_cb; 786 send_destroying_video_surface_done_cb_ = done_cb;
800 gpu_service_ptr_->DestroyingVideoSurface( 787 gpu_service_ptr_->DestroyingVideoSurface(
(...skipping 22 matching lines...) Expand all
823 return; 810 return;
824 } 811 }
825 812
826 callback.Run(IPC::ChannelHandle(channel_handle.release()), gpu_info_); 813 callback.Run(IPC::ChannelHandle(channel_handle.release()), gpu_info_);
827 } 814 }
828 815
829 void GpuProcessHost::OnGpuMemoryBufferCreated( 816 void GpuProcessHost::OnGpuMemoryBufferCreated(
830 const gfx::GpuMemoryBufferHandle& handle) { 817 const gfx::GpuMemoryBufferHandle& handle) {
831 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); 818 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated");
832 819
833 if (create_gpu_memory_buffer_requests_.empty()) 820 DCHECK(!create_gpu_memory_buffer_requests_.empty());
834 return; 821 auto callback = create_gpu_memory_buffer_requests_.front();
835
836 CreateGpuMemoryBufferCallback callback =
837 create_gpu_memory_buffer_requests_.front();
838 create_gpu_memory_buffer_requests_.pop(); 822 create_gpu_memory_buffer_requests_.pop();
839 callback.Run(handle); 823 callback.Run(handle);
840 } 824 }
841 825
842 #if defined(OS_ANDROID) 826 #if defined(OS_ANDROID)
843 void GpuProcessHost::OnDestroyingVideoSurfaceAck() { 827 void GpuProcessHost::OnDestroyingVideoSurfaceAck() {
844 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceAck"); 828 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceAck");
845 if (!send_destroying_video_surface_done_cb_.is_null()) 829 if (!send_destroying_video_surface_done_cb_.is_null())
846 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); 830 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run();
847 } 831 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 valid_ = false; 1097 valid_ = false;
1114 1098
1115 // First send empty channel handles for all EstablishChannel requests. 1099 // First send empty channel handles for all EstablishChannel requests.
1116 while (!channel_requests_.empty()) { 1100 while (!channel_requests_.empty()) {
1117 auto callback = channel_requests_.front(); 1101 auto callback = channel_requests_.front();
1118 channel_requests_.pop(); 1102 channel_requests_.pop();
1119 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); 1103 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo());
1120 } 1104 }
1121 1105
1122 while (!create_gpu_memory_buffer_requests_.empty()) { 1106 while (!create_gpu_memory_buffer_requests_.empty()) {
1123 CreateGpuMemoryBufferCallback callback = 1107 auto callback = create_gpu_memory_buffer_requests_.front();
1124 create_gpu_memory_buffer_requests_.front();
1125 create_gpu_memory_buffer_requests_.pop(); 1108 create_gpu_memory_buffer_requests_.pop();
1126 callback.Run(gfx::GpuMemoryBufferHandle()); 1109 callback.Run(gfx::GpuMemoryBufferHandle());
1127 } 1110 }
1128 1111
1129 if (!send_destroying_video_surface_done_cb_.is_null()) 1112 if (!send_destroying_video_surface_done_cb_.is_null())
1130 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); 1113 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run();
1131 } 1114 }
1132 1115
1133 void GpuProcessHost::BlockLiveOffscreenContexts() { 1116 void GpuProcessHost::BlockLiveOffscreenContexts() {
1134 for (std::multiset<GURL>::iterator iter = 1117 for (std::multiset<GURL>::iterator iter =
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 GetShaderCacheFactorySingleton()->Get(client_id); 1231 GetShaderCacheFactorySingleton()->Get(client_id);
1249 if (!cache.get()) 1232 if (!cache.get())
1250 return; 1233 return;
1251 1234
1252 cache->set_shader_loaded_callback(base::Bind(&HostLoadedShader, host_id_)); 1235 cache->set_shader_loaded_callback(base::Bind(&HostLoadedShader, host_id_));
1253 1236
1254 client_id_to_shader_cache_[client_id] = cache; 1237 client_id_to_shader_cache_[client_id] = cache;
1255 } 1238 }
1256 1239
1257 } // namespace content 1240 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | content/common/gpu_host_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698