Equalizer  2.1.0
Parallel Rendering Framework
fabric/canvas.h
1 
2 /* Copyright (c) 2010-2016, 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_CANVAS_H
19 #define EQFABRIC_CANVAS_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 
26 #include <string>
27 
28 namespace eq
29 {
30 namespace fabric
31 {
33 template <class CFG, class C, class S, class L>
34 // cppcheck-suppress noConstructor
35 class Canvas : public Object, public Frustum
36 {
37 public:
38  typedef std::vector<C*> Canvases;
39  typedef std::vector<S*> Segments;
40  typedef std::vector<L*> Layouts;
41 
43 
47  CFG* getConfig() { return _config; }
49  const CFG* getConfig() const { return _config; }
51  CanvasPath getPath() const;
52 
54  uint32_t getActiveLayoutIndex() const { return _data.activeLayout; }
56  EQFABRIC_INL const L* getActiveLayout() const;
57 
59  EQFABRIC_INL L* getActiveLayout();
60 
62  const Segments& getSegments() const { return _segments; }
64  S* findSegment(const std::string& name);
65 
67  const S* findSegment(const std::string& name) const;
68 
70  const Layouts& getLayouts() const { return _layouts; }
72  EQFABRIC_INL void addLayout(L* layout);
73 
75  EQFABRIC_INL bool removeLayout(L* layout);
76 
85  EQFABRIC_INL void setSwapBarrier(SwapBarrierPtr barrier);
86 
88  SwapBarrierConstPtr getSwapBarrier() const { return _swapBarrier; }
90  SwapBarrierPtr getSwapBarrier() { return _swapBarrier; }
92  EQFABRIC_INL virtual void setWall(const Wall& wall);
93 
95  EQFABRIC_INL virtual void setProjection(const Projection&);
96 
98  EQFABRIC_INL virtual void unsetFrustum();
100 
108  EQFABRIC_INL virtual bool useLayout(const uint32_t index);
109 
117  EQFABRIC_INL VisitorResult accept(Visitor& visitor);
118 
120  EQFABRIC_INL VisitorResult accept(Visitor& visitor) const;
121 
122  EQFABRIC_INL virtual void backup();
123  EQFABRIC_INL virtual void restore();
124 
125  void create(S** segment);
126  void release(S* segment);
127 
128 
129 protected:
131  EQFABRIC_INL explicit Canvas(CFG* config);
132 
134  EQFABRIC_INL virtual ~Canvas();
135 
137  EQFABRIC_INL virtual void attach(const uint128_t& id,
138  const uint32_t instanceID);
139 
141  EQFABRIC_INL void serialize(co::DataOStream& os, const uint64_t dirtyBits);
143  EQFABRIC_INL virtual void deserialize(co::DataIStream& is,
144  const uint64_t dirtyBits);
145 
146  EQFABRIC_INL virtual void notifyDetach();
147 
149  EQFABRIC_INL virtual void setDirty(const uint64_t bits);
150 
152  virtual void activateLayout(const uint32_t index)
153  {
154  _data.activeLayout = index;
155  }
156 
157 private:
159  CFG* const _config;
160 
161  struct BackupData
162  {
163  BackupData()
164  : activeLayout(0)
165  {
166  }
167 
169  uint32_t activeLayout;
170  } _data, _backup;
171 
173  Layouts _layouts;
174 
176  Segments _segments;
177 
178  SwapBarrierPtr _swapBarrier;
179 
180  struct Private;
181  Private* _private; // placeholder for binary-compatible changes
182 
183  enum DirtyBits
184  {
185  DIRTY_LAYOUT = Object::DIRTY_CUSTOM << 0,
186  DIRTY_SEGMENTS = Object::DIRTY_CUSTOM << 1,
187  DIRTY_LAYOUTS = Object::DIRTY_CUSTOM << 2,
188  DIRTY_FRUSTUM = Object::DIRTY_CUSTOM << 3,
189  DIRTY_CANVAS_BITS = DIRTY_LAYOUT | DIRTY_SEGMENTS | DIRTY_LAYOUTS |
190  DIRTY_FRUSTUM | DIRTY_OBJECT_BITS
191  };
192 
194  virtual uint64_t getRedistributableBits() const
195  {
196  return DIRTY_CANVAS_BITS;
197  }
198 
199  template <class, class, class>
200  friend class Segment;
201  friend class Object;
202  void _addChild(S* segment);
203  bool _removeChild(S* segment);
204 
206  EQFABRIC_INL virtual uint128_t commit(const uint32_t incarnation);
207  bool _mapViewObjects();
208 
209  typedef co::CommandFunc<Canvas<CFG, C, S, L>> CmdFunc;
210  bool _cmdNewSegment(co::ICommand& command);
211  bool _cmdNewSegmentReply(co::ICommand& command);
212 };
213 
214 template <class CFG, class C, class S, class L>
215 std::ostream& operator<<(std::ostream&, const Canvas<CFG, C, S, L>&);
216 }
217 }
218 #endif // EQFABRIC_CANVAS_H
virtual EQFABRIC_INL void setProjection(const Projection &)
EQFABRIC_INL void serialize(co::DataOStream &os, const uint64_t dirtyBits)
virtual EQFABRIC_INL void setDirty(const uint64_t bits)
const CFG * getConfig() const
Definition: fabric/canvas.h:49
std::vector< S * > Segments
A vector of segments.
Definition: fabric/canvas.h:39
EQFABRIC_INL VisitorResult accept(Visitor &visitor)
Traverse this canvas and all children using a canvas visitor.
A wall defining a view frustum.
Definition: wall.h:37
std::vector< C * > Canvases
A vector of canvases.
Definition: fabric/canvas.h:38
uint32_t getActiveLayoutIndex() const
Definition: fabric/canvas.h:54
const Layouts & getLayouts() const
Definition: fabric/canvas.h:70
DirtyBits
The changed parts of the object since the last pack().
Definition: object.h:107
A visitor to traverse non-leaf elements and their children in a tree.
A projector definition defining a view frustum.
Definition: projection.h:38
virtual EQFABRIC_INL void unsetFrustum()
virtual EQFABRIC_INL bool useLayout(const uint32_t index)
Activate the given layout on this canvas.
EQFABRIC_INL const L * getActiveLayout() const
EQFABRIC_INL Canvas(CFG *config)
Construct a new Canvas.
The Equalizer client library.
Definition: eq/agl/types.h:23
const Segments & getSegments() const
Definition: fabric/canvas.h:62
virtual EQFABRIC_INL void deserialize(co::DataIStream &is, const uint64_t dirtyBits)
virtual EQFABRIC_INL ~Canvas()
Destruct this canvas.
A canvas represents a logical 2D projection surface.
Definition: fabric/canvas.h:35
Base data transport class for segments.
virtual EQFABRIC_INL void setWall(const Wall &wall)
Internal base class for all distributed, inheritable Equalizer objects.
Definition: object.h:44
std::vector< L * > Layouts
A vector of layouts.
Definition: fabric/canvas.h:40
ElementVisitor< C, LeafVisitor< S > > Visitor
A Canvas visitor.
Definition: fabric/canvas.h:42
A distributed object for frustum data.
Definition: frustum.h:30