| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 } else { | 56 } else { |
| 57 CHECK(false) << "Invalid mode: " << mode_string | 57 CHECK(false) << "Invalid mode: " << mode_string |
| 58 << ". One of {fixed_size, layer, viewport, random} expected."; | 58 << ". One of {fixed_size, layer, viewport, random} expected."; |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 InvalidationBenchmark::~InvalidationBenchmark() { | 62 InvalidationBenchmark::~InvalidationBenchmark() { |
| 63 } | 63 } |
| 64 | 64 |
| 65 void InvalidationBenchmark::DidUpdateLayers(LayerTreeHost* host) { | 65 void InvalidationBenchmark::DidUpdateLayers(LayerTreeHost* host) { |
| 66 LayerTreeHostCommon::CallFunctionForSubtree( | 66 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 67 host->root_layer(), | 67 host, [this](Layer* layer) { layer->RunMicroBenchmark(this); }); |
| 68 [this](Layer* layer) { layer->RunMicroBenchmark(this); }); | |
| 69 } | 68 } |
| 70 | 69 |
| 71 void InvalidationBenchmark::RunOnLayer(PictureLayer* layer) { | 70 void InvalidationBenchmark::RunOnLayer(PictureLayer* layer) { |
| 72 switch (mode_) { | 71 switch (mode_) { |
| 73 case FIXED_SIZE: { | 72 case FIXED_SIZE: { |
| 74 // Invalidation with a random position and fixed size. | 73 // Invalidation with a random position and fixed size. |
| 75 gfx::Rect visible_layer_rect = layer->visible_layer_rect(); | 74 gfx::Rect visible_layer_rect = layer->visible_layer_rect(); |
| 76 int x = LCGRandom() * (visible_layer_rect.width() - width_); | 75 int x = LCGRandom() * (visible_layer_rect.width() - width_); |
| 77 int y = LCGRandom() * (visible_layer_rect.height() - height_); | 76 int y = LCGRandom() * (visible_layer_rect.height() - height_); |
| 78 gfx::Rect invalidation_rect(x, y, width_, height_); | 77 gfx::Rect invalidation_rect(x, y, width_, height_); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // high quality, but they need to be identical in each run. Therefore, we use a | 126 // high quality, but they need to be identical in each run. Therefore, we use a |
| 128 // LCG and keep the state locally in the benchmark. | 127 // LCG and keep the state locally in the benchmark. |
| 129 float InvalidationBenchmark::LCGRandom() { | 128 float InvalidationBenchmark::LCGRandom() { |
| 130 const uint32_t a = 1664525; | 129 const uint32_t a = 1664525; |
| 131 const uint32_t c = 1013904223; | 130 const uint32_t c = 1013904223; |
| 132 seed_ = a * seed_ + c; | 131 seed_ = a * seed_ + c; |
| 133 return static_cast<float>(seed_) / std::numeric_limits<uint32_t>::max(); | 132 return static_cast<float>(seed_) / std::numeric_limits<uint32_t>::max(); |
| 134 } | 133 } |
| 135 | 134 |
| 136 } // namespace cc | 135 } // namespace cc |
| OLD | NEW |