LCOV - code coverage report
Current view: top level - eq/fabric - segment.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 14 16 87.5 %
Date: 2017-12-16 05:07:20 Functions: 12 36 33.3 %

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

Generated by: LCOV version 1.11