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>
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 3f5d096..4817adb 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -1078,6 +1078,26 @@
}
/**
+ * \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 mask The new set of outputs for the surface
*
@@ -1095,8 +1115,6 @@
uint32_t output_bit;
struct weston_output *output;
struct weston_head *head;
- struct content_protection *cp;
- struct wl_event_loop *loop;
es->output_mask = mask;
if (es->resource == NULL)
@@ -1119,13 +1137,7 @@
* Change in surfaces' output mask might trigger a change in its
* protection.
*/
- loop = wl_display_get_event_loop(es->compositor->wl_display);
- 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);
+ weston_schedule_surface_protection_update(es->compositor);
}
static void
@@ -5402,10 +5414,6 @@
enum weston_hdcp_protection op_protection;
bool op_protection_valid = false;
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) {
if (!op_protection_valid) {
@@ -5420,16 +5428,9 @@
op_protection = WESTON_HDCP_DISABLE;
if (output->current_protection != op_protection) {
- struct wl_event_loop *loop;
-
output->current_protection = op_protection;
weston_output_damage(output);
- if (cp->surface_protection_update)
- 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);
+ weston_schedule_surface_protection_update(wc);
}
}