labwc/include/common/scaled_scene_buffer.h
Johan Malm 34b2374fd0 Fix minor coding-style violations
...based on https://github.com/johanmalm/checkpatch.pl

```
src/server.c:161: ERROR: space required before the open parenthesis '('
src/server.c:473: CHECK: Blank lines aren't necessary after an open brace '{'
src/desktop.c:228: WARNING: function definition argument 'struct wl_list *' should also have an identifier name
src/output.c:289: CHECK: Blank lines aren't necessary before a close brace '}'
src/interactive.c:20: WARNING: suspect code indent for conditional statements (8, 17)
src/interactive.c:27: WARNING: Statements should start on a tabstop
src/config/rcxml.c:607: CHECK: Blank lines aren't necessary after an open brace '{'
src/config/rcxml.c:638: CHECK: line length of 91 exceeds 90 columns
src/config/rcxml.c:639: CHECK: Blank lines aren't necessary after an open brace '{'
src/debug.c:126: WARNING: suspect code indent for conditional statements (8, 24)
src/debug.c:129: WARNING: suspect code indent for conditional statements (8, 24)
src/view.c:307: CHECK: Please use a blank line after function/struct/union/enum declarations
src/workspaces.c:52: CHECK: Blank lines aren't necessary after an open brace '{'
src/workspaces.c:147: ERROR: space prohibited before that close parenthesis ')'
src/workspaces.c:226: CHECK: line length of 91 exceeds 90 columns
src/workspaces.c:290: CHECK: Please don't use multiple blank lines
src/workspaces.c:328: WARNING: else is not generally useful after a break or return
src/cursor.c:18: ERROR: do not initialise statics to NULL
src/cursor.c:20: CHECK: Please don't use multiple blank lines
src/common/scaled_font_buffer.c:55: CHECK: Assignment operator '=' should be on the previous line
src/common/graphic-helpers.c:44: CHECK: Blank lines aren't necessary after an open brace '{'
src/common/graphic-helpers.c:71: CHECK: multiple assignments should be avoided
src/common/scaled_scene_buffer.c:115: CHECK: Assignment operator '=' should be on the previous line
src/common/scaled_scene_buffer.c:135: CHECK: Assignment operator '=' should be on the previous line
src/common/fd_util.c:15: CHECK: line length of 106 exceeds 90 columns
src/common/fd_util.c:22: CHECK: line length of 106 exceeds 90 columns
src/common/fd_util.c:25: ERROR: code indent should use tabs where possible
src/common/fd_util.c:25: WARNING: please, no spaces at the start of a line
include/workspaces.h:13: ERROR: code indent should use tabs where possible
include/workspaces.h:13: WARNING: Block comments use * on subsequent lines
include/workspaces.h:13: WARNING: Block comments use a trailing */ on a separate line
include/workspaces.h:20: CHECK: Please don't use multiple blank lines
include/workspaces.h:26: ERROR: "foo * bar" should be "foo *bar"
include/action.h:11: ERROR: code indent should use tabs where possible
include/action.h:12: ERROR: code indent should use tabs where possible
include/action.h:12: WARNING: Block comments use a trailing */ on a separate line
include/common/scaled_scene_buffer.h:62: CHECK: Please don't use multiple blank lines
```
2022-09-17 12:25:44 +01:00

69 lines
2.3 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef __LAB_COMMON_SCALED_SCENE_BUFFER_H
#define __LAB_COMMON_SCALED_SCENE_BUFFER_H
#define LAB_SCALED_BUFFER_MAX_CACHE 2
struct wl_list;
struct wlr_buffer;
struct wl_listener;
struct wlr_scene_tree;
struct lab_data_buffer;
struct scaled_scene_buffer;
struct scaled_scene_buffer_impl {
/* Return a new buffer optimized for the new scale */
struct lab_data_buffer *(*create_buffer)
(struct scaled_scene_buffer *scaled_buffer, double scale);
/* Might be NULL or used for cleaning up */
void (*destroy)(struct scaled_scene_buffer *scaled_buffer);
};
struct scaled_scene_buffer {
struct wlr_scene_buffer *scene_buffer;
int width; /* unscaled, read only */
int height; /* unscaled, read only */
void *data; /* opaque user data */
/* Private */
double active_scale;
struct wl_list cache; /* struct scaled_buffer_cache_entry.link */
struct wl_listener destroy;
struct wl_listener output_enter;
struct wl_listener output_leave;
const struct scaled_scene_buffer_impl *impl;
};
/**
* Create an auto scaling buffer that creates a wlr_scene_buffer
* and subscribes to its output_enter and output_leave signals.
*
* If the maximal scale changes, it either sets an already existing buffer
* that was rendered for the current scale or - if there is none - calls
* implementation->create_buffer(self, scale) to get a new lab_data_buffer
* optimized for the new scale.
*
* Up to LAB_SCALED_BUFFER_MAX_CACHE (2) buffers are cached in an LRU fashion
* to handle the majority of use cases where a view is moved between no more
* than two different scales.
*
* scaled_scene_buffer will clean up automatically once the internal
* 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
* allocations.
*/
struct scaled_scene_buffer *scaled_scene_buffer_create(
struct wlr_scene_tree *parent,
const struct scaled_scene_buffer_impl *implementation);
/* Clear the cache of existing buffers, useful in case the content changes */
void scaled_scene_buffer_invalidate_cache(struct scaled_scene_buffer *self);
/* Private */
struct scaled_scene_buffer_cache_entry {
struct wl_list link; /* struct scaled_scene_buffer.cache */
struct wlr_buffer *buffer;
double scale;
};
#endif /* __LAB_COMMON_SCALED_SCENE_BUFFER_H */