File: draw_surface.h

package info (click to toggle)
scummvm 2.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 450,580 kB
  • sloc: cpp: 4,299,825; asm: 28,322; python: 12,901; sh: 11,302; java: 9,289; xml: 7,895; perl: 2,639; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (128 lines) | stat: -rw-r--r-- 3,574 bytes parent folder | download | duplicates (3)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* 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 3 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, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef GLK_COMPREHEND_GRAPHICS_H
#define GLK_COMPREHEND_GRAPHICS_H

#include "common/scummsys.h"
#include "graphics/managed_surface.h"

namespace Glk {
namespace Comprehend {

#define G_RENDER_WIDTH  280
#define G_RENDER_HEIGHT 160

#define RGB(r, g, b)        (uint32)(((r) << 24) | ((g) << 16) | ((b) << 8) | 0xff)

#define G_COLOR_BLACK  0x000000ff
#define G_COLOR_WHITE  0xffffffff
#define G_COLOR_CYAN   0x3366ffff
#define G_COLOR_YELLOW 0xffff00ff
#define G_COLOR_RED    0xff0000ff

#define G_COLOR_GRAY0  0x202020ff
#define G_COLOR_GRAY1  0x404040ff
#define G_COLOR_GRAY2  0x808080ff
#define G_COLOR_GRAY3  0xc0c0c0ff

#define G_COLOR_LIGHT_ORANGE  0xff9966ff
#define G_COLOR_ORANGE        0xff9900ff
#define G_COLOR_DARK_PURPLE   0x666699ff
#define G_COLOR_DARK_BLUE     0x000099ff

#define G_COLOR_DARK_RED      0xcc0033ff
#define G_COLOR_DITHERED_PINK 0xff6699ff

#define G_COLOR_DARK_GREEN1   0x009966ff
#define G_COLOR_DARK_GREEN2   0x003300ff

#define G_COLOR_AQUA          0x33ccccff

#define G_COLOR_GREEN         0x33cc00ff

#define G_COLOR_BROWN1        0x7a5200ff
#define G_COLOR_BROWN2        0x663300ff

enum Shape {
	SHAPE_PIXEL = 0,
	SHAPE_BOX = 1,
	SHAPE_CIRCLE_TINY = 2,
	SHAPE_CIRCLE_SMALL = 3,
	SHAPE_CIRCLE_MED = 4,
	SHAPE_CIRCLE_LARGE = 5,
	SHAPE_A = 6,
	SHAPE_SPRAY = 7
};


class Surface : public Graphics::ManagedSurface {
private:
	static const uint32 PEN_COLORS[8];
	static const uint32 DEFAULT_COLOR_TABLE[256];
	static const uint32 COLOR_TABLE_1[256];
	static const uint32 *COLOR_TABLES[2];

public:
	const uint32 *_colorTable;
public:
	Surface() : _colorTable(DEFAULT_COLOR_TABLE) {
		reset();
	}

	/**
	 * Sets up the surface to the correct size and pixel format
	 */
	void reset();

	void setColorTable(uint index);
	uint getPenColor(uint8 param) const;
	uint32 getFillColor(uint8 index);

	void drawLine(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color);
	void drawBox(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color);
	void drawFilledBox(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color);
	void drawShape(int16 x, int16 y, Shape shapeType, uint32 fill_color);
	void drawPixel(int16 x, int16 y, uint32 color);
	uint32 getPixelColor(int16 x, int16 y) const;
	void clearScreen(uint32 color);
	void drawCircle(int16 x, int16 y, int16 diameter, uint32 color);
	void drawCirclePoint(int16 x, int16 y);
};

class FloodFillSurface : public Surface {
private:
	bool isPixelWhite(int16 x, int16 y) const;

	void floodFillRow(int16 x, int16 y, uint32 fillColor);
public:
	void floodFill(int16 x, int16 y, uint32 fillColor);

	void dumpToScreen();
};

class DrawSurface : public FloodFillSurface {
};

} // namespace Comprehend
} // namespace Glk

#endif