scaled-scene-buffer: reduce unnecessary renderings

Prior to this commit, a backing buffer with scale 1 was always created for
a scaled_scene_buffer before showing it, and backing buffers for specific
scales were created on output_enter events.

This commit removes this redundant re-renderings by calling
wlr_scene_buffer_set_dest_size() upon scaled_scene_buffer creation just to
receive output_enter events and delaying the first rendering to the first
output_enter event.

I needed to add font_get_buffer_size() to obtain the size of a font buffer
without actually creating it.
This commit is contained in:
tokyo4j 2024-12-03 16:18:52 +09:00 committed by Hiroaki Yamamoto
parent cc838e79ed
commit 5db953aa89
6 changed files with 69 additions and 23 deletions

View file

@ -36,6 +36,12 @@ int font_height(struct font *font);
*/
int font_width(struct font *font, const char *string);
/**
* font_get_buffer_size - dry-run font_buffer_create() to get buffer size
*/
void font_get_buffer_size(int max_width, const char *text, struct font *font,
int *width, int *height);
/**
* font_buffer_create - Create ARGB8888 lab_data_buffer using pango
* @buffer: buffer pointer

View file

@ -96,8 +96,17 @@ struct scaled_scene_buffer *scaled_scene_buffer_create(
const struct scaled_scene_buffer_impl *implementation,
struct wl_list *cached_buffers, bool drop_buffer);
/* Clear the cache of existing buffers, useful in case the content changes */
void scaled_scene_buffer_invalidate_cache(struct scaled_scene_buffer *self);
/**
* scaled_scene_buffer_request_update - mark the buffer that needs to be
* updated
* @width: the width of the buffer to be rendered, in scene coordinates
* @height: the height of the buffer to be rendered, in scene coordinates
*
* This function should be called when the states bound to the buffer are
* updated and ready for rendering.
*/
void scaled_scene_buffer_request_update(struct scaled_scene_buffer *self,
int width, int height);
/* Private */
struct scaled_scene_buffer_cache_entry {