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