| 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> |
| 11 | 11 |
| 12 #include "base/memory/ptr_util.h" |
| 12 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 13 #include "base/values.h" | 14 #include "base/values.h" |
| 14 #include "cc/layers/layer.h" | 15 #include "cc/layers/layer.h" |
| 15 #include "cc/layers/picture_layer.h" | 16 #include "cc/layers/picture_layer.h" |
| 16 #include "cc/trees/draw_property_utils.h" | 17 #include "cc/trees/draw_property_utils.h" |
| 17 #include "cc/trees/layer_tree_host.h" | 18 #include "cc/trees/layer_tree_host.h" |
| 18 #include "cc/trees/layer_tree_host_common.h" | 19 #include "cc/trees/layer_tree_host_common.h" |
| 19 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
| 20 | 21 |
| 21 namespace cc { | 22 namespace cc { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 bool InvalidationBenchmark::ProcessMessage(std::unique_ptr<base::Value> value) { | 117 bool InvalidationBenchmark::ProcessMessage(std::unique_ptr<base::Value> value) { |
| 117 base::DictionaryValue* message = nullptr; | 118 base::DictionaryValue* message = nullptr; |
| 118 value->GetAsDictionary(&message); | 119 value->GetAsDictionary(&message); |
| 119 if (!message) | 120 if (!message) |
| 120 return false; | 121 return false; |
| 121 | 122 |
| 122 bool notify_done; | 123 bool notify_done; |
| 123 if (message->HasKey("notify_done")) { | 124 if (message->HasKey("notify_done")) { |
| 124 message->GetBoolean("notify_done", ¬ify_done); | 125 message->GetBoolean("notify_done", ¬ify_done); |
| 125 if (notify_done) | 126 if (notify_done) |
| 126 NotifyDone(base::Value::CreateNullValue()); | 127 NotifyDone(base::MakeUnique<base::Value>()); |
| 127 return true; | 128 return true; |
| 128 } | 129 } |
| 129 return false; | 130 return false; |
| 130 } | 131 } |
| 131 | 132 |
| 132 // A simple linear congruential generator. The random numbers don't need to be | 133 // A simple linear congruential generator. The random numbers don't need to be |
| 133 // 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 |
| 134 // LCG and keep the state locally in the benchmark. | 135 // LCG and keep the state locally in the benchmark. |
| 135 float InvalidationBenchmark::LCGRandom() { | 136 float InvalidationBenchmark::LCGRandom() { |
| 136 const uint32_t a = 1664525; | 137 const uint32_t a = 1664525; |
| 137 const uint32_t c = 1013904223; | 138 const uint32_t c = 1013904223; |
| 138 seed_ = a * seed_ + c; | 139 seed_ = a * seed_ + c; |
| 139 return static_cast<float>(seed_) / std::numeric_limits<uint32_t>::max(); | 140 return static_cast<float>(seed_) / std::numeric_limits<uint32_t>::max(); |
| 140 } | 141 } |
| 141 | 142 |
| 142 } // namespace cc | 143 } // namespace cc |
| OLD | NEW |