LCOV - code coverage report
Current view: top level - eq/fabric - segment.h (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 12 14 85.7 %
Date: 2014-06-18 Functions: 12 24 50.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2010-2013, Stefan Eilemann <eile@eyescale.ch>
       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 EQFABRIC_SEGMENT_H
      19             : #define EQFABRIC_SEGMENT_H
      20             : 
      21             : #include <eq/fabric/types.h>
      22             : #include <eq/fabric/frustum.h>        // base class
      23             : #include <eq/fabric/object.h>         // base class
      24             : #include <eq/fabric/swapBarrier.h>    // RefPtr member
      25             : #include <eq/fabric/viewport.h>       // member
      26             : 
      27             : namespace eq
      28             : {
      29             : namespace fabric
      30             : {
      31             :     /** Base data transport class for segments. @sa eq::Segment */
      32             :     template< class C, class S, class CH >
      33             :     class Segment : public Object, public Frustum
      34             :     {
      35             :     public:
      36             :         /** The segment visitor type. @version 1.0 */
      37             :         typedef LeafVisitor< S > Visitor;
      38             : 
      39             :         /** @name Data Access */
      40             :         //@{
      41             :         /** @return the parent canvas. @version 1.0 */
      42        1028 :         const C* getCanvas() const { return _canvas; }
      43             : 
      44             :         /** @return the parent canvas. @version 1.0 */
      45        1309 :         C* getCanvas() { return _canvas; }
      46             : 
      47             :         /** @return the segment's viewport. @version 1.0 */
      48        2433 :         const Viewport& getViewport() const { return _vp; }
      49             : 
      50             :         /**
      51             :          * @internal
      52             :          * Set the segment's viewport wrt its canvas.
      53             :          *
      54             :          * The viewport defines which 2D area of the canvas is covered by this
      55             :          * segment. Destination channels are created on the intersection of
      56             :          * segment viewports and the views of the layout used by the canvas.
      57             :          *
      58             :          * @param vp the fractional viewport.
      59             :          */
      60             :         EQFABRIC_INL void setViewport( const Viewport& vp );
      61             : 
      62             :         /**
      63             :          * @internal
      64             :          * Set the channel of this segment.
      65             :          *
      66             :          * The channel defines the output area for this segment, typically a
      67             :          * rendering area covering a graphics card output.
      68             :          *
      69             :          * @param channel the channel.
      70             :          */
      71         375 :         void setChannel( CH* channel )
      72         375 :             { _channel = channel; setDirty( DIRTY_CHANNEL ); }
      73             : 
      74             :         /** Return the output channel of this segment. @version 1.0 */
      75         640 :         CH* getChannel()               { return _channel; }
      76             : 
      77             :         /** Return the output channel of this segment. @version 1.0 */
      78         711 :         const CH* getChannel() const   { return _channel; }
      79             : 
      80             :         /** @internal @sa Frustum::setWall() */
      81             :         EQFABRIC_INL virtual void setWall( const Wall& wall );
      82             : 
      83             :         /** @internal @sa Frustum::setProjection() */
      84             :         EQFABRIC_INL virtual void setProjection( const Projection& );
      85             : 
      86             :         /** @internal @sa Frustum::unsetFrustum() */
      87             :         EQFABRIC_INL virtual void unsetFrustum();
      88             : 
      89             :         /** @return the bitwise OR of the eye values. @version 1.0 */
      90         415 :         uint32_t getEyes() const { return _eyes; }
      91             : 
      92             :         /**
      93             :          * @internal
      94             :          * Set the eyes to be used by the segument.
      95             :          *
      96             :          * Previously set eyes are overwritten.
      97             :          *
      98             :          * @param eyes the segment eyes.
      99             :          */
     100             :         EQFABRIC_INL void setEyes( const uint32_t eyes );
     101             : 
     102             :         /**
     103             :          * @internal
     104             :          * Add eyes to be used by the segument.
     105             :          *
     106             :          * Previously set eyes are preserved.
     107             :          *
     108             :          * @param eyes the segument eyes.
     109             :          */
     110          36 :         void enableEye( const uint32_t eyes ) { _eyes |= eyes; }
     111             : 
     112             :         /** @internal
     113             :          * Set a swap barrier.
     114             :          *
     115             :          * This barrier will be set as a barrier on all destination compounds ,
     116             :          * unless the compounds already has a barrier.
     117             :          *
     118             :          * @param barrier the swap barrier.
     119             :          */
     120             :         EQFABRIC_INL void setSwapBarrier( SwapBarrierPtr barrier );
     121             : 
     122             :         /** @internal @return the current swap barrier. */
     123         200 :         SwapBarrierConstPtr getSwapBarrier() const { return _swapBarrier; }
     124             : 
     125             :         /** @internal @return the current swap barrier. */
     126         638 :         SwapBarrierPtr getSwapBarrier() { return _swapBarrier; }
     127             :         //@}
     128             : 
     129             :         /** @name Operations */
     130             :         //@{
     131             :         /**
     132             :          * Traverse this segment using a segment visitor.
     133             :          *
     134             :          * @param visitor the visitor.
     135             :          * @return the result of the visitor traversal.
     136             :          * @version 1.0
     137             :          */
     138             :         EQFABRIC_INL VisitorResult accept( Visitor& visitor );
     139             : 
     140             :         /** Const-version of accept(). @version 1.0 */
     141             :         EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const;
     142             : 
     143             :         /** @internal Update unset frustum from parent */
     144             :         void inheritFrustum();
     145             : 
     146             :         virtual void backup(); //!< @internal
     147             :         virtual void restore(); //!< @internal
     148             : 
     149             :         /** @internal */
     150             :         virtual uint128_t commit( const uint32_t incarnation=CO_COMMIT_NEXT );
     151             :         //@}
     152             : 
     153             :     protected:
     154             :         /** @internal Construct a new Segment. */
     155             :         EQFABRIC_INL Segment( C* canvas );
     156             : 
     157             :         /** @internal Destruct this segment. */
     158             :         EQFABRIC_INL virtual ~Segment();
     159             : 
     160             :         /** @internal */
     161             :         EQFABRIC_INL virtual void serialize( co::DataOStream& os,
     162             :                                                 const uint64_t dirtyBits );
     163             :         /** @internal */
     164             :         EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
     165             :                                                   const uint64_t dirtyBits );
     166             :         virtual void setDirty( const uint64_t bits ); //!< @internal
     167             : 
     168             :         /** @internal */
     169             :         enum DirtyBits
     170             :         {
     171             :             DIRTY_VIEWPORT   = Object::DIRTY_CUSTOM << 0,
     172             :             DIRTY_FRUSTUM    = Object::DIRTY_CUSTOM << 1,
     173             :             DIRTY_CHANNEL    = Object::DIRTY_CUSTOM << 2,
     174             :             DIRTY_EYES       = Object::DIRTY_CUSTOM << 3,
     175             :             DIRTY_SEGMENT_BITS = DIRTY_VIEWPORT | DIRTY_FRUSTUM |
     176             :                                  DIRTY_CHANNEL | DIRTY_EYES | DIRTY_OBJECT_BITS
     177             :         };
     178             : 
     179             :         /** @internal @return the bits to be re-committed by the master. */
     180           0 :         virtual uint64_t getRedistributableBits() const
     181           0 :             { return DIRTY_SEGMENT_BITS; }
     182             : 
     183             :         /** @internal */
     184         207 :         virtual void notifyFrustumChanged() { setDirty( DIRTY_FRUSTUM ); }
     185             : 
     186             :     private:
     187             :         /** The parent canvas. */
     188             :         C* const _canvas;
     189             : 
     190             :         /** The 2D area of this segment wrt to the canvas. */
     191             :         Viewport _vp;
     192             : 
     193             :         /** The output channel of this segment. */
     194             :         CH* _channel;
     195             : 
     196             :         uint32_t _eyes;
     197             : 
     198             :         SwapBarrierPtr _swapBarrier; //!< default segment swap barrier
     199             : 
     200             :         struct Private;
     201             :         Private* _private; // placeholder for binary-compatible changes
     202             :     };
     203             : 
     204             :     template< class C, class S, class CH >
     205             :     std::ostream& operator << ( std::ostream&, const Segment< C, S, CH >& );
     206             : }
     207             : }
     208             : #endif // EQFABRIC_SEGMENT_H

Generated by: LCOV version 1.10