Equalizer  1.6.1
include/eq/fabric/window.h
1 
2 /* Copyright (c) 2010-2013, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2010, Cedric Stalder <cedric.stalder@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License version 2.1 as published
7  * by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef EQFABRIC_WINDOW_H
20 #define EQFABRIC_WINDOW_H
21 
22 #include <eq/fabric/object.h> // base class
23 
24 #include <eq/fabric/drawableConfig.h> // enum
25 #include <eq/fabric/paths.h>
26 #include <eq/fabric/pixelViewport.h>
27 #include <eq/fabric/viewport.h>
28 
29 namespace eq
30 {
31  class Window;
32 namespace server
33 {
34  class Window;
35 }
36 namespace fabric
37 {
39  template< class P, class W, class C > class Window : public Object
40  {
41  public:
43  typedef std::vector< C* > Channels;
46 
50  void init();
51 
53  const P* getPipe() const { return _pipe; }
55  P* getPipe() { return _pipe; }
56 
58  const Channels& getChannels() const { return _channels; }
59 
62  { return _data.drawableConfig; }
63 
67  const PixelViewport& getPixelViewport() const { return _data.pvp; }
68 
73  const Viewport& getViewport() const { return _data.vp; }
74 
84  EQFABRIC_INL virtual void setPixelViewport(const PixelViewport& pvp);
85 
95  EQFABRIC_INL void setViewport( const Viewport& vp );
96 
98  bool hasFixedViewport( ) const { return _data.fixedVP; }
99 
101  virtual void notifyViewportChanged();
102 
110  EQFABRIC_INL VisitorResult accept( Visitor& visitor );
111 
113  EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const;
114 
116 
129  {
130  // Note: also update string array initialization in window.ipp
147  IATTR_LAST,
148  IATTR_ALL = IATTR_LAST + 5
149  };
150 
152  void setIAttribute( const IAttribute attr, const int32_t value )
153  { _data.iAttributes[attr] = value; }
154 
156  int32_t getIAttribute( const IAttribute attr ) const
157  { return _data.iAttributes[attr]; }
158 
160  EQFABRIC_INL static
161  const std::string& getIAttributeString( const IAttribute attr );
163 
165  EQFABRIC_INL WindowPath getPath() const;
166 
169  EQFABRIC_INL virtual void backup();
170  EQFABRIC_INL virtual void restore();
171  void create( C** channel );
172  void release( C* channel );
173  virtual void output( std::ostream& ) const {}
174 
175  EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation =
176  CO_COMMIT_NEXT );
178 
179  protected:
181  Window( P* parent );
182 
183  EQFABRIC_INL virtual ~Window();
184 
185  virtual void attach( const UUID& id,
186  const uint32_t instanceID );
187 
189  EQFABRIC_INL virtual void serialize( co::DataOStream& os,
190  const uint64_t dirtyBits );
192  EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
193  const uint64_t dirtyBits );
194 
195  EQFABRIC_INL virtual void notifyDetach();
196 
198  EQFABRIC_INL virtual void setDirty( const uint64_t bits );
199 
201  void _setDrawableConfig( const DrawableConfig& drawableConfig );
202 
204  virtual ChangeType getChangeType() const { return UNBUFFERED; }
205 
206  C* _findChannel( const UUID& id );
207 
209  enum DirtyBits
210  {
211  DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 0,
212  DIRTY_CHANNELS = Object::DIRTY_CUSTOM << 1,
213  DIRTY_VIEWPORT = Object::DIRTY_CUSTOM << 2,
214  DIRTY_DRAWABLECONFIG = Object::DIRTY_CUSTOM << 3,
215  DIRTY_WINDOW_BITS =
216  DIRTY_ATTRIBUTES | DIRTY_CHANNELS | DIRTY_VIEWPORT |
217  DIRTY_DRAWABLECONFIG | DIRTY_OBJECT_BITS
218  };
219 
221  virtual uint64_t getRedistributableBits() const
222  { return DIRTY_WINDOW_BITS; }
223 
224  private:
226  P* const _pipe;
227 
229  Channels _channels;
230 
231  struct BackupData
232  {
233  BackupData();
234 
236  int32_t iAttributes[ IATTR_ALL ];
237 
239  DrawableConfig drawableConfig;
240 
242  PixelViewport pvp;
243 
245  Viewport vp;
246 
249  bool fixedVP;
250  }
251  _data, _backup;
252 
253  struct Private;
254  Private* _private; // placeholder for binary-compatible changes
255 
256  friend class Channel< W, C >;
258  void _addChannel( C* channel );
259 
261  EQFABRIC_INL bool _removeChannel( C* channel );
262 
264  bool _mapNodeObjects() { return _pipe->_mapNodeObjects(); }
265 
266  typedef co::CommandFunc< Window< P, W, C > > CmdFunc;
267  bool _cmdNewChannel( co::ICommand& command );
268  bool _cmdNewChannelReply( co::ICommand& command );
269  };
270 
271  template< class P, class W, class C > EQFABRIC_INL
272  std::ostream& operator << ( std::ostream& os,
273  const Window< P, W, C >& window );
274 }
275 }
276 
277 #endif // EQFABRIC_WINDOW_H
const Viewport & getViewport() const
IAttribute
Possible values for integer attributes.
Definition: iAttribute.h:30
EQFABRIC_INL void setViewport(const Viewport &vp)
Set the window&#39;s viewport wrt its parent pipe.
std::vector< C * > Channels
A vector of pointers to channels.
const PixelViewport & getPixelViewport() const
const DrawableConfig & getDrawableConfig() const
A Window represents an on-screen or off-screen drawable.
virtual EQFABRIC_INL void setDirty(const uint64_t bits)
A visitor to traverse non-leaf elements and their children in a tree.
No of per-component color planes.
const P * getPipe() const
Holds a 2D pixel viewport with methods for manipulation.
Definition: pixelViewport.h:34
Stores the characteristics of a window&#39;s frame buffer configuration.
const Channels & getChannels() const
void setIAttribute(const IAttribute attr, const int32_t value)
Set a window attribute.
No of accumulation buffer planes.
int32_t getIAttribute(const IAttribute attr) const
virtual EQFABRIC_INL void setPixelViewport(const PixelViewport &pvp)
Set the window&#39;s pixel viewport wrt its parent pipe.
EQFABRIC_INL VisitorResult accept(Visitor &visitor)
Perform a depth-first traversal of this window.
A fractional viewport with methods for manipulation.
Definition: viewport.h:36
ElementVisitor< W, LeafVisitor< C > > Visitor
The Window visitor type.