mirror of https://github.com/yshui/picom.git
backend: turn max_buffer_age into a function
We want to change the backend interface as little as possible once we release it as a public interface, so while we still can, we should try to give it maximum flexibility. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
f5bebb3e2e
commit
5c1b0ba7a1
|
@ -450,7 +450,7 @@ struct backend_operations {
|
||||||
bool (*last_render_time)(backend_t *backend_data, struct timespec *ts);
|
bool (*last_render_time)(backend_t *backend_data, struct timespec *ts);
|
||||||
|
|
||||||
/// The maximum number buffer_age might return.
|
/// The maximum number buffer_age might return.
|
||||||
int max_buffer_age;
|
int (*max_buffer_age)(backend_t *backend_data);
|
||||||
|
|
||||||
// =========== Post-processing ============
|
// =========== Post-processing ============
|
||||||
/// Create a blur context that can be used to call `blur` for images with a
|
/// Create a blur context that can be used to call `blur` for images with a
|
||||||
|
|
|
@ -204,6 +204,10 @@ bool dummy_is_format_supported(struct backend_base *base attr_unused,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dummy_max_buffer_age(struct backend_base *base attr_unused) {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
struct backend_operations dummy_ops = {
|
struct backend_operations dummy_ops = {
|
||||||
.apply_alpha = dummy_apply_alpha,
|
.apply_alpha = dummy_apply_alpha,
|
||||||
.back_buffer = dummy_back_buffer,
|
.back_buffer = dummy_back_buffer,
|
||||||
|
@ -222,7 +226,7 @@ struct backend_operations dummy_ops = {
|
||||||
.init = dummy_init,
|
.init = dummy_init,
|
||||||
.deinit = dummy_deinit,
|
.deinit = dummy_deinit,
|
||||||
.buffer_age = dummy_buffer_age,
|
.buffer_age = dummy_buffer_age,
|
||||||
.max_buffer_age = 5,
|
.max_buffer_age = dummy_max_buffer_age,
|
||||||
|
|
||||||
.create_blur_context = dummy_create_blur_context,
|
.create_blur_context = dummy_create_blur_context,
|
||||||
.destroy_blur_context = dummy_destroy_blur_context,
|
.destroy_blur_context = dummy_destroy_blur_context,
|
||||||
|
|
|
@ -339,6 +339,14 @@ static void egl_diagnostics(backend_t *base) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int egl_max_buffer_age(backend_t *base attr_unused) {
|
||||||
|
if (!eglext.has_EGL_EXT_buffer_age) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 5; // Why?
|
||||||
|
}
|
||||||
|
|
||||||
struct backend_operations egl_ops = {
|
struct backend_operations egl_ops = {
|
||||||
.apply_alpha = gl_apply_alpha,
|
.apply_alpha = gl_apply_alpha,
|
||||||
.back_buffer = gl_back_buffer,
|
.back_buffer = gl_back_buffer,
|
||||||
|
@ -369,7 +377,7 @@ struct backend_operations egl_ops = {
|
||||||
.create_shader = gl_create_window_shader,
|
.create_shader = gl_create_window_shader,
|
||||||
.destroy_shader = gl_destroy_window_shader,
|
.destroy_shader = gl_destroy_window_shader,
|
||||||
.get_shader_attributes = gl_get_shader_attributes,
|
.get_shader_attributes = gl_get_shader_attributes,
|
||||||
.max_buffer_age = 5, // Why?
|
.max_buffer_age = egl_max_buffer_age,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct eglext_info eglext = {0};
|
struct eglext_info eglext = {0};
|
||||||
|
|
|
@ -517,6 +517,10 @@ static void glx_diagnostics(backend_t *base) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int glx_max_buffer_age(struct backend_base *base attr_unused) {
|
||||||
|
return 5; // Why?
|
||||||
|
}
|
||||||
|
|
||||||
struct backend_operations glx_ops = {
|
struct backend_operations glx_ops = {
|
||||||
.apply_alpha = gl_apply_alpha,
|
.apply_alpha = gl_apply_alpha,
|
||||||
.back_buffer = gl_back_buffer,
|
.back_buffer = gl_back_buffer,
|
||||||
|
@ -547,7 +551,7 @@ struct backend_operations glx_ops = {
|
||||||
.create_shader = gl_create_window_shader,
|
.create_shader = gl_create_window_shader,
|
||||||
.destroy_shader = gl_destroy_window_shader,
|
.destroy_shader = gl_destroy_window_shader,
|
||||||
.get_shader_attributes = gl_get_shader_attributes,
|
.get_shader_attributes = gl_get_shader_attributes,
|
||||||
.max_buffer_age = 5, // Why?
|
.max_buffer_age = glx_max_buffer_age,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct glxext_info glxext = {0};
|
struct glxext_info glxext = {0};
|
||||||
|
|
|
@ -1020,6 +1020,10 @@ uint32_t xrender_quirks(struct backend_base *base) {
|
||||||
return ((struct xrender_data *)base)->quirks;
|
return ((struct xrender_data *)base)->quirks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int xrender_max_buffer_age(struct backend_base *base) {
|
||||||
|
return ((struct xrender_data *)base)->vsync ? 2 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
struct backend_operations xrender_ops = {
|
struct backend_operations xrender_ops = {
|
||||||
.apply_alpha = xrender_apply_alpha,
|
.apply_alpha = xrender_apply_alpha,
|
||||||
.back_buffer = xrender_back_buffer,
|
.back_buffer = xrender_back_buffer,
|
||||||
|
@ -1042,7 +1046,7 @@ struct backend_operations xrender_ops = {
|
||||||
// `render_shadow`, and `backend_compat_shadow_from_mask` for
|
// `render_shadow`, and `backend_compat_shadow_from_mask` for
|
||||||
// `shadow_from_mask`
|
// `shadow_from_mask`
|
||||||
.buffer_age = xrender_buffer_age,
|
.buffer_age = xrender_buffer_age,
|
||||||
.max_buffer_age = 2,
|
.max_buffer_age = xrender_max_buffer_age,
|
||||||
.create_blur_context = xrender_create_blur_context,
|
.create_blur_context = xrender_create_blur_context,
|
||||||
.destroy_blur_context = xrender_destroy_blur_context,
|
.destroy_blur_context = xrender_destroy_blur_context,
|
||||||
.get_blur_size = xrender_get_blur_size
|
.get_blur_size = xrender_get_blur_size
|
||||||
|
|
|
@ -437,7 +437,7 @@ void add_damage(session_t *ps, const region_t *damage) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!damage) {
|
if (!damage || ps->damage_ring.count <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log_trace("Adding damage: ");
|
log_trace("Adding damage: ");
|
||||||
|
@ -1418,9 +1418,9 @@ static bool redirect_start(session_t *ps) {
|
||||||
|
|
||||||
if (!ps->o.use_legacy_backends) {
|
if (!ps->o.use_legacy_backends) {
|
||||||
assert(ps->backend_data);
|
assert(ps->backend_data);
|
||||||
ps->damage_ring.count = ps->backend_data->ops->max_buffer_age;
|
ps->damage_ring.count =
|
||||||
ps->layout_manager =
|
ps->backend_data->ops->max_buffer_age(ps->backend_data);
|
||||||
layout_manager_new((unsigned)ps->backend_data->ops->max_buffer_age);
|
ps->layout_manager = layout_manager_new((unsigned)ps->damage_ring.count);
|
||||||
} else {
|
} else {
|
||||||
ps->damage_ring.count = maximum_buffer_age(ps);
|
ps->damage_ring.count = maximum_buffer_age(ps);
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ renderer_init(struct renderer *renderer, struct backend_base *backend,
|
||||||
}
|
}
|
||||||
sum_kernel_preprocess(renderer->shadow_kernel);
|
sum_kernel_preprocess(renderer->shadow_kernel);
|
||||||
}
|
}
|
||||||
renderer->max_buffer_age = backend->ops->max_buffer_age + 1;
|
renderer->max_buffer_age = backend->ops->max_buffer_age(backend) + 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue