| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/invalidation_benchmark.h" | 5 #include "cc/debug/invalidation_benchmark.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 if (!settings) | 35 if (!settings) |
| 36 return; | 36 return; |
| 37 | 37 |
| 38 std::string mode_string = kDefaultInvalidationMode; | 38 std::string mode_string = kDefaultInvalidationMode; |
| 39 | 39 |
| 40 if (settings->HasKey("mode")) | 40 if (settings->HasKey("mode")) |
| 41 settings->GetString("mode", &mode_string); | 41 settings->GetString("mode", &mode_string); |
| 42 | 42 |
| 43 if (mode_string == "fixed_size") { | 43 if (mode_string == "fixed_size") { |
| 44 mode_ = FIXED_SIZE; | 44 mode_ = FIXED_SIZE; |
| 45 CHECK(settings->HasKey("width")) | 45 // Must provide a width for fixed_size mode. |
| 46 << "Must provide a width for fixed_size mode."; | 46 CHECK(settings->HasKey("width")); |
| 47 CHECK(settings->HasKey("height")) | 47 // Must provide a height for fixed_size mode. |
| 48 << "Must provide a height for fixed_size mode."; | 48 CHECK(settings->HasKey("height")); |
| 49 settings->GetInteger("width", &width_); | 49 settings->GetInteger("width", &width_); |
| 50 settings->GetInteger("height", &height_); | 50 settings->GetInteger("height", &height_); |
| 51 } else if (mode_string == "layer") { | 51 } else if (mode_string == "layer") { |
| 52 mode_ = LAYER; | 52 mode_ = LAYER; |
| 53 } else if (mode_string == "random") { | 53 } else if (mode_string == "random") { |
| 54 mode_ = RANDOM; | 54 mode_ = RANDOM; |
| 55 } else if (mode_string == "viewport") { | 55 } else if (mode_string == "viewport") { |
| 56 mode_ = VIEWPORT; | 56 mode_ = VIEWPORT; |
| 57 } else { | 57 } else { |
| 58 CHECK(false) << "Invalid mode: " << mode_string | 58 CHECK(false); |
| 59 << ". One of {fixed_size, layer, viewport, random} expected."; | |
| 60 } | 59 } |
| 61 } | 60 } |
| 62 | 61 |
| 63 InvalidationBenchmark::~InvalidationBenchmark() { | 62 InvalidationBenchmark::~InvalidationBenchmark() { |
| 64 } | 63 } |
| 65 | 64 |
| 66 void InvalidationBenchmark::DidUpdateLayers(LayerTree* layer_tree) { | 65 void InvalidationBenchmark::DidUpdateLayers(LayerTree* layer_tree) { |
| 67 LayerTreeHostCommon::CallFunctionForEveryLayer( | 66 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 68 layer_tree, [this](Layer* layer) { layer->RunMicroBenchmark(this); }); | 67 layer_tree, [this](Layer* layer) { layer->RunMicroBenchmark(this); }); |
| 69 } | 68 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // high quality, but they need to be identical in each run. Therefore, we use a | 132 // high quality, but they need to be identical in each run. Therefore, we use a |
| 134 // LCG and keep the state locally in the benchmark. | 133 // LCG and keep the state locally in the benchmark. |
| 135 float InvalidationBenchmark::LCGRandom() { | 134 float InvalidationBenchmark::LCGRandom() { |
| 136 const uint32_t a = 1664525; | 135 const uint32_t a = 1664525; |
| 137 const uint32_t c = 1013904223; | 136 const uint32_t c = 1013904223; |
| 138 seed_ = a * seed_ + c; | 137 seed_ = a * seed_ + c; |
| 139 return static_cast<float>(seed_) / std::numeric_limits<uint32_t>::max(); | 138 return static_cast<float>(seed_) / std::numeric_limits<uint32_t>::max(); |
| 140 } | 139 } |
| 141 | 140 |
| 142 } // namespace cc | 141 } // namespace cc |
| OLD | NEW |