Equalizer  1.4.1
include/eq/fabric/window.h
00001 
00002 /* Copyright (c) 2010-2011, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *                    2010, Cedric Stalder <cedric.stalder@gmail.com> 
00004  *
00005  * This library is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Lesser General Public License version 2.1 as published
00007  * by the Free Software Foundation.
00008  *  
00009  * This library is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00012  * details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this library; if not, write to the Free Software Foundation, Inc.,
00016  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00017  */
00018 
00019 #ifndef EQFABRIC_WINDOW_H
00020 #define EQFABRIC_WINDOW_H
00021 
00022 #include <eq/fabric/object.h>        // base class
00023 
00024 #include <eq/fabric/drawableConfig.h> // enum
00025 #include <eq/fabric/paths.h>
00026 #include <eq/fabric/pixelViewport.h>
00027 #include <eq/fabric/viewport.h>
00028 #include <eq/fabric/visitorResult.h> // enum
00029 
00030 namespace eq
00031 {
00032     class Window;
00033 namespace server 
00034 { 
00035     class Window;
00036 }
00037 namespace fabric
00038 {
00040     template< class P, class W, class C > class Window : public Object
00041     {
00042     public:
00044         typedef std::vector< C* >  Channels; 
00046         typedef ElementVisitor< W, LeafVisitor< C > > Visitor;
00047 
00051         void init();
00052 
00054         const P* getPipe() const { return _pipe; }
00056         P* getPipe() { return _pipe; }
00057 
00059         const Channels& getChannels() const { return _channels; }
00060 
00062         const DrawableConfig& getDrawableConfig() const
00063             { return _data.drawableConfig; }
00064 
00068         const PixelViewport& getPixelViewport() const { return _data.pvp; }
00069 
00074         const Viewport& getViewport() const { return _data.vp; }
00075 
00085         EQFABRIC_INL virtual void setPixelViewport(const PixelViewport& pvp);
00086 
00096         EQFABRIC_INL void setViewport( const Viewport& vp );
00097 
00099         bool hasFixedViewport( ) const { return _data.fixedVP; }
00100 
00102         virtual void notifyViewportChanged();
00103 
00111         EQFABRIC_INL VisitorResult accept( Visitor& visitor );
00112 
00114         EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const;
00115 
00117 
00129         enum IAttribute
00130         {
00131             // Note: also update string array initialization in window.ipp
00132             IATTR_HINT_STEREO,           
00133             IATTR_HINT_DOUBLEBUFFER,     
00134             IATTR_HINT_FULLSCREEN,       
00135             IATTR_HINT_DECORATION,       
00136             IATTR_HINT_SWAPSYNC,         
00137             IATTR_HINT_DRAWABLE,         
00138             IATTR_HINT_STATISTICS,       
00139             IATTR_HINT_SCREENSAVER,      
00140             IATTR_PLANES_COLOR,          
00141             IATTR_PLANES_ALPHA,          
00142             IATTR_PLANES_DEPTH,          
00143             IATTR_PLANES_STENCIL,        
00144             IATTR_PLANES_ACCUM,          
00145             IATTR_PLANES_ACCUM_ALPHA,    
00146             IATTR_PLANES_SAMPLES,        
00147             IATTR_LAST,
00148             IATTR_ALL = IATTR_LAST + 5
00149         };
00150 
00152         void setIAttribute( const IAttribute attr, const int32_t value )
00153             { _data.iAttributes[attr] = value; }
00154 
00156         int32_t  getIAttribute( const IAttribute attr ) const
00157             { return _data.iAttributes[attr]; }
00158 
00160         EQFABRIC_INL static 
00161         const std::string& getIAttributeString( const IAttribute attr );
00163 
00165         EQFABRIC_INL WindowPath getPath() const;
00166 
00169         EQFABRIC_INL virtual void backup(); 
00170         EQFABRIC_INL virtual void restore(); 
00171         void create( C** channel ); 
00172         void release( C* channel ); 
00173         virtual void output( std::ostream& ) const {} 
00174 
00175         EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation =
00176                                                CO_COMMIT_NEXT );
00178 
00179     protected: 
00181         Window( P* parent );
00182 
00183         EQFABRIC_INL virtual ~Window(); 
00184 
00185         virtual void attach( const UUID& id,
00186                              const uint32_t instanceID );
00187 
00189         EQFABRIC_INL virtual void serialize( co::DataOStream& os,
00190                                                 const uint64_t dirtyBits );
00192         EQFABRIC_INL virtual void deserialize( co::DataIStream& is, 
00193                                                   const uint64_t dirtyBits );
00194         
00195         EQFABRIC_INL virtual void notifyDetach(); 
00196 
00198         EQFABRIC_INL virtual void setDirty( const uint64_t bits );
00199 
00201         void _setDrawableConfig( const DrawableConfig& drawableConfig );
00202 
00204         virtual ChangeType getChangeType() const { return UNBUFFERED; }
00205 
00206         C* _findChannel( const UUID& id ); 
00207 
00209         enum DirtyBits
00210         {
00211             DIRTY_ATTRIBUTES      = Object::DIRTY_CUSTOM << 0,
00212             DIRTY_CHANNELS        = Object::DIRTY_CUSTOM << 1,
00213             DIRTY_VIEWPORT        = Object::DIRTY_CUSTOM << 2,
00214             DIRTY_DRAWABLECONFIG  = Object::DIRTY_CUSTOM << 3,
00215             DIRTY_WINDOW_BITS =
00216                 DIRTY_ATTRIBUTES | DIRTY_CHANNELS | DIRTY_VIEWPORT |
00217                 DIRTY_DRAWABLECONFIG | DIRTY_OBJECT_BITS
00218         };
00219 
00221         virtual uint64_t getRedistributableBits() const
00222             { return DIRTY_WINDOW_BITS; }
00223 
00224     private:
00226         P* const _pipe;
00227 
00229         Channels _channels;
00230 
00231         struct BackupData
00232         {
00233             BackupData();
00234 
00236             int32_t iAttributes[ IATTR_ALL ];
00237 
00239             DrawableConfig drawableConfig;
00240 
00242             PixelViewport pvp;
00243         
00245             Viewport vp;
00246 
00249             bool fixedVP;
00250         }
00251             _data, _backup;
00252 
00253         struct Private;
00254         Private* _private; // placeholder for binary-compatible changes
00255 
00256         friend class Channel< W, C >;
00258         void _addChannel( C* channel );
00259 
00261         EQFABRIC_INL bool _removeChannel( C* channel );
00262 
00264         bool _mapNodeObjects() { return _pipe->_mapNodeObjects(); }
00265 
00266         typedef co::CommandFunc< Window< P, W, C > > CmdFunc;
00267         bool _cmdNewChannel( co::Command& command );
00268         bool _cmdNewChannelReply( co::Command& command );
00269     };
00270 
00271     template< class P, class W, class C > EQFABRIC_INL
00272     std::ostream& operator << ( std::ostream& os,
00273                                 const Window< P, W, C >& window );
00274 }
00275 }
00276 
00277 #endif // EQFABRIC_WINDOW_H
00278 
Generated on Mon Nov 26 2012 14:41:50 for Equalizer 1.4.1 by  doxygen 1.7.6.1