Equalizer 1.0

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,
00153                                       const int32_t value )
00154             { _data.iAttributes[attr] = value; }
00155 
00157         int32_t  getIAttribute( const IAttribute attr ) const
00158             { return _data.iAttributes[attr]; }
00159 
00161         EQFABRIC_INL static const std::string& getIAttributeString(
00162                                                       const IAttribute attr );
00164 
00166         EQFABRIC_INL WindowPath getPath() const;
00167 
00168         EQFABRIC_INL virtual void backup(); 
00169         EQFABRIC_INL virtual void restore(); 
00170         void create( C** channel ); 
00171         void release( C* channel ); 
00172         virtual void output( std::ostream& ) const {} 
00173 
00174 
00175     protected: 
00177         Window( P* parent );
00178 
00179         EQFABRIC_INL virtual ~Window(); 
00180 
00181         virtual void attach( const co::base::UUID& id,
00182                              const uint32_t instanceID );
00183 
00185         EQFABRIC_INL virtual void serialize( co::DataOStream& os,
00186                                                 const uint64_t dirtyBits );
00188         EQFABRIC_INL virtual void deserialize( co::DataIStream& is, 
00189                                                   const uint64_t dirtyBits );
00190         
00191         EQFABRIC_INL virtual void notifyDetach(); 
00192 
00194         EQFABRIC_INL virtual void setDirty( const uint64_t bits );
00195 
00197         void _setDrawableConfig( const DrawableConfig& drawableConfig );
00198 
00200         virtual ChangeType getChangeType() const { return UNBUFFERED; }
00201 
00202         C* _findChannel( const co::base::UUID& id ); 
00203 
00205         enum DirtyBits
00206         {
00207             DIRTY_ATTRIBUTES      = Object::DIRTY_CUSTOM << 0,
00208             DIRTY_CHANNELS        = Object::DIRTY_CUSTOM << 1,
00209             DIRTY_VIEWPORT        = Object::DIRTY_CUSTOM << 2,
00210             DIRTY_DRAWABLECONFIG  = Object::DIRTY_CUSTOM << 3,
00211             DIRTY_WINDOW_BITS =
00212                 DIRTY_ATTRIBUTES | DIRTY_CHANNELS | DIRTY_VIEWPORT |
00213                 DIRTY_DRAWABLECONFIG | DIRTY_OBJECT_BITS
00214         };
00215 
00217         virtual uint64_t getRedistributableBits() const
00218             { return DIRTY_WINDOW_BITS; }
00219 
00220     private:
00222         P* const _pipe;
00223 
00225         Channels _channels;
00226 
00227         struct BackupData
00228         {
00229             BackupData();
00230 
00232             int32_t iAttributes[ IATTR_ALL ];
00233 
00235             DrawableConfig drawableConfig;
00236 
00238             PixelViewport pvp;
00239         
00241             Viewport vp;
00242 
00245             bool fixedVP;
00246         }
00247             _data, _backup;
00248 
00249         struct Private;
00250         Private* _private; // placeholder for binary-compatible changes
00251 
00252         friend class Channel< W, C >;
00254         void _addChannel( C* channel );
00255 
00257         EQFABRIC_INL bool _removeChannel( C* channel );
00258 
00260         EQFABRIC_INL virtual uint32_t commitNB( const uint32_t incarnation );
00261         bool _mapNodeObjects() { return _pipe->_mapNodeObjects(); }
00262 
00263         typedef co::CommandFunc< Window< P, W, C > > CmdFunc;
00264         bool _cmdNewChannel( co::Command& command );
00265         bool _cmdNewChannelReply( co::Command& command );
00266     };
00267 
00268     template< class P, class W, class C > EQFABRIC_INL
00269     std::ostream& operator << ( std::ostream& os,
00270                                 const Window< P, W, C >& window );
00271 }
00272 }
00273 
00274 #endif // EQFABRIC_WINDOW_H
00275 
Generated on Sun May 8 2011 19:11:08 for Equalizer 1.0 by  doxygen 1.7.3