Equalizer 1.0

compositor.h

00001 
00002 /* Copyright (c) 2007-2010, 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/frame.h>          // nested type Frame::Buffer
00022 #include <eq/gl.h>             // GLEWContext
00023 #include <eq/types.h>          // type definitions
00024 
00025 #include <eq/fabric/pixel.h>          // member
00026 
00027 #include <vector>
00028 
00029 namespace eq
00030 {
00031 namespace util
00032 {
00033     class Accum;
00034 }
00035     class Channel;
00036 
00048     class EQ_API Compositor
00049     {
00050     public:
00052         struct ImageOp
00053         {
00054             ImageOp() : channel( 0 ), buffers( 0 )
00055                       , offset( Vector2i::ZERO )
00056                       , zoomFilter( FILTER_LINEAR ) {}
00057 
00058             Channel* channel;      
00059             uint32_t buffers;      
00060             Vector2i offset;       
00061             ZoomFilter zoomFilter; 
00062             Pixel    pixel;        
00063             Zoom zoom;             
00064         };
00065 
00078         static uint32_t assembleFrames( const Frames& frames,
00079                                         Channel* channel, util::Accum* accum );
00080 
00095         static uint32_t assembleFramesSorted( const Frames& frames,
00096                                               Channel* channel, 
00097                                               util::Accum* accum,
00098                                               const bool blendAlpha = false );
00099 
00110         static uint32_t assembleFramesUnsorted( const Frames& frames,
00111                                                 Channel* channel,
00112                                                 util::Accum* accum );
00113 
00132         static uint32_t assembleFramesCPU( const Frames& frames,
00133                                            Channel* channel,
00134                                            const bool blendAlpha = false );
00135 
00146         static const Image* mergeFramesCPU( const Frames& frames,
00147                                             const bool blendAlpha = false );
00148 
00165         static bool mergeFramesCPU( const Frames& frames,
00166                                     const bool blendAlpha,
00167                                     void* colorBuffer,
00168                                     const uint32_t colorBufferSize,
00169                                     void* depthBuffer, 
00170                                     const uint32_t depthBufferSize,
00171                                     PixelViewport& outPVP );
00172 
00177         static void assembleFrame( const Frame* frame, Channel* channel );
00179 
00180         
00189         static void assembleImage( const Image* image,
00190                                    const ImageOp& operation );
00191 
00198         static void setupStencilBuffer( const Image* image, 
00199                                         const ImageOp& operation );
00200 
00206         static void clearStencilBuffer( const ImageOp& operation );
00207 
00213         static void setupAssemblyState( const PixelViewport& pvp,
00214                                         const GLEWContext* gl );
00215         
00219         static void resetAssemblyState();
00220 
00222         static void assembleImage2D( const Image* image, const ImageOp& op );
00224         static void assembleImageDB( const Image* image, const ImageOp& op );
00225 
00230         static void assembleImageDB_FF( const Image* image, const ImageOp& op );
00231 
00236         static void assembleImageDB_GLSL( const Image* image, 
00237                                           const ImageOp& op );
00239                                 
00240       private:
00241         typedef std::pair< const Frame*, const Image* > FrameImage;
00242 
00243         static bool _isSubPixelDecomposition( const Frames& frames );
00244         static const Frames _extractOneSubPixel( Frames& frames );
00245 
00246         static bool _collectOutputData( 
00247                              const Frames& frames, 
00248                              PixelViewport& destPVP, 
00249                              uint32_t& colorInternalFormat, 
00250                              uint32_t& colorPixelSize,
00251                              uint32_t& colorExternalFormat,
00252                              uint32_t& depthInternalFormat,
00253                              uint32_t& depthPixelSize,
00254                              uint32_t& depthExternalFormat );
00255                               
00256         static void _collectOutputData( const PixelData& pixelData, 
00257                                         uint32_t& internalFormat, 
00258                                         uint32_t& pixelSize, 
00259                                         uint32_t& externalFormat );
00260 
00261         static void _mergeFrames( const Frames& frames,
00262                                   const bool blendAlpha, 
00263                                   void* colorBuffer, void* depthBuffer,
00264                                   const PixelViewport& destPVP );
00265                                   
00266         static void _mergeDBImage( void* destColor, void* destDepth,
00267                                    const PixelViewport& destPVP, 
00268                                    const Image* image, 
00269                                    const Vector2i& offset );
00270                                      
00271         static void _merge2DImage( void* destColor, void* destDepth,
00272                                    const PixelViewport& destPVP,
00273                                    const Image* input,
00274                                    const Vector2i& offset );
00275                                      
00276         static void _mergeBlendImage( void* dest, 
00277                                       const PixelViewport& destPVP, 
00278                                       const Image* input,
00279                                       const Vector2i& offset );
00280         static bool _mergeImage_PC( int operation, void* destColor, 
00281                                     void* destDepth, const Image* source );
00285         static void _drawPixels( const Image* image, const ImageOp& op,
00286                                  const Frame::Buffer which );
00287 
00289         static util::Accum* _obtainAccum( Channel* channel );
00290     };
00291 }
00292 
00293 #endif // EQ_COMPOSITOR_H
00294 
Generated on Sun May 8 2011 19:11:05 for Equalizer 1.0 by  doxygen 1.7.3