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

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

Issue 370513002: Mac ÜC: Make resize smooth (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@enable_uc_for_reals
Patch Set: Add comments Created 6 years, 5 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 "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 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( 845 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped(
846 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { 846 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) {
847 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); 847 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped");
848 848
849 if (!ui::LatencyInfo::Verify(params.latency_info, 849 if (!ui::LatencyInfo::Verify(params.latency_info,
850 "GpuHostMsg_AcceleratedSurfaceBuffersSwapped")) 850 "GpuHostMsg_AcceleratedSurfaceBuffersSwapped"))
851 return; 851 return;
852 852
853 gfx::AcceleratedWidget native_widget = 853 gfx::AcceleratedWidget native_widget =
854 GpuSurfaceTracker::Get()->AcquireNativeWidget(params.surface_id); 854 GpuSurfaceTracker::Get()->AcquireNativeWidget(params.surface_id);
855
856 // Retrieve the render widget helper to forward this message to on the UI
857 // thread.
858 RenderWidgetHelper* helper = NULL;
859 int render_widget_id = 0;
855 if (native_widget) { 860 if (native_widget) {
856 RenderWidgetHelper::OnNativeSurfaceBuffersSwappedOnIOThread(this, params); 861 int render_process_id = 0;
857 return; 862 // TODO(ccameron): The render process and widget IDs have a race between
863 // the UI and the IO threads, and may potentially be wrong. Move the
864 // functionality in RenderProcessHost::WaitForBackingStoreMsg to a place
865 // where it can accept IPCs from all renderers (rather than this hack where
866 // we fake the render process and widget ID of a renderer for the browser).
867 // http://crbug.com/392031
868 if (RenderWidgetHelper::GetRenderWidgetIDForWidget(
869 native_widget, &render_process_id, &render_widget_id)) {
870 helper = RenderWidgetHelper::FromProcessHostID(render_process_id);
871 }
872 } else {
873 int render_process_id = 0;
874 if (GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface(
875 params.surface_id, &render_process_id, &render_widget_id)) {
876 helper = RenderWidgetHelper::FromProcessHostID(render_process_id);
877 }
858 } 878 }
859 879
860 gfx::GLSurfaceHandle surface_handle = 880 // If this is not targetting a native widget and we don't find a helper, then
861 GpuSurfaceTracker::Get()->GetSurfaceHandle(params.surface_id); 881 // ack immediately and ignore the message.
862 // Compositor window is always gfx::kNullPluginWindow. 882 if (!helper && !native_widget) {
863 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no 883 AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
864 // plugin windows. 884 ack_params.sync_point = 0;
865 if (surface_handle.handle != gfx::kNullPluginWindow ||
866 surface_handle.transport_type == gfx::TEXTURE_TRANSPORT) {
867 RouteOnUIThread(GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params));
868 return;
869 }
870
871 AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
872 ack_params.sync_point = 0;
873
874 int render_process_id = 0;
875 int render_widget_id = 0;
876 if (!GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface(
877 params.surface_id, &render_process_id, &render_widget_id)) {
878 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id,
879 ack_params));
880 return;
881 }
882 RenderWidgetHelper* helper =
883 RenderWidgetHelper::FromProcessHostID(render_process_id);
884 if (!helper) {
885 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, 885 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id,
886 ack_params)); 886 ack_params));
887 return; 887 return;
888 } 888 }
889 889
890 // If this is targetting a native widget, then ack the swap immediately to
891 // avoid introducing a deadlock between the browser and GPU processes (rate
892 // limiting is done through the compositor).
893 if (native_widget) {
894 AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
895 ack_params.sync_point = 0;
896 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id,
897 ack_params));
898 }
899
890 // Pass the SwapBuffers on to the RenderWidgetHelper to wake up the UI thread 900 // Pass the SwapBuffers on to the RenderWidgetHelper to wake up the UI thread
891 // if the browser is waiting for a new frame. Otherwise the RenderWidgetHelper 901 // if the browser is waiting for a new frame. Otherwise the RenderWidgetHelper
892 // will forward to the RenderWidgetHostView via RenderProcessHostImpl and 902 // will forward to the RenderWidgetHostView via RenderProcessHostImpl and
893 // RenderWidgetHostImpl. 903 // RenderWidgetHostImpl.
894 ViewHostMsg_CompositorSurfaceBuffersSwapped_Params view_params; 904 ViewHostMsg_CompositorSurfaceBuffersSwapped_Params view_params;
905 view_params.use_native_widget = native_widget;
895 view_params.surface_id = params.surface_id; 906 view_params.surface_id = params.surface_id;
896 view_params.surface_handle = params.surface_handle; 907 view_params.surface_handle = params.surface_handle;
897 view_params.route_id = params.route_id; 908 view_params.route_id = params.route_id;
898 view_params.size = params.size; 909 view_params.size = params.size;
899 view_params.scale_factor = params.scale_factor; 910 view_params.scale_factor = params.scale_factor;
900 view_params.gpu_process_host_id = host_id_; 911 view_params.gpu_process_host_id = host_id_;
901 view_params.latency_info = params.latency_info; 912 view_params.latency_info = params.latency_info;
902 helper->DidReceiveBackingStoreMsg(ViewHostMsg_CompositorSurfaceBuffersSwapped( 913 if (helper) {
903 render_widget_id, 914 helper->DidReceiveBackingStoreMsg(
904 view_params)); 915 ViewHostMsg_CompositorSurfaceBuffersSwapped(
916 render_widget_id,
917 view_params));
918 } else if (native_widget) {
919 BrowserThread::PostTask(
920 BrowserThread::UI,
921 FROM_HERE,
922 base::Bind(&RenderWidgetHelper::OnNativeSurfaceBuffersSwappedOnUIThread,
923 view_params));
924 }
905 } 925 }
906 #endif // OS_MACOSX 926 #endif // OS_MACOSX
907 927
908 void GpuProcessHost::OnProcessLaunched() { 928 void GpuProcessHost::OnProcessLaunched() {
909 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", 929 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime",
910 base::TimeTicks::Now() - init_start_time_); 930 base::TimeTicks::Now() - init_start_time_);
911 } 931 }
912 932
913 void GpuProcessHost::OnProcessCrashed(int exit_code) { 933 void GpuProcessHost::OnProcessCrashed(int exit_code) {
914 SendOutstandingReplies(); 934 SendOutstandingReplies();
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); 1139 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader");
1120 ClientIdToShaderCacheMap::iterator iter = 1140 ClientIdToShaderCacheMap::iterator iter =
1121 client_id_to_shader_cache_.find(client_id); 1141 client_id_to_shader_cache_.find(client_id);
1122 // If the cache doesn't exist then this is an off the record profile. 1142 // If the cache doesn't exist then this is an off the record profile.
1123 if (iter == client_id_to_shader_cache_.end()) 1143 if (iter == client_id_to_shader_cache_.end())
1124 return; 1144 return;
1125 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); 1145 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader);
1126 } 1146 }
1127 1147
1128 } // namespace content 1148 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698