Equalizer  1.13.0
Parallel Rendering Framework
image.h
1 
2 /* Copyright (c) 2006-2016, Stefan Eilemann <eile@equalizergraphics.com>
3  * Daniel Nachbaur <danielnachbaur@gmail.com>
4  * Cedric Stalder <cedric.stalder@gmail.com>
5  * Enrique <egparedes@ifi.uzh.ch>
6  *
7  * This library is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License version 2.1 as published
9  * by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef EQ_IMAGE_H
22 #define EQ_IMAGE_H
23 
24 #include <eq/frame.h> // for Frame::Buffer enum
25 #include <eq/types.h>
26 
27 namespace eq
28 {
29 namespace detail { class Image; }
30 
36 class Image
37 {
38 public:
40  EQ_API Image();
41 
43  EQ_API virtual ~Image();
44 
58  EQ_API void setInternalFormat( const Frame::Buffer buffer,
59  const uint32_t internalFormat );
60 
62  EQ_API uint32_t getInternalFormat( const Frame::Buffer buffer )const;
63 
75  EQ_API uint32_t getExternalFormat( const Frame::Buffer buffer ) const;
76 
84  EQ_API uint32_t getPixelSize( const Frame::Buffer buffer ) const;
85 
91  EQ_API bool hasAlpha() const;
92 
104  EQ_API void setStorageType( const Frame::Type type );
105 
107  EQ_API Frame::Type getStorageType() const;
108 
120  EQ_API void setPixelViewport( const PixelViewport& pvp );
121 
123  EQ_API const PixelViewport& getPixelViewport() const;
124 
126  EQ_API void setZoom( const Zoom& zoom );
127 
129  EQ_API const Zoom& getZoom() const;
130 
132  EQ_API void setContext( const RenderContext& context );
133 
135  EQ_API const RenderContext& getContext() const;
136 
146  EQ_API void useCompressor( Frame::Buffer buffer, uint32_t name );
147 
157  EQ_API void reset();
158 
160  EQ_API void flush();
161 
168  EQ_API void deleteGLObjects( util::ObjectManager& om );
169 
176  EQ_API void resetPlugins();
178 
182  EQ_API const uint8_t* getPixelPointer( const Frame::Buffer buffer )
183  const;
184 
186  EQ_API uint8_t* getPixelPointer( const Frame::Buffer buffer );
187 
189  EQ_API uint32_t getPixelDataSize( const Frame::Buffer buffer ) const;
190 
192  EQ_API const PixelData& getPixelData( const Frame::Buffer ) const;
193 
195  EQ_API const PixelData& compressPixelData( const Frame::Buffer );
196 
201  EQ_API bool hasPixelData( const Frame::Buffer buffer ) const;
202 
207  EQ_API bool hasAsyncReadback( const Frame::Buffer buffer ) const;
208 
213  EQ_API bool hasAsyncReadback() const;
214 
225  EQ_API void clearPixelData( const Frame::Buffer buffer );
226 
228  EQ_API void validatePixelData( const Frame::Buffer buffer );
229 
241  EQ_API void setPixelData( const Frame::Buffer buffer,
242  const PixelData& data );
243 
248  EQ_API void setAlphaUsage( const bool enabled );
249 
251  EQ_API bool getAlphaUsage() const;
252 
265  EQ_API void setQuality( const Frame::Buffer buffer,
266  const float quality );
267 
269  EQ_API float getQuality( const Frame::Buffer buffer ) const;
271 
275  EQ_API const util::Texture& getTexture( const Frame::Buffer buffer )
276  const;
277 
282  EQ_API bool hasTextureData( const Frame::Buffer buffer ) const;
284 
298  EQ_API bool startReadback( const uint32_t buffers, const PixelViewport& pvp,
299  const RenderContext& context, const Zoom& zoom,
300  util::ObjectManager& glObjects );
301 
303  bool startReadback( const Frame::Buffer buffer,
304  const util::Texture* texture,
305  const GLEWContext* glewContext );
306 
313  EQ_API void finishReadback( const GLEWContext* glewContext );
314 
329  EQ_API bool upload( const Frame::Buffer buffer, util::Texture* texture,
330  const Vector2i& position,
331  util::ObjectManager& glObjects ) const;
332 
341  EQ_API bool writeImage( const std::string& filename,
342  const Frame::Buffer buffer ) const;
343 
345  EQ_API bool writeImages( const std::string& filenameTemplate ) const;
346 
348  EQ_API bool readImage( const std::string& filename,
349  const Frame::Buffer buffer );
350 
352  void setOffset( int32_t x, int32_t y );
354 
361  EQ_API std::vector< uint32_t >
362  findCompressors( const Frame::Buffer buffer ) const;
363 
368  EQ_API std::vector< uint32_t >
369  findTransferers( const Frame::Buffer buffer, const GLEWContext* gl )
370  const;
371 
373  EQ_API bool allocCompressor( const Frame::Buffer buffer,
374  const uint32_t name );
375 
377  EQ_API bool allocDownloader( const Frame::Buffer buffer,
378  const uint32_t name,
379  const GLEWContext* glewContext );
380 
382  EQ_API uint32_t getDownloaderName( const Frame::Buffer buffer ) const;
384 
385 private:
386  Image( const Image& ) = delete;
387  Image& operator=( const Image& ) = delete;
388  detail::Image* const _impl;
389 
391  const void* _getBufferKey( const Frame::Buffer buffer ) const;
392 
394  const void* _getCompressorKey( const Frame::Buffer buffer ) const;
395 
406  void _setExternalFormat( const Frame::Buffer buffer,
407  const uint32_t externalFormat,
408  const uint32_t pixelSize,
409  const bool hasAlpha );
410 
411  bool _readback( const Frame::Buffer buffer, const Zoom& zoom,
412  util::ObjectManager& glObjects );
413 
414  bool _startReadback( const Frame::Buffer buffer, const Zoom& zoom,
415  util::ObjectManager& glObjects );
416 
417  void _finishReadback( const Frame::Buffer buffer, const GLEWContext* );
418  bool _readbackZoom( const Frame::Buffer buffer, util::ObjectManager& om );
419  bool _writeImage( const std::string& filename, const Frame::Buffer buffer,
420  const unsigned char* data ) const;
421 };
422 };
423 #endif // EQ_IMAGE_H
EQ_API bool writeImages(const std::string &filenameTemplate) const
Write all valid pixel data as separate images.
EQ_API bool hasTextureData(const Frame::Buffer buffer) const
EQ_API bool getAlphaUsage() const
EQ_API const RenderContext & getContext() const
EQ_API uint32_t getInternalFormat(const Frame::Buffer buffer) const
EQ_API bool writeImage(const std::string &filename, const Frame::Buffer buffer) const
Write the pixel data as rgb image file.
EQ_API void setContext(const RenderContext &context)
Set the render context producing this image.
EQ_API Frame::Type getStorageType() const
EQ_API const PixelViewport & getPixelViewport() const
EQ_API bool upload(const Frame::Buffer buffer, util::Texture *texture, const Vector2i &position, util::ObjectManager &glObjects) const
Upload this image to the frame buffer or a texture.
EQ_API void flush()
Free all cached data of this image.
The pixel data structure manages the pixel information for images.
Definition: pixelData.h:33
EQ_API void setPixelData(const Frame::Buffer buffer, const PixelData &data)
Set the pixel data of the given image buffer.
EQ_API bool startReadback(const uint32_t buffers, const PixelViewport &pvp, const RenderContext &context, const Zoom &zoom, util::ObjectManager &glObjects)
Start reading back an image from the frame buffer.
EQ_API const uint8_t * getPixelPointer(const Frame::Buffer buffer) const
Buffer
Components of the frame are to be used during readback and assembly.
Definition: fabric/frame.h:39
A wrapper around OpenGL textures.
Definition: texture.h:38
EQ_API uint32_t getExternalFormat(const Frame::Buffer buffer) const
Get the external format of the given buffer.
EQ_API const Zoom & getZoom() const
Type
The storage type for pixel data.
Definition: fabric/frame.h:49
EQ_API void deleteGLObjects(util::ObjectManager &om)
Delete all OpenGL objects allocated from the given object manager.
EQ_API void useCompressor(Frame::Buffer buffer, uint32_t name)
Set a compressor to be used during transmission of the image.
EQ_API void setZoom(const Zoom &zoom)
Sets the zoom factor to be used for compositing.
A holder for pixel data.
Definition: image.h:36
EQ_API bool hasPixelData(const Frame::Buffer buffer) const
EQ_API Image()
Construct a new Image.
EQ_API void setInternalFormat(const Frame::Buffer buffer, const uint32_t internalFormat)
Set the internal format for the given buffer.
EQ_API const PixelData & compressPixelData(const Frame::Buffer)
EQ_API void setStorageType(const Frame::Type type)
Set the frame pixel storage type.
The Equalizer client library.
Definition: eq/agl/types.h:23
EQ_API void validatePixelData(const Frame::Buffer buffer)
Allocate an image buffer without initialization.
EQ_API uint32_t getPixelDataSize(const Frame::Buffer buffer) const
EQ_API float getQuality(const Frame::Buffer buffer) const
A facility class to manage OpenGL objects across shared contexts.
Definition: objectManager.h:52
EQ_API void clearPixelData(const Frame::Buffer buffer)
Clear and validate an image buffer.
EQ_API bool hasAsyncReadback() const
EQ_API void setQuality(const Frame::Buffer buffer, const float quality)
Set the minimum quality after a full download-compression path.
EQ_API void finishReadback(const GLEWContext *glewContext)
Finish an asynchronous readback.
EQ_API const util::Texture & getTexture(const Frame::Buffer buffer) const
Get the texture of this image.
EQ_API bool readImage(const std::string &filename, const Frame::Buffer buffer)
Read pixel data from an uncompressed rgb image file.
EQ_API void reset()
Reset the image to its default state.
EQ_API uint32_t getPixelSize(const Frame::Buffer buffer) const
Get the size, in bytes, of one pixel in the external pixel data.
EQ_API void setPixelViewport(const PixelViewport &pvp)
Set the internal pixel viewport of the image.
EQ_API bool hasAlpha() const
virtual EQ_API ~Image()
Destruct the Image.
EQ_API const PixelData & getPixelData(const Frame::Buffer) const
EQ_API void resetPlugins()
Deallocate all transfer and compression plugins.
EQ_API void setAlphaUsage(const bool enabled)
Set alpha data preservation during download and compression.