supertux
src
video
drawing_request.hpp
1
// SuperTux
2
// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
#ifndef HEADER_SUPERTUX_VIDEO_DRAWING_REQUEST_HPP
18
#define HEADER_SUPERTUX_VIDEO_DRAWING_REQUEST_HPP
19
20
#include <string>
21
#include <memory>
22
23
#include "math/rectf.hpp"
24
#include "math/sizef.hpp"
25
#include "math/vector.hpp"
26
#include "video/blend.hpp"
27
#include "video/color.hpp"
28
#include "video/drawing_transform.hpp"
29
#include "video/font.hpp"
30
#include "video/gradient.hpp"
31
32
class
Surface
;
33
34
enum class
RequestType
35
{
36
TEXTURE, GRADIENT, FILLRECT, INVERSEELLIPSE, GETPIXEL, LINE, TRIANGLE
37
};
38
39
struct
DrawingRequest
40
{
41
int
layer;
42
Flip flip;
43
float
alpha;
44
Blend blend;
45
const
Rect
viewport;
46
47
DrawingRequest
() =
delete
;
48
DrawingRequest
(
const
DrawingTransform
& transform) :
49
layer(),
50
flip(transform.flip),
51
alpha(transform.alpha),
52
blend(),
53
viewport(transform.viewport)
54
{}
55
virtual
~
DrawingRequest
() {}
56
57
virtual
RequestType get_type()
const
= 0;
58
};
59
60
struct
TextureRequest
:
public
DrawingRequest
61
{
62
TextureRequest
(
const
DrawingTransform
& transform) :
63
DrawingRequest
(transform),
64
texture(),
65
displacement_texture(),
66
srcrects(),
67
dstrects(),
68
angles(),
69
color(1.0f, 1.0f, 1.0f)
70
{}
71
72
RequestType get_type()
const override
{
return
RequestType::TEXTURE; }
73
74
const
Texture
* texture;
75
const
Texture
* displacement_texture;
76
std::vector<Rectf> srcrects;
77
std::vector<Rectf> dstrects;
78
std::vector<float> angles;
79
Color
color;
80
81
private
:
82
TextureRequest
(
const
TextureRequest
&) =
delete
;
83
TextureRequest
& operator=(
const
TextureRequest
&) =
delete
;
84
};
85
86
struct
GradientRequest
:
public
DrawingRequest
87
{
88
GradientRequest
(
const
DrawingTransform
& transform) :
89
DrawingRequest
(transform),
90
pos(0.0f, 0.0f),
91
size(0.0f, 0.0f),
92
top(),
93
bottom(),
94
direction(),
95
region()
96
{}
97
98
RequestType get_type()
const override
{
return
RequestType::GRADIENT; }
99
100
Vector pos;
101
Vector size;
102
Color
top;
103
Color
bottom;
104
GradientDirection direction;
105
Rectf
region;
106
};
107
108
struct
FillRectRequest
:
public
DrawingRequest
109
{
110
FillRectRequest
(
const
DrawingTransform
& transform) :
111
DrawingRequest
(transform),
112
rect(),
113
color(),
114
radius()
115
{}
116
117
RequestType get_type()
const override
{
return
RequestType::FILLRECT; }
118
119
Rectf
rect;
120
Color
color;
121
float
radius;
122
};
123
124
struct
InverseEllipseRequest
:
public
DrawingRequest
125
{
126
InverseEllipseRequest
(
const
DrawingTransform
& transform) :
127
DrawingRequest
(transform),
128
pos(0.0f, 0.0f),
129
size(0.0f, 0.0f),
130
color()
131
{}
132
133
RequestType get_type()
const override
{
return
RequestType::INVERSEELLIPSE; }
134
135
Vector pos;
136
Vector size;
137
Color
color;
138
};
139
140
struct
LineRequest
:
public
DrawingRequest
141
{
142
LineRequest
(
const
DrawingTransform
& transform) :
143
DrawingRequest
(transform),
144
pos(0.0f, 0.0f),
145
dest_pos(0.0f, 0.0f),
146
color()
147
{}
148
149
RequestType get_type()
const override
{
return
RequestType::LINE; }
150
151
Vector pos;
152
Vector dest_pos;
153
Color
color;
154
};
155
156
struct
TriangleRequest
:
public
DrawingRequest
157
{
158
TriangleRequest
(
const
DrawingTransform
& transform) :
159
DrawingRequest
(transform),
160
pos1(0.0f, 0.0f),
161
pos2(0.0f, 0.0f),
162
pos3(0.0f, 0.0f),
163
color()
164
{}
165
166
RequestType get_type()
const override
{
return
RequestType::TRIANGLE; }
167
168
Vector pos1, pos2, pos3;
169
Color
color;
170
};
171
172
struct
GetPixelRequest
:
public
DrawingRequest
173
{
174
GetPixelRequest
(
const
DrawingTransform
& transform) :
175
DrawingRequest
(transform),
176
pos(0.0f, 0.0f),
177
color_ptr()
178
{}
179
180
RequestType get_type()
const override
{
return
RequestType::GETPIXEL; }
181
182
Vector pos;
183
std::shared_ptr<Color> color_ptr;
184
185
private
:
186
GetPixelRequest
(
const
GetPixelRequest
&) =
delete
;
187
GetPixelRequest
& operator=(
const
GetPixelRequest
&) =
delete
;
188
};
189
190
#endif
191
192
/* EOF */
InverseEllipseRequest
Definition:
drawing_request.hpp:124
DrawingTransform
Definition:
drawing_transform.hpp:24
FillRectRequest
Definition:
drawing_request.hpp:108
Surface
A rectangular image.
Definition:
surface.hpp:35
Rect
Definition:
rect.hpp:30
DrawingRequest
Definition:
drawing_request.hpp:39
Texture
This class is a wrapper around a texture handle.
Definition:
texture.hpp:30
GetPixelRequest
Definition:
drawing_request.hpp:172
Rectf
Definition:
rectf.hpp:31
Color
Definition:
color.hpp:26
TextureRequest
Definition:
drawing_request.hpp:60
LineRequest
Definition:
drawing_request.hpp:140
GradientRequest
Definition:
drawing_request.hpp:86
TriangleRequest
Definition:
drawing_request.hpp:156
Generated by
1.8.13