Equalizer
1.2.1
|
00001 00002 /* Copyright (c) 2007-2011, 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 = EQ_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 = EQ_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 00236 private: 00237 typedef std::pair< const Frame*, const Image* > FrameImage; 00238 00239 static bool _isSubPixelDecomposition( const Frames& frames ); 00240 static const Frames _extractOneSubPixel( Frames& frames ); 00241 00242 static bool _collectOutputData( 00243 const Frames& frames, 00244 PixelViewport& destPVP, 00245 uint32_t& colorInternalFormat, 00246 uint32_t& colorPixelSize, 00247 uint32_t& colorExternalFormat, 00248 uint32_t& depthInternalFormat, 00249 uint32_t& depthPixelSize, 00250 uint32_t& depthExternalFormat, 00251 const uint32_t timeout ); 00252 00253 static void _collectOutputData( const PixelData& pixelData, 00254 uint32_t& internalFormat, 00255 uint32_t& pixelSize, 00256 uint32_t& externalFormat ); 00257 00258 static void _mergeFrames( const Frames& frames, 00259 const bool blendAlpha, 00260 void* colorBuffer, void* depthBuffer, 00261 const PixelViewport& destPVP ); 00262 00263 static void _mergeDBImage( void* destColor, void* destDepth, 00264 const PixelViewport& destPVP, 00265 const Image* image, 00266 const Vector2i& offset ); 00267 00268 static void _merge2DImage( void* destColor, void* destDepth, 00269 const PixelViewport& destPVP, 00270 const Image* input, 00271 const Vector2i& offset ); 00272 00273 static void _mergeBlendImage( void* dest, 00274 const PixelViewport& destPVP, 00275 const Image* input, 00276 const Vector2i& offset ); 00277 static bool _mergeImage_PC( int operation, void* destColor, 00278 void* destDepth, const Image* source ); 00282 static void _drawPixels( const Image* image, const ImageOp& op, 00283 const Frame::Buffer which ); 00284 00286 static util::Accum* _obtainAccum( Channel* channel ); 00287 }; 00288 } 00289 00290 #endif // EQ_COMPOSITOR_H 00291