libweston: Add function to schedule idle task for updating surface protection

Currently, the idle task for updating surface protection is scheduled
in case of change in the output mask of a surface or in case of change
in protection status of an output.
This patch adds a function for reusing the code to schedule the
idle-tasks, that can be called whenever there is a chance of a change
in the protection status of a surface.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
dev
Ankit Nautiyal 6 years ago
parent 93dde245ee
commit faa5ab4e7b
  1. 43
      libweston/compositor.c

@ -1077,6 +1077,26 @@ notify_surface_protection_change(void *data)
weston_surface_compute_protection(psurface); weston_surface_compute_protection(psurface);
} }
/**
* \param compositor weston_compositor
*
* Schedule an idle task to notify surface about the update in protection,
* if not already scheduled.
*/
static void
weston_schedule_surface_protection_update(struct weston_compositor *compositor)
{
struct content_protection *cp = compositor->content_protection;
struct wl_event_loop *loop;
if (!cp || cp->surface_protection_update)
return;
loop = wl_display_get_event_loop(compositor->wl_display);
cp->surface_protection_update = wl_event_loop_add_idle(loop,
notify_surface_protection_change,
compositor);
}
/** /**
* \param es The surface * \param es The surface
* \param mask The new set of outputs for the surface * \param mask The new set of outputs for the surface
@ -1095,8 +1115,6 @@ weston_surface_update_output_mask(struct weston_surface *es, uint32_t mask)
uint32_t output_bit; uint32_t output_bit;
struct weston_output *output; struct weston_output *output;
struct weston_head *head; struct weston_head *head;
struct content_protection *cp;
struct wl_event_loop *loop;
es->output_mask = mask; es->output_mask = mask;
if (es->resource == NULL) if (es->resource == NULL)
@ -1119,13 +1137,7 @@ weston_surface_update_output_mask(struct weston_surface *es, uint32_t mask)
* Change in surfaces' output mask might trigger a change in its * Change in surfaces' output mask might trigger a change in its
* protection. * protection.
*/ */
loop = wl_display_get_event_loop(es->compositor->wl_display); weston_schedule_surface_protection_update(es->compositor);
cp = es->compositor->content_protection;
if (!cp || cp->surface_protection_update)
return;
cp->surface_protection_update = wl_event_loop_add_idle(loop,
notify_surface_protection_change,
es->compositor);
} }
static void static void
@ -5402,10 +5414,6 @@ weston_output_compute_protection(struct weston_output *output)
enum weston_hdcp_protection op_protection; enum weston_hdcp_protection op_protection;
bool op_protection_valid = false; bool op_protection_valid = false;
struct weston_compositor *wc = output->compositor; struct weston_compositor *wc = output->compositor;
struct content_protection *cp = wc->content_protection;
if (!cp)
return;
wl_list_for_each(head, &output->head_list, output_link) { wl_list_for_each(head, &output->head_list, output_link) {
if (!op_protection_valid) { if (!op_protection_valid) {
@ -5420,16 +5428,9 @@ weston_output_compute_protection(struct weston_output *output)
op_protection = WESTON_HDCP_DISABLE; op_protection = WESTON_HDCP_DISABLE;
if (output->current_protection != op_protection) { if (output->current_protection != op_protection) {
struct wl_event_loop *loop;
output->current_protection = op_protection; output->current_protection = op_protection;
weston_output_damage(output); weston_output_damage(output);
if (cp->surface_protection_update) weston_schedule_surface_protection_update(wc);
return;
loop = wl_display_get_event_loop(wc->wl_display);
cp->surface_protection_update = wl_event_loop_add_idle(loop,
notify_surface_protection_change,
wc);
} }
} }

Loading…
Cancel
Save