Chromium Code Reviews| 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/gpu/compositor_util.h" | 14 #include "content/browser/gpu/compositor_util.h" |
| 15 #include "content/browser/gpu/gpu_data_manager_impl.h" | 15 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 16 #include "content/browser/gpu/gpu_process_host.h" | 16 #include "content/browser/gpu/gpu_process_host.h" |
| 17 #include "content/browser/gpu/gpu_surface_tracker.h" | 17 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 18 #include "content/browser/renderer_host/render_process_host_impl.h" | 18 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 19 #include "content/browser/renderer_host/render_view_host_impl.h" | 19 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 20 #include "content/browser/renderer_host/render_widget_helper.h" | 20 #include "content/browser/renderer_host/render_widget_helper.h" |
| 21 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 21 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 22 #include "content/common/gpu/gpu_messages.h" | 22 #include "content/common/gpu/gpu_messages.h" |
| 23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 24 | 24 |
| 25 #if defined(OS_MACOSX) | |
| 26 #include "content/browser/compositor/browser_compositor_view_mac.h" | |
| 27 #endif | |
| 28 | |
| 29 #if defined(USE_OZONE) | 25 #if defined(USE_OZONE) |
| 30 #include "ui/ozone/public/gpu_platform_support_host.h" | 26 #include "ui/ozone/public/gpu_platform_support_host.h" |
| 31 #include "ui/ozone/public/ozone_platform.h" | 27 #include "ui/ozone/public/ozone_platform.h" |
| 32 #endif | 28 #endif |
| 33 | 29 |
| 34 namespace content { | 30 namespace content { |
| 35 | 31 |
| 32 // Forward-definition of the parts of BrowserCompositorCALayerTreeMac that are | |
| 33 // needed (the header cannot be included here because it uses Objective C). | |
| 34 #if defined(OS_MACOSX) | |
| 35 class BrowserCompositorCALayerTreeMac { | |
| 36 public: | |
| 37 static void GotAcceleratedFrame( | |
| 38 gfx::AcceleratedWidget widget, | |
| 39 uint64 surface_handle, int surface_id, | |
| 40 const std::vector<ui::LatencyInfo>& latency_info, | |
| 41 gfx::Size pixel_size, float scale_factor, | |
| 42 bool* disable_throttling, int* renderer_id); | |
| 43 }; | |
| 44 #endif | |
|
tapted
2014/10/17 00:04:36
I'm probably unnecessarily scared by this :). I'd
ccameron
2014/10/17 00:26:53
I was wondering which of the horrors was worse. Gi
| |
| 45 | |
| 36 namespace { | 46 namespace { |
| 37 | 47 |
| 38 // One of the linux specific headers defines this as a macro. | 48 // One of the linux specific headers defines this as a macro. |
| 39 #ifdef DestroyAll | 49 #ifdef DestroyAll |
| 40 #undef DestroyAll | 50 #undef DestroyAll |
| 41 #endif | 51 #endif |
| 42 | 52 |
| 43 base::LazyInstance<IDMap<GpuProcessHostUIShim> > g_hosts_by_id = | 53 base::LazyInstance<IDMap<GpuProcessHostUIShim> > g_hosts_by_id = |
| 44 LAZY_INSTANCE_INITIALIZER; | 54 LAZY_INSTANCE_INITIALIZER; |
| 45 | 55 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 #if defined(OS_MACOSX) | 260 #if defined(OS_MACOSX) |
| 251 TRACE_EVENT0("renderer", | 261 TRACE_EVENT0("renderer", |
| 252 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); | 262 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); |
| 253 if (!ui::LatencyInfo::Verify(params.latency_info, | 263 if (!ui::LatencyInfo::Verify(params.latency_info, |
| 254 "GpuHostMsg_AcceleratedSurfaceBuffersSwapped")) { | 264 "GpuHostMsg_AcceleratedSurfaceBuffersSwapped")) { |
| 255 return; | 265 return; |
| 256 } | 266 } |
| 257 | 267 |
| 258 // On Mac with delegated rendering, accelerated surfaces are not necessarily | 268 // On Mac with delegated rendering, accelerated surfaces are not necessarily |
| 259 // associated with a RenderWidgetHostViewBase. | 269 // associated with a RenderWidgetHostViewBase. |
| 270 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | |
| 260 DCHECK(IsDelegatedRendererEnabled()); | 271 DCHECK(IsDelegatedRendererEnabled()); |
| 261 gfx::AcceleratedWidget native_widget = | 272 gfx::AcceleratedWidget native_widget = |
| 262 content::GpuSurfaceTracker::Get()->AcquireNativeWidget(params.surface_id); | 273 content::GpuSurfaceTracker::Get()->AcquireNativeWidget(params.surface_id); |
| 263 BrowserCompositorViewMac::GotAcceleratedFrame(native_widget, | 274 BrowserCompositorCALayerTreeMac::GotAcceleratedFrame( |
| 264 params.surface_handle, | 275 native_widget, |
| 265 params.surface_id, | 276 params.surface_handle, |
| 266 params.latency_info, | 277 params.surface_id, |
| 267 params.size, | 278 params.latency_info, |
| 268 params.scale_factor, | 279 params.size, |
| 269 host_id_, | 280 params.scale_factor, |
| 270 params.route_id); | 281 &ack_params.disable_throttling, |
| 282 &ack_params.renderer_id); | |
| 283 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, ack_params)); | |
| 271 #else | 284 #else |
| 272 NOTREACHED(); | 285 NOTREACHED(); |
| 273 #endif | 286 #endif |
| 274 } | 287 } |
| 275 | 288 |
| 276 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( | 289 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( |
| 277 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { | 290 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { |
| 278 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( | 291 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( |
| 279 video_memory_usage_stats); | 292 video_memory_usage_stats); |
| 280 } | 293 } |
| 281 | 294 |
| 282 } // namespace content | 295 } // namespace content |
| OLD | NEW |