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

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

Issue 867803003: Report viewport memory and timing correctly for Slimming Paint. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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') | no next file » | 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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "cc/debug/lap_timer.h" 14 #include "cc/debug/lap_timer.h"
15 #include "cc/debug/rasterize_and_record_benchmark_impl.h" 15 #include "cc/debug/rasterize_and_record_benchmark_impl.h"
16 #include "cc/layers/content_layer_client.h"
16 #include "cc/layers/layer.h" 17 #include "cc/layers/layer.h"
17 #include "cc/layers/picture_layer.h" 18 #include "cc/layers/picture_layer.h"
19 #include "cc/resources/display_item_list.h"
18 #include "cc/resources/picture_pile.h" 20 #include "cc/resources/picture_pile.h"
19 #include "cc/trees/layer_tree_host.h" 21 #include "cc/trees/layer_tree_host.h"
20 #include "cc/trees/layer_tree_host_common.h" 22 #include "cc/trees/layer_tree_host_common.h"
21 #include "third_party/skia/include/utils/SkPictureUtils.h" 23 #include "third_party/skia/include/utils/SkPictureUtils.h"
22 #include "ui/gfx/geometry/rect.h" 24 #include "ui/gfx/geometry/rect.h"
23 25
24 namespace cc { 26 namespace cc {
25 27
26 namespace { 28 namespace {
27 29
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 101
100 void RasterizeAndRecordBenchmark::Run(Layer* layer) { 102 void RasterizeAndRecordBenchmark::Run(Layer* layer) {
101 layer->RunMicroBenchmark(this); 103 layer->RunMicroBenchmark(this);
102 } 104 }
103 105
104 void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { 106 void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) {
105 ContentLayerClient* painter = layer->client(); 107 ContentLayerClient* painter = layer->client();
106 gfx::Size content_bounds = layer->content_bounds(); 108 gfx::Size content_bounds = layer->content_bounds();
107 109
108 DCHECK(host_); 110 DCHECK(host_);
111
112 if (host_->settings().use_display_lists) {
113 RunOnDisplayListLayer(layer);
ajuma 2015/01/23 20:10:19 Perhaps also define a RunOnPicturePileLayer for th
114 return;
115 }
116
109 gfx::Size tile_grid_size = host_->settings().default_tile_size; 117 gfx::Size tile_grid_size = host_->settings().default_tile_size;
110 118
111 gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect( 119 gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect(
112 layer->visible_content_rect(), 1.f / layer->contents_scale_x()); 120 layer->visible_content_rect(), 1.f / layer->contents_scale_x());
113 if (visible_content_rect.IsEmpty()) 121 if (visible_content_rect.IsEmpty())
114 return; 122 return;
115 123
116 for (int mode_index = 0; mode_index < Picture::RECORDING_MODE_COUNT; 124 for (int mode_index = 0; mode_index < Picture::RECORDING_MODE_COUNT;
117 mode_index++) { 125 mode_index++) {
118 Picture::RecordingMode mode = 126 Picture::RecordingMode mode =
119 static_cast<Picture::RecordingMode>(mode_index); 127 static_cast<Picture::RecordingMode>(mode_index);
120 base::TimeDelta min_time = base::TimeDelta::Max(); 128 base::TimeDelta min_time = base::TimeDelta::Max();
121 size_t memory_used = 0; 129 size_t memory_used = 0;
122 130
123 // Parameters for LapTimer. 131 // Parameters for LapTimer.
124 const int kTimeLimitMillis = 1; 132 const int kTimeLimitMillis = 1;
125 const int kWarmupRuns = 0; 133 const int kWarmupRuns = 0;
126 const int kTimeCheckInterval = 1; 134 const int kTimeCheckInterval = 1;
127 135
128 for (int i = 0; i < record_repeat_count_; ++i) { 136 for (int i = 0; i < record_repeat_count_; ++i) {
129 // Run for a minimum amount of time to avoid problems with timer 137 // Run for a minimum amount of time to avoid problems with timer
130 // quantization when the layer is very small. 138 // quantization when the layer is very small.
131 LapTimer timer(kWarmupRuns, 139 LapTimer timer(kWarmupRuns,
132 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), 140 base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
133 kTimeCheckInterval); 141 kTimeCheckInterval);
134 scoped_refptr<Picture> picture; 142 scoped_refptr<Picture> picture;
135 do { 143 do {
136 picture = Picture::Create(visible_content_rect, painter, tile_grid_size, 144 picture = Picture::Create(visible_content_rect, painter, tile_grid_size,
137 false, mode); 145 false, mode);
146 if (memory_used) {
147 // Verify we are recording the same thing each time.
148 DCHECK(memory_used == picture->ApproximateMemoryUsage());
149 } else {
150 memory_used = picture->ApproximateMemoryUsage();
151 }
152
138 timer.NextLap(); 153 timer.NextLap();
139 } while (!timer.HasTimeLimitExpired()); 154 } while (!timer.HasTimeLimitExpired());
140 base::TimeDelta duration = 155 base::TimeDelta duration =
141 base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); 156 base::TimeDelta::FromMillisecondsD(timer.MsPerLap());
142 if (duration < min_time) 157 if (duration < min_time)
143 min_time = duration; 158 min_time = duration;
144 memory_used = picture->ApproximateMemoryUsage();
145 } 159 }
146 160
147 if (mode == Picture::RECORD_NORMALLY) { 161 if (mode == Picture::RECORD_NORMALLY) {
148 record_results_.bytes_used += memory_used; 162 record_results_.bytes_used += memory_used;
149 record_results_.pixels_recorded += 163 record_results_.pixels_recorded +=
150 visible_content_rect.width() * visible_content_rect.height(); 164 visible_content_rect.width() * visible_content_rect.height();
151 } 165 }
152 record_results_.total_best_time[mode_index] += min_time; 166 record_results_.total_best_time[mode_index] += min_time;
153 } 167 }
154 } 168 }
155 169
170 void RasterizeAndRecordBenchmark::RunOnDisplayListLayer(PictureLayer* layer) {
171 ContentLayerClient* painter = layer->client();
172 gfx::Size content_bounds = layer->content_bounds();
173
174 DCHECK(host_ && host_->settings().use_display_lists);
175
176 gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect(
vmpstr 2015/01/23 20:03:06 nit: Can you make this calculation a separate func
177 layer->visible_content_rect(), 1.f / layer->contents_scale_x());
178 if (visible_content_rect.IsEmpty())
179 return;
180
181 // TODO(schenney): There is no real correspondence between the existing
182 // Picture::RecordingMode enum and DisplayItemList recording. We need to
183 // rethink it and create an appropriate set of modes.
184 base::TimeDelta min_time = base::TimeDelta::Max();
185 size_t memory_used = 0;
186
187 // Parameters for LapTimer.
188 const int kTimeLimitMillis = 1;
189 const int kWarmupRuns = 0;
190 const int kTimeCheckInterval = 1;
191
192 // TODO(schenney): What are the corresponding Picture::RecordingMode modes
193 // for Slimming Paint. We could disable SkPicture creation in
194 // DrawingDisplayItems, or we could only generate the display list and not
195 // do any work on it in the compositor, or something else, or all of the
196 // above.
197 scoped_refptr<DisplayItemList> display_list;
198 for (int i = 0; i < record_repeat_count_; ++i) {
199 // Run for a minimum amount of time to avoid problems with timer
200 // quantization when the layer is very small.
201 LapTimer timer(kWarmupRuns,
202 base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
203 kTimeCheckInterval);
204
205 do {
206 display_list = painter->PaintContentsToDisplayList(
ajuma 2015/01/23 20:10:19 Will this actually cause the display list to be re
207 visible_content_rect, ContentLayerClient::GRAPHICS_CONTEXT_ENABLED);
208
209 if (memory_used) {
210 // Verify we are recording the same thing each time.
211 DCHECK(memory_used == display_list->PictureMemoryUsage());
212 } else {
213 memory_used = display_list->PictureMemoryUsage();
214 }
215
216 timer.NextLap();
217 } while (!timer.HasTimeLimitExpired());
218 base::TimeDelta duration =
219 base::TimeDelta::FromMillisecondsD(timer.MsPerLap());
220 if (duration < min_time)
221 min_time = duration;
222 }
223
224 record_results_.bytes_used += memory_used;
225 record_results_.pixels_recorded +=
226 visible_content_rect.width() * visible_content_rect.height();
227 record_results_.total_best_time[Picture::RECORD_NORMALLY] += min_time;
228 }
229
156 RasterizeAndRecordBenchmark::RecordResults::RecordResults() 230 RasterizeAndRecordBenchmark::RecordResults::RecordResults()
157 : pixels_recorded(0), bytes_used(0) { 231 : pixels_recorded(0), bytes_used(0) {
232 for (int mode_index = 0; mode_index < Picture::RECORDING_MODE_COUNT;
233 mode_index++) {
234 total_best_time[mode_index] = base::TimeDelta();
235 }
158 } 236 }
159 237
160 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} 238 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {}
161 239
162 } // namespace cc 240 } // namespace cc
OLDNEW
« no previous file with comments | « cc/debug/rasterize_and_record_benchmark.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698