1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGPIPELINECOMPOSER_H_
40 #define _OSGPIPELINECOMPOSER_H_
47 #include "OSGPipelineComposerBase.h"
48 #include "OSGBaseThread.h"
50 #include "OSGClusterNetwork.h"
52 //#define COMPRESS_IMAGES 1
54 #ifdef COMPRESS_IMAGES
62 //#define USE_NV_OCCLUSION 1
64 /*! \brief PipelineComposer class. See \ref
65 PageSystemPipelineComposer for a description.
67 \ingroup GrpClusterWindowComposer
68 \ingroup GrpLibOSGCluster
72 class OSG_CLUSTER_DLLMAPPING PipelineComposer
: public PipelineComposerBase
76 typedef PipelineComposerBase Inherited
;
80 struct GroupInfoOrder
;
82 friend struct TileBuffer
;
83 friend struct GroupInfo
;
84 friend struct GroupInfoOrder
;
86 /*! \brief RGB Color value
112 unsigned int sendTo
:13;
113 unsigned int empty
:1;
114 unsigned int sendDepth
:1;
115 unsigned int first
:1;
128 Connection
*dstConnection
;
129 struct DepthInfo depth
;
130 struct TransInfo trans
;
153 struct DepthInfo depth
;
154 struct TransInfo trans
;
160 struct GroupInfoOrder
: public std::binary_function
<
161 const GroupInfo
*,const GroupInfo
*, bool>
163 bool operator() (const GroupInfo
*a
, const GroupInfo
*b
);
178 double pixelReadTime
;
182 typedef std::list
<TileBuffer
*> QueueT
;
184 /*========================== PUBLIC =================================*/
188 /*---------------------------------------------------------------------*/
192 virtual void changed(ConstFieldMaskArg whichField
,
197 /*---------------------------------------------------------------------*/
201 virtual void dump( UInt32 uiIndent
= 0,
202 const BitVector bvFlags
= 0) const;
205 /*---------------------------------------------------------------------*/
206 /*! \name composition */
209 virtual void open (void );
210 virtual void startViewport (Viewport
*port
);
211 virtual void composeViewport(Viewport
*port
);
212 virtual void close (void );
215 /*---------------------------------------------------------------------*/
216 /*! \name features */
219 virtual bool getClientRendering(void);
222 /*========================= PROTECTED ===============================*/
226 UInt32 _tileBufferSize
;
227 std::vector
<UInt8
> _tileA
;
228 std::vector
<UInt8
> _tileB
;
229 std::vector
<UInt8
> _workingTile
;
230 std::vector
<UInt8
> *_readTilePtr
;
231 std::vector
<UInt8
> *_composeTilePtr
;
234 UInt32 _composeTilesX
;
235 UInt32 _composeTilesY
;
237 std::vector
< TransInfo
> _transInfo
;
238 std::list
< GroupInfo
> _groupInfoPool
;
239 std::vector
< GroupInfo
* > _groupInfo
;
245 Statistics _statistics
;
247 BaseThreadRefPtr _writer
;
248 ThreadRefPtr _composer
;
249 BarrierRefPtr _barrier
;
250 BarrierRefPtr _composeBarrier
;
251 BarrierRefPtr _frameEndBarrier
;
255 GLuint _occlusionQuery
;
258 /*---------------------------------------------------------------------*/
259 /*! \name Constructors */
262 PipelineComposer(void);
263 PipelineComposer(const PipelineComposer
&source
);
266 /*---------------------------------------------------------------------*/
267 /*! \name Destructors */
270 virtual ~PipelineComposer(void);
273 /*---------------------------------------------------------------------*/
274 /*! \name helper function */
277 template<class DepthT
,class ColorT
>
278 UInt32
getMinMaxOcclude(DepthT
&depth
,ColorT
&color
,
281 template<class DepthT
,class ColorT
>
282 void setTransInfo(DepthT
&depth
,ColorT
&color
);
284 template<class DepthT
,class ColorT
>
285 void calculateTransInfo(DepthT
&depth
,ColorT
&color
);
287 template<class DepthT
,class ColorT
>
288 void clientCompose(DepthT
&depth
,ColorT
&color
);
290 template<class DepthT
,class ColorT
>
291 void serverCompose(DepthT
&depth
,ColorT
&color
);
293 template<class DepthT
,class ColorT
>
294 void writeResult(DepthT
&depth
,ColorT
&color
);
296 template<class DepthT
,class ColorT
>
297 void readBuffer(DepthT
&depth
,ColorT
&color
,
299 template<class DepthT
,class ColorT
>
300 void composeBuffer(DepthT
&depth
,ColorT
&color
);
302 UInt32
compressTransInfo(std::vector
<TransInfo
> &transInfo
);
303 void uncompressTransInfo(std::vector
<TransInfo
> &transInfo
,
306 template <class T
,T empty
>
307 static bool checkDepth(T
*buffer
,T
&front
,T
&back
,int size
);
309 TileBuffer
*getComposeTileBuffer(UInt32 x
,UInt32 y
);
310 TileBuffer
*getReadTileBuffer(UInt32 x
,UInt32 y
);
311 TileBuffer
*getWorkingTileBuffer(void);
314 /*---------------------------------------------------------------------*/
318 static void initMethod(InitPhase ePhase
);
321 /*========================== PRIVATE ================================*/
324 friend class FieldContainer
;
325 friend class PipelineComposerBase
;
327 static void writeProc(void *arg
);
328 static void composeProc(void *arg
);
330 // prohibit default functions (move to 'public' if you need one)
331 void operator =(const PipelineComposer
&source
);
334 typedef PipelineComposer
*PipelineComposerP
;
338 #include "OSGPipelineComposerBase.inl"
339 #include "OSGPipelineComposer.inl"
341 #endif /* _OSGPIPELINECOMPOSER_H_ */