| 1 | // SuperTux |
|---|---|
| 2 | // Copyright (C) 2006 Matthias Braun <matze@braunis.de> |
| 3 | // |
| 4 | // This program is free software: you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation, either version 3 of the License, or |
| 7 | // (at your option) any later version. |
| 8 | // |
| 9 | // This program is distributed in the hope that it will be useful, |
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | // GNU General Public License for more details. |
| 13 | // |
| 14 | // You should have received a copy of the GNU General Public License |
| 15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | |
| 17 | #ifndef HEADER_SUPERTUX_VIDEO_SDL_SDL_TEXTURE_RENDERER_HPP |
| 18 | #define HEADER_SUPERTUX_VIDEO_SDL_SDL_TEXTURE_RENDERER_HPP |
| 19 | |
| 20 | #include <SDL.h> |
| 21 | #include <boost/optional.hpp> |
| 22 | |
| 23 | #include "video/texture_ptr.hpp" |
| 24 | #include "video/renderer.hpp" |
| 25 | #include "video/sdl/sdl_painter.hpp" |
| 26 | |
| 27 | class Color; |
| 28 | class SDLTexture; |
| 29 | class SDLVideoSystem; |
| 30 | struct DrawingRequest; |
| 31 | struct SDL_Renderer; |
| 32 | struct SDL_Texture; |
| 33 | |
| 34 | class SDLTextureRenderer final : public Renderer |
| 35 | { |
| 36 | public: |
| 37 | SDLTextureRenderer(SDLVideoSystem& video_system, SDL_Renderer* renderer, const Size& size, int downscale); |
| 38 | ~SDLTextureRenderer(); |
| 39 | |
| 40 | virtual void start_draw() override; |
| 41 | virtual void end_draw() override; |
| 42 | |
| 43 | virtual SDLPainter& get_painter() override { return m_painter; } |
| 44 | |
| 45 | virtual Rect get_rect() const override; |
| 46 | virtual Size get_logical_size() const override; |
| 47 | |
| 48 | virtual TexturePtr get_texture() const override; |
| 49 | |
| 50 | private: |
| 51 | SDL_Texture* get_sdl_texture() const; |
| 52 | |
| 53 | private: |
| 54 | SDLVideoSystem& m_video_system; |
| 55 | SDL_Renderer* m_renderer; |
| 56 | SDLPainter m_painter; |
| 57 | Size m_size; |
| 58 | int m_downscale; |
| 59 | |
| 60 | TexturePtr m_texture; |
| 61 | |
| 62 | private: |
| 63 | SDLTextureRenderer(const SDLTextureRenderer&) = delete; |
| 64 | SDLTextureRenderer& operator=(const SDLTextureRenderer&) = delete; |
| 65 | }; |
| 66 | |
| 67 | #endif |
| 68 | |
| 69 | /* EOF */ |
| 70 |