Equalizer  1.10.1
Parallel Rendering Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
image.h
1 
2 /* Copyright (c) 2006-2014, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2011, Daniel Nachbaur <danielnachbaur@gmail.com>
4  * 2010, Cedric Stalder <cedric.stalder@gmail.com>
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_IMAGE_H
21 #define EQ_IMAGE_H
22 
23 #include <eq/frame.h> // for Frame::Buffer enum
24 #include <eq/types.h>
25 
26 namespace eq
27 {
28 namespace detail { class Image; }
29 
35 class Image
36 {
37 public:
39  EQ_API Image();
40 
42  EQ_API virtual ~Image();
43 
57  EQ_API void setInternalFormat( const Frame::Buffer buffer,
58  const uint32_t internalFormat );
59 
61  EQ_API uint32_t getInternalFormat( const Frame::Buffer buffer )const;
62 
74  EQ_API uint32_t getExternalFormat( const Frame::Buffer buffer ) const;
75 
83  EQ_API uint32_t getPixelSize( const Frame::Buffer buffer ) const;
84 
90  EQ_API bool hasAlpha() const;
91 
103  EQ_API void setStorageType( const Frame::Type type );
104 
106  EQ_API Frame::Type getStorageType() const;
107 
119  EQ_API void setPixelViewport( const PixelViewport& pvp );
120 
122  EQ_API const PixelViewport& getPixelViewport() const;
123 
125  EQ_API void setZoom( const Zoom& zoom );
126 
128  EQ_API const Zoom& getZoom() const;
129 
139  EQ_API void useCompressor( const Frame::Buffer buffer,
140  const uint32_t name );
141 
151  EQ_API void reset();
152 
154  EQ_API void flush();
155 
162  EQ_API void deleteGLObjects( util::ObjectManager& om );
163 
170  EQ_API void resetPlugins();
172 
176  EQ_API const uint8_t* getPixelPointer( const Frame::Buffer buffer )
177  const;
178 
180  EQ_API uint8_t* getPixelPointer( const Frame::Buffer buffer );
181 
183  EQ_API uint32_t getPixelDataSize( const Frame::Buffer buffer ) const;
184 
186  EQ_API const PixelData& getPixelData( const Frame::Buffer ) const;
187 
189  EQ_API const PixelData& compressPixelData( const Frame::Buffer );
190 
195  EQ_API bool hasPixelData( const Frame::Buffer buffer ) const;
196 
201  EQ_API bool hasAsyncReadback( const Frame::Buffer buffer ) const;
202 
207  EQ_API bool hasAsyncReadback() const;
208 
219  EQ_API void clearPixelData( const Frame::Buffer buffer );
220 
222  EQ_API void validatePixelData( const Frame::Buffer buffer );
223 
235  EQ_API void setPixelData( const Frame::Buffer buffer,
236  const PixelData& data );
237 
242  EQ_API void setAlphaUsage( const bool enabled );
243 
245  EQ_API bool getAlphaUsage() const;
246 
259  EQ_API void setQuality( const Frame::Buffer buffer,
260  const float quality );
261 
263  EQ_API float getQuality( const Frame::Buffer buffer ) const;
265 
269  EQ_API const util::Texture& getTexture( const Frame::Buffer buffer )
270  const;
271 
276  EQ_API bool hasTextureData( const Frame::Buffer buffer ) const;
278 
281 #ifndef EQ_2_0_API
282 
293  EQ_API bool readback( const uint32_t buffers, const PixelViewport& pvp,
294  const Zoom& zoom, util::ObjectManager& glObjects);
295 
296  /* @deprecated Use finishReadback without Zoom */
297  EQ_API void finishReadback( const Zoom&, const GLEWContext* );
298 #endif
299 
310  EQ_API bool startReadback( const uint32_t buffers,
311  const PixelViewport& pvp, const Zoom& zoom,
312  util::ObjectManager& glObjects );
313 
315  bool startReadback( const Frame::Buffer buffer,
316  const util::Texture* texture,
317  const GLEWContext* glewContext );
318 
325  EQ_API void finishReadback( const GLEWContext* glewContext );
326 
341  EQ_API bool upload( const Frame::Buffer buffer, util::Texture* texture,
342  const Vector2i& position,
343  util::ObjectManager& glObjects ) const;
344 
353  EQ_API bool writeImage( const std::string& filename,
354  const Frame::Buffer buffer ) const;
355 
357  EQ_API bool writeImages( const std::string& filenameTemplate ) const;
358 
360  EQ_API bool readImage( const std::string& filename,
361  const Frame::Buffer buffer );
362 
364  void setOffset( int32_t x, int32_t y );
366 
373  EQ_API std::vector< uint32_t >
374  findCompressors( const Frame::Buffer buffer ) const;
375 
380  EQ_API std::vector< uint32_t >
381  findTransferers( const Frame::Buffer buffer, const GLEWContext* gl )
382  const;
383 
385  EQ_API bool allocCompressor( const Frame::Buffer buffer,
386  const uint32_t name );
387 
389  EQ_API bool allocDownloader( const Frame::Buffer buffer,
390  const uint32_t name,
391  const GLEWContext* glewContext );
392 
394  EQ_API uint32_t getDownloaderName( const Frame::Buffer buffer ) const;
396 
397 private:
398  Image( const Image& ) = delete;
399  Image& operator=( const Image& ) = delete;
400  detail::Image* const _impl;
401 
403  const void* _getBufferKey( const Frame::Buffer buffer ) const;
404 
406  const void* _getCompressorKey( const Frame::Buffer buffer ) const;
407 
418  void _setExternalFormat( const Frame::Buffer buffer,
419  const uint32_t externalFormat,
420  const uint32_t pixelSize,
421  const bool hasAlpha );
422 
423  bool _readback( const Frame::Buffer buffer, const Zoom& zoom,
424  util::ObjectManager& glObjects );
425 
426  bool _startReadback( const Frame::Buffer buffer, const Zoom& zoom,
427  util::ObjectManager& glObjects );
428 
429  void _finishReadback( const Frame::Buffer buffer, const GLEWContext* );
430  bool _readbackZoom( const Frame::Buffer buffer, util::ObjectManager& om );
431 };
432 };
433 #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 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 Frame::Type getStorageType() const
EQ_API bool startReadback(const uint32_t buffers, const PixelViewport &pvp, const Zoom &zoom, util::ObjectManager &glObjects)
Start reading back an image from the frame buffer.
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 const uint8_t * getPixelPointer(const Frame::Buffer buffer) const
Buffer
The buffer format defines which components of the frame are to be used during readback and assembly...
Definition: fabric/frame.h:40
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:50
EQ_API void deleteGLObjects(util::ObjectManager &om)
Delete all OpenGL objects allocated from the given object manager.
EQ_API void setZoom(const Zoom &zoom)
Sets the zoom factor to be used for compositing.
A holder for pixel data.
Definition: image.h:35
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.
EQ_API void validatePixelData(const Frame::Buffer buffer)
Allocate an image buffer without initialization.
EQ_API void useCompressor(const Frame::Buffer buffer, const uint32_t name)
Set a compressor to be used during transmission of the image.
EQ_API uint32_t getPixelDataSize(const Frame::Buffer buffer) const
EQ_API float getQuality(const Frame::Buffer buffer) const
EQ_API bool readback(const uint32_t buffers, const PixelViewport &pvp, const Zoom &zoom, util::ObjectManager &glObjects)
Read back an image from the frame buffer.
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 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.