lsnes/include/core/framebuffer.hpp

106 lines
2.3 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"
2012-06-20 17:40:27 +03:00
#include "library/framebuffer.hpp"
2012-02-23 16:48:56 +02:00
#include <stdexcept>
/**
* Triple buffering logic.
*/
class triplebuffer_logic
{
public:
/**
* Create new triple buffer logic.
*/
triplebuffer_logic() throw(std::bad_alloc);
/**
* Destructor.
*/
~triplebuffer_logic() throw();
/**
* Get index for write buffer.Also starts write cycle.
*
* Returns: Write buffer index (0-2).
*/
unsigned start_write() throw();
/**
* Notify that write cycle has ended.
*/
void end_write() throw();
/**
* Get index for read buffer. Also starts read cycle.
*
* Returns: Read buffer index (0-2).
*/
unsigned start_read() throw();
/**
* Notify that read cycle has ended.
*/
void end_read() throw();
private:
triplebuffer_logic(triplebuffer_logic&);
triplebuffer_logic& operator=(triplebuffer_logic&);
mutex_class mut;
2012-02-23 16:48:56 +02:00
unsigned read_active;
unsigned write_active;
unsigned read_active_slot;
unsigned write_active_slot;
unsigned last_complete_slot;
};
2011-09-16 06:13:33 +03:00
2011-09-17 00:06:20 +03:00
/**
* The main framebuffer.
*/
2012-06-20 17:40:27 +03:00
extern framebuffer_raw main_framebuffer;
2011-09-17 00:06:20 +03:00
/**
* Special screen: "SYSTEM STATE CORRUPT".
*/
2012-06-20 17:40:27 +03:00
extern framebuffer_raw screen_corrupt;
2011-09-17 00:06:20 +03:00
/**
* The main screen to draw on.
*/
2012-06-20 17:40:27 +03:00
extern framebuffer<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.
*/
2011-09-16 06:13:33 +03:00
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.
*/
2012-06-20 17:40:27 +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
*/
void redraw_framebuffer();
2012-01-06 17:28:01 +02:00
/**
* Return last complete framebuffer.
*/
2012-06-20 17:40:27 +03:00
framebuffer_raw get_framebuffer() throw(std::bad_alloc);
2012-01-06 17:28:01 +02:00
/**
* Render framebuffer to main screen.
*/
void render_framebuffer();
/**
* Get the size of current framebuffer.
*/
std::pair<uint32_t, uint32_t> get_framebuffer_size();
/**
* Take a screenshot to specified file.
*/
void take_screenshot(const std::string& file) throw(std::bad_alloc, std::runtime_error);
/**
* Kill pending requests associated with object.
*/
void render_kill_request(void* obj);
/**
* Get latest screen received from core.
*/
framebuffer_raw& render_get_latest_screen();
2011-09-16 06:13:33 +03:00
2012-02-23 16:48:56 +02:00
#endif