xoreos  0.0.5
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Graphics::FPSCounter Class Reference

A class counting frames per second. More...

#include <fpscounter.h>

Collaboration diagram for Graphics::FPSCounter:
Collaboration graph
[legend]

Public Member Functions

 FPSCounter (size_t secs)
 Average the FPS over that many seconds. More...
 
 ~FPSCounter ()
 
uint32 getFPS () const
 Get the current FPS value. More...
 
void reset ()
 Reset the counter. More...
 
void finishedFrame ()
 Signal a finished frame. More...
 

Private Member Functions

void calculateFPS ()
 Calculate the average FPS value. More...
 

Private Attributes

uint32 _lastSampled
 The last time a finished frame was signaled. More...
 
size_t _seconds
 Number of seconds over which to average the FPS. More...
 
size_t _currentSecond
 Current second we measure. More...
 
bool _hasFullSeconds
 Got all samples? More...
 
uint32 _fps
 The current FPS value. More...
 
Common::ScopedArray< uint32_frames
 All frame counters. More...
 

Detailed Description

A class counting frames per second.

Definition at line 34 of file fpscounter.h.

Constructor & Destructor Documentation

◆ FPSCounter()

Graphics::FPSCounter::FPSCounter ( size_t  secs)

Average the FPS over that many seconds.

Definition at line 35 of file fpscounter.cpp.

References _frames, _seconds, reset(), and Common::ScopedPtrBase< T, Deallocator >::reset().

Here is the call graph for this function:

◆ ~FPSCounter()

Graphics::FPSCounter::~FPSCounter ( )

Definition at line 43 of file fpscounter.cpp.

Member Function Documentation

◆ calculateFPS()

void Graphics::FPSCounter::calculateFPS ( )
private

Calculate the average FPS value.

Definition at line 91 of file fpscounter.cpp.

References _currentSecond, _fps, _frames, _hasFullSeconds, and _seconds.

Referenced by finishedFrame().

Here is the caller graph for this function:

◆ finishedFrame()

void Graphics::FPSCounter::finishedFrame ( )

Signal a finished frame.

Definition at line 63 of file fpscounter.cpp.

References _currentSecond, _frames, _hasFullSeconds, _lastSampled, _seconds, calculateFPS(), and EventMan.

Here is the call graph for this function:

◆ getFPS()

uint32 Graphics::FPSCounter::getFPS ( ) const

Get the current FPS value.

Definition at line 46 of file fpscounter.cpp.

References _fps.

◆ reset()

void Graphics::FPSCounter::reset ( )

Reset the counter.

Definition at line 50 of file fpscounter.cpp.

References _currentSecond, _fps, _frames, _hasFullSeconds, _lastSampled, and _seconds.

Referenced by FPSCounter().

Here is the caller graph for this function:

Member Data Documentation

◆ _currentSecond

size_t Graphics::FPSCounter::_currentSecond
private

Current second we measure.

Definition at line 53 of file fpscounter.h.

Referenced by calculateFPS(), finishedFrame(), and reset().

◆ _fps

uint32 Graphics::FPSCounter::_fps
private

The current FPS value.

Definition at line 57 of file fpscounter.h.

Referenced by calculateFPS(), getFPS(), and reset().

◆ _frames

Common::ScopedArray<uint32> Graphics::FPSCounter::_frames
private

All frame counters.

Definition at line 59 of file fpscounter.h.

Referenced by calculateFPS(), finishedFrame(), FPSCounter(), and reset().

◆ _hasFullSeconds

bool Graphics::FPSCounter::_hasFullSeconds
private

Got all samples?

Definition at line 55 of file fpscounter.h.

Referenced by calculateFPS(), finishedFrame(), and reset().

◆ _lastSampled

uint32 Graphics::FPSCounter::_lastSampled
private

The last time a finished frame was signaled.

Definition at line 50 of file fpscounter.h.

Referenced by finishedFrame(), and reset().

◆ _seconds

size_t Graphics::FPSCounter::_seconds
private

Number of seconds over which to average the FPS.

Definition at line 52 of file fpscounter.h.

Referenced by calculateFPS(), finishedFrame(), FPSCounter(), and reset().


The documentation for this class was generated from the following files: