diff --git a/gfx/drivers/omap_gfx.c b/gfx/drivers/omap_gfx.c index b1f44cbc0d..7825513baf 100644 --- a/gfx/drivers/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -41,6 +41,8 @@ #include "../../retroarch.h" #include "../video_context_driver.h" +#include "../video_frame.h" + #include "../font_driver.h" typedef struct omapfb_page @@ -1087,49 +1089,23 @@ static bool omap_gfx_read_viewport(void *data, uint8_t *buffer) return true; } -static void update_scaler( - omap_video_t *vid, - const void *frame, - struct scaler_ctx *scaler, - enum scaler_pix_fmt format, - unsigned width, - unsigned height, - unsigned pitch) -{ - if ( - width != scaler->in_width - || height != scaler->in_height - || format != scaler->in_fmt - || pitch != scaler->in_stride - ) - { - scaler->in_fmt = format; - scaler->in_width = width; - scaler->in_height = height; - scaler->in_stride = pitch; - - scaler->out_width = vid->width; - scaler->out_height = vid->height; - scaler->out_stride = vid->width * vid->bytes_per_pixel; - - if (!scaler_ctx_gen_filter(scaler)) - RARCH_ERR("[video_omap]: scaler_ctx_gen_filter failed\n"); - } - - scaler_ctx_scale(scaler, vid->menu.frame, frame); -} - static void omap_gfx_set_texture_frame(void *data, const void *frame, bool rgb32, unsigned width, unsigned height, float alpha) { omap_video_t *vid = (omap_video_t*)data; enum scaler_pix_fmt format = rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGBA4444; - (void) alpha; - - update_scaler(vid, frame, &vid->menu.scaler, format, width, height, + video_frame_scale( + &vid->menu.scaler, + vid->menu.frame, + frame, + format, + vid->width, + vid->height, + vid->bytes_per_pixel, + width, + height, width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t))); - } static void omap_gfx_set_texture_enable(void *data, bool state, bool full_screen) diff --git a/gfx/video_frame.h b/gfx/video_frame.h index ef0f5d44cb..8dfadef9bb 100644 --- a/gfx/video_frame.h +++ b/gfx/video_frame.h @@ -30,6 +30,40 @@ static INLINE void video_frame_convert_rgb16_to_rgb32( scaler_ctx_scale(scaler, output, input); } +static INLINE void video_frame_scale( + struct scaler_ctx *scaler, + void *output, + const void *input, + enum scaler_pix_fmt format, + unsigned scaler_width, + unsigned scaler_height, + unsigned scaler_pitch, + unsigned width, + unsigned height, + unsigned pitch) +{ + if ( + width != scaler->in_width + || height != scaler->in_height + || format != scaler->in_fmt + || pitch != scaler->in_stride + ) + { + scaler->in_fmt = format; + scaler->in_width = width; + scaler->in_height = height; + scaler->in_stride = pitch; + + scaler->out_width = scaler_width; + scaler->out_height = scaler_height; + scaler->out_stride = scaler_width * scaler_pitch; + + scaler_ctx_gen_filter(scaler); + } + + scaler_ctx_scale(scaler, output, input); +} + static INLINE void video_frame_convert_argb8888_to_abgr8888( struct scaler_ctx *scaler, void *output, const void *input,