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

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

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 #ifndef FRAME_COUNTER_H_
6 #define FRAME_COUNTER_H_
7
8 class FrameCounter {
9 public:
10 FrameCounter()
11 : frame_duration_accumulator_(0),
12 frame_count_(0),
13 frames_per_second_(0) {}
14 ~FrameCounter() {}
15
16 // Record the current time, which is used to compute the frame duration
17 // when EndFrame() is called.
18 void BeginFrame();
19
20 // Compute the delta since the last call to BeginFrame() and increment the
21 // frame count. Update the frame rate whenever the prescribed number of
22 // frames have been counted, or at least one second of simulator time has
23 // passed, whichever is less.
24 void EndFrame();
25
26 // Reset the frame counters back to 0.
27 void Reset();
28
29 // The current frame rate. Note that this is 0 for the first second in
30 // the accumulator, and is updated every 100 frames (and at least once
31 // every second of simulation time or so).
32 double frames_per_second() const {
33 return frames_per_second_;
34 }
35
36 private:
37 static const double kMicroSecondsPerSecond = 1000000.0;
38 static const int32_t kFrameRateRefreshCount = 100;
39
40 double frame_duration_accumulator_; // Measured in microseconds.
41 int32_t frame_count_;
42 double frame_start_;
43 double frames_per_second_;
44 };
45
46 #endif // FRAME_COUNTER_H_
OLDNEW
« no previous file with comments | « experimental/flocking_geese/nacl_app/flocking_geese_module.cc ('k') | experimental/flocking_geese/nacl_app/frame_counter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698