From 7040579a38d56576406f6be824bafe94af8dc1cb Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sat, 30 Nov 2019 21:22:28 +0000 Subject: [PATCH] backend: clarify comments about reg_paint Signed-off-by: Yuxuan Shui --- src/backend/backend.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/backend/backend.c b/src/backend/backend.c index ae8ea6d6..5739c802 100644 --- a/src/backend/backend.c +++ b/src/backend/backend.c @@ -85,6 +85,16 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) { static struct timespec last_paint = {0}; #endif + // + // If use_damage is enabled, we MUST make sure only the damaged regions of the + // screen are ever touched by the compositor. The reason is that at the beginning + // of each render, we clear the damaged regions with the wallpaper, and nothing + // else. If later during the render we changed anything outside the damaged + // region, that won't be cleared by the next render, and will thus accumulate. + // (e.g. if shadow is drawn outside the damaged region, it will become thicker and + // thicker over time.) + + /// The adjusted damaged regions region_t reg_paint; assert(ps->o.blur_method != BLUR_METHOD_INVALID); if (ps->o.blur_method != BLUR_METHOD_NONE && ps->backend_data->ops->get_blur_size) { @@ -266,8 +276,8 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) { // Set max brightness if (ps->o.max_brightness < 1.0) { ps->backend_data->ops->image_op( - ps->backend_data, IMAGE_OP_MAX_BRIGHTNESS, w->win_image, - NULL, ®_visible, &ps->o.max_brightness); + ps->backend_data, IMAGE_OP_MAX_BRIGHTNESS, w->win_image, NULL, + ®_visible, &ps->o.max_brightness); } // Draw window on target @@ -275,13 +285,13 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) { ps->backend_data->ops->compose(ps->backend_data, w->win_image, w->g.x, w->g.y, ®_paint_in_bound, ®_visible); - } else if (w->opacity * MAX_ALPHA >= 1){ + } else if (w->opacity * MAX_ALPHA >= 1) { // We don't need to paint the window body itself if it's // completely transparent. - // For window image processing, we don't need to limit the process - // region to damage, since the window image data is independent - // from the target image data, which we want to protect. + // For window image processing, we don't have to limit the process + // region to damage for correctness. (see for + // details) // The bounding shape, in window local coordinates region_t reg_bound_local;