| 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/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 15 #include "base/debug/trace_event.h" | 15 #include "base/debug/trace_event.h" |
| 16 #include "base/i18n/rtl.h" | 16 #include "base/i18n/rtl.h" |
| 17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
| 18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/metrics/field_trial.h" | 19 #include "base/metrics/field_trial.h" |
| 20 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
| 21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/thread_task_runner_handle.h" | 23 #include "base/thread_task_runner_handle.h" |
| 24 #include "cc/base/switches.h" |
| 24 #include "cc/output/compositor_frame.h" | 25 #include "cc/output/compositor_frame.h" |
| 25 #include "cc/output/compositor_frame_ack.h" | 26 #include "cc/output/compositor_frame_ack.h" |
| 26 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 27 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
| 27 #include "content/browser/gpu/compositor_util.h" | 28 #include "content/browser/gpu/compositor_util.h" |
| 28 #include "content/browser/gpu/gpu_process_host.h" | 29 #include "content/browser/gpu/gpu_process_host.h" |
| 29 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 30 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 30 #include "content/browser/gpu/gpu_surface_tracker.h" | 31 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 31 #include "content/browser/renderer_host/backing_store.h" | 32 #include "content/browser/renderer_host/backing_store.h" |
| 32 #include "content/browser/renderer_host/backing_store_manager.h" | 33 #include "content/browser/renderer_host/backing_store_manager.h" |
| 33 #include "content/browser/renderer_host/dip_util.h" | 34 #include "content/browser/renderer_host/dip_util.h" |
| (...skipping 2370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2404 rendering_stats_.total_touch_acked_latency += acked_delta; | 2405 rendering_stats_.total_touch_acked_latency += acked_delta; |
| 2405 UMA_HISTOGRAM_CUSTOM_COUNTS( | 2406 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 2406 "Event.Latency.Browser.TouchAcked", | 2407 "Event.Latency.Browser.TouchAcked", |
| 2407 acked_delta.InMicroseconds(), | 2408 acked_delta.InMicroseconds(), |
| 2408 0, | 2409 0, |
| 2409 1000000, | 2410 1000000, |
| 2410 100); | 2411 100); |
| 2411 } | 2412 } |
| 2412 | 2413 |
| 2413 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2414 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2414 switches::kEnableGpuBenchmarking)) | 2415 cc::switches::kEnableGpuBenchmarking)) |
| 2415 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); | 2416 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); |
| 2416 } | 2417 } |
| 2417 | 2418 |
| 2418 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { | 2419 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { |
| 2419 ui::LatencyInfo::LatencyComponent window_snapshot_component; | 2420 ui::LatencyInfo::LatencyComponent window_snapshot_component; |
| 2420 if (latency_info.FindLatency(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, | 2421 if (latency_info.FindLatency(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, |
| 2421 GetLatencyComponentId(), | 2422 GetLatencyComponentId(), |
| 2422 &window_snapshot_component)) { | 2423 &window_snapshot_component)) { |
| 2423 WindowSnapshotReachedScreen( | 2424 WindowSnapshotReachedScreen( |
| 2424 static_cast<int>(window_snapshot_component.sequence_number)); | 2425 static_cast<int>(window_snapshot_component.sequence_number)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2458 1000000, | 2459 1000000, |
| 2459 100); | 2460 100); |
| 2460 } | 2461 } |
| 2461 rendering_stats_.scroll_update_count += original_component.event_count; | 2462 rendering_stats_.scroll_update_count += original_component.event_count; |
| 2462 rendering_stats_.total_scroll_update_latency += | 2463 rendering_stats_.total_scroll_update_latency += |
| 2463 original_component.event_count * | 2464 original_component.event_count * |
| 2464 (swap_component.event_time - original_component.event_time); | 2465 (swap_component.event_time - original_component.event_time); |
| 2465 } | 2466 } |
| 2466 | 2467 |
| 2467 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2468 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2468 switches::kEnableGpuBenchmarking)) | 2469 cc::switches::kEnableGpuBenchmarking)) |
| 2469 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); | 2470 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); |
| 2470 } | 2471 } |
| 2471 | 2472 |
| 2472 void RenderWidgetHostImpl::DidReceiveRendererFrame() { | 2473 void RenderWidgetHostImpl::DidReceiveRendererFrame() { |
| 2473 view_->DidReceiveRendererFrame(); | 2474 view_->DidReceiveRendererFrame(); |
| 2474 } | 2475 } |
| 2475 | 2476 |
| 2476 void RenderWidgetHostImpl::WindowSnapshotAsyncCallback( | 2477 void RenderWidgetHostImpl::WindowSnapshotAsyncCallback( |
| 2477 int routing_id, | 2478 int routing_id, |
| 2478 int snapshot_id, | 2479 int snapshot_id, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2490 } | 2491 } |
| 2491 | 2492 |
| 2492 void RenderWidgetHostImpl::WindowSnapshotReachedScreen(int snapshot_id) { | 2493 void RenderWidgetHostImpl::WindowSnapshotReachedScreen(int snapshot_id) { |
| 2493 DCHECK(base::MessageLoopForUI::IsCurrent()); | 2494 DCHECK(base::MessageLoopForUI::IsCurrent()); |
| 2494 | 2495 |
| 2495 std::vector<unsigned char> png; | 2496 std::vector<unsigned char> png; |
| 2496 | 2497 |
| 2497 // This feature is behind the kEnableGpuBenchmarking command line switch | 2498 // This feature is behind the kEnableGpuBenchmarking command line switch |
| 2498 // because it poses security concerns and should only be used for testing. | 2499 // because it poses security concerns and should only be used for testing. |
| 2499 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 2500 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 2500 if (!command_line.HasSwitch(switches::kEnableGpuBenchmarking)) { | 2501 if (!command_line.HasSwitch(cc::switches::kEnableGpuBenchmarking)) { |
| 2501 Send(new ViewMsg_WindowSnapshotCompleted( | 2502 Send(new ViewMsg_WindowSnapshotCompleted( |
| 2502 GetRoutingID(), snapshot_id, gfx::Size(), png)); | 2503 GetRoutingID(), snapshot_id, gfx::Size(), png)); |
| 2503 return; | 2504 return; |
| 2504 } | 2505 } |
| 2505 | 2506 |
| 2506 gfx::Rect view_bounds = GetView()->GetViewBounds(); | 2507 gfx::Rect view_bounds = GetView()->GetViewBounds(); |
| 2507 gfx::Rect snapshot_bounds(view_bounds.size()); | 2508 gfx::Rect snapshot_bounds(view_bounds.size()); |
| 2508 gfx::Size snapshot_size = snapshot_bounds.size(); | 2509 gfx::Size snapshot_size = snapshot_bounds.size(); |
| 2509 | 2510 |
| 2510 if (ui::GrabViewSnapshot( | 2511 if (ui::GrabViewSnapshot( |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2572 } | 2573 } |
| 2573 } | 2574 } |
| 2574 | 2575 |
| 2575 // Add newly generated components into the latency info | 2576 // Add newly generated components into the latency info |
| 2576 for (lc = new_components.begin(); lc != new_components.end(); ++lc) { | 2577 for (lc = new_components.begin(); lc != new_components.end(); ++lc) { |
| 2577 latency_info->latency_components[lc->first] = lc->second; | 2578 latency_info->latency_components[lc->first] = lc->second; |
| 2578 } | 2579 } |
| 2579 } | 2580 } |
| 2580 | 2581 |
| 2581 } // namespace content | 2582 } // namespace content |
| OLD | NEW |