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

Side by Side Diff: cc/debug/rasterize_and_record_benchmark.cc

Issue 2216203002: Refactor MutatorHostClient from LayerTreeHost to LayerTree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on another LTH refactor CL. Created 4 years, 4 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
« no previous file with comments | « cc/debug/rasterize_and_record_benchmark.h ('k') | cc/debug/unittest_only_benchmark.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/debug/rasterize_and_record_benchmark.h" 5 #include "cc/debug/rasterize_and_record_benchmark.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
11 #include <string> 11 #include <string>
12 12
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "cc/debug/lap_timer.h" 16 #include "cc/debug/lap_timer.h"
17 #include "cc/debug/rasterize_and_record_benchmark_impl.h" 17 #include "cc/debug/rasterize_and_record_benchmark_impl.h"
18 #include "cc/layers/content_layer_client.h" 18 #include "cc/layers/content_layer_client.h"
19 #include "cc/layers/layer.h" 19 #include "cc/layers/layer.h"
20 #include "cc/layers/picture_layer.h" 20 #include "cc/layers/picture_layer.h"
21 #include "cc/playback/display_item_list.h" 21 #include "cc/playback/display_item_list.h"
22 #include "cc/playback/recording_source.h" 22 #include "cc/playback/recording_source.h"
23 #include "cc/trees/layer_tree_host.h" 23 #include "cc/trees/layer_tree.h"
24 #include "cc/trees/layer_tree_host_common.h" 24 #include "cc/trees/layer_tree_host_common.h"
25 #include "skia/ext/analysis_canvas.h" 25 #include "skia/ext/analysis_canvas.h"
26 #include "third_party/skia/include/utils/SkPictureUtils.h" 26 #include "third_party/skia/include/utils/SkPictureUtils.h"
27 #include "ui/gfx/geometry/rect.h" 27 #include "ui/gfx/geometry/rect.h"
28 28
29 namespace cc { 29 namespace cc {
30 30
31 namespace { 31 namespace {
32 32
33 const int kDefaultRecordRepeatCount = 100; 33 const int kDefaultRecordRepeatCount = 100;
(...skipping 13 matching lines...) Expand all
47 47
48 } // namespace 48 } // namespace
49 49
50 RasterizeAndRecordBenchmark::RasterizeAndRecordBenchmark( 50 RasterizeAndRecordBenchmark::RasterizeAndRecordBenchmark(
51 std::unique_ptr<base::Value> value, 51 std::unique_ptr<base::Value> value,
52 const MicroBenchmark::DoneCallback& callback) 52 const MicroBenchmark::DoneCallback& callback)
53 : MicroBenchmark(callback), 53 : MicroBenchmark(callback),
54 record_repeat_count_(kDefaultRecordRepeatCount), 54 record_repeat_count_(kDefaultRecordRepeatCount),
55 settings_(std::move(value)), 55 settings_(std::move(value)),
56 main_thread_benchmark_done_(false), 56 main_thread_benchmark_done_(false),
57 host_(nullptr), 57 layer_tree_(nullptr),
58 weak_ptr_factory_(this) { 58 weak_ptr_factory_(this) {
59 base::DictionaryValue* settings = nullptr; 59 base::DictionaryValue* settings = nullptr;
60 settings_->GetAsDictionary(&settings); 60 settings_->GetAsDictionary(&settings);
61 if (!settings) 61 if (!settings)
62 return; 62 return;
63 63
64 if (settings->HasKey("record_repeat_count")) 64 if (settings->HasKey("record_repeat_count"))
65 settings->GetInteger("record_repeat_count", &record_repeat_count_); 65 settings->GetInteger("record_repeat_count", &record_repeat_count_);
66 } 66 }
67 67
68 RasterizeAndRecordBenchmark::~RasterizeAndRecordBenchmark() { 68 RasterizeAndRecordBenchmark::~RasterizeAndRecordBenchmark() {
69 weak_ptr_factory_.InvalidateWeakPtrs(); 69 weak_ptr_factory_.InvalidateWeakPtrs();
70 } 70 }
71 71
72 void RasterizeAndRecordBenchmark::DidUpdateLayers(LayerTreeHost* host) { 72 void RasterizeAndRecordBenchmark::DidUpdateLayers(LayerTree* layer_tree) {
73 host_ = host; 73 layer_tree_ = layer_tree;
74 LayerTreeHostCommon::CallFunctionForEveryLayer( 74 LayerTreeHostCommon::CallFunctionForEveryLayer(
75 host, [this](Layer* layer) { layer->RunMicroBenchmark(this); }); 75 layer_tree, [this](Layer* layer) { layer->RunMicroBenchmark(this); });
76 76
77 DCHECK(!results_.get()); 77 DCHECK(!results_.get());
78 results_ = base::WrapUnique(new base::DictionaryValue); 78 results_ = base::WrapUnique(new base::DictionaryValue);
79 results_->SetInteger("pixels_recorded", record_results_.pixels_recorded); 79 results_->SetInteger("pixels_recorded", record_results_.pixels_recorded);
80 results_->SetInteger("picture_memory_usage", 80 results_->SetInteger("picture_memory_usage",
81 static_cast<int>(record_results_.bytes_used)); 81 static_cast<int>(record_results_.bytes_used));
82 82
83 for (int i = 0; i < RecordingSource::RECORDING_MODE_COUNT; i++) { 83 for (int i = 0; i < RecordingSource::RECORDING_MODE_COUNT; i++) {
84 std::string name = base::StringPrintf("record_time%s_ms", kModeSuffixes[i]); 84 std::string name = base::StringPrintf("record_time%s_ms", kModeSuffixes[i]);
85 results_->SetDouble(name, 85 results_->SetDouble(name,
(...skipping 18 matching lines...) Expand all
104 std::unique_ptr<MicroBenchmarkImpl> 104 std::unique_ptr<MicroBenchmarkImpl>
105 RasterizeAndRecordBenchmark::CreateBenchmarkImpl( 105 RasterizeAndRecordBenchmark::CreateBenchmarkImpl(
106 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner) { 106 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner) {
107 return base::WrapUnique(new RasterizeAndRecordBenchmarkImpl( 107 return base::WrapUnique(new RasterizeAndRecordBenchmarkImpl(
108 origin_task_runner, settings_.get(), 108 origin_task_runner, settings_.get(),
109 base::Bind(&RasterizeAndRecordBenchmark::RecordRasterResults, 109 base::Bind(&RasterizeAndRecordBenchmark::RecordRasterResults,
110 weak_ptr_factory_.GetWeakPtr()))); 110 weak_ptr_factory_.GetWeakPtr())));
111 } 111 }
112 112
113 void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { 113 void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) {
114 DCHECK(host_); 114 DCHECK(layer_tree_);
115 115
116 if (!layer->DrawsContent()) 116 if (!layer->DrawsContent())
117 return; 117 return;
118 118
119 ContentLayerClient* painter = layer->client(); 119 ContentLayerClient* painter = layer->client();
120 120
121 for (int mode_index = 0; mode_index < RecordingSource::RECORDING_MODE_COUNT; 121 for (int mode_index = 0; mode_index < RecordingSource::RECORDING_MODE_COUNT;
122 mode_index++) { 122 mode_index++) {
123 ContentLayerClient::PaintingControlSetting painting_control = 123 ContentLayerClient::PaintingControlSetting painting_control =
124 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL_FOR_TEST; 124 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL_FOR_TEST;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 189 }
190 } 190 }
191 191
192 RasterizeAndRecordBenchmark::RecordResults::RecordResults() 192 RasterizeAndRecordBenchmark::RecordResults::RecordResults()
193 : pixels_recorded(0), bytes_used(0) { 193 : pixels_recorded(0), bytes_used(0) {
194 } 194 }
195 195
196 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} 196 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {}
197 197
198 } // namespace cc 198 } // namespace cc
OLDNEW
« no previous file with comments | « cc/debug/rasterize_and_record_benchmark.h ('k') | cc/debug/unittest_only_benchmark.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698