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 
23 #ifndef BLADERUNNER_ZBUFFER_H
24 #define BLADERUNNER_ZBUFFER_H
25 
26 #include "bladerunner/bladerunner.h"
27 
28 #include "common/rect.h"
29 
30 namespace BladeRunner {
31 
32 #define MAX_DIRTY_RECTS 20
33 
34 class ZBufferDirtyRects {
35 	int          _count;
36 	Common::Rect _rects[MAX_DIRTY_RECTS];
37 
38 public:
ZBufferDirtyRects()39 	ZBufferDirtyRects() :
40 		_count(0)
41 	{}
42 
43 	void reset();
44 	bool add(Common::Rect rect);
45 	void extendExisting();
46 	int  getCount() const;
47 	bool popRect(Common::Rect *rect);
48 };
49 
50 class ZBuffer {
51 	int     _width;
52 	int     _height;
53 
54 	uint16 *_zbuf1;
55 	uint16 *_zbuf2;
56 
57 	ZBufferDirtyRects *_dirtyRects;
58 
59 	bool _disabled;
60 
61 public:
62 	ZBuffer();
63 	~ZBuffer();
64 
65 	void init(int width, int height);
66 	bool decodeData(const uint8 *data, int size);
67 
68 	uint16 *getData() const;
69 	uint16 getZValue(int x, int y) const;
70 
71 private:
72 	void blit(Common::Rect rect);
73 
74 public:
75 	void mark(Common::Rect rect);
76 	void clean();
77 	void resetUpdates();
78 
79 	// Only called from Scene::resume which is not yet implemented
80 	void disable();
81 	void enable();
82 };
83 
84 } // End of namespace BladeRunner
85 
86 #endif
87