mirror of
https://github.com/libretro/RetroArch
synced 2025-02-02 14:54:10 +00:00
(SDL) Use video_frame_scale
This commit is contained in:
parent
7b2a2f2336
commit
bfcc89f580
@ -1102,7 +1102,7 @@ static void omap_gfx_set_texture_frame(void *data, const void *frame, bool rgb32
|
||||
format,
|
||||
vid->width,
|
||||
vid->height,
|
||||
vid->bytes_per_pixel,
|
||||
vid->width * vid->bytes_per_pixel,
|
||||
width,
|
||||
height,
|
||||
width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)));
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include "../../driver.h"
|
||||
#include "../../general.h"
|
||||
#include "../../performance.h"
|
||||
|
||||
#include "../video_frame.h"
|
||||
#include "../video_context_driver.h"
|
||||
#include "../font_driver.h"
|
||||
|
||||
@ -83,30 +85,6 @@ static void sdl_gfx_free(void *data)
|
||||
free(vid);
|
||||
}
|
||||
|
||||
static void sdl_update_scaler(SDL_Surface *surf, struct scaler_ctx *scaler,
|
||||
enum scaler_pix_fmt format, unsigned width,
|
||||
unsigned height, unsigned pitch)
|
||||
{
|
||||
if (
|
||||
width != (unsigned)scaler->in_width
|
||||
|| height != (unsigned)scaler->in_height
|
||||
|| format != scaler->in_fmt
|
||||
|| pitch != (unsigned)scaler->in_stride
|
||||
)
|
||||
{
|
||||
scaler->in_fmt = format;
|
||||
scaler->in_width = width;
|
||||
scaler->in_height = height;
|
||||
scaler->in_stride = pitch;
|
||||
|
||||
scaler->out_width = surf->w;
|
||||
scaler->out_height = surf->h;
|
||||
scaler->out_stride = surf->pitch;
|
||||
|
||||
scaler_ctx_gen_filter(scaler);
|
||||
}
|
||||
}
|
||||
|
||||
static void sdl_init_font(sdl_video_t *vid, const char *font_path, unsigned font_size)
|
||||
{
|
||||
int r, g, b;
|
||||
@ -364,11 +342,20 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width,
|
||||
if (SDL_MUSTLOCK(vid->screen))
|
||||
SDL_LockSurface(vid->screen);
|
||||
|
||||
sdl_update_scaler(vid->screen, &vid->scaler, vid->scaler.in_fmt, width, height, pitch);
|
||||
|
||||
rarch_perf_init(&sdl_scale, "sdl_scale");
|
||||
retro_perf_start(&sdl_scale);
|
||||
scaler_ctx_scale(&vid->scaler, vid->screen->pixels, frame);
|
||||
|
||||
video_frame_scale(
|
||||
&vid->scaler,
|
||||
vid->screen->pixels,
|
||||
frame,
|
||||
vid->scaler.in_fmt,
|
||||
vid->screen->w,
|
||||
vid->screen->h,
|
||||
vid->screen->pitch,
|
||||
width,
|
||||
height,
|
||||
pitch);
|
||||
retro_perf_stop(&sdl_scale);
|
||||
|
||||
if (vid->menu.active)
|
||||
@ -480,15 +467,23 @@ static void sdl_apply_state_changes(void *data)
|
||||
static void sdl_set_texture_frame(void *data, const void *frame, bool rgb32,
|
||||
unsigned width, unsigned height, float alpha)
|
||||
{
|
||||
enum scaler_pix_fmt format = rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGBA4444;
|
||||
enum scaler_pix_fmt format = rgb32
|
||||
? SCALER_FMT_ARGB8888 : SCALER_FMT_RGBA4444;
|
||||
sdl_video_t *vid = (sdl_video_t*)data;
|
||||
|
||||
(void)alpha;
|
||||
video_frame_scale(
|
||||
&vid->menu.scaler,
|
||||
vid->menu.frame->pixels,
|
||||
frame,
|
||||
format,
|
||||
vid->menu.frame->w,
|
||||
vid->menu.frame->h,
|
||||
vid->menu.frame->pitch,
|
||||
width,
|
||||
height,
|
||||
width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t))
|
||||
);
|
||||
|
||||
sdl_update_scaler(vid->menu.frame, &vid->menu.scaler, format, width, height,
|
||||
width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)));
|
||||
|
||||
scaler_ctx_scale(&vid->menu.scaler, vid->menu.frame->pixels, frame);
|
||||
SDL_SetAlpha(vid->menu.frame, SDL_SRCALPHA, 255.0 * alpha);
|
||||
}
|
||||
|
||||
|
@ -43,10 +43,10 @@ static INLINE void video_frame_scale(
|
||||
unsigned pitch)
|
||||
{
|
||||
if (
|
||||
width != scaler->in_width
|
||||
|| height != scaler->in_height
|
||||
width != (unsigned)scaler->in_width
|
||||
|| height != (unsigned)scaler->in_height
|
||||
|| format != scaler->in_fmt
|
||||
|| pitch != scaler->in_stride
|
||||
|| pitch != (unsigned)scaler->in_stride
|
||||
)
|
||||
{
|
||||
scaler->in_fmt = format;
|
||||
@ -56,7 +56,7 @@ static INLINE void video_frame_scale(
|
||||
|
||||
scaler->out_width = scaler_width;
|
||||
scaler->out_height = scaler_height;
|
||||
scaler->out_stride = scaler_width * scaler_pitch;
|
||||
scaler->out_stride = scaler_pitch;
|
||||
|
||||
scaler_ctx_gen_filter(scaler);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user