Line data Source code
1 :
2 : /* Copyright (c) 2011-2012, Stefan Eilemann <eile@eyescale.ch>
3 : * 2011-2012, Daniel Nachbaur <danielnachbaur@googlemail.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_TILEQUEUE_H
20 : #define EQSERVER_TILEQUEUE_H
21 :
22 : #include "compound.h"
23 : #include "types.h"
24 :
25 : #include <lunchbox/bitOperation.h> // function getIndexOfLastBit
26 : #include <co/queueMaster.h>
27 :
28 : namespace eq
29 : {
30 : namespace server
31 : {
32 : /** A holder for tile data and parameters. */
33 : class TileQueue : public co::Object
34 : {
35 : public:
36 : /**
37 : * Constructs a new TileQueue.
38 : */
39 : EQSERVER_API TileQueue();
40 : EQSERVER_API virtual ~TileQueue();
41 : TileQueue( const TileQueue& from );
42 :
43 : /**
44 : * @name Data Access
45 : */
46 : //@{
47 0 : void setCompound( Compound* compound )
48 0 : { LBASSERT( !_compound ); _compound = compound; }
49 : Compound* getCompound() const { return _compound; }
50 : Channel* getChannel() const
51 : { return _compound ? _compound->getChannel() :0; }
52 : Node* getNode() const { return _compound ? _compound->getNode() : 0; }
53 :
54 0 : void setName( const std::string& name ) { _name = name; }
55 0 : const std::string& getName() const { return _name; }
56 :
57 : /** Set the size of the tiles. */
58 0 : void setTileSize( const Vector2i& size ) { _size = size; }
59 :
60 : /** @return the tile size. */
61 0 : const Vector2i& getTileSize() const { return _size; }
62 :
63 : /** Add a tile to the queue. */
64 : void addTile( const Tile& tile, const Eye eye );
65 :
66 : /**
67 : * Cycle the current tile queue.
68 : *
69 : * Used for output tile queues to allocate/recycle queue masters.
70 : *
71 : * @param frameNumber the current frame number.
72 : * @param compound the compound holding the output frame.
73 : */
74 : void cycleData( const uint32_t frameNumber, const Compound* compound );
75 :
76 : void setOutputQueue( TileQueue* queue, const Compound* compound );
77 0 : const TileQueue* getOutputQueue( const Eye eye ) const
78 0 : { return _outputQueue[ lunchbox::getIndexOfLastBit( eye ) ]; }
79 :
80 : /**
81 : * @name Operations
82 : */
83 : //@{
84 : /** Unset the tile data. */
85 : void unsetData();
86 :
87 : /** Reset the frame and delete all tile datas. */
88 : void flush();
89 : //@}
90 :
91 : uint128_t getQueueMasterID( const Eye eye ) const;
92 :
93 : protected:
94 0 : EQSERVER_API virtual ChangeType getChangeType() const
95 0 : { return INSTANCE; }
96 : EQSERVER_API virtual void getInstanceData( co::DataOStream& os );
97 : EQSERVER_API virtual void applyInstanceData( co::DataIStream& is );
98 :
99 : private:
100 :
101 0 : struct LatencyQueue
102 : {
103 : uint32_t _frameNumber;
104 : co::QueueMaster _queue;
105 : };
106 :
107 : /** The parent compound. */
108 : Compound* _compound;
109 :
110 : /** The name which associates input to output frames. */
111 : std::string _name;
112 :
113 : /** The size of each tile in the queue. */
114 : Vector2i _size;
115 :
116 : /** The collage queue pool. */
117 : std::deque< LatencyQueue* > _queues;
118 :
119 : /** the currently used tile queues */
120 : LatencyQueue* _queueMaster[ NUM_EYES ];
121 :
122 : /** The current output queue. */
123 : TileQueue* _outputQueue[ NUM_EYES ];
124 : };
125 :
126 : std::ostream& operator << ( std::ostream& os, const TileQueue* frame );
127 : }
128 : }
129 : #endif // EQSERVER_TILEQUEUE_H
|