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