Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: cc/debug/invalidation_benchmark.cc

Issue 2225973003: cc: Remove usage of ComputeVisibleRects on main thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and fix perf regressions Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cc/layers/layer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
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 gfx::Rect visible_layer_rect = gfx::Rect(layer->bounds());
73 LayerList update_list; 73 gfx::Transform from_screen;
74 update_list.push_back(layer); 74 bool invertible = layer->screen_space_transform().GetInverse(&from_screen);
75 draw_property_utils::ComputeVisibleRectsForTesting( 75 if (!invertible)
76 property_trees, property_trees->non_root_surfaces_enabled, &update_list); 76 from_screen = gfx::Transform();
77 gfx::Rect visible_layer_rect = layer->visible_layer_rect_for_testing(); 77 gfx::Rect viewport_rect = MathUtil::ProjectEnclosingClippedRect(
78 from_screen, gfx::Rect(layer->layer_tree_host()->device_viewport_size()));
79 visible_layer_rect.Intersect(viewport_rect);
78 switch (mode_) { 80 switch (mode_) {
79 case FIXED_SIZE: { 81 case FIXED_SIZE: {
80 // Invalidation with a random position and fixed size. 82 // Invalidation with a random position and fixed size.
81 int x = LCGRandom() * (visible_layer_rect.width() - width_); 83 int x = LCGRandom() * (visible_layer_rect.width() - width_);
82 int y = LCGRandom() * (visible_layer_rect.height() - height_); 84 int y = LCGRandom() * (visible_layer_rect.height() - height_);
83 gfx::Rect invalidation_rect(x, y, width_, height_); 85 gfx::Rect invalidation_rect(x, y, width_, height_);
84 layer->SetNeedsDisplayRect(invalidation_rect); 86 layer->SetNeedsDisplayRect(invalidation_rect);
85 break; 87 break;
86 } 88 }
87 case LAYER: { 89 case LAYER: {
(...skipping 10 matching lines...) Expand all
98 if (x_min > x_max) 100 if (x_min > x_max)
99 std::swap(x_min, x_max); 101 std::swap(x_min, x_max);
100 if (y_min > y_max) 102 if (y_min > y_max)
101 std::swap(y_min, y_max); 103 std::swap(y_min, y_max);
102 gfx::Rect invalidation_rect(x_min, y_min, x_max - x_min, y_max - y_min); 104 gfx::Rect invalidation_rect(x_min, y_min, x_max - x_min, y_max - y_min);
103 layer->SetNeedsDisplayRect(invalidation_rect); 105 layer->SetNeedsDisplayRect(invalidation_rect);
104 break; 106 break;
105 } 107 }
106 case VIEWPORT: { 108 case VIEWPORT: {
107 // Invalidate entire viewport. 109 // Invalidate entire viewport.
108 layer->SetNeedsDisplayRect(layer->visible_layer_rect_for_testing()); 110 layer->SetNeedsDisplayRect(visible_layer_rect);
109 break; 111 break;
110 } 112 }
111 } 113 }
112 } 114 }
113 115
114 bool InvalidationBenchmark::ProcessMessage(std::unique_ptr<base::Value> value) { 116 bool InvalidationBenchmark::ProcessMessage(std::unique_ptr<base::Value> value) {
115 base::DictionaryValue* message = nullptr; 117 base::DictionaryValue* message = nullptr;
116 value->GetAsDictionary(&message); 118 value->GetAsDictionary(&message);
117 if (!message) 119 if (!message)
118 return false; 120 return false;
(...skipping 12 matching lines...) Expand all
131 // high quality, but they need to be identical in each run. Therefore, we use a 133 // 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. 134 // LCG and keep the state locally in the benchmark.
133 float InvalidationBenchmark::LCGRandom() { 135 float InvalidationBenchmark::LCGRandom() {
134 const uint32_t a = 1664525; 136 const uint32_t a = 1664525;
135 const uint32_t c = 1013904223; 137 const uint32_t c = 1013904223;
136 seed_ = a * seed_ + c; 138 seed_ = a * seed_ + c;
137 return static_cast<float>(seed_) / std::numeric_limits<uint32_t>::max(); 139 return static_cast<float>(seed_) / std::numeric_limits<uint32_t>::max();
138 } 140 }
139 141
140 } // namespace cc 142 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layers/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698