Skip to content

Commit

Permalink
Merge branch 'next' into stable/10
Browse files Browse the repository at this point in the history
  • Loading branch information
yshui committed Nov 17, 2022
2 parents 5d15015 + 706acb7 commit c678ad6
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 37 deletions.
2 changes: 1 addition & 1 deletion man/picom.1.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ May also be one of the predefined kernels: `3x3box` (default), `5x5box`, `7x7box
GLX backend: Avoid rebinding pixmap on window damage. Probably could improve performance on rapid window content changes, but is known to break things on some drivers (LLVMpipe, xf86-video-intel, etc.). Recommended if it works.

*--no-use-damage*::
Disable the use of damage information. This cause the whole screen to be redrawn everytime, instead of the part of the screen has actually changed. Potentially degrades the performance, but might fix some artifacts.
Disable the use of damage information. This cause the whole screen to be redrawn every time, instead of the part of the screen has actually changed. Potentially degrades the performance, but might fix some artifacts.

*--xrender-sync-fence*::
Use X Sync fence to sync clients' draw calls, to make sure all draw calls are finished before picom starts drawing. Needed on nvidia-drivers with GLX backend for some users.
Expand Down
4 changes: 2 additions & 2 deletions picom.sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ detect-transient = true;
# glx-no-rebind-pixmap = false

# Disable the use of damage information.
# This cause the whole screen to be redrawn everytime, instead of the part of the screen
# This cause the whole screen to be redrawn every time, instead of the part of the screen
# has actually changed. Potentially degrades the performance, but might fix some artifacts.
# The opposing option is use-damage
#
Expand Down Expand Up @@ -409,7 +409,7 @@ log-level = "warn";
# transparent, and you want shadows in those areas.
#
# clip-shadow-above:::
# Controls wether shadows that would have been drawn above the window should
# Controls whether shadows that would have been drawn above the window should
# be clipped. Useful for dock windows that should have no shadow painted on top.
#
# redir-ignore:::
Expand Down
76 changes: 47 additions & 29 deletions src/backend/gl/gl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,18 +1174,28 @@ struct gl_shadow_context {
struct backend_shadow_context *gl_create_shadow_context(backend_t *base, double radius) {
auto ctx = ccalloc(1, struct gl_shadow_context);
ctx->radius = radius;

struct gaussian_blur_args args = {
.size = (int)radius,
.deviation = gaussian_kernel_std_for_size(radius, 0.5 / 256.0),
};
ctx->blur_context = gl_create_blur_context(base, BLUR_METHOD_GAUSSIAN, &args);
ctx->blur_context = NULL;

if (radius > 0) {
struct gaussian_blur_args args = {
.size = (int)radius,
.deviation = gaussian_kernel_std_for_size(radius, 0.5 / 256.0),
};
ctx->blur_context = gl_create_blur_context(base, BLUR_METHOD_GAUSSIAN, &args);
if (!ctx->blur_context) {
log_error("Failed to create shadow context");
free(ctx);
return NULL;
}
}
return (struct backend_shadow_context *)ctx;
}

void gl_destroy_shadow_context(backend_t *base attr_unused, struct backend_shadow_context *ctx) {
auto ctx_ = (struct gl_shadow_context *)ctx;
gl_destroy_blur_context(base, (struct backend_blur_context *)ctx_->blur_context);
if (ctx_->blur_context) {
gl_destroy_blur_context(base, (struct backend_blur_context *)ctx_->blur_context);
}
free(ctx_);
}

Expand Down Expand Up @@ -1246,27 +1256,32 @@ void *gl_shadow_from_mask(backend_t *base, void *mask,

gl_check_err();

glActiveTexture(GL_TEXTURE0);
auto tmp_texture = gl_new_texture(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, tmp_texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, new_inner->width, new_inner->height, 0,
GL_RED, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);

glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
tmp_texture, 0);

region_t reg_blur;
pixman_region32_init_rect(&reg_blur, 0, 0, (unsigned int)new_inner->width,
(unsigned int)new_inner->height);
// gl_blur expects reg_blur to be in X coordinate system (i.e. y flipped), but we
// are covering the whole texture so we don't need to worry about that.
gl_blur_impl(1.0, gsctx->blur_context, NULL, (coord_t){0}, &reg_blur, NULL,
source_texture,
(geometry_t){.width = new_inner->width, .height = new_inner->height},
fbo, gd->default_mask_texture);
pixman_region32_fini(&reg_blur);
auto tmp_texture = source_texture;
if (gsctx->blur_context != NULL) {
glActiveTexture(GL_TEXTURE0);
tmp_texture = gl_new_texture(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, tmp_texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, new_inner->width,
new_inner->height, 0, GL_RED, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);

glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, tmp_texture, 0);

region_t reg_blur;
pixman_region32_init_rect(&reg_blur, 0, 0, (unsigned int)new_inner->width,
(unsigned int)new_inner->height);
// gl_blur expects reg_blur to be in X coordinate system (i.e. y flipped),
// but we are covering the whole texture so we don't need to worry about
// that.
gl_blur_impl(
1.0, gsctx->blur_context, NULL, (coord_t){0}, &reg_blur, NULL,
source_texture,
(geometry_t){.width = new_inner->width, .height = new_inner->height},
fbo, gd->default_mask_texture);
pixman_region32_fini(&reg_blur);
}

// Colorize the shadow with color.
log_debug("Colorize shadow");
Expand Down Expand Up @@ -1318,7 +1333,10 @@ void *gl_shadow_from_mask(backend_t *base, void *mask,
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glDeleteBuffers(2, bo);

glDeleteTextures(1, (GLuint[]){source_texture, tmp_texture});
glDeleteTextures(1, (GLuint[]){source_texture});
if (tmp_texture != source_texture) {
glDeleteTextures(1, (GLuint[]){tmp_texture});
}
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glDeleteFramebuffers(1, &fbo);
gl_check_err();
Expand Down
4 changes: 2 additions & 2 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ typedef struct session {
/// Use an ev_idle callback for drawing
/// So we only start drawing when events are processed
ev_idle draw_idle;
/// Called everytime we have timeouts or new data on socket,
/// Called every time we have timeouts or new data on socket,
/// so we can be sure if xcb read from X socket at anytime during event
/// handling, we will not left any event unhandled in the queue
ev_prepare event_check;
Expand Down Expand Up @@ -240,7 +240,7 @@ typedef struct session {
/// Whether we need to redraw the screen
bool redraw_needed;

/// Cache a xfixes region so we don't need to allocate it everytime.
/// Cache a xfixes region so we don't need to allocate it every time.
/// A workaround for yshui/picom#301
xcb_xfixes_region_t damaged_region;
/// The region needs to painted on next paint.
Expand Down
2 changes: 1 addition & 1 deletion src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static const struct picom_option picom_options[] = {
{"log-file" , required_argument, 322, NULL , "Path to the log file."},
{"use-damage" , no_argument , 323, NULL , "Render only the damaged (changed) part of the screen"},
{"no-use-damage" , no_argument , 324, NULL , "Disable the use of damage information. This cause the whole screen to be"
"redrawn everytime, instead of the part of the screen that has actually "
"redrawn every time, instead of the part of the screen that has actually "
"changed. Potentially degrades the performance, but might fix some artifacts."},
{"no-vsync" , no_argument , 325, NULL , "Disable VSync"},
{"max-brightness" , required_argument, 326, NULL , "Dims windows which average brightness is above this threshold. Requires "
Expand Down
1 change: 1 addition & 0 deletions src/win.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ static inline bool win_bind_pixmap(struct backend_base *b, struct managed_win *w
}

bool win_bind_mask(struct backend_base *b, struct managed_win *w) {
assert(!w->mask_image);
auto reg_bound_local = win_get_bounding_shape_global_by_val(w);
pixman_region32_translate(&reg_bound_local, -w->g.x, -w->g.y);
w->mask_image = b->ops->make_mask(
Expand Down
4 changes: 2 additions & 2 deletions tests/configs/parsing_test.conf
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ detect-transient = true;
# glx-no-rebind-pixmap = false

# Disable the use of damage information.
# This cause the whole screen to be redrawn everytime, instead of the part of the screen
# This cause the whole screen to be redrawn every time, instead of the part of the screen
# has actually changed. Potentially degrades the performance, but might fix some artifacts.
# The opposing option is use-damage
#
Expand Down Expand Up @@ -400,7 +400,7 @@ log-level = "warn";
# transparent, and you want shadows in those areas.
#
# clip-shadow-above:::
# Controls wether shadows that would have been drawn above the window should
# Controls whether shadows that would have been drawn above the window should
# be clipped. Useful for dock windows that should have no shadow painted on top.
#
# redir-ignore:::
Expand Down

0 comments on commit c678ad6

Please sign in to comment.