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