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

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

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed bad android build patch Created 5 years, 9 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 | « cc/debug/invalidation_benchmark.h ('k') | cc/debug/picture_record_benchmark.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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 << ". One of {fixed_size, layer, viewport, random} expected."; 57 << ". One of {fixed_size, layer, viewport, random} expected.";
58 } 58 }
59 } 59 }
60 60
61 InvalidationBenchmark::~InvalidationBenchmark() { 61 InvalidationBenchmark::~InvalidationBenchmark() {
62 } 62 }
63 63
64 void InvalidationBenchmark::DidUpdateLayers(LayerTreeHost* host) { 64 void InvalidationBenchmark::DidUpdateLayers(LayerTreeHost* host) {
65 LayerTreeHostCommon::CallFunctionForSubtree( 65 LayerTreeHostCommon::CallFunctionForSubtree(
66 host->root_layer(), 66 host->root_layer(),
67 base::Bind(&InvalidationBenchmark::Run, base::Unretained(this))); 67 [this](Layer* layer) { layer->RunMicroBenchmark(this); });
68 }
69
70 void InvalidationBenchmark::Run(Layer* layer) {
71 layer->RunMicroBenchmark(this);
72 } 68 }
73 69
74 void InvalidationBenchmark::RunOnLayer(PictureLayer* layer) { 70 void InvalidationBenchmark::RunOnLayer(PictureLayer* layer) {
75 switch (mode_) { 71 switch (mode_) {
76 case FIXED_SIZE: { 72 case FIXED_SIZE: {
77 // Invalidation with a random position and fixed size. 73 // Invalidation with a random position and fixed size.
78 gfx::Rect visible_content_rect = layer->visible_content_rect(); 74 gfx::Rect visible_content_rect = layer->visible_content_rect();
79 int x = LCGRandom() * (visible_content_rect.width() - width_); 75 int x = LCGRandom() * (visible_content_rect.width() - width_);
80 int y = LCGRandom() * (visible_content_rect.height() - height_); 76 int y = LCGRandom() * (visible_content_rect.height() - height_);
81 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
130 // 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
131 // LCG and keep the state locally in the benchmark. 127 // LCG and keep the state locally in the benchmark.
132 float InvalidationBenchmark::LCGRandom() { 128 float InvalidationBenchmark::LCGRandom() {
133 const uint32 a = 1664525; 129 const uint32 a = 1664525;
134 const uint32 c = 1013904223; 130 const uint32 c = 1013904223;
135 seed_ = a * seed_ + c; 131 seed_ = a * seed_ + c;
136 return static_cast<float>(seed_) / std::numeric_limits<uint32>::max(); 132 return static_cast<float>(seed_) / std::numeric_limits<uint32>::max();
137 } 133 }
138 134
139 } // namespace cc 135 } // namespace cc
OLDNEW
« no previous file with comments | « cc/debug/invalidation_benchmark.h ('k') | cc/debug/picture_record_benchmark.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698