LCOV - code coverage report
Current view: top level - eq/server/equalizers - framerateEqualizer.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 4 9 44.4 %
Date: 2017-12-16 05:07:20 Functions: 2 8 25.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2008-2013, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *
       4             :  * This library is free software; you can redistribute it and/or modify it under
       5             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       6             :  * by the Free Software Foundation.
       7             :  *
       8             :  * This library is distributed in the hope that it will be useful, but WITHOUT
       9             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      10             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      11             :  * details.
      12             :  *
      13             :  * You should have received a copy of the GNU Lesser General Public License
      14             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      15             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      16             :  */
      17             : 
      18             : #ifndef EQS_FRAMERATEEQUALIZER_H
      19             : #define EQS_FRAMERATEEQUALIZER_H
      20             : 
      21             : #include "../channelListener.h" // base class
      22             : #include "equalizer.h"          // base class
      23             : 
      24             : #include <deque>
      25             : #include <map>
      26             : 
      27             : namespace eq
      28             : {
      29             : namespace server
      30             : {
      31             : std::ostream& operator<<(std::ostream& os, const FramerateEqualizer*);
      32             : 
      33             : /**
      34             :  * Adapts the frame rate of a compound to smoothen its output.
      35             :  *
      36             :  * Does not support period settings underneath a child. One channel should
      37             :  * not be used in compounds with a different inherit period.
      38             :  */
      39             : class FramerateEqualizer : public Equalizer
      40             : {
      41             : public:
      42             :     EQSERVER_API FramerateEqualizer();
      43             :     FramerateEqualizer(const FramerateEqualizer& from);
      44             :     virtual ~FramerateEqualizer();
      45          14 :     void toStream(std::ostream& os) const final { os << this; }
      46             :     /** @sa Equalizer::attach */
      47             :     void attach(Compound* compound) final;
      48             : 
      49             :     /** @sa CompoundListener::notifyUpdatePre */
      50             :     void notifyUpdatePre(Compound* compound, const uint32_t frameNumber) final;
      51             : 
      52           0 :     uint32_t getType() const final { return fabric::FRAMERATE_EQUALIZER; }
      53             : protected:
      54          68 :     void notifyChildAdded(Compound*, Compound*) override
      55             :     {
      56          68 :         LBASSERT(_nSamples == 0);
      57          68 :     }
      58           0 :     void notifyChildRemove(Compound*, Compound*) override
      59             :     {
      60           0 :         LBASSERT(_nSamples == 0);
      61           0 :     }
      62             : 
      63             : private:
      64             :     /** Frame number with max time. */
      65             :     typedef std::pair<uint32_t, float> FrameTime;
      66             : 
      67             :     /** Historical data to compute new frame rate. */
      68             :     std::deque<FrameTime> _times;
      69             : 
      70             :     /** Helper class connecting on child tree for load gathering. */
      71           0 :     class LoadListener : public ChannelListener
      72             :     {
      73             :     public:
      74             :         /** @sa ChannelListener::notifyLoadData */
      75             :         virtual void notifyLoadData(Channel* channel, uint32_t frameNumber,
      76             :                                     const Statistics& statistics,
      77             :                                     const Viewport& region);
      78             : 
      79             :         FramerateEqualizer* parent;
      80             :         uint32_t period;
      81             :     };
      82             : 
      83             :     /** One listener for each compound child. */
      84             :     std::vector<LoadListener> _loadListeners;
      85             :     friend class LoadListener;
      86             : 
      87             :     /** The number of samples to use from _times. */
      88             :     uint32_t _nSamples;
      89             : 
      90             :     void _init();
      91             :     void _exit();
      92             : };
      93             : }
      94             : }
      95             : 
      96             : #endif // EQS_LOADBALANCER_H

Generated by: LCOV version 1.11