Line data Source code
1 :
2 : /* Copyright (c) 2012-2014, 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_FRAME_H
19 : #define EQFABRIC_FRAME_H
20 :
21 : #include <eq/fabric/api.h>
22 : #include <eq/fabric/eye.h> // enum
23 : #include <eq/fabric/types.h>
24 : #include <co/object.h> // base class
25 :
26 : namespace eq
27 : {
28 : namespace fabric
29 : {
30 : namespace detail { class Frame; }
31 : /** A holder for a frame data and related parameters. */
32 0 : class Frame : public co::Object
33 : {
34 : public:
35 : /**
36 : * The buffer format defines which components of the frame are to
37 : * be used during readback and assembly.
38 : * @version 1.0
39 : */
40 : enum Buffer
41 : {
42 : BUFFER_NONE = LB_BIT_NONE,
43 : BUFFER_UNDEFINED = LB_BIT1, //!< Inherit, only if no others are set
44 : BUFFER_COLOR = LB_BIT5, //!< Use color images
45 : BUFFER_DEPTH = LB_BIT9, //!< Use depth images
46 : BUFFER_ALL = LB_BIT_ALL_32
47 : };
48 :
49 : /** The storage type for pixel data. @version 1.0 */
50 : enum Type
51 : {
52 : TYPE_MEMORY, //!< use main memory to store pixel data
53 : TYPE_TEXTURE //!< use a GL texture to store pixel data
54 : };
55 :
56 : /** Construct a new frame. @version 1.0 */
57 : EQFABRIC_API Frame();
58 :
59 : /** Destruct the frame. @version 1.0 */
60 : EQFABRIC_API virtual ~Frame();
61 :
62 : /** @name Data Access */
63 : //@{
64 : /** Set the name of the frame. @version 1.3.3 */
65 : EQFABRIC_API void setName( const std::string& name );
66 :
67 : /** @return the name of the frame. @version 1.0 */
68 : EQFABRIC_API const std::string& getName() const;
69 :
70 : /** @return the position of the frame wrt the channel. @version 1.0 */
71 : EQFABRIC_API const Vector2i& getOffset() const;
72 :
73 : /**
74 : * Set the position of the frame wrt the channel.
75 : *
76 : * The offset is only applied for operations on this frame holder, i.e.,
77 : * it does not apply to other (input) frames using the same underlying
78 : * frame data.
79 : * @version 1.0
80 : */
81 : EQFABRIC_API void setOffset( const Vector2i& offset );
82 :
83 : /**
84 : * Set the zoom for this frame holder.
85 : *
86 : * The zoom is only applied for operations on this frame holder, i.e.,
87 : * it does not apply to other (input) frames using the same underlying
88 : * frame data.
89 : * @version 1.0
90 : */
91 : EQFABRIC_API void setZoom( const Zoom& zoom );
92 :
93 : /** @return the zoom factor for readback or assemble. @version 1.0 */
94 : EQFABRIC_API const Zoom& getZoom() const;
95 :
96 : /** @internal */
97 : EQFABRIC_API const co::ObjectVersion& getDataVersion( const Eye ) const;
98 : //@}
99 :
100 : /** @internal @return the receiving eq::Node IDs of an output frame */
101 : EQFABRIC_API
102 : const std::vector< uint128_t >& getInputNodes( const Eye eye ) const;
103 :
104 : /** @internal @return the receiving co::Node IDs of an output frame */
105 : EQFABRIC_API const co::NodeIDs& getInputNetNodes(const Eye eye) const;
106 :
107 : protected:
108 166 : virtual ChangeType getChangeType() const { return INSTANCE; }
109 : EQFABRIC_API virtual void getInstanceData( co::DataOStream& os );
110 : EQFABRIC_API virtual void applyInstanceData( co::DataIStream& is );
111 :
112 : /** @internal */
113 : EQFABRIC_API void _setDataVersion( const unsigned i,
114 : const co::ObjectVersion& ov );
115 :
116 : /** @internal @return the receiving eq::Node IDs of an output frame */
117 : EQFABRIC_API std::vector< uint128_t >& _getInputNodes( const unsigned i );
118 :
119 : /** @internal @return the receiving co::Node IDs of an output frame */
120 : EQFABRIC_API co::NodeIDs& _getInputNetNodes( const unsigned i );
121 :
122 : private:
123 : detail::Frame* const _impl;
124 : };
125 :
126 : /** Print the frame to the given output stream. @version 1.4 */
127 : EQFABRIC_API std::ostream& operator << ( std::ostream&, const Frame& );
128 : /** Print the frame type to the given output stream. @version 1.0 */
129 : EQFABRIC_API std::ostream& operator << ( std::ostream&, const Frame::Type );
130 : /** Print the frame buffer value to the given output stream. @version 1.0 */
131 : EQFABRIC_API std::ostream& operator << (std::ostream&, const Frame::Buffer);
132 : }
133 : }
134 :
135 : namespace lunchbox
136 : {
137 0 : template<> inline void byteswap( eq::fabric::Frame::Type& value )
138 0 : { byteswap( reinterpret_cast< uint32_t& >( value )); }
139 : }
140 : #endif // EQFABRIC_FRAME_H
|