compositor.h

00001 
00002 /* Copyright (c) 2007-2009, 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/pixel.h>          // member
00023 #include <eq/client/types.h>          // type definitions
00024 #include <eq/base/base.h>             // EQ_EXPORT definition
00025 
00026 #include <vector>
00027 
00028 namespace eq
00029 {
00030 namespace util
00031 {
00032     class Accum;
00033 }
00034     class Channel;
00035     class Image;
00036 
00048     class EQ_EXPORT Compositor
00049     {
00050     public:
00052         struct ImageOp
00053         {
00054             ImageOp() : channel( 0 ), buffers( 0 )
00055                       , offset( Vector2i::ZERO ) {}
00056 
00057             Channel* channel; 
00058             uint32_t buffers; 
00059             Vector2i offset;  
00060             Pixel pixel;      
00061             Zoom zoom;        
00062         };
00063 
00075         static uint32_t assembleFrames( const FrameVector& frames,
00076                                         Channel* channel, util::Accum* accum );
00077 
00091         static uint32_t assembleFramesSorted( const FrameVector& frames,
00092                                               Channel* channel, 
00093                                               util::Accum* accum,
00094                                               const bool blendAlpha = false );
00095 
00105         static uint32_t assembleFramesUnsorted( const FrameVector& frames,
00106                                                 Channel* channel,
00107                                                 util::Accum* accum );
00108 
00126         static uint32_t assembleFramesCPU( const FrameVector& frames,
00127                                            Channel* channel,
00128                                            const bool blendAlpha = false );
00129 
00131         static const Image* mergeFramesCPU( const FrameVector& frames,
00132                                             const bool blendAlpha = false );
00133 
00149         static bool mergeFramesCPU( const FrameVector& frames,
00150                                     const bool blendAlpha,
00151                                     void* colorBuffer,
00152                                     const uint32_t colorBufferSize,
00153                                     void* depthBuffer, 
00154                                     const uint32_t depthBufferSize,
00155                                     PixelViewport& outPVP );
00156 
00158         static void assembleFrame( const Frame* frame, Channel* channel );
00160 
00161         
00170         static void assembleImage( const Image* image,
00171                                    const ImageOp& operation );
00172 
00179         static void setupStencilBuffer( const Image* image, 
00180                                         const ImageOp& operation );
00181 
00187         static void clearStencilBuffer( const ImageOp& operation );
00188 
00193         static void setupAssemblyState( const PixelViewport& pvp );
00194         
00198         static void resetAssemblyState();
00199 
00201         static void assembleImage2D( const Image* image, const ImageOp& op );
00203         static void assembleImageDB( const Image* image, const ImageOp& op );
00204 
00209         static void assembleImageDB_FF( const Image* image, const ImageOp& op );
00210 
00215         static void assembleImageDB_GLSL( const Image* image, 
00216                                           const ImageOp& op );
00218                                 
00219       private:
00220         typedef std::pair< const Frame*, const Image* > FrameImage;
00221 
00222         static bool _isSubPixelDecomposition( const FrameVector& frames );
00223         static const FrameVector _extractOneSubPixel( FrameVector& frames );
00224 
00225         static bool _collectOutputData( const FrameVector& frames,
00226                                         PixelViewport& destPVP, 
00227                                         uint32_t& colorFormat, 
00228                                         uint32_t& colorType,
00229                                         uint32_t& depthFormat,
00230                                         uint32_t& depthType );
00231                                         
00232         static void _mergeFrames( const FrameVector& frames,
00233                                   const bool blendAlpha, 
00234                                   void* colorBuffer, void* depthBuffer,
00235                                   const PixelViewport& destPVP );
00236                                   
00237         static void   _mergeDBImage( void* destColor, void* destDepth,
00238                                      const PixelViewport& destPVP, 
00239                                      const Image* image, 
00240                                      const Vector2i& offset );
00241                                      
00242         static void   _merge2DImage( void* destColor, void* destDepth,
00243                                      const PixelViewport& destPVP,
00244                                      const Image* input,
00245                                      const Vector2i& offset );
00246                                      
00247         static void   _mergeBlendImage( void* dest, 
00248                                         const PixelViewport& destPVP, 
00249                                         const Image* input,
00250                                         const Vector2i& offset );
00251         static bool     _mergeImage_PC( int operation, void* destColor, 
00252                                         void* destDepth, const Image* source );
00256         static void _drawPixels( const Image* image, const ImageOp& op,
00257                                  const Frame::Buffer which );
00258 
00260         static util::Accum* _obtainAccum( Channel* channel );
00261     };
00262 }
00263 
00264 #endif // EQ_COMPOSITOR_H
00265 
Generated on Sat Feb 6 12:59:47 2010 for Equalizer 0.9.1 by  doxygen 1.6.1