Equalizer  1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
frameData.h
1 
2 /* Copyright (c) 2006-2014, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2011, Daniel Nachbaur <danielnachbaur@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License version 2.1 as published
7  * by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef EQ_FRAMEDATA_H
20 #define EQ_FRAMEDATA_H
21 
22 #include <eq/client/frame.h> // enum Frame::Buffer
23 #include <eq/client/types.h>
24 
25 #include <eq/fabric/pixelViewport.h> // member
26 #include <eq/fabric/pixel.h> // member
27 #include <eq/fabric/range.h> // member
28 #include <eq/fabric/subPixel.h> // member
29 
30 #include <co/object.h> // base class
31 #include <lunchbox/monitor.h> // member
32 #include <lunchbox/spinLock.h> // member
33 
34 namespace eq
35 {
36 namespace detail { class FrameData; }
37 
53 class FrameData : public co::Object, public lunchbox::Referenced
54 {
55 public:
56  void assembleFrame( Frame* frame, Channel* channel );
57  struct ImageHeader
58  {
59  uint32_t internalFormat;
60  uint32_t externalFormat;
61  uint32_t pixelSize;
63  uint32_t compressorName;
64  uint32_t compressorFlags;
65  uint32_t nChunks;
66  float quality;
67  };
68 
70  EQ_API FrameData();
71 
73  EQ_API virtual ~FrameData();
74 
78  EQ_API Frame::Type getType() const;
79 
81  EQ_API void setType( const Frame::Type type );
82 
84  EQ_API uint32_t getBuffers() const;
85 
93  EQ_API void setBuffers( const uint32_t buffers );
94 
104  EQ_API const Range& getRange() const;
105 
107  EQ_API void setRange( const Range& range );
108 
113  EQ_API const Pixel& getPixel() const;
114 
119  EQ_API const SubPixel& getSubPixel() const;
120 
125  EQ_API uint32_t getPeriod() const;
126 
131  EQ_API uint32_t getPhase() const;
132 
134  EQ_API const Images& getImages() const;
135 
144  EQ_API void setPixelViewport( const PixelViewport& pvp );
145 
147  EQ_API const PixelViewport& getPixelViewport() const;
148 
156  EQ_API void setAlphaUsage( const bool useAlpha );
157 
167  void setQuality( const Frame::Buffer buffer, const float quality );
168 
170  EQ_API void setZoom( const Zoom& zoom );
171 
173  EQ_API const Zoom& getZoom() const;
174 
185  void useCompressor( const Frame::Buffer buffer, const uint32_t name );
187 
200  EQ_API Image* newImage( const Frame::Type type,
201  const DrawableConfig& config );
202 
204  EQ_API void clear();
205 
207  void flush();
208 
211 
213  EQ_API void resetPlugins();
214 
215 #ifndef EQ_2_0_API
216 
228  void readback( const Frame& frame, util::ObjectManager& glObjects,
229  const DrawableConfig& config );
230 #endif
231 
245  Images startReadback( const Frame& frame,
246  util::ObjectManager& glObjects,
247  const DrawableConfig& config,
248  const PixelViewports& regions );
249 
257  void setReady();
258 
260  EQ_API bool isReady() const;
261 
263  EQ_API void waitReady( const uint32_t timeout = LB_TIMEOUT_INDEFINITE )
264  const;
265 
267  void setVersion( const uint64_t version );
268 
269  typedef lunchbox::Monitor< uint32_t > Listener;
270 
280  void addListener( Listener& listener );
281 
288  void removeListener( Listener& listener );
289 
296  EQ_API void disableBuffer( const Frame::Buffer buffer );
298 
300  struct Data
301  {
302  Data() : frameType( Frame::TYPE_MEMORY ), buffers( 0 ), period( 1 )
303  , phase( 0 ) {}
304 
305  PixelViewport pvp;
306  fabric::Frame::Type frameType;
307  uint32_t buffers;
308  uint32_t period;
309  uint32_t phase;
310  Range range; //<! database-range of src wrt to dest
311  Pixel pixel; //<! pixel decomposition of source
312  SubPixel subpixel; //<! subpixel decomposition of source
313  Zoom zoom;
314 
315  EQ_API void serialize( co::DataOStream& os ) const;
316  EQ_API void deserialize( co::DataIStream& is );
317  };
318 
319  const Data& getData() const;
320 
322  bool addImage( const co::ObjectVersion& frameDataVersion,
323  const PixelViewport& pvp, const Zoom& zoom,
324  const uint32_t buffers, const bool useAlpha,
325  uint8_t* data );
326  void setReady( const co::ObjectVersion& frameData,
327  const FrameData::Data& data );
328 
329 protected:
330  virtual ChangeType getChangeType() const { return INSTANCE; }
331  virtual void getInstanceData( co::DataOStream& os );
332  virtual void applyInstanceData( co::DataIStream& is );
333 
334 private:
335  detail::FrameData* const _impl;
336 
338  Image* _allocImage( const Frame::Type type,
339  const DrawableConfig& config,
340  const bool setQuality );
341 
343  void _applyVersion( const uint128_t& version );
344 
346  void _setReady( const uint64_t version );
347 
348  LB_TS_VAR( _commandThread );
349 };
350 
352 EQ_API std::ostream& operator << ( std::ostream&, const FrameData& );
353 }
354 
355 namespace lunchbox
356 {
357 template<> inline void byteswap( eq::FrameData::Data& value )
358 {
359  byteswap( value.pvp );
360  byteswap( value.frameType );
361  byteswap( value.buffers );
362  byteswap( value.period );
363  byteswap( value.phase );
364  byteswap( value.range );
365  byteswap( value.pixel );
366  byteswap( value.subpixel );
367  byteswap( value.zoom );
368 }
369 }
370 
371 #endif // EQ_FRAMEDATA_H
372 
Images startReadback(const Frame &frame, util::ObjectManager &glObjects, const DrawableConfig &config, const PixelViewports &regions)
Start reading back a set of images for this frame data.
lunchbox::Monitor< uint32_t > Listener
Ready listener.
Definition: frameData.h:269
void flush()
Flush the frame by deleting all images.
A channel represents a two-dimensional viewport within a Window.
EQ_API void setAlphaUsage(const bool useAlpha)
Set alpha usage for newly allocated images.
EQ_API void setBuffers(const uint32_t buffers)
Set the enabled frame buffer attachments.
virtual EQ_API ~FrameData()
Destruct this frame data.
void readback(const Frame &frame, util::ObjectManager &glObjects, const DrawableConfig &config)
Read back an image for this frame data.
EQ_API std::ostream & operator<<(std::ostream &os, const ConfigEvent *event)
Print the config event to the given output stream.
EQ_API const Images & getImages() const
The images of this frame data holder.
std::vector< PixelViewport > PixelViewports
A vector of eq::PixelViewport.
Definition: client/types.h:170
EQ_API void setRange(const Range &range)
Set the range of this frame.
EQ_API FrameData()
Construct a new frame data holder.
EQ_API Frame::Type getType() const
Buffer
The buffer format defines which components of the frame are to be used during readback and assembly...
Definition: fabric/frame.h:40
Type
The storage type for pixel data.
Definition: fabric/frame.h:50
std::vector< Image * > Images
A vector of pointers to eq::Image.
Definition: client/types.h:156
EQ_API void disableBuffer(const Frame::Buffer buffer)
Disable the usage of a frame buffer attachment for all images.
EQ_API bool isReady() const
A holder for pixel data.
Definition: image.h:35
void useCompressor(const Frame::Buffer buffer, const uint32_t name)
Sets a compressor which will be allocated and used during transmit of the image buffer.
void addListener(Listener &listener)
Add a ready listener.
EQ_API const PixelViewport & getPixelViewport() const
A holder for multiple images.
Definition: frameData.h:53
use main memory to store pixel data
Definition: fabric/frame.h:52
EQ_API void setPixelViewport(const PixelViewport &pvp)
Set the covered area for readbacks.
EQ_API const SubPixel & getSubPixel() const
EQ_API void resetPlugins()
Deallocate all transfer and compression plugins on all images.
void setReady()
Set the frame data ready.
EQ_API uint32_t getPeriod() const
EQ_API void clear()
Clear the frame by recycling the attached images.
A facility class to manage OpenGL objects across shared contexts.
Definition: objectManager.h:51
EQ_API Image * newImage(const Frame::Type type, const DrawableConfig &config)
Allocate and add a new image.
A holder for a frame data and related parameters.
Definition: client/frame.h:42
void deleteGLObjects(util::ObjectManager &om)
Delete data allocated by the given object manager on all images.
EQ_API void waitReady(const uint32_t timeout=LB_TIMEOUT_INDEFINITE) const
Wait for the frame data to become available.
void setQuality(const Frame::Buffer buffer, const float quality)
Set the minimum quality after download and compression.
EQ_API const Pixel & getPixel() const
EQ_API uint32_t getBuffers() const
EQ_API uint32_t getPhase() const
EQ_API const Range & getRange() const
Get the range.
void removeListener(Listener &listener)
Remove a frame listener.
Holds a 2D pixel viewport with methods for manipulation.
Definition: pixelViewport.h:34
EQ_API void setType(const Frame::Type type)
Set the storage type.