Put the whole vtable in backend_list
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
7e3976947b
commit
f2aeb848ec
|
@ -10,10 +10,15 @@
|
||||||
#include "region.h"
|
#include "region.h"
|
||||||
#include "win.h"
|
#include "win.h"
|
||||||
|
|
||||||
backend_init_fn backend_list[NUM_BKEND] = {
|
extern struct backend_operations xrender_ops;
|
||||||
[BKEND_XRENDER] = backend_xrender_init,
|
|
||||||
#ifdef CONFIG_OPENGL
|
#ifdef CONFIG_OPENGL
|
||||||
[BKEND_GLX] = backend_glx_init,
|
extern struct backend_operations glx_ops;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct backend_operations *backend_list[NUM_BKEND] = {
|
||||||
|
[BKEND_XRENDER] = &xrender_ops,
|
||||||
|
#ifdef CONFIG_OPENGL
|
||||||
|
[BKEND_GLX] = &glx_ops,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -240,7 +245,7 @@ void paint_all_new(session_t *ps, win *const t, bool ignore_damage) {
|
||||||
}
|
}
|
||||||
pixman_region32_fini(®_damage);
|
pixman_region32_fini(®_damage);
|
||||||
|
|
||||||
if (ps->o.monitor_repaint && ps->backend_data->ops->fill_rectangle) {
|
if (ps->o.monitor_repaint) {
|
||||||
reg_damage = get_damage(ps, false);
|
reg_damage = get_damage(ps, false);
|
||||||
auto extent = pixman_region32_extents(®_damage);
|
auto extent = pixman_region32_extents(®_damage);
|
||||||
ps->backend_data->ops->fill_rectangle(
|
ps->backend_data->ops->fill_rectangle(
|
||||||
|
|
|
@ -43,6 +43,7 @@ struct backend_operations {
|
||||||
/// 1) if ps->overlay is not XCB_NONE, use that
|
/// 1) if ps->overlay is not XCB_NONE, use that
|
||||||
/// 2) use ps->root otherwise
|
/// 2) use ps->root otherwise
|
||||||
/// XXX make the target window a parameter
|
/// XXX make the target window a parameter
|
||||||
|
backend_t *(*init)(session_t *) attr_nonnull(1);
|
||||||
void (*deinit)(backend_t *backend_data) __attribute__((nonnull(1)));
|
void (*deinit)(backend_t *backend_data) __attribute__((nonnull(1)));
|
||||||
|
|
||||||
/// Called when rendering will be stopped for an unknown amount of
|
/// Called when rendering will be stopped for an unknown amount of
|
||||||
|
@ -172,11 +173,9 @@ struct backend_operations {
|
||||||
/// Let the backend hook into the event handling queue
|
/// Let the backend hook into the event handling queue
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef backend_t *(*backend_init_fn)(session_t *ps) __attribute__((nonnull(1)));
|
typedef backend_t *(*backend_init_fn)(session_t *ps) attr_nonnull(1);
|
||||||
|
|
||||||
extern backend_t *backend_xrender_init(session_t *ps);
|
extern struct backend_operations *backend_list[];
|
||||||
extern backend_t *backend_glx_init(session_t *ps);
|
|
||||||
extern backend_init_fn backend_list[];
|
|
||||||
|
|
||||||
bool default_is_win_transparent(void *, win *, void *);
|
bool default_is_win_transparent(void *, win *, void *);
|
||||||
bool default_is_frame_transparent(void *, win *, void *);
|
bool default_is_frame_transparent(void *, win *, void *);
|
||||||
|
|
|
@ -532,6 +532,8 @@ void glx_compose(void *backend_data, session_t *ps, win *w, void *win_data,
|
||||||
pixman_region32_fini(®ion_yflipped);
|
pixman_region32_fini(®ion_yflipped);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct backend_operations glx_ops;
|
||||||
|
|
||||||
/* backend_info_t glx_backend = { */
|
/* backend_info_t glx_backend = { */
|
||||||
/* .init = glx_init, */
|
/* .init = glx_init, */
|
||||||
/* .deinit = glx_deinit, */
|
/* .deinit = glx_deinit, */
|
||||||
|
|
|
@ -453,31 +453,11 @@ static void *copy(backend_t *base, const void *image, const region_t *reg) {
|
||||||
return new_img;
|
return new_img;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct backend_operations xrender_ops = {
|
|
||||||
.deinit = deinit,
|
|
||||||
.blur = blur,
|
|
||||||
.present = present,
|
|
||||||
.compose = compose,
|
|
||||||
.fill_rectangle = fill_rectangle,
|
|
||||||
.bind_pixmap = bind_pixmap,
|
|
||||||
.release_image = release_image,
|
|
||||||
.render_shadow = default_backend_render_shadow,
|
|
||||||
//.prepare_win = prepare_win,
|
|
||||||
//.release_win = release_win,
|
|
||||||
.is_image_transparent = is_image_transparent,
|
|
||||||
.buffer_age = buffer_age,
|
|
||||||
.max_buffer_age = 2,
|
|
||||||
|
|
||||||
.image_op = image_op,
|
|
||||||
.copy = copy,
|
|
||||||
};
|
|
||||||
|
|
||||||
backend_t *backend_xrender_init(session_t *ps) {
|
backend_t *backend_xrender_init(session_t *ps) {
|
||||||
auto xd = ccalloc(1, struct _xrender_data);
|
auto xd = ccalloc(1, struct _xrender_data);
|
||||||
|
|
||||||
xd->base.c = ps->c;
|
xd->base.c = ps->c;
|
||||||
xd->base.root = ps->root;
|
xd->base.root = ps->root;
|
||||||
xd->base.ops = &xrender_ops;
|
|
||||||
|
|
||||||
for (int i = 0; i < 256; ++i) {
|
for (int i = 0; i < 256; ++i) {
|
||||||
double o = (double)i / 255.0;
|
double o = (double)i / 255.0;
|
||||||
|
@ -567,4 +547,24 @@ err:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct backend_operations xrender_ops = {
|
||||||
|
.init = backend_xrender_init,
|
||||||
|
.deinit = deinit,
|
||||||
|
.blur = blur,
|
||||||
|
.present = present,
|
||||||
|
.compose = compose,
|
||||||
|
.fill_rectangle = fill_rectangle,
|
||||||
|
.bind_pixmap = bind_pixmap,
|
||||||
|
.release_image = release_image,
|
||||||
|
.render_shadow = default_backend_render_shadow,
|
||||||
|
//.prepare_win = prepare_win,
|
||||||
|
//.release_win = release_win,
|
||||||
|
.is_image_transparent = is_image_transparent,
|
||||||
|
.buffer_age = buffer_age,
|
||||||
|
.max_buffer_age = 2,
|
||||||
|
|
||||||
|
.image_op = image_op,
|
||||||
|
.copy = copy,
|
||||||
|
};
|
||||||
|
|
||||||
// vim: set noet sw=8 ts=8:
|
// vim: set noet sw=8 ts=8:
|
||||||
|
|
|
@ -838,7 +838,8 @@ void configure_root(session_t *ps, int width, int height) {
|
||||||
if (has_root_change) {
|
if (has_root_change) {
|
||||||
ps->backend_data->ops->root_change(ps->backend_data, ps);
|
ps->backend_data->ops->root_change(ps->backend_data, ps);
|
||||||
} else {
|
} else {
|
||||||
ps->backend_data = backend_list[ps->o.backend](ps);
|
ps->backend_data = backend_list[ps->o.backend]->init(ps);
|
||||||
|
ps->backend_data->ops = backend_list[ps->o.backend];
|
||||||
if (!ps->backend_data) {
|
if (!ps->backend_data) {
|
||||||
log_fatal("Failed to re-initialize backend after root change, aborting...");
|
log_fatal("Failed to re-initialize backend after root change, aborting...");
|
||||||
ps->quit = true;
|
ps->quit = true;
|
||||||
|
@ -1991,7 +1992,8 @@ redir_start(session_t *ps) {
|
||||||
|
|
||||||
if (ps->o.experimental_backends) {
|
if (ps->o.experimental_backends) {
|
||||||
// Reinitialize win_data
|
// Reinitialize win_data
|
||||||
ps->backend_data = backend_list[ps->o.backend](ps);
|
ps->backend_data = backend_list[ps->o.backend]->init(ps);
|
||||||
|
ps->backend_data->ops = backend_list[ps->o.backend];
|
||||||
if (!ps->backend_data) {
|
if (!ps->backend_data) {
|
||||||
log_fatal("Failed to initialize backend, aborting...");
|
log_fatal("Failed to initialize backend, aborting...");
|
||||||
ps->quit = true;
|
ps->quit = true;
|
||||||
|
@ -2721,6 +2723,13 @@ session_init(int argc, char **argv, Display *dpy, const char *config_file,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ps->o.experimental_backends) {
|
||||||
|
if (ps->o.monitor_repaint && !backend_list[ps->o.backend]->fill_rectangle) {
|
||||||
|
log_warn("--monitor-repaint is not supported by the backend, disabling");
|
||||||
|
ps->o.monitor_repaint = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize software optimization
|
// Initialize software optimization
|
||||||
if (ps->o.sw_opti)
|
if (ps->o.sw_opti)
|
||||||
ps->o.sw_opti = swopti_init(ps);
|
ps->o.sw_opti = swopti_init(ps);
|
||||||
|
|
Loading…
Reference in New Issue