source: trunk/src/testing/include/sageDoubleBuf.h @ 4

Revision 4, 3.1 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

Line 
1/***************************************************************************************
2 * SAGE - Scalable Adaptive Graphics Environment
3 *
4 * Module:  sageDoubleBuf.h
5 * Author : Byungil Jeong
6 *
7 *   Description: double buffer of sage pixel blocks for sageStreamer
8 *
9 * Copyright (C) 2004 Electronic Visualization Laboratory,
10 * University of Illinois at Chicago
11 *
12 * All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are met:
16 *
17 *  * Redistributions of source code must retain the above copyright
18 *    notice, this list of conditions and the following disclaimer.
19 *  * Redistributions in binary form must reproduce the above
20 *    copyright notice, this list of conditions and the following disclaimer
21 *    in the documentation and/or other materials provided with the distribution.
22 *  * Neither the name of the University of Illinois at Chicago nor
23 *    the names of its contributors may be used to endorse or promote
24 *    products derived from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
30 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 *
38 * Direct questions, comments etc about SAGE to sage_users@listserv.uic.edu or
39 * http://www.evl.uic.edu/cavern/forum/
40 *
41*****************************************************************************************/
42
43#ifndef _SAGEDOUBLEBUF_H
44#define _SAGEDOUBLEBUF_H
45
46#include "sageBase.h"
47
48class sagePixelData;
49
50class sageDoubleBuf {
51private:
52   int bufID;
53   sagePixelData **blockBuf;   
54     
55   pthread_mutex_t *bufLock;
56   pthread_cond_t *notFull;
57   pthread_cond_t *notEmpty;
58   
59   bool full, empty;
60   bool firstFrameReady;
61   int queueLen;
62     
63public:
64   sageDoubleBuf() : full(false), empty(true), queueLen(0), firstFrameReady(false) {}
65   int init(sagePixelData **bufs);   
66   
67   sagePixelData* getBuffer(int id);  // get buffer without checking availability
68   sagePixelData* getBackBuffer();    // get the pixel block on which pixel data has been written
69   int releaseBackBuffer();
70   int bufSize();
71   
72   // get the empty block on which application can write safely
73   sagePixelData* getFrontBuffer();
74   
75   int swapBuffer();
76   int resendBuffer(int num);
77   void enQueue()  { queueLen++; }
78   bool isEmpty()  { return (queueLen == 0); }
79   bool isFirstFrameReady() { return firstFrameReady; }
80   void releaseLocks();
81   ~sageDoubleBuf();
82};
83
84#endif
Note: See TracBrowser for help on using the repository browser.