Equalizer  1.8.0
Parallel Rendering Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
compositor.h
1 
2 /* Copyright (c) 2007-2012, Stefan Eilemann <eile@equalizergraphics.com>
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License version 2.1 as published
6  * by the Free Software Foundation.
7  *
8  * This library is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11  * details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16  */
17 
18 #ifndef EQ_COMPOSITOR_H
19 #define EQ_COMPOSITOR_H
20 
21 #include <eq/client/frame.h> // nested type Frame::Buffer
22 #include <eq/client/types.h> // type definitions
23 
24 #include <eq/fabric/pixel.h> // member
25 #include <eq/fabric/zoom.h> // member
26 
27 #include <vector>
28 
29 namespace eq
30 {
42  class EQ_API Compositor
43  {
44  public:
46  struct ImageOp
47  {
48  ImageOp() : channel( 0 ), buffers( 0 )
49  , offset( Vector2i::ZERO )
50  , zoomFilter( FILTER_LINEAR ) {}
51 
53  uint32_t buffers;
54  Vector2i offset;
56  Pixel pixel;
57  Zoom zoom;
58  };
59 
72  static uint32_t assembleFrames( const Frames& frames,
73  Channel* channel, util::Accum* accum );
74 
89  static uint32_t assembleFramesSorted( const Frames& frames,
90  Channel* channel,
91  util::Accum* accum,
92  const bool blendAlpha = false );
93 
104  static uint32_t assembleFramesUnsorted( const Frames& frames,
105  Channel* channel,
106  util::Accum* accum );
107 
126  static uint32_t assembleFramesCPU( const Frames& frames,
127  Channel* channel,
128  const bool blendAlpha = false );
129 
140  static const Image* mergeFramesCPU( const Frames& frames,
141  const bool blendAlpha = false,
142  const uint32_t timeout = LB_TIMEOUT_INDEFINITE );
143 
160  static bool mergeFramesCPU( const Frames& frames,
161  const bool blendAlpha,
162  void* colorBuffer,
163  const uint32_t colorBufferSize,
164  void* depthBuffer,
165  const uint32_t depthBufferSize,
166  PixelViewport& outPVP,
167  const uint32_t timeout = LB_TIMEOUT_INDEFINITE );
168 
173  static void assembleFrame( const Frame* frame, Channel* channel );
175 
176 
185  static void assembleImage( const Image* image,
186  const ImageOp& operation );
187 
194  static void setupStencilBuffer( const Image* image,
195  const ImageOp& operation );
196 
202  static void clearStencilBuffer( const ImageOp& operation );
203 
209  static void setupAssemblyState( const PixelViewport& pvp,
210  const GLEWContext* gl );
211 
215  static void resetAssemblyState();
216 
218  static void assembleImage2D( const Image* image, const ImageOp& op );
220  static void assembleImageDB( const Image* image, const ImageOp& op );
221 
226  static void assembleImageDB_FF( const Image* image, const ImageOp& op );
227 
232  static void assembleImageDB_GLSL( const Image* image,
233  const ImageOp& op );
235 
244  static void declareRegion( const Image* image, const ImageOp& op );
246 
250  class WaitHandle;
251 
253  static WaitHandle* startWaitFrames( const Frames& frames,
254  Channel* channel );
255 
268  static Frame* waitFrame( WaitHandle* handle );
270 
271  private:
272  typedef std::pair< const Frame*, const Image* > FrameImage;
273 
274  static bool _isSubPixelDecomposition( const Frames& frames );
275  static const Frames _extractOneSubPixel( Frames& frames );
276 
277  static bool _collectOutputData(
278  const Frames& frames,
279  PixelViewport& destPVP,
280  uint32_t& colorInternalFormat,
281  uint32_t& colorPixelSize,
282  uint32_t& colorExternalFormat,
283  uint32_t& depthInternalFormat,
284  uint32_t& depthPixelSize,
285  uint32_t& depthExternalFormat,
286  const uint32_t timeout );
287 
288  static void _collectOutputData( const PixelData& pixelData,
289  uint32_t& internalFormat,
290  uint32_t& pixelSize,
291  uint32_t& externalFormat );
292 
293  static void _mergeFrames( const Frames& frames,
294  const bool blendAlpha,
295  void* colorBuffer, void* depthBuffer,
296  const PixelViewport& destPVP );
297 
298  static void _mergeDBImage( void* destColor, void* destDepth,
299  const PixelViewport& destPVP,
300  const Image* image,
301  const Vector2i& offset );
302 
303  static void _merge2DImage( void* destColor, void* destDepth,
304  const PixelViewport& destPVP,
305  const Image* input,
306  const Vector2i& offset );
307 
308  static void _mergeBlendImage( void* dest,
309  const PixelViewport& destPVP,
310  const Image* input,
311  const Vector2i& offset );
312  static bool _mergeImage_PC( int operation, void* destColor,
313  void* destDepth, const Image* source );
317  static void _drawPixels( const Image* image, const ImageOp& op,
318  const Frame::Buffer which );
319 
321  static util::Accum* _obtainAccum( Channel* channel );
322  };
323 }
324 
325 #endif // EQ_COMPOSITOR_H
326 
uint32_t buffers
The Frame buffer attachments to use.
Definition: compositor.h:53
Zoom zoom
The zoom factor.
Definition: compositor.h:57
ZoomFilter zoomFilter
The zoom Filter from Frame.
Definition: compositor.h:55
A channel represents a two-dimensional viewport within a Window.
A C++ class to abstract an accumulation buffer.
Definition: accum.h:39
A set of functions performing compositing for a set of input frames.
Definition: compositor.h:42
Vector2i offset
The offset wrt destination window.
Definition: compositor.h:54
The pixel data structure manages the pixel information for images.
Definition: pixelData.h:33
Buffer
The buffer format defines which components of the frame are to be used during readback and assembly...
Definition: fabric/frame.h:40
Pixel pixel
The pixel decomposition parameters.
Definition: compositor.h:56
ZoomFilter
Filtering algorithm to applied during zoom operations.
Definition: zoomFilter.h:26
A structure describing an image assembly task.
Definition: compositor.h:46
A holder for pixel data.
Definition: image.h:35
std::vector< Frame * > Frames
A vector of pointers to eq::Frame.
GL_LINEAR.
Definition: zoomFilter.h:29
A holder for a frame data and related parameters.
Definition: client/frame.h:42
Channel * channel
The destination channel.
Definition: compositor.h:52