GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/surfaceimagehelper.h Lines: 2 5 40.0 %
Date: 2019-10-12 Branches: 0 0 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-2019  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
#ifndef RESOURCES_SURFACEIMAGEHELPER_H
24
#define RESOURCES_SURFACEIMAGEHELPER_H
25
26
#ifndef USE_SDL2
27
#include "resources/sdlimagehelper.h"
28
RESOURCES_SDLIMAGEHELPER_H
29
30
#else
31
32
#include "localconsts.h"
33
34
#include "resources/imagehelper.h"
35
36
class Dye;
37
class Image;
38
39
/**
40
 * Defines a class for loading and storing images.
41
 */
42
21
class SurfaceImageHelper final : public ImageHelper
43
{
44
    friend class Image;
45
46
    public:
47
        SurfaceImageHelper()
48
42
        { }
49
50
        A_DELETE_COPY(SurfaceImageHelper)
51
52
        /**
53
         * Loads an image from an SDL surface.
54
         */
55
        Image *loadSurface(SDL_Surface *const tmpImage) override final
56
                           A_WARN_UNUSED;
57
58
        Image *createTextSurface(SDL_Surface *const tmpImage,
59
                                 const int width, const int height,
60
                                 const float alpha)
61
                                 override final A_WARN_UNUSED;
62
63
        constexpr2 static void SDLSetEnableAlphaCache(const bool n) noexcept2
64
        { mEnableAlphaCache = n; }
65
66
        static bool SDLGetEnableAlphaCache() noexcept2 A_WARN_UNUSED
67
        { return mEnableAlphaCache; }
68
69
         /**
70
         * Tells if the image was loaded using OpenGL or SDL
71
         * @return true if OpenGL, false if SDL.
72
         */
73
        RenderType useOpenGL() const noexcept2 override final A_WARN_UNUSED
74
        { return RENDER_SOFTWARE; }
75
76
        static SDL_Surface* SDLDuplicateSurface(SDL_Surface *const tmpImage)
77
                                                A_WARN_UNUSED;
78
79
        static int combineSurface(SDL_Surface *restrict const src,
80
                                  SDL_Rect *restrict const srcrect,
81
                                  SDL_Surface *restrict const dst,
82
                                  SDL_Rect *restrict const dstrect);
83
84
    protected:
85
        /** SDL_Surface to SDL_Surface Image loader */
86
        Image *_SDLload(SDL_Surface *tmpImage) const A_WARN_UNUSED;
87
88
        static bool mEnableAlphaCache;
89
};
90
91
#endif  // USE_SDL2
92
#endif  // RESOURCES_SURFACEIMAGEHELPER_H