mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-03-21 14:30:35 +01:00
libweston: print scene-graph into FILE
Being able to print the scene-graph straight into a FILE removes one temporary memory allocation that used to be mandatory. That memory allocation is now gone from the DRM-backend debug log. It has moved into the scene-graph log scope. In the case of weston_log_subscription_printf() it shouldn't matter, because it is only used when new subscribers appear. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
parent
60567e7bd6
commit
e9665ef36f
3 changed files with 20 additions and 21 deletions
|
|
@ -1215,16 +1215,17 @@ drm_repaint_flush(struct weston_backend *backend)
|
|||
{
|
||||
struct drm_backend *b = container_of(backend, struct drm_backend, base);
|
||||
struct drm_device *device;
|
||||
FILE *dbg;
|
||||
|
||||
WESTON_TRACE_FUNC();
|
||||
|
||||
wl_list_for_each(device, &b->kms_list, link)
|
||||
drm_repaint_flush_device(device);
|
||||
|
||||
if (weston_log_scope_is_enabled(b->debug)) {
|
||||
char *dbg = weston_compositor_print_scene_graph(b->compositor);
|
||||
drm_debug(b, "%s", dbg);
|
||||
free(dbg);
|
||||
dbg = weston_log_scope_stream(b->debug);
|
||||
if (dbg) {
|
||||
weston_compositor_print_scene_graph(b->compositor, dbg);
|
||||
fflush(dbg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9759,25 +9759,25 @@ debug_scene_view_print_tree(struct weston_view *view, FILE *fp)
|
|||
* Output information on how libweston is currently composing the scene
|
||||
* graph.
|
||||
*
|
||||
* \param ec The compositor has a single scene-graph.
|
||||
* \param fp A writable stream where the scene-graph is printed.
|
||||
* Can also be NULL to skip printing.
|
||||
*
|
||||
* \ingroup compositor
|
||||
*/
|
||||
WL_EXPORT char *
|
||||
weston_compositor_print_scene_graph(struct weston_compositor *ec)
|
||||
WL_EXPORT void
|
||||
weston_compositor_print_scene_graph(struct weston_compositor *ec, FILE *fp)
|
||||
{
|
||||
struct weston_output *output;
|
||||
struct weston_layer *layer;
|
||||
struct timespec now;
|
||||
int layer_idx = 0;
|
||||
FILE *fp;
|
||||
char *ret;
|
||||
size_t len;
|
||||
int err;
|
||||
|
||||
if (!fp)
|
||||
return;
|
||||
|
||||
WESTON_TRACE_FUNC();
|
||||
|
||||
fp = open_memstream(&ret, &len);
|
||||
assert(fp);
|
||||
|
||||
weston_compositor_read_presentation_clock(ec, &now);
|
||||
fprintf(fp, "Weston scene graph at %" PRId64 ".%09ld:\n\n",
|
||||
(int64_t)now.tv_sec, now.tv_nsec);
|
||||
|
|
@ -9849,11 +9849,6 @@ weston_compositor_print_scene_graph(struct weston_compositor *ec)
|
|||
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
|
||||
err = fclose(fp);
|
||||
assert(err == 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -9891,6 +9886,7 @@ static void
|
|||
debug_scene_graph_cb(struct weston_log_subscription *sub, void *data)
|
||||
{
|
||||
struct weston_compositor *ec = data;
|
||||
FILE *fp;
|
||||
char *str;
|
||||
|
||||
/* If the presentation_clock is CLOCK_REALTIME, then it is
|
||||
|
|
@ -9899,7 +9895,9 @@ debug_scene_graph_cb(struct weston_log_subscription *sub, void *data)
|
|||
if (ec->presentation_clock == CLOCK_REALTIME)
|
||||
return;
|
||||
|
||||
str = weston_compositor_print_scene_graph(ec);
|
||||
fp = open_memstream(&str, NULL);
|
||||
weston_compositor_print_scene_graph(ec, fp);
|
||||
fclose(fp);
|
||||
|
||||
weston_log_subscription_write(sub, str, strlen(str));
|
||||
free(str);
|
||||
|
|
|
|||
|
|
@ -329,8 +329,8 @@ weston_compositor_dmabuf_can_scanout(struct weston_compositor *compositor,
|
|||
void
|
||||
weston_compositor_offscreen(struct weston_compositor *compositor);
|
||||
|
||||
char *
|
||||
weston_compositor_print_scene_graph(struct weston_compositor *ec);
|
||||
void
|
||||
weston_compositor_print_scene_graph(struct weston_compositor *ec, FILE *fp);
|
||||
|
||||
void
|
||||
weston_compositor_read_presentation_clock(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue