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 <marius.vlad@collabora.com>
This commit is contained in:
committed by
Daniel Stone
parent
bc137e345f
commit
880b485d76
+8
-1
@@ -2918,6 +2918,7 @@ int main(int argc, char *argv[])
|
|||||||
struct wl_listener primary_client_destroyed;
|
struct wl_listener primary_client_destroyed;
|
||||||
struct weston_seat *seat;
|
struct weston_seat *seat;
|
||||||
struct wet_compositor wet = { 0 };
|
struct wet_compositor wet = { 0 };
|
||||||
|
struct weston_debug_compositor *wdc = NULL;
|
||||||
int require_input;
|
int require_input;
|
||||||
sigset_t mask;
|
sigset_t mask;
|
||||||
|
|
||||||
@@ -2961,6 +2962,12 @@ int main(int argc, char *argv[])
|
|||||||
return EXIT_SUCCESS;
|
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_set_handler(vlog, vlog_continue);
|
||||||
weston_log_file_open(log);
|
weston_log_file_open(log);
|
||||||
|
|
||||||
@@ -3025,7 +3032,7 @@ int main(int argc, char *argv[])
|
|||||||
backend = weston_choose_default_backend();
|
backend = weston_choose_default_backend();
|
||||||
}
|
}
|
||||||
|
|
||||||
wet.compositor = weston_compositor_create(display, &wet);
|
wet.compositor = weston_compositor_create(display, wdc, &wet);
|
||||||
if (wet.compositor == NULL) {
|
if (wet.compositor == NULL) {
|
||||||
weston_log("fatal: failed to create compositor\n");
|
weston_log("fatal: failed to create compositor\n");
|
||||||
goto out;
|
goto out;
|
||||||
|
|||||||
@@ -1982,7 +1982,8 @@ weston_compositor_print_scene_graph(struct weston_compositor *ec);
|
|||||||
void
|
void
|
||||||
weston_compositor_destroy(struct weston_compositor *ec);
|
weston_compositor_destroy(struct weston_compositor *ec);
|
||||||
struct weston_compositor *
|
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 {
|
enum weston_compositor_backend {
|
||||||
WESTON_BACKEND_DRM,
|
WESTON_BACKEND_DRM,
|
||||||
@@ -2376,8 +2377,12 @@ int
|
|||||||
weston_compositor_enable_touch_calibrator(struct weston_compositor *compositor,
|
weston_compositor_enable_touch_calibrator(struct weston_compositor *compositor,
|
||||||
weston_touch_calibration_save_func save);
|
weston_touch_calibration_save_func save);
|
||||||
|
|
||||||
|
struct weston_debug_compositor *
|
||||||
|
weston_debug_compositor_create(void);
|
||||||
|
|
||||||
int
|
int
|
||||||
weston_debug_compositor_create(struct weston_compositor *compositor);
|
weston_debug_compositor_setup(struct weston_compositor *compositor,
|
||||||
|
struct weston_debug_compositor *wdc);
|
||||||
|
|
||||||
void
|
void
|
||||||
weston_debug_compositor_destroy(struct weston_compositor *compositor);
|
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 display The Wayland display to be used.
|
||||||
* \param user_data A pointer to an object that can later be retrieved
|
* \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.
|
* using the \ref weston_compositor_get_user_data function.
|
||||||
* \return The compositor instance on success or NULL on failure.
|
* \return The compositor instance on success or NULL on failure.
|
||||||
*/
|
*/
|
||||||
WL_EXPORT struct weston_compositor *
|
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 weston_compositor *ec;
|
||||||
struct wl_event_loop *loop;
|
struct wl_event_loop *loop;
|
||||||
@@ -6840,7 +6843,7 @@ weston_compositor_create(struct wl_display *display, void *user_data)
|
|||||||
ec, bind_presentation))
|
ec, bind_presentation))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (weston_debug_compositor_create(ec) < 0)
|
if (weston_debug_compositor_setup(ec, wdc) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (weston_input_init(ec) != 0)
|
if (weston_input_init(ec) != 0)
|
||||||
|
|||||||
+26
-10
@@ -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
|
/** Initialize weston-debug structure
|
||||||
*
|
*
|
||||||
* \param compositor The libweston compositor.
|
* \param compositor The libweston compositor.
|
||||||
@@ -264,24 +286,18 @@ bind_weston_debug(struct wl_client *client,
|
|||||||
*
|
*
|
||||||
* \internal
|
* \internal
|
||||||
*/
|
*/
|
||||||
int
|
WL_EXPORT struct weston_debug_compositor *
|
||||||
weston_debug_compositor_create(struct weston_compositor *compositor)
|
weston_debug_compositor_create(void)
|
||||||
{
|
{
|
||||||
struct weston_debug_compositor *wdc;
|
struct weston_debug_compositor *wdc;
|
||||||
|
|
||||||
if (compositor->weston_debug)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
wdc = zalloc(sizeof *wdc);
|
wdc = zalloc(sizeof *wdc);
|
||||||
if (!wdc)
|
if (!wdc)
|
||||||
return -1;
|
return NULL;
|
||||||
|
|
||||||
wdc->compositor = compositor;
|
|
||||||
wl_list_init(&wdc->scope_list);
|
wl_list_init(&wdc->scope_list);
|
||||||
|
|
||||||
compositor->weston_debug = wdc;
|
return wdc;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Destroy weston_debug_compositor structure
|
/** Destroy weston_debug_compositor structure
|
||||||
|
|||||||
Reference in New Issue
Block a user