From 9c5dcf93989bdfccd4779c2f19282a23703ee4f7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 9 Aug 2017 20:57:37 +0200 Subject: vo_opengl: shrink the hwdec overlay API Just remove one callback, and fold the functionality into the other one. RPI will still not compile, so the hwdec_rpi.c changes are untested. --- video/out/opengl/hwdec.h | 12 +++++------- video/out/opengl/hwdec_rpi.c | 23 +++++++++++------------ video/out/opengl/video.c | 10 ++++------ 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/video/out/opengl/hwdec.h b/video/out/opengl/hwdec.h index 95cbdadcf1..6d4dc5d591 100644 --- a/video/out/opengl/hwdec.h +++ b/video/out/opengl/hwdec.h @@ -71,13 +71,11 @@ struct gl_hwdec_driver { // layer below it. // Non-overlay mode is strictly preferred, so try not to use overlay mode. - // Set the given frame as overlay, replacing the previous one. - // hw_image==NULL is passed to clear the overlay. - int (*overlay_frame)(struct gl_hwdec *hw, struct mp_image *hw_image); - - // Move overlay position within the "window". - void (*overlay_adjust)(struct gl_hwdec *hw, - struct mp_rect *src, struct mp_rect *dst); + // Set the given frame as overlay, replacing the previous one. This can also + // just change the position of the overlay. + // hw_image==src==dst==NULL is passed to clear the overlay. + int (*overlay_frame)(struct gl_hwdec *hw, struct mp_image *hw_image, + struct mp_rect *src, struct mp_rect *dst, bool newframe); }; struct gl_hwdec *gl_hwdec_load_api(struct mp_log *log, GL *gl, diff --git a/video/out/opengl/hwdec_rpi.c b/video/out/opengl/hwdec_rpi.c index e8feb714fa..daa1a9a54c 100644 --- a/video/out/opengl/hwdec_rpi.c +++ b/video/out/opengl/hwdec_rpi.c @@ -244,17 +244,6 @@ static int enable_renderer(struct gl_hwdec *hw) return 0; } -static void overlay_adjust(struct gl_hwdec *hw, - struct mp_rect *src, struct mp_rect *dst) -{ - struct priv *p = hw->priv; - - p->src = *src; - p->dst = *dst; - - update_overlay(hw, false); -} - static int reinit(struct gl_hwdec *hw, struct mp_image_params *params) { struct priv *p = hw->priv; @@ -306,10 +295,20 @@ static struct mp_image *upload(struct gl_hwdec *hw, struct mp_image *hw_image) return new_ref; } -static int overlay_frame(struct gl_hwdec *hw, struct mp_image *hw_image) +static int overlay_frame(struct gl_hwdec *hw, struct mp_image *hw_image, + struct mp_rect *src, struct mp_rect *dst, bool newframe) { struct priv *p = hw->priv; + if (hw_image && p->current_frame && !newframe) { + if (!mp_rect_equals(&p->src, src) ||mp_rect_equals(&p->dst, dst)) { + p->src = *src; + p->dst = *dst; + update_overlay(hw, false); + } + return; + } + mp_image_unrefp(&p->current_frame); if (!hw_image) { diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index a33060de73..8ed21d4380 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -973,7 +973,7 @@ static void unref_current_image(struct gl_video *p) static void unmap_overlay(struct gl_video *p) { if (p->hwdec_active && p->hwdec->driver->overlay_frame) - p->hwdec->driver->overlay_frame(p->hwdec, NULL); + p->hwdec->driver->overlay_frame(p->hwdec, NULL, NULL, NULL, true); } static void uninit_video(struct gl_video *p) @@ -3013,8 +3013,9 @@ void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame, p->ra->fns->clear(p->ra, target.tex, color, &p->dst_rect); } - if (frame->frame_id != p->image.id || !frame->current) - p->hwdec->driver->overlay_frame(p->hwdec, frame->current); + p->hwdec->driver->overlay_frame(p->hwdec, frame->current, + &p->src_rect, &p->dst_rect, + frame->frame_id != p->image.id); if (frame->current) p->osd_pts = frame->current->pts; @@ -3133,9 +3134,6 @@ void gl_video_resize(struct gl_video *p, if (p->osd) mpgl_osd_resize(p->osd, p->osd_rect, p->image_params.stereo_out); - - if (p->hwdec && p->hwdec->driver->overlay_adjust) - p->hwdec->driver->overlay_adjust(p->hwdec, src, dst); } static void frame_perf_data(struct pass_info pass[], struct mp_frame_perf *out) -- cgit v1.2.3