Index: cc/debug/rasterize_and_record_benchmark.cc |
diff --git a/cc/debug/rasterize_and_record_benchmark.cc b/cc/debug/rasterize_and_record_benchmark.cc |
index 51edc985a49338cdf619ea38121d53b380348b44..aec539fc87bfb0ab8cfc09290c754e838a4a6ad9 100644 |
--- a/cc/debug/rasterize_and_record_benchmark.cc |
+++ b/cc/debug/rasterize_and_record_benchmark.cc |
@@ -13,8 +13,10 @@ |
#include "base/values.h" |
#include "cc/debug/lap_timer.h" |
#include "cc/debug/rasterize_and_record_benchmark_impl.h" |
+#include "cc/layers/content_layer_client.h" |
#include "cc/layers/layer.h" |
#include "cc/layers/picture_layer.h" |
+#include "cc/resources/display_item_list.h" |
#include "cc/resources/picture_pile.h" |
#include "cc/trees/layer_tree_host.h" |
#include "cc/trees/layer_tree_host_common.h" |
@@ -106,6 +108,12 @@ void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { |
gfx::Size content_bounds = layer->content_bounds(); |
DCHECK(host_); |
+ |
+ if (host_->settings().use_display_lists) { |
+ RunOnDisplayListLayer(layer); |
ajuma
2015/01/23 20:10:19
Perhaps also define a RunOnPicturePileLayer for th
|
+ return; |
+ } |
+ |
gfx::Size tile_grid_size = host_->settings().default_tile_size; |
gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect( |
@@ -135,13 +143,19 @@ void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { |
do { |
picture = Picture::Create(visible_content_rect, painter, tile_grid_size, |
false, mode); |
+ if (memory_used) { |
+ // Verify we are recording the same thing each time. |
+ DCHECK(memory_used == picture->ApproximateMemoryUsage()); |
+ } else { |
+ memory_used = picture->ApproximateMemoryUsage(); |
+ } |
+ |
timer.NextLap(); |
} while (!timer.HasTimeLimitExpired()); |
base::TimeDelta duration = |
base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); |
if (duration < min_time) |
min_time = duration; |
- memory_used = picture->ApproximateMemoryUsage(); |
} |
if (mode == Picture::RECORD_NORMALLY) { |
@@ -153,8 +167,72 @@ void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { |
} |
} |
+void RasterizeAndRecordBenchmark::RunOnDisplayListLayer(PictureLayer* layer) { |
+ ContentLayerClient* painter = layer->client(); |
+ gfx::Size content_bounds = layer->content_bounds(); |
+ |
+ DCHECK(host_ && host_->settings().use_display_lists); |
+ |
+ gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect( |
vmpstr
2015/01/23 20:03:06
nit: Can you make this calculation a separate func
|
+ layer->visible_content_rect(), 1.f / layer->contents_scale_x()); |
+ if (visible_content_rect.IsEmpty()) |
+ return; |
+ |
+ // TODO(schenney): There is no real correspondence between the existing |
+ // Picture::RecordingMode enum and DisplayItemList recording. We need to |
+ // rethink it and create an appropriate set of modes. |
+ base::TimeDelta min_time = base::TimeDelta::Max(); |
+ size_t memory_used = 0; |
+ |
+ // Parameters for LapTimer. |
+ const int kTimeLimitMillis = 1; |
+ const int kWarmupRuns = 0; |
+ const int kTimeCheckInterval = 1; |
+ |
+ // TODO(schenney): What are the corresponding Picture::RecordingMode modes |
+ // for Slimming Paint. We could disable SkPicture creation in |
+ // DrawingDisplayItems, or we could only generate the display list and not |
+ // do any work on it in the compositor, or something else, or all of the |
+ // above. |
+ scoped_refptr<DisplayItemList> display_list; |
+ for (int i = 0; i < record_repeat_count_; ++i) { |
+ // Run for a minimum amount of time to avoid problems with timer |
+ // quantization when the layer is very small. |
+ LapTimer timer(kWarmupRuns, |
+ base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
+ kTimeCheckInterval); |
+ |
+ do { |
+ display_list = painter->PaintContentsToDisplayList( |
ajuma
2015/01/23 20:10:19
Will this actually cause the display list to be re
|
+ visible_content_rect, ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); |
+ |
+ if (memory_used) { |
+ // Verify we are recording the same thing each time. |
+ DCHECK(memory_used == display_list->PictureMemoryUsage()); |
+ } else { |
+ memory_used = display_list->PictureMemoryUsage(); |
+ } |
+ |
+ timer.NextLap(); |
+ } while (!timer.HasTimeLimitExpired()); |
+ base::TimeDelta duration = |
+ base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); |
+ if (duration < min_time) |
+ min_time = duration; |
+ } |
+ |
+ record_results_.bytes_used += memory_used; |
+ record_results_.pixels_recorded += |
+ visible_content_rect.width() * visible_content_rect.height(); |
+ record_results_.total_best_time[Picture::RECORD_NORMALLY] += min_time; |
+} |
+ |
RasterizeAndRecordBenchmark::RecordResults::RecordResults() |
: pixels_recorded(0), bytes_used(0) { |
+ for (int mode_index = 0; mode_index < Picture::RECORDING_MODE_COUNT; |
+ mode_index++) { |
+ total_best_time[mode_index] = base::TimeDelta(); |
+ } |
} |
RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} |