| 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 25 matching lines...) Expand all Loading... |
| 36 #include "content/public/common/result_codes.h" | 36 #include "content/public/common/result_codes.h" |
| 37 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 37 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| 38 #include "gpu/command_buffer/service/gpu_switches.h" | 38 #include "gpu/command_buffer/service/gpu_switches.h" |
| 39 #include "ipc/ipc_channel_handle.h" | 39 #include "ipc/ipc_channel_handle.h" |
| 40 #include "ipc/ipc_switches.h" | 40 #include "ipc/ipc_switches.h" |
| 41 #include "ipc/message_filter.h" | 41 #include "ipc/message_filter.h" |
| 42 #include "media/base/media_switches.h" | 42 #include "media/base/media_switches.h" |
| 43 #include "ui/events/latency_info.h" | 43 #include "ui/events/latency_info.h" |
| 44 #include "ui/gl/gl_switches.h" | 44 #include "ui/gl/gl_switches.h" |
| 45 | 45 |
| 46 #if defined(OS_MACOSX) | |
| 47 #include <IOSurface/IOSurfaceAPI.h> | |
| 48 #include "base/mac/scoped_cftyperef.h" | |
| 49 #include "content/common/gpu/surface_handle_types_mac.h" | |
| 50 #endif | |
| 51 | |
| 52 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
| 53 #include "base/win/windows_version.h" | 47 #include "base/win/windows_version.h" |
| 54 #include "content/common/sandbox_win.h" | 48 #include "content/common/sandbox_win.h" |
| 55 #include "sandbox/win/src/sandbox_policy.h" | 49 #include "sandbox/win/src/sandbox_policy.h" |
| 56 #include "ui/gfx/switches.h" | 50 #include "ui/gfx/switches.h" |
| 57 #endif | 51 #endif |
| 58 | 52 |
| 59 #if defined(USE_OZONE) | 53 #if defined(USE_OZONE) |
| 60 #include "ui/ozone/public/ozone_switches.h" | 54 #include "ui/ozone/public/ozone_switches.h" |
| 61 #endif | 55 #endif |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 } | 745 } |
| 752 | 746 |
| 753 void GpuProcessHost::OnGpuMemoryUmaStatsReceived( | 747 void GpuProcessHost::OnGpuMemoryUmaStatsReceived( |
| 754 const GPUMemoryUmaStats& stats) { | 748 const GPUMemoryUmaStats& stats) { |
| 755 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryUmaStatsReceived"); | 749 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryUmaStatsReceived"); |
| 756 uma_memory_stats_received_ = true; | 750 uma_memory_stats_received_ = true; |
| 757 uma_memory_stats_ = stats; | 751 uma_memory_stats_ = stats; |
| 758 } | 752 } |
| 759 | 753 |
| 760 #if defined(OS_MACOSX) | 754 #if defined(OS_MACOSX) |
| 761 namespace { | |
| 762 void HoldIOSurfaceReference(base::ScopedCFTypeRef<IOSurfaceRef> io_surface) {} | |
| 763 } // namespace | |
| 764 | |
| 765 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( | 755 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
| 766 const IPC::Message& message) { | 756 const IPC::Message& message) { |
| 767 RenderWidgetResizeHelper::Get()->PostGpuProcessMsg(host_id_, message); | 757 RenderWidgetResizeHelper::Get()->PostGpuProcessMsg(host_id_, message); |
| 768 | |
| 769 if (!IsDelegatedRendererEnabled()) | |
| 770 return; | |
| 771 | |
| 772 GpuHostMsg_AcceleratedSurfaceBuffersSwapped::Param param; | |
| 773 if (!GpuHostMsg_AcceleratedSurfaceBuffersSwapped::Read(&message, ¶m)) | |
| 774 return; | |
| 775 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params = param.a; | |
| 776 | |
| 777 if (GetSurfaceHandleType(params.surface_handle) == | |
| 778 kSurfaceHandleTypeIOSurface) { | |
| 779 // As soon as the frame is acked, the IOSurface may be thrown away by the | |
| 780 // GPU process. Open the IOSurface and post a task referencing it to the UI | |
| 781 // thread. This will keep the IOSurface from being thrown away until the UI | |
| 782 // thread can open another reference to it, if needed. | |
| 783 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceLookup( | |
| 784 IOSurfaceIDFromSurfaceHandle(params.surface_handle))); | |
| 785 BrowserThread::PostTask(BrowserThread::UI, | |
| 786 FROM_HERE, | |
| 787 base::Bind(HoldIOSurfaceReference, io_surface)); | |
| 788 } | |
| 789 | |
| 790 // If delegated rendering is enabled, then immediately acknowledge this frame | |
| 791 // on the IO thread instead of the UI thread. The UI thread will wait on the | |
| 792 // GPU process. If the UI thread were to be responsible for acking swaps, | |
| 793 // then there would be a cycle and a potential deadlock. Back-pressure from | |
| 794 // the GPU is provided through the compositor's output surface. | |
| 795 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | |
| 796 ack_params.sync_point = 0; | |
| 797 ack_params.renderer_id = 0; | |
| 798 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, ack_params)); | |
| 799 } | 758 } |
| 800 #endif | 759 #endif |
| 801 | 760 |
| 802 void GpuProcessHost::OnProcessLaunched() { | 761 void GpuProcessHost::OnProcessLaunched() { |
| 803 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", | 762 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", |
| 804 base::TimeTicks::Now() - init_start_time_); | 763 base::TimeTicks::Now() - init_start_time_); |
| 805 } | 764 } |
| 806 | 765 |
| 807 void GpuProcessHost::OnProcessCrashed(int exit_code) { | 766 void GpuProcessHost::OnProcessCrashed(int exit_code) { |
| 808 SendOutstandingReplies(); | 767 SendOutstandingReplies(); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1039 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1081 ClientIdToShaderCacheMap::iterator iter = | 1040 ClientIdToShaderCacheMap::iterator iter = |
| 1082 client_id_to_shader_cache_.find(client_id); | 1041 client_id_to_shader_cache_.find(client_id); |
| 1083 // If the cache doesn't exist then this is an off the record profile. | 1042 // If the cache doesn't exist then this is an off the record profile. |
| 1084 if (iter == client_id_to_shader_cache_.end()) | 1043 if (iter == client_id_to_shader_cache_.end()) |
| 1085 return; | 1044 return; |
| 1086 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1045 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1087 } | 1046 } |
| 1088 | 1047 |
| 1089 } // namespace content | 1048 } // namespace content |
| OLD | NEW |