GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/sdl2imagehelper.h Lines: 3 3 100.0 %
Date: 2019-08-19 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_SDL2IMAGEHELPER_H
24
#define RESOURCES_SDL2IMAGEHELPER_H
25
26
#ifdef USE_SDL2
27
28
#include "localconsts.h"
29
30
#include "resources/imagehelper.h"
31
32
PRAGMA48(GCC diagnostic push)
33
PRAGMA48(GCC diagnostic ignored "-Wshadow")
34
#include <SDL.h>
35
PRAGMA48(GCC diagnostic pop)
36
37
class Dye;
38
class Image;
39
40
/**
41
 * Defines a class for loading and storing images.
42
 */
43
213
class SDLImageHelper final : public ImageHelper
44
{
45
    friend class Image;
46
47
    public:
48
        SDLImageHelper() :
49
426
            ImageHelper()
50
        { }
51
52
        A_DELETE_COPY(SDLImageHelper)
53
54
        /**
55
         * Loads an image from an SDL surface.
56
         */
57
        Image *loadSurface(SDL_Surface *const tmpImage) override final
58
                           A_WARN_UNUSED;
59
60
        Image *createTextSurface(SDL_Surface *const tmpImage,
61
                                 const int width, const int height,
62
                                 const float alpha)
63
                                 override final A_WARN_UNUSED;
64
65
        void copySurfaceToImage(const Image *const image,
66
                                const int x, const int y,
67
                                SDL_Surface *const surface)
68
                                const override final;
69
70
        constexpr2 static void SDLSetEnableAlphaCache(const bool n) noexcept2
71
        { mEnableAlphaCache = n; }
72
73
        static bool SDLGetEnableAlphaCache() noexcept2 A_WARN_UNUSED
74
        { return mEnableAlphaCache; }
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
        constexpr2 static void setRenderer(SDL_Renderer *const renderer)
85
                                          noexcept2
86
311
        { mRenderer = renderer; }
87
88
    protected:
89
        /** SDL_Surface to SDL_Surface Image loader */
90
        Image *_SDLload(SDL_Surface *tmpImage) A_WARN_UNUSED;
91
92
        static bool mEnableAlphaCache;
93
        static SDL_Renderer *mRenderer;
94
};
95
96
#endif  // USE_SDL2
97
#endif  // RESOURCES_SDL2IMAGEHELPER_H