Further framebuffer refactoring (pixel formats)

This commit is contained in:
Ilari Liusvaara 2013-12-19 06:51:54 +02:00
parent dce933b76d
commit 10dbbf278d
22 changed files with 270 additions and 241 deletions

View file

@ -0,0 +1,33 @@
#ifndef _library__framebuffer_pixfmt_lrgb__hpp__included__
#define _library__framebuffer_pixfmt_lrgb__hpp__included__
#include "framebuffer.hpp"
namespace framebuffer
{
/**
* Pixel format LRGB (bsnes).
*/
class _pixfmt_lrgb : public pixfmt
{
public:
~_pixfmt_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 auxpalette<false>& auxp) throw();
void decode(uint64_t* target, const uint8_t* src, size_t width,
const auxpalette<true>& auxp) throw();
void set_palette(auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc);
void set_palette(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();
uint32_t get_magic() throw();
};
extern _pixfmt_lrgb pixfmt_lrgb;
}
#endif

View file

@ -0,0 +1,35 @@
#ifndef _library__framebuffer_pixfmt_rgb15__hpp__included__
#define _library__framebuffer_pixfmt_rgb15__hpp__included__
#include "framebuffer.hpp"
namespace framebuffer
{
/**
* Pixel format RGB15 (5:5:5).
*/
template<bool uvswap>
class _pixfmt_rgb15 : public pixfmt
{
public:
~_pixfmt_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 auxpalette<false>& auxp) throw();
void decode(uint64_t* target, const uint8_t* src, size_t width,
const auxpalette<true>& auxp) throw();
void set_palette(auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc);
void set_palette(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();
uint32_t get_magic() throw();
};
extern _pixfmt_rgb15<false> pixfmt_rgb15;
extern _pixfmt_rgb15<true> pixfmt_bgr15;
}
#endif

View file

@ -0,0 +1,35 @@
#ifndef _library__framebuffer_pixfmt_rgb16__hpp__included__
#define _library__framebuffer_pixfmt_rgb16__hpp__included__
#include "framebuffer.hpp"
namespace framebuffer
{
/**
* Pixel format RGB16 (5:6:5).
*/
template<bool uvswap>
class _pixfmt_rgb16 : public pixfmt
{
public:
~_pixfmt_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 auxpalette<false>& auxp) throw();
void decode(uint64_t* target, const uint8_t* src, size_t width,
const auxpalette<true>& auxp) throw();
void set_palette(auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc);
void set_palette(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();
uint32_t get_magic() throw();
};
extern _pixfmt_rgb16<false> pixfmt_rgb16;
extern _pixfmt_rgb16<true> pixfmt_bgr16;
}
#endif

View file

@ -0,0 +1,35 @@
#ifndef _library__framebuffer_pixfmt_rgb24__hpp__included__
#define _library__framebuffer_pixfmt_rgb24__hpp__included__
#include "framebuffer.hpp"
namespace framebuffer
{
/**
* Pixel format RGB24.
*/
template<bool uvswap>
class _pixfmt_rgb24 : public pixfmt
{
public:
~_pixfmt_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 auxpalette<false>& auxp) throw();
void decode(uint64_t* target, const uint8_t* src, size_t width,
const auxpalette<true>& auxp) throw();
void set_palette(auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc);
void set_palette(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();
uint32_t get_magic() throw();
};
extern _pixfmt_rgb24<false> pixfmt_rgb24;
extern _pixfmt_rgb24<true> pixfmt_bgr24;
}
#endif

View file

@ -0,0 +1,33 @@
#ifndef _library__framebuffer_pixfmt_rgb32__hpp__included__
#define _library__framebuffer_pixfmt_rgb32__hpp__included__
#include "framebuffer.hpp"
namespace framebuffer
{
/**
* Pixel format RGB32.
*/
class _pixfmt_rgb32 : public pixfmt
{
public:
~_pixfmt_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 auxpalette<false>& auxp) throw();
void decode(uint64_t* target, const uint8_t* src, size_t width,
const auxpalette<true>& auxp) throw();
void set_palette(auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc);
void set_palette(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();
uint32_t get_magic() throw();
};
extern _pixfmt_rgb32 pixfmt_rgb32;
}
#endif

