LCOV - code coverage report
Current view: top level - eq - frameData.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 1 2 50.0 %
Date: 2016-09-29 05:02:09 Functions: 2 3 66.7 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2006-2016, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                          Daniel Nachbaur <danielnachbaur@gmail.com>
       4             :  *                          Enrique <egparedes@ifi.uzh.ch>
       5             :  *
       6             :  * This library is free software; you can redistribute it and/or modify it under
       7             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       8             :  * by the Free Software Foundation.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      11             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      12             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      13             :  * details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public License
      16             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      17             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      18             :  */
      19             : 
      20             : #ifndef EQ_FRAMEDATA_H
      21             : #define EQ_FRAMEDATA_H
      22             : 
      23             : #include <eq/frame.h>         // enum Frame::Buffer
      24             : #include <eq/types.h>
      25             : #include <eq/fabric/frameData.h> // base class
      26             : #include <co/object.h>               // base class
      27             : #include <lunchbox/monitor.h>        // member
      28             : #include <lunchbox/spinLock.h>       // member
      29             : 
      30             : namespace eq
      31             : {
      32             : namespace detail { class FrameData; }
      33             : 
      34             : /**
      35             :  * A holder for multiple images.
      36             :  *
      37             :  * The FrameData is used to connect the Image data for multiple frames.
      38             :  * Equalizer uses the same frame data for all input and output frames of the
      39             :  * same name. This enables frame-specific parameters to be set on the Frame, and
      40             :  * generic parameters (of the output frame) to be set on the FrameData, as well
      41             :  * as ready synchronization of the pixel data.
      42             :  *
      43             :  * An application may allocate its own Frame and FrameData for
      44             :  * application-specific purposes.
      45             :  *
      46             :  * Parameters set on an Equalizer output frame data are automatically
      47             :  * transported to the corresponding input frames.
      48             :  */
      49             : class FrameData : public fabric::FrameData, public co::Object,
      50             :                   public lunchbox::Referenced
      51             : {
      52             : public:
      53             :     void assembleFrame( Frame* frame, Channel* channel );
      54             :     struct ImageHeader
      55             :     {
      56             :         uint32_t                internalFormat;
      57             :         uint32_t                externalFormat;
      58             :         uint32_t                pixelSize;
      59             :         fabric::PixelViewport   pvp;
      60             :         uint32_t                compressorName;
      61             :         uint32_t                compressorFlags;
      62             :         uint32_t                nChunks;
      63             :         float                   quality;
      64             :     };
      65             : 
      66             :     /** Construct a new frame data holder. @version 1.0 */
      67             :     EQ_API FrameData();
      68             : 
      69             :     /** Destruct this frame data. @version 1.0 */
      70             :     EQ_API virtual ~FrameData();
      71             : 
      72             :     /** @name Data Access */
      73             :     //@{
      74             :     /** The images of this frame data holder. @version 1.0 */
      75             :     EQ_API const Images& getImages() const;
      76             : 
      77             :     /**
      78             :      * Set alpha usage for newly allocated images.
      79             :      *
      80             :      * Disabling alpha allows the selection of download or compression
      81             :      * plugins which drop the alpha channel for better performance.
      82             :      * @version 1.0
      83             :      */
      84             :     EQ_API void setAlphaUsage( const bool useAlpha );
      85             : 
      86             :     /**
      87             :      * Set the minimum quality after download and compression.
      88             :      *
      89             :      * Setting a lower quality decreases the image quality while increasing
      90             :      * the performance of scalable rendering. An application typically
      91             :      * selects a lower quality during interaction. Setting a quality of 1.0
      92             :      * provides lossless image compositing.
      93             :      * @version 1.0
      94             :      */
      95             :     void setQuality( const Frame::Buffer buffer, const float quality );
      96             : 
      97             :     /**
      98             :      * Sets a compressor which will be allocated and used during transmit of
      99             :      * the image buffer. The default compressor is EQ_COMPRESSOR_AUTO which
     100             :      * selects the most suitable compressor wrt the current image and buffer
     101             :      * parameters.
     102             :      * @sa _chooseCompressor()
     103             :      *
     104             :      * @param buffer the frame buffer attachment.
     105             :      * @param name the compressor name.
     106             :      */
     107             :     void useCompressor( const Frame::Buffer buffer, const uint32_t name );
     108             :     //@}
     109             : 
     110             :     /** @name Operations */
     111             :     //@{
     112             :     /**
     113             :      * Allocate and add a new image.
     114             :      *
     115             :      * The allocated image inherits the current quality, storage type from
     116             :      * this frame data and the internal format corresponding to the given
     117             :      * drawable config.
     118             :      *
     119             :      * @return the image.
     120             :      * @version 1.0
     121             :      */
     122             :     EQ_API Image* newImage( const Frame::Type type,
     123             :                             const DrawableConfig& config );
     124             : 
     125             :     /** Clear the frame by recycling the attached images. @version 1.0 */
     126             :     EQ_API void clear();
     127             : 
     128             :     /** Flush the frame by deleting all images. @version 1.0 */
     129             :     EQ_API void flush();
     130             : 
     131             :     /** Delete data allocated by the given object manager on all images.*/
     132             :     void deleteGLObjects( util::ObjectManager& om );
     133             : 
     134             :     /** Deallocate all transfer and compression plugins on all images. */
     135             :     EQ_API void resetPlugins();
     136             : 
     137             :     /**
     138             :      * Start reading back a set of images for this frame data.
     139             :      *
     140             :      * The newly read images are added to the data using
     141             :      * newImage(). Existing images are retained.
     142             :      *
     143             :      * @param frame the corresponding output frame holder.
     144             :      * @param glObjects the GL object manager for the current GL context.
     145             :      * @param config the configuration of the source frame buffer.
     146             :      * @param regions the areas to read back.
     147             :      * @param context the render context producing the pixel data.
     148             :      * @return the new images which need finishReadback.
     149             :      * @version 1.3.0
     150             :      */
     151             :     Images startReadback( const Frame& frame,
     152             :                           util::ObjectManager& glObjects,
     153             :                           const DrawableConfig& config,
     154             :                           const PixelViewports& regions,
     155             :                           const RenderContext& context );
     156             : 
     157             :     /**
     158             :      * Set the frame data ready.
     159             :      *
     160             :      * The frame data is automatically set ready by readback() and after
     161             :      * receiving an output frame.
     162             :      * @version 1.0
     163             :      */
     164             :     void setReady();
     165             : 
     166             :     /** @return true if the frame data is ready. @version 1.0 */
     167             :     EQ_API bool isReady() const;
     168             : 
     169             :     /** Wait for the frame data to become available. @version 1.0 */
     170             :     EQ_API void waitReady( const uint32_t timeout = LB_TIMEOUT_INDEFINITE )
     171             :         const;
     172             : 
     173             :     /** @internal */
     174             :     void setVersion( const uint64_t version );
     175             : 
     176             :     typedef lunchbox::Monitor< uint32_t > Listener; //!< Ready listener
     177             : 
     178             :     /**
     179             :      * Add a ready listener.
     180             :      *
     181             :      * The listener value will will be incremented when the frame is ready,
     182             :      * which might happen immediately.
     183             :      *
     184             :      * @param listener the listener.
     185             :      * @version 1.0
     186             :      */
     187             :     void addListener( Listener& listener );
     188             : 
     189             :     /**
     190             :      * Remove a frame listener.
     191             :      *
     192             :      * @param listener the listener.
     193             :      * @version 1.0
     194             :      */
     195             :     void removeListener( Listener& listener );
     196             :     //@}
     197             : 
     198             :     /** @internal */
     199             :     bool addImage( const co::ObjectVersion& frameDataVersion,
     200             :                    const PixelViewport& pvp, const Zoom& zoom,
     201             :                    const RenderContext& context, const uint32_t buffers,
     202             :                    const bool useAlpha, uint8_t* data );
     203             :     void setReady( const co::ObjectVersion& frameData,
     204             :                    const fabric::FrameData& data ); //!< @internal
     205             : 
     206             : protected:
     207           0 :     virtual ChangeType getChangeType() const { return INSTANCE; }
     208             :     virtual void getInstanceData( co::DataOStream& os );
     209             :     virtual void applyInstanceData( co::DataIStream& is );
     210             : 
     211             : private:
     212             :     detail::FrameData* const _impl;
     213             : 
     214             :     /** Allocate or reuse an image. */
     215             :     Image* _allocImage( const Frame::Type type,
     216             :                         const DrawableConfig& config,
     217             :                         const bool setQuality );
     218             : 
     219             :     /** Apply all received images of the given version. */
     220             :     void _applyVersion( const uint128_t& version );
     221             : 
     222             :     /** Set a specific version ready. */
     223             :     void _setReady( const uint64_t version );
     224             : 
     225           2 :     LB_TS_VAR( _commandThread );
     226             : };
     227             : 
     228             : /** Print the frame data to the given output stream. @version 1.4 */
     229             : EQ_API std::ostream& operator << ( std::ostream&, const FrameData& );
     230             : }
     231             : 
     232             : #endif // EQ_FRAMEDATA_H

Generated by: LCOV version 1.11