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 |
|
|
* Copyright (C) 2019-2021 Andrei Karas |
7 |
|
|
* |
8 |
|
|
* This file is part of The ManaPlus Client. |
9 |
|
|
* |
10 |
|
|
* This program is free software; you can redistribute it and/or modify |
11 |
|
|
* it under the terms of the GNU General Public License as published by |
12 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
13 |
|
|
* any later version. |
14 |
|
|
* |
15 |
|
|
* This program is distributed in the hope that it will be useful, |
16 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
|
|
* GNU General Public License for more details. |
19 |
|
|
* |
20 |
|
|
* You should have received a copy of the GNU General Public License |
21 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 |
|
|
*/ |
23 |
|
|
|
24 |
|
|
#ifndef RESOURCES_SDL2SOFTWAREIMAGEHELPER_H |
25 |
|
|
#define RESOURCES_SDL2SOFTWAREIMAGEHELPER_H |
26 |
|
|
|
27 |
|
|
#ifdef USE_SDL2 |
28 |
|
|
|
29 |
|
|
#include "localconsts.h" |
30 |
|
|
|
31 |
|
|
#include "resources/imagehelper.h" |
32 |
|
|
|
33 |
|
|
class Dye; |
34 |
|
|
class Image; |
35 |
|
|
|
36 |
|
|
/** |
37 |
|
|
* Defines a class for loading and storing images. |
38 |
|
|
*/ |
39 |
|
|
class SDL2SoftwareImageHelper final : public ImageHelper |
40 |
|
|
{ |
41 |
|
|
friend class Image; |
42 |
|
|
|
43 |
|
|
public: |
44 |
|
|
SDL2SoftwareImageHelper() : |
45 |
|
|
ImageHelper() |
46 |
|
|
{ } |
47 |
|
|
|
48 |
|
|
A_DELETE_COPY(SDL2SoftwareImageHelper) |
49 |
|
|
|
50 |
|
|
/** |
51 |
|
|
* Loads an image from an SDL surface. |
52 |
|
|
*/ |
53 |
|
|
Image *loadSurface(SDL_Surface *const tmpImage) override final |
54 |
|
|
A_WARN_UNUSED; |
55 |
|
|
|
56 |
|
|
Image *createTextSurface(SDL_Surface *const tmpImage, |
57 |
|
|
const int width, const int height, |
58 |
|
|
const float alpha) |
59 |
|
|
override final A_WARN_UNUSED; |
60 |
|
|
|
61 |
|
|
constexpr2 static void SDLSetEnableAlphaCache(const bool n) noexcept2 |
62 |
|
|
{ mEnableAlphaCache = n; } |
63 |
|
|
|
64 |
|
|
static bool SDLGetEnableAlphaCache() noexcept2 A_WARN_UNUSED |
65 |
|
|
{ return mEnableAlphaCache; } |
66 |
|
|
|
67 |
|
|
static SDL_Surface* SDLDuplicateSurface(SDL_Surface *const tmpImage) |
68 |
|
|
A_WARN_UNUSED; |
69 |
|
|
|
70 |
|
|
static int combineSurface(SDL_Surface *restrict const src, |
71 |
|
|
SDL_Rect *restrict const srcrect, |
72 |
|
|
SDL_Surface *restrict const dst, |
73 |
|
|
SDL_Rect *restrict const dstrect); |
74 |
|
|
|
75 |
|
|
static void setFormat(SDL_PixelFormat *const format) noexcept2 |
76 |
|
|
{ |
77 |
|
|
mFormat = format; |
78 |
|
|
if (mFormat) |
79 |
|
|
{ |
80 |
|
|
mFormat->Amask = ~(format->Rmask |
81 |
|
|
| format->Gmask | format->Bmask); |
82 |
|
|
} |
83 |
|
|
} |
84 |
|
|
|
85 |
|
|
protected: |
86 |
|
|
/** SDL_Surface to SDL_Surface Image loader */ |
87 |
|
|
Image *_SDLload(SDL_Surface *tmpImage) A_WARN_UNUSED; |
88 |
|
|
|
89 |
|
|
static bool mEnableAlphaCache; |
90 |
|
|
static SDL_PixelFormat *mFormat; |
91 |
|
|
}; |
92 |
|
|
|
93 |
|
|
#endif // USE_SDL2 |
94 |
|
|
#endif // RESOURCES_SDL2SOFTWAREIMAGEHELPER_H |