changed: gcc8 base update
[opensg.git] / Source / System / Cluster / Window / SortLast / OSGBinarySwapComposer.h
blobd43ea00ade668d42f4b123101f848e448fe1d76d
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGBINARYSWAPCOMPOSER_H_
40 #define _OSGBINARYSWAPCOMPOSER_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGBaseThread.h"
46 #include "OSGLock.h"
47 #include "OSGBinarySwapComposerBase.h"
48 #include "OSGGLEXT.h"
49 #include "OSGClusterNetwork.h"
51 OSG_BEGIN_NAMESPACE
53 /*! \brief BinarySwapComposer class. See \ref
54 PageSystemBinarySwapComposer for a description.
56 \ingroup GrpClusterWindowComposer
57 \ingroup GrpLibOSGCluster
58 \includebasedoc
61 class OSG_CLUSTER_DLLMAPPING BinarySwapComposer :
62 public BinarySwapComposerBase
64 private:
66 typedef BinarySwapComposerBase Inherited;
68 /*! \brief RGB Color value
69 \nohierarchy
72 struct RGBValue
74 UInt8 red;
75 UInt8 green;
76 UInt8 blue;
79 /*! \nohierarchy
82 struct TileBuffer
84 bool empty;
85 UInt32 size;
86 UInt32 colorSize;
87 UInt32 depthSize;
88 UInt32 dataSize;
90 /*! \nohierarchy
93 struct
95 UInt16 x;
96 UInt16 y;
97 UInt16 w;
98 UInt16 h;
99 } header;
101 UInt8 data[1];
104 /*! \nohierarchy
107 struct Statistics
109 UInt32 bytesIn;
110 UInt32 bytesOut;
111 double composeTime;
114 /*========================== PUBLIC =================================*/
116 public:
118 /*---------------------------------------------------------------------*/
119 /*! \name Sync */
120 /*! \{ */
122 virtual void changed(ConstFieldMaskArg whichField,
123 UInt32 origin,
124 BitVector detail);
126 /*! \} */
127 /*---------------------------------------------------------------------*/
128 /*! \name Output */
129 /*! \{ */
131 virtual void dump( UInt32 uiIndent = 0,
132 const BitVector bvFlags = 0) const;
134 /*! \} */
135 /*---------------------------------------------------------------------*/
136 /*! \name features */
137 /*! \{ */
139 virtual bool clientRendering(void);
141 /*! \} */
142 /*---------------------------------------------------------------------*/
143 /*! \name composition */
144 /*! \{ */
146 virtual void open ( );
147 virtual void composeViewport(Viewport *port);
148 virtual void close (void );
150 /*! \} */
151 /*---------------------------------------------------------------------*/
152 /*! \name features */
153 /*! \{ */
155 virtual bool getClientRendering(void);
156 virtual UInt32 getUsableServers (void);
158 /*! \} */
159 /*========================= PROTECTED ===============================*/
161 protected:
163 BaseThreadRefPtr _writer;
164 BarrierRefPtr _barrier;
165 bool _stopWriter;
166 UInt32 _swapWith;
167 Connection *_swapConnection;
168 UInt32 _tilesX;
169 UInt32 _tilesY;
170 UInt32 _tileBufferSize;
171 std::vector<UInt8> _tile;
172 std::vector<UInt8> _readTile;
173 UInt32 _writeLeft;
174 UInt32 _writeRight;
175 UInt32 _writeBottom;
176 UInt32 _writeTop;
177 UInt32 _usableServers;
178 Statistics _statistics;
179 UInt32 _intDepthMax;
180 UInt32 _shortDepthMax;
182 /*---------------------------------------------------------------------*/
183 /*! \name Constructors */
184 /*! \{ */
186 BinarySwapComposer(void);
187 BinarySwapComposer(const BinarySwapComposer &source);
189 /*! \} */
190 /*---------------------------------------------------------------------*/
191 /*! \name Destructors */
192 /*! \{ */
194 virtual ~BinarySwapComposer(void);
196 /*! \} */
197 /*---------------------------------------------------------------------*/
198 /*! \name compose */
199 /*! \{ */
201 void writeBuffer();
202 void readBuffer();
204 /*! \} */
205 /*---------------------------------------------------------------------*/
206 /*! \name helper function */
207 /*! \{ */
209 template<class DepthT,class ColorT>
210 void sendToClient(DepthT &depth,ColorT &color,
211 UInt32 left,
212 UInt32 bottom,
213 UInt32 right,
214 UInt32 top);
216 template<class DepthT,class ColorT>
217 void recvFromServers(DepthT &depth,ColorT &color,
218 UInt32 colorType,
219 UInt32 colorFormat,
220 Viewport *port);
222 template<class DepthT,class ColorT>
223 void writeCombine(DepthT &depthDummy,ColorT &colorDummy);
225 template<class DepthT,class ColorT>
226 void readCombine(DepthT &depth,ColorT &color,
227 UInt32 colorType,
228 UInt32 colorFormat,
229 UInt32 left,
230 UInt32 bottom,
231 UInt32 right,
232 UInt32 top,
233 UInt32 level);
235 template<class DepthT,class ColorT>
236 void startReader(DepthT &depth,ColorT &color,
237 UInt32 depthFormat,
238 UInt32 colorType,
239 UInt32 colorFormat,
240 Viewport *port);
242 TileBuffer *getTileBuffer(UInt32 x,UInt32 y);
243 TileBuffer *getTileReadBuffer(void);
245 /*! \} */
246 /*---------------------------------------------------------------------*/
247 /*! \name Init */
248 /*! \{ */
250 static void initMethod(InitPhase ePhase);
252 /*! \} */
253 /*========================== PRIVATE ================================*/
255 private:
257 friend class FieldContainer;
258 friend class BinarySwapComposerBase;
260 static void writeProc(void *arg);
262 // prohibit default functions (move to 'public' if you need one)
263 void operator =(const BinarySwapComposer &source);
266 typedef BinarySwapComposer *BinarySwapComposerP;
268 OSG_END_NAMESPACE
270 #include "OSGBinarySwapComposerBase.inl"
271 #include "OSGBinarySwapComposer.inl"
273 #endif /* _OSGBINARYSWAPCOMPOSER_H_ */