| 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_ui_shim.h" | 5 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "base/id_map.h" | 11 #include "base/id_map.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "content/browser/compositor/gpu_process_transport_factory.h" |
| 14 #include "content/browser/gpu/compositor_util.h" | 15 #include "content/browser/gpu/compositor_util.h" |
| 15 #include "content/browser/gpu/gpu_data_manager_impl.h" | 16 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 16 #include "content/browser/gpu/gpu_process_host.h" | 17 #include "content/browser/gpu/gpu_process_host.h" |
| 17 #include "content/browser/gpu/gpu_surface_tracker.h" | 18 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 18 #include "content/browser/renderer_host/render_process_host_impl.h" | 19 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 19 #include "content/browser/renderer_host/render_view_host_impl.h" | 20 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 20 #include "content/browser/renderer_host/render_widget_helper.h" | 21 #include "content/browser/renderer_host/render_widget_helper.h" |
| 21 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 22 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 22 #include "content/common/gpu/gpu_messages.h" | 23 #include "content/common/gpu/gpu_messages.h" |
| 23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 24 | 25 |
| 25 #if defined(OS_MACOSX) | 26 #if defined(OS_MACOSX) |
| 26 #include "content/browser/compositor/browser_compositor_ca_layer_tree_mac.h" | 27 #include "content/browser/compositor/browser_compositor_ca_layer_tree_mac.h" |
| 27 #endif | 28 #endif |
| 28 | 29 |
| 29 #if defined(USE_OZONE) | 30 #if defined(USE_OZONE) |
| 30 #include "ui/ozone/public/gpu_platform_support_host.h" | 31 #include "ui/ozone/public/gpu_platform_support_host.h" |
| 31 #include "ui/ozone/public/ozone_platform.h" | 32 #include "ui/ozone/public/ozone_platform.h" |
| 32 #endif | 33 #endif |
| 33 | 34 |
| 34 namespace content { | 35 namespace content { |
| 35 | 36 |
| 36 namespace { | 37 namespace { |
| 37 | 38 |
| 38 // One of the linux specific headers defines this as a macro. | 39 // One of the linux specific headers defines this as a macro. |
| 39 #ifdef DestroyAll | 40 #ifdef DestroyAll |
| 40 #undef DestroyAll | 41 #undef DestroyAll |
| 41 #endif | 42 #endif |
| 42 | 43 |
| 44 #if defined(OS_MACOSX) |
| 45 void OnSurfaceDisplayedCallback(int output_surface_id) { |
| 46 content::ImageTransportFactory::GetInstance()->OnSurfaceDisplayed( |
| 47 output_surface_id); |
| 48 } |
| 49 #endif |
| 50 |
| 43 base::LazyInstance<IDMap<GpuProcessHostUIShim> > g_hosts_by_id = | 51 base::LazyInstance<IDMap<GpuProcessHostUIShim> > g_hosts_by_id = |
| 44 LAZY_INSTANCE_INITIALIZER; | 52 LAZY_INSTANCE_INITIALIZER; |
| 45 | 53 |
| 46 void SendOnIOThreadTask(int host_id, IPC::Message* msg) { | 54 void SendOnIOThreadTask(int host_id, IPC::Message* msg) { |
| 47 GpuProcessHost* host = GpuProcessHost::FromID(host_id); | 55 GpuProcessHost* host = GpuProcessHost::FromID(host_id); |
| 48 if (host) | 56 if (host) |
| 49 host->Send(msg); | 57 host->Send(msg); |
| 50 else | 58 else |
| 51 delete msg; | 59 delete msg; |
| 52 } | 60 } |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 "GpuHostMsg_AcceleratedSurfaceBuffersSwapped")) { | 262 "GpuHostMsg_AcceleratedSurfaceBuffersSwapped")) { |
| 255 return; | 263 return; |
| 256 } | 264 } |
| 257 | 265 |
| 258 // On Mac with delegated rendering, accelerated surfaces are not necessarily | 266 // On Mac with delegated rendering, accelerated surfaces are not necessarily |
| 259 // associated with a RenderWidgetHostViewBase. | 267 // associated with a RenderWidgetHostViewBase. |
| 260 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | 268 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
| 261 DCHECK(IsDelegatedRendererEnabled()); | 269 DCHECK(IsDelegatedRendererEnabled()); |
| 262 gfx::AcceleratedWidget native_widget = | 270 gfx::AcceleratedWidget native_widget = |
| 263 content::GpuSurfaceTracker::Get()->AcquireNativeWidget(params.surface_id); | 271 content::GpuSurfaceTracker::Get()->AcquireNativeWidget(params.surface_id); |
| 264 BrowserCompositorCALayerTreeMacGotAcceleratedFrame( | 272 AcceleratedWidgetMacGotAcceleratedFrame( |
| 265 native_widget, | 273 native_widget, |
| 266 params.surface_handle, | 274 params.surface_handle, |
| 267 params.surface_id, | |
| 268 params.latency_info, | 275 params.latency_info, |
| 269 params.size, | 276 params.size, |
| 270 params.scale_factor, | 277 params.scale_factor, |
| 278 base::Bind(&OnSurfaceDisplayedCallback, params.surface_id), |
| 271 &ack_params.disable_throttling, | 279 &ack_params.disable_throttling, |
| 272 &ack_params.renderer_id); | 280 &ack_params.renderer_id); |
| 273 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, ack_params)); | 281 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, ack_params)); |
| 274 #else | 282 #else |
| 275 NOTREACHED(); | 283 NOTREACHED(); |
| 276 #endif | 284 #endif |
| 277 } | 285 } |
| 278 | 286 |
| 279 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( | 287 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( |
| 280 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { | 288 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { |
| 281 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( | 289 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( |
| 282 video_memory_usage_stats); | 290 video_memory_usage_stats); |
| 283 } | 291 } |
| 284 | 292 |
| 285 } // namespace content | 293 } // namespace content |
| OLD | NEW |