Line data Source code
1 : /* Copyright (c) 2012-2016, Stefan Eilemann <eile@eyescale.ch>
2 : *
3 : * This library is free software; you can redistribute it and/or modify it under
4 : * the terms of the GNU Lesser General Public License version 2.1 as published
5 : * by the Free Software Foundation.
6 : *
7 : * This library is distributed in the hope that it will be useful, but WITHOUT
8 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
10 : * details.
11 : *
12 : * You should have received a copy of the GNU Lesser General Public License
13 : * along with this library; if not, write to the Free Software Foundation, Inc.,
14 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15 : */
16 :
17 : #ifndef EQFABRIC_FRAME_H
18 : #define EQFABRIC_FRAME_H
19 :
20 : #include <eq/fabric/api.h>
21 : #include <eq/fabric/eye.h> // enum
22 : #include <eq/fabric/types.h>
23 : #include <co/object.h> // base class
24 :
25 : namespace eq
26 : {
27 : namespace fabric
28 : {
29 : namespace detail { class Frame; }
30 :
31 : /** A holder for a frame data and related parameters. */
32 0 : class Frame : public co::Object
33 : {
34 : public:
35 : /**
36 : * Components of the frame are to be used during readback and assembly.
37 : * @version 1.0
38 : */
39 : enum Buffer
40 : {
41 : BUFFER_NONE = LB_BIT_NONE,
42 : BUFFER_UNDEFINED = LB_BIT1, //!< Inherit, only if no others are set
43 : BUFFER_COLOR = LB_BIT5, //!< Use color images
44 : BUFFER_DEPTH = LB_BIT9, //!< Use depth images
45 : BUFFER_ALL = LB_BIT_ALL_32
46 : };
47 :
48 : /** The storage type for pixel data. @version 1.0 */
49 : enum Type
50 : {
51 : TYPE_MEMORY, //!< use main memory to store pixel data
52 : TYPE_TEXTURE //!< use a GL texture to store pixel data
53 : };
54 :
55 : /** Construct a new frame. @version 1.0 */
56 : EQFABRIC_API Frame();
57 :
58 : /** Destruct the frame. @version 1.0 */
59 : EQFABRIC_API virtual ~Frame();
60 :
61 : /** @name Data Access */
62 : //@{
63 : /** Set the name of the frame. @version 1.3.3 */
64 : EQFABRIC_API void setName( const std::string& name );
65 :
66 : /** @return the name of the frame. @version 1.0 */
67 : EQFABRIC_API const std::string& getName() const;
68 :
69 : /** @return the position of the frame wrt the channel. @version 1.0 */
70 : EQFABRIC_API const Vector2i& getOffset() const;
71 :
72 : /**
73 : * Set the position of the frame wrt the channel.
74 : *
75 : * The offset is only applied for operations on this frame holder, i.e., it
76 : * does not apply to other (input) frames using the same underlying frame
77 : * data.
78 : * @version 1.0
79 : */
80 : EQFABRIC_API void setOffset( const Vector2i& offset );
81 :
82 : /**
83 : * Set the zoom for this frame holder.
84 : *
85 : * The zoom is only applied for operations on this frame holder, i.e., it
86 : * does not apply to other (input) frames using the same underlying frame
87 : * data.
88 : * @version 1.0
89 : */
90 : EQFABRIC_API void setZoom( const Zoom& zoom );
91 :
92 : /** @return the zoom factor for readback or assemble. @version 1.0 */
93 : EQFABRIC_API const Zoom& getZoom() const;
94 :
95 : /** @internal */
96 : EQFABRIC_API const co::ObjectVersion& getDataVersion( const Eye ) const;
97 : //@}
98 :
99 : /** @internal @return the receiving eq::Node IDs of an output frame */
100 : EQFABRIC_API
101 : const std::vector< uint128_t >& getInputNodes( const Eye eye ) const;
102 :
103 : /** @internal @return the receiving co::Node IDs of an output frame */
104 : EQFABRIC_API const co::NodeIDs& getInputNetNodes(const Eye eye) const;
105 :
106 : protected:
107 0 : virtual ChangeType getChangeType() const { return INSTANCE; }
108 : EQFABRIC_API virtual void getInstanceData( co::DataOStream& os );
109 : EQFABRIC_API virtual void applyInstanceData( co::DataIStream& is );
110 :
111 : /** @internal */
112 : EQFABRIC_API void _setDataVersion( const unsigned i,
113 : const co::ObjectVersion& ov );
114 :
115 : /** @internal @return the receiving eq::Node IDs of an output frame */
116 : EQFABRIC_API std::vector< uint128_t >& _getInputNodes( const unsigned i );
117 :
118 : /** @internal @return the receiving co::Node IDs of an output frame */
119 : EQFABRIC_API co::NodeIDs& _getInputNetNodes( const unsigned i );
120 :
121 : private:
122 : detail::Frame* const _impl;
123 : };
124 :
125 : /** Print the frame to the given output stream. @version 1.4 */
126 : EQFABRIC_API std::ostream& operator << ( std::ostream&, const Frame& );
127 : /** Print the frame type to the given output stream. @version 1.0 */
128 : EQFABRIC_API std::ostream& operator << ( std::ostream&, const Frame::Type );
129 : /** Print the frame buffer value to the given output stream. @version 1.0 */
130 : EQFABRIC_API std::ostream& operator << (std::ostream&, const Frame::Buffer);
131 : }
132 : }
133 :
134 : namespace lunchbox
135 : {
136 0 : template<> inline void byteswap( eq::fabric::Frame::Type& value )
137 0 : { byteswap( reinterpret_cast< uint32_t& >( value )); }
138 : }
139 : #endif // EQFABRIC_FRAME_H
|