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

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: removed size_t to fix tests 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 153 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