Fix another round of squirrel coverity issues
[supertux.git] / 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 <memory>
21 #include <string>
22 #include <vector>
23
24 #include <stdint.h>
25
26 #include "math/rectf.hpp"
27 #include "math/sizef.hpp"
28 #include "math/vector.hpp"
29 #include "video/color.hpp"
30 #include "video/drawing_context.hpp"
31 #include "video/font.hpp"
32 #include "video/glutil.hpp"
33
34 class Surface;
35
36 enum RequestType
37 {
38   SURFACE, SURFACE_PART, TEXT, GRADIENT, FILLRECT, INVERSEELLIPSE, DRAW_LIGHTMAP, GETLIGHT
39 };
40
41 struct DrawingRequestData
42 {
43   virtual ~DrawingRequestData()
44   {}
45 };
46
47 struct SurfaceRequest : public DrawingRequestData
48 {
49   SurfaceRequest() :
50     surface()
51   {}
52
53   const Surface* surface;
54
55 private:
56   SurfaceRequest(const SurfaceRequest&) = delete;
57   SurfaceRequest& operator=(const SurfaceRequest&) = delete;
58 };
59
60 struct SurfacePartRequest : public DrawingRequestData
61 {
62   SurfacePartRequest() :
63     surface(),
64     srcrect(),
65     dstsize()
66   {}
67
68   const Surface* surface;
69   Rectf srcrect;
70   Sizef dstsize;
71
72 private:
73   SurfacePartRequest(const SurfacePartRequest&) = delete;
74   SurfacePartRequest& operator=(const SurfacePartRequest&) = delete;
75 };
76
77 struct TextRequest : public DrawingRequestData
78 {
79   TextRequest() :
80     font(),
81     text(),
82     alignment()
83   {}
84
85   const Font* font;
86   std::string text;
87   FontAlignment alignment;
88
89 private:
90   TextRequest(const TextRequest&);
91   TextRequest& operator=(const TextRequest&);
92 };
93
94 struct GradientRequest : public DrawingRequestData
95 {
96   GradientRequest()  :
97     top(),
98     bottom(),
99     size()
100   {}
101
102   Color top;
103   Color bottom;
104   Vector size;
105 };
106
107 struct FillRectRequest : public DrawingRequestData
108 {
109   FillRectRequest() :
110     color(),
111     size(),
112     radius()
113   {}
114
115   Color  color;
116   Vector size;
117   float  radius;
118 };
119
120 struct InverseEllipseRequest : public DrawingRequestData
121 {
122   InverseEllipseRequest() :
123     color(),
124     size()
125   {}
126
127   Color  color;
128   Vector size;
129 };
130
131 struct DrawingRequest
132 {
133   Target target;
134   RequestType type;
135   Vector pos;
136
137   int layer;
138   DrawingEffect drawing_effect;
139   float alpha;
140   Blend blend;
141   float angle;
142   Color color;
143
144   DrawingRequestData* request_data;
145
146   DrawingRequest() :
147     target(),
148     type(),
149     pos(),
150     layer(),
151     drawing_effect(),
152     alpha(),
153     blend(),
154     angle(0.0f),
155     color(1.0f, 1.0f, 1.0f, 1.0f),
156     request_data()
157   {}
158
159   bool operator<(const DrawingRequest& other) const
160   {
161     return layer < other.layer;
162   }
163 };
164
165 struct GetLightRequest : public DrawingRequestData
166 {
167   GetLightRequest() : color_ptr() {}
168
169   Color* color_ptr;
170
171 private:
172   GetLightRequest(const GetLightRequest&) = delete;
173   GetLightRequest& operator=(const GetLightRequest&) = delete;
174 };
175
176 #endif
177
178 /* EOF */