1// SuperTux
2// Copyright (C) 2018 Ingo Ruhnke <grumbel@gmail.com>
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_COMPOSITOR_HPP
18#define HEADER_SUPERTUX_VIDEO_COMPOSITOR_HPP
19
20#include <vector>
21#include <memory>
22
23#include "util/obstackpp.hpp"
24
25class DrawingContext;
26class Rect;
27class VideoSystem;
28
29class Compositor final
30{
31public:
32 /** Debug flag to disable lighting, used in the editor */
33 static bool s_render_lighting;
34
35public:
36 Compositor(VideoSystem& video_system);
37 ~Compositor();
38
39 void render();
40
41 /** Create a DrawingContext, if overlay is true the context will not
42 feature light rendering. This is required for contexts that
43 overlap with other context (e.g. the HUD in ScreenManager) as
44 otherwise their lighting would get messed up. */
45 DrawingContext& make_context(bool overlay = false);
46
47private:
48 VideoSystem& m_video_system;
49
50 /* obstack holding the memory of the drawing requests */
51 obstack m_obst;
52
53 std::vector<std::unique_ptr<DrawingContext> > m_drawing_contexts;
54
55private:
56 Compositor(const Compositor&) = delete;
57 Compositor& operator=(const Compositor&) = delete;
58};
59
60#endif
61
62/* EOF */
63