/* * This Software is the original work of Daniel TUNG * This Software is submitted in partial fulfillment of the * requirements for the degree of BCSE. * Dept. Computer Science, Monash University 2000 * * Copyright (c) 2000 beetung@cs.monash.edu.au * beetung@geocities.com */ #include #include "fastbuf.h" XShmTester Fastbuf::hasXShm; LListHolder > Fastbuf::nodeHolder; //////////////////////////////////////////////////////////////// ///---begins--- XShmTester Class Function Body ---begins---/// //////////////////////////////////////////////////////////////// //----------------------------- XShmTester::XShmTester() { //----------------------------- // Do we have X at all? // if ((dpy = XOpenDisplay(NULL)) ==NULL) { cerr << "ERROR: Cannot open the bloody X display!!\n"; exit(-1); } weHaveXShm = isXShmEnabled(); if (weHaveXShm) cout << " XSHM enabled... " << endl; else cout << " XSHM disabled... " << endl; } //----------------------------- bool XShmTester::isXShmEnabled(void) { //----------------------------- // all standard XShm stuff... no comment necessary ? // we must use RGB mode, ie 24bpp as specified below // on XxxxCreateImage(...) if ( !XShmQueryExtension (dpy) ) return false; else return true; } //// What does this function do, really? //// //----------------------------- void XShmTester::NoXShmError(void) { //----------------------------- cerr << " ..XShmQueryExtension Failed." << endl; cerr << "..Basic X interface not implemented. get to a Linux!!" << endl << endl; cerr << " This Frame object is specially built for our CCC project. It is not " " intended for general use." << endl; } ///////////////////////////////////////////////////////////// ///---begins--- Fastbuf Class Function Body ---begins---/// ///////////////////////////////////////////////////////////// //// Ctor //----------------------------- Fastbuf::Fastbuf() : nodeCount(nodeHolder.getNodeCount()) { //----------------------------- // Do we have X at all? // if ((dpy = XOpenDisplay(NULL)) ==NULL) { cerr << "ERROR: Cannot open the bloody X display!!\n"; exit(-1); } if ( Fastbuf::hasXShm ) // its a static! newXShmImage(); else newXImage(); } //----------------------------- Fastbuf::Fastbuf(char*& bufPtr) : nodeCount(nodeHolder.getNodeCount()) { //----------------------------- // Do we have X at all? // if ((dpy = XOpenDisplay(NULL)) ==NULL) { cerr << "ERROR: Cannot open the bloody X display!!"<< endl; exit(-1); } cerr << " .. passed in buffer location: using stardard BASIC_X_IMAGE"<< endl; newXImage(bufPtr); } //----------------------------- Fastbuf::Fastbuf(Fastbuf& fb) : nodeCount(nodeHolder.getNodeCount()) { //----------------------------- // Do we have X at all? // if ((dpy = XOpenDisplay(NULL)) ==NULL) { cerr << "ERROR: Cannot open the bloody X display!!"<< endl; exit(-1); } if ( Fastbuf::hasXShm ) // its a static! newXShmImage(); else newXImage(); const int NOT_USING_VALUE = 0; this->mXCopy( fb , NOT_USING_VALUE); } //// Dtor //----------------------------- Fastbuf::~Fastbuf() { //----------------------------- if ( Fastbuf::hasXShm ) XDestroyImage (image); else if (bAlloc) // we allocated BASIC_X buffers? delete [] pixel; }