1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * 22 * Based on the original sources 23 * Faery Tale II -- The Halls of the Dead 24 * (c) 1993-1996 The Wyrmkeep Entertainment Co. 25 */ 26 27 #ifndef SAGA2_IMAGCACH_H 28 #define SAGA2_IMAGCACH_H 29 30 namespace Saga2 { 31 32 /* ===================================================================== * 33 ImageNode class which defines a re-entrant image resource 34 * ===================================================================== */ 35 36 class CImageNode { 37 private: 38 uint32 contextID; // ID of context 39 uint32 resourceID; // RES_ID of image 40 41 uint16 requested; // the number of allocation requests made to node 42 void *image; // the image 43 44 public: 45 CImageNode(hResContext *con, uint32 resID); 46 ~CImageNode(void); 47 48 void *getImagePtr(void); 49 bool isSameImage(hResContext *con, uint32 resID); 50 bool isSameImage(void *imagePtr); getNumRequested(void)51 uint16 getNumRequested(void) { 52 return requested; 53 } 54 bool releaseRequest(void); 55 }; 56 57 58 /* ===================================================================== * 59 ImageCache class which maintains a list of ImageNodes 60 * ===================================================================== */ 61 62 class CImageCache { 63 private: 64 Common::List<CImageNode *> _nodes; // list of ImageNode 65 66 public: CImageCache(void)67 CImageCache(void) { 68 assert(_nodes.empty()); 69 } 70 ~CImageCache(void); 71 72 void *requestImage(hResContext *con, uint32 resID); 73 void releaseImage(void *); 74 }; 75 76 } // end of namespace Saga2 77 78 #endif 79