(switch) Add support for RETRO_PIXEL_FORMAT_XRGB8888
This commit is contained in:
parent
a039e6c41e
commit
ad695a8b72
|
@ -35,6 +35,7 @@
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
bool vsync;
|
bool vsync;
|
||||||
|
bool rgb32;
|
||||||
unsigned width, height;
|
unsigned width, height;
|
||||||
unsigned rotation;
|
unsigned rotation;
|
||||||
struct video_viewport vp;
|
struct video_viewport vp;
|
||||||
|
@ -110,6 +111,8 @@ static void *switch_init(const video_info_t *video,
|
||||||
video_driver_set_size(&sw->vp.width, &sw->vp.height);
|
video_driver_set_size(&sw->vp.width, &sw->vp.height);
|
||||||
|
|
||||||
sw->vsync = video->vsync;
|
sw->vsync = video->vsync;
|
||||||
|
|
||||||
|
sw->rgb32 = video->rgb32;
|
||||||
|
|
||||||
*input = NULL;
|
*input = NULL;
|
||||||
*input_data = NULL;
|
*input_data = NULL;
|
||||||
|
@ -142,7 +145,6 @@ static bool switch_frame(void *data, const void *frame,
|
||||||
uint64_t begin, done_copying, post_vsync, pre_swizzle, post_swizzle,
|
uint64_t begin, done_copying, post_vsync, pre_swizzle, post_swizzle,
|
||||||
copy_ms, swizzle_ms, vsync_ms;
|
copy_ms, swizzle_ms, vsync_ms;
|
||||||
int tgtw, tgth, centerx, centery;
|
int tgtw, tgth, centerx, centery;
|
||||||
const uint16_t *frame_pixels = frame;
|
|
||||||
uint32_t *out_buffer = NULL;
|
uint32_t *out_buffer = NULL;
|
||||||
switch_video_t *sw = data;
|
switch_video_t *sw = data;
|
||||||
int xsf = 1280 / width;
|
int xsf = 1280 / width;
|
||||||
|
@ -163,21 +165,29 @@ static bool switch_frame(void *data, const void *frame,
|
||||||
{
|
{
|
||||||
for(y = 0; y < height; y++)
|
for(y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
unsigned subx, suby;
|
uint32_t pixel = 0;
|
||||||
uint32_t spixel = frame_pixels[(y*pitch/sizeof(uint16_t)) + x];
|
|
||||||
uint32_t dpixel = 0;
|
if (sw->rgb32)
|
||||||
uint8_t r = (spixel >> 11) & 31;
|
{
|
||||||
uint8_t g = (spixel >> 5) & 63;
|
const uint32_t *frame_pixels = frame;
|
||||||
uint8_t b = (spixel >> 0) & 31;
|
pixel = frame_pixels[(y*pitch/sizeof(uint32_t)) + x];
|
||||||
r = (r * 256) / 32;
|
} else {
|
||||||
g = (g * 256) / 64;
|
const uint16_t *frame_pixels = frame;
|
||||||
b = (b * 256) / 32;
|
unsigned subx, suby;
|
||||||
dpixel = (r << 0) | (g << 8) | (b << 16) | (0xFF << 24);
|
uint32_t spixel = frame_pixels[(y*pitch/sizeof(uint16_t)) + x];
|
||||||
|
uint8_t r = (spixel >> 11) & 31;
|
||||||
|
uint8_t g = (spixel >> 5) & 63;
|
||||||
|
uint8_t b = (spixel >> 0) & 31;
|
||||||
|
r = (r * 256) / 32;
|
||||||
|
g = (g * 256) / 64;
|
||||||
|
b = (b * 256) / 32;
|
||||||
|
pixel = (r << 0) | (g << 8) | (b << 16) | (0xFF << 24);
|
||||||
|
}
|
||||||
|
|
||||||
for (subx = 0; subx < xsf; subx++)
|
for (subx = 0; subx < xsf; subx++)
|
||||||
for (suby = 0; suby < ysf; suby++)
|
for (suby = 0; suby < ysf; suby++)
|
||||||
image[(((y*sf)+suby+centery)*1280)
|
image[(((y*sf)+suby+centery)*1280)
|
||||||
+ ((x*sf)+subx+centerx)] = dpixel;
|
+ ((x*sf)+subx+centerx)] = pixel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,4 +434,4 @@ video_driver_t video_switch = {
|
||||||
NULL, /* overlay_interface */
|
NULL, /* overlay_interface */
|
||||||
#endif
|
#endif
|
||||||
switch_get_poke_interface,
|
switch_get_poke_interface,
|
||||||
};
|
};
|
Loading…
Reference in New Issue