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

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

Issue 2661523003: cc: Merge LayerTree into the LayerTreeHost. (Closed)
Patch Set: auto Created 3 years, 10 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.h" 23 #include "cc/trees/layer_tree_host.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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 } // namespace 69 } // namespace
70 70
71 RasterizeAndRecordBenchmark::RasterizeAndRecordBenchmark( 71 RasterizeAndRecordBenchmark::RasterizeAndRecordBenchmark(
72 std::unique_ptr<base::Value> value, 72 std::unique_ptr<base::Value> value,
73 const MicroBenchmark::DoneCallback& callback) 73 const MicroBenchmark::DoneCallback& callback)
74 : MicroBenchmark(callback), 74 : MicroBenchmark(callback),
75 record_repeat_count_(kDefaultRecordRepeatCount), 75 record_repeat_count_(kDefaultRecordRepeatCount),
76 settings_(std::move(value)), 76 settings_(std::move(value)),
77 main_thread_benchmark_done_(false), 77 main_thread_benchmark_done_(false),
78 layer_tree_(nullptr), 78 layer_tree_host_(nullptr),
79 weak_ptr_factory_(this) { 79 weak_ptr_factory_(this) {
80 base::DictionaryValue* settings = nullptr; 80 base::DictionaryValue* settings = nullptr;
81 settings_->GetAsDictionary(&settings); 81 settings_->GetAsDictionary(&settings);
82 if (!settings) 82 if (!settings)
83 return; 83 return;
84 84
85 if (settings->HasKey("record_repeat_count")) 85 if (settings->HasKey("record_repeat_count"))
86 settings->GetInteger("record_repeat_count", &record_repeat_count_); 86 settings->GetInteger("record_repeat_count", &record_repeat_count_);
87 } 87 }
88 88
89 RasterizeAndRecordBenchmark::~RasterizeAndRecordBenchmark() { 89 RasterizeAndRecordBenchmark::~RasterizeAndRecordBenchmark() {
90 weak_ptr_factory_.InvalidateWeakPtrs(); 90 weak_ptr_factory_.InvalidateWeakPtrs();
91 } 91 }
92 92
93 void RasterizeAndRecordBenchmark::DidUpdateLayers(LayerTree* layer_tree) { 93 void RasterizeAndRecordBenchmark::DidUpdateLayers(
94 layer_tree_ = layer_tree; 94 LayerTreeHost* layer_tree_host) {
95 layer_tree_host_ = layer_tree_host;
95 LayerTreeHostCommon::CallFunctionForEveryLayer( 96 LayerTreeHostCommon::CallFunctionForEveryLayer(
96 layer_tree, [this](Layer* layer) { layer->RunMicroBenchmark(this); }); 97 layer_tree_host_,
98 [this](Layer* layer) { layer->RunMicroBenchmark(this); });
97 99
98 DCHECK(!results_.get()); 100 DCHECK(!results_.get());
99 results_ = base::WrapUnique(new base::DictionaryValue); 101 results_ = base::WrapUnique(new base::DictionaryValue);
100 results_->SetInteger("pixels_recorded", record_results_.pixels_recorded); 102 results_->SetInteger("pixels_recorded", record_results_.pixels_recorded);
101 results_->SetInteger("picture_memory_usage", 103 results_->SetInteger("picture_memory_usage",
102 static_cast<int>(record_results_.bytes_used)); 104 static_cast<int>(record_results_.bytes_used));
103 105
104 for (int i = 0; i < RecordingSource::RECORDING_MODE_COUNT; i++) { 106 for (int i = 0; i < RecordingSource::RECORDING_MODE_COUNT; i++) {
105 std::string name = base::StringPrintf("record_time%s_ms", kModeSuffixes[i]); 107 std::string name = base::StringPrintf("record_time%s_ms", kModeSuffixes[i]);
106 results_->SetDouble(name, 108 results_->SetDouble(name,
(...skipping 18 matching lines...) Expand all
125 std::unique_ptr<MicroBenchmarkImpl> 127 std::unique_ptr<MicroBenchmarkImpl>
126 RasterizeAndRecordBenchmark::CreateBenchmarkImpl( 128 RasterizeAndRecordBenchmark::CreateBenchmarkImpl(
127 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner) { 129 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner) {
128 return base::WrapUnique(new RasterizeAndRecordBenchmarkImpl( 130 return base::WrapUnique(new RasterizeAndRecordBenchmarkImpl(
129 origin_task_runner, settings_.get(), 131 origin_task_runner, settings_.get(),
130 base::Bind(&RasterizeAndRecordBenchmark::RecordRasterResults, 132 base::Bind(&RasterizeAndRecordBenchmark::RecordRasterResults,
131 weak_ptr_factory_.GetWeakPtr()))); 133 weak_ptr_factory_.GetWeakPtr())));
132 } 134 }
133 135
134 void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { 136 void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) {
135 DCHECK(layer_tree_); 137 DCHECK(layer_tree_host_);
136 138
137 if (!layer->DrawsContent()) 139 if (!layer->DrawsContent())
138 return; 140 return;
139 141
140 ContentLayerClient* painter = layer->client(); 142 ContentLayerClient* painter = layer->client();
141 143
142 for (int mode_index = 0; mode_index < RecordingSource::RECORDING_MODE_COUNT; 144 for (int mode_index = 0; mode_index < RecordingSource::RECORDING_MODE_COUNT;
143 mode_index++) { 145 mode_index++) {
144 ContentLayerClient::PaintingControlSetting painting_control = 146 ContentLayerClient::PaintingControlSetting painting_control =
145 RecordingModeToPaintingControlSetting( 147 RecordingModeToPaintingControlSetting(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 190 }
189 } 191 }
190 192
191 RasterizeAndRecordBenchmark::RecordResults::RecordResults() 193 RasterizeAndRecordBenchmark::RecordResults::RecordResults()
192 : pixels_recorded(0), bytes_used(0) { 194 : pixels_recorded(0), bytes_used(0) {
193 } 195 }
194 196
195 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} 197 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {}
196 198
197 } // namespace cc 199 } // 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