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

Side by Side Diff: cc/heads_up_display_layer_impl.cc

Issue 11817011: cc: add RingBuffer class for timestamp storing in FrameRateCounter (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: size_t for buffer size, index and loops Created 7 years, 11 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/heads_up_display_layer_impl.h" 5 #include "cc/heads_up_display_layer_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "cc/debug_colors.h" 10 #include "cc/debug_colors.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 207
208 drawFPSCounterText(canvas, paint, fpsCounter, textBounds); 208 drawFPSCounterText(canvas, paint, fpsCounter, textBounds);
209 drawFPSCounterGraphAndHistogram(canvas, paint, fpsCounter, graphBounds, hist ogramBounds); 209 drawFPSCounterGraphAndHistogram(canvas, paint, fpsCounter, graphBounds, hist ogramBounds);
210 210
211 return top + height; 211 return top + height;
212 } 212 }
213 213
214 void HeadsUpDisplayLayerImpl::drawFPSCounterText(SkCanvas* canvas, SkPaint& pain t, FrameRateCounter* fpsCounter, SkRect bounds) 214 void HeadsUpDisplayLayerImpl::drawFPSCounterText(SkCanvas* canvas, SkPaint& pain t, FrameRateCounter* fpsCounter, SkRect bounds)
215 { 215 {
216 // Update FPS text - not every frame so text is readable 216 // Update FPS text - not every frame so text is readable
217 if (base::TimeDelta(fpsCounter->timeStampOfRecentFrame(0) - textUpdateTime). InSecondsF() > 0.25) { 217 base::TimeTicks now = base::TimeTicks::Now();
218 if (base::TimeDelta(now - textUpdateTime).InSecondsF() > 0.25) {
218 m_averageFPS = fpsCounter->getAverageFPS(); 219 m_averageFPS = fpsCounter->getAverageFPS();
219 textUpdateTime = fpsCounter->timeStampOfRecentFrame(0); 220 textUpdateTime = now;
220 } 221 }
221 222
222 // Draw FPS text. 223 // Draw FPS text.
223 if (m_fontAtlas.get()) { 224 if (m_fontAtlas.get()) {
224 std::string fpsText = base::StringPrintf("FPS:%5.1f", m_averageFPS); 225 std::string fpsText = base::StringPrintf("FPS:%5.1f", m_averageFPS);
225 std::string minMaxText = base::StringPrintf("%.0f-%.0f", std::min( m_min FPS, m_maxFPS), m_maxFPS); 226 std::string minMaxText = base::StringPrintf("%.0f-%.0f", std::min( m_min FPS, m_maxFPS), m_maxFPS);
226 227
227 int minMaxWidth = m_fontAtlas->textSize(minMaxText).width(); 228 int minMaxWidth = m_fontAtlas->textSize(minMaxText).width();
228 gfx::Size textArea(bounds.width(), bounds.height()); 229 gfx::Size textArea(bounds.width(), bounds.height());
229 230
(...skipping 22 matching lines...) Expand all
252 int x = 0; 253 int x = 0;
253 SkPath path; 254 SkPath path;
254 255
255 m_minFPS = std::numeric_limits<double>::max(); 256 m_minFPS = std::numeric_limits<double>::max();
256 m_maxFPS = 0; 257 m_maxFPS = 0;
257 258
258 const int histogramSize = 20; 259 const int histogramSize = 20;
259 double histogram[histogramSize] = {0}; 260 double histogram[histogramSize] = {0};
260 double maxBucketValue = 0; 261 double maxBucketValue = 0;
261 262
262 for (int i = 1; i < fpsCounter->timeStampHistorySize() - 1; ++i) { 263 for (size_t i = 1; i < fpsCounter->timeStampHistorySize() - 1; ++i) {
263 base::TimeDelta delta = fpsCounter->timeStampOfRecentFrame(i + 1) - fpsC ounter->timeStampOfRecentFrame(i); 264 base::TimeDelta delta = fpsCounter->timeStampOfRecentFrame(i + 1) - fpsC ounter->timeStampOfRecentFrame(i);
264 265
265 // Skip this particular instantaneous frame rate if it is not likely to have been valid. 266 // Skip this particular instantaneous frame rate if it is not likely to have been valid.
266 if (!fpsCounter->isBadFrameInterval(delta)) { 267 if (!fpsCounter->isBadFrameInterval(delta)) {
267 268
268 double fps = 1.0 / delta.InSecondsF(); 269 double fps = 1.0 / delta.InSecondsF();
269 270
270 m_minFPS = std::min(fps, m_minFPS); 271 m_minFPS = std::min(fps, m_minFPS);
271 m_maxFPS = std::max(fps, m_maxFPS); 272 m_maxFPS = std::max(fps, m_maxFPS);
272 273
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 384
384 canvas->restore(); 385 canvas->restore();
385 } 386 }
386 387
387 const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const 388 const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const
388 { 389 {
389 return "HeadsUpDisplayLayer"; 390 return "HeadsUpDisplayLayer";
390 } 391 }
391 392
392 } // namespace cc 393 } // namespace cc
OLDNEW
« no previous file with comments | « cc/frame_rate_counter.cc ('k') | cc/layer_tree_host_impl.cc » ('j') | cc/ring_buffer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698