lsnes/include/core/framebuffer.hpp

117 lines
2.7 KiB
C++
Raw Normal View History

2011-09-16 06:13:33 +03:00
#ifndef _framebuffer__hpp__included__
#define _framebuffer__hpp__included__
2012-02-23 16:48:56 +02:00
#include "core/window.hpp"
#include "library/command.hpp"
2012-06-20 17:40:27 +03:00
#include "library/framebuffer.hpp"
2014-05-23 20:14:12 +03:00
#include "library/triplebuffer.hpp"
2012-02-23 16:48:56 +02:00
#include <stdexcept>
class subtitle_commentary;
class memwatch_set;
2014-05-31 13:58:17 +03:00
class emulator_dispatch;
class lua_state;
2014-06-08 04:15:01 +03:00
class loaded_rom;
class status_updater;
namespace settingvar
{
class group;
}
namespace keyboard
{
class keyboard;
}
2014-05-23 20:14:12 +03:00
/**
* Emulator frame buffer.
*/
class emu_framebuffer
{
public:
emu_framebuffer(subtitle_commentary& _subtitles, settingvar::group& _settings, memwatch_set& _mwatch,
keyboard::keyboard& _keyboard, emulator_dispatch& _dispatch, lua_state& _lua2, loaded_rom& _rom,
status_updater& _supdater, command::group& _cmd);
2011-09-17 00:06:20 +03:00
/**
* The main framebuffer.
*/
2014-05-23 20:14:12 +03:00
framebuffer::raw main_framebuffer;
2011-09-17 00:06:20 +03:00
/**
* Special screen: "SYSTEM STATE CORRUPT".
*/
2014-05-23 20:14:12 +03:00
static framebuffer::raw screen_corrupt;
2011-09-17 00:06:20 +03:00
/**
* The main screen to draw on.
*/
2014-05-23 20:14:12 +03:00
framebuffer::fb<false> main_screen;
2011-09-17 00:06:20 +03:00
/**
* Initialize special screens.
2011-09-26 19:02:43 +03:00
*
2011-09-17 00:06:20 +03:00
* throws std::bad_alloc: Not enough memory.
*/
2014-05-23 20:14:12 +03:00
static void init_special_screens() throw(std::bad_alloc);
2011-09-17 00:06:20 +03:00
/**
2012-01-06 17:28:01 +02:00
* Copy framebuffer to backing store, running Lua hooks if any.
*/
2014-05-23 20:14:12 +03:00
void redraw_framebuffer(framebuffer::raw& torender, bool no_lua = false, bool spontaneous = false);
2012-01-06 17:28:01 +02:00
/**
* Redraw the framebuffer, reusing contents from last redraw. Runs lua hooks if last redraw ran them.
2011-09-17 00:06:20 +03:00
*/
2014-05-23 20:14:12 +03:00
void redraw_framebuffer();
2012-01-06 17:28:01 +02:00
/**
* Return last complete framebuffer.
*/
2014-05-23 20:14:12 +03:00
framebuffer::raw get_framebuffer() throw(std::bad_alloc);
2012-01-06 17:28:01 +02:00
/**
* Render framebuffer to main screen.
*/
2014-05-23 20:14:12 +03:00
void render_framebuffer();
2012-01-06 17:28:01 +02:00
/**
* Get the size of current framebuffer.
*/
2014-05-23 20:14:12 +03:00
std::pair<uint32_t, uint32_t> get_framebuffer_size();
2012-01-06 17:28:01 +02:00
/**
* Take a screenshot to specified file.
*/
2014-05-23 20:14:12 +03:00
void take_screenshot(const std::string& file) throw(std::bad_alloc, std::runtime_error);
/**
* Kill pending requests associated with object.
*/
2014-05-23 20:14:12 +03:00
void render_kill_request(void* obj);
/**
* Get latest screen received from core.
*/
2014-05-23 20:14:12 +03:00
framebuffer::raw& render_get_latest_screen();
void render_get_latest_screen_end();
private:
void do_screenshot(command::arg_filename a);
2014-05-23 20:14:12 +03:00
struct render_info
{
framebuffer::raw fbuf;
framebuffer::queue rq;
uint32_t hscl;
uint32_t vscl;
uint32_t lgap;
uint32_t rgap;
uint32_t tgap;
uint32_t bgap;
};
render_info buffer1;
render_info buffer2;
render_info buffer3;
triplebuffer::triplebuffer<render_info> buffering;
bool last_redraw_no_lua;
subtitle_commentary& subtitles;
settingvar::group& settings;
memwatch_set& mwatch;
keyboard::keyboard& keyboard;
2014-05-31 13:58:17 +03:00
emulator_dispatch& edispatch;
lua_state& lua2;
2014-06-08 04:15:01 +03:00
loaded_rom& rom;
status_updater& supdater;
command::group& cmd;
command::_fnptr<command::arg_filename> screenshot;
2014-05-23 20:14:12 +03:00
};
2011-09-16 06:13:33 +03:00
2012-02-23 16:48:56 +02:00
#endif