| OLD | NEW |
| 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 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 | 59 |
| 60 RasterizeAndRecordBenchmark::~RasterizeAndRecordBenchmark() { | 60 RasterizeAndRecordBenchmark::~RasterizeAndRecordBenchmark() { |
| 61 weak_ptr_factory_.InvalidateWeakPtrs(); | 61 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void RasterizeAndRecordBenchmark::DidUpdateLayers(LayerTreeHost* host) { | 64 void RasterizeAndRecordBenchmark::DidUpdateLayers(LayerTreeHost* host) { |
| 65 host_ = host; | 65 host_ = host; |
| 66 LayerTreeHostCommon::CallFunctionForSubtree( | 66 LayerTreeHostCommon::CallFunctionForSubtree( |
| 67 host->root_layer(), | 67 host->root_layer(), |
| 68 base::Bind(&RasterizeAndRecordBenchmark::Run, base::Unretained(this))); | 68 [this](Layer* layer) { layer->RunMicroBenchmark(this); }); |
| 69 | 69 |
| 70 DCHECK(!results_.get()); | 70 DCHECK(!results_.get()); |
| 71 results_ = make_scoped_ptr(new base::DictionaryValue); | 71 results_ = make_scoped_ptr(new base::DictionaryValue); |
| 72 results_->SetInteger("pixels_recorded", record_results_.pixels_recorded); | 72 results_->SetInteger("pixels_recorded", record_results_.pixels_recorded); |
| 73 results_->SetInteger("picture_memory_usage", record_results_.bytes_used); | 73 results_->SetInteger("picture_memory_usage", record_results_.bytes_used); |
| 74 | 74 |
| 75 for (int i = 0; i < RecordingSource::RECORDING_MODE_COUNT; i++) { | 75 for (int i = 0; i < RecordingSource::RECORDING_MODE_COUNT; i++) { |
| 76 std::string name = base::StringPrintf("record_time%s_ms", kModeSuffixes[i]); | 76 std::string name = base::StringPrintf("record_time%s_ms", kModeSuffixes[i]); |
| 77 results_->SetDouble(name, | 77 results_->SetDouble(name, |
| 78 record_results_.total_best_time[i].InMillisecondsF()); | 78 record_results_.total_best_time[i].InMillisecondsF()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 95 | 95 |
| 96 scoped_ptr<MicroBenchmarkImpl> RasterizeAndRecordBenchmark::CreateBenchmarkImpl( | 96 scoped_ptr<MicroBenchmarkImpl> RasterizeAndRecordBenchmark::CreateBenchmarkImpl( |
| 97 scoped_refptr<base::MessageLoopProxy> origin_loop) { | 97 scoped_refptr<base::MessageLoopProxy> origin_loop) { |
| 98 return make_scoped_ptr(new RasterizeAndRecordBenchmarkImpl( | 98 return make_scoped_ptr(new RasterizeAndRecordBenchmarkImpl( |
| 99 origin_loop, | 99 origin_loop, |
| 100 settings_.get(), | 100 settings_.get(), |
| 101 base::Bind(&RasterizeAndRecordBenchmark::RecordRasterResults, | 101 base::Bind(&RasterizeAndRecordBenchmark::RecordRasterResults, |
| 102 weak_ptr_factory_.GetWeakPtr()))); | 102 weak_ptr_factory_.GetWeakPtr()))); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void RasterizeAndRecordBenchmark::Run(Layer* layer) { | |
| 106 layer->RunMicroBenchmark(this); | |
| 107 } | |
| 108 | |
| 109 void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { | 105 void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { |
| 110 DCHECK(host_); | 106 DCHECK(host_); |
| 111 | 107 |
| 112 gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect( | 108 gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect( |
| 113 layer->visible_content_rect(), 1.f / layer->contents_scale_x()); | 109 layer->visible_content_rect(), 1.f / layer->contents_scale_x()); |
| 114 if (visible_content_rect.IsEmpty()) | 110 if (visible_content_rect.IsEmpty()) |
| 115 return; | 111 return; |
| 116 | 112 |
| 117 if (host_->settings().use_display_lists) { | 113 if (host_->settings().use_display_lists) { |
| 118 RunOnDisplayListLayer(layer, visible_content_rect); | 114 RunOnDisplayListLayer(layer, visible_content_rect); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 } | 232 } |
| 237 } | 233 } |
| 238 | 234 |
| 239 RasterizeAndRecordBenchmark::RecordResults::RecordResults() | 235 RasterizeAndRecordBenchmark::RecordResults::RecordResults() |
| 240 : pixels_recorded(0), bytes_used(0) { | 236 : pixels_recorded(0), bytes_used(0) { |
| 241 } | 237 } |
| 242 | 238 |
| 243 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} | 239 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} |
| 244 | 240 |
| 245 } // namespace cc | 241 } // namespace cc |
| OLD | NEW |