LCOV - code coverage report
Current view: top level - eq/server - frame.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 18 21 85.7 %
Date: 2017-12-16 05:07:20 Functions: 14 16 87.5 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2006-2017, 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_FRAME_H
      20             : #define EQSERVER_FRAME_H
      21             : 
      22             : #include "compound.h"
      23             : #include "types.h"
      24             : 
      25             : #include <eq/fabric/frame.h>       // base class
      26             : #include <lunchbox/bitOperation.h> // function getIndexOfLastBit
      27             : 
      28             : namespace eq
      29             : {
      30             : namespace server
      31             : {
      32             : /** A holder for frame data and parameters. */
      33             : class Frame : public fabric::Frame
      34             : {
      35             : public:
      36             :     /** Construct a new Frame. */
      37             :     EQSERVER_API Frame();
      38             :     EQSERVER_API virtual ~Frame();
      39             :     Frame(const Frame& from);
      40             : 
      41             :     /** @name Data Access */
      42             :     //@{
      43        5548 :     void setCompound(Compound* compound)
      44             :     {
      45        5548 :         LBASSERT(!_compound);
      46        5548 :         _compound = compound;
      47        5548 :     }
      48           4 :     Compound* getCompound() const { return _compound; }
      49           0 :     Channel* getChannel() const
      50             :     {
      51           0 :         return _compound ? _compound->getChannel() : 0;
      52             :     }
      53           8 :     Node* getNode() const { return _compound ? _compound->getNode() : 0; }
      54          16 :     FrameData* getMasterData() const { return _masterFrameData; }
      55           8 :     bool hasData(const Eye eye) const
      56             :     {
      57           8 :         return (_frameData[lunchbox::getIndexOfLastBit(eye)] != 0);
      58             :     }
      59             : 
      60             :     /**
      61             :      * Set the frame's viewport wrt the compound (output frames) or wrt the
      62             :      * corresponding output frame (input frames).
      63             :      *
      64             :      * @param vp the fractional viewport.
      65             :      */
      66        1484 :     void setViewport(const Viewport& vp) { _vp = vp; }
      67             :     /** @return the fractional viewport. */
      68        2874 :     const Viewport& getViewport() const { return _vp; }
      69             :     /**
      70             :      * Set the frame buffers to be read or write by this frame.
      71             :      *
      72             :      * @param buffers a bitwise combination of the buffers.
      73             :      */
      74         252 :     void setBuffers(const fabric::Frame::Buffer buffers) { _buffers = buffers; }
      75             :     /** return the frame storage type. */
      76        2878 :     Type getType() const { return _type; }
      77             :     /**
      78             :      * Set the frame storage type.
      79             :      *
      80             :      * @param type frame storage type.
      81             :      */
      82         128 :     void setType(const Type type) { _type = type; }
      83             :     /** @return the frame buffers used by this frame. */
      84        2874 :     fabric::Frame::Buffer getBuffers() const { return _buffers; }
      85             :     //@}
      86             : 
      87             :     /** @name Operations */
      88             :     //@{
      89             :     /** Commit the frame's data (used for output frames only) */
      90             :     void commitData();
      91             : 
      92             :     /** Commit the frame */
      93             :     EQSERVER_API virtual uint128_t commit(
      94             :         const uint32_t incarnation = CO_COMMIT_NEXT);
      95             : 
      96             :     /**
      97             :      * Cycle the current FrameData.
      98             :      *
      99             :      * Used for output frames to allocate/recycle frame data. Also
     100             :      * clears the list of input frames.
     101             :      *
     102             :      * @param frameNumber the current frame number.
     103             :      * @param compound the compound holding the output frame.
     104             :      */
     105             :     void cycleData(const uint32_t frameNumber, const Compound* compound);
     106             : 
     107             :     /**
     108             :      * Add an input frame to this (output) frame
     109             :      *
     110             :      * @param frame the input frame.
     111             :      * @param compound the compound holding the input frame.
     112             :      */
     113             :     void addInputFrame(Frame* frame, const Compound* compound);
     114             : 
     115             :     /** @return the vector of current input frames. */
     116             :     const Frames& getInputFrames(const Eye eye) const
     117             :     {
     118             :         return _inputFrames[lunchbox::getIndexOfLastBit(eye)];
     119             :     }
     120             : 
     121             :     /** Unset the frame data. */
     122             :     void unsetData();
     123             : 
     124             :     /** Reset the frame and delete all frame datas. */
     125             :     void flush();
     126             :     //@}
     127             : 
     128             :     /**
     129             :      * @name Native data access.
     130             :      *
     131             :      * Native data is the raw data based on which the actual data used is
     132             :      * computed each frame and set using the non-native methods.
     133             :      */
     134             :     //@{
     135             :     /**
     136             :      * Set the offset of the frame.
     137             :      *
     138             :      * The offset defines relative data position wrt to the current
     139             :      * destination channel of the source.
     140             :      */
     141           0 :     void setNativeOffset(const Vector2i& offset) { _native.setOffset(offset); }
     142             :     /** @return the frame's effective offset. */
     143           4 :     const Vector2i& getNativeOffset() const { return _native.getOffset(); }
     144             :     /** Set the native frame zoom factor. */
     145        5548 :     void setNativeZoom(const Zoom& zoom) { _native.setZoom(zoom); }
     146             :     /** @return the native zoom factor. */
     147           8 :     const Zoom& getNativeZoom() const { return _native.getZoom(); }
     148             :     //@}
     149             : 
     150             : private:
     151             :     /** The parent compound. */
     152             :     Compound* _compound;
     153             : 
     154             :     /** Frame-specific data. */
     155             :     Viewport _vp;
     156             :     fabric::Frame::Buffer _buffers;
     157             :     Type _type;
     158             : 
     159             :     /** The configured frame data (base class contains inherit values). */
     160             :     fabric::Frame _native;
     161             : 
     162             :     /** All framedatas ever allocated, used for recycling old datas. */
     163             :     std::deque<FrameData*> _datas;
     164             : 
     165             :     /** Current frame data. */
     166             :     FrameData* _masterFrameData;
     167             :     FrameData* _frameData[fabric::NUM_EYES];
     168             : 
     169             :     /** Vector of current input frames. */
     170             :     Frames _inputFrames[fabric::NUM_EYES];
     171             : };
     172             : 
     173             : EQSERVER_API std::ostream& operator<<(std::ostream&, const Frame&);
     174             : }
     175             : }
     176             : #endif // EQSERVER_FRAME_H

Generated by: LCOV version 1.11