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

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: switched to FrameRateCounter has a RingBuffer 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 drawFPSCounterText(canvas, paint, fpsCounter, textBounds); 202 drawFPSCounterText(canvas, paint, fpsCounter, textBounds);
203 drawFPSCounterGraphAndHistogram(canvas, paint, fpsCounter, graphBounds, hist ogramBounds); 203 drawFPSCounterGraphAndHistogram(canvas, paint, fpsCounter, graphBounds, hist ogramBounds);
204 204
205 return top + height; 205 return top + height;
206 } 206 }
207 207
208 void HeadsUpDisplayLayerImpl::drawFPSCounterText(SkCanvas* canvas, SkPaint& pain t, FrameRateCounter* fpsCounter, SkRect bounds) 208 void HeadsUpDisplayLayerImpl::drawFPSCounterText(SkCanvas* canvas, SkPaint& pain t, FrameRateCounter* fpsCounter, SkRect bounds)
209 { 209 {
210 // Update FPS text - not every frame so text is readable 210 // Update FPS text - not every frame so text is readable
211 if (base::TimeDelta(fpsCounter->timeStampOfRecentFrame(0) - textUpdateTime). InSecondsF() > 0.25) { 211 base::TimeTicks now = base::TimeTicks::Now();
egraether 2013/01/10 02:32:09 This should just use the current timestamp, which
212 if (base::TimeDelta(now - textUpdateTime).InSecondsF() > 0.25) {
212 m_averageFPS = fpsCounter->getAverageFPS(); 213 m_averageFPS = fpsCounter->getAverageFPS();
213 textUpdateTime = fpsCounter->timeStampOfRecentFrame(0); 214 textUpdateTime = now;
214 } 215 }
215 216
216 // Draw FPS text. 217 // Draw FPS text.
217 if (m_fontAtlas.get()) { 218 if (m_fontAtlas.get()) {
218 std::string fpsText = base::StringPrintf("FPS:%5.1f", m_averageFPS); 219 std::string fpsText = base::StringPrintf("FPS:%5.1f", m_averageFPS);
219 std::string minMaxText = base::StringPrintf("%.0f-%.0f", std::min( m_min FPS, m_maxFPS), m_maxFPS); 220 std::string minMaxText = base::StringPrintf("%.0f-%.0f", std::min( m_min FPS, m_maxFPS), m_maxFPS);
220 221
221 int minMaxWidth = m_fontAtlas->textSize(minMaxText).width(); 222 int minMaxWidth = m_fontAtlas->textSize(minMaxText).width();
222 gfx::Size textArea(bounds.width(), bounds.height()); 223 gfx::Size textArea(bounds.width(), bounds.height());
223 224
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 378
378 canvas->restore(); 379 canvas->restore();
379 } 380 }
380 381
381 const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const 382 const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const
382 { 383 {
383 return "HeadsUpDisplayLayer"; 384 return "HeadsUpDisplayLayer";
384 } 385 }
385 386
386 } // namespace cc 387 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698