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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace { | 21 namespace { |
22 | 22 |
23 const char* kDefaultInvalidationMode = "viewport"; | 23 const char* kDefaultInvalidationMode = "viewport"; |
24 | 24 |
25 } // namespace | 25 } // namespace |
26 | 26 |
27 InvalidationBenchmark::InvalidationBenchmark( | 27 InvalidationBenchmark::InvalidationBenchmark( |
28 scoped_ptr<base::Value> value, | 28 scoped_ptr<base::Value> value, |
29 const MicroBenchmark::DoneCallback& callback) | 29 const MicroBenchmark::DoneCallback& callback) |
30 : MicroBenchmark(callback), seed_(0) { | 30 : MicroBenchmark(callback), seed_(0) { |
31 base::DictionaryValue* settings = NULL; | 31 base::DictionaryValue* settings = nullptr; |
32 value->GetAsDictionary(&settings); | 32 value->GetAsDictionary(&settings); |
33 if (!settings) | 33 if (!settings) |
34 return; | 34 return; |
35 | 35 |
36 std::string mode_string = kDefaultInvalidationMode; | 36 std::string mode_string = kDefaultInvalidationMode; |
37 | 37 |
38 if (settings->HasKey("mode")) | 38 if (settings->HasKey("mode")) |
39 settings->GetString("mode", &mode_string); | 39 settings->GetString("mode", &mode_string); |
40 | 40 |
41 if (mode_string == "fixed_size") { | 41 if (mode_string == "fixed_size") { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } | 104 } |
105 case VIEWPORT: { | 105 case VIEWPORT: { |
106 // Invalidate entire viewport. | 106 // Invalidate entire viewport. |
107 layer->SetNeedsDisplayRect(layer->visible_content_rect()); | 107 layer->SetNeedsDisplayRect(layer->visible_content_rect()); |
108 break; | 108 break; |
109 } | 109 } |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 bool InvalidationBenchmark::ProcessMessage(scoped_ptr<base::Value> value) { | 113 bool InvalidationBenchmark::ProcessMessage(scoped_ptr<base::Value> value) { |
114 base::DictionaryValue* message = NULL; | 114 base::DictionaryValue* message = nullptr; |
115 value->GetAsDictionary(&message); | 115 value->GetAsDictionary(&message); |
116 if (!message) | 116 if (!message) |
117 return false; | 117 return false; |
118 | 118 |
119 bool notify_done; | 119 bool notify_done; |
120 if (message->HasKey("notify_done")) { | 120 if (message->HasKey("notify_done")) { |
121 message->GetBoolean("notify_done", ¬ify_done); | 121 message->GetBoolean("notify_done", ¬ify_done); |
122 if (notify_done) | 122 if (notify_done) |
123 NotifyDone(scoped_ptr<base::Value>(base::Value::CreateNullValue())); | 123 NotifyDone(scoped_ptr<base::Value>(base::Value::CreateNullValue())); |
124 return true; | 124 return true; |
125 } | 125 } |
126 return false; | 126 return false; |
127 } | 127 } |
128 | 128 |
129 // A simple linear congruential generator. The random numbers don't need to be | 129 // A simple linear congruential generator. The random numbers don't need to be |
130 // high quality, but they need to be identical in each run. Therefore, we use a | 130 // 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. | 131 // LCG and keep the state locally in the benchmark. |
132 float InvalidationBenchmark::LCGRandom() { | 132 float InvalidationBenchmark::LCGRandom() { |
133 const uint32 a = 1664525; | 133 const uint32 a = 1664525; |
134 const uint32 c = 1013904223; | 134 const uint32 c = 1013904223; |
135 seed_ = a * seed_ + c; | 135 seed_ = a * seed_ + c; |
136 return static_cast<float>(seed_) / std::numeric_limits<uint32>::max(); | 136 return static_cast<float>(seed_) / std::numeric_limits<uint32>::max(); |
137 } | 137 } |
138 | 138 |
139 } // namespace cc | 139 } // namespace cc |
OLD | NEW |