GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/unittests/render/mockgraphics.cc Lines: 13 50 26.0 %
Date: 2017-11-29 Branches: 0 2 0.0 %

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