Debian Codegraph @

engine/core/video/sdl/sdlimage.h

raw
1 /***************************************************************************
2 * Copyright (C) 2005-2019 by the FIFE team *
3 * http://www.fifengine.net *
4 * This file is part of FIFE. *
5 * *
6 * FIFE is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Lesser General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2.1 of the License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Lesser General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
21
22 #ifndef FIFE_VIDEO_RENDERBACKENDS_SDL_SDLIMAGE_H
23 #define FIFE_VIDEO_RENDERBACKENDS_SDL_SDLIMAGE_H
24
25 // Standard C++ library includes
26
27 // 3rd party library includes
28 #include <SDL_video.h>
29
30 // FIFE includes
31 // These includes are split up in two parts, separated by one empty line
32 // First block: files included from the FIFE root src directory
33 // Second block: files included from the same folder
34 #include "video/image.h"
35
36 namespace FIFE {
37
38 /** The SDL implementation of the @c Image base class.
39 */
40 class SDLImage : public Image {
41 public:
42 SDLImage(IResourceLoader* loader = 0);
43 SDLImage(const std::string& name, IResourceLoader* loader = 0);
44 SDLImage(SDL_Surface* surface);
45 SDLImage(const std::string& name, SDL_Surface* surface);
46 SDLImage(const uint8_t* data, uint32_t width, uint32_t height);
47 SDLImage(const std::string& name, const uint8_t* data, uint32_t width, uint32_t height);
48
49 virtual ~SDLImage();
50 virtual void invalidate();
51 virtual void setSurface(SDL_Surface* surface);
52 virtual void render(const Rect& rect, uint8_t alpha = 255, uint8_t const* rgb = 0);
53 virtual size_t getSize();
54 virtual void useSharedImage(const ImagePtr& shared, const Rect& region);
55 virtual void forceLoadInternal();
56 virtual void load();
57 virtual void free();
58
59 SDL_Texture* getTexture();
60 void setTexture(SDL_Texture* texture);
61
62 private:
63 void resetSdlimage();
64 void validateShared();
65
66 // colorkey for the image
67 SDL_Color m_colorkey;
68 // texture of image
69 SDL_Texture* m_texture;
70
71 // Holds Atlas ImagePtr if this is a shared image
72 ImagePtr m_atlas_img;
73 // Holds Atlas Name if this is a shared image
74 std::string m_atlas_name;
75 };
76
77 }
78
79 #endif