Equalizer  1.2.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,
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 
00170         EQFABRIC_INL virtual void backup(); 
00171         EQFABRIC_INL virtual void restore(); 
00172         void create( C** channel ); 
00173         void release( C* channel ); 
00174         virtual void output( std::ostream& ) const {} 
00175 
00176         EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation =
00177                                                CO_COMMIT_NEXT );
00179 
00180     protected: 
00182         Window( P* parent );
00183 
00184         EQFABRIC_INL virtual ~Window(); 
00185 
00186         virtual void attach( const co::base::UUID& id,
00187                              const uint32_t instanceID );
00188 
00190         EQFABRIC_INL virtual void serialize( co::DataOStream& os,
00191                                                 const uint64_t dirtyBits );
00193         EQFABRIC_INL virtual void deserialize( co::DataIStream& is, 
00194                                                   const uint64_t dirtyBits );
00195         
00196         EQFABRIC_INL virtual void notifyDetach(); 
00197 
00199         EQFABRIC_INL virtual void setDirty( const uint64_t bits );
00200 
00202         void _setDrawableConfig( const DrawableConfig& drawableConfig );
00203 
00205         virtual ChangeType getChangeType() const { return UNBUFFERED; }
00206 
00207         C* _findChannel( const co::base::UUID& id ); 
00208 
00210         enum DirtyBits
00211         {
00212             DIRTY_ATTRIBUTES      = Object::DIRTY_CUSTOM << 0,
00213             DIRTY_CHANNELS        = Object::DIRTY_CUSTOM << 1,
00214             DIRTY_VIEWPORT        = Object::DIRTY_CUSTOM << 2,
00215             DIRTY_DRAWABLECONFIG  = Object::DIRTY_CUSTOM << 3,
00216             DIRTY_WINDOW_BITS =
00217                 DIRTY_ATTRIBUTES | DIRTY_CHANNELS | DIRTY_VIEWPORT |
00218                 DIRTY_DRAWABLECONFIG | DIRTY_OBJECT_BITS
00219         };
00220 
00222         virtual uint64_t getRedistributableBits() const
00223             { return DIRTY_WINDOW_BITS; }
00224 
00225     private:
00227         P* const _pipe;
00228 
00230         Channels _channels;
00231 
00232         struct BackupData
00233         {
00234             BackupData();
00235 
00237             int32_t iAttributes[ IATTR_ALL ];
00238 
00240             DrawableConfig drawableConfig;
00241 
00243             PixelViewport pvp;
00244         
00246             Viewport vp;
00247 
00250             bool fixedVP;
00251         }
00252             _data, _backup;
00253 
00254         struct Private;
00255         Private* _private; // placeholder for binary-compatible changes
00256 
00257         friend class Channel< W, C >;
00259         void _addChannel( C* channel );
00260 
00262         EQFABRIC_INL bool _removeChannel( C* channel );
00263 
00265         bool _mapNodeObjects() { return _pipe->_mapNodeObjects(); }
00266 
00267         typedef co::CommandFunc< Window< P, W, C > > CmdFunc;
00268         bool _cmdNewChannel( co::Command& command );
00269         bool _cmdNewChannelReply( co::Command& command );
00270     };
00271 
00272     template< class P, class W, class C > EQFABRIC_INL
00273     std::ostream& operator << ( std::ostream& os,
00274                                 const Window< P, W, C >& window );
00275 }
00276 }
00277 
00278 #endif // EQFABRIC_WINDOW_H
00279 
Generated on Fri Jun 8 2012 15:44:33 for Equalizer 1.2.1 by  doxygen 1.8.0