Equalizer  1.6.1
image.h
1 
2 /* Copyright (c) 2006-2013, 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
36  {
37  public:
39  EQ_API Image();
40 
42  EQ_API virtual ~Image();
43 
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 
76  EQ_API uint32_t getExternalFormat( const Frame::Buffer buffer ) const;
77 
85  EQ_API uint32_t getPixelSize( const Frame::Buffer buffer ) const;
86 
92  EQ_API bool hasAlpha() const;
93 
105  EQ_API void setStorageType( const Frame::Type type );
106 
108  EQ_API Frame::Type getStorageType() const;
109 
121  EQ_API void setPixelViewport( const PixelViewport& pvp );
122 
124  EQ_API const PixelViewport& getPixelViewport() const;
125 
127  EQ_API void setZoom( const Zoom& zoom );
128 
130  EQ_API const Zoom& getZoom() const;
131 
141  EQ_API void useCompressor( const Frame::Buffer buffer,
142  const uint32_t name );
143 
153  EQ_API void reset();
154 
156  EQ_API void flush();
157 
164  EQ_API void deleteGLObjects( ObjectManager* om );
165 
172  EQ_API void resetPlugins();
174 
178  EQ_API const uint8_t* getPixelPointer( const Frame::Buffer buffer )
179  const;
180 
182  EQ_API uint8_t* getPixelPointer( const Frame::Buffer buffer );
183 
185  EQ_API uint32_t getPixelDataSize( const Frame::Buffer buffer ) const;
186 
188  EQ_API const PixelData& getPixelData( const Frame::Buffer ) const;
189 
191  EQ_API const PixelData& compressPixelData( const Frame::Buffer );
192 
197  EQ_API bool hasPixelData( const Frame::Buffer buffer ) const;
198 
203  EQ_API bool hasAsyncReadback( const Frame::Buffer buffer ) const;
204 
209  EQ_API bool hasAsyncReadback() const;
210 
221  EQ_API void clearPixelData( const Frame::Buffer buffer );
222 
224  EQ_API void validatePixelData( const Frame::Buffer buffer );
225 
237  EQ_API void setPixelData( const Frame::Buffer buffer,
238  const PixelData& data );
239 
244  EQ_API void setAlphaUsage( const bool enabled );
245 
247  EQ_API bool getAlphaUsage() const;
248 
261  EQ_API void setQuality( const Frame::Buffer buffer,
262  const float quality );
263 
265  EQ_API float getQuality( const Frame::Buffer buffer ) const;
267 
271  EQ_API const util::Texture& getTexture( const Frame::Buffer buffer )
272  const;
273 
278  EQ_API bool hasTextureData( const Frame::Buffer buffer ) const;
280 
283 #ifndef EQ_2_0_API
284 
295  EQ_API bool readback( const uint32_t buffers, const PixelViewport& pvp,
296  const Zoom& zoom, ObjectManager* glObjects );
297 #endif
298 
309  EQ_API bool startReadback( const uint32_t buffers,
310  const PixelViewport& pvp, const Zoom& zoom,
311  ObjectManager* glObjects );
312 
314  bool startReadback( const Frame::Buffer buffer,
315  const util::Texture* texture,
316  const GLEWContext* glewContext );
317 
325  EQ_API void finishReadback( const Zoom& zoom,
326  const GLEWContext* glewContext );
327 
343  EQ_API bool upload( const Frame::Buffer buffer, util::Texture* texture,
344  const Vector2i& position,
345  ObjectManager* glObjects ) const;
346 
348  EQ_API bool writeImage( const std::string& filename,
349  const Frame::Buffer buffer ) const;
350 
352  EQ_API bool writeImages( const std::string& filenameTemplate ) const;
353 
355  EQ_API bool readImage( const std::string& filename,
356  const Frame::Buffer buffer );
357 
359  void setOffset( int32_t x, int32_t y );
361 
368  EQ_API std::vector< uint32_t >
369  findCompressors( const Frame::Buffer buffer ) const;
370 
375  EQ_API std::vector< uint32_t >
376  findTransferers( const Frame::Buffer buffer, const GLEWContext* gl )
377  const;
378 
380  EQ_API bool allocCompressor( const Frame::Buffer buffer,
381  const uint32_t name );
382 
384  EQ_API bool allocDownloader( const Frame::Buffer buffer,
385  const uint32_t name,
386  const GLEWContext* glewContext );
387 
389  EQ_API uint32_t getDownloaderName( const Frame::Buffer buffer ) const;
391 
392  private:
393  detail::Image* const _impl;
394 
396  const void* _getBufferKey( const Frame::Buffer buffer ) const;
397 
399  const void* _getCompressorKey( const Frame::Buffer buffer ) const;
400 
411  void _setExternalFormat( const Frame::Buffer buffer,
412  const uint32_t externalFormat,
413  const uint32_t pixelSize,
414  const bool hasAlpha );
415 
416  bool _readback( const Frame::Buffer buffer, const Zoom& zoom,
417  ObjectManager* glObjects );
418 
419  bool _startReadback( const Frame::Buffer buffer, const Zoom& zoom,
420  ObjectManager* glObjects );
421 
422  void _finishReadback( const Frame::Buffer buffer, const Zoom& zoom,
423  const GLEWContext* glewContext );
424 
425  bool _readbackZoom( const Frame::Buffer buffer, const Zoom& zoom,
426  ObjectManager* glObjects );
427  };
428 };
429 #endif // EQ_IMAGE_H
bool getAlphaUsage() const
const PixelData & compressPixelData(const Frame::Buffer)
bool upload(const Frame::Buffer buffer, util::Texture *texture, const Vector2i &position, ObjectManager *glObjects) const
Upload this image to the frame buffer or a texture.
Frame::Type getStorageType() const
const PixelData & getPixelData(const Frame::Buffer) const
float getQuality(const Frame::Buffer buffer) const
void setStorageType(const Frame::Type type)
Set the frame pixel storage type.
The pixel data structure manages the pixel information for images.
Definition: pixelData.h:33
A holder for pixel data.
Definition: image.h:35
void setInternalFormat(const Frame::Buffer buffer, const uint32_t internalFormat)
Set the internal format for the given buffer.
void setZoom(const Zoom &zoom)
Sets the zoom factor to be used for compositing.
const Zoom & getZoom() const
void setPixelData(const Frame::Buffer buffer, const PixelData &data)
Set the pixel data of the given image buffer.
const util::Texture & getTexture(const Frame::Buffer buffer) const
Get the texture of this image.
A facility class to manage OpenGL objects across shared contexts.
bool readImage(const std::string &filename, const Frame::Buffer buffer)
Read pixel data from an uncompressed rgb image file.
bool writeImage(const std::string &filename, const Frame::Buffer buffer) const
Write the pixel data as rgb image file.
uint32_t getExternalFormat(const Frame::Buffer buffer) const
Get the external format of the given buffer.
void flush()
Free all cached data of this image.
void setQuality(const Frame::Buffer buffer, const float quality)
Set the minimum quality after a full download-compression path.
uint32_t getPixelDataSize(const Frame::Buffer buffer) const
void deleteGLObjects(ObjectManager *om)
Delete all OpenGL objects allocated from the given object manager.
void setAlphaUsage(const bool enabled)
Set alpha data preservation during download and compression.
bool hasPixelData(const Frame::Buffer buffer) const
bool readback(const uint32_t buffers, const PixelViewport &pvp, const Zoom &zoom, ObjectManager *glObjects)
Read back an image from the frame buffer.
void resetPlugins()
Deallocate all transfer and compression plugins.
void setPixelViewport(const PixelViewport &pvp)
Set the internal pixel viewport of the image.
const uint8_t * getPixelPointer(const Frame::Buffer buffer) const
void reset()
Reset the image to its default state.
void validatePixelData(const Frame::Buffer buffer)
Allocate an image buffer without initialization.
void finishReadback(const Zoom &zoom, const GLEWContext *glewContext)
Finish an asynchronous readback.
A wrapper around OpenGL textures.
Definition: texture.h:38
Buffer
The buffer format defines which components of the frame are to be used during readback and assembly...
Definition: fabric/frame.h:40
bool hasTextureData(const Frame::Buffer buffer) const
void useCompressor(const Frame::Buffer buffer, const uint32_t name)
Set a compressor to be used during transmission of the image.
bool hasAsyncReadback() const
Image()
Construct a new Image.
bool hasAlpha() const
bool writeImages(const std::string &filenameTemplate) const
Write all valid pixel data as separate images.
void clearPixelData(const Frame::Buffer buffer)
Clear and validate an image buffer.
virtual ~Image()
Destruct the Image.
bool startReadback(const uint32_t buffers, const PixelViewport &pvp, const Zoom &zoom, ObjectManager *glObjects)
Start reading back an image from the frame buffer.
const PixelViewport & getPixelViewport() const
uint32_t getInternalFormat(const Frame::Buffer buffer) const
uint32_t getPixelSize(const Frame::Buffer buffer) const
Get the size, in bytes, of one pixel in the external pixel data.
Type
The storage type for pixel data.
Definition: fabric/frame.h:50