[PATCH weston v2 10/14] libweston: move output id into add/remove_output() (original) (raw)

Armin Krezović krezovic.armin at gmail.com
Mon Jul 24 16:19:06 UTC 2017


On 24.07.2017 17:08, Pekka Paalanen wrote:

From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Move the output id management into westoncompositoraddoutput() and westoncompositorremoveoutput(). This is a more logical place, and works towards assimilating westonoutputenableundo(). The output id is no longer available to the backend enable() vfuncs, but it was not used there to begin with. v2: moved assert earlier in westoncompositoraddoutput() Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Hi,

Nice:

Reviewed-by: Armin Krezović <krezovic.armin at gmail.com>

Thanks,

Armin

--- libweston/compositor.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/libweston/compositor.c b/libweston/compositor.c index 6f8d9391..3c6d6db8 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -4472,6 +4472,8 @@ westonoutputmove(struct westonoutput *output, int x, int y) * Removes the output from the pending list and adds it to the compositor's * list of enabled outputs. The output created signal is emitted. * + * The output gets an internal ID assigned. + * * \param compositor The compositor instance. * \param output The output to be added. * @@ -4484,6 +4486,17 @@ westoncompositoraddoutput(struct westoncompositor *compositor, struct westonview *view, *next; assert(!output->enabled); + + /* Verify we haven't reached the limit of 32 available output IDs */ + assert(ffs(~compositor->outputidpool) > 0); + + /* Invert the output id pool and look for the lowest numbered + * switch (the least significant bit). Take that bit's position + * as our ID, and mark it used in the compositor's outputidpool. + */ + output->id = ffs(~compositor->outputidpool) - 1; + compositor->outputidpool |= 1u << output->id; + wllistremove(&output->link); wllistinsert(compositor->outputlist.prev, &output->link); output->enabled = true; @@ -4532,7 +4545,6 @@ westonoutputtransformcoordinate(struct westonoutput *output, * Removes the repaint timer. * Destroys the Wayland global assigned to the output. * Destroys pixman regions allocated to the output. - * Deallocates output's ID and updates compositor's outputidpool. */ static void westonoutputenableundo(struct westonoutput *output) @@ -4541,7 +4553,6 @@ westonoutputenableundo(struct westonoutput *output) pixmanregion32fini(&output->region); pixmanregion32fini(&output->previousdamage); - output->compositor->outputidpool &= ~(1u << output->id); } /** Removes output from compositor's list of enabled outputs @@ -4566,6 +4577,8 @@ westonoutputenableundo(struct westonoutput *output) * - wloutput protocol objects referencing this westonoutput * are made inert. * + * - The output's internal ID is released. + * * \memberof westonoutput * \internal */ @@ -4598,6 +4611,9 @@ westoncompositorremoveoutput(struct westonoutput *output) wlresourceforeach(resource, &output->resourcelist) { wlresourcesetdestructor(resource, NULL); } + + compositor->outputidpool &= ~(1u << output->id); + output->id = 0xffffffff; /* invalid */ } /** Sets the output scale for a given output. @@ -4768,9 +4784,6 @@ westonoutputenable(struct westonoutput *output) /* Make sure we have a transform set */ assert(output->transform != UINT32MAX); - /* Verify we haven't reached the limit of 32 available output IDs */ - assert(ffs(~c->outputidpool) > 0); - output->x = x; output->y = y; output->dirty = 1; @@ -4788,13 +4801,6 @@ westonoutputenable(struct westonoutput *output) wllistinit(&output->resourcelist); wllistinit(&output->feedbacklist); - /* Invert the output id pool and look for the lowest numbered - * switch (the least significant bit). Take that bit's position - * as our ID, and mark it used in the compositor's outputidpool. - */ - output->id = ffs(~output->compositor->outputidpool) - 1; - output->compositor->outputidpool |= 1u << output->id; - output->global = wlglobalcreate(c->wldisplay, &wloutputinterface, 3, output, bindoutput);



More information about the wayland-devel mailing list