OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/layer_tree_host_in_process.h" | 5 #include "cc/trees/layer_tree_host_in_process.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <memory> | 11 #include <memory> |
12 #include <stack> | 12 #include <stack> |
13 #include <string> | 13 #include <string> |
14 #include <unordered_map> | 14 #include <unordered_map> |
15 | 15 |
16 #include "base/atomic_sequence_num.h" | 16 #include "base/atomic_sequence_num.h" |
17 #include "base/bind.h" | 17 #include "base/bind.h" |
18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
19 #include "base/location.h" | 19 #include "base/location.h" |
20 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
21 #include "base/metrics/histogram_macros.h" | 21 #include "base/metrics/histogram_macros.h" |
22 #include "base/numerics/safe_math.h" | 22 #include "base/numerics/safe_math.h" |
23 #include "base/single_thread_task_runner.h" | 23 #include "base/single_thread_task_runner.h" |
24 #include "base/stl_util.h" | 24 #include "base/stl_util.h" |
25 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
26 #include "base/strings/stringprintf.h" | |
26 #include "base/threading/thread_task_runner_handle.h" | 27 #include "base/threading/thread_task_runner_handle.h" |
28 #include "base/timer/elapsed_timer.h" | |
27 #include "base/trace_event/trace_event.h" | 29 #include "base/trace_event/trace_event.h" |
28 #include "base/trace_event/trace_event_argument.h" | 30 #include "base/trace_event/trace_event_argument.h" |
31 #include "cc/base/histograms.h" | |
29 #include "cc/base/math_util.h" | 32 #include "cc/base/math_util.h" |
30 #include "cc/blimp/client_picture_cache.h" | 33 #include "cc/blimp/client_picture_cache.h" |
31 #include "cc/blimp/engine_picture_cache.h" | 34 #include "cc/blimp/engine_picture_cache.h" |
32 #include "cc/blimp/image_serialization_processor.h" | 35 #include "cc/blimp/image_serialization_processor.h" |
33 #include "cc/blimp/picture_data.h" | 36 #include "cc/blimp/picture_data.h" |
34 #include "cc/blimp/picture_data_conversions.h" | 37 #include "cc/blimp/picture_data_conversions.h" |
35 #include "cc/debug/devtools_instrumentation.h" | 38 #include "cc/debug/devtools_instrumentation.h" |
36 #include "cc/debug/frame_viewer_instrumentation.h" | 39 #include "cc/debug/frame_viewer_instrumentation.h" |
37 #include "cc/debug/rendering_stats_instrumentation.h" | 40 #include "cc/debug/rendering_stats_instrumentation.h" |
38 #include "cc/input/layer_selection_bound.h" | 41 #include "cc/input/layer_selection_bound.h" |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
575 | 578 |
576 void LayerTreeHostInProcess::Composite(base::TimeTicks frame_begin_time) { | 579 void LayerTreeHostInProcess::Composite(base::TimeTicks frame_begin_time) { |
577 DCHECK(IsSingleThreaded()); | 580 DCHECK(IsSingleThreaded()); |
578 // This function is only valid when not using the scheduler. | 581 // This function is only valid when not using the scheduler. |
579 DCHECK(!settings_.single_thread_proxy_scheduler); | 582 DCHECK(!settings_.single_thread_proxy_scheduler); |
580 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get()); | 583 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get()); |
581 | 584 |
582 proxy->CompositeImmediately(frame_begin_time); | 585 proxy->CompositeImmediately(frame_begin_time); |
583 } | 586 } |
584 | 587 |
588 static int GetLayersUpdateTimeHistogramBucket(size_t numLayers) { | |
589 // We uses the following exponential (ratio 2) bucketization: | |
590 // [0, 10), [10, 30), [30, 70), [70, 150), [150, infinity) | |
591 if (numLayers < 10) | |
592 return 0; | |
593 else if (numLayers >= 10 && numLayers < 30) | |
flackr
2016/12/08 22:35:08
nit: >= condition in each of these is unnecessary
majidvp
2016/12/19 20:39:33
Done.
| |
594 return 1; | |
595 else if (numLayers >= 30 && numLayers < 70) | |
596 return 2; | |
597 else if (numLayers >= 70 && numLayers < 150) | |
598 return 3; | |
599 else | |
flackr
2016/12/08 22:35:08
per the style guide, no else (or else if) after re
majidvp
2016/12/19 20:39:33
Done.
| |
600 return 4; | |
601 } | |
602 | |
585 bool LayerTreeHostInProcess::UpdateLayers() { | 603 bool LayerTreeHostInProcess::UpdateLayers() { |
586 if (!layer_tree_->root_layer()) | 604 if (!layer_tree_->root_layer()) |
587 return false; | 605 return false; |
588 DCHECK(!layer_tree_->root_layer()->parent()); | 606 DCHECK(!layer_tree_->root_layer()->parent()); |
607 base::ElapsedTimer timer; | |
608 | |
589 bool result = DoUpdateLayers(layer_tree_->root_layer()); | 609 bool result = DoUpdateLayers(layer_tree_->root_layer()); |
590 micro_benchmark_controller_.DidUpdateLayers(); | 610 micro_benchmark_controller_.DidUpdateLayers(); |
611 | |
612 if (const char* client_name = GetClientNameForMetrics()) { | |
613 std::string histogram_name = base::StringPrintf( | |
614 "Compositing.%s.LayersUpdateTime.%d", client_name, | |
615 GetLayersUpdateTimeHistogramBucket(layer_tree_->NumLayers())); | |
616 base::Histogram::FactoryGet(histogram_name, 0, 10000000, 50, | |
617 base::HistogramBase::kUmaTargetedHistogramFlag) | |
618 ->Add(timer.Elapsed().InMicroseconds()); | |
619 } | |
620 | |
591 return result || next_commit_forces_redraw_; | 621 return result || next_commit_forces_redraw_; |
592 } | 622 } |
593 | 623 |
594 void LayerTreeHostInProcess::DidCompletePageScaleAnimation() { | 624 void LayerTreeHostInProcess::DidCompletePageScaleAnimation() { |
595 did_complete_scale_animation_ = true; | 625 did_complete_scale_animation_ = true; |
596 } | 626 } |
597 | 627 |
598 void LayerTreeHostInProcess::RecordGpuRasterizationHistogram() { | 628 void LayerTreeHostInProcess::RecordGpuRasterizationHistogram() { |
599 // Gpu rasterization is only supported for Renderer compositors. | 629 // Gpu rasterization is only supported for Renderer compositors. |
600 // Checking for IsSingleThreaded() to exclude Browser compositors. | 630 // Checking for IsSingleThreaded() to exclude Browser compositors. |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
821 return compositor_mode_ == CompositorMode::SINGLE_THREADED; | 851 return compositor_mode_ == CompositorMode::SINGLE_THREADED; |
822 } | 852 } |
823 | 853 |
824 bool LayerTreeHostInProcess::IsThreaded() const { | 854 bool LayerTreeHostInProcess::IsThreaded() const { |
825 DCHECK(compositor_mode_ != CompositorMode::THREADED || | 855 DCHECK(compositor_mode_ != CompositorMode::THREADED || |
826 task_runner_provider_->HasImplThread()); | 856 task_runner_provider_->HasImplThread()); |
827 return compositor_mode_ == CompositorMode::THREADED; | 857 return compositor_mode_ == CompositorMode::THREADED; |
828 } | 858 } |
829 | 859 |
830 } // namespace cc | 860 } // namespace cc |
OLD | NEW |