Equalizer  1.3.1-git
compositor.h
00001 
00002 /* Copyright (c) 2007-2012, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016  */
00017 
00018 #ifndef EQ_COMPOSITOR_H
00019 #define EQ_COMPOSITOR_H
00020 
00021 #include <eq/client/frame.h>          // nested type Frame::Buffer
00022 #include <eq/client/gl.h>             // GLEWContext
00023 #include <eq/client/types.h>          // type definitions
00024 
00025 #include <eq/fabric/pixel.h>          // member
00026 
00027 #include <vector>
00028 
00029 namespace eq
00030 {
00042     class EQ_API Compositor
00043     {
00044     public:
00046         struct ImageOp
00047         {
00048             ImageOp() : channel( 0 ), buffers( 0 )
00049                       , offset( Vector2i::ZERO )
00050                       , zoomFilter( FILTER_LINEAR ) {}
00051 
00052             Channel* channel;      
00053             uint32_t buffers;      
00054             Vector2i offset;       
00055             ZoomFilter zoomFilter; 
00056             Pixel    pixel;        
00057             Zoom zoom;             
00058         };
00059 
00072         static uint32_t assembleFrames( const Frames& frames,
00073                                         Channel* channel, util::Accum* accum );
00074 
00089         static uint32_t assembleFramesSorted( const Frames& frames,
00090                                               Channel* channel, 
00091                                               util::Accum* accum,
00092                                               const bool blendAlpha = false );
00093 
00104         static uint32_t assembleFramesUnsorted( const Frames& frames,
00105                                                 Channel* channel,
00106                                                 util::Accum* accum );
00107 
00126         static uint32_t assembleFramesCPU( const Frames& frames,
00127                                            Channel* channel,
00128                                            const bool blendAlpha = false );
00129 
00140         static const Image* mergeFramesCPU( const Frames& frames,
00141                                             const bool blendAlpha = false,
00142                                const uint32_t timeout = LB_TIMEOUT_INDEFINITE );
00143 
00160         static bool mergeFramesCPU( const Frames& frames,
00161                                     const bool blendAlpha,
00162                                     void* colorBuffer,
00163                                     const uint32_t colorBufferSize,
00164                                     void* depthBuffer, 
00165                                     const uint32_t depthBufferSize,
00166                                     PixelViewport& outPVP,
00167                                const uint32_t timeout = LB_TIMEOUT_INDEFINITE );
00168 
00173         static void assembleFrame( const Frame* frame, Channel* channel );
00175 
00176         
00185         static void assembleImage( const Image* image,
00186                                    const ImageOp& operation );
00187 
00194         static void setupStencilBuffer( const Image* image, 
00195                                         const ImageOp& operation );
00196 
00202         static void clearStencilBuffer( const ImageOp& operation );
00203 
00209         static void setupAssemblyState( const PixelViewport& pvp,
00210                                         const GLEWContext* gl );
00211         
00215         static void resetAssemblyState();
00216 
00218         static void assembleImage2D( const Image* image, const ImageOp& op );
00220         static void assembleImageDB( const Image* image, const ImageOp& op );
00221 
00226         static void assembleImageDB_FF( const Image* image, const ImageOp& op );
00227 
00232         static void assembleImageDB_GLSL( const Image* image, 
00233                                           const ImageOp& op );
00235 
00244         static void declareRegion( const Image* image, const ImageOp& op );
00246 
00250         class WaitHandle;
00251 
00253         static WaitHandle* startWaitFrames( const Frames& frames,
00254                                             Channel* channel );
00255 
00268         static Frame* waitFrame( WaitHandle* handle );
00270 
00271       private:
00272         typedef std::pair< const Frame*, const Image* > FrameImage;
00273 
00274         static bool _isSubPixelDecomposition( const Frames& frames );
00275         static const Frames _extractOneSubPixel( Frames& frames );
00276 
00277         static bool _collectOutputData( 
00278                              const Frames& frames, 
00279                              PixelViewport& destPVP, 
00280                              uint32_t& colorInternalFormat, 
00281                              uint32_t& colorPixelSize,
00282                              uint32_t& colorExternalFormat,
00283                              uint32_t& depthInternalFormat,
00284                              uint32_t& depthPixelSize,
00285                              uint32_t& depthExternalFormat,
00286                              const uint32_t timeout );
00287                               
00288         static void _collectOutputData( const PixelData& pixelData, 
00289                                         uint32_t& internalFormat, 
00290                                         uint32_t& pixelSize, 
00291                                         uint32_t& externalFormat );
00292 
00293         static void _mergeFrames( const Frames& frames,
00294                                   const bool blendAlpha, 
00295                                   void* colorBuffer, void* depthBuffer,
00296                                   const PixelViewport& destPVP );
00297                                   
00298         static void _mergeDBImage( void* destColor, void* destDepth,
00299                                    const PixelViewport& destPVP, 
00300                                    const Image* image, 
00301                                    const Vector2i& offset );
00302                                      
00303         static void _merge2DImage( void* destColor, void* destDepth,
00304                                    const PixelViewport& destPVP,
00305                                    const Image* input,
00306                                    const Vector2i& offset );
00307                                      
00308         static void _mergeBlendImage( void* dest, 
00309                                       const PixelViewport& destPVP, 
00310                                       const Image* input,
00311                                       const Vector2i& offset );
00312         static bool _mergeImage_PC( int operation, void* destColor, 
00313                                     void* destDepth, const Image* source );
00317         static void _drawPixels( const Image* image, const ImageOp& op,
00318                                  const Frame::Buffer which );
00319 
00321         static util::Accum* _obtainAccum( Channel* channel );
00322     };
00323 }
00324 
00325 #endif // EQ_COMPOSITOR_H
00326 
Generated on Tue May 1 2012 15:14:25 for Equalizer 1.3.1-git by  doxygen 1.8.0