Adapt paint_all_new to new interface

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-01-27 19:29:02 +00:00
parent e898526afb
commit b50f15c835
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
2 changed files with 33 additions and 14 deletions

View File

@ -22,20 +22,39 @@ bool default_is_frame_transparent(void *backend_data, win *w, void *win_data) {
return w->frame_opacity != 1; return w->frame_opacity != 1;
} }
region_t get_damage(session_t *ps) {
region_t region;
pixman_region32_init(&region);
int buffer_age = backend_list[ps->o.backend]->buffer_age(ps->backend_data, ps);
if (buffer_age == -1 || buffer_age > ps->ndamage) {
pixman_region32_copy(&region, &ps->screen_reg);
} else {
for (int i = 0; i < buffer_age; i++) {
const int curr = ((ps->damage - ps->damage_ring) + i) % ps->ndamage;
pixman_region32_union(&region, &region, &ps->damage_ring[curr]);
}
pixman_region32_intersect(&region, &region, &ps->screen_reg);
}
return region;
}
/// paint all windows /// paint all windows
void paint_all_new(session_t *ps, region_t *_region, win *const t) { void paint_all_new(session_t *ps, win *const t, bool ignore_damage) {
region_t region;
if (!ignore_damage) {
region = get_damage(ps);
} else {
pixman_region32_init(&region);
pixman_region32_copy(&region, &ps->screen_reg);
}
if (!pixman_region32_not_empty(&region)) {
pixman_region32_fini(&region);
return;
}
auto bi = backend_list[ps->o.backend]; auto bi = backend_list[ps->o.backend];
assert(bi); assert(bi);
const region_t *region;
if (!_region) {
region = &ps->screen_reg;
} else {
// Ignore out-of-screen damages
pixman_region32_intersect(_region, _region, &ps->screen_reg);
region = _region;
}
#ifdef DEBUG_REPAINT #ifdef DEBUG_REPAINT
static struct timespec last_paint = {0}; static struct timespec last_paint = {0};
#endif #endif
@ -46,10 +65,10 @@ void paint_all_new(session_t *ps, region_t *_region, win *const t) {
if (t) { if (t) {
// Calculate the region upon which the root window (wallpaper) is to be // Calculate the region upon which the root window (wallpaper) is to be
// painted based on the ignore region of the lowest window, if available // painted based on the ignore region of the lowest window, if available
pixman_region32_subtract(&reg_tmp, (region_t *)region, t->reg_ignore); pixman_region32_subtract(&reg_tmp, &region, t->reg_ignore);
reg_paint = &reg_tmp; reg_paint = &reg_tmp;
} else { } else {
reg_paint = region; reg_paint = &region;
} }
if (bi->prepare) if (bi->prepare)
@ -64,7 +83,7 @@ void paint_all_new(session_t *ps, region_t *_region, win *const t) {
// Calculate the region based on the reg_ignore of the next (higher) // Calculate the region based on the reg_ignore of the next (higher)
// window and the bounding region // window and the bounding region
// XXX XXX // XXX XXX
pixman_region32_subtract(&reg_tmp, (region_t *)region, w->reg_ignore); pixman_region32_subtract(&reg_tmp, &region, w->reg_ignore);
if (pixman_region32_not_empty(&reg_tmp)) { if (pixman_region32_not_empty(&reg_tmp)) {
// Render window content // Render window content

View File

@ -151,6 +151,6 @@ extern backend_info_t *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 *);
void paint_all_new(session_t *ps, region_t *region, win *const t) attr_nonnull(1); void paint_all_new(session_t *ps, win *const t, bool ignore_damage) attr_nonnull(1);
// vim: set noet sw=8 ts=8 : // vim: set noet sw=8 ts=8 :