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

Side by Side Diff: experimental/flocking_geese/nacl_app/frame_counter.cc

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 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
(Empty)
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "nacl_app/flock.h"
6
7 #include <time.h>
8 #include <limits>
9
10 void FrameCounter::BeginFrame() {
11 struct timeval start_time;
12 gettimeofday(&start_time, NULL);
13 frame_start_ = start_time.tv_sec * kMicroSecondsPerSecond +
14 start_time.tv_usec;
15 }
16
17 void FrameCounter::EndFrame() {
18 struct timeval end_time;
19 gettimeofday(&end_time, NULL);
20 double frame_end = end_time.tv_sec * kMicroSecondsPerSecond +
21 end_time.tv_usec;
22 double dt = frame_end - frame_start_;
23 if (dt < 0)
24 return;
25 frame_duration_accumulator_ += dt;
26 frame_count_++;
27 if (frame_count_ > kFrameRateRefreshCount ||
28 frame_duration_accumulator_ >= kMicroSecondsPerSecond) {
29 double elapsed_time = frame_duration_accumulator_ /
30 kMicroSecondsPerSecond;
31 if (fabs(elapsed_time) > std::numeric_limits<double>::epsilon()) {
32 frames_per_second_ = frame_count_ / elapsed_time;
33 }
34 frame_duration_accumulator_ = 0;
35 frame_count_ = 0;
36 }
37 }
38
39 void FrameCounter::Reset() {
40 frames_per_second_ = 0;
41 frame_duration_accumulator_ = 0;
42 frame_count_ = 0;
43 }
OLDNEW
« no previous file with comments | « experimental/flocking_geese/nacl_app/frame_counter.h ('k') | experimental/flocking_geese/nacl_app/goose.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698