Refactor library framebuffer to dedicated namespace

This commit is contained in:
Ilari Liusvaara 2013-12-19 06:57:22 +02:00
parent 4a58db3c25
commit dce933b76d
59 changed files with 449 additions and 443 deletions

View file

@ -118,9 +118,9 @@ private:
* Parameter fn: Function to call between running lua hooks and actually rendering.
* Returns: True if frame should be dumped, false if not.
*/
template<bool X> bool render_video_hud(struct framebuffer<X>& target, struct framebuffer_raw& source, uint32_t hscl,
uint32_t vscl, uint32_t roffset, uint32_t goffset, uint32_t boffset, uint32_t lgap, uint32_t tgap,
uint32_t rgap, uint32_t bgap, void(*fn)());
template<bool X> bool render_video_hud(struct framebuffer::fb<X>& target, struct framebuffer::raw& source,
uint32_t hscl, uint32_t vscl, uint32_t roffset, uint32_t goffset, uint32_t boffset, uint32_t lgap,
uint32_t tgap, uint32_t rgap, uint32_t bgap, void(*fn)());
/**
* Calculate number of sound samples to drop due to dropped frame.

View file

@ -110,13 +110,13 @@ public:
* Parameter fps_n: Numerator of current video fps.
* Parameter fps_d: Denominator of current video fps.
*/
virtual void on_frame(struct framebuffer_raw& _frame, uint32_t fps_n, uint32_t fps_d);
virtual void on_frame(struct framebuffer::raw& _frame, uint32_t fps_n, uint32_t fps_d);
/**
* Call all on_frame() handlers.
*
* Calls on_new_dumper() on dumpers that had that not yet called.
*/
static void do_frame(struct framebuffer_raw& _frame, uint32_t fps_n, uint32_t fps_d) throw();
static void do_frame(struct framebuffer::raw& _frame, uint32_t fps_n, uint32_t fps_d) throw();
/**
* A sample has been received.
*
@ -258,7 +258,7 @@ extern struct dispatch::source<> notify_autohold_reconfigure;
extern struct dispatch::source<unsigned, unsigned, unsigned, bool> notify_autohold_update;
extern struct dispatch::source<unsigned, unsigned, unsigned, unsigned, unsigned> notify_autofire_update;
extern struct dispatch::source<> notify_close;
extern struct dispatch::source<framebuffer<false>&> notify_set_screen;
extern struct dispatch::source<framebuffer::fb<false>&> notify_set_screen;
extern struct dispatch::source<std::pair<std::string, std::string>> notify_sound_change;
extern struct dispatch::source<> notify_screen_update;
extern struct dispatch::source<> notify_status_update;

View file

@ -54,15 +54,15 @@ private:
/**
* The main framebuffer.
*/
extern framebuffer_raw main_framebuffer;
extern framebuffer::raw main_framebuffer;
/**
* Special screen: "SYSTEM STATE CORRUPT".
*/
extern framebuffer_raw screen_corrupt;
extern framebuffer::raw screen_corrupt;
/**
* The main screen to draw on.
*/
extern framebuffer<false> main_screen;
extern framebuffer::fb<false> main_screen;
/**
* Initialize special screens.
*
@ -72,7 +72,7 @@ void init_special_screens() throw(std::bad_alloc);
/**
* Copy framebuffer to backing store, running Lua hooks if any.
*/
void redraw_framebuffer(framebuffer_raw& torender, bool no_lua = false, bool spontaneous = false);
void redraw_framebuffer(framebuffer::raw& torender, bool no_lua = false, bool spontaneous = false);
/**
* Redraw the framebuffer, reusing contents from last redraw. Runs lua hooks if last redraw ran them.
*/
@ -80,7 +80,7 @@ void redraw_framebuffer();
/**
* Return last complete framebuffer.
*/
framebuffer_raw get_framebuffer() throw(std::bad_alloc);
framebuffer::raw get_framebuffer() throw(std::bad_alloc);
/**
* Render framebuffer to main screen.
*/
@ -100,7 +100,7 @@ void render_kill_request(void* obj);
/**
* Get latest screen received from core.
*/
framebuffer_raw& render_get_latest_screen();
framebuffer::raw& render_get_latest_screen();
void render_get_latest_screen_end();
#endif

View file

@ -3,7 +3,7 @@
#include "library/framebuffer.hpp"
extern bitmap_font main_font;
extern framebuffer::font main_font;
void do_init_font();

View file

@ -50,7 +50,7 @@ public:
/**
* Output a frame. Call once for each call to emulate().
*/
virtual void output_frame(framebuffer_raw& screen, uint32_t fps_n, uint32_t fps_d) = 0;
virtual void output_frame(framebuffer::raw& screen, uint32_t fps_n, uint32_t fps_d) = 0;
/**
* Notify that action states have been updated.
*/

View file

@ -318,7 +318,7 @@ struct core_core
void runtosave();
bool get_pflag();
void set_pflag(bool pflag);
framebuffer_raw& draw_cover();
framebuffer::raw& draw_cover();
std::vector<port_type*> get_port_types() { return port_types; }
std::string get_core_shortname();
void pre_emulate_frame(controller_frame& cf);
@ -435,7 +435,7 @@ protected:
*
* Should display information about the ROM loaded.
*/
virtual framebuffer_raw& c_draw_cover() = 0;
virtual framebuffer::raw& c_draw_cover() = 0;
/**
* Get shortened name of the core.
*/
@ -572,7 +572,7 @@ public:
void runtosave() { core->runtosave(); }
bool get_pflag() { return core->get_pflag(); }
void set_pflag(bool pflag) { core->set_pflag(pflag); }
framebuffer_raw& draw_cover() { return core->draw_cover(); }
framebuffer::raw& draw_cover() { return core->draw_cover(); }
std::string get_systemmenu_name() { return sysname; }
void execute_action(unsigned id, const std::vector<interface_action_paramval>& p)
{

View file

@ -17,10 +17,10 @@ struct font_glyph_data
unsigned height;
unsigned stride;
std::vector<uint32_t> glyph; //Bitpacked, element breaks between rows.
void render(framebuffer<false>& fb, int32_t x, int32_t y, premultiplied_color fg, premultiplied_color bg,
premultiplied_color hl) const;
void render(framebuffer<true>& fb, int32_t x, int32_t y, premultiplied_color fg, premultiplied_color bg,
premultiplied_color hl) const;
void render(framebuffer::fb<false>& fb, int32_t x, int32_t y, framebuffer::color fg, framebuffer::color bg,
framebuffer::color hl) const;
void render(framebuffer::fb<true>& fb, int32_t x, int32_t y, framebuffer::color fg, framebuffer::color bg,
framebuffer::color hl) const;
};
struct custom_font
@ -28,7 +28,7 @@ struct custom_font
public:
custom_font();
custom_font(const std::string& file);
custom_font(struct bitmap_font& bfont);
custom_font(struct framebuffer::font& bfont);
void add(const std::u32string& key, const font_glyph_data& glyph) throw(std::bad_alloc);
std::u32string best_ligature_match(const std::u32string& codepoints, size_t start) const
throw(std::bad_alloc);

View file

