Equalizer  1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends 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/client/frame.h> // for Frame::Buffer enum
24 #include <eq/client/types.h>
25 
26 namespace eq
27 {
28 namespace detail { class Image; }
29 
35 class Image : public boost::noncopyable
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 
346  EQ_API bool writeImage( const std::string& filename,
347  const Frame::Buffer buffer ) const;
348 
350  EQ_API bool writeImages( const std::string& filenameTemplate ) const;
351 
353  EQ_API bool readImage( const std::string& filename,
354  const Frame::Buffer buffer );
355 
357  void setOffset( int32_t x, int32_t y );
359 
366  EQ_API std::vector< uint32_t >
367  findCompressors( const Frame::Buffer buffer ) const;
368 
373  EQ_API std::vector< uint32_t >
374  findTransferers( const Frame::Buffer buffer, const GLEWContext* gl )
375  const;
376 
378  EQ_API bool allocCompressor( const Frame::Buffer buffer,
379  const uint32_t name );
380 
382  EQ_API bool allocDownloader( const Frame::Buffer buffer,
383  const uint32_t name,
384  const GLEWContext* glewContext );
385 
387  EQ_API uint32_t getDownloaderName( const Frame::Buffer buffer ) const;
389 
390 private:
391  detail::Image* const _impl;
392 
394  const void* _getBufferKey( const Frame::Buffer buffer ) const;
395 
397  const void* _getCompressorKey( const Frame::Buffer buffer ) const;
398 
409  void _setExternalFormat( const Frame::Buffer buffer,
410  const uint32_t externalFormat,
411  const uint32_t pixelSize,
412  const bool hasAlpha );
413 
414  bool _readback( const Frame::Buffer buffer, const Zoom& zoom,
415  util::ObjectManager& glObjects );
416 
417  bool _startReadback( const Frame::Buffer buffer, const Zoom& zoom,
418  util::ObjectManager& glObjects );
419 
420  void _finishReadback( const Frame::Buffer buffer, const GLEWContext* );
421  bool _readbackZoom( const Frame::Buffer buffer, util::ObjectManager& om );
422 };
423 };
424 #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:51
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.