aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/psp/default_display_client.h
blob: d46b7f1a8abeb1a163ac54aea00bbe2383788c8d (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* 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.
 *
 * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef PSP_DEF_DISPLAY_CLIENT_H
#define PSP_DEF_DISPLAY_CLIENT_H

/**
 *	Default display client that is useful for most purposes.
 */
class DefaultDisplayClient : public DisplayClient {
public:
	DefaultDisplayClient() : _visible(false), _dirty(true) {}

	bool isVisible() const { return _visible; }
	void setVisible(bool v) { _visible = v; setDirty(); }
	Buffer &buffer() { return _buffer; }
	Palette &palette() { return _palette; }
	void init();
	bool allocate(bool bufferInVram = false, bool paletteInVram = false);
	void deallocate();
	void clearBuffer();
	void clearPalette();
	void render() { _renderer.render(); }
	uint32 getWidth() { return _buffer.getSourceWidth(); }
	uint32 getHeight() { return _buffer.getSourceHeight(); }
	void setPartialPalette(const byte *colors, uint start, uint num) { setDirty(); return _palette.setPartial(colors, start, num); }
	void getPartialPalette(byte *colors, uint start, uint num) {
		return _palette.getPartial(colors, start, num);
	}
	void copyFromRect(const byte *buf, int pitch, int destX, int destY, int recWidth, int recHeight);
	void copyToArray(byte *dst, int pitch);
	void setDirty() { _dirty = true; }
	void setClean() { _dirty = false; }
	bool isDirty() const { return _dirty; }

protected:
	Buffer _buffer;
	Palette _palette;
	GuRenderer _renderer;
	bool _visible;
	bool _dirty;
};

/**
 *	Screen overlay class.
 */
class Overlay : public DefaultDisplayClient {
public:
	void init();
	bool allocate();
	void setBytesPerPixel(uint32 size);
	void setSize(uint32 width, uint32 height);
	void copyToArray(void *buf, int pitch);
	void copyFromRect(const void *buf, int pitch, int x, int y, int w, int h);
};

/**
 *	Screen class.
 */
class Screen : public DefaultDisplayClient {
public:
	Screen() : _shakePos(0) {
		memset(&_pixelFormat, 0, sizeof(_pixelFormat));
		memset(&_frameBuffer, 0, sizeof(_frameBuffer));
	}

	void init();
	bool allocate();
	void setShakePos(int pos);
	void setScummvmPixelFormat(const Graphics::PixelFormat *format);
	const Graphics::PixelFormat &getScummvmPixelFormat() const { return _pixelFormat; }
	Graphics::Surface *lockAndGetForEditing();
	void unlock() { setDirty(); } // set dirty here because of changes
	void setSize(uint32 width, uint32 height);

private:
	uint32 _shakePos;
	Graphics::PixelFormat _pixelFormat;
	Graphics::Surface _frameBuffer;
};

#endif /* PSP_DEF_DISPLAY_CLIENT_H */