Commit 880b485d authored by Marius Vlad's avatar Marius Vlad Committed by Daniel Stone

libweston: Decouple weston_debug_compositor from weston_compositor

This patch allows initialization of weston-debug/log framework much earlier
than weston_compositor, which in turn will provide the option start
logging before weston_compositor has been created.
Signed-off-by: Marius Vlad's avatarMarius Vlad <marius.vlad@collabora.com>
parent bc137e34
......@@ -2918,6 +2918,7 @@ int main(int argc, char *argv[])
struct wl_listener primary_client_destroyed;
struct weston_seat *seat;
struct wet_compositor wet = { 0 };
struct weston_debug_compositor *wdc = NULL;
int require_input;
sigset_t mask;
......@@ -2961,6 +2962,12 @@ int main(int argc, char *argv[])
return EXIT_SUCCESS;
}
wdc = weston_debug_compositor_create();
if (!wdc) {
fprintf(stderr, "Failed to initialize weston debug framework.\n");
return EXIT_FAILURE;
}
weston_log_set_handler(vlog, vlog_continue);
weston_log_file_open(log);
......@@ -3025,7 +3032,7 @@ int main(int argc, char *argv[])
backend = weston_choose_default_backend();
}
wet.compositor = weston_compositor_create(display, &wet);
wet.compositor = weston_compositor_create(display, wdc, &wet);
if (wet.compositor == NULL) {
weston_log("fatal: failed to create compositor\n");
goto out;
......
......@@ -1982,7 +1982,8 @@ weston_compositor_print_scene_graph(struct weston_compositor *ec);
void
weston_compositor_destroy(struct weston_compositor *ec);
struct weston_compositor *
weston_compositor_create(struct wl_display *display, void *user_data);
weston_compositor_create(struct wl_display *display,
struct weston_debug_compositor *wdc, void *user_data);
enum weston_compositor_backend {
WESTON_BACKEND_DRM,
......@@ -2376,8 +2377,12 @@ int
weston_compositor_enable_touch_calibrator(struct weston_compositor *compositor,
weston_touch_calibration_save_func save);
struct weston_debug_compositor *
weston_debug_compositor_create(void);
int
weston_debug_compositor_create(struct weston_compositor *compositor);
weston_debug_compositor_setup(struct weston_compositor *compositor,
struct weston_debug_compositor *wdc);
void
weston_debug_compositor_destroy(struct weston_compositor *compositor);
......
......@@ -6782,11 +6782,14 @@ debug_scene_graph_cb(struct weston_debug_stream *stream, void *data)
*
* \param display The Wayland display to be used.
* \param user_data A pointer to an object that can later be retrieved
* \param wdc A pointer to weston_debug_compositor
* using the \ref weston_compositor_get_user_data function.
* \return The compositor instance on success or NULL on failure.
*/
WL_EXPORT struct weston_compositor *
weston_compositor_create(struct wl_display *display, void *user_data)
weston_compositor_create(struct wl_display *display,
struct weston_debug_compositor *wdc,
void *user_data)
{
struct weston_compositor *ec;
struct wl_event_loop *loop;
......@@ -6840,7 +6843,7 @@ weston_compositor_create(struct wl_display *display, void *user_data)
ec, bind_presentation))
goto fail;
if (weston_debug_compositor_create(ec) < 0)
if (weston_debug_compositor_setup(ec, wdc) < 0)
goto fail;
if (weston_input_init(ec) != 0)
......
......@@ -253,6 +253,28 @@ bind_weston_debug(struct wl_client *client,
}
}
/**
* Connect weston-compositor structure to weston-debug structure
* an vice versa.
*
* \param compositor
* \param wdc
* \return 0 on success, -1 on failure
*
*/
int
weston_debug_compositor_setup(struct weston_compositor *compositor,
struct weston_debug_compositor *wdc)
{
if (compositor->weston_debug)
return -1;
wdc->compositor = compositor;
compositor->weston_debug = wdc;
return 0;
}
/** Initialize weston-debug structure
*
* \param compositor The libweston compositor.
......@@ -264,24 +286,18 @@ bind_weston_debug(struct wl_client *client,
*
* \internal
*/
int
weston_debug_compositor_create(struct weston_compositor *compositor)
WL_EXPORT struct weston_debug_compositor *
weston_debug_compositor_create(void)
{
struct weston_debug_compositor *wdc;
if (compositor->weston_debug)
return -1;
wdc = zalloc(sizeof *wdc);
if (!wdc)
return -1;
return NULL;
wdc->compositor = compositor;
wl_list_init(&wdc->scope_list);
compositor->weston_debug = wdc;
return 0;
return wdc;
}
/** Destroy weston_debug_compositor structure
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment