libweston: consolidate weston_compositor_create_output(_with_head)

Add a struct weston_head parameter to weston_compositor_create_output()
and fold weston_compositor_create_output_with_head() into it.

See: https://gitlab.freedesktop.org/wayland/weston/-/issues/268

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
dev
Philipp Zabel 4 years ago committed by Pekka Paalanen
parent 060ef82d93
commit c6e47d177a
  1. 6
      compositor/main.c
  2. 2
      doc/sphinx/toc/libweston/images/create_output.msc
  3. 6
      include/libweston/libweston.h
  4. 36
      libweston/compositor.c

@ -1696,8 +1696,8 @@ simple_head_enable(struct wet_compositor *wet, struct weston_head *head)
struct weston_output *output;
int ret = 0;
output = weston_compositor_create_output_with_head(wet->compositor,
head);
output = weston_compositor_create_output(wet->compositor, head,
head->name);
if (!output) {
weston_log("Could not create an output for head \"%s\".\n",
weston_head_get_name(head));
@ -2162,7 +2162,7 @@ wet_layoutput_create_output(struct wet_layoutput *lo, const char *name)
output->output =
weston_compositor_create_output(lo->compositor->compositor,
name);
NULL, name);
if (!output->output) {
free(output);
return NULL;

@ -11,7 +11,7 @@ msc {
--- [label = "Compositor creates an output for a head"];
c box c [label = "Have an existing head to process."];
c => w [label = "weston_compositor_create_output_with_head()"];
c => w [label = "weston_compositor_create_output()"];
w => b [label = "weston_backend::create_output()"];
w << b [label = "an empty output, no hw resources"];
w => b [label = "weston_output::attach_head()"];

@ -2228,11 +2228,7 @@ weston_compositor_find_output_by_name(struct weston_compositor *compositor,
struct weston_output *
weston_compositor_create_output(struct weston_compositor *compositor,
const char *name);
struct weston_output *
weston_compositor_create_output_with_head(struct weston_compositor *compositor,
struct weston_head *head);
struct weston_head *head, const char *name);
void
weston_output_destroy(struct weston_output *output);

@ -7306,13 +7306,15 @@ weston_compositor_find_output_by_name(struct weston_compositor *compositor,
return NULL;
}
/** Create a named output
/** Create a named output for an unused head
*
* \param compositor The compositor.
* \param head The head to attach to the output.
* \param name The name for the output.
* \return A new \c weston_output, or NULL on failure.
*
* This creates a new weston_output that starts with no heads attached.
* This creates a new weston_output that starts with the given head attached.
* The head must not be already attached to another output.
*
* An output must be configured and it must have at least one head before
* it can be enabled.
@ -7321,8 +7323,11 @@ weston_compositor_find_output_by_name(struct weston_compositor *compositor,
*/
WL_EXPORT struct weston_output *
weston_compositor_create_output(struct weston_compositor *compositor,
struct weston_head *head,
const char *name)
{
struct weston_output *output;
assert(compositor->backend->create_output);
if (weston_compositor_find_output_by_name(compositor, name)) {
@ -7331,34 +7336,11 @@ weston_compositor_create_output(struct weston_compositor *compositor,
return NULL;
}
return compositor->backend->create_output(compositor, name);
}
/** Create an output for an unused head
*
* \param compositor The compositor.
* \param head The head to attach to the output.
* \return A new \c weston_output, or NULL on failure.
*
* This creates a new weston_output that starts with the given head attached.
* The output inherits the name of the head. The head must not be already
* attached to another output.
*
* An output must be configured before it can be enabled.
*
* \ingroup compositor
*/
WL_EXPORT struct weston_output *
weston_compositor_create_output_with_head(struct weston_compositor *compositor,
struct weston_head *head)
{
struct weston_output *output;
output = weston_compositor_create_output(compositor, head->name);
output = compositor->backend->create_output(compositor, name);
if (!output)
return NULL;
if (weston_output_attach_head(output, head) < 0) {
if (head && weston_output_attach_head(output, head) < 0) {
weston_output_destroy(output);
return NULL;
}

Loading…
Cancel
Save