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

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

Issue 643583003: [C++11 Allowed Features] Declares a type-safe null pointer converting from NULL to nullptr in src/… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: foramted. Created 6 years, 2 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
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 10 matching lines...) Expand all
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
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", &notify_done); 121 message->GetBoolean("notify_done", &notify_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
OLDNEW
« no previous file with comments | « cc/blink/web_layer_impl.cc ('k') | cc/debug/micro_benchmark.cc » ('j') | cc/layers/layer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698