LCOV - code coverage report
Current view: top level - eq/server - window.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 9 12 75.0 %
Date: 2017-12-16 05:07:20 Functions: 7 10 70.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2005-2015, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                          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 "state.h" // enum
      23             : #include "types.h"
      24             : #include "visitorResult.h" // enum
      25             : #include <eq/server/api.h>
      26             : 
      27             : #include <co/barrier.h>
      28             : #include <eq/fabric/window.h> // base class
      29             : #include <iostream>
      30             : #include <lunchbox/monitor.h>   // member
      31             : #include <lunchbox/uint128_t.h> // member
      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             :     /** Construct a new Window. */
      43             :     EQSERVER_API explicit Window(Pipe* parent);
      44             : 
      45             :     virtual ~Window();
      46             : 
      47             :     /** @name Data Access */
      48             :     //@{
      49             :     Node* getNode();
      50             :     const Node* getNode() const;
      51             : 
      52             :     Config* getConfig();
      53             :     const Config* getConfig() const;
      54             : 
      55             :     /** @return the Server of this window. */
      56             :     ServerPtr getServer();
      57             : 
      58             :     Channel* getChannel(const ChannelPath& path);
      59             : 
      60             :     co::CommandQueue* getMainThreadQueue();
      61             :     co::CommandQueue* getCommandThreadQueue();
      62             : 
      63             :     /** Increase window activition count. */
      64             :     void activate();
      65             : 
      66             :     /** Decrease window activition count. */
      67             :     void deactivate();
      68             : 
      69             :     /** @return the state of this window. */
      70          32 :     State getState() const { return _state.get(); }
      71             :     /** @internal */
      72           0 :     void setState(const State state) { _state = state; }
      73             :     /** @return if this window is actively used for rendering. */
      74          24 :     bool isActive() const { return (_active != 0); }
      75             :     /** @return true if this window is stopped. */
      76             :     bool isStopped() const { return _state & STATE_STOPPED; }
      77             :     /** @return true if this window is running. */
      78          12 :     bool isRunning() const { return _state & STATE_RUNNING; }
      79             :     /** @return true if this window should be deleted. */
      80          32 :     bool needsDelete() const { return _state & STATE_DELETE; }
      81             :     /** Schedule deletion of this window. */
      82             :     void postDelete();
      83             : 
      84             :     /**
      85             :      * Add additional tasks this window, and all its parents, might
      86             :      * potentially execute.
      87             :      */
      88             :     void addTasks(const uint32_t tasks);
      89             : 
      90             :     /**
      91             :      * Join a swap barrier for the next update.
      92             :      *
      93             :      * @param barrier the net::Barrier for the swap barrier group, or 0 if
      94             :      *                this is the first window.
      95             :      * @return the net::Barrier for the swap barrier group.
      96             :      */
      97             :     co::Barrier* joinSwapBarrier(co::Barrier* barrier);
      98             : 
      99             :     /**
     100             :      * Join a NV_swap_group barrier for the next update.
     101             :      *
     102             :      * @param swapBarrier the swap barrier containing the NV_swap_group
     103             :      *                    parameters.
     104             :      * @param netBarrier the net::Barrier to protect the entry from the
     105             :      *                   NV_swap_group , or 0 if this is the first window
     106             :      *                   entering.
     107             :      * @return the net::Barrier for protecting the swap group entry.
     108             :      */
     109             :     co::Barrier* joinNVSwapBarrier(SwapBarrierConstPtr swapBarrier,
     110             :                                    co::Barrier* netBarrier);
     111             : 
     112             :     /** @return true if this window has entered a NV_swap_group. */
     113           0 :     bool hasNVSwapBarrier() const { return (_nvSwapBarrier != 0); }
     114             :     /** The last drawing channel for this entity. @internal */
     115           8 :     void setLastDrawChannel(const Channel* channel)
     116             :     {
     117           8 :         _lastDrawChannel = channel;
     118           8 :     }
     119           4 :     const Channel* getLastDrawChannel() const { return _lastDrawChannel; }
     120             :     /** The maximum frame rate for this window. @internal */
     121           0 :     void setMaxFPS(const float fps) { _maxFPS = fps; }
     122           8 :     float getMaxFPS() const { return _maxFPS; }
     123             :     //@}
     124             : 
     125             :     /**
     126             :      * @name Operations
     127             :      */
     128             :     //@{
     129             :     /** Start initializing this entity. */
     130             :     void configInit(const uint128_t& initID, const uint32_t frameNumber);
     131             : 
     132             :     /** Sync initialization of this entity. */
     133             :     bool syncConfigInit();
     134             : 
     135             :     /** Start exiting this entity. */
     136             :     void configExit();
     137             : 
     138             :     /** Sync exit of this entity. */
     139             :     bool syncConfigExit();
     140             : 
     141             :     /**
     142             :      * Update one frame.
     143             :      *
     144             :      * @param frameID a per-frame identifier passed to all rendering
     145             :      *                methods.
     146             :      * @param frameNumber the number of the frame.
     147             :      */
     148             :     void updateDraw(const uint128_t& frameID, const uint32_t frameNumber);
     149             : 
     150             :     /**
     151             :      * Trigger the post-draw operations.
     152             :      *
     153             :      * @param frameID a per-frame identifier passed to all rendering
     154             :      *                methods.
     155             :      * @param frameNumber the number of the frame.
     156             :      */
     157             :     void updatePost(const uint128_t& frameID, const uint32_t frameNumber);
     158             :     //@}
     159             : 
     160             :     co::ObjectOCommand send(const uint32_t cmd);
     161             :     void output(std::ostream&) const; //!< @internal
     162             : 
     163             : protected:
     164             :     /** @sa net::Object::attach. */
     165             :     virtual void attach(const uint128_t& id, const uint32_t instanceID);
     166             : 
     167             :     /** @internal Execute the slave remove request. */
     168             :     virtual void removeChild(const uint128_t& id);
     169             : 
     170             : private:
     171             :     /** Number of activations for this window. */
     172             :     uint32_t _active;
     173             : 
     174             :     /** The current state for state change synchronization. */
     175             :     lunchbox::Monitor<State> _state;
     176             : 
     177             :     /** The maximum frame rate allowed for this window. */
     178             :     float _maxFPS;
     179             : 
     180             :     /** The list of master swap barriers for the current frame. */
     181             :     co::Barriers _masterBarriers;
     182             :     /** The list of slave swap barriers for the current frame. */
     183             :     co::Barriers _barriers;
     184             : 
     185             :     /** The hardware swap barrier to use. */
     186             :     SwapBarrierConstPtr _nvSwapBarrier;
     187             : 
     188             :     /** The network barrier used to protect hardware barrier entry. */
     189             :     co::Barrier* _nvNetBarrier;
     190             : 
     191             :     /** The last draw channel for this entity */
     192             :     const Channel* _lastDrawChannel;
     193             : 
     194             :     /** The flag if the window has to execute a finish */
     195             :     bool _swapFinish;
     196             : 
     197             :     /**
     198             :      * The flag if the window has to swap, i.e, something was done during
     199             :      * the last update.
     200             :      */
     201             :     bool _swap;
     202             : 
     203             :     struct Private;
     204             :     Private* _private; // placeholder for binary-compatible changes
     205             : 
     206             :     /** Clears all swap barriers of the window. */
     207             :     void _resetSwapBarriers();
     208             : 
     209             :     void _updateSwap(const uint32_t frameNumber);
     210             : 
     211             :     /* command handler functions. */
     212             :     bool _cmdConfigInitReply(co::ICommand& command);
     213             :     bool _cmdConfigExitReply(co::ICommand& command);
     214             : 
     215             :     // For access to _fixedPVP
     216             :     friend std::ostream& operator<<(std::ostream&, const Window*);
     217             : };
     218             : }
     219             : }
     220             : 
     221             : #endif // EQSERVER_WINDOW_H

Generated by: LCOV version 1.11