LCOV - code coverage report
Current view: top level - eq/fabric - frame.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 27 81 33.3 %
Date: 2016-07-30 05:04:55 Functions: 14 28 50.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2012-2014, 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             : #include "frame.h"
      19             : 
      20             : #include "zoom.h"
      21             : #include <co/dataIStream.h>
      22             : #include <co/dataOStream.h>
      23             : 
      24             : namespace eq
      25             : {
      26             : namespace fabric
      27             : {
      28       66780 : struct ToNodes
      29             : {
      30             :     std::vector< uint128_t > inputNodes;
      31             :     co::NodeIDs inputNetNodes;
      32             : };
      33             : 
      34             : namespace detail
      35             : {
      36       11130 : class Frame
      37             : {
      38             : public:
      39             :     // shared data:
      40             :     std::string name;
      41             :     Vector2i offset;
      42             :     Zoom zoom;
      43             :     co::ObjectVersion frameDataVersion[ NUM_EYES ];
      44             :     ToNodes toNodes[ NUM_EYES ];
      45             : 
      46       11130 :     Frame() : offset( Vector2i::ZERO ) {}
      47             : 
      48           0 :     void serialize( co::DataOStream& os ) const
      49             :     {
      50           0 :         os << name << offset << zoom;
      51             : 
      52           0 :         for( unsigned i = 0; i < NUM_EYES; ++i )
      53           0 :             os << frameDataVersion[i] << toNodes[i].inputNodes
      54           0 :                << toNodes[i].inputNetNodes;
      55           0 :     }
      56             : 
      57           0 :     void deserialize( co::DataIStream& is )
      58             :     {
      59           0 :         is >> name >> offset >> zoom;
      60             : 
      61           0 :         for( unsigned i = 0; i < NUM_EYES; ++i )
      62           0 :             is >> frameDataVersion[i] >> toNodes[i].inputNodes
      63           0 :                >> toNodes[i].inputNetNodes;
      64           0 :     }
      65             : };
      66             : }
      67       11130 : Frame::Frame()
      68       11130 :         : _impl( new detail::Frame )
      69       11130 : {}
      70             : 
      71       22260 : Frame::~Frame()
      72             : {
      73       11130 :     delete _impl;
      74       11130 : }
      75             : 
      76           0 : void Frame::getInstanceData( co::DataOStream& os )
      77             : {
      78           0 :     _impl->serialize( os );
      79           0 : }
      80             : 
      81           0 : void Frame::applyInstanceData( co::DataIStream& is )
      82             : {
      83           0 :     _impl->deserialize( is );
      84           0 : }
      85             : 
      86        5564 : void Frame::setName( const std::string& name )
      87             : {
      88        5564 :     _impl->name = name;
      89        5564 : }
      90             : 
      91        8346 : const std::string& Frame::getName() const
      92             : {
      93        8346 :     return _impl->name;
      94             : }
      95             : 
      96         126 : const Vector2i& Frame::getOffset() const
      97             : {
      98         126 :     return _impl->offset;
      99             : }
     100             : 
     101           0 : void Frame::setOffset( const Vector2i& offset )
     102             : {
     103           0 :     _impl->offset = offset;
     104           0 : }
     105             : 
     106        5564 : void Frame::setZoom( const Zoom& zoom )
     107             : {
     108        5564 :     _impl->zoom = zoom;
     109        5564 : }
     110             : 
     111        2908 : const Zoom& Frame::getZoom() const
     112             : {
     113        2908 :     return _impl->zoom;
     114             : }
     115             : 
     116           0 : void Frame::_setDataVersion( const unsigned i, const co::ObjectVersion& ov )
     117             : {
     118           0 :     _impl->frameDataVersion[ i ] = ov;
     119           0 : }
     120             : 
     121           0 : const co::ObjectVersion& Frame::getDataVersion( const Eye eye ) const
     122             : {
     123           0 :     return _impl->frameDataVersion[ lunchbox::getIndexOfLastBit( eye )];
     124             : }
     125             : 
     126           0 : const std::vector< uint128_t >& Frame::getInputNodes( const Eye eye ) const
     127             : {
     128           0 :     return _impl->toNodes[ lunchbox::getIndexOfLastBit( eye )].inputNodes;
     129             : }
     130             : 
     131           0 : const co::NodeIDs& Frame::getInputNetNodes(const Eye eye) const
     132             : {
     133           0 :     return _impl->toNodes[ lunchbox::getIndexOfLastBit( eye )].inputNetNodes;
     134             : }
     135             : 
     136           0 : std::vector< uint128_t >& Frame::_getInputNodes( const unsigned i )
     137             : {
     138           0 :     return _impl->toNodes[ i ].inputNodes;
     139             : }
     140             : 
     141           0 : co::NodeIDs& Frame::_getInputNetNodes( const unsigned i )
     142             : {
     143           0 :     return _impl->toNodes[ i ].inputNetNodes;
     144             : }
     145             : 
     146           0 : std::ostream& operator << ( std::ostream& os, const Frame& frame )
     147             : {
     148           0 :     os << lunchbox::disableFlush << "frame" << std::endl
     149           0 :        << "{" << std::endl << lunchbox::indent
     150           0 :        << "name     \"" << frame.getName() << "\"" << std::endl;
     151             : 
     152           0 :     const Zoom& zoom = frame.getZoom();
     153           0 :     if( zoom.isValid() && zoom != Zoom::NONE )
     154           0 :         os << zoom << std::endl;
     155             : 
     156           0 :     return os << lunchbox::exdent << "}" << std::endl << lunchbox::enableFlush;
     157             : }
     158             : 
     159          62 : std::ostream& operator << ( std::ostream& os, const Frame::Type type )
     160             : {
     161          62 :     os << "type     ";
     162          62 :     if ( type == Frame::TYPE_TEXTURE )
     163          62 :         os << " texture" << std::endl;
     164           0 :     else if ( type == Frame::TYPE_MEMORY )
     165           0 :         os << " memory" << std::endl;
     166             : 
     167          62 :     return os;
     168             : }
     169             : 
     170           0 : std::ostream& operator << ( std::ostream& os, const Frame::Buffer buffer )
     171             : {
     172           0 :     if( buffer == Frame::BUFFER_NONE )
     173           0 :         os << "none ";
     174           0 :     else if( buffer & Frame::BUFFER_UNDEFINED )
     175           0 :         os << "undefined ";
     176             :     else
     177             :     {
     178           0 :         if( buffer & Frame::BUFFER_COLOR )
     179           0 :             os << "color ";
     180           0 :         if( buffer & Frame::BUFFER_DEPTH )
     181           0 :             os << "depth ";
     182             :     }
     183             : 
     184           0 :     return os;
     185             : }
     186             : 
     187             : }
     188          84 : }

Generated by: LCOV version 1.11