scaled-scene-buffer: restructure source files
Some checks failed
labwc.github.io / notify (push) Has been cancelled

- Rename `scaled_scene_buffer` to `scaled_buffer`. This makes it clear
  that `scaled_{font,img,icon}_buffers` are implementations of it.
- Move the files from `src/common` to `src/scaled-buffer` as
  `scaled_icon_buffer` heavily depends on `server` and `view` etc.
This commit is contained in:
tokyo4j 2025-09-02 17:47:01 +09:00 committed by Johan Malm
parent 02be24bf59
commit 074b27fd47
22 changed files with 128 additions and 125 deletions

View file

@ -8,7 +8,7 @@ struct lab_layer_surface;
struct lab_layer_popup; struct lab_layer_popup;
struct menuitem; struct menuitem;
struct ssd_part; struct ssd_part;
struct scaled_scene_buffer; struct scaled_buffer;
enum node_descriptor_type { enum node_descriptor_type {
LAB_NODE_DESC_NODE = 0, LAB_NODE_DESC_NODE = 0,
@ -20,7 +20,7 @@ enum node_descriptor_type {
LAB_NODE_DESC_IME_POPUP, LAB_NODE_DESC_IME_POPUP,
LAB_NODE_DESC_MENUITEM, LAB_NODE_DESC_MENUITEM,
LAB_NODE_DESC_TREE, LAB_NODE_DESC_TREE,
LAB_NODE_DESC_SCALED_SCENE_BUFFER, LAB_NODE_DESC_SCALED_BUFFER,
LAB_NODE_DESC_SSD_PART, LAB_NODE_DESC_SSD_PART,
}; };
@ -84,10 +84,10 @@ struct ssd_part *node_ssd_part_from_node(
struct wlr_scene_node *wlr_scene_node); struct wlr_scene_node *wlr_scene_node);
/** /**
* node_scaled_scene_buffer_from_node - return scaled_scene_buffer from node * node_scaled_buffer_from_node - return scaled_buffer from node
* @wlr_scene_node: wlr_scene_node from which to return data * @wlr_scene_node: wlr_scene_node from which to return data
*/ */
struct scaled_scene_buffer *node_scaled_scene_buffer_from_node( struct scaled_buffer *node_scaled_buffer_from_node(
struct wlr_scene_node *wlr_scene_node); struct wlr_scene_node *wlr_scene_node);
#endif /* LABWC_NODE_DESCRIPTOR_H */ #endif /* LABWC_NODE_DESCRIPTOR_H */

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */ /* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_SCALED_SCENE_BUFFER_H #ifndef LABWC_SCALED_BUFFER_H
#define LABWC_SCALED_SCENE_BUFFER_H #define LABWC_SCALED_BUFFER_H
#include <wayland-server-core.h> #include <wayland-server-core.h>
@ -9,20 +9,20 @@
struct wlr_buffer; struct wlr_buffer;
struct wlr_scene_tree; struct wlr_scene_tree;
struct lab_data_buffer; struct lab_data_buffer;
struct scaled_scene_buffer; struct scaled_buffer;
struct scaled_scene_buffer_impl { struct scaled_buffer_impl {
/* Return a new buffer optimized for the new scale */ /* Return a new buffer optimized for the new scale */
struct lab_data_buffer *(*create_buffer) struct lab_data_buffer *(*create_buffer)
(struct scaled_scene_buffer *scaled_buffer, double scale); (struct scaled_buffer *scaled_buffer, double scale);
/* Might be NULL or used for cleaning up */ /* Might be NULL or used for cleaning up */
void (*destroy)(struct scaled_scene_buffer *scaled_buffer); void (*destroy)(struct scaled_buffer *scaled_buffer);
/* Returns true if the two buffers are visually the same */ /* Returns true if the two buffers are visually the same */
bool (*equal)(struct scaled_scene_buffer *scaled_buffer_a, bool (*equal)(struct scaled_buffer *scaled_buffer_a,
struct scaled_scene_buffer *scaled_buffer_b); struct scaled_buffer *scaled_buffer_b);
}; };
struct scaled_scene_buffer { struct scaled_buffer {
struct wlr_scene_buffer *scene_buffer; struct wlr_scene_buffer *scene_buffer;
int width; /* unscaled, read only */ int width; /* unscaled, read only */
int height; /* unscaled, read only */ int height; /* unscaled, read only */
@ -35,7 +35,7 @@ struct scaled_scene_buffer {
struct wl_list cache; /* struct scaled_buffer_cache_entry.link */ struct wl_list cache; /* struct scaled_buffer_cache_entry.link */
struct wl_listener destroy; struct wl_listener destroy;
struct wl_listener outputs_update; struct wl_listener outputs_update;
const struct scaled_scene_buffer_impl *impl; const struct scaled_buffer_impl *impl;
struct wl_list link; /* all_scaled_buffers */ struct wl_list link; /* all_scaled_buffers */
}; };
@ -78,22 +78,22 @@ struct scaled_scene_buffer {
* to handle the majority of use cases where a view is moved between no more * to handle the majority of use cases where a view is moved between no more
* than two different scales. * than two different scales.
* *
* scaled_scene_buffer will clean up automatically once the internal * scaled_buffer will clean up automatically once the internal
* wlr_scene_buffer is being destroyed. If implementation->destroy is set * wlr_scene_buffer is being destroyed. If implementation->destroy is set
* it will also get called so a consumer of this API may clean up its own * it will also get called so a consumer of this API may clean up its own
* allocations. * allocations.
* *
* Besides caching buffers for each scale per scaled_scene_buffer, we also * Besides caching buffers for each scale per scaled_buffer, we also
* store all the scaled_scene_buffers from all the implementers in a list * store all the scaled_buffers from all the implementers in a list
* in order to reuse backing buffers for visually duplicated * in order to reuse backing buffers for visually duplicated
* scaled_scene_buffers found via impl->equal(). * scaled_buffers found via impl->equal().
* *
* All requested lab_data_buffers via impl->create_buffer() will be locked * All requested lab_data_buffers via impl->create_buffer() will be locked
* during the lifetime of the buffer in the internal cache and unlocked * during the lifetime of the buffer in the internal cache and unlocked
* when being evacuated from the cache (due to LAB_SCALED_BUFFER_MAX_CACHE * when being evacuated from the cache (due to LAB_SCALED_BUFFER_MAX_CACHE
* or the internal wlr_scene_buffer being destroyed). * or the internal wlr_scene_buffer being destroyed).
* *
* If drop_buffer was set during creation of the scaled_scene_buffer, the * If drop_buffer was set during creation of the scaled_buffer, the
* backing wlr_buffer behind a lab_data_buffer will also get dropped * backing wlr_buffer behind a lab_data_buffer will also get dropped
* (via wlr_buffer_drop). If there are no more locks (consumers) of the * (via wlr_buffer_drop). If there are no more locks (consumers) of the
* respective buffer this will then cause the lab_data_buffer to be free'd. * respective buffer this will then cause the lab_data_buffer to be free'd.
@ -103,21 +103,21 @@ struct scaled_scene_buffer {
* destroyed until the buffer is evacuated from the internal cache and thus * destroyed until the buffer is evacuated from the internal cache and thus
* unlocked. * unlocked.
* *
* This allows using scaled_scene_buffer for an autoscaling font_buffer * This allows using scaled_buffer for an autoscaling font_buffer
* (which gets free'd automatically) and also for theme components like * (which gets free'd automatically) and also for theme components like
* rounded corner images or button icons whose buffers only exist once but * rounded corner images or button icons whose buffers only exist once but
* are references by multiple windows with their own scaled_scene_buffers. * are references by multiple windows with their own scaled_buffers.
* *
* The rough idea is: use drop_buffer = true for one-shot buffers and false * The rough idea is: use drop_buffer = true for one-shot buffers and false
* for buffers that should outlive the scaled_scene_buffer instance itself. * for buffers that should outlive the scaled_buffer instance itself.
*/ */
struct scaled_scene_buffer *scaled_scene_buffer_create( struct scaled_buffer *scaled_buffer_create(
struct wlr_scene_tree *parent, struct wlr_scene_tree *parent,
const struct scaled_scene_buffer_impl *implementation, const struct scaled_buffer_impl *implementation,
bool drop_buffer); bool drop_buffer);
/** /**
* scaled_scene_buffer_request_update - mark the buffer that needs to be * scaled_buffer_request_update - mark the buffer that needs to be
* updated * updated
* @width: the width of the buffer to be rendered, in scene coordinates * @width: the width of the buffer to be rendered, in scene coordinates
* @height: the height of the buffer to be rendered, in scene coordinates * @height: the height of the buffer to be rendered, in scene coordinates
@ -125,22 +125,22 @@ struct scaled_scene_buffer *scaled_scene_buffer_create(
* This function should be called when the states bound to the buffer are * This function should be called when the states bound to the buffer are
* updated and ready for rendering. * updated and ready for rendering.
*/ */
void scaled_scene_buffer_request_update(struct scaled_scene_buffer *self, void scaled_buffer_request_update(struct scaled_buffer *self,
int width, int height); int width, int height);
/** /**
* scaled_scene_buffer_invalidate_sharing - clear the list of entire cached * scaled_buffer_invalidate_sharing - clear the list of entire cached
* scaled_scene_buffers used to share visually dupliated buffers. This should * scaled_buffers used to share visually dupliated buffers. This should
* be called on Reconfigure to force updates of newly created * be called on Reconfigure to force updates of newly created
* scaled_scene_buffers rather than reusing ones created before Reconfigure. * scaled_buffers rather than reusing ones created before Reconfigure.
*/ */
void scaled_scene_buffer_invalidate_sharing(void); void scaled_buffer_invalidate_sharing(void);
/* Private */ /* Private */
struct scaled_scene_buffer_cache_entry { struct scaled_buffer_cache_entry {
struct wl_list link; /* struct scaled_scene_buffer.cache */ struct wl_list link; /* struct scaled_buffer.cache */
struct wlr_buffer *buffer; struct wlr_buffer *buffer;
double scale; double scale;
}; };
#endif /* LABWC_SCALED_SCENE_BUFFER_H */ #endif /* LABWC_SCALED_BUFFER_H */

View file

@ -6,7 +6,7 @@
struct wlr_scene_tree; struct wlr_scene_tree;
struct wlr_scene_buffer; struct wlr_scene_buffer;
struct scaled_scene_buffer; struct scaled_buffer;
struct scaled_font_buffer { struct scaled_font_buffer {
struct wlr_scene_buffer *scene_buffer; struct wlr_scene_buffer *scene_buffer;
@ -19,7 +19,7 @@ struct scaled_font_buffer {
float color[4]; float color[4];
float bg_color[4]; float bg_color[4];
struct font font; struct font font;
struct scaled_scene_buffer *scaled_buffer; struct scaled_buffer *scaled_buffer;
/* /*
* The following fields are used only for the titlebar, where * The following fields are used only for the titlebar, where
@ -34,7 +34,7 @@ struct scaled_font_buffer {
/** /**
* Create an auto scaling font buffer, providing a wlr_scene_buffer node for * Create an auto scaling font buffer, providing a wlr_scene_buffer node for
* display. It gets destroyed automatically when the backing scaled_scene_buffer * display. It gets destroyed automatically when the backing scaled_buffer
* is being destroyed which in turn happens automatically when the backing * is being destroyed which in turn happens automatically when the backing
* wlr_scene_buffer (or one of its parents) is being destroyed. * wlr_scene_buffer (or one of its parents) is being destroyed.
* *

View file

@ -10,7 +10,7 @@ struct wlr_scene_node;
struct wlr_scene_buffer; struct wlr_scene_buffer;
struct scaled_icon_buffer { struct scaled_icon_buffer {
struct scaled_scene_buffer *scaled_buffer; struct scaled_buffer *scaled_buffer;
struct wlr_scene_buffer *scene_buffer; struct wlr_scene_buffer *scene_buffer;
struct server *server; struct server *server;
/* for window icon */ /* for window icon */
@ -34,7 +34,7 @@ struct scaled_icon_buffer {
/* /*
* Create an auto scaling icon buffer, providing a wlr_scene_buffer node for * Create an auto scaling icon buffer, providing a wlr_scene_buffer node for
* display. It gets destroyed automatically when the backing scaled_scene_buffer * display. It gets destroyed automatically when the backing scaled_buffer
* is being destroyed which in turn happens automatically when the backing * is being destroyed which in turn happens automatically when the backing
* wlr_scene_buffer (or one of its parents) is being destroyed. * wlr_scene_buffer (or one of its parents) is being destroyed.
*/ */

View file

@ -10,7 +10,7 @@ struct wlr_scene_buffer;
struct lab_img; struct lab_img;
struct scaled_img_buffer { struct scaled_img_buffer {
struct scaled_scene_buffer *scaled_buffer; struct scaled_buffer *scaled_buffer;
struct wlr_scene_buffer *scene_buffer; struct wlr_scene_buffer *scene_buffer;
struct lab_img *img; struct lab_img *img;
int width; int width;
@ -56,7 +56,7 @@ struct scaled_img_buffer {
/* /*
* Create an auto scaling image buffer, providing a wlr_scene_buffer node for * Create an auto scaling image buffer, providing a wlr_scene_buffer node for
* display. It gets destroyed automatically when the backing scaled_scene_buffer * display. It gets destroyed automatically when the backing scaled_buffer
* is being destroyed which in turn happens automatically when the backing * is being destroyed which in turn happens automatically when the backing
* wlr_scene_buffer (or one of its parents) is being destroyed. * wlr_scene_buffer (or one of its parents) is being destroyed.
* *

View file

@ -14,10 +14,6 @@ labwc_sources += files(
'nodename.c', 'nodename.c',
'parse-bool.c', 'parse-bool.c',
'parse-double.c', 'parse-double.c',
'scaled-font-buffer.c',
'scaled-icon-buffer.c',
'scaled-img-buffer.c',
'scaled-scene-buffer.c',
'scene-helpers.c', 'scene-helpers.c',
'set.c', 'set.c',
'surface-helpers.c', 'surface-helpers.c',

View file

@ -350,7 +350,7 @@ get_cursor_context(struct server *server)
return ret; return ret;
case LAB_NODE_DESC_NODE: case LAB_NODE_DESC_NODE:
case LAB_NODE_DESC_TREE: case LAB_NODE_DESC_TREE:
case LAB_NODE_DESC_SCALED_SCENE_BUFFER: case LAB_NODE_DESC_SCALED_BUFFER:
break; break;
} }
} }

View file

@ -20,19 +20,19 @@
#include "common/lab-scene-rect.h" #include "common/lab-scene-rect.h"
#include "common/list.h" #include "common/list.h"
#include "common/mem.h" #include "common/mem.h"
#include "common/scaled-font-buffer.h"
#include "common/scaled-icon-buffer.h"
#include "common/scene-helpers.h" #include "common/scene-helpers.h"
#include "common/spawn.h" #include "common/spawn.h"
#include "common/string-helpers.h" #include "common/string-helpers.h"
#include "common/xml.h" #include "common/xml.h"
#include "config/rcxml.h" #include "config/rcxml.h"
#include "labwc.h" #include "labwc.h"
#include "output.h"
#include "workspaces.h"
#include "view.h"
#include "node.h" #include "node.h"
#include "output.h"
#include "scaled-buffer/scaled-font-buffer.h"
#include "scaled-buffer/scaled-icon-buffer.h"
#include "theme.h" #include "theme.h"
#include "view.h"
#include "workspaces.h"
#define PIPEMENU_MAX_BUF_SIZE 1048576 /* 1 MiB */ #define PIPEMENU_MAX_BUF_SIZE 1048576 /* 1 MiB */
#define PIPEMENU_TIMEOUT_IN_MS 4000 /* 4 seconds */ #define PIPEMENU_TIMEOUT_IN_MS 4000 /* 4 seconds */

View file

@ -56,4 +56,5 @@ subdir('input')
subdir('menu') subdir('menu')
subdir('osd') subdir('osd')
subdir('protocols') subdir('protocols')
subdir('scaled-buffer')
subdir('ssd') subdir('ssd')

View file

@ -80,11 +80,11 @@ node_ssd_part_from_node(struct wlr_scene_node *wlr_scene_node)
return (struct ssd_part *)node_descriptor->data; return (struct ssd_part *)node_descriptor->data;
} }
struct scaled_scene_buffer * struct scaled_buffer *
node_scaled_scene_buffer_from_node(struct wlr_scene_node *wlr_scene_node) node_scaled_buffer_from_node(struct wlr_scene_node *wlr_scene_node)
{ {
assert(wlr_scene_node->data); assert(wlr_scene_node->data);
struct node_descriptor *node_descriptor = wlr_scene_node->data; struct node_descriptor *node_descriptor = wlr_scene_node->data;
assert(node_descriptor->type == LAB_NODE_DESC_SCALED_SCENE_BUFFER); assert(node_descriptor->type == LAB_NODE_DESC_SCALED_BUFFER);
return (struct scaled_scene_buffer *)node_descriptor->data; return (struct scaled_buffer *)node_descriptor->data;
} }

View file

@ -7,8 +7,6 @@
#include "common/buf.h" #include "common/buf.h"
#include "common/font.h" #include "common/font.h"
#include "common/lab-scene-rect.h" #include "common/lab-scene-rect.h"
#include "common/scaled-font-buffer.h"
#include "common/scaled-icon-buffer.h"
#include "common/scene-helpers.h" #include "common/scene-helpers.h"
#include "common/string-helpers.h" #include "common/string-helpers.h"
#include "config/rcxml.h" #include "config/rcxml.h"
@ -16,6 +14,8 @@
#include "node.h" #include "node.h"
#include "osd.h" #include "osd.h"
#include "output.h" #include "output.h"
#include "scaled-buffer/scaled-font-buffer.h"
#include "scaled-buffer/scaled-icon-buffer.h"
#include "theme.h" #include "theme.h"
#include "view.h" #include "view.h"
#include "window-rules.h" #include "window-rules.h"

View file

@ -8,11 +8,11 @@
#include "common/array.h" #include "common/array.h"
#include "common/box.h" #include "common/box.h"
#include "common/lab-scene-rect.h" #include "common/lab-scene-rect.h"
#include "common/scaled-font-buffer.h"
#include "common/scaled-icon-buffer.h"
#include "labwc.h" #include "labwc.h"
#include "osd.h" #include "osd.h"
#include "output.h" #include "output.h"
#include "scaled-buffer/scaled-font-buffer.h"
#include "scaled-buffer/scaled-icon-buffer.h"
#include "theme.h" #include "theme.h"
#include "view.h" #include "view.h"

View file

@ -6,13 +6,13 @@
#include <wlr/util/box.h> #include <wlr/util/box.h>
#include "common/array.h" #include "common/array.h"
#include "common/lab-scene-rect.h" #include "common/lab-scene-rect.h"
#include "common/scaled-font-buffer.h"
#include "common/scaled-icon-buffer.h"
#include "common/scene-helpers.h" #include "common/scene-helpers.h"
#include "config/rcxml.h" #include "config/rcxml.h"
#include "labwc.h" #include "labwc.h"
#include "node.h" #include "node.h"
#include "output.h" #include "output.h"
#include "scaled-buffer/scaled-font-buffer.h"
#include "scaled-buffer/scaled-icon-buffer.h"
#include "theme.h" #include "theme.h"
#include "view.h" #include "view.h"
#include "window-rules.h" #include "window-rules.h"

View file

@ -0,0 +1,6 @@
labwc_sources += files(
'scaled-font-buffer.c',
'scaled-icon-buffer.c',
'scaled-img-buffer.c',
'scaled-buffer.c',
)

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
#define _POSIX_C_SOURCE 200809L #define _POSIX_C_SOURCE 200809L
#include "common/scaled-scene-buffer.h" #include "scaled-buffer/scaled-buffer.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
@ -15,14 +15,14 @@
#include "node.h" #include "node.h"
/* /*
* This holds all the scaled_scene_buffers from all the implementers. * This holds all the scaled_buffers from all the implementers.
* This is used to share visually duplicated buffers found via impl->equal(). * This is used to share visually duplicated buffers found via impl->equal().
*/ */
static struct wl_list all_scaled_buffers = WL_LIST_INIT(&all_scaled_buffers); static struct wl_list all_scaled_buffers = WL_LIST_INIT(&all_scaled_buffers);
/* Internal API */ /* Internal API */
static void static void
_cache_entry_destroy(struct scaled_scene_buffer_cache_entry *cache_entry, bool drop_buffer) _cache_entry_destroy(struct scaled_buffer_cache_entry *cache_entry, bool drop_buffer)
{ {
wl_list_remove(&cache_entry->link); wl_list_remove(&cache_entry->link);
if (cache_entry->buffer) { if (cache_entry->buffer) {
@ -35,10 +35,10 @@ _cache_entry_destroy(struct scaled_scene_buffer_cache_entry *cache_entry, bool d
free(cache_entry); free(cache_entry);
} }
static struct scaled_scene_buffer_cache_entry * static struct scaled_buffer_cache_entry *
find_cache_for_scale(struct scaled_scene_buffer *scene_buffer, double scale) find_cache_for_scale(struct scaled_buffer *scene_buffer, double scale)
{ {
struct scaled_scene_buffer_cache_entry *cache_entry; struct scaled_buffer_cache_entry *cache_entry;
wl_list_for_each(cache_entry, &scene_buffer->cache, link) { wl_list_for_each(cache_entry, &scene_buffer->cache, link) {
if (cache_entry->scale == scale) { if (cache_entry->scale == scale) {
return cache_entry; return cache_entry;
@ -48,12 +48,12 @@ find_cache_for_scale(struct scaled_scene_buffer *scene_buffer, double scale)
} }
static void static void
_update_buffer(struct scaled_scene_buffer *self, double scale) _update_buffer(struct scaled_buffer *self, double scale)
{ {
self->active_scale = scale; self->active_scale = scale;
/* Search for cached buffer of specified scale */ /* Search for cached buffer of specified scale */
struct scaled_scene_buffer_cache_entry *cache_entry = struct scaled_buffer_cache_entry *cache_entry =
find_cache_for_scale(self, scale); find_cache_for_scale(self, scale);
if (cache_entry) { if (cache_entry) {
/* LRU cache, recently used in front */ /* LRU cache, recently used in front */
@ -71,8 +71,8 @@ _update_buffer(struct scaled_scene_buffer *self, double scale)
struct wlr_buffer *wlr_buffer = NULL; struct wlr_buffer *wlr_buffer = NULL;
if (self->impl->equal) { if (self->impl->equal) {
/* Search from other cached scaled-scene-buffers */ /* Search from other cached scaled-buffers */
struct scaled_scene_buffer *scene_buffer; struct scaled_buffer *scene_buffer;
wl_list_for_each(scene_buffer, &all_scaled_buffers, link) { wl_list_for_each(scene_buffer, &all_scaled_buffers, link) {
if (scene_buffer == self) { if (scene_buffer == self) {
continue; continue;
@ -146,8 +146,8 @@ _update_buffer(struct scaled_scene_buffer *self, double scale)
static void static void
_handle_node_destroy(struct wl_listener *listener, void *data) _handle_node_destroy(struct wl_listener *listener, void *data)
{ {
struct scaled_scene_buffer_cache_entry *cache_entry, *cache_entry_tmp; struct scaled_buffer_cache_entry *cache_entry, *cache_entry_tmp;
struct scaled_scene_buffer *self = wl_container_of(listener, self, destroy); struct scaled_buffer *self = wl_container_of(listener, self, destroy);
wl_list_remove(&self->destroy.link); wl_list_remove(&self->destroy.link);
wl_list_remove(&self->outputs_update.link); wl_list_remove(&self->outputs_update.link);
@ -167,7 +167,7 @@ _handle_node_destroy(struct wl_listener *listener, void *data)
static void static void
_handle_outputs_update(struct wl_listener *listener, void *data) _handle_outputs_update(struct wl_listener *listener, void *data)
{ {
struct scaled_scene_buffer *self = struct scaled_buffer *self =
wl_container_of(listener, self, outputs_update); wl_container_of(listener, self, outputs_update);
double max_scale = 0; double max_scale = 0;
@ -181,16 +181,16 @@ _handle_outputs_update(struct wl_listener *listener, void *data)
} }
/* Public API */ /* Public API */
struct scaled_scene_buffer * struct scaled_buffer *
scaled_scene_buffer_create(struct wlr_scene_tree *parent, scaled_buffer_create(struct wlr_scene_tree *parent,
const struct scaled_scene_buffer_impl *impl, const struct scaled_buffer_impl *impl,
bool drop_buffer) bool drop_buffer)
{ {
assert(parent); assert(parent);
assert(impl); assert(impl);
assert(impl->create_buffer); assert(impl->create_buffer);
struct scaled_scene_buffer *self = znew(*self); struct scaled_buffer *self = znew(*self);
self->scene_buffer = wlr_scene_buffer_create(parent, NULL); self->scene_buffer = wlr_scene_buffer_create(parent, NULL);
if (!self->scene_buffer) { if (!self->scene_buffer) {
wlr_log(WLR_ERROR, "Failed to create scene buffer"); wlr_log(WLR_ERROR, "Failed to create scene buffer");
@ -198,7 +198,7 @@ scaled_scene_buffer_create(struct wlr_scene_tree *parent,
return NULL; return NULL;
} }
node_descriptor_create(&self->scene_buffer->node, node_descriptor_create(&self->scene_buffer->node,
LAB_NODE_DESC_SCALED_SCENE_BUFFER, self); LAB_NODE_DESC_SCALED_BUFFER, self);
self->impl = impl; self->impl = impl;
/* /*
@ -223,14 +223,14 @@ scaled_scene_buffer_create(struct wlr_scene_tree *parent,
} }
void void
scaled_scene_buffer_request_update(struct scaled_scene_buffer *self, scaled_buffer_request_update(struct scaled_buffer *self,
int width, int height) int width, int height)
{ {
assert(self); assert(self);
assert(width >= 0); assert(width >= 0);
assert(height >= 0); assert(height >= 0);
struct scaled_scene_buffer_cache_entry *cache_entry, *cache_entry_tmp; struct scaled_buffer_cache_entry *cache_entry, *cache_entry_tmp;
wl_list_for_each_safe(cache_entry, cache_entry_tmp, &self->cache, link) { wl_list_for_each_safe(cache_entry, cache_entry_tmp, &self->cache, link) {
_cache_entry_destroy(cache_entry, self->drop_buffer); _cache_entry_destroy(cache_entry, self->drop_buffer);
} }
@ -256,9 +256,9 @@ scaled_scene_buffer_request_update(struct scaled_scene_buffer *self,
} }
void void
scaled_scene_buffer_invalidate_sharing(void) scaled_buffer_invalidate_sharing(void)
{ {
struct scaled_scene_buffer *scene_buffer, *tmp; struct scaled_buffer *scene_buffer, *tmp;
wl_list_for_each_safe(scene_buffer, tmp, &all_scaled_buffers, link) { wl_list_for_each_safe(scene_buffer, tmp, &all_scaled_buffers, link) {
wl_list_remove(&scene_buffer->link); wl_list_remove(&scene_buffer->link);
wl_list_init(&scene_buffer->link); wl_list_init(&scene_buffer->link);

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
#define _POSIX_C_SOURCE 200809L #define _POSIX_C_SOURCE 200809L
#include "common/scaled-font-buffer.h" #include "scaled-buffer/scaled-font-buffer.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -10,11 +10,11 @@
#include "common/font.h" #include "common/font.h"
#include "common/graphic-helpers.h" #include "common/graphic-helpers.h"
#include "common/mem.h" #include "common/mem.h"
#include "common/scaled-scene-buffer.h"
#include "common/string-helpers.h" #include "common/string-helpers.h"
#include "scaled-buffer/scaled-buffer.h"
static struct lab_data_buffer * static struct lab_data_buffer *
_create_buffer(struct scaled_scene_buffer *scaled_buffer, double scale) _create_buffer(struct scaled_buffer *scaled_buffer, double scale)
{ {
struct lab_data_buffer *buffer = NULL; struct lab_data_buffer *buffer = NULL;
struct scaled_font_buffer *self = scaled_buffer->data; struct scaled_font_buffer *self = scaled_buffer->data;
@ -39,7 +39,7 @@ _create_buffer(struct scaled_scene_buffer *scaled_buffer, double scale)
} }
static void static void
_destroy(struct scaled_scene_buffer *scaled_buffer) _destroy(struct scaled_buffer *scaled_buffer)
{ {
struct scaled_font_buffer *self = scaled_buffer->data; struct scaled_font_buffer *self = scaled_buffer->data;
scaled_buffer->data = NULL; scaled_buffer->data = NULL;
@ -51,8 +51,8 @@ _destroy(struct scaled_scene_buffer *scaled_buffer)
} }
static bool static bool
_equal(struct scaled_scene_buffer *scaled_buffer_a, _equal(struct scaled_buffer *scaled_buffer_a,
struct scaled_scene_buffer *scaled_buffer_b) struct scaled_buffer *scaled_buffer_b)
{ {
struct scaled_font_buffer *a = scaled_buffer_a->data; struct scaled_font_buffer *a = scaled_buffer_a->data;
struct scaled_font_buffer *b = scaled_buffer_b->data; struct scaled_font_buffer *b = scaled_buffer_b->data;
@ -69,7 +69,7 @@ _equal(struct scaled_scene_buffer *scaled_buffer_a,
&& a->bg_pattern == b->bg_pattern; && a->bg_pattern == b->bg_pattern;
} }
static const struct scaled_scene_buffer_impl impl = { static const struct scaled_buffer_impl impl = {
.create_buffer = _create_buffer, .create_buffer = _create_buffer,
.destroy = _destroy, .destroy = _destroy,
.equal = _equal, .equal = _equal,
@ -81,7 +81,7 @@ scaled_font_buffer_create(struct wlr_scene_tree *parent)
{ {
assert(parent); assert(parent);
struct scaled_font_buffer *self = znew(*self); struct scaled_font_buffer *self = znew(*self);
struct scaled_scene_buffer *scaled_buffer = scaled_scene_buffer_create( struct scaled_buffer *scaled_buffer = scaled_buffer_create(
parent, &impl, /* drop_buffer */ true); parent, &impl, /* drop_buffer */ true);
if (!scaled_buffer) { if (!scaled_buffer) {
free(self); free(self);
@ -138,7 +138,7 @@ scaled_font_buffer_update(struct scaled_font_buffer *self, const char *text,
&self->width, &computed_height); &self->width, &computed_height);
self->height = (self->fixed_height > 0) ? self->height = (self->fixed_height > 0) ?
self->fixed_height : computed_height; self->fixed_height : computed_height;
scaled_scene_buffer_request_update(self->scaled_buffer, scaled_buffer_request_update(self->scaled_buffer,
self->width, self->height); self->width, self->height);
} }
@ -152,6 +152,6 @@ scaled_font_buffer_set_max_width(struct scaled_font_buffer *self, int max_width)
&self->width, &computed_height); &self->width, &computed_height);
self->height = (self->fixed_height > 0) ? self->height = (self->fixed_height > 0) ?
self->fixed_height : computed_height; self->fixed_height : computed_height;
scaled_scene_buffer_request_update(self->scaled_buffer, scaled_buffer_request_update(self->scaled_buffer,
self->width, self->height); self->width, self->height);
} }

View file

@ -1,19 +1,19 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
#define _POSIX_C_SOURCE 200809L #define _POSIX_C_SOURCE 200809L
#include "common/scaled-icon-buffer.h" #include "scaled-buffer/scaled-icon-buffer.h"
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "buffer.h" #include "buffer.h"
#include "common/macros.h" #include "common/macros.h"
#include "common/mem.h" #include "common/mem.h"
#include "common/scaled-scene-buffer.h"
#include "common/string-helpers.h" #include "common/string-helpers.h"
#include "config.h" #include "config.h"
#include "config/rcxml.h" #include "config/rcxml.h"
#include "desktop-entry.h" #include "desktop-entry.h"
#include "img/img.h" #include "img/img.h"
#include "node.h" #include "node.h"
#include "scaled-buffer/scaled-buffer.h"
#include "view.h" #include "view.h"
#include "window-rules.h" #include "window-rules.h"
@ -97,7 +97,7 @@ load_server_icon(struct scaled_icon_buffer *self, int icon_size, double scale)
#endif /* HAVE_LIBSFDO */ #endif /* HAVE_LIBSFDO */
static struct lab_data_buffer * static struct lab_data_buffer *
_create_buffer(struct scaled_scene_buffer *scaled_buffer, double scale) _create_buffer(struct scaled_buffer *scaled_buffer, double scale)
{ {
#if HAVE_LIBSFDO #if HAVE_LIBSFDO
struct scaled_icon_buffer *self = scaled_buffer->data; struct scaled_icon_buffer *self = scaled_buffer->data;
@ -168,7 +168,7 @@ set_icon_buffers(struct scaled_icon_buffer *self, struct wl_array *buffers)
} }
static void static void
_destroy(struct scaled_scene_buffer *scaled_buffer) _destroy(struct scaled_buffer *scaled_buffer)
{ {
struct scaled_icon_buffer *self = scaled_buffer->data; struct scaled_icon_buffer *self = scaled_buffer->data;
if (self->view) { if (self->view) {
@ -194,8 +194,8 @@ icon_buffers_equal(struct wl_array *a, struct wl_array *b)
} }
static bool static bool
_equal(struct scaled_scene_buffer *scaled_buffer_a, _equal(struct scaled_buffer *scaled_buffer_a,
struct scaled_scene_buffer *scaled_buffer_b) struct scaled_buffer *scaled_buffer_b)
{ {
struct scaled_icon_buffer *a = scaled_buffer_a->data; struct scaled_icon_buffer *a = scaled_buffer_a->data;
struct scaled_icon_buffer *b = scaled_buffer_b->data; struct scaled_icon_buffer *b = scaled_buffer_b->data;
@ -209,7 +209,7 @@ _equal(struct scaled_scene_buffer *scaled_buffer_a,
&& a->height == b->height; && a->height == b->height;
} }
static struct scaled_scene_buffer_impl impl = { static struct scaled_buffer_impl impl = {
.create_buffer = _create_buffer, .create_buffer = _create_buffer,
.destroy = _destroy, .destroy = _destroy,
.equal = _equal, .equal = _equal,
@ -222,7 +222,7 @@ scaled_icon_buffer_create(struct wlr_scene_tree *parent, struct server *server,
assert(parent); assert(parent);
assert(width >= 0 && height >= 0); assert(width >= 0 && height >= 0);
struct scaled_scene_buffer *scaled_buffer = scaled_scene_buffer_create( struct scaled_buffer *scaled_buffer = scaled_buffer_create(
parent, &impl, /* drop_buffer */ true); parent, &impl, /* drop_buffer */ true);
struct scaled_icon_buffer *self = znew(*self); struct scaled_icon_buffer *self = znew(*self);
self->scaled_buffer = scaled_buffer; self->scaled_buffer = scaled_buffer;
@ -256,7 +256,7 @@ handle_view_set_icon(struct wl_listener *listener, void *data)
} }
set_icon_buffers(self, &self->view->icon.buffers); set_icon_buffers(self, &self->view->icon.buffers);
scaled_scene_buffer_request_update(self->scaled_buffer, scaled_buffer_request_update(self->scaled_buffer,
self->width, self->height); self->width, self->height);
} }
@ -272,7 +272,7 @@ handle_view_new_title(struct wl_listener *listener, void *data)
return; return;
} }
self->view_icon_prefer_client = prefer_client; self->view_icon_prefer_client = prefer_client;
scaled_scene_buffer_request_update(self->scaled_buffer, scaled_buffer_request_update(self->scaled_buffer,
self->width, self->height); self->width, self->height);
} }
@ -290,7 +290,7 @@ handle_view_new_app_id(struct wl_listener *listener, void *data)
xstrdup_replace(self->view_app_id, app_id); xstrdup_replace(self->view_app_id, app_id);
self->view_icon_prefer_client = window_rules_get_property( self->view_icon_prefer_client = window_rules_get_property(
self->view, "iconPreferClient") == LAB_PROP_TRUE; self->view, "iconPreferClient") == LAB_PROP_TRUE;
scaled_scene_buffer_request_update(self->scaled_buffer, scaled_buffer_request_update(self->scaled_buffer,
self->width, self->height); self->width, self->height);
} }
@ -348,14 +348,14 @@ scaled_icon_buffer_set_icon_name(struct scaled_icon_buffer *self,
return; return;
} }
xstrdup_replace(self->icon_name, icon_name); xstrdup_replace(self->icon_name, icon_name);
scaled_scene_buffer_request_update(self->scaled_buffer, self->width, self->height); scaled_buffer_request_update(self->scaled_buffer, self->width, self->height);
} }
struct scaled_icon_buffer * struct scaled_icon_buffer *
scaled_icon_buffer_from_node(struct wlr_scene_node *node) scaled_icon_buffer_from_node(struct wlr_scene_node *node)
{ {
struct scaled_scene_buffer *scaled_buffer = struct scaled_buffer *scaled_buffer =
node_scaled_scene_buffer_from_node(node); node_scaled_buffer_from_node(node);
assert(scaled_buffer->impl == &impl); assert(scaled_buffer->impl == &impl);
return scaled_buffer->data; return scaled_buffer->data;
} }

View file

@ -1,17 +1,17 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
#define _POSIX_C_SOURCE 200809L #define _POSIX_C_SOURCE 200809L
#include "common/scaled-img-buffer.h" #include "scaled-buffer/scaled-img-buffer.h"
#include <assert.h> #include <assert.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_scene.h> #include <wlr/types/wlr_scene.h>
#include "buffer.h" #include "buffer.h"
#include "common/mem.h" #include "common/mem.h"
#include "common/scaled-scene-buffer.h"
#include "img/img.h" #include "img/img.h"
#include "node.h" #include "node.h"
#include "scaled-buffer/scaled-buffer.h"
static struct lab_data_buffer * static struct lab_data_buffer *
_create_buffer(struct scaled_scene_buffer *scaled_buffer, double scale) _create_buffer(struct scaled_buffer *scaled_buffer, double scale)
{ {
struct scaled_img_buffer *self = scaled_buffer->data; struct scaled_img_buffer *self = scaled_buffer->data;
struct lab_data_buffer *buffer = lab_img_render(self->img, struct lab_data_buffer *buffer = lab_img_render(self->img,
@ -20,7 +20,7 @@ _create_buffer(struct scaled_scene_buffer *scaled_buffer, double scale)
} }
static void static void
_destroy(struct scaled_scene_buffer *scaled_buffer) _destroy(struct scaled_buffer *scaled_buffer)
{ {
struct scaled_img_buffer *self = scaled_buffer->data; struct scaled_img_buffer *self = scaled_buffer->data;
lab_img_destroy(self->img); lab_img_destroy(self->img);
@ -28,8 +28,8 @@ _destroy(struct scaled_scene_buffer *scaled_buffer)
} }
static bool static bool
_equal(struct scaled_scene_buffer *scaled_buffer_a, _equal(struct scaled_buffer *scaled_buffer_a,
struct scaled_scene_buffer *scaled_buffer_b) struct scaled_buffer *scaled_buffer_b)
{ {
struct scaled_img_buffer *a = scaled_buffer_a->data; struct scaled_img_buffer *a = scaled_buffer_a->data;
struct scaled_img_buffer *b = scaled_buffer_b->data; struct scaled_img_buffer *b = scaled_buffer_b->data;
@ -39,7 +39,7 @@ _equal(struct scaled_scene_buffer *scaled_buffer_a,
&& a->height == b->height; && a->height == b->height;
} }
static struct scaled_scene_buffer_impl impl = { static struct scaled_buffer_impl impl = {
.create_buffer = _create_buffer, .create_buffer = _create_buffer,
.destroy = _destroy, .destroy = _destroy,
.equal = _equal, .equal = _equal,
@ -53,7 +53,7 @@ scaled_img_buffer_create(struct wlr_scene_tree *parent, struct lab_img *img,
assert(img); assert(img);
assert(width >= 0 && height >= 0); assert(width >= 0 && height >= 0);
struct scaled_scene_buffer *scaled_buffer = scaled_scene_buffer_create( struct scaled_buffer *scaled_buffer = scaled_buffer_create(
parent, &impl, /* drop_buffer */ true); parent, &impl, /* drop_buffer */ true);
struct scaled_img_buffer *self = znew(*self); struct scaled_img_buffer *self = znew(*self);
self->scaled_buffer = scaled_buffer; self->scaled_buffer = scaled_buffer;
@ -64,7 +64,7 @@ scaled_img_buffer_create(struct wlr_scene_tree *parent, struct lab_img *img,
scaled_buffer->data = self; scaled_buffer->data = self;
scaled_scene_buffer_request_update(scaled_buffer, width, height); scaled_buffer_request_update(scaled_buffer, width, height);
return self; return self;
} }
@ -72,8 +72,8 @@ scaled_img_buffer_create(struct wlr_scene_tree *parent, struct lab_img *img,
struct scaled_img_buffer * struct scaled_img_buffer *
scaled_img_buffer_from_node(struct wlr_scene_node *node) scaled_img_buffer_from_node(struct wlr_scene_node *node)
{ {
struct scaled_scene_buffer *scaled_buffer = struct scaled_buffer *scaled_buffer =
node_scaled_scene_buffer_from_node(node); node_scaled_buffer_from_node(node);
assert(scaled_buffer->impl == &impl); assert(scaled_buffer->impl == &impl);
return scaled_buffer->data; return scaled_buffer->data;
} }

View file

@ -48,7 +48,6 @@
#include "drm-lease-v1-protocol.h" #include "drm-lease-v1-protocol.h"
#include "action.h" #include "action.h"
#include "common/macros.h" #include "common/macros.h"
#include "common/scaled-scene-buffer.h"
#include "config/rcxml.h" #include "config/rcxml.h"
#include "config/session.h" #include "config/session.h"
#include "decorations.h" #include "decorations.h"
@ -64,6 +63,7 @@
#include "output-virtual.h" #include "output-virtual.h"
#include "regions.h" #include "regions.h"
#include "resize-indicator.h" #include "resize-indicator.h"
#include "scaled-buffer/scaled-buffer.h"
#include "session-lock.h" #include "session-lock.h"
#include "theme.h" #include "theme.h"
#include "view.h" #include "view.h"
@ -80,7 +80,7 @@
static void static void
reload_config_and_theme(struct server *server) reload_config_and_theme(struct server *server)
{ {
scaled_scene_buffer_invalidate_sharing(); scaled_buffer_invalidate_sharing();
rcxml_finish(); rcxml_finish();
rcxml_read(rc.config_file); rcxml_read(rc.config_file);
theme_finish(server->theme); theme_finish(server->theme);

View file

@ -4,11 +4,11 @@
#include <wlr/util/box.h> #include <wlr/util/box.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "common/macros.h" #include "common/macros.h"
#include "common/scaled-font-buffer.h"
#include "config/rcxml.h" #include "config/rcxml.h"
#include "labwc.h" #include "labwc.h"
#include "resize-indicator.h" #include "resize-indicator.h"
#include "resize-outlines.h" #include "resize-outlines.h"
#include "scaled-buffer/scaled-font-buffer.h"
#include "theme.h" #include "theme.h"
#include "view.h" #include "view.h"

View file

@ -4,9 +4,9 @@
#include "config/rcxml.h" #include "config/rcxml.h"
#include "common/list.h" #include "common/list.h"
#include "common/mem.h" #include "common/mem.h"
#include "common/scaled-icon-buffer.h"
#include "common/scaled-img-buffer.h"
#include "node.h" #include "node.h"
#include "scaled-buffer/scaled-icon-buffer.h"
#include "scaled-buffer/scaled-img-buffer.h"
#include "ssd-internal.h" #include "ssd-internal.h"
/* Internal helpers */ /* Internal helpers */

View file

@ -6,9 +6,6 @@
#include <wlr/render/pixman.h> #include <wlr/render/pixman.h>
#include "buffer.h" #include "buffer.h"
#include "common/mem.h" #include "common/mem.h"
#include "common/scaled-font-buffer.h"
#include "common/scaled-icon-buffer.h"
#include "common/scaled-img-buffer.h"
#include "common/scene-helpers.h" #include "common/scene-helpers.h"
#include "common/string-helpers.h" #include "common/string-helpers.h"
#include "config/rcxml.h" #include "config/rcxml.h"
@ -16,6 +13,9 @@
#include "img/img.h" #include "img/img.h"
#include "labwc.h" #include "labwc.h"
#include "node.h" #include "node.h"
#include "scaled-buffer/scaled-font-buffer.h"
#include "scaled-buffer/scaled-icon-buffer.h"
#include "scaled-buffer/scaled-img-buffer.h"
#include "ssd-internal.h" #include "ssd-internal.h"
#include "theme.h" #include "theme.h"
#include "view.h" #include "view.h"