Chromium Code Reviews| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 InvalidationBenchmark::~InvalidationBenchmark() { | 63 InvalidationBenchmark::~InvalidationBenchmark() { |
| 64 } | 64 } |
| 65 | 65 |
| 66 void InvalidationBenchmark::DidUpdateLayers(LayerTreeHost* host) { | 66 void InvalidationBenchmark::DidUpdateLayers(LayerTreeHost* host) { |
| 67 LayerTreeHostCommon::CallFunctionForEveryLayer( | 67 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 68 host, [this](Layer* layer) { layer->RunMicroBenchmark(this); }); | 68 host, [this](Layer* layer) { layer->RunMicroBenchmark(this); }); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void InvalidationBenchmark::RunOnLayer(PictureLayer* layer) { | 71 void InvalidationBenchmark::RunOnLayer(PictureLayer* layer) { |
| 72 PropertyTrees* property_trees = layer->layer_tree_host()->property_trees(); | 72 PropertyTrees* property_trees = layer->layer_tree_host()->property_trees(); |
| 73 LayerList update_list; | 73 const TransformTree& transform_tree = property_trees->transform_tree; |
| 74 update_list.push_back(layer); | 74 int index = layer->transform_tree_index(); |
| 75 draw_property_utils::ComputeVisibleRectsForTesting( | 75 layer->layer_tree_host()->BuildPropertyTreesForTesting(); |
| 76 property_trees, property_trees->non_root_surfaces_enabled, &update_list); | 76 gfx::Point position = |
| 77 gfx::Rect visible_layer_rect = layer->visible_layer_rect_for_testing(); | 77 gfx::Point(layer->position().x(), layer->position().y()); |
| 78 gfx::Rect layer_rect = gfx::Rect(position, layer->bounds()); | |
| 79 gfx::Rect screen_space_rect = MathUtil::MapEnclosingClippedRect( | |
| 80 transform_tree.ToScreen(index), layer_rect); | |
| 81 screen_space_rect.Intersect( | |
| 82 gfx::Rect(layer->layer_tree_host()->device_viewport_size())); | |
| 83 gfx::Rect visible_layer_rect = MathUtil::MapEnclosingClippedRect( | |
|
sunxd
2016/08/09 19:17:50
I forgot to make it a projection here. Please igno
| |
| 84 transform_tree.FromScreen(index), screen_space_rect); | |
| 78 switch (mode_) { | 85 switch (mode_) { |
| 79 case FIXED_SIZE: { | 86 case FIXED_SIZE: { |
| 80 // Invalidation with a random position and fixed size. | 87 // Invalidation with a random position and fixed size. |
| 81 int x = LCGRandom() * (visible_layer_rect.width() - width_); | 88 int x = LCGRandom() * (visible_layer_rect.width() - width_); |
| 82 int y = LCGRandom() * (visible_layer_rect.height() - height_); | 89 int y = LCGRandom() * (visible_layer_rect.height() - height_); |
| 83 gfx::Rect invalidation_rect(x, y, width_, height_); | 90 gfx::Rect invalidation_rect(x, y, width_, height_); |
| 84 layer->SetNeedsDisplayRect(invalidation_rect); | 91 layer->SetNeedsDisplayRect(invalidation_rect); |
| 85 break; | 92 break; |
| 86 } | 93 } |
| 87 case LAYER: { | 94 case LAYER: { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 // high quality, but they need to be identical in each run. Therefore, we use a | 138 // high quality, but they need to be identical in each run. Therefore, we use a |
| 132 // LCG and keep the state locally in the benchmark. | 139 // LCG and keep the state locally in the benchmark. |
| 133 float InvalidationBenchmark::LCGRandom() { | 140 float InvalidationBenchmark::LCGRandom() { |
| 134 const uint32_t a = 1664525; | 141 const uint32_t a = 1664525; |
| 135 const uint32_t c = 1013904223; | 142 const uint32_t c = 1013904223; |
| 136 seed_ = a * seed_ + c; | 143 seed_ = a * seed_ + c; |
| 137 return static_cast<float>(seed_) / std::numeric_limits<uint32_t>::max(); | 144 return static_cast<float>(seed_) / std::numeric_limits<uint32_t>::max(); |
| 138 } | 145 } |
| 139 | 146 |
| 140 } // namespace cc | 147 } // namespace cc |
| OLD | NEW |