@ -7,17 +7,19 @@
#include <map>
#include <set>
template<bool X> struct framebufferelem {};
template<> struct framebufferelem<false> { typedef uint32_t t; };
template<> struct framebufferelem<true> { typedef uint64_t t; };
namespace framebuffer
{
template<bool X> struct elem {};
template<> struct elem<false> { typedef uint32_t t; };
template<> struct elem<true> { typedef uint64_t t; };
/**
* Pixel format auxillary palette.
*/
template<bool X>
struct pixel_format_aux_palette
struct auxpalette
{
typedef typename framebufferelem<X>::t element_t;
typedef typename elem<X>::t element_t;
uint8_t rshift; //Red shift.
uint8_t gshift; //Green shift.
uint8_t bshift; //Blue shift.
@ -27,14 +29,14 @@ struct pixel_format_aux_palette
/**
* Pixel format.
*/
class pixel_format
class pixfmt
{
public:
virtual ~pixel_format() throw();
virtual ~pixfmt() throw();
/**
* Register the pixel format.
*/
pixel_format() throw(std::bad_alloc);
pixfmt() throw(std::bad_alloc);
/**
* Decode pixel format data into RGB data (0, R, G, B).
*/
@ -44,21 +46,21 @@ public:
* Decode pixel format data into RGB (with specified byte order).
*/
virtual void decode(uint32_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<false>& auxp) throw() = 0;
const auxpalette<false>& auxp) throw() = 0;
/**
* Decode pixel format data into RGB (with specified byte order).
*/
virtual void decode(uint64_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<true>& auxp) throw() = 0;
const auxpalette<true>& auxp) throw() = 0;
/**
* Create aux palette.
*/
virtual void set_palette(pixel_format_aux_palette<false>& auxp, uint8_t rshift, uint8_t gshift,
virtual void set_palette(auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc) = 0;
/**
* Create aux palette.
*/
virtual void set_palette(pixel_format_aux_palette<true>& auxp, uint8_t rshift, uint8_t gshift,
virtual void set_palette(auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc) = 0;
/**
* Bytes per pixel in data.
@ -77,12 +79,12 @@ public:
/**
* Game framebuffer information.
*/
struct framebuffer_info
struct info
{
/**
* Pixel format of framebuffer.
*/
pixel_format* type;
pixfmt* type;
/**
* The physical memory backing the framebuffer.
*/
@ -130,7 +132,7 @@ template<bool X> struct framebuffer;
*
* Any copying only preserves the visible part.
*/
struct framebuffer_raw
struct raw
{
/**
* Create a new framebuffer backed by temporary buffer.
@ -139,13 +141,13 @@ struct framebuffer_raw
*
* Parameter info: The framebuffer info.
*/
framebuffer_raw(const framebuffer_info& info) throw(std::bad_alloc);
raw(const info& finfo) throw(std::bad_alloc);
/**
* Create a new framebuffer backed by memory buffer.
*
* The resulting framebuffer can be written to.
*/
framebuffer_raw() throw(std::bad_alloc);
raw() throw(std::bad_alloc);
/**
* Copy a framebuffer.
*
@ -153,14 +155,14 @@ struct framebuffer_raw
*
* Parameter f: The framebuffer.
*/
framebuffer_raw(const framebuffer_raw& f) throw(std::bad_alloc);
raw(const raw& f) throw(std::bad_alloc);
/**
* Assign a framebuffer.
*
* Parameter f: The framebuffer.
* Throws std::runtime_error: The target framebuffer is not writable.
*/
framebuffer_raw& operator=(const framebuffer_raw& f) throw(std::bad_alloc, std::runtime_error);
raw& operator=(const raw& f) throw(std::bad_alloc, std::runtime_error);
/**
* Load contents of framebuffer.
*
@ -204,24 +206,24 @@ struct framebuffer_raw
/**
* Get pixel format.
*/
pixel_format* get_format() const throw();
pixfmt* get_format() const throw();
/**
* Destructor.
*/
~framebuffer_raw();
~raw();
private:
bool user_memory; //True if allocated in user memory, false if aliases framebuffer.
char* addr; //Address of framebuffer start.
pixel_format* fmt; //Format of framebuffer.
pixfmt* fmt; //Format of framebuffer.
size_t width; //Width of framebuffer.
size_t height; //Height of framebuffer.
size_t stride; //Stride in pixels.
size_t allocated; //Amount of memory allocated (only meaningful if user_memory=true).
template<bool X> friend class framebuffer;
template<bool X> friend class fb;
};
struct premultiplied_color;
struct color;
/**
* Rendered framebuffer.
@ -229,18 +231,18 @@ struct premultiplied_color;
* This framebuffer is in RGB32/RGB64 format, and is always backed by memory buffer.
*/
template<bool X>
struct framebuffer
struct fb
{
typedef typename framebufferelem<X>::t element_t;
typedef typename elem<X>::t element_t;
/**
* Creates framebuffer. The framebuffer dimensions are initially 0x0.
*/
framebuffer() throw();
fb() throw();
/**
* Destructor.
*/
~framebuffer() throw();
~fb() throw();
/**
* Sets the backing memory for framebuffer. The specified memory is not freed if framebuffer is reallocated or
@ -292,7 +294,7 @@ struct framebuffer
* parameter hscale Horizontal scale factor.
* parameter vscale Vertical scale factor.
*/
void copy_from(framebuffer_raw& scr, size_t hscale, size_t vscale) throw();
void copy_from(raw& scr, size_t hscale, size_t vscale) throw();
/**
* Get pointer into specified row.
@ -353,8 +355,8 @@ struct framebuffer
*/
uint8_t get_palette_b() const throw();
private:
framebuffer(const framebuffer& f);
framebuffer& operator=(const framebuffer& f);
fb(const fb& f);
fb& operator=(const fb& f);
size_t width; //Width of framebuffer.
size_t height; //Height of framebuffer.
size_t stride; //Stride in pixels.
@ -363,31 +365,31 @@ private:
size_t last_blit_w; //Width of last blit.
size_t last_blit_h; //Height of last blit.
element_t* mem; //The memory of framebuffer.
pixel_format* current_fmt; //Current format of framebuffer.
pixel_format_aux_palette<X> auxpal; //Aux palette.
pixfmt* current_fmt; //Current format of framebuffer.
auxpalette<X> auxpal; //Aux palette.
bool user_mem; //True if internal memory is used.
bool upside_down; //Upside down flag.
uint8_t active_rshift; //Red shift.
uint8_t active_gshift; //Green shift.
uint8_t active_bshift; //Blue shift.
friend struct premultiplied_color;
friend struct color;
};
struct render_queue;
struct queue;
/**
* Base class for objects to render.
*/
struct render_object
struct object
{
/**
* Constructor.
*/
render_object() throw();
object() throw();
/**
* Destructor.
*/
virtual ~render_object() throw();
virtual ~object() throw();
/**
* Kill object function. If it returns true, kill the request. Default is to return false.
*/
@ -401,18 +403,18 @@ struct render_object
*
* parameter scr: The screen to draw it on.
*/
virtual void operator()(struct framebuffer<false>& scr) throw() = 0;
virtual void operator()(struct framebuffer<true>& scr) throw() = 0;
virtual void operator()(struct fb<false>& scr) throw() = 0;
virtual void operator()(struct fb<true>& scr) throw() = 0;
/**
* Clone the object.
*/
virtual void clone(struct render_queue& q) const throw(std::bad_alloc) = 0;
virtual void clone(struct queue& q) const throw(std::bad_alloc) = 0;
};
/**
* Premultiplied color.
*/
struct premultiplied_color
struct color
{
uint32_t hi;
uint32_t lo;
@ -426,7 +428,7 @@ struct premultiplied_color
operator bool() const throw() { return (origa != 0); }
bool operator!() const throw() { return (origa == 0); }
premultiplied_color() throw()
color() throw()
{
hi = lo = 0;
hiHI = loHI = 0;
@ -436,7 +438,7 @@ struct premultiplied_color
invHI = 65536;
}
premultiplied_color(int64_t color) throw()
color(int64_t color) throw()
{
if(color < 0) {
//Transparent.
@ -454,7 +456,7 @@ struct premultiplied_color
//std::cerr << "Color " << color << " -> hi=" << hi << " lo=" << lo << " inv=" << inv << std::endl;
}
void set_palette(unsigned rshift, unsigned gshift, unsigned bshift, bool X) throw();
template<bool X> void set_palette(struct framebuffer<X>& s) throw()
template<bool X> void set_palette(struct fb<X>& s) throw()
{
set_palette(s.active_rshift, s.active_gshift, s.active_bshift, X);
}
@ -474,7 +476,8 @@ struct premultiplied_color
uint64_t a, b;
a = color & 0xFFFF0000FFFFULL;
b = (color & 0xFFFF0000FFFF0000ULL) >> 16;
return (((a * invHI + hiHI) >> 16) & 0xFFFF0000FFFFULL) | ((b * invHI + loHI) & 0xFFFF0000FFFF0000ULL);
return (((a * invHI + hiHI) >> 16) & 0xFFFF0000FFFFULL) | ((b * invHI + loHI) &
0xFFFF0000FFFF0000ULL);
}
void apply(uint64_t& x) throw()
{
@ -486,7 +489,7 @@ struct premultiplied_color
/**
* Bitmap font (8x16).
*/
struct bitmap_font
struct font
{
/**
* Bitmap font glyph.
@ -510,7 +513,7 @@ struct bitmap_font
/**
* Constructor.
*/
bitmap_font() throw(std::bad_alloc);
font() throw(std::bad_alloc);
/**
* Load a .hex format font.
*
@ -560,8 +563,8 @@ struct bitmap_font
* Parameter hdbl: If set, double width horizontally.
* Parameter vdbl: If set, double height vertically.
*/
template<bool X> void render(struct framebuffer<X>& scr, int32_t x, int32_t y, const std::string& text,
premultiplied_color fg, premultiplied_color bg, bool hdbl, bool vdbl) throw();
template<bool X> void render(struct fb<X>& scr, int32_t x, int32_t y, const std::string& text,
color fg, color bg, bool hdbl, bool vdbl) throw();
private:
glyph bad_glyph;
uint32_t bad_glyph_data[4];
@ -577,14 +580,14 @@ private:
/**
* Queue of render operations.
*/
struct render_queue
struct queue
{
/**
* Applies all objects in the queue in order.
*
* parameter scr: The screen to apply queue to.
*/
template<bool X> void run(struct framebuffer<X>& scr) throw();
template<bool X> void run(struct fb<X>& scr) throw();
/**
* Frees all objects in the queue without applying them.
@ -609,7 +612,7 @@ struct render_queue
/**
* Copy objects from another render queue.
*/
void copy_from(render_queue& q) throw(std::bad_alloc);
void copy_from(queue& q) throw(std::bad_alloc);
/**
* Helper for clone.
*/
@ -633,14 +636,14 @@ struct render_queue
/**
* Constructor.
*/
render_queue() throw();
queue() throw();
/**
* Destructor.
*/
~render_queue() throw();
~queue() throw();
private:
void add(struct render_object& obj) throw(std::bad_alloc);
struct node { struct render_object* obj; struct node* next; bool killed; };
void add(struct object& obj) throw(std::bad_alloc);
struct node { struct object* obj; struct node* next; bool killed; };
struct page { char content[RENDER_PAGE_SIZE]; };
struct node* queue_head;
struct node* queue_tail;
@ -659,6 +662,6 @@ private:
* parameter maxc: Maximum coordinate relative to base. Updated.
*/
void clip_range(uint32_t origin, uint32_t size, int32_t base, int32_t& minc, int32_t& maxc) throw();
}
#endif

View file

@ -7,7 +7,7 @@ struct lua_render_context
uint32_t right_gap;
uint32_t top_gap;
uint32_t bottom_gap;
struct render_queue* queue;
struct framebuffer::queue* queue;
uint32_t width;
uint32_t height;
};

View file

@ -6,19 +6,19 @@
/**
* Pixel format LRGB (bsnes).
*/
class pixel_format_lrgb : public pixel_format
class pixel_format_lrgb : public framebuffer::pixfmt
{
public:
~pixel_format_lrgb() throw();
void decode(uint32_t* target, const uint8_t* src, size_t width)
throw();
void decode(uint32_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<false>& auxp) throw();
const framebuffer::auxpalette<false>& auxp) throw();
void decode(uint64_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<true>& auxp) throw();
void set_palette(pixel_format_aux_palette<false>& auxp, uint8_t rshift, uint8_t gshift,
const framebuffer::auxpalette<true>& auxp) throw();
void set_palette(framebuffer::auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc);
void set_palette(pixel_format_aux_palette<true>& auxp, uint8_t rshift, uint8_t gshift,
void set_palette(framebuffer::auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc);
uint8_t get_bpp() throw();
uint8_t get_ss_bpp() throw();

View file

@ -7,19 +7,19 @@
* Pixel format RGB15 (5:5:5).
*/
template<bool uvswap>
class pixel_format_rgb15 : public pixel_format
class pixel_format_rgb15 : public framebuffer::pixfmt
{
public:
~pixel_format_rgb15() throw();
void decode(uint32_t* target, const uint8_t* src, size_t width)
throw();
void decode(uint32_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<false>& auxp) throw();
const framebuffer::auxpalette<false>& auxp) throw();
void decode(uint64_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<true>& auxp) throw();
void set_palette(pixel_format_aux_palette<false>& auxp, uint8_t rshift, uint8_t gshift,
const framebuffer::auxpalette<true>& auxp) throw();
void set_palette(framebuffer::auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc);
void set_palette(pixel_format_aux_palette<true>& auxp, uint8_t rshift, uint8_t gshift,
void set_palette(framebuffer::auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc);
uint8_t get_bpp() throw();
uint8_t get_ss_bpp() throw();

View file

@ -7,19 +7,19 @@
* Pixel format RGB16 (5:6:5).
*/
template<bool uvswap>
class pixel_format_rgb16 : public pixel_format
class pixel_format_rgb16 : public framebuffer::pixfmt
{
public:
~pixel_format_rgb16() throw();
void decode(uint32_t* target, const uint8_t* src, size_t width)
throw();
void decode(uint32_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<false>& auxp) throw();
const framebuffer::auxpalette<false>& auxp) throw();
void decode(uint64_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<true>& auxp) throw();
void set_palette(pixel_format_aux_palette<false>& auxp, uint8_t rshift, uint8_t gshift,
const framebuffer::auxpalette<true>& auxp) throw();
void set_palette(framebuffer::auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc);
void set_palette(pixel_format_aux_palette<true>& auxp, uint8_t rshift, uint8_t gshift,
void set_palette(framebuffer::auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc);
uint8_t get_bpp() throw();
uint8_t get_ss_bpp() throw();

View file

@ -7,19 +7,19 @@
* Pixel format RGB24.
*/
template<bool uvswap>
class pixel_format_rgb24 : public pixel_format
class pixel_format_rgb24 : public framebuffer::pixfmt
{
public:
~pixel_format_rgb24() throw();
void decode(uint32_t* target, const uint8_t* src, size_t width)
throw();
void decode(uint32_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<false>& auxp) throw();
const framebuffer::auxpalette<false>& auxp) throw();
void decode(uint64_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<true>& auxp) throw();
void set_palette(pixel_format_aux_palette<false>& auxp, uint8_t rshift, uint8_t gshift,
const framebuffer::auxpalette<true>& auxp) throw();
void set_palette(framebuffer::auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc);
void set_palette(pixel_format_aux_palette<true>& auxp, uint8_t rshift, uint8_t gshift,
void set_palette(framebuffer::auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc);
uint8_t get_bpp() throw();
uint8_t get_ss_bpp() throw();

View file

@ -6,19 +6,19 @@
/**
* Pixel format RGB32.
*/
class pixel_format_rgb32 : public pixel_format
class pixel_format_rgb32 : public framebuffer::pixfmt
{
public:
~pixel_format_rgb32() throw();
void decode(uint32_t* target, const uint8_t* src, size_t width)
throw();
void decode(uint32_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<false>& auxp) throw();
const framebuffer::auxpalette<false>& auxp) throw();
void decode(uint64_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<true>& auxp) throw();
void set_palette(pixel_format_aux_palette<false>& auxp, uint8_t rshift, uint8_t gshift,
const framebuffer::auxpalette<true>& auxp) throw();
void set_palette(framebuffer::auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc);
void set_palette(pixel_format_aux_palette<true>& auxp, uint8_t rshift, uint8_t gshift,
void set_palette(framebuffer::auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc);
uint8_t get_bpp() throw();
uint8_t get_ss_bpp() throw();

View file

@ -12,7 +12,7 @@
struct lua_palette
{
std::vector<premultiplied_color> colors;
std::vector<framebuffer::color> colors;
lua_palette(lua_state& L);
~lua_palette();
mutex_class palette_mutex;
@ -36,7 +36,7 @@ struct lua_dbitmap
~lua_dbitmap();
size_t width;
size_t height;
std::vector<premultiplied_color> pixels;
std::vector<framebuffer::color> pixels;
std::vector<char> save_png() const;
std::string print();
};

View file

@ -43,13 +43,13 @@ unsigned adv_dumper::target_type_file = 0;
unsigned adv_dumper::target_type_prefix = 1;
unsigned adv_dumper::target_type_special = 2;
template<bool X> bool render_video_hud(struct framebuffer<X>& target, struct framebuffer_raw& source, uint32_t hscl,
template<bool X> bool render_video_hud(struct framebuffer::fb<X>& target, struct framebuffer::raw& source, uint32_t hscl,
uint32_t vscl, uint32_t roffset, uint32_t goffset, uint32_t boffset, uint32_t lgap, uint32_t tgap,
uint32_t rgap, uint32_t bgap, void(*fn)())
{
bool lua_kill_video = false;
struct lua_render_context lrc;
render_queue rq;
framebuffer::queue rq;
lrc.left_gap = lgap;
lrc.right_gap = rgap;
lrc.bottom_gap = bgap;
@ -78,9 +78,9 @@ uint64_t killed_audio_length(uint32_t fps_n, uint32_t fps_d, double& fraction)
return y;
}
template bool render_video_hud(struct framebuffer<false>& target, struct framebuffer_raw& source, uint32_t hscl,
template bool render_video_hud(struct framebuffer::fb<false>& target, struct framebuffer::raw& source, uint32_t hscl,
uint32_t vscl, uint32_t roffset, uint32_t goffset, uint32_t boffset, uint32_t lgap, uint32_t tgap,
uint32_t rgap, uint32_t bgap, void(*fn)());
template bool render_video_hud(struct framebuffer<true>& target, struct framebuffer_raw& source, uint32_t hscl,
template bool render_video_hud(struct framebuffer::fb<true>& target, struct framebuffer::raw& source, uint32_t hscl,
uint32_t vscl, uint32_t roffset, uint32_t goffset, uint32_t boffset, uint32_t lgap, uint32_t tgap,
uint32_t rgap, uint32_t bgap, void(*fn)());

View file

@ -128,12 +128,12 @@ information_dispatch::~information_dispatch() throw()
}
}
void information_dispatch::on_frame(struct framebuffer_raw& _frame, uint32_t fps_n, uint32_t fps_d)
void information_dispatch::on_frame(struct framebuffer::raw& _frame, uint32_t fps_n, uint32_t fps_d)
{
//Do nothing.
}
void information_dispatch::do_frame(struct framebuffer_raw& _frame, uint32_t fps_n, uint32_t fps_d) throw()
void information_dispatch::do_frame(struct framebuffer::raw& _frame, uint32_t fps_n, uint32_t fps_d) throw()
{
update_dumpers();
for(auto& i : _dispatch()) {
@ -347,7 +347,7 @@ struct dispatch::source<> notify_autohold_reconfigure("autohold_reconfigure");
struct dispatch::source<unsigned, unsigned, unsigned, bool> notify_autohold_update("autohold_update");
struct dispatch::source<unsigned, unsigned, unsigned, unsigned, unsigned> notify_autofire_update("autofire_update");
struct dispatch::source<> notify_close("notify_close");
struct dispatch::source<framebuffer<false>&> notify_set_screen("set_screen");
struct dispatch::source<framebuffer::fb<false>&> notify_set_screen("set_screen");
struct dispatch::source<std::pair<std::string, std::string>> notify_sound_change("sound_change");
struct dispatch::source<> notify_screen_update("screen_update");
struct dispatch::source<> notify_status_update("status_update");

View file

@ -12,14 +12,14 @@
#include "library/framebuffer.hpp"
#include "library/pixfmt-lrgb.hpp"
framebuffer_raw screen_corrupt;
framebuffer::raw screen_corrupt;
namespace
{
struct render_info
{
framebuffer_raw fbuf;
render_queue rq;
framebuffer::raw fbuf;
framebuffer::queue rq;
uint32_t hscl;
uint32_t vscl;
uint32_t lgap;
@ -132,7 +132,7 @@ namespace
bool last_redraw_no_lua = true;
}
framebuffer<false> main_screen;
framebuffer::fb<false> main_screen;
void take_screenshot(const std::string& file) throw(std::bad_alloc, std::runtime_error)
{
@ -147,7 +147,7 @@ void init_special_screens() throw(std::bad_alloc)
std::vector<uint32_t> buf;
buf.resize(512*448);
framebuffer_info inf;
framebuffer::info inf;
inf.type = &_pixel_format_lrgb;
inf.mem = reinterpret_cast<char*>(&buf[0]);
inf.physwidth = 512;
@ -160,10 +160,10 @@ void init_special_screens() throw(std::bad_alloc)
inf.offset_y = 0;
draw_corrupt(&buf[0]);
screen_corrupt = framebuffer_raw(inf);
screen_corrupt = framebuffer::raw(inf);
}
void redraw_framebuffer(framebuffer_raw& todraw, bool no_lua, bool spontaneous)
void redraw_framebuffer(framebuffer::raw& todraw, bool no_lua, bool spontaneous)
{
uint32_t hscl, vscl;
auto g = our_rom.rtype->get_scale_factors(todraw.get_width(), todraw.get_height());
@ -198,7 +198,7 @@ void redraw_framebuffer(framebuffer_raw& todraw, bool no_lua, bool spontaneous)
void redraw_framebuffer()
{
render_info& ri = get_read_buffer();
framebuffer_raw copy = ri.fbuf;
framebuffer::raw copy = ri.fbuf;
buffering.end_read();
//Redraws are never spontaneous
redraw_framebuffer(copy, last_redraw_no_lua, false);
@ -238,10 +238,10 @@ std::pair<uint32_t, uint32_t> get_framebuffer_size()
return std::make_pair(h, v);
}
framebuffer_raw get_framebuffer() throw(std::bad_alloc)
framebuffer::raw get_framebuffer() throw(std::bad_alloc)
{
render_info& ri = get_read_buffer();
framebuffer_raw copy = ri.fbuf;
framebuffer::raw copy = ri.fbuf;
buffering.end_read();
return copy;
}
@ -305,7 +305,7 @@ void render_kill_request(void* obj)
buffer3.rq.kill_request(obj);
}
framebuffer_raw& render_get_latest_screen()
framebuffer::raw& render_get_latest_screen()
{
return get_read_buffer().fbuf;
}

View file

@ -482,7 +482,7 @@ public:
return random_seed_value;
}
void output_frame(framebuffer_raw& screen, uint32_t fps_n, uint32_t fps_d)
void output_frame(framebuffer::raw& screen, uint32_t fps_n, uint32_t fps_d)
{
lua_callback_do_frame_emulated();
location_special = SPECIAL_FRAME_VIDEO;

View file

@ -535,7 +535,7 @@ void do_load_state(struct moviefile& _movie, int lmode)
movb.get_movie().readonly_mode(false);
//Paint the screen.
{
framebuffer_raw tmp;
framebuffer::raw tmp;
if(will_load_state) {
tmp.load(_movie.screenshot);
redraw_framebuffer(tmp);

View file

@ -48,7 +48,7 @@ namespace
"Movie‣Loading‣Don't check savestates", false);
//Framebuffer.
struct framebuffer_info null_fbinfo = {
struct framebuffer::info null_fbinfo = {
&_pixel_format_bgr16, //Format.
(char*)null_cover_fbmem, //Memory.
512, 448, 1024, //Physical size.
@ -100,8 +100,8 @@ namespace
void c_runtosave() {}
bool c_get_pflag() { return false; }
void c_set_pflag(bool pflag) {}
framebuffer_raw& c_draw_cover() {
static framebuffer_raw x(null_fbinfo);
framebuffer::raw& c_draw_cover() {
static framebuffer::raw x(null_fbinfo);
for(size_t i = 0; i < sizeof(null_cover_fbmem)/sizeof(null_cover_fbmem[0]); i++)
null_cover_fbmem[i] = 0x0000;
std::string message = "NO ROM LOADED";

View file

@ -76,26 +76,26 @@ namespace
return y;
}
struct render_object_subtitle : public render_object
struct render_object_subtitle : public framebuffer::object
{
render_object_subtitle(int32_t _x, int32_t _y, const std::string& _text) throw()
: x(_x), y(_y), text(_text), fg(0xFFFF80), bg(-1) {}
~render_object_subtitle() throw() {}
template<bool X> void op(struct framebuffer<X>& scr) throw()
template<bool X> void op(struct framebuffer::fb<X>& scr) throw()
{
fg.set_palette(scr);
bg.set_palette(scr);
main_font.render(scr, x, y, text, fg, bg, false, false);
}
void operator()(struct framebuffer<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer<false>& scr) throw() { op(scr); }
void clone(render_queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
void operator()(struct framebuffer::fb<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer::fb<false>& scr) throw() { op(scr); }
void clone(framebuffer::queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
private:
int32_t x;
int32_t y;
std::string text;
premultiplied_color fg;
premultiplied_color bg;
framebuffer::color fg;
framebuffer::color bg;
};

View file

@ -516,7 +516,7 @@ void platform::system_thread_available(bool av) throw()
namespace
{
mutex_class _msgbuf_lock;
framebuffer<false>* our_screen;
framebuffer::fb<false>* our_screen;
struct painter_listener
{
@ -524,12 +524,12 @@ namespace
{
screenupdate.set(notify_screen_update, []() { graphics_driver_notify_screen(); });
statusupdate.set(notify_status_update, []() { graphics_driver_notify_status(); });
setscreen.set(notify_set_screen, [](framebuffer<false>& scr) { our_screen = &scr; });
setscreen.set(notify_set_screen, [](framebuffer::fb<false>& scr) { our_screen = &scr; });
}
private:
struct dispatch::target<> screenupdate;
struct dispatch::target<> statusupdate;
struct dispatch::target<framebuffer<false>&> setscreen;
struct dispatch::target<framebuffer::fb<false>&> setscreen;
} x;
}

View file

@ -66,7 +66,7 @@ namespace
lua_palette* p = lua_class<lua_palette>::create(L);
for(unsigned j = 0; j < ps; j++) {
if(j == 0 && ftrans)
p->colors.push_back(premultiplied_color(-1));
p->colors.push_back(framebuffer::color(-1));
else {
uint64_t val = 0;
uint16_t c = lsnes_memory.read<uint16_t>(addr + j * 2);
@ -75,7 +75,7 @@ namespace
uint64_t b = (c >> 10) & 0x1F;
val = (r << 19) | ((r << 14) & 0xFF0000) | (g << 11) | ((g << 6) & 0xFF00) |
(b << 3) | (b >> 2);
p->colors.push_back(premultiplied_color(val));
p->colors.push_back(framebuffer::color(val));
}
}
return 1;

View file

@ -91,7 +91,7 @@ namespace
unsigned long long delayreset_cycles_target;
//Framebuffer.
struct framebuffer_info cover_fbinfo = {
struct framebuffer::info cover_fbinfo = {
&_pixel_format_lrgb, //Format.
(char*)cover_fbmem, //Memory.
512, 448, 2048, //Physical size.
@ -880,8 +880,8 @@ again2:
}
bool c_get_pflag() { return SNES::cpu.controller_flag; }
void c_set_pflag(bool pflag) { SNES::cpu.controller_flag = pflag; }
framebuffer_raw& c_draw_cover() {
static framebuffer_raw x(cover_fbinfo);
framebuffer::raw& c_draw_cover() {
static framebuffer::raw x(cover_fbinfo);
redraw_cover_fbinfo();
return x;
}
@ -1240,7 +1240,7 @@ again2:
fps_n /= g;
fps_d /= g;
framebuffer_info inf;
framebuffer::info inf;
inf.type = &_pixel_format_lrgb;
inf.mem = const_cast<char*>(reinterpret_cast<const char*>(data));
inf.physwidth = 512;
@ -1251,7 +1251,7 @@ again2:
inf.stride = interlace ? 2048 : 4096;
inf.offset_x = 0;
inf.offset_y = (region ? (overscan ? 9 : 1) : (overscan ? 16 : 9)) * 2;
framebuffer_raw ls(inf);
framebuffer::raw ls(inf);
ecore_callbacks->output_frame(ls, fps_n, fps_d);
if(soundbuf_fill > 0) {

View file

@ -109,7 +109,7 @@ namespace
};
//Framebuffer.
struct framebuffer_info cover_fbinfo = {
struct framebuffer::info cover_fbinfo = {
&_pixel_format_rgb32, //Format.
(char*)cover_fbmem, //Memory.
480, 432, 1920, //Physical size.
@ -631,7 +631,7 @@ namespace
break;
}
}
framebuffer_info inf;
framebuffer::info inf;
inf.type = &_pixel_format_rgb32;
inf.mem = const_cast<char*>(reinterpret_cast<const char*>(primary_framebuffer));
inf.physwidth = 160;
@ -643,15 +643,15 @@ namespace
inf.offset_x = 0;
inf.offset_y = 0;
framebuffer_raw ls(inf);
framebuffer::raw ls(inf);
ecore_callbacks->output_frame(ls, 262144, 4389);
audioapi_submit_buffer(soundbuf, emitted / 2, true, native_rate ? 2097152 : 32768);
}
void c_runtosave() {}
bool c_get_pflag() { return pflag; }
void c_set_pflag(bool _pflag) { pflag = _pflag; }
framebuffer_raw& c_draw_cover() {
static framebuffer_raw x(cover_fbinfo);
framebuffer::raw& c_draw_cover() {
static framebuffer::raw x(cover_fbinfo);
redraw_cover_fbinfo();
return x;
}

View file

@ -27,7 +27,7 @@ namespace sky
//Framebuffer.
uint32_t cover_fbmem[320*200];
struct framebuffer_info cover_fbinfo = {
struct framebuffer::info cover_fbinfo = {
&_pixel_format_rgb32, //Format.
(char*)cover_fbmem, //Memory.
320, 200, 1280, //Physical size.
@ -308,7 +308,7 @@ namespace sky
pflag = true;
simulate_frame(corei, x);
uint32_t* fb = corei.get_framebuffer();
framebuffer_info inf;
framebuffer::info inf;
inf.type = &_pixel_format_rgb32;
inf.mem = const_cast<char*>(reinterpret_cast<const char*>(fb));
inf.physwidth = FB_WIDTH;
@ -320,7 +320,7 @@ namespace sky
inf.offset_x = 0;
inf.offset_y = 0;
framebuffer_raw ls(inf);
framebuffer::raw ls(inf);
ecore_callbacks->output_frame(ls, 656250, 18227);
ecore_callbacks->timer_tick(18227, 656250);
size_t samples = 1333;
@ -332,8 +332,8 @@ namespace sky
void c_runtosave() {}
bool c_get_pflag() { return pflag; }
void c_set_pflag(bool _pflag) { pflag = _pflag; }
framebuffer_raw& c_draw_cover() {
static framebuffer_raw x(cover_fbinfo);
framebuffer::raw& c_draw_cover() {
static framebuffer::raw x(cover_fbinfo);
return x;
}
std::string c_get_core_shortname() { return "sky"; }

View file

@ -44,7 +44,7 @@ namespace
bool pflag = false;
//Framebuffer.
struct framebuffer_info cover_fbinfo = {
struct framebuffer::info cover_fbinfo = {
&_pixel_format_rgb32, //Format.
(char*)cover_fbmem, //Memory.
480, 432, 1920, //Physical size.
@ -149,7 +149,7 @@ namespace
int16_t audio[800] = {0};
pflag = false;
redraw_screen();
framebuffer_info inf;
framebuffer::info inf;
inf.type = &_pixel_format_rgb32;
inf.mem = const_cast<char*>(reinterpret_cast<const char*>(cover_fbmem));
inf.physwidth = 480;
@ -160,15 +160,15 @@ namespace
inf.stride = 1920;
inf.offset_x = 0;
inf.offset_y = 0;
framebuffer_raw ls(inf);
framebuffer::raw ls(inf);
ecore_callbacks->output_frame(ls, 60,1);
audioapi_submit_buffer(audio, 800, false, 48000);
}
void c_runtosave() {}
bool c_get_pflag() { return pflag; }
void c_set_pflag(bool _pflag) { pflag = _pflag; }
framebuffer_raw& c_draw_cover() {
static framebuffer_raw x(cover_fbinfo);
framebuffer::raw& c_draw_cover() {
static framebuffer::raw x(cover_fbinfo);
redraw_cover_fbinfo();
return x;
}

View file

@ -3,7 +3,7 @@
#include <cstring>
extern const char* font_hex_data;
bitmap_font main_font;
framebuffer::font main_font;
void do_init_font()
{

View file

@ -16,7 +16,7 @@ namespace
unsigned char* _bg = reinterpret_cast<unsigned char*>(&bg);
if(x >= w || y >= h)
return;
const bitmap_font::glyph& g = main_font.get_glyph(ch);
const framebuffer::font::glyph& g = main_font.get_glyph(ch);
unsigned maxw = min((size_t)(g.wide ? 16 : 8), (size_t)(w - x));
unsigned maxh = min((size_t)16, (size_t)(h - y));
unsigned char* cellbase = reinterpret_cast<unsigned char*>(fb) + y * istride + pstride * x;
@ -99,7 +99,7 @@ void cover_next_position(uint32_t ch, unsigned& x, unsigned& y)
x = 0;
y = y + 16;
} else {
const bitmap_font::glyph& g = main_font.get_glyph(ch);
const framebuffer::font::glyph& g = main_font.get_glyph(ch);
x = x + (g.wide ? 16 : 8);
}
}

View file

@ -511,7 +511,7 @@ void core_core::set_pflag(bool pflag)
return c_set_pflag(pflag);
}
framebuffer_raw& core_core::draw_cover()
framebuffer::raw& core_core::draw_cover()
{
return c_draw_cover();
}

View file

@ -37,8 +37,8 @@ namespace
return ((glyph.glyph[ge] >> gb) & 1);
}
template<bool T> void _render(const font_glyph_data& glyph, framebuffer<T>& fb, int32_t x, int32_t y,
premultiplied_color fg, premultiplied_color bg, premultiplied_color hl)
template<bool T> void _render(const font_glyph_data& glyph, framebuffer::fb<T>& fb, int32_t x, int32_t y,
framebuffer::color fg, framebuffer::color bg, framebuffer::color hl)
{
uint32_t xdc, xoff, xsize;
uint32_t ydc, yoff, ysize;
@ -172,14 +172,14 @@ font_glyph_data::font_glyph_data(std::istream& s)
}
}
void font_glyph_data::render(framebuffer<false>& fb, int32_t x, int32_t y, premultiplied_color fg,
premultiplied_color bg, premultiplied_color hl) const
void font_glyph_data::render(framebuffer::fb<false>& fb, int32_t x, int32_t y, framebuffer::color fg,
framebuffer::color bg, framebuffer::color hl) const
{
_render(*this, fb, x, y, fg, bg, hl);
}
void font_glyph_data::render(framebuffer<true>& fb, int32_t x, int32_t y, premultiplied_color fg,
premultiplied_color bg, premultiplied_color hl) const
void font_glyph_data::render(framebuffer::fb<true>& fb, int32_t x, int32_t y, framebuffer::color fg,
framebuffer::color bg, framebuffer::color hl) const
{
_render(*this, fb, x, y, fg, bg, hl);
}
@ -236,11 +236,11 @@ custom_font::custom_font(const std::string& file)
}
}
custom_font::custom_font(struct bitmap_font& bfont)
custom_font::custom_font(struct framebuffer::font& bfont)
{
auto s = bfont.get_glyphs_set();
for(auto i = s.begin();;i++) {
const bitmap_font::glyph& j = (i != s.end()) ? bfont.get_glyph(*i) : bfont.get_bad_glyph();
const framebuffer::font::glyph& j = (i != s.end()) ? bfont.get_glyph(*i) : bfont.get_bad_glyph();
font_glyph_data k;
k.width = j.wide ? 16 : 8;
k.height = 16;

View file

@ -10,11 +10,13 @@
#define TABSTOPS 64
#define SCREENSHOT_RGB_MAGIC 0x74212536U
namespace framebuffer
{
namespace
{
std::list<pixel_format*>& pixel_formats()
std::list<pixfmt*>& pixfmts()
{
static std::list<pixel_format*> x;
static std::list<pixfmt*> x;
return x;
}
@ -93,21 +95,21 @@ namespace
}
}
pixel_format::pixel_format() throw(std::bad_alloc)
pixfmt::pixfmt() throw(std::bad_alloc)
{
pixel_formats().push_back(this);
pixfmts().push_back(this);
}
pixel_format::~pixel_format() throw()
pixfmt::~pixfmt() throw()
{
for(auto i = pixel_formats().begin(); i != pixel_formats().end(); i++)
for(auto i = pixfmts().begin(); i != pixfmts().end(); i++)
if(*i == this) {
pixel_formats().erase(i);
pixfmts().erase(i);
break;
}
}
framebuffer_raw::framebuffer_raw(const framebuffer_info& info) throw(std::bad_alloc)
raw::raw(const info& info) throw(std::bad_alloc)
{
size_t unit = info.type->get_bpp();
size_t pixel_offset = info.offset_y * info.physstride + unit * info.offset_x;
@ -120,7 +122,7 @@ framebuffer_raw::framebuffer_raw(const framebuffer_info& info) throw(std::bad_al
allocated = 0;
}
framebuffer_raw::framebuffer_raw() throw(std::bad_alloc)
raw::raw() throw(std::bad_alloc)
{
user_memory = true;
fmt = NULL;
@ -131,7 +133,7 @@ framebuffer_raw::framebuffer_raw() throw(std::bad_alloc)
allocated = 0;
}
framebuffer_raw::framebuffer_raw(const framebuffer_raw& f) throw(std::bad_alloc)
raw::raw(const raw& f) throw(std::bad_alloc)
{
user_memory = true;
fmt = f.fmt;
@ -145,7 +147,7 @@ framebuffer_raw::framebuffer_raw(const framebuffer_raw& f) throw(std::bad_alloc)
memcpy(addr + stride * i, f.addr + f.stride * i, unit * width);
}
framebuffer_raw& framebuffer_raw::operator=(const framebuffer_raw& f) throw(std::bad_alloc, std::runtime_error)
raw& raw::operator=(const raw& f) throw(std::bad_alloc, std::runtime_error)
{
if(!user_memory)
throw std::runtime_error("Target framebuffer is not writable");
@ -168,19 +170,19 @@ framebuffer_raw& framebuffer_raw::operator=(const framebuffer_raw& f) throw(std:
return *this;
}
framebuffer_raw::~framebuffer_raw()
raw::~raw()
{
if(user_memory)
delete[] addr;
}
void framebuffer_raw::load(const std::vector<char>& data) throw(std::bad_alloc, std::runtime_error)
void raw::load(const std::vector<char>& data) throw(std::bad_alloc, std::runtime_error)
{
if(data.size() < 2)
throw std::runtime_error("Bad screenshot data");
if(!user_memory)
throw std::runtime_error("Target framebuffer is not writable");
pixel_format* nfmt = NULL;
pixfmt* nfmt = NULL;
const uint8_t* data2 = reinterpret_cast<const uint8_t*>(&data[0]);
size_t legacy_width = read16ube(data2);
size_t dataoffset;
@ -189,7 +191,7 @@ void framebuffer_raw::load(const std::vector<char>& data) throw(std::bad_alloc,
if(legacy_width > 0 && data.size() % (3 * legacy_width) == 2) {
//Legacy screenshot.
for(pixel_format* f : pixel_formats())
for(pixfmt* f : pixfmts())
if(f->get_magic() == 0)
nfmt = f;
if(!nfmt)
@ -203,7 +205,7 @@ void framebuffer_raw::load(const std::vector<char>& data) throw(std::bad_alloc,
throw std::runtime_error("Bad screenshot data");
dataoffset = 8;
uint32_t magic = read32ube(data2 + 2);
for(pixel_format* f : pixel_formats())
for(pixfmt* f : pixfmts())
if(f->get_magic() == magic)
nfmt = f;
if(!nfmt)
@ -240,7 +242,7 @@ void framebuffer_raw::load(const std::vector<char>& data) throw(std::bad_alloc,
decode_words<4>(reinterpret_cast<uint8_t*>(addr), data2 + dataoffset, data.size() - dataoffset);
}
void framebuffer_raw::save(std::vector<char>& data) throw(std::bad_alloc)
void raw::save(std::vector<char>& data) throw(std::bad_alloc)
{
uint8_t* memory = reinterpret_cast<uint8_t*>(addr);
unsigned m;
@ -284,7 +286,7 @@ void framebuffer_raw::save(std::vector<char>& data) throw(std::bad_alloc)
}
}
void framebuffer_raw::save_png(const std::string& file) throw(std::bad_alloc, std::runtime_error)
void raw::save_png(const std::string& file) throw(std::bad_alloc, std::runtime_error)
{
uint8_t* memory = reinterpret_cast<uint8_t*>(addr);
png_encodedable_image img;
@ -302,13 +304,13 @@ void framebuffer_raw::save_png(const std::string& file) throw(std::bad_alloc, st
}
}
size_t framebuffer_raw::get_stride() const throw() { return stride; }
unsigned char* framebuffer_raw::get_start() const throw() { return reinterpret_cast<uint8_t*>(addr); }
pixel_format* framebuffer_raw::get_format() const throw() { return fmt; }
size_t raw::get_stride() const throw() { return stride; }
unsigned char* raw::get_start() const throw() { return reinterpret_cast<uint8_t*>(addr); }
pixfmt* raw::get_format() const throw() { return fmt; }
template<bool X>
framebuffer<X>::framebuffer() throw()
fb<X>::fb() throw()
{
width = 0;
height = 0;
@ -328,7 +330,7 @@ framebuffer<X>::framebuffer() throw()
template<bool X>
framebuffer<X>::~framebuffer() throw()
fb<X>::~fb() throw()
{
if(user_mem)
delete[] mem;
@ -337,15 +339,15 @@ framebuffer<X>::~framebuffer() throw()
#define DECBUF_SIZE 4096
template<bool X>
void framebuffer<X>::copy_from(framebuffer_raw& scr, size_t hscale, size_t vscale) throw()
void fb<X>::copy_from(raw& scr, size_t hscale, size_t vscale) throw()
{
typename framebuffer<X>::element_t decbuf[DECBUF_SIZE];
typename fb<X>::element_t decbuf[DECBUF_SIZE];
last_blit_w = scr.width * hscale;
last_blit_h = scr.height * vscale;
if(!scr.fmt) {
for(size_t y = 0; y < height; y++)
memset(rowptr(y), 0, sizeof(typename framebuffer<X>::element_t) * width);
memset(rowptr(y), 0, sizeof(typename fb<X>::element_t) * width);
return;
}
if(scr.fmt != current_fmt || active_rshift != auxpal.rshift || active_gshift != auxpal.gshift ||
@ -355,7 +357,7 @@ void framebuffer<X>::copy_from(framebuffer_raw& scr, size_t hscale, size_t vscal
}
for(size_t y = 0; y < height; y++)
memset(rowptr(y), 0, sizeof(typename framebuffer<X>::element_t) * width);
memset(rowptr(y), 0, sizeof(typename fb<X>::element_t) * width);
if(width < offset_x || height < offset_y) {
//Just clear the screen.
return;
@ -371,7 +373,7 @@ void framebuffer<X>::copy_from(framebuffer_raw& scr, size_t hscale, size_t vscal
for(size_t y = 0; y < copyable_height; y++) {
size_t line = y * vscale + offset_y;
const uint8_t* sbase = reinterpret_cast<uint8_t*>(scr.addr) + y * scr.stride;
typename framebuffer<X>::element_t* ptr = rowptr(line) + offset_x;
typename fb<X>::element_t* ptr = rowptr(line) + offset_x;
size_t bpp = scr.fmt->get_bpp();
size_t xptr = 0;
size_t old_copyable_width = copyable_width;
@ -390,18 +392,18 @@ void framebuffer<X>::copy_from(framebuffer_raw& scr, size_t hscale, size_t vscal
copyable_width = old_copyable_width;
for(size_t j = 1; j < vscale; j++)
memcpy(rowptr(line + j) + offset_x, rowptr(line) + offset_x,
sizeof(typename framebuffer<X>::element_t) * hscale * copyable_width);
sizeof(typename fb<X>::element_t) * hscale * copyable_width);
};
}
template<bool X>
void framebuffer<X>::set_palette(uint32_t r, uint32_t g, uint32_t b) throw(std::bad_alloc)
void fb<X>::set_palette(uint32_t r, uint32_t g, uint32_t b) throw(std::bad_alloc)
{
typename framebuffer<X>::element_t R, G, B;
typename fb<X>::element_t R, G, B;
if(r == active_rshift && g == active_gshift && b == active_bshift)
return;
for(size_t i = 0; i < static_cast<size_t>(width) * height; i++) {
typename framebuffer<X>::element_t word = mem[i];
typename fb<X>::element_t word = mem[i];
R = (word >> active_rshift) & (X ? 0xFFFF : 0xFF);
G = (word >> active_gshift) & (X ? 0xFFFF : 0xFF);
B = (word >> active_bshift) & (X ? 0xFFFF : 0xFF);
@ -413,7 +415,7 @@ void framebuffer<X>::set_palette(uint32_t r, uint32_t g, uint32_t b) throw(std::
}
template<bool X>
void framebuffer<X>::set(element_t* _memory, size_t _width, size_t _height, size_t _pitch) throw()
void fb<X>::set(element_t* _memory, size_t _width, size_t _height, size_t _pitch) throw()
{
if(user_mem && mem)
delete[] mem;
@ -426,7 +428,7 @@ void framebuffer<X>::set(element_t* _memory, size_t _width, size_t _height, size
}
template<bool X>
void framebuffer<X>::reallocate(size_t _width, size_t _height, bool _upside_down) throw(std::bad_alloc)
void fb<X>::reallocate(size_t _width, size_t _height, bool _upside_down) throw(std::bad_alloc)
{
if(width != _width || height != _height) {
if(user_mem) {
@ -445,39 +447,39 @@ void framebuffer<X>::reallocate(size_t _width, size_t _height, bool _upside_down
}
template<bool X>
void framebuffer<X>::set_origin(size_t _offset_x, size_t _offset_y) throw()
void fb<X>::set_origin(size_t _offset_x, size_t _offset_y) throw()
{
offset_x = _offset_x;
offset_y = _offset_y;
}
template<bool X>
size_t framebuffer<X>::get_width() const throw()
size_t fb<X>::get_width() const throw()
{
return width;
}
template<bool X>
size_t framebuffer<X>::get_height() const throw()
size_t fb<X>::get_height() const throw()
{
return height;
}
template<bool X>
size_t framebuffer<X>::get_last_blit_width() const throw()
size_t fb<X>::get_last_blit_width() const throw()
{
return last_blit_w;
}
template<bool X>
size_t framebuffer<X>::get_last_blit_height() const throw()
size_t fb<X>::get_last_blit_height() const throw()
{
return last_blit_h;
}
template<bool X>
typename framebuffer<X>::element_t* framebuffer<X>::rowptr(size_t row) throw()
typename fb<X>::element_t* fb<X>::rowptr(size_t row) throw()
{
if(upside_down)
row = height - row - 1;
@ -485,21 +487,21 @@ typename framebuffer<X>::element_t* framebuffer<X>::rowptr(size_t row) throw()
}
template<bool X>
const typename framebuffer<X>::element_t* framebuffer<X>::rowptr(size_t row) const throw()
const typename fb<X>::element_t* fb<X>::rowptr(size_t row) const throw()
{
if(upside_down)
row = height - row - 1;
return mem + stride * row;
}
template<bool X> uint8_t framebuffer<X>::get_palette_r() const throw() { return auxpal.rshift; }
template<bool X> uint8_t framebuffer<X>::get_palette_g() const throw() { return auxpal.gshift; }
template<bool X> uint8_t framebuffer<X>::get_palette_b() const throw() { return auxpal.bshift; }
template<bool X> uint8_t fb<X>::get_palette_r() const throw() { return auxpal.rshift; }
template<bool X> uint8_t fb<X>::get_palette_g() const throw() { return auxpal.gshift; }
template<bool X> uint8_t fb<X>::get_palette_b() const throw() { return auxpal.bshift; }
size_t framebuffer_raw::get_width() const throw() { return width; }
size_t framebuffer_raw::get_height() const throw() { return height; }
template<bool X> size_t framebuffer<X>::get_origin_x() const throw() { return offset_x; }
template<bool X> size_t framebuffer<X>::get_origin_y() const throw() { return offset_y; }
size_t raw::get_width() const throw() { return width; }
size_t raw::get_height() const throw() { return height; }
template<bool X> size_t fb<X>::get_origin_x() const throw() { return offset_x; }
template<bool X> size_t fb<X>::get_origin_y() const throw() { return offset_y; }
void clip_range(uint32_t origin, uint32_t size, int32_t base, int32_t& minc, int32_t& maxc) throw()
{
@ -523,7 +525,7 @@ void clip_range(uint32_t origin, uint32_t size, int32_t base, int32_t& minc, int
}
}
void render_queue::add(struct render_object& obj) throw(std::bad_alloc)
void queue::add(struct object& obj) throw(std::bad_alloc)
{
struct node* n = reinterpret_cast<struct node*>(alloc(sizeof(node)));
n->obj = &obj;
@ -535,7 +537,7 @@ void render_queue::add(struct render_object& obj) throw(std::bad_alloc)
queue_head = queue_tail = n;
}
void render_queue::copy_from(render_queue& q) throw(std::bad_alloc)
void queue::copy_from(queue& q) throw(std::bad_alloc)
{
struct node* tmp = q.queue_head;
while(tmp) {
@ -547,7 +549,7 @@ void render_queue::copy_from(render_queue& q) throw(std::bad_alloc)
}
}
template<bool X> void render_queue::run(struct framebuffer<X>& scr) throw()
template<bool X> void queue::run(struct fb<X>& scr) throw()
{
struct node* tmp = queue_head;
while(tmp) {
@ -560,11 +562,11 @@ template<bool X> void render_queue::run(struct framebuffer<X>& scr) throw()
}
}
void render_queue::clear() throw()
void queue::clear() throw()
{
while(queue_head) {
if(!queue_head->killed)
queue_head->obj->~render_object();
queue_head->obj->~object();
queue_head = queue_head->next;
}
//Release all memory for reuse.
@ -573,7 +575,7 @@ void render_queue::clear() throw()
queue_tail = NULL;
}
void* render_queue::alloc(size_t block) throw(std::bad_alloc)
void* queue::alloc(size_t block) throw(std::bad_alloc)
{
block = (block + 15) / 16 * 16;
if(block > RENDER_PAGE_SIZE)
@ -587,7 +589,7 @@ void* render_queue::alloc(size_t block) throw(std::bad_alloc)
return mem;
}
void render_queue::kill_request(void* obj) throw()
void queue::kill_request(void* obj) throw()
{
struct node* tmp = queue_head;
while(tmp) {
@ -595,7 +597,7 @@ void render_queue::kill_request(void* obj) throw()
if(!tmp->killed && tmp->obj->kill_request(obj)) {
//Kill this request.
tmp->killed = true;
tmp->obj->~render_object();
tmp->obj->~object();
}
tmp = tmp->next;
} catch(...) {
@ -603,7 +605,7 @@ void render_queue::kill_request(void* obj) throw()
}
}
render_queue::render_queue() throw()
queue::queue() throw()
{
queue_head = NULL;
queue_tail = NULL;
@ -611,20 +613,20 @@ render_queue::render_queue() throw()
pages = 0;
}
render_queue::~render_queue() throw()
queue::~queue() throw()
{
clear();
}
render_object::render_object() throw()
object::object() throw()
{
}
render_object::~render_object() throw()
object::~object() throw()
{
}
bool render_object::kill_request_ifeq(void* myobj, void* killobj)
bool object::kill_request_ifeq(void* myobj, void* killobj)
{
if(!killobj)
return false;
@ -633,12 +635,12 @@ bool render_object::kill_request_ifeq(void* myobj, void* killobj)
return false;
}
bool render_object::kill_request(void* obj) throw()
bool object::kill_request(void* obj) throw()
{
return false;
}
bitmap_font::bitmap_font() throw(std::bad_alloc)
font::font() throw(std::bad_alloc)
{
bad_glyph_data[0] = 0x018001AAU;
bad_glyph_data[1] = 0x01800180U;
@ -648,7 +650,7 @@ bitmap_font::bitmap_font() throw(std::bad_alloc)
bad_glyph.data = bad_glyph_data;
}
void bitmap_font::load_hex_glyph(const char* data, size_t size) throw(std::bad_alloc, std::runtime_error)
void font::load_hex_glyph(const char* data, size_t size) throw(std::bad_alloc, std::runtime_error)
{
char buf2[8];
std::string line(data, data + size);
@ -678,7 +680,7 @@ void bitmap_font::load_hex_glyph(const char* data, size_t size) throw(std::bad_a
glyphs[cp].offset = p;
}
void bitmap_font::load_hex(const char* data, size_t size) throw(std::bad_alloc, std::runtime_error)
void font::load_hex(const char* data, size_t size) throw(std::bad_alloc, std::runtime_error)
{
const char* enddata = data + size;
while(data != enddata) {
@ -701,7 +703,7 @@ void bitmap_font::load_hex(const char* data, size_t size) throw(std::bad_alloc,
i.second.data = &memory[i.second.offset];
}
const bitmap_font::glyph& bitmap_font::get_glyph(uint32_t glyph) throw()
const font::glyph& font::get_glyph(uint32_t glyph) throw()
{
if(glyphs.count(glyph))
return glyphs[glyph];
@ -709,7 +711,7 @@ const bitmap_font::glyph& bitmap_font::get_glyph(uint32_t glyph) throw()
return bad_glyph;
}
std::set<uint32_t> bitmap_font::get_glyphs_set()
std::set<uint32_t> font::get_glyphs_set()
{
std::set<uint32_t> out;
for(auto& i : glyphs)
@ -717,12 +719,12 @@ std::set<uint32_t> bitmap_font::get_glyphs_set()
return out;
}
const bitmap_font::glyph& bitmap_font::get_bad_glyph() throw()
const font::glyph& font::get_bad_glyph() throw()
{
return bad_glyph;
}
std::pair<size_t, size_t> bitmap_font::get_metrics(const std::string& string) throw()
std::pair<size_t, size_t> font::get_metrics(const std::string& string) throw()
{
size_t commit_width = 0;
size_t commit_height = 0;
@ -760,7 +762,7 @@ std::pair<size_t, size_t> bitmap_font::get_metrics(const std::string& string) th
return std::make_pair(commit_width, commit_height);
}
std::vector<bitmap_font::layout> bitmap_font::dolayout(const std::string& string) throw(std::bad_alloc)
std::vector<font::layout> font::dolayout(const std::string& string) throw(std::bad_alloc)
{
//First, calculate the number of glyphs to draw.
uint16_t utfstate = utf8_initial_state;
@ -807,8 +809,8 @@ std::vector<bitmap_font::layout> bitmap_font::dolayout(const std::string& string
return l;
}
template<bool X> void bitmap_font::render(struct framebuffer<X>& scr, int32_t x, int32_t y, const std::string& text,
premultiplied_color fg, premultiplied_color bg, bool hdbl, bool vdbl) throw()
template<bool X> void font::render(struct fb<X>& scr, int32_t x, int32_t y, const std::string& text,
color fg, color bg, bool hdbl, bool vdbl) throw()
{
x += scr.get_origin_x();
y += scr.get_origin_y();
@ -855,7 +857,7 @@ template<bool X> void bitmap_font::render(struct framebuffer<X>& scr, int32_t x,
if(gy + ystart + ylength > sheight) ylength = sheight - (gy + ystart);
if(g.data)
for(size_t i = 0; i < ylength; i++) {
typename framebuffer<X>::element_t* r = scr.rowptr(gy + ystart + i) +
typename fb<X>::element_t* r = scr.rowptr(gy + ystart + i) +
(gx + xstart);
uint32_t _y = (i + ystart) >> (vdbl ? 1 : 0);
uint32_t d = g.data[_y >> (g.wide ? 1 : 2)];
@ -882,7 +884,7 @@ template<bool X> void bitmap_font::render(struct framebuffer<X>& scr, int32_t x,
}
else
for(size_t i = 0; i < ylength; i++) {
typename framebuffer<X>::element_t* r = scr.rowptr(gy + ystart + i) +
typename fb<X>::element_t* r = scr.rowptr(gy + ystart + i) +
(gx + xstart);
for(size_t j = 0; j < xlength; j++)
bg.apply(r[j]);
@ -892,7 +894,7 @@ template<bool X> void bitmap_font::render(struct framebuffer<X>& scr, int32_t x,
}
}
void premultiplied_color::set_palette(unsigned rshift, unsigned gshift, unsigned bshift, bool X) throw()
void color::set_palette(unsigned rshift, unsigned gshift, unsigned bshift, bool X) throw()
{
if(X) {
uint64_t r = ((orig >> 16) & 0xFF) * 257;
@ -915,11 +917,12 @@ void premultiplied_color::set_palette(unsigned rshift, unsigned gshift, unsigned
}
}
template class framebuffer<false>;
template class framebuffer<true>;
template void render_queue::run(struct framebuffer<false>&);
template void render_queue::run(struct framebuffer<true>&);
template void bitmap_font::render(struct framebuffer<false>& scr, int32_t x, int32_t y, const std::string& text,
premultiplied_color fg, premultiplied_color bg, bool hdbl, bool vdbl) throw();
template void bitmap_font::render(struct framebuffer<true>& scr, int32_t x, int32_t y, const std::string& text,
premultiplied_color fg, premultiplied_color bg, bool hdbl, bool vdbl) throw();
template class fb<false>;
template class fb<true>;
template void queue::run(struct fb<false>&);
template void queue::run(struct fb<true>&);
template void font::render(struct fb<false>& scr, int32_t x, int32_t y, const std::string& text,
color fg, color bg, bool hdbl, bool vdbl) throw();
template void font::render(struct fb<true>& scr, int32_t x, int32_t y, const std::string& text,
color fg, color bg, bool hdbl, bool vdbl) throw();
}

View file

@ -22,7 +22,7 @@ void pixel_format_lrgb::decode(uint32_t* target, const uint8_t* src, size_t widt
}
void pixel_format_lrgb::decode(uint32_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<false>& auxp) throw()
const framebuffer::auxpalette<false>& auxp) throw()
{
const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
for(size_t i = 0; i < width; i++)
@ -30,14 +30,14 @@ void pixel_format_lrgb::decode(uint32_t* target, const uint8_t* src, size_t widt
}
void pixel_format_lrgb::decode(uint64_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<true>& auxp) throw()
const framebuffer::auxpalette<true>& auxp) throw()
{
const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
for(size_t i = 0; i < width; i++)
target[i] = auxp.pcache[_src[i] & 0x7FFFF];
}
void pixel_format_lrgb::set_palette(pixel_format_aux_palette<false>& auxp, uint8_t rshift, uint8_t gshift,
void pixel_format_lrgb::set_palette(framebuffer::auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.pcache.resize(0x80000);
@ -55,7 +55,7 @@ void pixel_format_lrgb::set_palette(pixel_format_aux_palette<false>& auxp, uint8
auxp.bshift = bshift;
}
void pixel_format_lrgb::set_palette(pixel_format_aux_palette<true>& auxp, uint8_t rshift, uint8_t gshift,
void pixel_format_lrgb::set_palette(framebuffer::auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.pcache.resize(0x80000);

View file

@ -23,7 +23,7 @@ void pixel_format_rgb15<uvswap>::decode(uint32_t* target, const uint8_t* src, si
template<bool uvswap>
void pixel_format_rgb15<uvswap>::decode(uint32_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<false>& auxp) throw()
const framebuffer::auxpalette<false>& auxp) throw()
{
const uint16_t* _src = reinterpret_cast<const uint16_t*>(src);
for(size_t i = 0; i < width; i++)
@ -32,7 +32,7 @@ void pixel_format_rgb15<uvswap>::decode(uint32_t* target, const uint8_t* src, si
template<bool uvswap>
void pixel_format_rgb15<uvswap>::decode(uint64_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<true>& auxp) throw()
const framebuffer::auxpalette<true>& auxp) throw()
{
const uint16_t* _src = reinterpret_cast<const uint16_t*>(src);
for(size_t i = 0; i < width; i++)
@ -40,7 +40,7 @@ void pixel_format_rgb15<uvswap>::decode(uint64_t* target, const uint8_t* src, si
}
template<bool uvswap>
void pixel_format_rgb15<uvswap>::set_palette(pixel_format_aux_palette<false>& auxp, uint8_t rshift, uint8_t gshift,
void pixel_format_rgb15<uvswap>::set_palette(framebuffer::auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.pcache.resize(0x8000);
@ -58,7 +58,7 @@ void pixel_format_rgb15<uvswap>::set_palette(pixel_format_aux_palette<false>& au
}
template<bool uvswap>
void pixel_format_rgb15<uvswap>::set_palette(pixel_format_aux_palette<true>& auxp, uint8_t rshift, uint8_t gshift,
void pixel_format_rgb15<uvswap>::set_palette(framebuffer::auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.pcache.resize(0x8000);

View file

@ -22,7 +22,7 @@ void pixel_format_rgb16<uvswap>::decode(uint32_t* target, const uint8_t* src, si
template<bool uvswap>
void pixel_format_rgb16<uvswap>::decode(uint32_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<false>& auxp) throw()
const framebuffer::auxpalette<false>& auxp) throw()
{
const uint16_t* _src = reinterpret_cast<const uint16_t*>(src);
for(size_t i = 0; i < width; i++)
@ -31,7 +31,7 @@ void pixel_format_rgb16<uvswap>::decode(uint32_t* target, const uint8_t* src, si
template<bool uvswap>
void pixel_format_rgb16<uvswap>::decode(uint64_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<true>& auxp) throw()
const framebuffer::auxpalette<true>& auxp) throw()
{
const uint16_t* _src = reinterpret_cast<const uint16_t*>(src);
for(size_t i = 0; i < width; i++)
@ -39,7 +39,7 @@ void pixel_format_rgb16<uvswap>::decode(uint64_t* target, const uint8_t* src, si
}
template<bool uvswap>
void pixel_format_rgb16<uvswap>::set_palette(pixel_format_aux_palette<false>& auxp, uint8_t rshift, uint8_t gshift,
void pixel_format_rgb16<uvswap>::set_palette(framebuffer::auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.pcache.resize(0x10000);
@ -57,7 +57,7 @@ void pixel_format_rgb16<uvswap>::set_palette(pixel_format_aux_palette<false>& au
}
template<bool uvswap>
void pixel_format_rgb16<uvswap>::set_palette(pixel_format_aux_palette<true>& auxp, uint8_t rshift, uint8_t gshift,
void pixel_format_rgb16<uvswap>::set_palette(framebuffer::auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.pcache.resize(0x10000);

View file

@ -24,7 +24,7 @@ void pixel_format_rgb24<uvswap>::decode(uint32_t* target, const uint8_t* src, si
template<bool uvswap>
void pixel_format_rgb24<uvswap>::decode(uint32_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<false>& auxp) throw()
const framebuffer::auxpalette<false>& auxp) throw()
{
for(size_t i = 0; i < width; i++) {
target[i] = static_cast<uint32_t>(src[3 * i + (uvswap ? 2 : 0)]) << auxp.rshift;
@ -35,7 +35,7 @@ void pixel_format_rgb24<uvswap>::decode(uint32_t* target, const uint8_t* src, si
template<bool uvswap>
void pixel_format_rgb24<uvswap>::decode(uint64_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<true>& auxp) throw()
const framebuffer::auxpalette<true>& auxp) throw()
{
for(size_t i = 0; i < width; i++) {
target[i] = static_cast<uint64_t>(src[3 * i + (uvswap ? 2 : 0)]) << auxp.rshift;
@ -46,7 +46,7 @@ void pixel_format_rgb24<uvswap>::decode(uint64_t* target, const uint8_t* src, si
}
template<bool uvswap>
void pixel_format_rgb24<uvswap>::set_palette(pixel_format_aux_palette<false>& auxp, uint8_t rshift, uint8_t gshift,
void pixel_format_rgb24<uvswap>::set_palette(framebuffer::auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.rshift = rshift;
@ -56,7 +56,7 @@ void pixel_format_rgb24<uvswap>::set_palette(pixel_format_aux_palette<false>& au
}
template<bool uvswap>
void pixel_format_rgb24<uvswap>::set_palette(pixel_format_aux_palette<true>& auxp, uint8_t rshift, uint8_t gshift,
void pixel_format_rgb24<uvswap>::set_palette(framebuffer::auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.rshift = rshift;

View file

@ -10,7 +10,7 @@ void pixel_format_rgb32::decode(uint32_t* target, const uint8_t* src, size_t wid
}
void pixel_format_rgb32::decode(uint32_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<false>& auxp) throw()
const framebuffer::auxpalette<false>& auxp) throw()
{
const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
for(size_t i = 0; i < width; i++) {
@ -21,7 +21,7 @@ void pixel_format_rgb32::decode(uint32_t* target, const uint8_t* src, size_t wid
}
void pixel_format_rgb32::decode(uint64_t* target, const uint8_t* src, size_t width,
const pixel_format_aux_palette<true>& auxp) throw()
const framebuffer::auxpalette<true>& auxp) throw()
{
const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
for(size_t i = 0; i < width; i++) {
@ -32,7 +32,7 @@ void pixel_format_rgb32::decode(uint64_t* target, const uint8_t* src, size_t wid
}
}
void pixel_format_rgb32::set_palette(pixel_format_aux_palette<false>& auxp, uint8_t rshift, uint8_t gshift,
void pixel_format_rgb32::set_palette(framebuffer::auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.rshift = rshift;
@ -41,7 +41,7 @@ void pixel_format_rgb32::set_palette(pixel_format_aux_palette<false>& auxp, uint
auxp.pcache.clear();
}
void pixel_format_rgb32::set_palette(pixel_format_aux_palette<true>& auxp, uint8_t rshift, uint8_t gshift,
void pixel_format_rgb32::set_palette(framebuffer::auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.rshift = rshift;

View file

@ -10,15 +10,15 @@ namespace
int _dyn[8] = { 1, 1, 0, 0,-1,-1, 0, 0};
int _dxp[8] = { 0, 1, 1, 0, 0,-1,-1, 0};
int _dyp[8] = { 1, 0, 0,-1,-1, 0, 0, 1};
struct render_object_arrow : public render_object
struct render_object_arrow : public framebuffer::object
{
render_object_arrow(int32_t _x, int32_t _y, uint32_t _length, uint32_t _width,
uint32_t _headwidth, uint32_t _headthickness, int _direction, bool _fill,
premultiplied_color _color) throw()
framebuffer::color _color) throw()
: x(_x), y(_y), length(_length), width(_width), headwidth(_headwidth),
headthickness(_headthickness), direction(_direction), fill(_fill), color(_color) {}
~render_object_arrow() throw() {}
template<bool X> void op(struct framebuffer<X>& scr) throw()
template<bool X> void op(struct framebuffer::fb<X>& scr) throw()
{
color.set_palette(scr);
uint32_t originx = scr.get_origin_x();
@ -42,9 +42,9 @@ namespace
}
}
}
void operator()(struct framebuffer<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer<false>& scr) throw() { op(scr); }
void clone(render_queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
void operator()(struct framebuffer::fb<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer::fb<false>& scr) throw() { op(scr); }
void clone(framebuffer::queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
private:
std::pair<int32_t, int32_t> offsetrange()
{
@ -85,7 +85,7 @@ namespace
uint32_t headthickness;
int direction;
bool fill;
premultiplied_color color;
framebuffer::color color;
};
function_ptr_luafun gui_box(lua_func_misc, "gui.arrow", [](lua_state& L, const std::string& fname) -> int {

View file

@ -69,7 +69,7 @@ std::vector<char> lua_dbitmap::save_png() const
img.has_alpha = false;
img.data.resize(width * height);
for(size_t i = 0; i < width * height; i++) {
const premultiplied_color& c = pixels[i];
const framebuffer::color& c = pixels[i];
if(c.origa != 256)
img.has_alpha = true;
img.data[i] = c.orig + ((uint32_t)(c.origa - (c.origa >> 7) + (c.origa >> 8)) << 24);
@ -93,7 +93,7 @@ std::vector<char> lua_bitmap::save_png(const lua_palette& pal) const
img.data[i] = pixels[i];
}
for(size_t i = 0; i < pal.colors.size(); i++) {
const premultiplied_color& c = pal.colors[i];
const framebuffer::color& c = pal.colors[i];
if(c.origa != 256)
img.has_alpha = true;
img.palette[i] = c.orig + ((uint32_t)(c.origa - (c.origa >> 7) + (c.origa >> 8)) << 24);
@ -108,7 +108,7 @@ namespace
{
const char* base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
struct render_object_bitmap : public render_object
struct render_object_bitmap : public framebuffer::object
{
render_object_bitmap(int32_t _x, int32_t _y, lua_obj_pin<lua_bitmap> _bitmap,
lua_obj_pin<lua_palette> _palette) throw()
@ -137,7 +137,7 @@ namespace
kill_request_ifeq(b2.object(), obj);
}
template<bool T> void composite_op(struct framebuffer<T>& scr) throw()
template<bool T> void composite_op(struct framebuffer::fb<T>& scr) throw()
{
if(p)
p->palette_mutex.lock();
@ -145,7 +145,7 @@ namespace
uint32_t originy = scr.get_origin_y();
size_t pallim = 0;
size_t w, h;
premultiplied_color* palette;
framebuffer::color* palette;
if(b) {
palette = &p->colors[0];
for(auto& c : p->colors)
@ -164,10 +164,10 @@ namespace
int32_t xmax = w;
int32_t ymin = 0;
int32_t ymax = h;
clip_range(originx, scr.get_width(), x, xmin, xmax);
clip_range(originy, scr.get_height(), y, ymin, ymax);
framebuffer::clip_range(originx, scr.get_width(), x, xmin, xmax);
framebuffer::clip_range(originy, scr.get_height(), y, ymin, ymax);
for(int32_t r = ymin; r < ymax; r++) {
typename framebuffer<T>::element_t* rptr = scr.rowptr(y + r + originy);
typename framebuffer::fb<T>::element_t* rptr = scr.rowptr(y + r + originy);
size_t eptr = x + xmin + originx;
if(b)
for(int32_t c = xmin; c < xmax; c++, eptr++) {
@ -182,9 +182,9 @@ namespace
if(p)
p->palette_mutex.unlock();
}
void operator()(struct framebuffer<false>& x) throw() { composite_op(x); }
void operator()(struct framebuffer<true>& x) throw() { composite_op(x); }
void clone(render_queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
void operator()(struct framebuffer::fb<false>& x) throw() { composite_op(x); }
void operator()(struct framebuffer::fb<true>& x) throw() { composite_op(x); }
void clone(framebuffer::queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
private:
int32_t x;
int32_t y;
@ -230,7 +230,7 @@ namespace
L.get_numeric_argument<int64_t>(4, c, fname.c_str());
lua_dbitmap* b = lua_class<lua_dbitmap>::create(L, w, h);
for(size_t i = 0; i < b->width * b->height; i++)
b->pixels[i] = premultiplied_color(c);
b->pixels[i] = framebuffer::color(c);
} else {
uint16_t c = 0;
L.get_numeric_argument<uint16_t>(4, c, fname.c_str());
@ -246,7 +246,7 @@ namespace
lua_palette* p = lua_class<lua_palette>::get(L, 1, fname.c_str());
uint16_t c = L.get_numeric_argument<uint16_t>(2, fname.c_str());
int64_t nval = L.get_numeric_argument<int64_t>(3, fname.c_str());
premultiplied_color nc(nval);
framebuffer::color nc(nval);
//The mutex lock protects only the internals of colors array.
if(p->colors.size() <= c) {
p->palette_mutex.lock();
@ -272,13 +272,13 @@ namespace
int64_t c = L.get_numeric_argument<int64_t>(4, fname.c_str());
if(x >= b->width || y >= b->height)
return 0;
b->pixels[y * b->width + x] = premultiplied_color(c);
b->pixels[y * b->width + x] = framebuffer::color(c);
} else
throw std::runtime_error("Expected BITMAP or DBITMAP as argument 1 for gui.bitmap_pset.");
return 0;
});
inline int64_t demultiply_color(const premultiplied_color& c)
inline int64_t demultiply_color(const framebuffer::color& c)
{
if(!c.origa)
return -1;
@ -391,18 +391,18 @@ namespace
struct colorkey_none
{
bool iskey(uint16_t& c) const { return false; }
bool iskey(premultiplied_color& c) const { return false; }
bool iskey(framebuffer::color& c) const { return false; }
};
struct colorkey_direct
{
colorkey_direct(uint64_t _ck)
{
premultiplied_color c(_ck);
framebuffer::color c(_ck);
ck = c.orig;
cka = c.origa;
}
bool iskey(premultiplied_color& c) const { return (c.orig == ck && c.origa == cka); }
bool iskey(framebuffer::color& c) const { return (c.orig == ck && c.origa == cka); }
uint32_t ck;
uint16_t cka;
};
@ -428,14 +428,14 @@ namespace
}
void copy(size_t didx, size_t sidx)
{
premultiplied_color c = sarray[sidx];
framebuffer::color c = sarray[sidx];
if(!ckey.iskey(c))
darray[didx] = c;
}
size_t swidth, sheight, dwidth, dheight;
private:
premultiplied_color* sarray;
premultiplied_color* darray;
framebuffer::color* sarray;
framebuffer::color* darray;
const colorkey& ckey;
};
@ -466,7 +466,7 @@ namespace
template<class colorkey> struct srcdest_paletted
{
typedef premultiplied_color ptype;
typedef framebuffer::color ptype;
srcdest_paletted(lua_dbitmap& dest, lua_bitmap& src, lua_palette& palette, const colorkey& _ckey)
: ckey(_ckey), transparent(-1)
{
@ -488,10 +488,10 @@ namespace
size_t swidth, sheight, dwidth, dheight;
private:
uint16_t* sarray;
premultiplied_color* darray;
premultiplied_color* pal;
framebuffer::color* darray;
framebuffer::color* pal;
uint32_t limit;
premultiplied_color transparent;
framebuffer::color transparent;
const colorkey& ckey;
};
@ -580,7 +580,7 @@ namespace
if(bitmap.d) {
lua_dbitmap* b = lua_class<lua_dbitmap>::create(L, bitmap.w, bitmap.h);
for(size_t i = 0; i < bitmap.w * bitmap.h; i++)
b->pixels[i] = premultiplied_color(bitmap.bitmap[i]);
b->pixels[i] = framebuffer::color(bitmap.bitmap[i]);
return 1;
} else {
lua_bitmap* b = lua_class<lua_bitmap>::create(L, bitmap.w, bitmap.h);
@ -589,7 +589,7 @@ namespace
b->pixels[i] = bitmap.bitmap[i];
p->colors.resize(bitmap.palette.size());
for(size_t i = 0; i < bitmap.palette.size(); i++)
p->colors[i] = premultiplied_color(bitmap.palette[i]);
p->colors[i] = framebuffer::color(bitmap.palette[i]);
return 2;
}
}
@ -723,12 +723,12 @@ namespace
b->pixels[i] = img.data[i];
p->colors.resize(img.palette.size());
for(size_t i = 0; i < img.palette.size(); i++)
p->colors[i] = premultiplied_color(mangle_color(img.palette[i]));
p->colors[i] = framebuffer::color(mangle_color(img.palette[i]));
return 2;
} else {
lua_dbitmap* b = lua_class<lua_dbitmap>::create(L, img.width, img.height);
for(size_t i = 0; i < img.width * img.height; i++)
b->pixels[i] = premultiplied_color(mangle_color(img.data[i]));
b->pixels[i] = framebuffer::color(mangle_color(img.data[i]));
return 1;
}
}
@ -815,18 +815,18 @@ namespace
ca = 256 - parse_value<uint16_t>(r[4]);
int64_t clr;
if(ca == 256)
p->colors.push_back(premultiplied_color(-1));
p->colors.push_back(framebuffer::color(-1));
else
p->colors.push_back(premultiplied_color((ca << 24) | (cr << 16)
p->colors.push_back(framebuffer::color((ca << 24) | (cr << 16)
| (cg << 8) | cb));
} else if(r = regex("[ \t]*([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]*", line)) {
int64_t cr, cg, cb;
cr = parse_value<uint8_t>(r[1]);
cg = parse_value<uint8_t>(r[2]);
cb = parse_value<uint8_t>(r[3]);
p->colors.push_back(premultiplied_color((cr << 16) | (cg << 8) | cb));
p->colors.push_back(framebuffer::color((cr << 16) | (cg << 8) | cb));
} else if(regex_match("[ \t]*transparent[ \t]*", line)) {
p->colors.push_back(premultiplied_color(-1));
p->colors.push_back(framebuffer::color(-1));
} else if(!regex_match("[ \t]*(#.*)?", line))
throw std::runtime_error("Invalid line format (" + line + ")");
}
@ -866,7 +866,7 @@ namespace
return 0;
});
inline premultiplied_color tadjust(premultiplied_color c, uint16_t adj)
inline framebuffer::color tadjust(framebuffer::color c, uint16_t adj)
{
uint32_t rgb = c.orig;
uint32_t a = c.origa;
@ -874,9 +874,9 @@ namespace
if(a > 256)
a = 256;
if(a == 0)
return premultiplied_color(-1);
return framebuffer::color(-1);
else
return premultiplied_color(rgb | ((uint32_t)(256 - a) << 24));
return framebuffer::color(rgb | ((uint32_t)(256 - a) << 24));
}
function_ptr_luafun adjust_trans(lua_func_misc, "gui.adjust_transparency", [](lua_state& L,

View file

@ -3,15 +3,15 @@
namespace
{
struct render_object_box : public render_object
struct render_object_box : public framebuffer::object
{
render_object_box(int32_t _x, int32_t _y, int32_t _width, int32_t _height,
premultiplied_color _outline1, premultiplied_color _outline2, premultiplied_color _fill,
framebuffer::color _outline1, framebuffer::color _outline2, framebuffer::color _fill,
int32_t _thickness) throw()
: x(_x), y(_y), width(_width), height(_height), outline1(_outline1), outline2(_outline2),
fill(_fill), thickness(_thickness) {}
~render_object_box() throw() {}
template<bool X> void op(struct framebuffer<X>& scr) throw()
template<bool X> void op(struct framebuffer::fb<X>& scr) throw()
{
outline1.set_palette(scr);
outline2.set_palette(scr);
@ -22,10 +22,10 @@ namespace
int32_t xmax = width;
int32_t ymin = 0;
int32_t ymax = height;
clip_range(originx, scr.get_width(), x, xmin, xmax);
clip_range(originy, scr.get_height(), y, ymin, ymax);
framebuffer::clip_range(originx, scr.get_width(), x, xmin, xmax);
framebuffer::clip_range(originy, scr.get_height(), y, ymin, ymax);
for(int32_t r = ymin; r < ymax; r++) {
typename framebuffer<X>::element_t* rptr = scr.rowptr(y + r + originy);
typename framebuffer::fb<X>::element_t* rptr = scr.rowptr(y + r + originy);
size_t eptr = x + xmin + originx;
for(int32_t c = xmin; c < xmax; c++, eptr++)
if((r < thickness && r <= (width - c)) || (c < thickness && c < (height - r)))
@ -37,17 +37,17 @@ namespace
fill.apply(rptr[eptr]);
}
}
void operator()(struct framebuffer<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer<false>& scr) throw() { op(scr); }
void clone(render_queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
void operator()(struct framebuffer::fb<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer::fb<false>& scr) throw() { op(scr); }
void clone(framebuffer::queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
private:
int32_t x;
int32_t y;
int32_t width;
int32_t height;
premultiplied_color outline1;
premultiplied_color outline2;
premultiplied_color fill;
framebuffer::color outline1;
framebuffer::color outline2;
framebuffer::color fill;
int32_t thickness;
};
@ -66,9 +66,9 @@ namespace
L.get_numeric_argument<int64_t>(6, outline1, fname.c_str());
L.get_numeric_argument<int64_t>(7, outline2, fname.c_str());
L.get_numeric_argument<int64_t>(8, fill, fname.c_str());
premultiplied_color poutline1(outline1);
premultiplied_color poutline2(outline2);
premultiplied_color pfill(fill);
framebuffer::color poutline1(outline1);
framebuffer::color poutline2(outline2);
framebuffer::color pfill(fill);
lua_render_ctx->queue->create_add<render_object_box>(x, y, width, height, poutline1, poutline2,
pfill, thickness);
return 0;

View file

@ -3,10 +3,10 @@
namespace
{
struct render_object_circle : public render_object
struct render_object_circle : public framebuffer::object
{
render_object_circle(int32_t _x, int32_t _y, uint32_t _radius,
premultiplied_color _outline, premultiplied_color _fill, uint32_t _thickness) throw()
framebuffer::color _outline, framebuffer::color _fill, uint32_t _thickness) throw()
: x(_x), y(_y), outline(_outline), fill(_fill)
{
radius = _radius;
@ -18,7 +18,7 @@ namespace
(_radius - _thickness);
}
~render_object_circle() throw() {}
template<bool X> void op(struct framebuffer<X>& scr) throw()
template<bool X> void op(struct framebuffer::fb<X>& scr) throw()
{
outline.set_palette(scr);
fill.set_palette(scr);
@ -28,11 +28,11 @@ namespace
int32_t xmax = radius;
int32_t ymin = -radius;
int32_t ymax = radius;
clip_range(originx, scr.get_width(), x, xmin, xmax);
clip_range(originy, scr.get_height(), y, ymin, ymax);
framebuffer::clip_range(originx, scr.get_width(), x, xmin, xmax);
framebuffer::clip_range(originy, scr.get_height(), y, ymin, ymax);
for(int32_t r = ymin; r < ymax; r++) {
uint64_t pd2 = static_cast<int64_t>(r) * r;
typename framebuffer<X>::element_t* rptr = scr.rowptr(y + r + originy);
typename framebuffer::fb<X>::element_t* rptr = scr.rowptr(y + r + originy);
size_t eptr = x + xmin + originx;
for(int32_t c = xmin; c < xmax; c++, eptr++) {
uint64_t fd2 = pd2 + static_cast<int64_t>(c) * c;
@ -45,17 +45,17 @@ namespace
}
}
}
void operator()(struct framebuffer<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer<false>& scr) throw() { op(scr); }
void clone(render_queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
void operator()(struct framebuffer::fb<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer::fb<false>& scr) throw() { op(scr); }
void clone(framebuffer::queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
private:
int32_t x;
int32_t y;
int32_t radius;
uint64_t radius2;
uint64_t iradius2;
premultiplied_color outline;
premultiplied_color fill;
framebuffer::color outline;
framebuffer::color fill;
};
function_ptr_luafun gui_rectangle(lua_func_misc, "gui.circle", [](lua_state& L, const std::string& fname)
@ -71,8 +71,8 @@ namespace
L.get_numeric_argument<uint32_t>(4, thickness, fname.c_str());
L.get_numeric_argument<int64_t>(5, outline, fname.c_str());
L.get_numeric_argument<int64_t>(6, fill, fname.c_str());
premultiplied_color poutline(outline);
premultiplied_color pfill(fill);
framebuffer::color poutline(outline);
framebuffer::color pfill(fill);
lua_render_ctx->queue->create_add<render_object_circle>(x, y, radius, poutline, pfill, thickness);
return 0;
});

View file

@ -3,12 +3,12 @@
namespace
{
struct render_object_crosshair : public render_object
struct render_object_crosshair : public framebuffer::object
{
render_object_crosshair(int32_t _x, int32_t _y, premultiplied_color _color, uint32_t _length) throw()
render_object_crosshair(int32_t _x, int32_t _y, framebuffer::color _color, uint32_t _length) throw()
: x(_x), y(_y), color(_color), length(_length) {}
~render_object_crosshair() throw() {}
template<bool X> void op(struct framebuffer<X>& scr) throw()
template<bool X> void op(struct framebuffer::fb<X>& scr) throw()
{
color.set_palette(scr);
uint32_t originx = scr.get_origin_x();
@ -17,8 +17,8 @@ namespace
int32_t xmax = static_cast<int32_t>(length + 1);
int32_t ymin = -static_cast<int32_t>(length);
int32_t ymax = static_cast<int32_t>(length + 1);
clip_range(originx, scr.get_width(), x, xmin, xmax);
clip_range(originy, scr.get_height(), y, ymin, ymax);
framebuffer::clip_range(originx, scr.get_width(), x, xmin, xmax);
framebuffer::clip_range(originy, scr.get_height(), y, ymin, ymax);
if(xmin <= 0 && xmax > 0)
for(int32_t r = ymin; r < ymax; r++)
color.apply(scr.rowptr(y + r + originy)[x + originx]);
@ -26,13 +26,13 @@ namespace
for(int32_t r = xmin; r < xmax; r++)
color.apply(scr.rowptr(y + originy)[x + r + originx]);
}
void operator()(struct framebuffer<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer<false>& scr) throw() { op(scr); }
void clone(render_queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
void operator()(struct framebuffer::fb<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer::fb<false>& scr) throw() { op(scr); }
void clone(framebuffer::queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
private:
int32_t x;
int32_t y;
premultiplied_color color;
framebuffer::color color;
uint32_t length;
};
@ -46,7 +46,7 @@ namespace
int32_t y = L.get_numeric_argument<int32_t>(2, fname.c_str());
L.get_numeric_argument<uint32_t>(3, length, fname.c_str());
L.get_numeric_argument<int64_t>(4, color, fname.c_str());
premultiplied_color pcolor(color);
framebuffer::color pcolor(color);
lua_render_ctx->queue->create_add<render_object_crosshair>(x, y, pcolor, length);
return 0;
});

View file

@ -3,13 +3,13 @@
namespace
{
struct render_object_line : public render_object
struct render_object_line : public framebuffer::object
{
render_object_line(int32_t _x1, int32_t _x2, int32_t _y1, int32_t _y2, premultiplied_color _color)
render_object_line(int32_t _x1, int32_t _x2, int32_t _y1, int32_t _y2, framebuffer::color _color)
throw()
: x1(_x1), y1(_y1), x2(_x2), y2(_y2), color(_color) {}
~render_object_line() throw() {}
template<bool X> void op(struct framebuffer<X>& scr) throw()
template<bool X> void op(struct framebuffer::fb<X>& scr) throw()
{
size_t swidth = scr.get_width();
size_t sheight = scr.get_height();
@ -78,15 +78,15 @@ nodraw2:
}
}
}
void operator()(struct framebuffer<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer<false>& scr) throw() { op(scr); }
void clone(render_queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
void operator()(struct framebuffer::fb<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer::fb<false>& scr) throw() { op(scr); }
void clone(framebuffer::queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
private:
int32_t x1;
int32_t y1;
int32_t x2;
int32_t y2;
premultiplied_color color;
framebuffer::color color;
};
function_ptr_luafun gui_pixel(lua_func_misc, "gui.line", [](lua_state& L, const std::string& fname) -> int {
@ -98,7 +98,7 @@ nodraw2:
int32_t x2 = L.get_numeric_argument<int32_t>(3, fname.c_str());
int32_t y2 = L.get_numeric_argument<int32_t>(4, fname.c_str());
L.get_numeric_argument<int64_t>(5, color, fname.c_str());
premultiplied_color pcolor(color);
framebuffer::color pcolor(color);
lua_render_ctx->queue->create_add<render_object_line>(x1, x2, y1, y2, pcolor);
return 0;
});

View file

@ -3,12 +3,12 @@
namespace
{
struct render_object_pixel : public render_object
struct render_object_pixel : public framebuffer::object
{
render_object_pixel(int32_t _x, int32_t _y, premultiplied_color _color) throw()
render_object_pixel(int32_t _x, int32_t _y, framebuffer::color _color) throw()
: x(_x), y(_y), color(_color) {}
~render_object_pixel() throw() {}
template<bool X> void op(struct framebuffer<X>& scr) throw()
template<bool X> void op(struct framebuffer::fb<X>& scr) throw()
{
color.set_palette(scr);
int32_t _x = x + scr.get_origin_x();
@ -19,13 +19,13 @@ namespace
return;
color.apply(scr.rowptr(_y)[_x]);
}
void operator()(struct framebuffer<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer<false>& scr) throw() { op(scr); }
void clone(render_queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
void operator()(struct framebuffer::fb<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer::fb<false>& scr) throw() { op(scr); }
void clone(framebuffer::queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
private:
int32_t x;
int32_t y;
premultiplied_color color;
framebuffer::color color;
};
function_ptr_luafun gui_pixel(lua_func_misc, "gui.pixel", [](lua_state& L, const std::string& fname) -> int {
@ -35,7 +35,7 @@ namespace
int32_t x = L.get_numeric_argument<int32_t>(1, fname.c_str());
int32_t y = L.get_numeric_argument<int32_t>(2, fname.c_str());
L.get_numeric_argument<int64_t>(3, color, fname.c_str());
premultiplied_color pcolor(color);
framebuffer::color pcolor(color);
lua_render_ctx->queue->create_add<render_object_pixel>(x, y, pcolor);
return 0;
});

View file

@ -3,14 +3,14 @@
namespace
{
struct render_object_rectangle : public render_object
struct render_object_rectangle : public framebuffer::object
{
render_object_rectangle(int32_t _x, int32_t _y, int32_t _width, int32_t _height,
premultiplied_color _outline, premultiplied_color _fill, int32_t _thickness) throw()
framebuffer::color _outline, framebuffer::color _fill, int32_t _thickness) throw()
: x(_x), y(_y), width(_width), height(_height), outline(_outline), fill(_fill),
thickness(_thickness) {}
~render_object_rectangle() throw() {}
template<bool X> void op(struct framebuffer<X>& scr) throw()
template<bool X> void op(struct framebuffer::fb<X>& scr) throw()
{
outline.set_palette(scr);
fill.set_palette(scr);
@ -20,10 +20,10 @@ namespace
int32_t xmax = width;
int32_t ymin = 0;
int32_t ymax = height;
clip_range(originx, scr.get_width(), x, xmin, xmax);
clip_range(originy, scr.get_height(), y, ymin, ymax);
framebuffer::clip_range(originx, scr.get_width(), x, xmin, xmax);
framebuffer::clip_range(originy, scr.get_height(), y, ymin, ymax);
for(int32_t r = ymin; r < ymax; r++) {
typename framebuffer<X>::element_t* rptr = scr.rowptr(y + r + originy);
typename framebuffer::fb<X>::element_t* rptr = scr.rowptr(y + r + originy);
size_t eptr = x + xmin + originx;
for(int32_t c = xmin; c < xmax; c++, eptr++)
if(r < thickness || c < thickness || r >= height - thickness ||
@ -33,16 +33,16 @@ namespace
fill.apply(rptr[eptr]);
}
}
void operator()(struct framebuffer<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer<false>& scr) throw() { op(scr); }
void clone(render_queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
void operator()(struct framebuffer::fb<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer::fb<false>& scr) throw() { op(scr); }
void clone(framebuffer::queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
private:
int32_t x;
int32_t y;
int32_t width;
int32_t height;
premultiplied_color outline;
premultiplied_color fill;
framebuffer::color outline;
framebuffer::color fill;
int32_t thickness;
};
@ -60,8 +60,8 @@ namespace
L.get_numeric_argument<uint32_t>(5, thickness, fname.c_str());
L.get_numeric_argument<int64_t>(6, outline, fname.c_str());
L.get_numeric_argument<int64_t>(7, fill, fname.c_str());
premultiplied_color poutline(outline);
premultiplied_color pfill(fill);
framebuffer::color poutline(outline);
framebuffer::color pfill(fill);
lua_render_ctx->queue->create_add<render_object_rectangle>(x, y, width, height, poutline, pfill,
thickness);
return 0;

View file

@ -28,7 +28,7 @@ namespace
return (stringfmt() << s << " " << ((s != 1) ? "objects" : "object")).str();
}
private:
render_queue rqueue;
framebuffer::queue rqueue;
lua_render_context lctx;
};

View file

@ -32,15 +32,15 @@ DECLARE_LUACLASS(lua_customfont, "CUSTOMFONT");
namespace
{
struct render_object_text_cf : public render_object
struct render_object_text_cf : public framebuffer::object
{
render_object_text_cf(int32_t _x, int32_t _y, const std::string& _text, premultiplied_color _fg,
premultiplied_color _bg, premultiplied_color _hl, lua_obj_pin<lua_customfont> _font) throw()
render_object_text_cf(int32_t _x, int32_t _y, const std::string& _text, framebuffer::color _fg,
framebuffer::color _bg, framebuffer::color _hl, lua_obj_pin<lua_customfont> _font) throw()
: x(_x), y(_y), text(_text), fg(_fg), bg(_bg), hl(_hl), font(_font) {}
~render_object_text_cf() throw()
{
}
template<bool X> void op(struct framebuffer<X>& scr) throw()
template<bool X> void op(struct framebuffer::fb<X>& scr) throw()
{
fg.set_palette(scr);
bg.set_palette(scr);
@ -79,16 +79,16 @@ namespace
{
return kill_request_ifeq(font.object(), obj);
}
void operator()(struct framebuffer<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer<false>& scr) throw() { op(scr); }
void clone(render_queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
void operator()(struct framebuffer::fb<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer::fb<false>& scr) throw() { op(scr); }
void clone(framebuffer::queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
private:
int32_t x;
int32_t y;
std::string text;
premultiplied_color fg;
premultiplied_color bg;
premultiplied_color hl;
framebuffer::color fg;
framebuffer::color bg;
framebuffer::color hl;
lua_obj_pin<lua_customfont> font;
};
@ -132,9 +132,9 @@ namespace
L.get_numeric_argument<int64_t>(7, hlc, fname.c_str());
std::string text = L.get_string(4, fname.c_str());
auto f = lua_class<lua_customfont>::pin(L, 1, fname.c_str());
premultiplied_color fg(fgc);
premultiplied_color bg(bgc);
premultiplied_color hl(hlc);
framebuffer::color fg(fgc);
framebuffer::color bg(bgc);
framebuffer::color hl(hlc);
lua_render_ctx->queue->create_add<render_object_text_cf>(_x, _y, text, fg, bg, hl, f);
return 0;
}

View file

@ -4,27 +4,27 @@
namespace
{
struct render_object_text : public render_object
struct render_object_text : public framebuffer::object
{
render_object_text(int32_t _x, int32_t _y, const std::string& _text, premultiplied_color _fg,
premultiplied_color _bg, bool _hdbl = false, bool _vdbl = false) throw()
render_object_text(int32_t _x, int32_t _y, const std::string& _text, framebuffer::color _fg,
framebuffer::color _bg, bool _hdbl = false, bool _vdbl = false) throw()
: x(_x), y(_y), text(_text), fg(_fg), bg(_bg), hdbl(_hdbl), vdbl(_vdbl) {}
~render_object_text() throw() {}
template<bool X> void op(struct framebuffer<X>& scr) throw()
template<bool X> void op(struct framebuffer::fb<X>& scr) throw()
{
fg.set_palette(scr);
bg.set_palette(scr);
main_font.render(scr, x, y, text, fg, bg, hdbl, vdbl);
}
void operator()(struct framebuffer<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer<false>& scr) throw() { op(scr); }
void clone(render_queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
void operator()(struct framebuffer::fb<true>& scr) throw() { op(scr); }
void operator()(struct framebuffer::fb<false>& scr) throw() { op(scr); }
void clone(framebuffer::queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
private:
int32_t x;
int32_t y;
std::string text;
premultiplied_color fg;
premultiplied_color bg;
framebuffer::color fg;
framebuffer::color bg;
bool hdbl;
bool vdbl;
};
@ -40,8 +40,8 @@ namespace
L.get_numeric_argument<int64_t>(4, fgc, fname.c_str());
L.get_numeric_argument<int64_t>(5, bgc, fname.c_str());
std::string text = L.get_string(3, fname.c_str());
premultiplied_color fg(fgc);
premultiplied_color bg(bgc);
framebuffer::color fg(fgc);
framebuffer::color bg(bgc);
lua_render_ctx->queue->create_add<render_object_text>(_x, _y, text, fg, bg, hdbl, vdbl);
return 0;
}

View file

@ -160,7 +160,7 @@ namespace
mutex_class mutex;
};
struct render_object_tilemap : public render_object
struct render_object_tilemap : public framebuffer::object
{
render_object_tilemap(int32_t _x, int32_t _y, int32_t _x0, int32_t _y0, uint32_t _w,
uint32_t _h, lua_obj_pin<tilemap> _map)
@ -172,7 +172,7 @@ namespace
{
return kill_request_ifeq(map.object(), obj);
}
template<bool T> void composite_op(struct framebuffer<T>& scr) throw()
template<bool T> void composite_op(struct framebuffer::fb<T>& scr) throw()
{
tilemap& _map = *map;
umutex_class h(_map.mutex);
@ -184,7 +184,7 @@ namespace
}
}
}
template<bool T> void composite_op(struct framebuffer<T>& scr, int32_t xp,
template<bool T> void composite_op(struct framebuffer::fb<T>& scr, int32_t xp,
int32_t yp, int32_t xmin, int32_t xmax, int32_t ymin, int32_t ymax, lua_dbitmap& d) throw()
{
if(xmin >= xmax || ymin >= ymax) return;
@ -192,26 +192,26 @@ namespace
c.set_palette(scr);
for(int32_t r = ymin; r < ymax; r++) {
typename framebuffer<T>::element_t* rptr = scr.rowptr(yp + r);
typename framebuffer::fb<T>::element_t* rptr = scr.rowptr(yp + r);
size_t eptr = xp + xmin;
for(int32_t c = xmin; c < xmax; c++, eptr++)
d.pixels[r * d.width + c].apply(rptr[eptr]);
}
}
template<bool T> void composite_op(struct framebuffer<T>& scr, int32_t xp,
template<bool T> void composite_op(struct framebuffer::fb<T>& scr, int32_t xp,
int32_t yp, int32_t xmin, int32_t xmax, int32_t ymin, int32_t ymax, lua_bitmap& b,
lua_palette& p)
throw()
{
if(xmin >= xmax || ymin >= ymax) return;
p.palette_mutex.lock();
premultiplied_color* palette = &p.colors[0];
framebuffer::color* palette = &p.colors[0];
for(auto& c : p.colors)
c.set_palette(scr);
size_t pallim = p.colors.size();
for(int32_t r = ymin; r < ymax; r++) {
typename framebuffer<T>::element_t* rptr = scr.rowptr(yp + r);
typename framebuffer::fb<T>::element_t* rptr = scr.rowptr(yp + r);
size_t eptr = xp + xmin;
for(int32_t c = xmin; c < xmax; c++, eptr++) {
uint16_t i = b.pixels[r * b.width + c];
@ -221,7 +221,7 @@ namespace
}
p.palette_mutex.unlock();
}
template<bool T> void composite_op(struct framebuffer<T>& scr, tilemap_entry& e, int32_t bx,
template<bool T> void composite_op(struct framebuffer::fb<T>& scr, tilemap_entry& e, int32_t bx,
int32_t by) throw()
{
size_t _w, _h;
@ -262,9 +262,9 @@ namespace
if(scrc + cmax > bc + d)
cmax = bc + d - scrc;
}
void operator()(struct framebuffer<false>& x) throw() { composite_op(x); }
void operator()(struct framebuffer<true>& x) throw() { composite_op(x); }
void clone(render_queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
void operator()(struct framebuffer::fb<false>& x) throw() { composite_op(x); }
void operator()(struct framebuffer::fb<true>& x) throw() { composite_op(x); }
void clone(framebuffer::queue& q) const throw(std::bad_alloc) { q.clone_helper(this); }
private:
int32_t x;
int32_t y;

View file

@ -13,7 +13,7 @@ namespace
function_ptr_luafun lua_gui_screenshot_b(lua_func_misc, "gui.screenshot_bitmap", [](lua_state& L,
const std::string& fname) -> int {
framebuffer_raw& _fb = render_get_latest_screen();
framebuffer::raw& _fb = render_get_latest_screen();
try {
auto osize = std::make_pair(_fb.get_width(), _fb.get_height());
std::vector<uint32_t> tmp(_fb.get_width());
@ -22,7 +22,7 @@ namespace
_fb.get_format()->decode(&tmp[0], _fb.get_start() + _fb.get_stride() * y,
_fb.get_width());
for(size_t x = 0; x < osize.first; x++)
b->pixels[y * b->width + x] = premultiplied_color(tmp[x]);
b->pixels[y * b->width + x] = framebuffer::color(tmp[x]);
}
} catch(...) {
render_get_latest_screen_end();

View file

@ -1397,8 +1397,8 @@ void wxeditor_movie::_moviepanel::popup_axis_panel(uint64_t row, control_info ci
});
signal_repaint();
} else if(ci.axistype == port_controller_button::TYPE_LIGHTGUN) {
framebuffer_raw& _fb = render_get_latest_screen();
framebuffer<false> fb;
framebuffer::raw& _fb = render_get_latest_screen();
framebuffer::fb<false> fb;
auto osize = std::make_pair(_fb.get_width(), _fb.get_height());
auto size = our_rom.rtype->lightgun_scale();
fb.reallocate(osize.first, osize.second, false);

View file

@ -248,8 +248,8 @@ void wxeditor_tasinput::xypanel::on_paint(wxPaintEvent& e)
wxPaintDC dc(graphics);
if(lightgun) {
//Draw the current screen.
framebuffer_raw& _fb = render_get_latest_screen();
framebuffer<false> fb;
framebuffer::raw& _fb = render_get_latest_screen();
framebuffer::fb<false> fb;
auto osize = std::make_pair(_fb.get_width(), _fb.get_height());
auto size = our_rom.rtype->lightgun_scale();
fb.reallocate(osize.first, osize.second, false);

View file

@ -58,7 +58,7 @@ void text_framebuffer::render(char* tbuffer)
break; //No more space in row.
char* cellbase = tbuffer + y * (16 * stride) + xp * cellstride;
const element& e = buffer[y * width + x];
const bitmap_font::glyph& g = main_font.get_glyph(e.ch);
const framebuffer::font::glyph& g = main_font.get_glyph(e.ch);
char bgb = (e.bg >> 16);
char bgg = (e.bg >> 8);
char bgr = (e.bg >> 0);
@ -155,7 +155,7 @@ size_t text_framebuffer::write(const std::string& str, size_t w, size_t x, size_
continue;
}
//Okay, got u to write...
const bitmap_font::glyph& g = main_font.get_glyph(u);
const framebuffer::font::glyph& g = main_font.get_glyph(u);
if(x < width) {
element& e = buffer[y * width + x];
e.ch = u;
@ -190,7 +190,7 @@ size_t text_framebuffer::write(const std::u32string& str, size_t w, size_t x, si
size_t slen = str.length();
size_t pused = 0;
for(auto u : str) {
const bitmap_font::glyph& g = main_font.get_glyph(u);
const framebuffer::font::glyph& g = main_font.get_glyph(u);
if(x < width) {
element& e = buffer[y * width + x];
e.ch = u;

View file

@ -63,7 +63,7 @@ namespace
{
}
void on_frame(struct framebuffer_raw& _frame, uint32_t fps_n, uint32_t fps_d)
void on_frame(struct framebuffer::raw& _frame, uint32_t fps_n, uint32_t fps_d)
{
frames_dumped++;
if(frames_dumped % 100 == 0) {

View file

@ -344,7 +344,7 @@ again:
delete soxdumper;
}
void on_frame(struct framebuffer_raw& _frame, uint32_t fps_n, uint32_t fps_d)
void on_frame(struct framebuffer::raw& _frame, uint32_t fps_n, uint32_t fps_d)
{
uint32_t hscl = 1;
uint32_t vscl = 1;
@ -419,7 +419,7 @@ again:
resample_worker* resampler_w;
private:
sox_dumper* soxdumper;
framebuffer<false> dscr;
framebuffer::fb<false> dscr;
unsigned dcounter;
bool have_dumped_frame;
std::pair<uint32_t, uint32_t> soundrate;

View file

@ -90,7 +90,7 @@ namespace
}
}
void on_frame(struct framebuffer_raw& _frame, uint32_t fps_n, uint32_t fps_d)
void on_frame(struct framebuffer::raw& _frame, uint32_t fps_n, uint32_t fps_d)
{
if(!render_video_hud(dscr, _frame, 1, 1, 0, 8, 16, 0, 0, 0, 0, NULL)) {
akill += killed_audio_length(fps_n, fps_d, akillfrac);
@ -184,7 +184,7 @@ namespace
return ret;
}
framebuffer<false> dscr;
framebuffer::fb<false> dscr;
unsigned dcounter;
bool have_dumped_frame;
uint64_t audio_w;

View file

@ -135,7 +135,7 @@ namespace
pclose(video);
}
void on_frame(struct framebuffer_raw& _frame, uint32_t fps_n, uint32_t fps_d)
void on_frame(struct framebuffer::raw& _frame, uint32_t fps_n, uint32_t fps_d)
{
unsigned r, g, b;
unsigned short magic = 258;
@ -216,7 +216,7 @@ namespace
FILE* video;
sox_dumper* audio;
bool have_dumped_frame;
struct framebuffer<false> dscr;
struct framebuffer::fb<false> dscr;
bool upsidedown;
bool bits32;
std::string cmd;

View file

@ -76,7 +76,7 @@ namespace
deleter(audio);
}
void on_frame(struct framebuffer_raw& _frame, uint32_t fps_n, uint32_t fps_d)
void on_frame(struct framebuffer::raw& _frame, uint32_t fps_n, uint32_t fps_d)
{
if(!video)
return;
@ -146,8 +146,8 @@ namespace
std::ostream* video;
void (*deleter)(void* f);
bool have_dumped_frame;
struct framebuffer<false> dscr;
struct framebuffer<true> dscr2;
struct framebuffer::fb<false> dscr;
struct framebuffer::fb<true> dscr2;
bool swap;
bool bits64;
};