Equalizer  1.10.1
Parallel Rendering Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fabric/window.h
1 
2 /* Copyright (c) 2010-2013, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2014, Daniel Nachbaur <danielnachbaur@gmail.com>
4  * 2010, Cedric Stalder <cedric.stalder@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 2.1 as published
8  * by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef EQFABRIC_WINDOW_H
21 #define EQFABRIC_WINDOW_H
22 
23 #include <eq/fabric/object.h> // base class
24 
25 #include <eq/fabric/drawableConfig.h> // enum
26 #include <eq/fabric/paths.h>
27 #include <eq/fabric/pixelViewport.h>
28 #include <eq/fabric/viewport.h>
29 #include <eq/fabric/windowSettings.h>
30 
31 namespace eq
32 {
33 namespace fabric
34 {
36  template< class P, class W, class C, class Settings = WindowSettings >
37  class Window : public Object
38  {
39  public:
41  typedef std::vector< C* > Channels;
44 
48  void init();
49 
51  const P* getPipe() const { return _pipe; }
53  P* getPipe() { return _pipe; }
54 
56  const Channels& getChannels() const { return _channels; }
57 
60  { return _data.drawableConfig; }
61 
65  EQFABRIC_INL const PixelViewport& getPixelViewport() const;
66 
71  const Viewport& getViewport() const { return _data.vp; }
72 
74  EQFABRIC_INL void setName( const std::string& name ) final;
75 
85  EQFABRIC_INL virtual void setPixelViewport( const PixelViewport& pvp );
86 
96  EQFABRIC_INL void setViewport( const Viewport& vp );
97 
99  bool hasFixedViewport( ) const { return _data.fixedVP; }
100 
102  virtual void notifyViewportChanged();
103 
111  EQFABRIC_INL VisitorResult accept( Visitor& visitor );
112 
114  EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const;
115 
117 
121  EQFABRIC_INL void setSettings( const Settings& settings );
122 
124  EQFABRIC_INL const Settings& getSettings() const;
125 
127  EQFABRIC_INL void setIAttribute( const WindowSettings::IAttribute attr,
128  const int32_t value );
129 
131  EQFABRIC_INL int32_t
132  getIAttribute( const WindowSettings::IAttribute attr ) const;
133 
135  EQFABRIC_INL static const std::string&
136  getIAttributeString( const WindowSettings::IAttribute attr );
138 
140  EQFABRIC_INL WindowPath getPath() const;
141 
144  EQFABRIC_INL virtual void backup();
145  EQFABRIC_INL virtual void restore();
146  void create( C** channel );
147  void release( C* channel );
148  virtual void output( std::ostream& ) const {}
149 
150  EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation =
151  CO_COMMIT_NEXT );
153 
154  protected:
156  explicit Window( P* parent );
157 
158  EQFABRIC_INL virtual ~Window();
159 
160  virtual void attach( const uint128_t& id,
161  const uint32_t instanceID );
162 
164  EQFABRIC_INL virtual void serialize( co::DataOStream& os,
165  const uint64_t dirtyBits );
167  EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
168  const uint64_t dirtyBits );
169 
170  EQFABRIC_INL virtual void notifyDetach();
171 
173  EQFABRIC_INL virtual void setDirty( const uint64_t bits );
174 
176  void _setDrawableConfig( const DrawableConfig& drawableConfig );
177 
179  virtual ChangeType getChangeType() const { return UNBUFFERED; }
180 
181  C* _findChannel( const uint128_t& id );
182 
184  enum DirtyBits
185  {
186  DIRTY_SETTINGS = Object::DIRTY_CUSTOM << 0,
187  DIRTY_CHANNELS = Object::DIRTY_CUSTOM << 1,
188  DIRTY_VIEWPORT = Object::DIRTY_CUSTOM << 2,
189  DIRTY_DRAWABLECONFIG = Object::DIRTY_CUSTOM << 3,
190  DIRTY_WINDOW_BITS =
191  DIRTY_SETTINGS | DIRTY_CHANNELS | DIRTY_VIEWPORT |
192  DIRTY_DRAWABLECONFIG | DIRTY_OBJECT_BITS
193  };
194 
196  virtual uint64_t getRedistributableBits() const
197  { return DIRTY_WINDOW_BITS; }
198 
199  private:
201  P* const _pipe;
202 
204  Channels _channels;
205 
206  struct BackupData
207  {
208  BackupData();
209 
211  Settings windowSettings;
212 
214  DrawableConfig drawableConfig;
215 
217  PixelViewport pvp;
218 
220  Viewport vp;
221 
224  bool fixedVP;
225  }
226  _data, _backup;
227 
228  struct Private;
229  Private* _private; // placeholder for binary-compatible changes
230 
231  friend class Channel< W, C >;
233  void _addChannel( C* channel );
234 
236  EQFABRIC_INL bool _removeChannel( C* channel );
237 
239  bool _mapNodeObjects() { return _pipe->_mapNodeObjects(); }
240 
241  typedef co::CommandFunc< Window< P, W, C, Settings > > CmdFunc;
242  bool _cmdNewChannel( co::ICommand& command );
243  bool _cmdNewChannelReply( co::ICommand& command );
244  };
245 
246  template< class P, class W, class C, class Settings > EQFABRIC_INL
247  std::ostream& operator << ( std::ostream& os,
248  const Window< P, W, C, Settings >& window );
249 }
250 }
251 
252 #endif // EQFABRIC_WINDOW_H
virtual EQFABRIC_INL void setPixelViewport(const PixelViewport &pvp)
Set the window's pixel viewport wrt its parent pipe.
ElementVisitor< W, LeafVisitor< C > > Visitor
The Window visitor type.
Definition: fabric/window.h:43
EQFABRIC_INL void setName(const std::string &name) final
Set the window's name/caption.
A fractional viewport with methods for manipulation.
Definition: viewport.h:34
EQFABRIC_INL void setViewport(const Viewport &vp)
Set the window's viewport wrt its parent pipe.
std::vector< C * > Channels
A vector of pointers to channels.
Definition: fabric/window.h:41
const Viewport & getViewport() const
Definition: fabric/window.h:71
EQFABRIC_INL const PixelViewport & getPixelViewport() const
const Channels & getChannels() const
Definition: fabric/window.h:56
EQFABRIC_INL void setIAttribute(const WindowSettings::IAttribute attr, const int32_t value)
Set a window attribute.
A visitor to traverse non-leaf elements and their children in a tree.
virtual EQFABRIC_INL void setDirty(const uint64_t bits)
const DrawableConfig & getDrawableConfig() const
Definition: fabric/window.h:59
A Window represents an on-screen or off-screen drawable.
Definition: window.h:64
EQFABRIC_INL const Settings & getSettings() const
EQFABRIC_INL void setSettings(const Settings &settings)
Set the settings of this window.
EQFABRIC_INL int32_t getIAttribute(const WindowSettings::IAttribute attr) const
bool hasFixedViewport() const
Definition: fabric/window.h:99
const P * getPipe() const
Definition: fabric/window.h:51
EQFABRIC_INL VisitorResult accept(Visitor &visitor)
Perform a depth-first traversal of this window.
Stores the characteristics of a window's frame buffer configuration.
Holds a 2D pixel viewport with methods for manipulation.
Definition: pixelViewport.h:34