LCOV - code coverage report
Current view: top level - eq/fabric - frame.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 8 14 57.1 %
Date: 2017-12-16 05:07:20 Functions: 4 7 57.1 %

          Line data    Source code
       1             : /* Copyright (c) 2012-2017, Stefan Eilemann <eile@eyescale.ch>
       2             :  *
       3             :  * This library is free software; you can redistribute it and/or modify it under
       4             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       5             :  * by the Free Software Foundation.
       6             :  *
       7             :  * This library is distributed in the hope that it will be useful, but WITHOUT
       8             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
       9             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      10             :  * details.
      11             :  *
      12             :  * You should have received a copy of the GNU Lesser General Public License
      13             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      14             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      15             :  */
      16             : 
      17             : #ifndef EQFABRIC_FRAME_H
      18             : #define EQFABRIC_FRAME_H
      19             : 
      20             : #include <co/object.h> // base class
      21             : #include <eq/fabric/api.h>
      22             : #include <eq/fabric/eye.h> // enum
      23             : #include <eq/fabric/types.h>
      24             : 
      25             : namespace eq
      26             : {
      27             : namespace fabric
      28             : {
      29             : namespace detail
      30             : {
      31             : class Frame;
      32             : }
      33             : 
      34             : /** A holder for a frame data and related parameters. */
      35           0 : class Frame : public co::Object
      36             : {
      37             : public:
      38             :     /**
      39             :      * Components of the frame are to be used during readback and assembly.
      40             :      * @version 2.1
      41             :      */
      42             :     enum class Buffer : uint32_t
      43             :     {
      44             :         none = LB_BIT_NONE,
      45             :         undefined = LB_BIT1, //!< Inherit, only if no others are set
      46             :         color = LB_BIT5,     //!< Use color images
      47             :         depth = LB_BIT9,     //!< Use depth images
      48             :         all = LB_BIT_ALL_32
      49             :     };
      50             : 
      51             :     /** The storage type for pixel data. @version 1.0 */
      52             :     enum Type
      53             :     {
      54             :         TYPE_MEMORY, //!< use main memory to store pixel data
      55             :         TYPE_TEXTURE //!< use a GL texture to store pixel data
      56             :     };
      57             : 
      58             :     /** Construct a new frame. @version 1.0 */
      59             :     EQFABRIC_API Frame();
      60             : 
      61             :     /** Destruct the frame. @version 1.0 */
      62             :     EQFABRIC_API virtual ~Frame();
      63             : 
      64             :     /** @name Data Access */
      65             :     //@{
      66             :     /** Set the name of the frame. @version 1.3.3 */
      67             :     EQFABRIC_API void setName(const std::string& name);
      68             : 
      69             :     /** @return the name of the frame. @version 1.0 */
      70             :     EQFABRIC_API const std::string& getName() const;
      71             : 
      72             :     /** @return the position of the frame wrt the channel. @version 1.0 */
      73             :     EQFABRIC_API const Vector2i& getOffset() const;
      74             : 
      75             :     /**
      76             :      * Set the position of the frame wrt the channel.
      77             :      *
      78             :      * The offset is only applied for operations on this frame holder, i.e., it
      79             :      * does not apply to other (input) frames using the same underlying frame
      80             :      * data.
      81             :      * @version 1.0
      82             :      */
      83             :     EQFABRIC_API void setOffset(const Vector2i& offset);
      84             : 
      85             :     /**
      86             :      * Set the zoom for this frame holder.
      87             :      *
      88             :      * The zoom is only applied for operations on this frame holder, i.e., it
      89             :      * does not apply to other (input) frames using the same underlying frame
      90             :      * data.
      91             :      * @version 1.0
      92             :      */
      93             :     EQFABRIC_API void setZoom(const Zoom& zoom);
      94             : 
      95             :     /** @return the zoom factor for readback or assemble. @version 1.0 */
      96             :     EQFABRIC_API const Zoom& getZoom() const;
      97             : 
      98             :     /** @internal */
      99             :     EQFABRIC_API const co::ObjectVersion& getDataVersion(const Eye) const;
     100             :     //@}
     101             : 
     102             :     /** @internal @return the receiving eq::Node IDs of an output frame */
     103             :     EQFABRIC_API
     104             :     const std::vector<uint128_t>& getInputNodes(const Eye eye) const;
     105             : 
     106             :     /** @internal @return the receiving co::Node IDs of an output frame */
     107             :     EQFABRIC_API const co::NodeIDs& getInputNetNodes(const Eye eye) const;
     108             : 
     109             : protected:
     110          34 :     virtual ChangeType getChangeType() const { return INSTANCE; }
     111             :     EQFABRIC_API virtual void getInstanceData(co::DataOStream& os);
     112             :     EQFABRIC_API virtual void applyInstanceData(co::DataIStream& is);
     113             : 
     114             :     /** @internal */
     115             :     EQFABRIC_API void _setDataVersion(const unsigned i,
     116             :                                       const co::ObjectVersion& ov);
     117             : 
     118             :     /** @internal @return the receiving eq::Node IDs of an output frame */
     119             :     EQFABRIC_API std::vector<uint128_t>& _getInputNodes(const unsigned i);
     120             : 
     121             :     /** @internal @return the receiving co::Node IDs of an output frame */
     122             :     EQFABRIC_API co::NodeIDs& _getInputNetNodes(const unsigned i);
     123             : 
     124             : private:
     125             :     detail::Frame* const _impl;
     126             : };
     127             : 
     128         254 : inline bool operator&(const Frame::Buffer l, const Frame::Buffer r)
     129             : {
     130         254 :     return (static_cast<uint32_t>(l) & static_cast<uint32_t>(r));
     131             : }
     132             : 
     133           9 : inline Frame::Buffer operator|(const Frame::Buffer l, const Frame::Buffer r)
     134             : {
     135             :     return static_cast<Frame::Buffer>(static_cast<uint32_t>(l) |
     136           9 :                                       static_cast<uint32_t>(r));
     137             : }
     138             : 
     139           0 : inline Frame::Buffer& operator&=(Frame::Buffer& l, const Frame::Buffer r)
     140             : {
     141           0 :     l = static_cast<Frame::Buffer>(static_cast<uint32_t>(l) &
     142             :                                    static_cast<uint32_t>(r));
     143           0 :     return l;
     144             : }
     145             : 
     146         313 : inline Frame::Buffer& operator|=(Frame::Buffer& l, const Frame::Buffer r)
     147             : {
     148         313 :     l = static_cast<Frame::Buffer>(static_cast<uint32_t>(l) |
     149             :                                    static_cast<uint32_t>(r));
     150         313 :     return l;
     151             : }
     152             : 
     153           0 : inline Frame::Buffer operator~(const Frame::Buffer l)
     154             : {
     155           0 :     return static_cast<Frame::Buffer>(~static_cast<uint32_t>(l));
     156             : }
     157             : 
     158             : /** Print the frame to the given output stream. @version 1.4 */
     159             : EQFABRIC_API std::ostream& operator<<(std::ostream&, const Frame&);
     160             : /** Print the frame type to the given output stream. @version 1.0 */
     161             : EQFABRIC_API std::ostream& operator<<(std::ostream&, const Frame::Type);
     162             : /** Print the frame buffer value to the given output stream. @version 1.0 */
     163             : EQFABRIC_API std::ostream& operator<<(std::ostream&, const Frame::Buffer);
     164             : }
     165             : }
     166             : 
     167             : #endif // EQFABRIC_FRAME_H

Generated by: LCOV version 1.11