Equalizer  1.13.0
Parallel Rendering Framework
fabric/segment.h
1 
2 /* Copyright (c) 2010-2015, Stefan Eilemann <eile@eyescale.ch>
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License version 2.1 as published
6  * by the Free Software Foundation.
7  *
8  * This library is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11  * details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16  */
17 
18 #ifndef EQFABRIC_SEGMENT_H
19 #define EQFABRIC_SEGMENT_H
20 
21 #include <eq/fabric/types.h>
22 #include <eq/fabric/frustum.h> // base class
23 #include <eq/fabric/object.h> // base class
24 #include <eq/fabric/swapBarrier.h> // RefPtr member
25 #include <eq/fabric/viewport.h> // member
26 
27 namespace eq
28 {
29 namespace fabric
30 {
32 template< class C, class S, class CH >
33 // cppcheck-suppress noConstructor
34 class Segment : public Object, public Frustum
35 {
36 public:
39 
43  const C* getCanvas() const { return _canvas; }
44 
46  C* getCanvas() { return _canvas; }
47 
49  const Viewport& getViewport() const { return _vp; }
50 
61  EQFABRIC_INL void setViewport( const Viewport& vp );
62 
72  void setChannel( CH* channel )
73  { _channel = channel; setDirty( DIRTY_CHANNEL ); }
74 
76  CH* getChannel() { return _channel; }
77 
79  const CH* getChannel() const { return _channel; }
80 
82  EQFABRIC_INL virtual void setWall( const Wall& wall );
83 
85  EQFABRIC_INL virtual void setProjection( const Projection& );
86 
88  EQFABRIC_INL virtual void unsetFrustum();
89 
91  uint32_t getEyes() const { return _eyes; }
92 
101  EQFABRIC_INL void setEyes( const uint32_t eyes );
102 
111  void enableEye( const uint32_t eyes ) { _eyes |= eyes; }
112 
121  EQFABRIC_INL void setSwapBarrier( SwapBarrierPtr barrier );
122 
124  SwapBarrierConstPtr getSwapBarrier() const { return _swapBarrier; }
125 
127  SwapBarrierPtr getSwapBarrier() { return _swapBarrier; }
129 
139  EQFABRIC_INL VisitorResult accept( Visitor& visitor );
140 
142  EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const;
143 
145  void inheritFrustum();
146 
147  virtual void backup();
148  virtual void restore();
149 
151  virtual uint128_t commit( const uint32_t incarnation=CO_COMMIT_NEXT );
153 
154 protected:
156  EQFABRIC_INL explicit Segment( C* canvas );
157 
159  EQFABRIC_INL virtual ~Segment();
160 
162  EQFABRIC_INL virtual void serialize( co::DataOStream& os,
163  const uint64_t dirtyBits );
165  EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
166  const uint64_t dirtyBits );
167  virtual void setDirty( const uint64_t bits );
168 
170  enum DirtyBits
171  {
172  DIRTY_VIEWPORT = Object::DIRTY_CUSTOM << 0,
173  DIRTY_FRUSTUM = Object::DIRTY_CUSTOM << 1,
174  DIRTY_CHANNEL = Object::DIRTY_CUSTOM << 2,
175  DIRTY_EYES = Object::DIRTY_CUSTOM << 3,
176  DIRTY_SEGMENT_BITS = DIRTY_VIEWPORT | DIRTY_FRUSTUM |
177  DIRTY_CHANNEL | DIRTY_EYES | DIRTY_OBJECT_BITS
178  };
179 
181  virtual uint64_t getRedistributableBits() const
182  { return DIRTY_SEGMENT_BITS; }
183 
185  virtual void notifyFrustumChanged() { setDirty( DIRTY_FRUSTUM ); }
186 
187 private:
189  C* const _canvas;
190 
192  Viewport _vp;
193 
195  CH* _channel;
196 
197  uint32_t _eyes;
198 
199  SwapBarrierPtr _swapBarrier;
200 
201  struct Private;
202  Private* _private; // placeholder for binary-compatible changes
203 };
204 
205 template< class C, class S, class CH >
206 std::ostream& operator << ( std::ostream&, const Segment< C, S, CH >& );
207 }
208 }
209 #endif // EQFABRIC_SEGMENT_H
A fractional viewport with methods for manipulation.
Definition: viewport.h:34
const Viewport & getViewport() const
uint32_t getEyes() const
A wall defining a view frustum.
Definition: wall.h:37
A visitor to traverse leaf nodes of a graph.
Definition: leafVisitor.h:28
A projector definition defining a view frustum.
Definition: projection.h:38
EQFABRIC_INL VisitorResult accept(Visitor &visitor)
Traverse this segment using a segment visitor.
The Equalizer client library.
Definition: eq/agl/types.h:23
const C * getCanvas() const
LeafVisitor< S > Visitor
The segment visitor type.
CH * getChannel()
Return the output channel of this segment.
Base data transport class for segments.
const CH * getChannel() const
Return the output channel of this segment.
Internal base class for all distributed, inheritable Equalizer objects.
Definition: object.h:41
A distributed object for frustum data.
Definition: frustum.h:30