win: make sure delayed image update is always used

Convert several places where the window image is bound/unbound directly
to use image flags. Make sure window image updates only happen in one
place.

Remove win_bind_image function since its no longer used after this.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-09-20 02:18:16 +01:00
parent 39a609acb0
commit 3766aa2c79
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
3 changed files with 19 additions and 44 deletions

View File

@ -752,13 +752,14 @@ static bool initialize_backend(session_t *ps) {
continue; continue;
} }
auto w = (struct managed_win *)_w; auto w = (struct managed_win *)_w;
if (w->a.map_state == XCB_MAP_STATE_VIEWABLE) { assert(w->state == WSTATE_MAPPED || w->state == WSTATE_UNMAPPED);
win_bind_image(ps->backend_data, w, if (w->state == WSTATE_MAPPED) {
(struct color){.red = ps->o.shadow_red, // We need to reacquire image
.green = ps->o.shadow_green, log_debug("Marking window %#010x (%s) for update after "
.blue = ps->o.shadow_blue, "redirection",
.alpha = ps->o.shadow_opacity}, w->base.id, w->name);
ps->gaussian_map); w->flags |= WIN_FLAGS_IMAGES_STALE;
ps->pending_updates = true;
} }
} }
} }

View File

@ -323,14 +323,6 @@ void win_release_images(struct backend_base *backend, struct managed_win *w) {
} }
} }
void win_bind_image(struct backend_base *backend, struct managed_win *w, struct color c,
struct conv *kernel) {
win_bind_pixmap(backend, w);
if (w->shadow) {
win_bind_shadow(backend, w, c, kernel);
}
}
void win_process_flags(session_t *ps, struct managed_win *w) { void win_process_flags(session_t *ps, struct managed_win *w) {
if (!w->flags || (w->flags & WIN_FLAGS_IMAGE_ERROR) != 0) { if (!w->flags || (w->flags & WIN_FLAGS_IMAGE_ERROR) != 0) {
return; return;
@ -701,18 +693,10 @@ static void win_set_shadow(session_t *ps, struct managed_win *w, bool shadow_new
if (w->shadow) { if (w->shadow) {
win_extents(w, &extents); win_extents(w, &extents);
add_damage_from_win(ps, w); add_damage_from_win(ps, w);
if (ps->backend_data && w->state != WSTATE_UNMAPPED && if (w->state != WSTATE_UNMAPPED) {
!(w->flags & WIN_FLAGS_IMAGE_ERROR)) {
assert(!w->shadow_image); assert(!w->shadow_image);
// Create shadow image // Delayed creation of shadow image
w->shadow_image = ps->backend_data->ops->render_shadow( w->flags |= WIN_FLAGS_SHADOW_STALE;
ps->backend_data, w->widthb, w->heightb, ps->gaussian_map,
ps->o.shadow_red, ps->o.shadow_green, ps->o.shadow_blue,
ps->o.shadow_opacity);
if (!w->shadow_image) {
log_error("Failed to bind shadow image");
w->shadow_force = OFF;
}
} }
} }
pixman_region32_fini(&extents); pixman_region32_fini(&extents);
@ -1668,7 +1652,11 @@ static void unmap_win_finish(session_t *ps, struct managed_win *w) {
// We are in unmap_win, this window definitely was viewable // We are in unmap_win, this window definitely was viewable
if (ps->backend_data) { if (ps->backend_data) {
win_release_images(ps->backend_data, w); win_release_images(ps->backend_data, w);
} else {
assert(!w->win_image);
assert(!w->shadow_image);
} }
free_paint(ps, &w->paint); free_paint(ps, &w->paint);
free_paint(ps, &w->shadow_paint); free_paint(ps, &w->shadow_paint);
@ -2095,24 +2083,12 @@ void map_win_start(session_t *ps, struct managed_win *w) {
// when the window is unmapped (XXX we shouldn't), // when the window is unmapped (XXX we shouldn't),
// so the shape of the window might have changed, // so the shape of the window might have changed,
// update. (Issue #35) // update. (Issue #35)
//
// Also this sets the WIN_FLAGS_IMAGES_STALE flag so later in the critical section
// the window's image will be bound
win_update_bounding_shape(ps, w); win_update_bounding_shape(ps, w);
// Reset the STALE_IMAGE flag set by win_update_bounding_shape. Because we are assert((w->flags & WIN_FLAGS_IMAGES_STALE) == WIN_FLAGS_IMAGES_STALE);
// just about to bind the image, no way that's stale.
//
// Also because NVIDIA driver doesn't like seeing the same pixmap under different
// ids, so avoid naming the pixmap again when it didn't actually change.
w->flags &= ~WIN_FLAGS_IMAGES_STALE;
// Bind image after update_bounding_shape, so the shadow has the correct size.
if (ps->backend_data) {
win_bind_image(ps->backend_data, w,
(struct color){.red = ps->o.shadow_red,
.green = ps->o.shadow_green,
.blue = ps->o.shadow_blue,
.alpha = ps->o.shadow_opacity},
ps->gaussian_map);
}
#ifdef CONFIG_DBUS #ifdef CONFIG_DBUS
// Send D-Bus signal // Send D-Bus signal

View File

@ -272,8 +272,6 @@ bool must_use destroy_win_start(session_t *ps, struct win *w);
/// Release images bound with a window, set the *_NONE flags on the window. Only to be /// Release images bound with a window, set the *_NONE flags on the window. Only to be
/// used when de-initializing the backend outside of win.c /// used when de-initializing the backend outside of win.c
void win_release_images(struct backend_base *base, struct managed_win *w); void win_release_images(struct backend_base *base, struct managed_win *w);
void win_bind_image(struct backend_base *backend, struct managed_win *w, struct color c,
struct conv *kernel);
int win_get_name(session_t *ps, struct managed_win *w); int win_get_name(session_t *ps, struct managed_win *w);
int win_get_role(session_t *ps, struct managed_win *w); int win_get_role(session_t *ps, struct managed_win *w);
winmode_t attr_pure win_calc_mode(const struct managed_win *w); winmode_t attr_pure win_calc_mode(const struct managed_win *w);