summaryrefslogtreecommitdiffstats
path: root/sub/osd.c
diff options
context:
space:
mode:
Diffstat (limited to 'sub/osd.c')
-rw-r--r--sub/osd.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/sub/osd.c b/sub/osd.c
index 381fa8892d..dfe75b7698 100644
--- a/sub/osd.c
+++ b/sub/osd.c
@@ -81,6 +81,7 @@ const struct m_sub_options osd_style_conf = {
.align_x = -1,
.align_y = -1,
},
+ .change_flags = UPDATE_OSD,
};
const struct m_sub_options sub_style_conf = {
@@ -99,6 +100,7 @@ const struct m_sub_options sub_style_conf = {
.align_x = 0,
.align_y = 1,
},
+ .change_flags = UPDATE_OSD,
};
static bool osd_res_equals(struct mp_osd_res a, struct mp_osd_res b)
@@ -146,12 +148,6 @@ void osd_free(struct osd_state *osd)
talloc_free(osd);
}
-void osd_changed_unlocked(struct osd_state *osd, int obj)
-{
- osd->objs[obj]->force_redraw = true;
- osd->want_redraw = true;
-}
-
void osd_set_text(struct osd_state *osd, const char *text)
{
pthread_mutex_lock(&osd->lock);
@@ -161,7 +157,8 @@ void osd_set_text(struct osd_state *osd, const char *text)
if (strcmp(osd_obj->text, text) != 0) {
talloc_free(osd_obj->text);
osd_obj->text = talloc_strdup(osd_obj, text);
- osd_changed_unlocked(osd, osd_obj->type);
+ osd_obj->osd_changed = true;
+ osd->want_redraw_notification = true;
}
pthread_mutex_unlock(&osd->lock);
}
@@ -169,8 +166,12 @@ void osd_set_text(struct osd_state *osd, const char *text)
void osd_set_sub(struct osd_state *osd, int index, struct dec_sub *dec_sub)
{
pthread_mutex_lock(&osd->lock);
- if (index >= 0 && index < 2)
- osd->objs[OSDTYPE_SUB + index]->sub = dec_sub;
+ if (index >= 0 && index < 2) {
+ struct osd_object *obj = osd->objs[OSDTYPE_SUB + index];
+ obj->sub = dec_sub;
+ obj->vo_change_id += 1;
+ }
+ osd->want_redraw_notification = true;
pthread_mutex_unlock(&osd->lock);
}
@@ -199,7 +200,8 @@ void osd_set_progbar(struct osd_state *osd, struct osd_progbar_state *s)
MP_TARRAY_GROW(osd_obj, osd_obj->progbar_state.stops, s->num_stops);
memcpy(osd_obj->progbar_state.stops, s->stops,
sizeof(osd_obj->progbar_state.stops[0]) * s->num_stops);
- osd_changed_unlocked(osd, osd_obj->type);
+ osd_obj->osd_changed = true;
+ osd->want_redraw_notification = true;
pthread_mutex_unlock(&osd->lock);
}
@@ -207,7 +209,8 @@ void osd_set_external2(struct osd_state *osd, struct sub_bitmaps *imgs)
{
pthread_mutex_lock(&osd->lock);
osd->objs[OSDTYPE_EXTERNAL2]->external2 = imgs;
- osd_changed_unlocked(osd, OSDTYPE_EXTERNAL2);
+ osd->objs[OSDTYPE_EXTERNAL2]->vo_change_id += 1;
+ osd->want_redraw_notification = true;
pthread_mutex_unlock(&osd->lock);
}
@@ -216,7 +219,6 @@ static void check_obj_resize(struct osd_state *osd, struct mp_osd_res res,
{
if (!osd_res_equals(res, obj->vo_res)) {
obj->vo_res = res;
- obj->force_redraw = true;
mp_client_broadcast_event(mp_client_api_get_core(osd->global->client_api),
MP_EVENT_WIN_RESIZE, NULL);
}
@@ -269,10 +271,6 @@ static void render_object(struct osd_state *osd, struct osd_object *obj,
osd_object_get_bitmaps(osd, obj, format, out_imgs);
}
- if (obj->force_redraw)
- out_imgs->change_id++;
-
- obj->force_redraw = false;
obj->vo_change_id += out_imgs->change_id;
if (out_imgs->num_parts == 0)
@@ -323,6 +321,13 @@ void osd_draw(struct osd_state *osd, struct mp_osd_res res,
sub_unlock(obj->sub);
}
+ // If this is called with OSD_DRAW_SUB_ONLY or OSD_DRAW_OSD_ONLY set, assume
+ // it will always draw the complete OSD by doing multiple osd_draw() calls.
+ // OSD_DRAW_SUB_FILTER on the other hand is an evil special-case, and we
+ // must not reset the flag when it happens.
+ if (!(draw_flags & OSD_DRAW_SUB_FILTER))
+ osd->want_redraw_notification = false;
+
pthread_mutex_unlock(&osd->lock);
}
@@ -379,24 +384,20 @@ struct mp_osd_res osd_res_from_image_params(const struct mp_image_params *p)
};
}
-void osd_changed(struct osd_state *osd, int new_value)
+// Typically called to react to OSD style changes.
+void osd_changed(struct osd_state *osd)
{
pthread_mutex_lock(&osd->lock);
- osd_changed_unlocked(osd, new_value);
+ osd->objs[OSDTYPE_OSD]->osd_changed = true;
+ osd->want_redraw_notification = true;
pthread_mutex_unlock(&osd->lock);
}
-void osd_changed_all(struct osd_state *osd)
-{
- for (int n = 0; n < MAX_OSD_PARTS; n++)
- osd_changed(osd, n);
-}
-
bool osd_query_and_reset_want_redraw(struct osd_state *osd)
{
pthread_mutex_lock(&osd->lock);
- bool r = osd->want_redraw;
- osd->want_redraw = false;
+ bool r = osd->want_redraw_notification;
+ osd->want_redraw_notification = false;
pthread_mutex_unlock(&osd->lock);
return r;
}