1 |
|
|
/* |
2 |
|
|
* The ManaPlus Client |
3 |
|
|
* Copyright (C) 2004-2009 The Mana World Development Team |
4 |
|
|
* Copyright (C) 2009-2010 The Mana Developers |
5 |
|
|
* Copyright (C) 2011-2019 The ManaPlus Developers |
6 |
|
|
* Copyright (C) 2019-2021 Andrei Karas |
7 |
|
|
* |
8 |
|
|
* This file is part of The ManaPlus Client. |
9 |
|
|
* |
10 |
|
|
* This program is free software; you can redistribute it and/or modify |
11 |
|
|
* it under the terms of the GNU General Public License as published by |
12 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
13 |
|
|
* any later version. |
14 |
|
|
* |
15 |
|
|
* This program is distributed in the hope that it will be useful, |
16 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
|
|
* GNU General Public License for more details. |
19 |
|
|
* |
20 |
|
|
* You should have received a copy of the GNU General Public License |
21 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 |
|
|
*/ |
23 |
|
|
|
24 |
|
|
#include "unittests/render/mockgraphics.h" |
25 |
|
|
|
26 |
|
|
#include "graphicsmanager.h" |
27 |
|
|
|
28 |
|
|
#include "utils/sdlcheckutils.h" |
29 |
|
|
|
30 |
|
|
#include "render/vertexes/imagecollection.h" |
31 |
|
|
|
32 |
|
|
#include "debug.h" |
33 |
|
|
|
34 |
|
40 |
MockGraphics::MockGraphics() : |
35 |
|
80 |
Graphics() |
36 |
|
|
{ |
37 |
|
40 |
mOpenGL = RENDER_SOFTWARE; |
38 |
|
80 |
mName = "Software"; |
39 |
|
40 |
} |
40 |
|
|
|
41 |
|
120 |
MockGraphics::~MockGraphics() |
42 |
|
|
{ |
43 |
|
80 |
} |
44 |
|
|
|
45 |
|
|
void MockGraphics::drawRescaledImage(const Image *restrict const image |
46 |
|
|
A_UNUSED, |
47 |
|
|
int dstX A_UNUSED, |
48 |
|
|
int dstY A_UNUSED, |
49 |
|
|
const int desiredWidth A_UNUSED, |
50 |
|
|
const int desiredHeight A_UNUSED) |
51 |
|
|
restrict2 |
52 |
|
|
{ |
53 |
|
|
} |
54 |
|
|
|
55 |
|
112 |
void MockGraphics::drawImage(const Image *restrict const image, |
56 |
|
|
int dstX, |
57 |
|
|
int dstY) restrict2 |
58 |
|
|
{ |
59 |
|
224 |
mDraws.push_back(MockDrawItem(MockDrawType::DrawImage, |
60 |
|
|
image, |
61 |
|
|
dstX, |
62 |
|
|
dstY, |
63 |
|
|
0, |
64 |
|
112 |
0)); |
65 |
|
112 |
} |
66 |
|
|
|
67 |
|
|
void MockGraphics::drawImageInline(const Image *restrict const image A_UNUSED, |
68 |
|
|
int dstX A_UNUSED, |
69 |
|
|
int dstY A_UNUSED) restrict2 |
70 |
|
|
{ |
71 |
|
|
} |
72 |
|
|
|
73 |
|
|
void MockGraphics::copyImage(const Image *restrict const image A_UNUSED, |
74 |
|
|
int dstX A_UNUSED, |
75 |
|
|
int dstY A_UNUSED) restrict2 |
76 |
|
|
{ |
77 |
|
|
} |
78 |
|
|
|
79 |
|
|
void MockGraphics::drawImageCached(const Image *restrict const image A_UNUSED, |
80 |
|
|
int x A_UNUSED, |
81 |
|
|
int y A_UNUSED) restrict2 |
82 |
|
|
{ |
83 |
|
|
} |
84 |
|
|
|
85 |
|
|
void MockGraphics::drawPatternCached(const Image *restrict const image |
86 |
|
|
A_UNUSED, |
87 |
|
|
const int x A_UNUSED, |
88 |
|
|
const int y A_UNUSED, |
89 |
|
|
const int w A_UNUSED, |
90 |
|
|
const int h A_UNUSED) restrict2 |
91 |
|
|
{ |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
void MockGraphics::completeCache() restrict2 |
95 |
|
|
{ |
96 |
|
|
} |
97 |
|
|
|
98 |
|
36 |
void MockGraphics::drawPattern(const Image *restrict const image, |
99 |
|
|
const int x, |
100 |
|
|
const int y, |
101 |
|
|
const int w, |
102 |
|
|
const int h) restrict2 |
103 |
|
|
{ |
104 |
|
72 |
mDraws.push_back(MockDrawItem(MockDrawType::DrawPattern, |
105 |
|
|
image, |
106 |
|
|
x, |
107 |
|
|
y, |
108 |
|
|
w, |
109 |
|
36 |
h)); |
110 |
|
36 |
} |
111 |
|
|
|
112 |
|
|
void MockGraphics::drawPatternInline(const Image *restrict const image |
113 |
|
|
A_UNUSED, |
114 |
|
|
const int x A_UNUSED, |
115 |
|
|
const int y A_UNUSED, |
116 |
|
|
const int w A_UNUSED, |
117 |
|
|
const int h A_UNUSED) restrict2 |
118 |
|
|
{ |
119 |
|
|
} |
120 |
|
|
|
121 |
|
|
void MockGraphics::drawRescaledPattern(const Image *restrict const image |
122 |
|
|
A_UNUSED, |
123 |
|
|
const int x A_UNUSED, |
124 |
|
|
const int y A_UNUSED, |
125 |
|
|
const int w A_UNUSED, |
126 |
|
|
const int h A_UNUSED, |
127 |
|
|
const int scaledWidth A_UNUSED, |
128 |
|
|
const int scaledHeight A_UNUSED) |
129 |
|
|
restrict2 |
130 |
|
|
{ |
131 |
|
|
} |
132 |
|
|
|
133 |
|
|
void MockGraphics::calcPattern(ImageVertexes *restrict const vert A_UNUSED, |
134 |
|
|
const Image *restrict const image A_UNUSED, |
135 |
|
|
const int x A_UNUSED, |
136 |
|
|
const int y A_UNUSED, |
137 |
|
|
const int w A_UNUSED, |
138 |
|
|
const int h A_UNUSED) const restrict2 |
139 |
|
|
{ |
140 |
|
|
} |
141 |
|
|
|
142 |
|
|
void MockGraphics::calcPatternInline(ImageVertexes *restrict const vert |
143 |
|
|
A_UNUSED, |
144 |
|
|
const Image *restrict const image |
145 |
|
|
A_UNUSED, |
146 |
|
|
const int x A_UNUSED, |
147 |
|
|
const int y A_UNUSED, |
148 |
|
|
const int w A_UNUSED, |
149 |
|
|
const int h A_UNUSED) const restrict2 |
150 |
|
|
{ |
151 |
|
|
} |
152 |
|
|
|
153 |
|
|
void MockGraphics::calcPattern(ImageCollection *restrict const vertCol |
154 |
|
|
A_UNUSED, |
155 |
|
|
const Image *restrict const image A_UNUSED, |
156 |
|
|
const int x A_UNUSED, |
157 |
|
|
const int y A_UNUSED, |
158 |
|
|
const int w A_UNUSED, |
159 |
|
|
const int h A_UNUSED) const restrict2 |
160 |
|
|
{ |
161 |
|
|
} |
162 |
|
|
|
163 |
|
|
void MockGraphics::calcTileVertexes(ImageVertexes *restrict const vert, |
164 |
|
|
const Image *restrict const image, |
165 |
|
|
int x, int y) const restrict2 |
166 |
|
|
{ |
167 |
|
|
vert->image = image; |
168 |
|
|
calcTileSDL(vert, x, y); |
169 |
|
|
} |
170 |
|
|
|
171 |
|
|
void MockGraphics::calcTileVertexesInline(ImageVertexes *restrict const vert |
172 |
|
|
A_UNUSED, |
173 |
|
|
const Image *restrict const image |
174 |
|
|
A_UNUSED, |
175 |
|
|
int x A_UNUSED, |
176 |
|
|
int y A_UNUSED) const restrict2 |
177 |
|
|
{ |
178 |
|
|
} |
179 |
|
|
|
180 |
|
|
void MockGraphics::calcTileSDL(ImageVertexes *restrict const vert A_UNUSED, |
181 |
|
|
int x A_UNUSED, |
182 |
|
|
int y A_UNUSED) const restrict2 |
183 |
|
|
{ |
184 |
|
|
} |
185 |
|
|
|
186 |
|
|
void MockGraphics::calcTileCollection(ImageCollection *restrict const vertCol |
187 |
|
|
A_UNUSED, |
188 |
|
|
const Image *restrict const image |
189 |
|
|
A_UNUSED, |
190 |
|
|
int x A_UNUSED, |
191 |
|
|
int y A_UNUSED) restrict2 |
192 |
|
|
{ |
193 |
|
|
} |
194 |
|
|
|
195 |
|
|
void MockGraphics::drawTileCollection(const ImageCollection *restrict const |
196 |
|
|
vertCol A_UNUSED) restrict2 |
197 |
|
|
{ |
198 |
|
|
} |
199 |
|
|
|
200 |
|
|
void MockGraphics::drawTileVertexes(const ImageVertexes *restrict const |
201 |
|
|
vert A_UNUSED) restrict2 |
202 |
|
|
{ |
203 |
|
|
} |
204 |
|
|
|
205 |
|
|
void MockGraphics::updateScreen() restrict2 |
206 |
|
|
{ |
207 |
|
|
} |
208 |
|
|
|
209 |
|
|
void MockGraphics::calcWindow(ImageCollection *restrict const vertCol A_UNUSED, |
210 |
|
|
const int x A_UNUSED, |
211 |
|
|
const int y A_UNUSED, |
212 |
|
|
const int w A_UNUSED, |
213 |
|
|
const int h A_UNUSED, |
214 |
|
|
const ImageRect &restrict imgRect A_UNUSED) |
215 |
|
|
restrict2 |
216 |
|
|
{ |
217 |
|
|
} |
218 |
|
|
|
219 |
|
|
void MockGraphics::fillRectangle(const Rect &restrict rectangle A_UNUSED) |
220 |
|
|
restrict2 |
221 |
|
|
{ |
222 |
|
|
} |
223 |
|
|
|
224 |
|
|
void MockGraphics::beginDraw() restrict2 |
225 |
|
|
{ |
226 |
|
|
pushClipArea(Rect(0, 0, mRect.w, mRect.h)); |
227 |
|
|
} |
228 |
|
|
|
229 |
|
|
void MockGraphics::endDraw() restrict2 |
230 |
|
|
{ |
231 |
|
|
popClipArea(); |
232 |
|
|
} |
233 |
|
|
|
234 |
|
|
void MockGraphics::pushClipArea(const Rect &restrict area) restrict2 |
235 |
|
|
{ |
236 |
|
|
Graphics::pushClipArea(area); |
237 |
|
|
} |
238 |
|
|
|
239 |
|
|
void MockGraphics::popClipArea() restrict2 |
240 |
|
|
{ |
241 |
|
|
Graphics::popClipArea(); |
242 |
|
|
} |
243 |
|
|
|
244 |
|
|
void MockGraphics::drawPoint(int x A_UNUSED, |
245 |
|
|
int y A_UNUSED) restrict2 |
246 |
|
|
{ |
247 |
|
|
} |
248 |
|
|
|
249 |
|
|
void MockGraphics::drawRectangle(const Rect &restrict rectangle A_UNUSED) |
250 |
|
|
restrict2 |
251 |
|
|
{ |
252 |
|
|
} |
253 |
|
|
|
254 |
|
|
void MockGraphics::drawLine(int x1 A_UNUSED, |
255 |
|
|
int y1 A_UNUSED, |
256 |
|
|
int x2 A_UNUSED, |
257 |
|
|
int y2 A_UNUSED) restrict2 |
258 |
|
|
{ |
259 |
|
|
} |
260 |
|
|
|
261 |
|
|
bool MockGraphics::setVideoMode(const int w, const int h, |
262 |
|
|
const int scale, |
263 |
|
|
const int bpp, |
264 |
|
|
const bool fs, |
265 |
|
|
const bool hwaccel, |
266 |
|
|
const bool resize, |
267 |
|
|
const bool noFrame, |
268 |
|
|
const bool allowHighDPI) restrict2 |
269 |
|
|
{ |
270 |
|
|
setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame, allowHighDPI); |
271 |
|
|
|
272 |
|
|
if ((mWindow = GraphicsManager::createWindow(w, h, bpp, |
273 |
|
|
getSoftwareFlags())) == nullptr) |
274 |
|
|
{ |
275 |
|
|
mRect.w = 0; |
276 |
|
|
mRect.h = 0; |
277 |
|
|
return false; |
278 |
|
|
} |
279 |
|
|
|
280 |
|
|
mRect.w = CAST_U16(mRect.w); |
281 |
|
|
mRect.h = CAST_U16(mRect.h); |
282 |
|
|
|
283 |
|
|
return videoInfo(); |
284 |
|
|
} |
285 |
|
|
|
286 |
|
|
void MockGraphics::drawImageRect(const int x A_UNUSED, |
287 |
|
|
const int y A_UNUSED, |
288 |
|
|
const int w A_UNUSED, |
289 |
|
|
const int h A_UNUSED, |
290 |
|
|
const ImageRect &restrict imgRect A_UNUSED) |
291 |
|
|
restrict2 |
292 |
|
|
{ |
293 |
|
|
} |
294 |
|
|
|
295 |
|
|
void MockGraphics::calcImageRect(ImageVertexes *restrict const vert A_UNUSED, |
296 |
|
|
const int x A_UNUSED, |
297 |
|
|
const int y A_UNUSED, |
298 |
|
|
const int w A_UNUSED, |
299 |
|
|
const int h A_UNUSED, |
300 |
|
|
const ImageRect &restrict imgRect A_UNUSED) |
301 |
|
|
restrict2 |
302 |
|
|
{ |
303 |
|
|
} |