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

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: cleaner test fix 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
« no previous file with comments | « cc/frame_rate_counter.cc ('k') | cc/layer_tree_host_impl.cc » ('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 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 208
209 drawFPSCounterText(canvas, paint, fpsCounter, textBounds); 209 drawFPSCounterText(canvas, paint, fpsCounter, textBounds);
210 drawFPSCounterGraphAndHistogram(canvas, paint, fpsCounter, graphBounds, hist ogramBounds); 210 drawFPSCounterGraphAndHistogram(canvas, paint, fpsCounter, graphBounds, hist ogramBounds);
211 211
212 return top + height; 212 return top + height;
213 } 213 }
214 214
215 void HeadsUpDisplayLayerImpl::drawFPSCounterText(SkCanvas* canvas, SkPaint& pain t, FrameRateCounter* fpsCounter, SkRect bounds) 215 void HeadsUpDisplayLayerImpl::drawFPSCounterText(SkCanvas* canvas, SkPaint& pain t, FrameRateCounter* fpsCounter, SkRect bounds)
216 { 216 {
217 // Update FPS text - not every frame so text is readable 217 // Update FPS text - not every frame so text is readable
218 if (base::TimeDelta(fpsCounter->timeStampOfRecentFrame(0) - textUpdateTime). InSecondsF() > 0.25) { 218 base::TimeTicks now = base::TimeTicks::Now();
219 if (base::TimeDelta(now - textUpdateTime).InSecondsF() > 0.25) {
219 m_averageFPS = fpsCounter->getAverageFPS(); 220 m_averageFPS = fpsCounter->getAverageFPS();
220 textUpdateTime = fpsCounter->timeStampOfRecentFrame(0); 221 textUpdateTime = now;
221 } 222 }
222 223
223 // Draw FPS text. 224 // Draw FPS text.
224 if (m_fontAtlas.get()) { 225 if (m_fontAtlas.get()) {
225 std::string fpsText = base::StringPrintf("FPS:%5.1f", m_averageFPS); 226 std::string fpsText = base::StringPrintf("FPS:%5.1f", m_averageFPS);
226 std::string minMaxText = base::StringPrintf("%.0f-%.0f", std::min( m_min FPS, m_maxFPS), m_maxFPS); 227 std::string minMaxText = base::StringPrintf("%.0f-%.0f", std::min( m_min FPS, m_maxFPS), m_maxFPS);
227 228
228 int minMaxWidth = m_fontAtlas->textSize(minMaxText).width(); 229 int minMaxWidth = m_fontAtlas->textSize(minMaxText).width();
229 gfx::Size textArea(bounds.width(), bounds.height()); 230 gfx::Size textArea(bounds.width(), bounds.height());
230 231
(...skipping 22 matching lines...) Expand all
253 int x = 0; 254 int x = 0;
254 SkPath path; 255 SkPath path;
255 256
256 m_minFPS = std::numeric_limits<double>::max(); 257 m_minFPS = std::numeric_limits<double>::max();
257 m_maxFPS = 0; 258 m_maxFPS = 0;
258 259
259 const int histogramSize = 20; 260 const int histogramSize = 20;
260 double histogram[histogramSize] = {0}; 261 double histogram[histogramSize] = {0};
261 double maxBucketValue = 0; 262 double maxBucketValue = 0;
262 263
263 for (int i = 1; i < fpsCounter->timeStampHistorySize() - 1; ++i) { 264 for (size_t i = 1; i < fpsCounter->timeStampHistorySize() - 1; ++i) {
264 base::TimeDelta delta = fpsCounter->timeStampOfRecentFrame(i + 1) - fpsC ounter->timeStampOfRecentFrame(i); 265 base::TimeDelta delta = fpsCounter->timeStampOfRecentFrame(i + 1) - fpsC ounter->timeStampOfRecentFrame(i);
265 266
266 // Skip this particular instantaneous frame rate if it is not likely to have been valid. 267 // Skip this particular instantaneous frame rate if it is not likely to have been valid.
267 if (!fpsCounter->isBadFrameInterval(delta)) { 268 if (!fpsCounter->isBadFrameInterval(delta)) {
268 269
269 double fps = 1.0 / delta.InSecondsF(); 270 double fps = 1.0 / delta.InSecondsF();
270 271
271 m_minFPS = std::min(fps, m_minFPS); 272 m_minFPS = std::min(fps, m_minFPS);
272 m_maxFPS = std::max(fps, m_maxFPS); 273 m_maxFPS = std::max(fps, m_maxFPS);
273 274
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 385
385 canvas->restore(); 386 canvas->restore();
386 } 387 }
387 388
388 const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const 389 const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const
389 { 390 {
390 return "HeadsUpDisplayLayer"; 391 return "HeadsUpDisplayLayer";
391 } 392 }
392 393
393 } // namespace cc 394 } // namespace cc
OLDNEW
« no previous file with comments | « cc/frame_rate_counter.cc ('k') | cc/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698