LCOV - code coverage report
Current view: top level - eq/server - window.h (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 8 11 72.7 %
Date: 2014-06-18 Functions: 7 10 70.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2005-2012, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                    2010, Cedric Stalder <cedric.stalder@gmail.com>
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or modify it under
       6             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       7             :  * by the Free Software Foundation.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      11             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      12             :  * details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public License
      15             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #ifndef EQSERVER_WINDOW_H
      20             : #define EQSERVER_WINDOW_H
      21             : 
      22             : #include "api.h"
      23             : #include "state.h"          // enum
      24             : #include "types.h"
      25             : #include "visitorResult.h"  // enum
      26             : 
      27             : #include <eq/fabric/window.h> // base class
      28             : #include <co/barrier.h>
      29             : #include <lunchbox/monitor.h>   // member
      30             : #include <lunchbox/uint128_t.h> // member
      31             : #include <iostream>
      32             : #include <vector>
      33             : 
      34             : namespace eq
      35             : {
      36             : namespace server
      37             : {
      38             :     /** The window. */
      39             :     class Window : public fabric::Window< Pipe, Window, Channel >
      40             :     {
      41             :     public:
      42             :         /**
      43             :          * Constructs a new Window.
      44             :          */
      45             :         EQSERVER_API Window( Pipe* parent );
      46             : 
      47             :         virtual ~Window();
      48             :         /**
      49             :          * @name Data Access
      50             :          */
      51             :         //@{
      52             : 
      53             :         Node* getNode();
      54             :         const Node* getNode() const;
      55             : 
      56             :         Config* getConfig();
      57             :         const Config* getConfig() const;
      58             : 
      59             :         /** @return the Server of this window. */
      60             :         ServerPtr getServer();
      61             : 
      62             :         Channel* getChannel( const ChannelPath& path );
      63             : 
      64             :         co::CommandQueue* getMainThreadQueue();
      65             :         co::CommandQueue* getCommandThreadQueue();
      66             : 
      67             :         /** Increase window activition count. */
      68             :         void activate();
      69             : 
      70             :         /** Decrease window activition count. */
      71             :         void deactivate();
      72             : 
      73             :         /** @return the state of this window. */
      74         120 :         State getState() const { return _state.get(); }
      75             : 
      76             :         /** @internal */
      77           0 :         void setState( const State state ) { _state = state; }
      78             : 
      79             :         /** @return if this window is actively used for rendering. */
      80          66 :         bool isActive() const { return (_active != 0); }
      81             : 
      82             :         /** @return true if this window is stopped. */
      83             :         bool isStopped() const { return _state & STATE_STOPPED; }
      84             : 
      85             :         /** @return true if this window is running. */
      86          29 :         bool isRunning() const { return _state & STATE_RUNNING; }
      87             : 
      88             :         /** @return true if this window should be deleted. */
      89         130 :         bool needsDelete() const { return _state & STATE_DELETE; }
      90             : 
      91             :         /** Schedule deletion of this window. */
      92             :         void postDelete();
      93             : 
      94             :         /**
      95             :          * Add additional tasks this window, and all its parents, might
      96             :          * potentially execute.
      97             :          */
      98             :         void addTasks( const uint32_t tasks );
      99             : 
     100             :         /**
     101             :          * Join a swap barrier for the next update.
     102             :          *
     103             :          * @param barrier the net::Barrier for the swap barrier group, or 0 if
     104             :          *                this is the first window.
     105             :          * @return the net::Barrier for the swap barrier group.
     106             :          */
     107             :         co::Barrier* joinSwapBarrier( co::Barrier* barrier );
     108             : 
     109             :         /**
     110             :          * Join a NV_swap_group barrier for the next update.
     111             :          *
     112             :          * @param swapBarrier the swap barrier containing the NV_swap_group
     113             :          *                    parameters.
     114             :          * @param netBarrier the net::Barrier to protect the entry from the
     115             :          *                   NV_swap_group , or 0 if this is the first window
     116             :          *                   entering.
     117             :          * @return the net::Barrier for protecting the swap group entry.
     118             :          */
     119             :         co::Barrier* joinNVSwapBarrier( SwapBarrierConstPtr swapBarrier,
     120             :                                         co::Barrier* netBarrier );
     121             : 
     122             :         /** @return true if this window has entered a NV_swap_group. */
     123           0 :         bool hasNVSwapBarrier() const { return (_nvSwapBarrier != 0); }
     124             : 
     125             :         /** The last drawing channel for this entity. @internal */
     126          14 :         void setLastDrawChannel( const Channel* channel )
     127          14 :             { _lastDrawChannel = channel; }
     128           7 :         const Channel* getLastDrawChannel() const { return _lastDrawChannel; }
     129             : 
     130             :         /** The maximum frame rate for this window. @internal */
     131           0 :         void setMaxFPS( const float fps ) { _maxFPS = fps; }
     132           9 :         float getMaxFPS() const { return _maxFPS; }
     133             :         //@}
     134             : 
     135             :         /**
     136             :          * @name Operations
     137             :          */
     138             :         //@{
     139             :         /** Start initializing this entity. */
     140             :         void configInit( const uint128_t& initID, const uint32_t frameNumber );
     141             : 
     142             :         /** Sync initialization of this entity. */
     143             :         bool syncConfigInit();
     144             : 
     145             :         /** Start exiting this entity. */
     146             :         void configExit();
     147             : 
     148             :         /** Sync exit of this entity. */
     149             :         bool syncConfigExit();
     150             : 
     151             :         /**
     152             :          * Update one frame.
     153             :          *
     154             :          * @param frameID a per-frame identifier passed to all rendering
     155             :          *                methods.
     156             :          * @param frameNumber the number of the frame.
     157             :          */
     158             :         void updateDraw( const uint128_t& frameID, const uint32_t frameNumber );
     159             : 
     160             :         /**
     161             :          * Trigger the post-draw operations.
     162             :          *
     163             :          * @param frameID a per-frame identifier passed to all rendering
     164             :          *                methods.
     165             :          * @param frameNumber the number of the frame.
     166             :          */
     167             :         void updatePost( const uint128_t& frameID, const uint32_t frameNumber );
     168             :         //@}
     169             : 
     170             :         co::ObjectOCommand send( const uint32_t cmd );
     171             :         void output( std::ostream& ) const; //!< @internal
     172             : 
     173             :     protected:
     174             : 
     175             :         /** @sa net::Object::attach. */
     176             :         virtual void attach( const uint128_t& id, const uint32_t instanceID );
     177             : 
     178             :         /** @internal Execute the slave remove request. */
     179             :         virtual void removeChild( const uint128_t& id );
     180             : 
     181             :     private:
     182             : 
     183             :         /** Number of activations for this window. */
     184             :         uint32_t _active;
     185             : 
     186             :         /** The current state for state change synchronization. */
     187             :         lunchbox::Monitor< State > _state;
     188             : 
     189             :         /** The maximum frame rate allowed for this window. */
     190             :         float _maxFPS;
     191             : 
     192             :         /** The list of master swap barriers for the current frame. */
     193             :         co::Barriers _masterBarriers;
     194             :         /** The list of slave swap barriers for the current frame. */
     195             :         co::Barriers _barriers;
     196             : 
     197             :         /** The hardware swap barrier to use. */
     198             :         SwapBarrierConstPtr _nvSwapBarrier;
     199             : 
     200             :         /** The network barrier used to protect hardware barrier entry. */
     201             :         co::Barrier* _nvNetBarrier;
     202             : 
     203             :         /** The last draw channel for this entity */
     204             :         const Channel* _lastDrawChannel;
     205             : 
     206             :         /** The flag if the window has to execute a finish */
     207             :         bool _swapFinish;
     208             : 
     209             :         /**
     210             :          * The flag if the window has to swap, i.e, something was done during
     211             :          * the last update.
     212             :          */
     213             :         bool _swap;
     214             : 
     215             :         struct Private;
     216             :         Private* _private; // placeholder for binary-compatible changes
     217             : 
     218             :         /** Clears all swap barriers of the window. */
     219             :         void _resetSwapBarriers();
     220             : 
     221             :         void _updateSwap( const uint32_t frameNumber );
     222             : 
     223             :         /* command handler functions. */
     224             :         bool _cmdConfigInitReply( co::ICommand& command );
     225             :         bool _cmdConfigExitReply( co::ICommand& command );
     226             : 
     227             :         // For access to _fixedPVP
     228             :         friend std::ostream& operator << ( std::ostream&, const Window*);
     229             :     };
     230             : }
     231             : }
     232             : 
     233             : #endif // EQSERVER_WINDOW_H

Generated by: LCOV version 1.10