From 697c4389a9e650935cee934009bdbd42dc4e5cfa Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 11 Aug 2017 13:02:13 +0200 Subject: rpi: fix build Runtime untested, because I get this: [vo/rpi] Could not get DISPMANX objects. This happened even when building older git versions, and on a RPI image that hasn't changed in the recent years. I don't know how to make this POS work again, so I guess if there's a bug in the new code, it will remain broken. --- video/out/opengl/hwdec_rpi.c | 10 +++++----- video/out/opengl/osd.c | 15 ++++++++++----- video/out/opengl/osd.h | 3 ++- video/out/opengl/video.c | 20 +++++++++++++++++++- video/out/opengl/video.h | 3 +++ 5 files changed, 39 insertions(+), 12 deletions(-) (limited to 'video/out/opengl') diff --git a/video/out/opengl/hwdec_rpi.c b/video/out/opengl/hwdec_rpi.c index 72270b5787..6f39c3e330 100644 --- a/video/out/opengl/hwdec_rpi.c +++ b/video/out/opengl/hwdec_rpi.c @@ -36,6 +36,7 @@ #include "hwdec.h" #include "common.h" +#include "ra_gl.h" struct priv { struct mp_log *log; @@ -125,13 +126,13 @@ static void disable_renderer(struct ra_hwdec *hw) static void update_overlay(struct ra_hwdec *hw, bool check_window_only) { struct priv *p = hw->priv; - GL *gl = hw->gl; + GL *gl = ra_is_gl(hw->ra) ? ra_gl_get(hw->ra) : NULL; MMAL_PORT_T *input = p->renderer->input[0]; struct mp_rect src = p->src; struct mp_rect dst = p->dst; int defs[4] = {0, 0, 0, 0}; - int *z = mpgl_get_native_display(gl, "MPV_RPI_WINDOW"); + int *z = gl ? mpgl_get_native_display(gl, "MPV_RPI_WINDOW") : NULL; if (!z) z = defs; @@ -285,7 +286,7 @@ static int overlay_frame(struct ra_hwdec *hw, struct mp_image *hw_image, struct priv *p = hw->priv; if (hw_image && !mp_image_params_equal(&p->params, &hw_image->params)) { - p->params = *params; + p->params = hw_image->params; disable_renderer(hw); mp_image_unrefp(&p->current_frame); @@ -300,7 +301,7 @@ static int overlay_frame(struct ra_hwdec *hw, struct mp_image *hw_image, p->dst = *dst; update_overlay(hw, false); } - return; + return 0; // don't reupload } mp_image_unrefp(&p->current_frame); @@ -382,6 +383,5 @@ const struct ra_hwdec_driver ra_hwdec_rpi_overlay = { .imgfmts = {IMGFMT_MMAL, IMGFMT_420P, 0}, .init = create, .overlay_frame = overlay_frame, - .overlay_adjust = overlay_adjust, .uninit = destroy, }; diff --git a/video/out/opengl/osd.c b/video/out/opengl/osd.c index 2678e12774..7030e8d8f4 100644 --- a/video/out/opengl/osd.c +++ b/video/out/opengl/osd.c @@ -66,7 +66,7 @@ struct mpgl_osd { struct mpgl_osd_part *parts[MAX_OSD_PARTS]; const struct ra_format *fmt_table[SUBBITMAP_COUNT]; bool formats[SUBBITMAP_COUNT]; - int64_t change_counter; + bool change_flag; // for reporting to API user only // temporary int stereo_mode; struct mp_osd_res osd_res; @@ -81,6 +81,7 @@ struct mpgl_osd *mpgl_osd_init(struct ra *ra, struct mp_log *log, .log = log, .osd = osd, .ra = ra, + .change_flag = true, .scratch = talloc_zero_size(ctx, 1), }; @@ -189,7 +190,7 @@ static void gen_osd_cb(void *pctx, struct sub_bitmaps *imgs) ok = false; osd->change_id = imgs->change_id; - ctx->change_counter += 1; + ctx->change_flag = true; } osd->num_subparts = ok ? imgs->num_parts : 0; @@ -310,6 +311,8 @@ void mpgl_osd_draw_finish(struct mpgl_osd *ctx, int index, gl_sc_blend(sc, factors[0], factors[1], factors[2], factors[3]); gl_sc_dispatch_draw(sc, target.tex, part->vertices, part->num_vertices); + + ctx->change_flag = false; } static void set_res(struct mpgl_osd *ctx, struct mp_osd_res res, int stereo_mode) @@ -338,7 +341,7 @@ void mpgl_osd_generate(struct mpgl_osd *ctx, struct mp_osd_res res, double pts, for (int n = 0; n < MAX_OSD_PARTS; n++) { struct mpgl_osd_part *part = ctx->parts[n]; if (part->num_subparts != part->prev_num_subparts) - ctx->change_counter += 1; + ctx->change_flag = true; part->prev_num_subparts = part->num_subparts; } } @@ -350,7 +353,9 @@ void mpgl_osd_resize(struct mpgl_osd *ctx, struct mp_osd_res res, int stereo_mod osd_resize(ctx->osd, ctx->osd_res); } -int64_t mpgl_get_change_counter(struct mpgl_osd *ctx) +bool mpgl_osd_check_change(struct mpgl_osd *ctx, struct mp_osd_res *res, + double pts) { - return ctx->change_counter; + mpgl_osd_generate(ctx, *res, pts, 0, 0); + return ctx->change_flag; } diff --git a/video/out/opengl/osd.h b/video/out/opengl/osd.h index 9763d7e03a..6c2b886de3 100644 --- a/video/out/opengl/osd.h +++ b/video/out/opengl/osd.h @@ -19,6 +19,7 @@ bool mpgl_osd_draw_prepare(struct mpgl_osd *ctx, int index, struct gl_shader_cache *sc); void mpgl_osd_draw_finish(struct mpgl_osd *ctx, int index, struct gl_shader_cache *sc, struct fbodst target); -int64_t mpgl_get_change_counter(struct mpgl_osd *ctx); +bool mpgl_osd_check_change(struct mpgl_osd *ctx, struct mp_osd_res *res, + double pts); #endif diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index 8b1e29b936..7f467397a1 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -180,6 +180,8 @@ struct gl_video { struct gl_lcms *cms; int fb_depth; // actual bits available in GL main framebuffer + struct m_color clear_color; + bool force_clear_color; struct gl_shader_cache *sc; @@ -3000,7 +3002,7 @@ void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame, bool has_frame = !!frame->current; if (!has_frame || !mp_rect_equals(&p->dst_rect, &target_rc)) { - struct m_color c = p->opts.background; + struct m_color c = p->clear_color; float color[4] = {c.r / 255.0, c.g / 255.0, c.b / 255.0, c.a / 255.0}; p->ra->fns->clear(p->ra, target.tex, color, &target_rc); } @@ -3120,6 +3122,19 @@ done: pass_report_performance(p); } +// Use this color instead of the global option. +void gl_video_set_clear_color(struct gl_video *p, struct m_color c) +{ + p->force_clear_color = true; + p->clear_color = c; +} + +bool gl_video_check_osd_change(struct gl_video *p, struct mp_osd_res *res, + double pts) +{ + return p->osd ? mpgl_osd_check_change(p->osd, res, pts) : false; +} + void gl_video_resize(struct gl_video *p, struct mp_rect *src, struct mp_rect *dst, struct mp_osd_res *osd) @@ -3605,6 +3620,9 @@ static void reinit_from_options(struct gl_video *p) // referenced by them. p->opts = *(struct gl_video_opts *)p->opts_cache->opts; + if (!p->force_clear_color) + p->clear_color = p->opts.background; + check_gl_features(p); uninit_rendering(p); gl_sc_set_cache_dir(p->sc, p->opts.shader_cache_dir); diff --git a/video/out/opengl/video.h b/video/out/opengl/video.h index 84ddc0d47c..915994f435 100644 --- a/video/out/opengl/video.h +++ b/video/out/opengl/video.h @@ -168,6 +168,9 @@ void gl_video_perfdata(struct gl_video *p, struct voctrl_performance_data *out); struct mp_csp_equalizer; struct mp_csp_equalizer *gl_video_eq_ptr(struct gl_video *p); void gl_video_eq_update(struct gl_video *p); +void gl_video_set_clear_color(struct gl_video *p, struct m_color color); +bool gl_video_check_osd_change(struct gl_video *p, struct mp_osd_res *osd, + double pts); float gl_video_scale_ambient_lux(float lmin, float lmax, float rmin, float rmax, float lux); -- cgit v1.2.3