Equalizer  1.4.1
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/types.h>          // type definitions
00023 
00024 #include <eq/fabric/pixel.h>          // member
00025 
00026 #include <vector>
00027 
00028 namespace eq
00029 {
00041     class EQ_API Compositor
00042     {
00043     public:
00045         struct ImageOp
00046         {
00047             ImageOp() : channel( 0 ), buffers( 0 )
00048                       , offset( Vector2i::ZERO )
00049                       , zoomFilter( FILTER_LINEAR ) {}
00050 
00051             Channel* channel;      
00052             uint32_t buffers;      
00053             Vector2i offset;       
00054             ZoomFilter zoomFilter; 
00055             Pixel    pixel;        
00056             Zoom zoom;             
00057         };
00058 
00071         static uint32_t assembleFrames( const Frames& frames,
00072                                         Channel* channel, util::Accum* accum );
00073 
00088         static uint32_t assembleFramesSorted( const Frames& frames,
00089                                               Channel* channel, 
00090                                               util::Accum* accum,
00091                                               const bool blendAlpha = false );
00092 
00103         static uint32_t assembleFramesUnsorted( const Frames& frames,
00104                                                 Channel* channel,
00105                                                 util::Accum* accum );
00106 
00125         static uint32_t assembleFramesCPU( const Frames& frames,
00126                                            Channel* channel,
00127                                            const bool blendAlpha = false );
00128 
00139         static const Image* mergeFramesCPU( const Frames& frames,
00140                                             const bool blendAlpha = false,
00141                                const uint32_t timeout = LB_TIMEOUT_INDEFINITE );
00142 
00159         static bool mergeFramesCPU( const Frames& frames,
00160                                     const bool blendAlpha,
00161                                     void* colorBuffer,
00162                                     const uint32_t colorBufferSize,
00163                                     void* depthBuffer, 
00164                                     const uint32_t depthBufferSize,
00165                                     PixelViewport& outPVP,
00166                                const uint32_t timeout = LB_TIMEOUT_INDEFINITE );
00167 
00172         static void assembleFrame( const Frame* frame, Channel* channel );
00174 
00175         
00184         static void assembleImage( const Image* image,
00185                                    const ImageOp& operation );
00186 
00193         static void setupStencilBuffer( const Image* image, 
00194                                         const ImageOp& operation );
00195 
00201         static void clearStencilBuffer( const ImageOp& operation );
00202 
00208         static void setupAssemblyState( const PixelViewport& pvp,
00209                                         const GLEWContext* gl );
00210         
00214         static void resetAssemblyState();
00215 
00217         static void assembleImage2D( const Image* image, const ImageOp& op );
00219         static void assembleImageDB( const Image* image, const ImageOp& op );
00220 
00225         static void assembleImageDB_FF( const Image* image, const ImageOp& op );
00226 
00231         static void assembleImageDB_GLSL( const Image* image, 
00232                                           const ImageOp& op );
00234 
00243         static void declareRegion( const Image* image, const ImageOp& op );
00245 
00249         class WaitHandle;
00250 
00252         static WaitHandle* startWaitFrames( const Frames& frames,
00253                                             Channel* channel );
00254 
00267         static Frame* waitFrame( WaitHandle* handle );
00269 
00270       private:
00271         typedef std::pair< const Frame*, const Image* > FrameImage;
00272 
00273         static bool _isSubPixelDecomposition( const Frames& frames );
00274         static const Frames _extractOneSubPixel( Frames& frames );
00275 
00276         static bool _collectOutputData( 
00277                              const Frames& frames, 
00278                              PixelViewport& destPVP, 
00279                              uint32_t& colorInternalFormat, 
00280                              uint32_t& colorPixelSize,
00281                              uint32_t& colorExternalFormat,
00282                              uint32_t& depthInternalFormat,
00283                              uint32_t& depthPixelSize,
00284                              uint32_t& depthExternalFormat,
00285                              const uint32_t timeout );
00286                               
00287         static void _collectOutputData( const PixelData& pixelData, 
00288                                         uint32_t& internalFormat, 
00289                                         uint32_t& pixelSize, 
00290                                         uint32_t& externalFormat );
00291 
00292         static void _mergeFrames( const Frames& frames,
00293                                   const bool blendAlpha, 
00294                                   void* colorBuffer, void* depthBuffer,
00295                                   const PixelViewport& destPVP );
00296                                   
00297         static void _mergeDBImage( void* destColor, void* destDepth,
00298                                    const PixelViewport& destPVP, 
00299                                    const Image* image, 
00300                                    const Vector2i& offset );
00301                                      
00302         static void _merge2DImage( void* destColor, void* destDepth,
00303                                    const PixelViewport& destPVP,
00304                                    const Image* input,
00305                                    const Vector2i& offset );
00306                                      
00307         static void _mergeBlendImage( void* dest, 
00308                                       const PixelViewport& destPVP, 
00309                                       const Image* input,
00310                                       const Vector2i& offset );
00311         static bool _mergeImage_PC( int operation, void* destColor, 
00312                                     void* destDepth, const Image* source );
00316         static void _drawPixels( const Image* image, const ImageOp& op,
00317                                  const Frame::Buffer which );
00318 
00320         static util::Accum* _obtainAccum( Channel* channel );
00321     };
00322 }
00323 
00324 #endif // EQ_COMPOSITOR_H
00325 
Generated on Mon Nov 26 2012 14:41:48 for Equalizer 1.4.1 by  doxygen 1.7.6.1