LCOV - code coverage report
Current view: top level - lunchbox/compressor - compressor.h (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 3 13 23.1 %
Date: 2014-10-01 Functions: 3 8 37.5 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2009-2010, Cedric Stalder <cedric.stalder@gmail.com>
       3             :  *               2009-2013, Stefan Eilemann <eile@equalizergraphics.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 LUNCHBOX_PLUGIN_COMPRESSOR
      20             : #define LUNCHBOX_PLUGIN_COMPRESSOR
      21             : 
      22             : #include <lunchbox/plugins/compressor.h>
      23             : 
      24             : #include <lunchbox/buffer.h>
      25             : #include <lunchbox/plugin.h>
      26             : #include <vector>
      27             : 
      28             : /**
      29             :  * @file lunchbox/compressor/compressor.h
      30             :  *
      31             :  * Compression plugins provided with Lunchbox.
      32             :  */
      33             : namespace lunchbox
      34             : {
      35             : namespace plugin
      36             : {
      37             : class Compressor
      38             : {
      39             : public:
      40             :     typedef void        ( *GetInfo_t )( EqCompressorInfo* const );
      41             :     typedef Compressor* ( *NewCompressor_t )( const unsigned );
      42             :     typedef void        ( *Decompress_t )( const void* const*,
      43             :                                            const eq_uint64_t* const,
      44             :                                            const unsigned, void* const,
      45             :                                            eq_uint64_t* const,
      46             :                                            const eq_uint64_t, void* const );
      47             :     typedef bool        ( *IsCompatible_t )( const GLEWContext* );
      48             :     struct Functions
      49             :     {
      50             :         Functions( const unsigned name, GetInfo_t getInfo,
      51             :                    NewCompressor_t newCompressor,
      52             :                    NewCompressor_t newDecompressor,
      53             :                    Decompress_t decompress, IsCompatible_t isCompatible );
      54             : 
      55             :         unsigned name;
      56             :         GetInfo_t getInfo;
      57             :         NewCompressor_t newCompressor;
      58             :         NewCompressor_t newDecompressor;
      59             :         Decompress_t decompress;
      60             :         IsCompatible_t isCompatible;
      61             :     };
      62             : 
      63             :     /** Construct a new compressor. */
      64             :     Compressor();
      65             :     virtual ~Compressor();
      66             : 
      67             :     /**
      68             :      * Compress data.
      69             :      *
      70             :      * @param inData data to compress.
      71             :      * @param inDims input dimensions.
      72             :      * @param flags compression flags.
      73             :      */
      74             :     virtual void compress( const void* const inData, const eq_uint64_t* inDims,
      75             :                            const eq_uint64_t flags );
      76             : 
      77             :     /**
      78             :      * Compress data.
      79             :      *
      80             :      * @param inData data to compress.
      81             :      * @param nPixels number data to compress.
      82             :      * @param useAlpha use alpha channel in compression.
      83             :      */
      84           0 :     virtual void compress( const void* const inData LB_UNUSED,
      85             :                            const eq_uint64_t nPixels LB_UNUSED,
      86           0 :                            const bool useAlpha LB_UNUSED ) { LBDONTCALL; };
      87             : 
      88             :     typedef lunchbox::Bufferb Result;
      89             :     typedef std::vector< Result* > ResultVector;
      90             : 
      91             :     /** @return the vector containing the result data. */
      92         566 :     const ResultVector& getResults() const { return _results; }
      93             : 
      94             :     /** @return the number of result items produced. */
      95         152 :     unsigned getNResults() const { return _nResults; }
      96             : 
      97             :     /**
      98             :      * Transfer frame buffer data into main memory.
      99             :      *
     100             :      * @param glewContext the initialized GLEW context describing
     101             :      *                    corresponding to the current OpenGL context.
     102             :      * @param inDims the dimensions of the input data (x, w, y, h).
     103             :      * @param source texture name to process.
     104             :      * @param flags capability flags for the compression (see description).
     105             :      * @param outDims the dimensions of the output data (see description).
     106             :      * @param out the pointer to the output data.
     107             :      */
     108           0 :     virtual void download( const GLEWContext* glewContext LB_UNUSED,
     109             :                            const eq_uint64_t  inDims[4] LB_UNUSED,
     110             :                            const unsigned     source LB_UNUSED,
     111             :                            const eq_uint64_t  flags LB_UNUSED,
     112             :                            eq_uint64_t        outDims[4] LB_UNUSED,
     113           0 :                            void**             out LB_UNUSED ) { LBDONTCALL; }
     114             : 
     115             :     /**
     116             :      * Transfer data from main memory into GPU memory.
     117             :      *
     118             :      * @param glewContext the initialized GLEW context describing
     119             :      *                    corresponding to the current OpenGL context.
     120             :      * @param buffer the datas input.
     121             :      * @param inDims the dimension of data in the frame buffer.
     122             :      * @param flags capability flags for the compression.
     123             :      * @param outDims the result data size
     124             :      * @param destination the destination texture name.
     125             :      */
     126           0 :     virtual void upload( const GLEWContext* glewContext LB_UNUSED,
     127             :                          const void*        buffer LB_UNUSED,
     128             :                          const eq_uint64_t  inDims[4] LB_UNUSED,
     129             :                          const eq_uint64_t  flags LB_UNUSED,
     130             :                          const eq_uint64_t  outDims[4] LB_UNUSED,
     131           0 :                          const unsigned destination LB_UNUSED ) { LBDONTCALL; }
     132             : 
     133             :     /**
     134             :      * Start transferring frame buffer data into main memory.
     135             :      *
     136             :      * @param glewContext the initialized GLEW context describing
     137             :      *                    corresponding to the current OpenGL context.
     138             :      * @param inDims the dimensions of the input data (x, w, y, h).
     139             :      * @param source texture name, if EQ_COMPRESSOR_USE_TEXTURE_2D or
     140             :      *               EQ_COMPRESSOR_USE_TEXTURE_RECT is set.
     141             :      * @param flags capability flags for the compression (see description).
     142             :      * @version 4
     143             :      */
     144           0 :     virtual void startDownload( const GLEWContext* glewContext LB_UNUSED,
     145             :                                 const eq_uint64_t  inDims[4] LB_UNUSED,
     146             :                                 const unsigned     source LB_UNUSED,
     147           0 :                                 const eq_uint64_t flags LB_UNUSED ) {LBDONTCALL}
     148             : 
     149             : 
     150             :     /**
     151             :      * Finish transferring frame buffer data into main memory.
     152             :      *
     153             :      * @param glewContext the initialized GLEW context describing
     154             :      *                    corresponding to the current OpenGL context.
     155             :      * @param inDims the dimensions of the input data (x, w, y, h).
     156             :      * @param source texture name, if EQ_COMPRESSOR_USE_TEXTURE_2D or
     157             :      *               EQ_COMPRESSOR_USE_TEXTURE_RECT is set.
     158             :      * @param flags capability flags for the compression (see description).
     159             :      * @param outDims the dimensions of the output data (see description).
     160             :      * @param out the pointer to the output data.
     161             :      * @version 4
     162             :      */
     163           0 :     virtual void finishDownload( const GLEWContext* glewContext LB_UNUSED,
     164             :                                  const eq_uint64_t  inDims[4] LB_UNUSED,
     165             :                                  const unsigned     source LB_UNUSED,
     166             :                                  const eq_uint64_t  flags LB_UNUSED,
     167             :                                  eq_uint64_t        outDims[4] LB_UNUSED,
     168           0 :                                  void** out LB_UNUSED ) { LBDONTCALL; }
     169             : 
     170             :     /** @internal Register a new plugin engine. */
     171             :     static void registerEngine( const Functions& functions );
     172             : 
     173             :     /** Convenience function for instance-less decompressor allocation. */
     174         152 :     static Compressor* getNewDecompressor( const unsigned /*name*/ ){ return 0;}
     175             : 
     176             : protected:
     177             :     ResultVector _results;  //!< The compressed data
     178             :     unsigned _nResults;     //!< Number of elements used in _results
     179             : 
     180             : };
     181             : }
     182             : }
     183             : 
     184             : #endif // LUNCHBOX_PLUGIN_COMPRESSOR

Generated by: LCOV version 1.10