LCOV - code coverage report
Current view: top level - eq - frameData.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 1 2 50.0 %
Date: 2017-12-16 05:07:20 Functions: 2 3 66.7 %

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

Generated by: LCOV version 1.11