GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/sdlimagehelper.h Lines: 3 4 75.0 %
Date: 2017-11-29 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-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
#ifndef RESOURCES_SDLIMAGEHELPER_H
24
#define RESOURCES_SDLIMAGEHELPER_H
25
26
#ifdef USE_SDL2
27
#include "resources/sdl2imagehelper.h"
28
RESOURCES_SDL2IMAGEHELPER_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
class SDLImageHelper final : public ImageHelper
43
{
44
    friend class Image;
45
46
    public:
47
        SDLImageHelper() :
48
888
            ImageHelper()
49
        { }
50
51
        A_DELETE_COPY(SDLImageHelper)
52
53
444
        ~SDLImageHelper()
54
444
        { }
55
56
        /**
57
         * Loads an image from an SDL_RWops structure and recolors it.
58
         *
59
         * @param rw         The SDL_RWops to load the image from.
60
         * @param dye        The dye used to recolor the image.
61
         *
62
         * @return <code>NULL</code> if an error occurred, a valid pointer
63
         *         otherwise.
64
         */
65
        Image *load(SDL_RWops *const rw,
66
                    Dye const &dye) override final A_WARN_UNUSED;
67
68
        /**
69
         * Loads an image from an SDL surface.
70
         */
71
        Image *loadSurface(SDL_Surface *const tmpImage) override final
72
                           A_WARN_UNUSED;
73
74
        Image *createTextSurface(SDL_Surface *const tmpImage,
75
                                 const int width, const int height,
76
                                 const float alpha)
77
                                 override final A_WARN_UNUSED;
78
79
        void copySurfaceToImage(const Image *const image,
80
                                const int x, const int y,
81
                                SDL_Surface *const surface)
82
                                const override final;
83
84
        constexpr2 static void SDLSetEnableAlphaCache(const bool n) noexcept2
85
        { mEnableAlphaCache = n; }
86
87
        static bool SDLGetEnableAlphaCache() noexcept2 A_WARN_UNUSED
88
        { return mEnableAlphaCache; }
89
90
        static SDL_Surface* SDLDuplicateSurface(SDL_Surface *const tmpImage)
91
                                                A_WARN_UNUSED;
92
93
        static int combineSurface(SDL_Surface *restrict const src,
94
                                  SDL_Rect *restrict const srcrect,
95
                                  SDL_Surface *restrict const dst,
96
                                  SDL_Rect *restrict const dstrect);
97
98
    protected:
99
        /** SDL_Surface to SDL_Surface Image loader */
100
        Image *_SDLload(SDL_Surface *tmpImage) A_WARN_UNUSED;
101
102
        static bool mEnableAlphaCache;
103
};
104
105
#endif  // USE_SDL2
106
#endif  // RESOURCES_SDLIMAGEHELPER_H