Equalizer  2.1.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/frustum.h> // base class
22 #include <eq/fabric/object.h> // base class
23 #include <eq/fabric/swapBarrier.h> // RefPtr member
24 #include <eq/fabric/types.h>
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; }
45  C* getCanvas() { return _canvas; }
47  const Viewport& getViewport() const { return _vp; }
58  EQFABRIC_INL void setViewport(const Viewport& vp);
59 
69  void setChannel(CH* channel)
70  {
71  _channel = channel;
72  setDirty(DIRTY_CHANNEL);
73  }
74 
76  CH* getChannel() { return _channel; }
78  const CH* getChannel() const { return _channel; }
80  EQFABRIC_INL virtual void setWall(const Wall& wall);
81 
83  EQFABRIC_INL virtual void setProjection(const Projection&);
84 
86  EQFABRIC_INL virtual void unsetFrustum();
87 
89  uint32_t getEyes() const { return _eyes; }
98  EQFABRIC_INL void setEyes(const uint32_t eyes);
99 
108  void enableEye(const uint32_t eyes) { _eyes |= eyes; }
117  EQFABRIC_INL void setSwapBarrier(SwapBarrierPtr barrier);
118 
120  SwapBarrierConstPtr getSwapBarrier() const { return _swapBarrier; }
122  SwapBarrierPtr getSwapBarrier() { return _swapBarrier; }
124 
134  EQFABRIC_INL VisitorResult accept(Visitor& visitor);
135 
137  EQFABRIC_INL VisitorResult accept(Visitor& visitor) const;
138 
140  void inheritFrustum();
141 
142  virtual void backup();
143  virtual void restore();
144 
146  virtual uint128_t commit(const uint32_t incarnation = CO_COMMIT_NEXT);
148 
149 protected:
151  EQFABRIC_INL explicit Segment(C* canvas);
152 
154  EQFABRIC_INL virtual ~Segment();
155 
157  EQFABRIC_INL virtual void serialize(co::DataOStream& os,
158  const uint64_t dirtyBits);
160  EQFABRIC_INL virtual void deserialize(co::DataIStream& is,
161  const uint64_t dirtyBits);
162  virtual void setDirty(const uint64_t bits);
163 
165  enum DirtyBits
166  {
167  DIRTY_VIEWPORT = Object::DIRTY_CUSTOM << 0,
168  DIRTY_FRUSTUM = Object::DIRTY_CUSTOM << 1,
169  DIRTY_CHANNEL = Object::DIRTY_CUSTOM << 2,
170  DIRTY_EYES = Object::DIRTY_CUSTOM << 3,
171  DIRTY_SEGMENT_BITS = DIRTY_VIEWPORT | DIRTY_FRUSTUM | DIRTY_CHANNEL |
172  DIRTY_EYES | DIRTY_OBJECT_BITS
173  };
174 
176  virtual uint64_t getRedistributableBits() const
177  {
178  return DIRTY_SEGMENT_BITS;
179  }
180 
182  virtual void notifyFrustumChanged() { setDirty(DIRTY_FRUSTUM); }
183 private:
185  C* const _canvas;
186 
188  Viewport _vp;
189 
191  CH* _channel;
192 
193  uint32_t _eyes;
194 
195  SwapBarrierPtr _swapBarrier;
196 
197  struct Private;
198  Private* _private; // placeholder for binary-compatible changes
199 };
200 
201 template <class C, class S, class CH>
202 std::ostream& operator<<(std::ostream&, const Segment<C, S, CH>&);
203 }
204 }
205 #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:29
DirtyBits
The changed parts of the object since the last pack().
Definition: object.h:107
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
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:44
LeafVisitor< S > Visitor
The segment visitor type.
A distributed object for frustum data.
Definition: frustum.h:30