mirror of
https://github.com/labwc/labwc.git
synced 2026-03-14 05:33:52 -04:00
scaled-scene-buffer: store all the scaled_scene_buffers in a single list
This commit is contained in:
parent
138a514c90
commit
c49f577c6b
5 changed files with 21 additions and 32 deletions
|
|
@ -36,12 +36,7 @@ struct scaled_scene_buffer {
|
||||||
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_scene_buffer_impl *impl;
|
||||||
/*
|
struct wl_list link; /* all_scaled_buffers */
|
||||||
* Pointer to the per-implementation list of scaled-scene-buffers.
|
|
||||||
* This is used to share the backing wlr_buffers.
|
|
||||||
*/
|
|
||||||
struct wl_list *cached_buffers;
|
|
||||||
struct wl_list link; /* struct scaled_scene_buffer.cached_buffers */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -89,8 +84,8 @@ struct scaled_scene_buffer {
|
||||||
* allocations.
|
* allocations.
|
||||||
*
|
*
|
||||||
* Besides caching buffers for each scale per scaled_scene_buffer, we also
|
* Besides caching buffers for each scale per scaled_scene_buffer, we also
|
||||||
* store all the scaled_scene_buffers in a per-implementer list passed as
|
* store all the scaled_scene_buffers from all the implementers in a list
|
||||||
* @cached_buffers 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_scene_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
|
||||||
|
|
@ -119,7 +114,7 @@ struct scaled_scene_buffer {
|
||||||
struct scaled_scene_buffer *scaled_scene_buffer_create(
|
struct scaled_scene_buffer *scaled_scene_buffer_create(
|
||||||
struct wlr_scene_tree *parent,
|
struct wlr_scene_tree *parent,
|
||||||
const struct scaled_scene_buffer_impl *implementation,
|
const struct scaled_scene_buffer_impl *implementation,
|
||||||
struct wl_list *cached_buffers, bool drop_buffer);
|
bool drop_buffer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* scaled_scene_buffer_request_update - mark the buffer that needs to be
|
* scaled_scene_buffer_request_update - mark the buffer that needs to be
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,10 @@
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "common/font.h"
|
#include "common/font.h"
|
||||||
#include "common/list.h"
|
|
||||||
#include "common/mem.h"
|
#include "common/mem.h"
|
||||||
#include "common/scaled-scene-buffer.h"
|
#include "common/scaled-scene-buffer.h"
|
||||||
#include "common/scaled-font-buffer.h"
|
#include "common/scaled-font-buffer.h"
|
||||||
|
|
||||||
/* This holds all the scaled-font-buffers and used for sharing backing buffers */
|
|
||||||
static struct wl_list cached_buffers = WL_LIST_INIT(&cached_buffers);
|
|
||||||
|
|
||||||
static struct lab_data_buffer *
|
static struct lab_data_buffer *
|
||||||
_create_buffer(struct scaled_scene_buffer *scaled_buffer, double scale)
|
_create_buffer(struct scaled_scene_buffer *scaled_buffer, double scale)
|
||||||
{
|
{
|
||||||
|
|
@ -78,7 +74,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_scene_buffer *scaled_buffer = scaled_scene_buffer_create(
|
||||||
parent, &impl, &cached_buffers, /* drop_buffer */ true);
|
parent, &impl, /* drop_buffer */ true);
|
||||||
if (!scaled_buffer) {
|
if (!scaled_buffer) {
|
||||||
free(self);
|
free(self);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,12 @@
|
||||||
#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/list.h"
|
|
||||||
#include "common/mem.h"
|
#include "common/mem.h"
|
||||||
#include "common/scaled-img-buffer.h"
|
#include "common/scaled-img-buffer.h"
|
||||||
#include "common/scaled-scene-buffer.h"
|
#include "common/scaled-scene-buffer.h"
|
||||||
#include "img/img.h"
|
#include "img/img.h"
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
|
|
||||||
static struct wl_list cached_buffers = WL_LIST_INIT(&cached_buffers);
|
|
||||||
|
|
||||||
static struct lab_data_buffer *
|
static struct lab_data_buffer *
|
||||||
_create_buffer(struct scaled_scene_buffer *scaled_buffer, double scale)
|
_create_buffer(struct scaled_scene_buffer *scaled_buffer, double scale)
|
||||||
{
|
{
|
||||||
|
|
@ -55,7 +52,7 @@ scaled_img_buffer_create(struct wlr_scene_tree *parent, struct lab_img *img,
|
||||||
{
|
{
|
||||||
assert(img);
|
assert(img);
|
||||||
struct scaled_scene_buffer *scaled_buffer = scaled_scene_buffer_create(
|
struct scaled_scene_buffer *scaled_buffer = scaled_scene_buffer_create(
|
||||||
parent, &impl, &cached_buffers, /* 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;
|
||||||
self->scene_buffer = scaled_buffer->scene_buffer;
|
self->scene_buffer = scaled_buffer->scene_buffer;
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,11 @@
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "common/graphic-helpers.h"
|
#include "common/graphic-helpers.h"
|
||||||
#include "common/list.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/scaled-scene-buffer.h"
|
||||||
#include "common/scaled-rect-buffer.h"
|
#include "common/scaled-rect-buffer.h"
|
||||||
|
|
||||||
static struct wl_list cached_buffers = WL_LIST_INIT(&cached_buffers);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_rectangle_path(cairo_t *cairo, int width, int height, int border_width)
|
draw_rectangle_path(cairo_t *cairo, int width, int height, int border_width)
|
||||||
{
|
{
|
||||||
|
|
@ -100,7 +97,7 @@ struct scaled_rect_buffer *scaled_rect_buffer_create(
|
||||||
assert(parent);
|
assert(parent);
|
||||||
struct scaled_rect_buffer *self = znew(*self);
|
struct scaled_rect_buffer *self = znew(*self);
|
||||||
struct scaled_scene_buffer *scaled_buffer = scaled_scene_buffer_create(
|
struct scaled_scene_buffer *scaled_buffer = scaled_scene_buffer_create(
|
||||||
parent, &impl, &cached_buffers, /* drop_buffer */ true);
|
parent, &impl, /* drop_buffer */ true);
|
||||||
scaled_buffer->data = self;
|
scaled_buffer->data = self;
|
||||||
self->scaled_buffer = scaled_buffer;
|
self->scaled_buffer = scaled_buffer;
|
||||||
self->scene_buffer = scaled_buffer->scene_buffer;
|
self->scene_buffer = scaled_buffer->scene_buffer;
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,18 @@
|
||||||
#include <wlr/types/wlr_scene.h>
|
#include <wlr/types/wlr_scene.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
|
#include "common/list.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/scaled-scene-buffer.h"
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This holds all the scaled_scene_buffers from all the implementers.
|
||||||
|
* 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);
|
||||||
|
|
||||||
/* 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_scene_buffer_cache_entry *cache_entry, bool drop_buffer)
|
||||||
|
|
@ -63,13 +70,16 @@ _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 && self->cached_buffers) {
|
if (self->impl->equal) {
|
||||||
/* Search from other cached scaled-scene-buffers */
|
/* Search from other cached scaled-scene-buffers */
|
||||||
struct scaled_scene_buffer *scene_buffer;
|
struct scaled_scene_buffer *scene_buffer;
|
||||||
wl_list_for_each(scene_buffer, self->cached_buffers, link) {
|
wl_list_for_each(scene_buffer, &all_scaled_buffers, link) {
|
||||||
if (scene_buffer == self) {
|
if (scene_buffer == self) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (self->impl != scene_buffer->impl) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!self->impl->equal(self, scene_buffer)) {
|
if (!self->impl->equal(self, scene_buffer)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -174,7 +184,7 @@ _handle_outputs_update(struct wl_listener *listener, void *data)
|
||||||
struct scaled_scene_buffer *
|
struct scaled_scene_buffer *
|
||||||
scaled_scene_buffer_create(struct wlr_scene_tree *parent,
|
scaled_scene_buffer_create(struct wlr_scene_tree *parent,
|
||||||
const struct scaled_scene_buffer_impl *impl,
|
const struct scaled_scene_buffer_impl *impl,
|
||||||
struct wl_list *cached_buffers, bool drop_buffer)
|
bool drop_buffer)
|
||||||
{
|
{
|
||||||
assert(parent);
|
assert(parent);
|
||||||
assert(impl);
|
assert(impl);
|
||||||
|
|
@ -199,13 +209,7 @@ scaled_scene_buffer_create(struct wlr_scene_tree *parent,
|
||||||
self->drop_buffer = drop_buffer;
|
self->drop_buffer = drop_buffer;
|
||||||
wl_list_init(&self->cache);
|
wl_list_init(&self->cache);
|
||||||
|
|
||||||
self->cached_buffers = cached_buffers;
|
wl_list_insert(&all_scaled_buffers, &self->link);
|
||||||
if (self->cached_buffers) {
|
|
||||||
wl_list_insert(self->cached_buffers, &self->link);
|
|
||||||
} else {
|
|
||||||
/* Ensure self->link can be removed safely in the destroy handler */
|
|
||||||
wl_list_init(&self->link);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Listen to outputs_update so we get notified about scale changes */
|
/* Listen to outputs_update so we get notified about scale changes */
|
||||||
self->outputs_update.notify = _handle_outputs_update;
|
self->outputs_update.notify = _handle_outputs_update;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue