| 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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, | 600 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, |
| 601 OnGpuMemoryUmaStatsReceived) | 601 OnGpuMemoryUmaStatsReceived) |
| 602 #if defined(OS_MACOSX) | 602 #if defined(OS_MACOSX) |
| 603 IPC_MESSAGE_HANDLER_GENERIC(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 603 IPC_MESSAGE_HANDLER_GENERIC(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
| 604 OnAcceleratedSurfaceBuffersSwapped(message)) | 604 OnAcceleratedSurfaceBuffersSwapped(message)) |
| 605 #endif | 605 #endif |
| 606 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel, | 606 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel, |
| 607 OnDestroyChannel) | 607 OnDestroyChannel) |
| 608 IPC_MESSAGE_HANDLER(GpuHostMsg_CacheShader, | 608 IPC_MESSAGE_HANDLER(GpuHostMsg_CacheShader, |
| 609 OnCacheShader) | 609 OnCacheShader) |
| 610 IPC_MESSAGE_HANDLER(GpuHostMsg_StreamTextureCreated, OnStreamTextureCreated) |
| 610 | 611 |
| 611 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) | 612 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) |
| 612 IPC_END_MESSAGE_MAP() | 613 IPC_END_MESSAGE_MAP() |
| 613 | 614 |
| 614 return true; | 615 return true; |
| 615 } | 616 } |
| 616 | 617 |
| 617 void GpuProcessHost::OnChannelConnected(int32 peer_pid) { | 618 void GpuProcessHost::OnChannelConnected(int32 peer_pid) { |
| 618 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelConnected"); | 619 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelConnected"); |
| 619 | 620 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 create_command_buffer_requests_.push(callback); | 676 create_command_buffer_requests_.push(callback); |
| 676 surface_refs_.insert(std::make_pair(surface_id, | 677 surface_refs_.insert(std::make_pair(surface_id, |
| 677 GpuSurfaceTracker::GetInstance()->GetSurfaceRefForSurface(surface_id))); | 678 GpuSurfaceTracker::GetInstance()->GetSurfaceRefForSurface(surface_id))); |
| 678 } else { | 679 } else { |
| 679 // Could distinguish here between compositing_surface being NULL | 680 // Could distinguish here between compositing_surface being NULL |
| 680 // and Send failing, if desired. | 681 // and Send failing, if desired. |
| 681 callback.Run(CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST); | 682 callback.Run(CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST); |
| 682 } | 683 } |
| 683 } | 684 } |
| 684 | 685 |
| 686 void GpuProcessHost::CreateStreamTexture( |
| 687 int32 image_id, |
| 688 int client_id, |
| 689 int32 route_id, |
| 690 int32 stream_id, |
| 691 const CreateStreamTextureCallback& callback) { |
| 692 TRACE_EVENT0("gpu", "GpuProcessHost::CreateStreamTexture"); |
| 693 DCHECK(CalledOnValidThread()); |
| 694 Send( |
| 695 new GpuMsg_CreateStreamTexture(image_id, client_id, route_id, stream_id)); |
| 696 create_stream_texture_requests_.push(callback); |
| 697 } |
| 698 |
| 685 void GpuProcessHost::CreateGpuMemoryBuffer( | 699 void GpuProcessHost::CreateGpuMemoryBuffer( |
| 686 gfx::GpuMemoryBufferId id, | 700 gfx::GpuMemoryBufferId id, |
| 687 const gfx::Size& size, | 701 const gfx::Size& size, |
| 688 gfx::GpuMemoryBuffer::Format format, | 702 gfx::GpuMemoryBuffer::Format format, |
| 689 gfx::GpuMemoryBuffer::Usage usage, | 703 gfx::GpuMemoryBuffer::Usage usage, |
| 690 int client_id, | 704 int client_id, |
| 691 int32 surface_id, | 705 int32 surface_id, |
| 692 const CreateGpuMemoryBufferCallback& callback) { | 706 const CreateGpuMemoryBufferCallback& callback) { |
| 693 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); | 707 TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); |
| 694 | 708 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 | 786 |
| 773 if (create_command_buffer_requests_.empty()) | 787 if (create_command_buffer_requests_.empty()) |
| 774 return; | 788 return; |
| 775 | 789 |
| 776 CreateCommandBufferCallback callback = | 790 CreateCommandBufferCallback callback = |
| 777 create_command_buffer_requests_.front(); | 791 create_command_buffer_requests_.front(); |
| 778 create_command_buffer_requests_.pop(); | 792 create_command_buffer_requests_.pop(); |
| 779 callback.Run(result); | 793 callback.Run(result); |
| 780 } | 794 } |
| 781 | 795 |
| 796 void GpuProcessHost::OnStreamTextureCreated(bool result) { |
| 797 if (create_stream_texture_requests_.empty()) |
| 798 return; |
| 799 CreateStreamTextureCallback callback = |
| 800 create_stream_texture_requests_.front(); |
| 801 create_stream_texture_requests_.pop(); |
| 802 callback.Run(result); |
| 803 } |
| 804 |
| 782 void GpuProcessHost::OnDestroyCommandBuffer(int32 surface_id) { | 805 void GpuProcessHost::OnDestroyCommandBuffer(int32 surface_id) { |
| 783 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyCommandBuffer"); | 806 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyCommandBuffer"); |
| 784 SurfaceRefMap::iterator it = surface_refs_.find(surface_id); | 807 SurfaceRefMap::iterator it = surface_refs_.find(surface_id); |
| 785 if (it != surface_refs_.end()) { | 808 if (it != surface_refs_.end()) { |
| 786 surface_refs_.erase(it); | 809 surface_refs_.erase(it); |
| 787 } | 810 } |
| 788 } | 811 } |
| 789 | 812 |
| 790 void GpuProcessHost::OnGpuMemoryBufferCreated( | 813 void GpuProcessHost::OnGpuMemoryBufferCreated( |
| 791 const gfx::GpuMemoryBufferHandle& handle) { | 814 const gfx::GpuMemoryBufferHandle& handle) { |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1150 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1128 ClientIdToShaderCacheMap::iterator iter = | 1151 ClientIdToShaderCacheMap::iterator iter = |
| 1129 client_id_to_shader_cache_.find(client_id); | 1152 client_id_to_shader_cache_.find(client_id); |
| 1130 // If the cache doesn't exist then this is an off the record profile. | 1153 // If the cache doesn't exist then this is an off the record profile. |
| 1131 if (iter == client_id_to_shader_cache_.end()) | 1154 if (iter == client_id_to_shader_cache_.end()) |
| 1132 return; | 1155 return; |
| 1133 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1156 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1134 } | 1157 } |
| 1135 | 1158 |
| 1136 } // namespace content | 1159 } // namespace content |
| OLD | NEW |