| 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/benchmarks/invalidation_benchmark.h" | 5 #include "cc/benchmarks/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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 void InvalidationBenchmark::DidUpdateLayers(LayerTreeHost* layer_tree_host) { | 66 void InvalidationBenchmark::DidUpdateLayers(LayerTreeHost* layer_tree_host) { |
| 67 LayerTreeHostCommon::CallFunctionForEveryLayer( | 67 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 68 layer_tree_host, | 68 layer_tree_host, |
| 69 [this](Layer* layer) { layer->RunMicroBenchmark(this); }); | 69 [this](Layer* layer) { layer->RunMicroBenchmark(this); }); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void InvalidationBenchmark::RunOnLayer(PictureLayer* layer) { | 72 void InvalidationBenchmark::RunOnLayer(PictureLayer* layer) { |
| 73 gfx::Rect visible_layer_rect = gfx::Rect(layer->bounds()); | 73 gfx::Rect visible_layer_rect = gfx::Rect(layer->bounds()); |
| 74 gfx::Transform from_screen; | 74 gfx::Transform from_screen; |
| 75 bool invertible = layer->screen_space_transform().GetInverse(&from_screen); | 75 bool invertible = layer->ScreenSpaceTransform().GetInverse(&from_screen); |
| 76 if (!invertible) | 76 if (!invertible) |
| 77 from_screen = gfx::Transform(); | 77 from_screen = gfx::Transform(); |
| 78 gfx::Rect viewport_rect = MathUtil::ProjectEnclosingClippedRect( | 78 gfx::Rect viewport_rect = MathUtil::ProjectEnclosingClippedRect( |
| 79 from_screen, gfx::Rect(layer->layer_tree_host()->device_viewport_size())); | 79 from_screen, gfx::Rect(layer->layer_tree_host()->device_viewport_size())); |
| 80 visible_layer_rect.Intersect(viewport_rect); | 80 visible_layer_rect.Intersect(viewport_rect); |
| 81 switch (mode_) { | 81 switch (mode_) { |
| 82 case FIXED_SIZE: { | 82 case FIXED_SIZE: { |
| 83 // Invalidation with a random position and fixed size. | 83 // Invalidation with a random position and fixed size. |
| 84 int x = LCGRandom() * (visible_layer_rect.width() - width_); | 84 int x = LCGRandom() * (visible_layer_rect.width() - width_); |
| 85 int y = LCGRandom() * (visible_layer_rect.height() - height_); | 85 int y = LCGRandom() * (visible_layer_rect.height() - height_); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // high quality, but they need to be identical in each run. Therefore, we use a | 134 // high quality, but they need to be identical in each run. Therefore, we use a |
| 135 // LCG and keep the state locally in the benchmark. | 135 // LCG and keep the state locally in the benchmark. |
| 136 float InvalidationBenchmark::LCGRandom() { | 136 float InvalidationBenchmark::LCGRandom() { |
| 137 const uint32_t a = 1664525; | 137 const uint32_t a = 1664525; |
| 138 const uint32_t c = 1013904223; | 138 const uint32_t c = 1013904223; |
| 139 seed_ = a * seed_ + c; | 139 seed_ = a * seed_ + c; |
| 140 return static_cast<float>(seed_) / std::numeric_limits<uint32_t>::max(); | 140 return static_cast<float>(seed_) / std::numeric_limits<uint32_t>::max(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 } // namespace cc | 143 } // namespace cc |
| OLD | NEW |