2021-05-17 20:47:39 +02:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
2021-12-26 18:47:58 +01:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2021-05-17 20:47:39 +02:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 18:47:58 +01:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2021-05-17 20:47:39 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Based on the original sources
|
|
|
|
* Faery Tale II -- The Halls of the Dead
|
|
|
|
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SAGA2_IMAGCACH_H
|
|
|
|
#define SAGA2_IMAGCACH_H
|
|
|
|
|
|
|
|
namespace Saga2 {
|
|
|
|
|
|
|
|
/* ===================================================================== *
|
|
|
|
ImageNode class which defines a re-entrant image resource
|
|
|
|
* ===================================================================== */
|
|
|
|
|
2021-07-03 08:13:09 +09:00
|
|
|
class CImageNode {
|
2021-05-17 20:47:39 +02:00
|
|
|
private:
|
2022-09-26 14:55:18 +02:00
|
|
|
uint32 _contextID; // ID of context
|
|
|
|
uint32 _resourceID; // RES_ID of image
|
2021-05-17 20:47:39 +02:00
|
|
|
|
2022-09-26 14:55:18 +02:00
|
|
|
uint16 _requested; // the number of allocation requests made to node
|
|
|
|
void *_image; // the image
|
2021-05-17 20:47:39 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
CImageNode(hResContext *con, uint32 resID);
|
2021-09-11 12:13:35 +03:00
|
|
|
~CImageNode();
|
2021-05-17 20:47:39 +02:00
|
|
|
|
2021-09-11 12:13:35 +03:00
|
|
|
void *getImagePtr();
|
2021-05-17 20:47:39 +02:00
|
|
|
bool isSameImage(hResContext *con, uint32 resID);
|
|
|
|
bool isSameImage(void *imagePtr);
|
2021-09-11 12:13:35 +03:00
|
|
|
uint16 getNumRequested() {
|
2022-09-26 14:55:18 +02:00
|
|
|
return _requested;
|
2021-05-17 20:47:39 +02:00
|
|
|
}
|
2021-09-11 12:13:35 +03:00
|
|
|
bool releaseRequest();
|
2021-05-17 20:47:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* ===================================================================== *
|
|
|
|
ImageCache class which maintains a list of ImageNodes
|
|
|
|
* ===================================================================== */
|
|
|
|
|
|
|
|
class CImageCache {
|
|
|
|
private:
|
2021-07-03 08:13:09 +09:00
|
|
|
Common::List<CImageNode *> _nodes; // list of ImageNode
|
2021-05-17 20:47:39 +02:00
|
|
|
|
|
|
|
public:
|
2021-09-11 12:13:35 +03:00
|
|
|
CImageCache() {
|
2021-07-03 08:13:09 +09:00
|
|
|
assert(_nodes.empty());
|
2021-05-17 20:47:39 +02:00
|
|
|
}
|
2021-09-11 12:13:35 +03:00
|
|
|
~CImageCache();
|
2021-05-17 20:47:39 +02:00
|
|
|
|
|
|
|
void *requestImage(hResContext *con, uint32 resID);
|
|
|
|
void releaseImage(void *);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end of namespace Saga2
|
|
|
|
|
|
|
|
#endif
|