Equalizer  2.1.0
Parallel Rendering Framework
image.h
1 
2 /* Copyright (c) 2006-2017, 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
30 {
31 class Image;
32 }
33 
39 class Image
40 {
41 public:
43  EQ_API Image();
44 
46  EQ_API Image(const Image&);
47 
49  EQ_API Image& operator=(Image&& rhs);
50 
52  EQ_API virtual ~Image();
53 
67  EQ_API void setInternalFormat(const Frame::Buffer buffer,
68  const uint32_t internalFormat);
69 
71  EQ_API uint32_t getInternalFormat(const Frame::Buffer buffer) const;
72 
84  EQ_API uint32_t getExternalFormat(const Frame::Buffer buffer) const;
85 
93  EQ_API uint32_t getPixelSize(const Frame::Buffer buffer) const;
94 
100  EQ_API bool hasAlpha() const;
101 
113  EQ_API void setStorageType(const Frame::Type type);
114 
116  EQ_API Frame::Type getStorageType() const;
117 
129  EQ_API void setPixelViewport(const PixelViewport& pvp);
130 
132  EQ_API const PixelViewport& getPixelViewport() const;
133 
135  EQ_API void setZoom(const Zoom& zoom);
136 
138  EQ_API const Zoom& getZoom() const;
139 
141  EQ_API void setContext(const RenderContext& context);
142 
144  EQ_API const RenderContext& getContext() const;
145 
155  EQ_API void useCompressor(Frame::Buffer buffer, uint32_t name);
156 
166  EQ_API void reset();
167 
169  EQ_API void flush();
170 
177  EQ_API void deleteGLObjects(util::ObjectManager& om);
178 
185  EQ_API void resetPlugins();
187 
191  EQ_API const uint8_t* getPixelPointer(const Frame::Buffer buffer) const;
192 
194  EQ_API uint8_t* getPixelPointer(const Frame::Buffer buffer);
195 
197  EQ_API uint32_t getPixelDataSize(const Frame::Buffer buffer) const;
198 
200  EQ_API const PixelData& getPixelData(const Frame::Buffer) const;
201 
203  EQ_API const PixelData& compressPixelData(const Frame::Buffer);
204 
209  EQ_API bool hasPixelData(const Frame::Buffer buffer) const;
210 
215  EQ_API bool hasAsyncReadback(const Frame::Buffer buffer) const;
216 
221  EQ_API bool hasAsyncReadback() const;
222 
233  EQ_API void clearPixelData(const Frame::Buffer buffer);
234 
236  EQ_API void validatePixelData(const Frame::Buffer buffer);
237 
249  EQ_API void setPixelData(const Frame::Buffer buffer, const PixelData& data);
250 
255  EQ_API void setAlphaUsage(const bool enabled);
256 
258  EQ_API bool getAlphaUsage() const;
259 
272  EQ_API void setQuality(const Frame::Buffer buffer, const float quality);
273 
275  EQ_API float getQuality(const Frame::Buffer buffer) const;
277 
281  EQ_API const util::Texture& getTexture(const Frame::Buffer buffer) const;
282 
287  EQ_API bool hasTextureData(const Frame::Buffer buffer) const;
289 
303  EQ_API bool startReadback(const Frame::Buffer buffers,
304  const PixelViewport& pvp,
305  const RenderContext& context, const Zoom& zoom,
306  util::ObjectManager& glObjects);
307 
309  bool startReadback(const Frame::Buffer buffer, const util::Texture* texture,
310  const GLEWContext* glewContext);
311 
318  EQ_API void finishReadback(const GLEWContext* glewContext);
319 
334  EQ_API bool upload(const Frame::Buffer buffer, util::Texture* texture,
335  const Vector2i& position,
336  util::ObjectManager& glObjects) const;
337 
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> findCompressors(
367  const Frame::Buffer buffer) const;
368 
373  EQ_API std::vector<uint32_t> findTransferers(const Frame::Buffer buffer,
374  const GLEWContext* gl) const;
375 
377  EQ_API bool allocCompressor(const Frame::Buffer buffer,
378  const uint32_t name);
379 
381  EQ_API bool allocDownloader(const Frame::Buffer buffer, const uint32_t name,
382  const GLEWContext* glewContext);
383 
385  EQ_API uint32_t getDownloaderName(const Frame::Buffer buffer) const;
387 
388 private:
389  Image& operator=(const Image&) = delete;
390  detail::Image* _impl;
391 
392  EQ_API
393  friend co::DataOStream& operator<<(co::DataOStream& os, const Image&);
394  EQ_API
395  friend co::DataIStream& operator>>(co::DataIStream& is, Image&);
396 
398  const void* _getBufferKey(const Frame::Buffer buffer) const;
399 
401  const void* _getCompressorKey(const Frame::Buffer buffer) const;
402 
413  void _setExternalFormat(const Frame::Buffer buffer,
414  const uint32_t externalFormat,
415  const uint32_t pixelSize, const bool hasAlpha);
416 
417  bool _readback(const Frame::Buffer buffer, const Zoom& zoom,
418  util::ObjectManager& glObjects);
419 
420  bool _startReadback(const Frame::Buffer buffer, const Zoom& zoom,
421  util::ObjectManager& glObjects);
422 
423  void _finishReadback(const Frame::Buffer buffer, const GLEWContext*);
424  bool _readbackZoom(const Frame::Buffer buffer, util::ObjectManager& om);
425  bool _writeImage(const std::string& filename, const Frame::Buffer buffer,
426  const unsigned char* data) const;
427 };
428 
430 EQ_API co::DataOStream& operator<<(co::DataOStream& os, const Image&);
431 
433 EQ_API co::DataIStream& operator>>(co::DataIStream& is, Image&);
434 }
435 
436 #endif // EQ_IMAGE_H
EQ_API std::ostream & operator<<(std::ostream &os, const EventICommand &command)
Print the event command to the given output stream.
The pixel data structure manages the pixel information for images.
Definition: pixelData.h:33
A wrapper around OpenGL textures.
Definition: texture.h:41
Type
The storage type for pixel data.
Definition: fabric/frame.h:52
A holder for pixel data.
Definition: image.h:39
The Equalizer client library.
Definition: eq/agl/types.h:23
Buffer
Components of the frame are to be used during readback and assembly.
Definition: fabric/frame.h:42
A facility class to manage OpenGL objects across shared contexts.
Definition: objectManager.h:56
EQ_API co::DataIStream & operator>>(co::DataIStream &is, Image &)
eq::Image deserializer.