GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/sdl2softwareimagehelper.h Lines: 0 6 0.0 %
Date: 2019-08-19 Branches: 0 4 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_SDL2SOFTWAREIMAGEHELPER_H
24
#define RESOURCES_SDL2SOFTWAREIMAGEHELPER_H
25
26
#ifdef USE_SDL2
27
28
#include "localconsts.h"
29
30
#include "resources/imagehelper.h"
31
32
class Dye;
33
class Image;
34
35
/**
36
 * Defines a class for loading and storing images.
37
 */
38
class SDL2SoftwareImageHelper final : public ImageHelper
39
{
40
    friend class Image;
41
42
    public:
43
        SDL2SoftwareImageHelper() :
44
            ImageHelper()
45
        { }
46
47
        A_DELETE_COPY(SDL2SoftwareImageHelper)
48
49
        /**
50
         * Loads an image from an SDL surface.
51
         */
52
        Image *loadSurface(SDL_Surface *const tmpImage) override final
53
                           A_WARN_UNUSED;
54
55
        Image *createTextSurface(SDL_Surface *const tmpImage,
56
                                 const int width, const int height,
57
                                 const float alpha)
58
                                 override final A_WARN_UNUSED;
59
60
        constexpr2 static void SDLSetEnableAlphaCache(const bool n) noexcept2
61
        { mEnableAlphaCache = n; }
62
63
        static bool SDLGetEnableAlphaCache() noexcept2 A_WARN_UNUSED
64
        { return mEnableAlphaCache; }
65
66
        static SDL_Surface* SDLDuplicateSurface(SDL_Surface *const tmpImage)
67
                                                A_WARN_UNUSED;
68
69
        static int combineSurface(SDL_Surface *restrict const src,
70
                                  SDL_Rect *restrict const srcrect,
71
                                  SDL_Surface *restrict const dst,
72
                                  SDL_Rect *restrict const dstrect);
73
74
        static void setFormat(SDL_PixelFormat *const format) noexcept2
75
        {
76
            mFormat = format;
77
            if (mFormat)
78
            {
79
                mFormat->Amask = ~(format->Rmask
80
                    | format->Gmask | format->Bmask);
81
            }
82
        }
83
84
    protected:
85
        /** SDL_Surface to SDL_Surface Image loader */
86
        Image *_SDLload(SDL_Surface *tmpImage) A_WARN_UNUSED;
87
88
        static bool mEnableAlphaCache;
89
        static SDL_PixelFormat *mFormat;
90
};
91
92
#endif  // USE_SDL2
93
#endif  // RESOURCES_SDL2SOFTWAREIMAGEHELPER_H