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 "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, | 608 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, |
609 OnGpuMemoryUmaStatsReceived) | 609 OnGpuMemoryUmaStatsReceived) |
610 #if defined(OS_MACOSX) | 610 #if defined(OS_MACOSX) |
611 IPC_MESSAGE_HANDLER_GENERIC(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 611 IPC_MESSAGE_HANDLER_GENERIC(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
612 OnAcceleratedSurfaceBuffersSwapped(message)) | 612 OnAcceleratedSurfaceBuffersSwapped(message)) |
613 #endif | 613 #endif |
614 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel, | 614 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel, |
615 OnDestroyChannel) | 615 OnDestroyChannel) |
616 IPC_MESSAGE_HANDLER(GpuHostMsg_CacheShader, | 616 IPC_MESSAGE_HANDLER(GpuHostMsg_CacheShader, |
617 OnCacheShader) | 617 OnCacheShader) |
| 618 IPC_MESSAGE_HANDLER(GpuHostMsg_StreamTextureCreated, OnStreamTextureCreated) |
618 | 619 |
619 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) | 620 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) |
620 IPC_END_MESSAGE_MAP() | 621 IPC_END_MESSAGE_MAP() |
621 | 622 |
622 return true; | 623 return true; |
623 } | 624 } |
624 | 625 |
625 void GpuProcessHost::OnChannelConnected(int32 peer_pid) { | 626 void GpuProcessHost::OnChannelConnected(int32 peer_pid) { |
626 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelConnected"); | 627 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelConnected"); |
627 | 628 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 create_command_buffer_requests_.push(callback); | 678 create_command_buffer_requests_.push(callback); |
678 surface_refs_.insert(std::make_pair(surface_id, | 679 surface_refs_.insert(std::make_pair(surface_id, |
679 GpuSurfaceTracker::GetInstance()->GetSurfaceRefForSurface(surface_id))); | 680 GpuSurfaceTracker::GetInstance()->GetSurfaceRefForSurface(surface_id))); |
680 } else { | 681 } else { |
681 // Could distinguish here between compositing_surface being NULL | 682 // Could distinguish here between compositing_surface being NULL |
682 // and Send failing, if desired. | 683 // and Send failing, if desired. |
683 callback.Run(CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST); | 684 callback.Run(CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST); |
684 } | 685 } |
685 } | 686 } |
686 | 687 |
| 688 void GpuProcessHost::CreateStreamTexture( |
| 689 int32 image_id, |
| 690 int client_id, |
| 691 int32 route_id, |
| 692 int32 stream_id, |
| 693 const CreateStreamTextureCallback& callback) { |
| 694 TRACE_EVENT0("gpu", "GpuProcessHost::CreateStreamTexture"); |
| 695 DCHECK(CalledOnValidThread()); |
| 696 Send( |
| 697 new GpuMsg_CreateStreamTexture(image_id, client_id, route_id, stream_id)); |
| 698 create_stream_texture_requests_.push(callback); |
| 699 } |
| 700 |
687 void GpuProcessHost::CreateGpuMemoryBuffer( | 701 void GpuProcessHost::CreateGpuMemoryBuffer( |
688 gfx::GpuMemoryBufferId id, | 702 gfx::GpuMemoryBufferId id, |
689 const gfx::Size& size, | 703 const gfx::Size& size, |
690 gfx::GpuMemoryBuffer::Format format, | 704 gfx::GpuMemoryBuffer::Format format, |
691 gfx::GpuMemoryBuffer::Usage usage, | 705 gfx::GpuMemoryBuffer::Usage usage, |
692 int client_id, | 706 int client_id, |
693 int32 surface_id, | 707 int32 surface_id, |
694 const CreateGpuMemoryBufferCallback& callback) { | 708 const CreateGpuMemoryBufferCallback& callback) { |
695 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); | 709 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); |
696 | 710 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 | 788 |
775 if (create_command_buffer_requests_.empty()) | 789 if (create_command_buffer_requests_.empty()) |
776 return; | 790 return; |
777 | 791 |
778 CreateCommandBufferCallback callback = | 792 CreateCommandBufferCallback callback = |
779 create_command_buffer_requests_.front(); | 793 create_command_buffer_requests_.front(); |
780 create_command_buffer_requests_.pop(); | 794 create_command_buffer_requests_.pop(); |
781 callback.Run(result); | 795 callback.Run(result); |
782 } | 796 } |
783 | 797 |
| 798 void GpuProcessHost::OnStreamTextureCreated(bool result) { |
| 799 if (create_stream_texture_requests_.empty()) |
| 800 return; |
| 801 CreateStreamTextureCallback callback = |
| 802 create_stream_texture_requests_.front(); |
| 803 create_stream_texture_requests_.pop(); |
| 804 callback.Run(result); |
| 805 } |
| 806 |
784 void GpuProcessHost::OnDestroyCommandBuffer(int32 surface_id) { | 807 void GpuProcessHost::OnDestroyCommandBuffer(int32 surface_id) { |
785 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyCommandBuffer"); | 808 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyCommandBuffer"); |
786 SurfaceRefMap::iterator it = surface_refs_.find(surface_id); | 809 SurfaceRefMap::iterator it = surface_refs_.find(surface_id); |
787 if (it != surface_refs_.end()) { | 810 if (it != surface_refs_.end()) { |
788 surface_refs_.erase(it); | 811 surface_refs_.erase(it); |
789 } | 812 } |
790 } | 813 } |
791 | 814 |
792 void GpuProcessHost::OnGpuMemoryBufferCreated( | 815 void GpuProcessHost::OnGpuMemoryBufferCreated( |
793 const gfx::GpuMemoryBufferHandle& handle) { | 816 const gfx::GpuMemoryBufferHandle& handle) { |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1159 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1137 ClientIdToShaderCacheMap::iterator iter = | 1160 ClientIdToShaderCacheMap::iterator iter = |
1138 client_id_to_shader_cache_.find(client_id); | 1161 client_id_to_shader_cache_.find(client_id); |
1139 // If the cache doesn't exist then this is an off the record profile. | 1162 // If the cache doesn't exist then this is an off the record profile. |
1140 if (iter == client_id_to_shader_cache_.end()) | 1163 if (iter == client_id_to_shader_cache_.end()) |
1141 return; | 1164 return; |
1142 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1165 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1143 } | 1166 } |
1144 | 1167 |
1145 } // namespace content | 1168 } // namespace content |
OLD | NEW |