blob: b5ec15aad73938993e255f4723b643575b6fbb4b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/* ScummVM - Scumm int32erpreter
* Copyright (C) 2001/2002 The ScummVM project
*
* 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 2
* of the License, or (at your option) any later version.
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header$
*
*/
#ifndef BRENDERER_H
#define BRENDERER_H
#include "config.h"
#include "renderer.h"
#include "palette.h"
/*! @brief base class for easily creating ::renderer instances
This class implements some function available in the ::renderer abstract class, so that
creation of subclasses of ::renderer is easier.
*/
class BaseRenderer : public Renderer {
private:
Palette _pal; //!< The current palette
char * _data; //!< The current frame buffer
int32 _frame; //!< The current frame number
int32 _nbframes; //!< The number of frames in the animation
int32 _width; //!< The current frame's width
int32 _height; //!< The current frame's height
const char * _fname; //!< The filename of the animation being played
protected:
virtual void save(int32 frame = -1) = 0;
protected:
const char * getFilename() const { return _fname; }; //!< accessor for animation filename
int32 getNbframes() const { return _nbframes; }; //!< accessor for number of frames
int32 getWidth() const { return _width; }; //!< accessor for current width
int32 getHeight() const { return _height; }; //!< accessor for current height
const char * data() const { return _data; }; //!< accessor for current frame buffer
void clean(); //!< memory cleanup (deletes frame buffer)
void setFrame(int32 f) { _frame = f; }; //!< allows to change the frame number
public:
int32 getFrame() const { return _frame; }; //!< accessor for current frame number
BaseRenderer();
virtual ~BaseRenderer();
virtual bool initFrame(const Point & size);
virtual char * lockFrame(int32 frame);
virtual bool unlockFrame();
virtual bool flipFrame();
virtual bool setPalette(const Palette & pal);
virtual bool startDecode(const char * fname, int32 version, int32 nbframes) { _fname = fname; _nbframes = nbframes; return true; }
virtual Mixer * getMixer() { return 0; };
virtual bool prematureClose() { return false; };
};
/*! @brief A null ::renderer
This class completely implements ::renderer, without actually doing anything.
This class is useful for performance measurements.
*/
class NullRenderer : public BaseRenderer {
protected:
void save(int32 frame = -1) {};
public:
NullRenderer() {};
virtual ~NullRenderer() {};
bool wait(int32 ms) { return true; };
};
#endif
|