mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
Remove several unnecessary experimental_backends check
Window flags can be set whichever backend we use, we will ignore then in paint_preprocess. free_paint can be called whichever backend we use, they just do nothing if we use experimental backends. Others should rather just check if backend_data is NULL. Making the code slightly more understandable, also making the eventual removal of these checks easier. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
8e5210cb9c
commit
f93f697759
2 changed files with 55 additions and 55 deletions
|
@ -475,6 +475,11 @@ static struct managed_win *paint_preprocess(session_t *ps, bool *fade_running) {
|
|||
rc_region_unref(&w->reg_ignore);
|
||||
}
|
||||
|
||||
// Clear flags if we are not using experimental backends
|
||||
if (!ps->o.experimental_backends) {
|
||||
w->flags = 0;
|
||||
}
|
||||
|
||||
// log_trace("%d %d %s", w->a.map_state, w->ever_damaged, w->name);
|
||||
|
||||
// Give up if it's not damaged or invisible, or it's unmapped and its
|
||||
|
@ -700,7 +705,7 @@ static void destroy_backend(session_t *ps) {
|
|||
if (!w) {
|
||||
continue;
|
||||
}
|
||||
if (ps->o.experimental_backends) {
|
||||
if (ps->backend_data) {
|
||||
if (w->state == WSTATE_MAPPED) {
|
||||
win_release_image(ps->backend_data, w);
|
||||
} else {
|
||||
|
@ -712,12 +717,11 @@ static void destroy_backend(session_t *ps) {
|
|||
ps->root_image);
|
||||
ps->root_image = NULL;
|
||||
}
|
||||
} else {
|
||||
free_paint(ps, &w->paint);
|
||||
}
|
||||
free_paint(ps, &w->paint);
|
||||
}
|
||||
|
||||
if (ps->o.experimental_backends) {
|
||||
if (ps->backend_data) {
|
||||
// deinit backend
|
||||
ps->backend_data->ops->deinit(ps->backend_data);
|
||||
ps->backend_data = NULL;
|
||||
|
@ -762,17 +766,20 @@ void configure_root(session_t *ps, int width, int height) {
|
|||
log_info("Root configuration changed, new geometry: %dx%d", width, height);
|
||||
// On root window changes
|
||||
bool has_root_change = false;
|
||||
if (ps->o.experimental_backends && ps->redirected) {
|
||||
if (ps->o.experimental_backends) {
|
||||
has_root_change = ps->backend_data->ops->root_change != NULL;
|
||||
if (!has_root_change) {
|
||||
// deinit/reinit backend and free up resources if the backend
|
||||
// cannot handle root change
|
||||
destroy_backend(ps);
|
||||
}
|
||||
} else {
|
||||
free_paint(ps, &ps->tgt_buffer);
|
||||
// Old backend can handle root change
|
||||
has_root_change = true;
|
||||
}
|
||||
|
||||
if (!has_root_change) {
|
||||
// deinit/reinit backend and free up resources if the backend
|
||||
// cannot handle root change
|
||||
destroy_backend(ps);
|
||||
}
|
||||
free_paint(ps, &ps->tgt_buffer);
|
||||
|
||||
ps->root_width = width;
|
||||
ps->root_height = height;
|
||||
|
||||
|
@ -796,20 +803,21 @@ void configure_root(session_t *ps, int width, int height) {
|
|||
glx_on_root_change(ps);
|
||||
}
|
||||
#endif
|
||||
if (ps->o.experimental_backends && ps->redirected) {
|
||||
if (has_root_change) {
|
||||
if (has_root_change) {
|
||||
if (ps->backend_data != NULL) {
|
||||
ps->backend_data->ops->root_change(ps->backend_data, ps);
|
||||
} else {
|
||||
if (!initialize_backend(ps)) {
|
||||
log_fatal("Failed to re-initialize backend after root "
|
||||
"change, aborting...");
|
||||
ps->quit = true;
|
||||
// TODO only event handlers should request ev_break,
|
||||
// otherwise it's too hard to keep track of what can break
|
||||
// the event loop
|
||||
ev_break(ps->loop, EVBREAK_ALL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Old backend's root_change is not a specific function
|
||||
} else {
|
||||
if (!initialize_backend(ps)) {
|
||||
log_fatal("Failed to re-initialize backend after root "
|
||||
"change, aborting...");
|
||||
ps->quit = true;
|
||||
// TODO only event handlers should request ev_break,
|
||||
// otherwise it's too hard to keep track of what can break
|
||||
// the event loop
|
||||
ev_break(ps->loop, EVBREAK_ALL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
force_repaint(ps);
|
||||
|
@ -900,7 +908,7 @@ void root_damaged(session_t *ps) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (ps->o.experimental_backends) {
|
||||
if (ps->backend_data) {
|
||||
if (ps->root_image) {
|
||||
ps->backend_data->ops->release_image(ps->backend_data, ps->root_image);
|
||||
}
|
||||
|
@ -1295,6 +1303,7 @@ static bool redir_start(session_t *ps) {
|
|||
}
|
||||
|
||||
if (ps->o.experimental_backends) {
|
||||
assert(ps->backend_data);
|
||||
ps->ndamage = ps->backend_data->ops->max_buffer_age;
|
||||
} else {
|
||||
ps->ndamage = maximum_buffer_age(ps);
|
||||
|
|
51
src/win.c
51
src/win.c
|
@ -550,7 +550,7 @@ void win_set_shadow(session_t *ps, struct managed_win *w, bool shadow_new) {
|
|||
|
||||
log_debug("Updating shadow property of window %#010x (%s) to %d", w->base.id,
|
||||
w->name, shadow_new);
|
||||
if (ps->o.experimental_backends && ps->redirected &&
|
||||
if (ps->backend_data &&
|
||||
w->state != WSTATE_UNMAPPED && !(w->flags & WIN_FLAGS_IMAGE_ERROR)) {
|
||||
assert(!w->shadow_image);
|
||||
// Create shadow image
|
||||
|
@ -783,17 +783,15 @@ void win_on_win_size_change(session_t *ps, struct managed_win *w) {
|
|||
w->shadow_dy = ps->o.shadow_offset_y;
|
||||
w->shadow_width = w->widthb + ps->o.shadow_radius * 2;
|
||||
w->shadow_height = w->heightb + ps->o.shadow_radius * 2;
|
||||
|
||||
// Invalidate the shadow we built
|
||||
if (ps->o.experimental_backends && ps->redirected) {
|
||||
if (w->state == WSTATE_MAPPED || w->state == WSTATE_MAPPING ||
|
||||
w->state == WSTATE_FADING) {
|
||||
w->flags |= WIN_FLAGS_IMAGE_STALE;
|
||||
} else {
|
||||
assert(w->state == WSTATE_UNMAPPED);
|
||||
}
|
||||
if (w->state == WSTATE_MAPPED || w->state == WSTATE_MAPPING ||
|
||||
w->state == WSTATE_FADING) {
|
||||
w->flags |= WIN_FLAGS_IMAGE_STALE;
|
||||
} else {
|
||||
free_paint(ps, &w->shadow_paint);
|
||||
assert(w->state == WSTATE_UNMAPPED);
|
||||
}
|
||||
free_paint(ps, &w->shadow_paint);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1448,19 +1446,15 @@ void win_update_bounding_shape(session_t *ps, struct managed_win *w) {
|
|||
}
|
||||
|
||||
// Window shape changed, we should free old wpaint and shadow pict
|
||||
if (ps->o.experimental_backends) {
|
||||
// log_trace("free out dated pict");
|
||||
// Window shape changed, we should free win_data
|
||||
if (ps->redirected && w->state != WSTATE_UNMAPPED) {
|
||||
// Note we only do this when screen is redirected, because
|
||||
// otherwise win_data is not valid
|
||||
assert(w->state != WSTATE_UNMAPPING && w->state != WSTATE_DESTROYING);
|
||||
w->flags |= WIN_FLAGS_IMAGE_STALE;
|
||||
}
|
||||
} else {
|
||||
free_paint(ps, &w->paint);
|
||||
free_paint(ps, &w->shadow_paint);
|
||||
// log_trace("free out dated pict");
|
||||
if (w->state != WSTATE_UNMAPPED) {
|
||||
// Note we only do this when screen is redirected, because
|
||||
// otherwise win_data is not valid
|
||||
assert(w->state != WSTATE_UNMAPPING && w->state != WSTATE_DESTROYING);
|
||||
w->flags |= WIN_FLAGS_IMAGE_STALE;
|
||||
}
|
||||
free_paint(ps, &w->paint);
|
||||
free_paint(ps, &w->shadow_paint);
|
||||
|
||||
win_on_factor_change(ps, w);
|
||||
}
|
||||
|
@ -1557,15 +1551,12 @@ static void finish_unmap_win(session_t *ps, struct managed_win **_w) {
|
|||
w->reg_ignore_valid = false;
|
||||
w->state = WSTATE_UNMAPPED;
|
||||
|
||||
if (ps->o.experimental_backends) {
|
||||
// We are in unmap_win, we definitely was viewable
|
||||
if (ps->redirected) {
|
||||
win_release_image(ps->backend_data, w);
|
||||
}
|
||||
} else {
|
||||
free_paint(ps, &w->paint);
|
||||
free_paint(ps, &w->shadow_paint);
|
||||
// We are in unmap_win, this window definitely was viewable
|
||||
if (ps->backend_data) {
|
||||
win_release_image(ps->backend_data, w);
|
||||
}
|
||||
free_paint(ps, &w->paint);
|
||||
free_paint(ps, &w->shadow_paint);
|
||||
|
||||
w->flags = 0;
|
||||
}
|
||||
|
@ -1898,7 +1889,7 @@ void map_win(session_t *ps, struct managed_win *w) {
|
|||
w->flags &= ~WIN_FLAGS_IMAGE_STALE;
|
||||
|
||||
// Bind image after update_bounding_shape, so the shadow has the correct size.
|
||||
if (ps->redirected && ps->o.experimental_backends) {
|
||||
if (ps->backend_data) {
|
||||
if (!win_bind_image(ps, w)) {
|
||||
w->flags |= WIN_FLAGS_IMAGE_ERROR;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue