Memory tracker: Add tracking of render objects
[lsnes.git] / include / core / framebuffer.hpp
blob9bfbbc9e09c59e8e4a5be105e9f29cd0b37cdf14
1 #ifndef _framebuffer__hpp__included__
2 #define _framebuffer__hpp__included__
4 #include "core/window.hpp"
5 #include "library/command.hpp"
6 #include "library/framebuffer.hpp"
7 #include "library/triplebuffer.hpp"
9 #include <stdexcept>
11 class subtitle_commentary;
12 class memwatch_set;
13 class emulator_dispatch;
14 class lua_state;
15 class loaded_rom;
16 class status_updater;
17 namespace settingvar
19 class group;
21 namespace keyboard
23 class keyboard;
26 /**
27 * Emulator frame buffer.
29 class emu_framebuffer
31 public:
32 emu_framebuffer(subtitle_commentary& _subtitles, settingvar::group& _settings, memwatch_set& _mwatch,
33 keyboard::keyboard& _keyboard, emulator_dispatch& _dispatch, lua_state& _lua2, loaded_rom& _rom,
34 status_updater& _supdater, command::group& _cmd);
35 /**
36 * The main framebuffer.
38 framebuffer::raw main_framebuffer;
39 /**
40 * Special screen: "SYSTEM STATE CORRUPT".
42 static framebuffer::raw screen_corrupt;
43 /**
44 * The main screen to draw on.
46 framebuffer::fb<false> main_screen;
47 /**
48 * Initialize special screens.
50 * throws std::bad_alloc: Not enough memory.
52 static void init_special_screens() throw(std::bad_alloc);
53 /**
54 * Copy framebuffer to backing store, running Lua hooks if any.
56 void redraw_framebuffer(framebuffer::raw& torender, bool no_lua = false, bool spontaneous = false);
57 /**
58 * Redraw the framebuffer, reusing contents from last redraw. Runs lua hooks if last redraw ran them.
60 void redraw_framebuffer();
61 /**
62 * Return last complete framebuffer.
64 framebuffer::raw get_framebuffer() throw(std::bad_alloc);
65 /**
66 * Render framebuffer to main screen.
68 void render_framebuffer();
69 /**
70 * Get the size of current framebuffer.
72 std::pair<uint32_t, uint32_t> get_framebuffer_size();
73 /**
74 * Take a screenshot to specified file.
76 void take_screenshot(const std::string& file) throw(std::bad_alloc, std::runtime_error);
77 /**
78 * Kill pending requests associated with object.
80 void render_kill_request(void* obj);
81 /**
82 * Get latest screen received from core.
84 framebuffer::raw& render_get_latest_screen();
85 void render_get_latest_screen_end();
86 private:
87 void do_screenshot(command::arg_filename a);
88 struct render_info
90 render_info();
91 framebuffer::raw fbuf;
92 framebuffer::queue rq;
93 uint32_t hscl;
94 uint32_t vscl;
95 uint32_t lgap;
96 uint32_t rgap;
97 uint32_t tgap;
98 uint32_t bgap;
100 render_info buffer1;
101 render_info buffer2;
102 render_info buffer3;
103 triplebuffer::triplebuffer<render_info> buffering;
104 bool last_redraw_no_lua;
105 subtitle_commentary& subtitles;
106 settingvar::group& settings;
107 memwatch_set& mwatch;
108 keyboard::keyboard& keyboard;
109 emulator_dispatch& edispatch;
110 lua_state& lua2;
111 loaded_rom& rom;
112 status_updater& supdater;
113 command::group& cmd;
114 command::_fnptr<command::arg_filename> screenshot;
117 #endif