View file

@ -1,30 +0,0 @@
#ifndef _library__pixfmt_lrgb__hpp__included__
#define _library__pixfmt_lrgb__hpp__included__
#include "framebuffer.hpp"
/**
* Pixel format LRGB (bsnes).
*/
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 framebuffer::auxpalette<false>& auxp) throw();
void decode(uint64_t* target, const uint8_t* src, size_t width,
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(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();
uint32_t get_magic() throw();
};
extern pixel_format_lrgb _pixel_format_lrgb;
#endif

View file

@ -1,32 +0,0 @@
#ifndef _library__pixfmt_rgb15__hpp__included__
#define _library__pixfmt_rgb15__hpp__included__
#include "framebuffer.hpp"
/**
* Pixel format RGB15 (5:5:5).
*/
template<bool uvswap>
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 framebuffer::auxpalette<false>& auxp) throw();
void decode(uint64_t* target, const uint8_t* src, size_t width,
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(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();
uint32_t get_magic() throw();
};
extern pixel_format_rgb15<false> _pixel_format_rgb15;
extern pixel_format_rgb15<true> _pixel_format_bgr15;
#endif

View file

@ -1,32 +0,0 @@
#ifndef _library__pixfmt_rgb16__hpp__included__
#define _library__pixfmt_rgb16__hpp__included__
#include "framebuffer.hpp"
/**
* Pixel format RGB16 (5:6:5).
*/
template<bool uvswap>
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 framebuffer::auxpalette<false>& auxp) throw();
void decode(uint64_t* target, const uint8_t* src, size_t width,
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(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();
uint32_t get_magic() throw();
};
extern pixel_format_rgb16<false> _pixel_format_rgb16;
extern pixel_format_rgb16<true> _pixel_format_bgr16;
#endif

View file

@ -1,32 +0,0 @@
#ifndef _library__pixfmt_rgb24__hpp__included__
#define _library__pixfmt_rgb24__hpp__included__
#include "framebuffer.hpp"
/**
* Pixel format RGB24.
*/
template<bool uvswap>
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 framebuffer::auxpalette<false>& auxp) throw();
void decode(uint64_t* target, const uint8_t* src, size_t width,
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(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();
uint32_t get_magic() throw();
};
extern pixel_format_rgb24<false> _pixel_format_rgb24;
extern pixel_format_rgb24<true> _pixel_format_bgr24;
#endif

View file

@ -1,30 +0,0 @@
#ifndef _library__pixfmt_rgb32__hpp__included__
#define _library__pixfmt_rgb32__hpp__included__
#include "framebuffer.hpp"
/**
* Pixel format RGB32.
*/
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 framebuffer::auxpalette<false>& auxp) throw();
void decode(uint64_t* target, const uint8_t* src, size_t width,
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(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();
uint32_t get_magic() throw();
};
extern pixel_format_rgb32 _pixel_format_rgb32;
#endif

View file

@ -10,7 +10,7 @@
#include "lua/lua.hpp"
#include "fonts/wrapper.hpp"
#include "library/framebuffer.hpp"
#include "library/pixfmt-lrgb.hpp"
#include "library/framebuffer-pixfmt-lrgb.hpp"
framebuffer::raw screen_corrupt;
@ -148,7 +148,7 @@ void init_special_screens() throw(std::bad_alloc)
buf.resize(512*448);
framebuffer::info inf;
inf.type = &_pixel_format_lrgb;
inf.type = &framebuffer::pixfmt_lrgb;
inf.mem = reinterpret_cast<char*>(&buf[0]);
inf.physwidth = 512;
inf.physheight = 448;

View file

@ -27,7 +27,6 @@
#include "interface/callbacks.hpp"
#include "interface/romtype.hpp"
#include "library/framebuffer.hpp"
#include "library/pixfmt-lrgb.hpp"
#include "library/zip.hpp"
#include <iomanip>

View file

@ -13,7 +13,7 @@
#include "interface/cover.hpp"
#include "interface/romtype.hpp"
#include "interface/callbacks.hpp"
#include "library/pixfmt-rgb16.hpp"
#include "library/framebuffer-pixfmt-rgb16.hpp"
#include "library/controller-data.hpp"
#include "library/patch.hpp"
#include "library/sha256.hpp"
@ -49,7 +49,7 @@ namespace
//Framebuffer.
struct framebuffer::info null_fbinfo = {
&_pixel_format_bgr16, //Format.
&framebuffer::pixfmt_bgr16, //Format.
(char*)null_cover_fbmem, //Memory.
512, 448, 1024, //Physical size.
512, 448, 1024, //Logical size.

View file

@ -34,7 +34,7 @@
#include "interface/romtype.hpp"
#include "interface/setting.hpp"
#include "interface/callbacks.hpp"
#include "library/pixfmt-lrgb.hpp"
#include "library/framebuffer-pixfmt-lrgb.hpp"
#include "library/string.hpp"
#include "library/controller-data.hpp"
#include "library/framebuffer.hpp"
@ -92,7 +92,7 @@ namespace
//Framebuffer.
struct framebuffer::info cover_fbinfo = {
&_pixel_format_lrgb, //Format.
&framebuffer::pixfmt_lrgb, //Format.
(char*)cover_fbmem, //Memory.
512, 448, 2048, //Physical size.
512, 448, 2048, //Logical size.
@ -1241,7 +1241,7 @@ again2:
fps_d /= g;
framebuffer::info inf;
inf.type = &_pixel_format_lrgb;
inf.type = &framebuffer::pixfmt_lrgb;
inf.mem = const_cast<char*>(reinterpret_cast<const char*>(data));
inf.physwidth = 512;
inf.physheight = 512;

View file

@ -33,7 +33,7 @@
#include "interface/callbacks.hpp"
#include "interface/cover.hpp"
#include "interface/romtype.hpp"
#include "library/pixfmt-rgb32.hpp"
#include "library/framebuffer-pixfmt-rgb32.hpp"
#include "library/string.hpp"
#include "library/controller-data.hpp"
#include "library/serialization.hpp"
@ -110,7 +110,7 @@ namespace
//Framebuffer.
struct framebuffer::info cover_fbinfo = {
&_pixel_format_rgb32, //Format.
&framebuffer::pixfmt_rgb32, //Format.
(char*)cover_fbmem, //Memory.
480, 432, 1920, //Physical size.
480, 432, 1920, //Logical size.
@ -632,7 +632,7 @@ namespace
}
}
framebuffer::info inf;
inf.type = &_pixel_format_rgb32;
inf.type = &framebuffer::pixfmt_rgb32;
inf.mem = const_cast<char*>(reinterpret_cast<const char*>(primary_framebuffer));
inf.physwidth = 160;
inf.physheight = 144;

View file

@ -9,7 +9,7 @@
#include "core/window.hpp"
#include "interface/romtype.hpp"
#include "interface/callbacks.hpp"
#include "library/pixfmt-rgb32.hpp"
#include "library/framebuffer-pixfmt-rgb32.hpp"
namespace sky
{
@ -28,7 +28,7 @@ namespace sky
//Framebuffer.
uint32_t cover_fbmem[320*200];
struct framebuffer::info cover_fbinfo = {
&_pixel_format_rgb32, //Format.
&framebuffer::pixfmt_rgb32, //Format.
(char*)cover_fbmem, //Memory.
320, 200, 1280, //Physical size.
320, 200, 1280, //Logical size.
@ -309,7 +309,7 @@ namespace sky
simulate_frame(corei, x);
uint32_t* fb = corei.get_framebuffer();
framebuffer::info inf;
inf.type = &_pixel_format_rgb32;
inf.type = &framebuffer::pixfmt_rgb32;
inf.mem = const_cast<char*>(reinterpret_cast<const char*>(fb));
inf.physwidth = FB_WIDTH;
inf.physheight = FB_HEIGHT;

View file

@ -31,7 +31,7 @@
#include "interface/callbacks.hpp"
#include "interface/cover.hpp"
#include "interface/romtype.hpp"
#include "library/pixfmt-rgb32.hpp"
#include "library/framebuffer-pixfmt-rgb32.hpp"
#include "library/string.hpp"
#include "library/controller-data.hpp"
#include "library/serialization.hpp"
@ -45,7 +45,7 @@ namespace
//Framebuffer.
struct framebuffer::info cover_fbinfo = {
&_pixel_format_rgb32, //Format.
&framebuffer::pixfmt_rgb32, //Format.
(char*)cover_fbmem, //Memory.
480, 432, 1920, //Physical size.
480, 432, 1920, //Logical size.
@ -150,7 +150,7 @@ namespace
pflag = false;
redraw_screen();
framebuffer::info inf;
inf.type = &_pixel_format_rgb32;
inf.type = &framebuffer::pixfmt_rgb32;
inf.mem = const_cast<char*>(reinterpret_cast<const char*>(cover_fbmem));
inf.physwidth = 480;
inf.physheight = 432;

View file

@ -1,10 +1,12 @@
#include "pixfmt-lrgb.hpp"
#include "framebuffer-pixfmt-lrgb.hpp"
pixel_format_lrgb::~pixel_format_lrgb() throw()
namespace framebuffer
{
_pixfmt_lrgb::~_pixfmt_lrgb() throw()
{
}
void pixel_format_lrgb::decode(uint32_t* target, const uint8_t* src, size_t width)
void _pixfmt_lrgb::decode(uint32_t* target, const uint8_t* src, size_t width)
throw()
{
const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
@ -21,23 +23,23 @@ 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 framebuffer::auxpalette<false>& auxp) throw()
void _pixfmt_lrgb::decode(uint32_t* target, const uint8_t* src, size_t width,
const auxpalette<false>& 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::decode(uint64_t* target, const uint8_t* src, size_t width,
const framebuffer::auxpalette<true>& auxp) throw()
void _pixfmt_lrgb::decode(uint64_t* target, const uint8_t* src, size_t width,
const 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(framebuffer::auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
void _pixfmt_lrgb::set_palette(auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.pcache.resize(0x80000);
@ -55,7 +57,7 @@ void pixel_format_lrgb::set_palette(framebuffer::auxpalette<false>& auxp, uint8_
auxp.bshift = bshift;
}
void pixel_format_lrgb::set_palette(framebuffer::auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
void _pixfmt_lrgb::set_palette(auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.pcache.resize(0x80000);
@ -73,19 +75,20 @@ void pixel_format_lrgb::set_palette(framebuffer::auxpalette<true>& auxp, uint8_t
auxp.bshift = bshift;
}
uint8_t pixel_format_lrgb::get_bpp() throw()
uint8_t _pixfmt_lrgb::get_bpp() throw()
{
return 4;
}
uint8_t pixel_format_lrgb::get_ss_bpp() throw()
uint8_t _pixfmt_lrgb::get_ss_bpp() throw()
{
return 3;
}
uint32_t pixel_format_lrgb::get_magic() throw()
uint32_t _pixfmt_lrgb::get_magic() throw()
{
return 0;
}
pixel_format_lrgb _pixel_format_lrgb;
_pixfmt_lrgb pixfmt_lrgb;
}

View file

@ -1,12 +1,14 @@
#include "pixfmt-rgb15.hpp"
#include "framebuffer-pixfmt-rgb15.hpp"
namespace framebuffer
{
template<bool uvswap>
pixel_format_rgb15<uvswap>::~pixel_format_rgb15() throw()
_pixfmt_rgb15<uvswap>::~_pixfmt_rgb15() throw()
{
}
template<bool uvswap>
void pixel_format_rgb15<uvswap>::decode(uint32_t* target, const uint8_t* src, size_t width)
void _pixfmt_rgb15<uvswap>::decode(uint32_t* target, const uint8_t* src, size_t width)
throw()
{
const uint16_t* _src = reinterpret_cast<const uint16_t*>(src);
@ -22,8 +24,8 @@ 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 framebuffer::auxpalette<false>& auxp) throw()
void _pixfmt_rgb15<uvswap>::decode(uint32_t* target, const uint8_t* src, size_t width,
const auxpalette<false>& auxp) throw()
{
const uint16_t* _src = reinterpret_cast<const uint16_t*>(src);
for(size_t i = 0; i < width; i++)
@ -31,8 +33,8 @@ 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 framebuffer::auxpalette<true>& auxp) throw()
void _pixfmt_rgb15<uvswap>::decode(uint64_t* target, const uint8_t* src, size_t width,
const auxpalette<true>& auxp) throw()
{
const uint16_t* _src = reinterpret_cast<const uint16_t*>(src);
for(size_t i = 0; i < width; i++)
@ -40,7 +42,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(framebuffer::auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
void _pixfmt_rgb15<uvswap>::set_palette(auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.pcache.resize(0x8000);
@ -58,7 +60,7 @@ void pixel_format_rgb15<uvswap>::set_palette(framebuffer::auxpalette<false>& aux
}
template<bool uvswap>
void pixel_format_rgb15<uvswap>::set_palette(framebuffer::auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
void _pixfmt_rgb15<uvswap>::set_palette(auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.pcache.resize(0x8000);
@ -76,19 +78,19 @@ void pixel_format_rgb15<uvswap>::set_palette(framebuffer::auxpalette<true>& auxp
}
template<bool uvswap>
uint8_t pixel_format_rgb15<uvswap>::get_bpp() throw()
uint8_t _pixfmt_rgb15<uvswap>::get_bpp() throw()
{
return 2;
}
template<bool uvswap>
uint8_t pixel_format_rgb15<uvswap>::get_ss_bpp() throw()
uint8_t _pixfmt_rgb15<uvswap>::get_ss_bpp() throw()
{
return 2;
}
template<bool uvswap>
uint32_t pixel_format_rgb15<uvswap>::get_magic() throw()
uint32_t _pixfmt_rgb15<uvswap>::get_magic() throw()
{
if(uvswap)
return 0x16326322;
@ -96,5 +98,6 @@ uint32_t pixel_format_rgb15<uvswap>::get_magic() throw()
return 0x74324563;
}
pixel_format_rgb15<false> _pixel_format_rgb15;
pixel_format_rgb15<true> _pixel_format_bgr15;
_pixfmt_rgb15<false> pixfmt_rgb15;
_pixfmt_rgb15<true> pixfmt_bgr15;
}

View file

@ -1,12 +1,14 @@
#include "pixfmt-rgb16.hpp"
#include "framebuffer-pixfmt-rgb16.hpp"
namespace framebuffer
{
template<bool uvswap>
pixel_format_rgb16<uvswap>::~pixel_format_rgb16() throw()
_pixfmt_rgb16<uvswap>::~_pixfmt_rgb16() throw()
{
}
template<bool uvswap>
void pixel_format_rgb16<uvswap>::decode(uint32_t* target, const uint8_t* src, size_t width) throw()
void _pixfmt_rgb16<uvswap>::decode(uint32_t* target, const uint8_t* src, size_t width) throw()
{
const uint16_t* _src = reinterpret_cast<const uint16_t*>(src);
for(size_t i = 0; i < width; i++) {
@ -21,8 +23,8 @@ 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 framebuffer::auxpalette<false>& auxp) throw()
void _pixfmt_rgb16<uvswap>::decode(uint32_t* target, const uint8_t* src, size_t width,
const auxpalette<false>& auxp) throw()
{
const uint16_t* _src = reinterpret_cast<const uint16_t*>(src);
for(size_t i = 0; i < width; i++)
@ -30,8 +32,8 @@ 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 framebuffer::auxpalette<true>& auxp) throw()
void _pixfmt_rgb16<uvswap>::decode(uint64_t* target, const uint8_t* src, size_t width,
const auxpalette<true>& auxp) throw()
{
const uint16_t* _src = reinterpret_cast<const uint16_t*>(src);
for(size_t i = 0; i < width; i++)
@ -39,7 +41,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(framebuffer::auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
void _pixfmt_rgb16<uvswap>::set_palette(auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.pcache.resize(0x10000);
@ -57,7 +59,7 @@ void pixel_format_rgb16<uvswap>::set_palette(framebuffer::auxpalette<false>& aux
}
template<bool uvswap>
void pixel_format_rgb16<uvswap>::set_palette(framebuffer::auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
void _pixfmt_rgb16<uvswap>::set_palette(auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.pcache.resize(0x10000);
@ -75,19 +77,19 @@ void pixel_format_rgb16<uvswap>::set_palette(framebuffer::auxpalette<true>& auxp
}
template<bool uvswap>
uint8_t pixel_format_rgb16<uvswap>::get_bpp() throw()
uint8_t _pixfmt_rgb16<uvswap>::get_bpp() throw()
{
return 2;
}
template<bool uvswap>
uint8_t pixel_format_rgb16<uvswap>::get_ss_bpp() throw()
uint8_t _pixfmt_rgb16<uvswap>::get_ss_bpp() throw()
{
return 2;
}
template<bool uvswap>
uint32_t pixel_format_rgb16<uvswap>::get_magic() throw()
uint32_t _pixfmt_rgb16<uvswap>::get_magic() throw()
{
if(uvswap)
return 0x74234643;
@ -95,5 +97,6 @@ uint32_t pixel_format_rgb16<uvswap>::get_magic() throw()
return 0x32642474;
}
pixel_format_rgb16<false> _pixel_format_rgb16;
pixel_format_rgb16<true> _pixel_format_bgr16;
_pixfmt_rgb16<false> pixfmt_rgb16;
_pixfmt_rgb16<true> pixfmt_bgr16;
}

View file

@ -1,11 +1,13 @@
#include "pixfmt-rgb24.hpp"
#include "framebuffer-pixfmt-rgb24.hpp"
#include <cstring>
namespace framebuffer
{
template<bool uvswap>
pixel_format_rgb24<uvswap>::~pixel_format_rgb24() throw() {}
_pixfmt_rgb24<uvswap>::~_pixfmt_rgb24() throw() {}
template<bool uvswap>
void pixel_format_rgb24<uvswap>::decode(uint32_t* target, const uint8_t* src, size_t width) throw()
void _pixfmt_rgb24<uvswap>::decode(uint32_t* target, const uint8_t* src, size_t width) throw()
{
if(uvswap) {
for(size_t i = 0; i < width; i++) {
@ -23,8 +25,8 @@ 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 framebuffer::auxpalette<false>& auxp) throw()
void _pixfmt_rgb24<uvswap>::decode(uint32_t* target, const uint8_t* src, size_t width,
const 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;
@ -34,8 +36,8 @@ 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 framebuffer::auxpalette<true>& auxp) throw()
void _pixfmt_rgb24<uvswap>::decode(uint64_t* target, const uint8_t* src, size_t width,
const 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 +48,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(framebuffer::auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
void _pixfmt_rgb24<uvswap>::set_palette(auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.rshift = rshift;
@ -56,7 +58,7 @@ void pixel_format_rgb24<uvswap>::set_palette(framebuffer::auxpalette<false>& aux
}
template<bool uvswap>
void pixel_format_rgb24<uvswap>::set_palette(framebuffer::auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
void _pixfmt_rgb24<uvswap>::set_palette(auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.rshift = rshift;
@ -66,19 +68,19 @@ void pixel_format_rgb24<uvswap>::set_palette(framebuffer::auxpalette<true>& auxp
}
template<bool uvswap>
uint8_t pixel_format_rgb24<uvswap>::get_bpp() throw()
uint8_t _pixfmt_rgb24<uvswap>::get_bpp() throw()
{
return 3;
}
template<bool uvswap>
uint8_t pixel_format_rgb24<uvswap>::get_ss_bpp() throw()
uint8_t _pixfmt_rgb24<uvswap>::get_ss_bpp() throw()
{
return 3;
}
template<bool uvswap>
uint32_t pixel_format_rgb24<uvswap>::get_magic() throw()
uint32_t _pixfmt_rgb24<uvswap>::get_magic() throw()
{
if(uvswap)
return 0x25642332U;
@ -86,5 +88,6 @@ uint32_t pixel_format_rgb24<uvswap>::get_magic() throw()
return 0x85433684U;
}
pixel_format_rgb24<false> _pixel_format_rgb24;
pixel_format_rgb24<true> _pixel_format_bgr24;
_pixfmt_rgb24<false> pixfmt_rgb24;
_pixfmt_rgb24<true> pixfmt_bgr24;
}

View file

@ -1,16 +1,18 @@
#include "pixfmt-rgb32.hpp"
#include "framebuffer-pixfmt-rgb32.hpp"
pixel_format_rgb32::~pixel_format_rgb32() throw() {}
namespace framebuffer
{
_pixfmt_rgb32::~_pixfmt_rgb32() throw() {}
void pixel_format_rgb32::decode(uint32_t* target, const uint8_t* src, size_t width) throw()
void _pixfmt_rgb32::decode(uint32_t* target, const uint8_t* src, size_t width) throw()
{
const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
for(size_t i = 0; i < width; i++)
target[i] = _src[i];
}
void pixel_format_rgb32::decode(uint32_t* target, const uint8_t* src, size_t width,
const framebuffer::auxpalette<false>& auxp) throw()
void _pixfmt_rgb32::decode(uint32_t* target, const uint8_t* src, size_t width,
const auxpalette<false>& auxp) throw()
{
const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
for(size_t i = 0; i < width; i++) {
@ -20,8 +22,8 @@ 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 framebuffer::auxpalette<true>& auxp) throw()
void _pixfmt_rgb32::decode(uint64_t* target, const uint8_t* src, size_t width,
const auxpalette<true>& auxp) throw()
{
const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
for(size_t i = 0; i < width; i++) {
@ -32,7 +34,7 @@ void pixel_format_rgb32::decode(uint64_t* target, const uint8_t* src, size_t wid
}
}
void pixel_format_rgb32::set_palette(framebuffer::auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
void _pixfmt_rgb32::set_palette(auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.rshift = rshift;
@ -41,7 +43,7 @@ void pixel_format_rgb32::set_palette(framebuffer::auxpalette<false>& auxp, uint8
auxp.pcache.clear();
}
void pixel_format_rgb32::set_palette(framebuffer::auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
void _pixfmt_rgb32::set_palette(auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
uint8_t bshift) throw(std::bad_alloc)
{
auxp.rshift = rshift;
@ -50,19 +52,20 @@ void pixel_format_rgb32::set_palette(framebuffer::auxpalette<true>& auxp, uint8_
auxp.pcache.clear();
}
uint8_t pixel_format_rgb32::get_bpp() throw()
uint8_t _pixfmt_rgb32::get_bpp() throw()
{
return 4;
}
uint8_t pixel_format_rgb32::get_ss_bpp() throw()
uint8_t _pixfmt_rgb32::get_ss_bpp() throw()
{
return 3;
}
uint32_t pixel_format_rgb32::get_magic() throw()
uint32_t _pixfmt_rgb32::get_magic() throw()
{
return 0x74212536U;
}
pixel_format_rgb32 _pixel_format_rgb32;
_pixfmt_rgb32 pixfmt_rgb32;
}