(switch_nx_gx.c) Some style nits

This commit is contained in:
twinaphex 2018-09-15 17:39:03 +02:00
parent 6ff2c96d03
commit 2fc08ce394
1 changed files with 49 additions and 45 deletions

View File

@ -54,11 +54,11 @@
#ifdef HAVE_NXRGUI #ifdef HAVE_NXRGUI
extern uint32_t *nx_backgroundImage; extern uint32_t *nx_backgroundImage;
// Temp Overlay // KILL IT WITH FIRE /* Temp Overlay - kill it with fire */
extern uint32_t *tmp_overlay; extern uint32_t *tmp_overlay;
#endif #endif
// (C) libtransistor /* (C) libtransistor */
static int pdep(uint32_t mask, uint32_t value) static int pdep(uint32_t mask, uint32_t value)
{ {
uint32_t out = 0; uint32_t out = 0;
@ -89,14 +89,14 @@ void gfx_slow_swizzling_blit(uint32_t *buffer, uint32_t *image, int w, int h, in
const uint32_t tile_height = 128; const uint32_t tile_height = 128;
const uint32_t padded_width = 128 * 10; const uint32_t padded_width = 128 * 10;
// we're doing this in pixels - should just shift the swizzles instead /* we're doing this in pixels - should just shift the swizzles instead */
uint32_t offs_x0 = swizzle_x(x0); uint32_t offs_x0 = swizzle_x(x0);
uint32_t offs_y = swizzle_y(y0); uint32_t offs_y = swizzle_y(y0);
uint32_t x_mask = swizzle_x(~0u); uint32_t x_mask = swizzle_x(~0u);
uint32_t y_mask = swizzle_y(~0u); uint32_t y_mask = swizzle_y(~0u);
uint32_t incr_y = swizzle_x(padded_width); uint32_t incr_y = swizzle_x(padded_width);
// step offs_x0 to the right row of tiles /* step offs_x0 to the right row of tiles */
offs_x0 += incr_y * (y0 / tile_height); offs_x0 += incr_y * (y0 / tile_height);
uint32_t x, y; uint32_t x, y;
@ -108,7 +108,7 @@ void gfx_slow_swizzling_blit(uint32_t *buffer, uint32_t *image, int w, int h, in
for (x = x0; x < x1; x++) for (x = x0; x < x1; x++)
{ {
uint32_t pixel = *src++; uint32_t pixel = *src++;
if (blend) // supercheap masking if (blend) /* supercheap masking */
{ {
uint32_t dst = dest_line[offs_x]; uint32_t dst = dest_line[offs_x];
uint8_t src_a = ((pixel & 0xFF000000) >> 24); uint8_t src_a = ((pixel & 0xFF000000) >> 24);
@ -126,16 +126,17 @@ void gfx_slow_swizzling_blit(uint32_t *buffer, uint32_t *image, int w, int h, in
offs_y = (offs_y - y_mask) & y_mask; offs_y = (offs_y - y_mask) & y_mask;
if (!offs_y) if (!offs_y)
offs_x0 += incr_y; // wrap into next tile row offs_x0 += incr_y; /* wrap into next tile row */
} }
} }
// needed to clear surface completely as hw scaling doesn't always scale to full resoution perflectly /* needed to clear surface completely as hw scaling doesn't always scale to full resoution perflectly */
static void clear_screen(switch_video_t *sw) static void clear_screen(switch_video_t *sw)
{ {
uint32_t *out_buffer = NULL;
gfxConfigureResolution(sw->vp.full_width, sw->vp.full_height); gfxConfigureResolution(sw->vp.full_width, sw->vp.full_height);
uint32_t *out_buffer = (uint32_t *)gfxGetFramebuffer(NULL, NULL); out_buffer = (uint32_t *)gfxGetFramebuffer(NULL, NULL);
memset(out_buffer, 0, gfxGetFramebufferSize()); memset(out_buffer, 0, gfxGetFramebufferSize());
@ -164,7 +165,7 @@ static void *switch_init(const video_info_t *video,
sw->vp.full_width = 1280; sw->vp.full_width = 1280;
sw->vp.full_height = 720; sw->vp.full_height = 720;
// Sanity check /* Sanity check */
sw->vp.width = MIN(sw->vp.width, sw->vp.full_width); sw->vp.width = MIN(sw->vp.width, sw->vp.full_width);
sw->vp.height = MIN(sw->vp.height, sw->vp.full_height); sw->vp.height = MIN(sw->vp.height, sw->vp.full_height);
@ -177,7 +178,7 @@ static void *switch_init(const video_info_t *video,
sw->smooth = video->smooth; sw->smooth = video->smooth;
sw->menu_texture.enable = false; sw->menu_texture.enable = false;
// Autoselect driver /* Autoselect driver */
if (input && input_data) if (input && input_data)
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
@ -343,7 +344,7 @@ static bool switch_frame(void *data, const void *frame,
if (ffwd_mode && !sw->is_threaded) if (ffwd_mode && !sw->is_threaded)
{ {
// render every 4th frame when in ffwd mode and not threaded /* render every 4th frame when in ffwd mode and not threaded */
if ((frame_count % 4) != 0) if ((frame_count % 4) != 0)
return true; return true;
} }
@ -355,7 +356,7 @@ static bool switch_frame(void *data, const void *frame,
switch_update_viewport(sw, video_info); switch_update_viewport(sw, video_info);
printf("[Video] fw: %i fh: %i w: %i h: %i x: %i y: %i\n", sw->vp.full_width, sw->vp.full_height, sw->vp.width, sw->vp.height, sw->vp.x, sw->vp.y); printf("[Video] fw: %i fh: %i w: %i h: %i x: %i y: %i\n", sw->vp.full_width, sw->vp.full_height, sw->vp.width, sw->vp.height, sw->vp.x, sw->vp.y);
// Sanity check /* Sanity check */
sw->vp.width = MIN(sw->vp.width, sw->vp.full_width); sw->vp.width = MIN(sw->vp.width, sw->vp.full_width);
sw->vp.height = MIN(sw->vp.height, sw->vp.full_height); sw->vp.height = MIN(sw->vp.height, sw->vp.full_height);
@ -430,14 +431,17 @@ static bool switch_frame(void *data, const void *frame,
gfx_slow_swizzling_blit(out_buffer, sw->tmp_image, sw->vp.full_width, sw->vp.full_height, 0, 0, true); gfx_slow_swizzling_blit(out_buffer, sw->tmp_image, sw->vp.full_width, sw->vp.full_height, 0, 0, true);
} }
} }
else if (sw->smooth) // bilinear else if (sw->smooth) /* bilinear */
{ {
int w, h;
unsigned x, y;
struct scaler_ctx *ctx = &sw->scaler; struct scaler_ctx *ctx = &sw->scaler;
scaler_ctx_scale_direct(ctx, sw->image, frame); scaler_ctx_scale_direct(ctx, sw->image, frame);
int w = sw->scaler.out_width; w = sw->scaler.out_width;
int h = sw->scaler.out_height; h = sw->scaler.out_height;
for (int y = 0; y < h; y++)
for (int x = 0; x < w; x++) for (y = 0; y < h; y++)
for (x = 0; x < w; x++)
out_buffer[gfxGetFramebufferDisplayOffset(x + sw->hw_scale.x_offset, y)] = sw->image[y * w + x]; out_buffer[gfxGetFramebufferDisplayOffset(x + sw->hw_scale.x_offset, y)] = sw->image[y * w + x];
} }
else else
@ -447,9 +451,7 @@ static bool switch_frame(void *data, const void *frame,
gfx_slow_swizzling_blit(out_buffer, sw->image, sw->vp.full_width, sw->vp.full_height, 0, 0, false); gfx_slow_swizzling_blit(out_buffer, sw->image, sw->vp.full_width, sw->vp.full_height, 0, 0, false);
#ifdef HAVE_NXRGUI #ifdef HAVE_NXRGUI
if (tmp_overlay) if (tmp_overlay)
{
gfx_slow_swizzling_blit(out_buffer, tmp_overlay, sw->vp.full_width, sw->vp.full_height, 0, 0, true); gfx_slow_swizzling_blit(out_buffer, tmp_overlay, sw->vp.full_width, sw->vp.full_height, 0, 0, true);
}
#endif #endif
} }
@ -514,7 +516,7 @@ static void switch_free(void *data)
} }
static bool switch_set_shader(void *data, static bool switch_set_shader(void *data,
enum rarch_shader_type type, const char *path) enum rarch_shader_type type, const char *path)
{ {
(void)data; (void)data;
(void)type; (void)type;
@ -556,6 +558,9 @@ static void switch_set_texture_frame(
sw->menu_texture.width != width || sw->menu_texture.width != width ||
sw->menu_texture.height != height) sw->menu_texture.height != height)
{ {
int xsf, yf, sf;
struct scaler_ctx *sctx = NULL;
if (sw->menu_texture.pixels) if (sw->menu_texture.pixels)
realloc(sw->menu_texture.pixels, sz); realloc(sw->menu_texture.pixels, sz);
else else
@ -567,31 +572,31 @@ static void switch_set_texture_frame(
return; return;
} }
int xsf = 1280 / width; xsf = 1280 / width;
int ysf = 720 / height; ysf = 720 / height;
int sf = xsf; sf = xsf;
if (ysf < sf) if (ysf < sf)
sf = ysf; sf = ysf;
sw->menu_texture.width = width; sw->menu_texture.width = width;
sw->menu_texture.height = height; sw->menu_texture.height = height;
sw->menu_texture.tgtw = width * sf; sw->menu_texture.tgtw = width * sf;
sw->menu_texture.tgth = height * sf; sw->menu_texture.tgth = height * sf;
struct scaler_ctx *sctx = &sw->menu_texture.scaler; sctx = &sw->menu_texture.scaler;
scaler_ctx_gen_reset(sctx); scaler_ctx_gen_reset(sctx);
sctx->in_width = width; sctx->in_width = width;
sctx->in_height = height; sctx->in_height = height;
sctx->in_stride = width * (rgb32 ? 4 : 2); sctx->in_stride = width * (rgb32 ? 4 : 2);
sctx->in_fmt = rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGB565; sctx->in_fmt = rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGB565;
sctx->out_width = sw->menu_texture.tgtw; sctx->out_width = sw->menu_texture.tgtw;
sctx->out_height = sw->menu_texture.tgth; sctx->out_height = sw->menu_texture.tgth;
sctx->out_stride = 1280 * 4; sctx->out_stride = 1280 * 4;
sctx->out_fmt = SCALER_FMT_ABGR8888; sctx->out_fmt = SCALER_FMT_ABGR8888;
sctx->scaler_type = SCALER_TYPE_POINT; sctx->scaler_type = SCALER_TYPE_POINT;
if (!scaler_ctx_gen_filter(sctx)) if (!scaler_ctx_gen_filter(sctx))
{ {
@ -625,9 +630,9 @@ static void switch_set_texture_enable(void *data, bool enable, bool full_screen)
} }
static void switch_set_osd_msg(void *data, static void switch_set_osd_msg(void *data,
video_frame_info_t *video_info, video_frame_info_t *video_info,
const char *msg, const char *msg,
const void *params, void *font) const void *params, void *font)
{ {
switch_video_t *sw = (switch_video_t *)data; switch_video_t *sw = (switch_video_t *)data;
@ -649,10 +654,9 @@ static void switch_overlay_enable(void *data, bool state)
} }
static bool switch_overlay_load(void *data, static bool switch_overlay_load(void *data,
const void *image_data, unsigned num_images) const void *image_data, unsigned num_images)
{ {
switch_video_t *swa = (switch_video_t *)data; switch_video_t *swa = (switch_video_t *)data;
struct texture_image *images = (struct texture_image *)image_data; struct texture_image *images = (struct texture_image *)image_data;
if (!swa) if (!swa)
@ -665,7 +669,7 @@ static bool switch_overlay_load(void *data,
} }
static void switch_overlay_tex_geom(void *data, static void switch_overlay_tex_geom(void *data,
unsigned idx, float x, float y, float w, float h) unsigned idx, float x, float y, float w, float h)
{ {
switch_video_t *swa = (switch_video_t *)data; switch_video_t *swa = (switch_video_t *)data;
@ -674,7 +678,7 @@ static void switch_overlay_tex_geom(void *data,
} }
static void switch_overlay_vertex_geom(void *data, static void switch_overlay_vertex_geom(void *data,
unsigned idx, float x, float y, float w, float h) unsigned idx, float x, float y, float w, float h)
{ {
switch_video_t *swa = (switch_video_t *)data; switch_video_t *swa = (switch_video_t *)data;
@ -741,7 +745,7 @@ static const video_poke_interface_t switch_poke_interface = {
}; };
static void switch_get_poke_interface(void *data, static void switch_get_poke_interface(void *data,
const video_poke_interface_t **iface) const video_poke_interface_t **iface)
{ {
(void)data; (void)data;
*iface = &switch_poke_interface; *iface = &switch_poke_interface;