Line data Source code
1 :
2 : /* Copyright (c) 2006-2012, 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 EQSERVER_FRAME_H
20 : #define EQSERVER_FRAME_H
21 :
22 : #include "compound.h"
23 : #include "types.h"
24 :
25 : #include <eq/fabric/frame.h> // base class
26 : #include <lunchbox/bitOperation.h> // function getIndexOfLastBit
27 :
28 : namespace eq
29 : {
30 : namespace server
31 : {
32 : /** A holder for frame data and parameters. */
33 : class Frame : public fabric::Frame
34 : {
35 : public:
36 : /** Construct a new Frame. */
37 : EQSERVER_API Frame();
38 : EQSERVER_API virtual ~Frame();
39 : Frame( const Frame& from );
40 :
41 : /** @name Data Access */
42 : //@{
43 2924 : void setCompound( Compound* compound )
44 2924 : { LBASSERT( !_compound ); _compound = compound; }
45 9 : Compound* getCompound() const { return _compound; }
46 0 : Channel* getChannel() const
47 0 : { return _compound ? _compound->getChannel() : 0; }
48 18 : Node* getNode() const { return _compound ? _compound->getNode() : 0; }
49 :
50 36 : FrameData* getMasterData() const { return _masterFrameData; }
51 13 : bool hasData( const Eye eye ) const
52 13 : { return ( _frameData[ lunchbox::getIndexOfLastBit(eye) ] != 0 ); }
53 :
54 : /**
55 : * Set the frame's viewport wrt the compound (output frames) or wrt the
56 : * corresponding output frame (input frames).
57 : *
58 : * @param vp the fractional viewport.
59 : */
60 750 : void setViewport( const eq::Viewport& vp ) { _vp = vp; }
61 :
62 : /** @return the fractional viewport. */
63 1714 : const eq::Viewport& getViewport() const { return _vp; }
64 :
65 : /**
66 : * Set the frame buffers to be read or write by this frame.
67 : *
68 : * @param buffers a bitwise combination of the buffers.
69 : */
70 124 : void setBuffers( const uint32_t buffers ) { _buffers = buffers; }
71 :
72 : /** return the frame storage type. */
73 1723 : Type getType() const { return _type; }
74 :
75 : /**
76 : * Set the frame storage type.
77 : *
78 : * @param type frame storage type.
79 : */
80 58 : void setType( const Type type ) { _type = type; }
81 :
82 : /** @return the frame buffers used by this frame. */
83 1714 : uint32_t getBuffers() const { return _buffers; }
84 : //@}
85 :
86 : /** @name Operations */
87 : //@{
88 : /** Commit the frame's data (used for output frames only) */
89 : void commitData();
90 :
91 : /** Commit the frame */
92 : EQSERVER_API virtual uint128_t commit( const uint32_t incarnation =
93 : CO_COMMIT_NEXT );
94 :
95 : /**
96 : * Cycle the current FrameData.
97 : *
98 : * Used for output frames to allocate/recycle frame data. Also
99 : * clears the list of input frames.
100 : *
101 : * @param frameNumber the current frame number.
102 : * @param compound the compound holding the output frame.
103 : */
104 : void cycleData( const uint32_t frameNumber, const Compound* compound );
105 :
106 : /**
107 : * Add an input frame to this (output) frame
108 : *
109 : * @param frame the input frame.
110 : * @param compound the compound holding the input frame.
111 : */
112 : void addInputFrame( Frame* frame, const Compound* compound );
113 :
114 : /** @return the vector of current input frames. */
115 : const Frames& getInputFrames( const Eye eye ) const
116 : { return _inputFrames[ lunchbox::getIndexOfLastBit( eye ) ]; }
117 :
118 : /** Unset the frame data. */
119 : void unsetData();
120 :
121 : /** Reset the frame and delete all frame datas. */
122 : void flush();
123 : //@}
124 :
125 : /**
126 : * @name Native data access.
127 : *
128 : * Native data is the raw data based on which the actual data used is
129 : * computed each frame and set using the non-native methods.
130 : */
131 : //@{
132 : /**
133 : * Set the offset of the frame.
134 : *
135 : * The offset defines relative data position wrt to the current
136 : * destination channel of the source.
137 : */
138 0 : void setNativeOffset( const Vector2i& offset )
139 0 : { _native.setOffset( offset ); }
140 :
141 : /** @return the frame's effective offset. */
142 9 : const Vector2i& getNativeOffset() const { return _native.getOffset(); }
143 :
144 : /** Set the native frame zoom factor. */
145 2924 : void setNativeZoom( const eq::Zoom& zoom ) { _native.setZoom( zoom ); }
146 :
147 : /** @return the native zoom factor. */
148 18 : const eq::Zoom& getNativeZoom() const { return _native.getZoom(); }
149 : //@}
150 :
151 : private:
152 : /** The parent compound. */
153 : Compound* _compound;
154 :
155 : /** Frame-specific data. */
156 : eq::Viewport _vp;
157 : uint32_t _buffers;
158 : Type _type;
159 :
160 : /** The configured frame data (base class contains inherit values). */
161 : fabric::Frame _native;
162 :
163 : /** All framedatas ever allocated, used for recycling old datas. */
164 : std::deque<FrameData*> _datas;
165 :
166 : /** Current frame data. */
167 : FrameData* _masterFrameData;
168 : FrameData* _frameData[ fabric::NUM_EYES ];
169 :
170 : /** Vector of current input frames. */
171 : Frames _inputFrames[ fabric::NUM_EYES ];
172 : };
173 :
174 : EQSERVER_API std::ostream& operator << ( std::ostream&, const Frame& );
175 : }
176 : }
177 : #endif // EQSERVER_FRAME_H
|