Skip to content

Commit

Permalink
Merge branch 'yshui:next' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
FT-Labs authored Aug 16, 2023
2 parents a5c4095 + 8cc5090 commit 367643e
Show file tree
Hide file tree
Showing 21 changed files with 177 additions and 121 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
languages: ${{ matrix.language }}

# Install dependencies
- run: sudo apt update && sudo apt install libxext-dev libxcb1-dev libxcb-dpms0-dev libxcb-damage0-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-randr0-dev libxcb-composite0-dev libxcb-image0-dev libxcb-present-dev libxcb-glx0-dev libxcb-util-dev libpixman-1-dev libdbus-1-dev libconfig-dev libgl1-mesa-dev libpcre2-dev libevdev-dev uthash-dev libev-dev libx11-xcb-dev meson ninja-build
- run: sudo apt update && sudo apt install libconfig-dev libdbus-1-dev libegl-dev libev-dev libgl-dev libpcre2-dev libpixman-1-dev libx11-xcb-dev libxcb1-dev libxcb-composite0-dev libxcb-damage0-dev libxcb-dpms0-dev libxcb-glx0-dev libxcb-image0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-shape0-dev libxcb-util-dev libxcb-xfixes0-dev libxext-dev meson ninja-build uthash-dev
if: ${{ matrix.language == 'cpp' }}

# Autobuild
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Assuming you already have all the usual building tools installed (e.g. gcc, pyth
On Debian based distributions (e.g. Ubuntu), the needed packages are

```
libxext-dev libxcb1-dev libxcb-damage0-dev libxcb-dpms0-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-randr0-dev libxcb-composite0-dev libxcb-image0-dev libxcb-present-dev libxcb-glx0-dev libpixman-1-dev libdbus-1-dev libconfig-dev libgl-dev libegl-dev libpcre2-dev libevdev-dev uthash-dev libev-dev libx11-xcb-dev meson
libconfig-dev libdbus-1-dev libegl-dev libev-dev libgl-dev libpcre2-dev libpixman-1-dev libx11-xcb-dev libxcb1-dev libxcb-composite0-dev libxcb-damage0-dev libxcb-dpms0-dev libxcb-glx0-dev libxcb-image0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-shape0-dev libxcb-util-dev libxcb-xfixes0-dev libxext-dev meson ninja-build uthash-dev
```

On Fedora, the needed packages are
Expand Down
44 changes: 22 additions & 22 deletions src/backend/backend_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,31 +405,31 @@ struct dual_kawase_params *generate_dual_kawase_params(void *args) {
int min_radius; /// Approximate gauss-blur with at least this
/// radius and std-deviation
} strength_levels[20] = {
{.iterations = 1, .offset = 1.25f, .min_radius = 1}, // LVL 1
{.iterations = 1, .offset = 2.25f, .min_radius = 6}, // LVL 2
{.iterations = 2, .offset = 2.00f, .min_radius = 11}, // LVL 3
{.iterations = 2, .offset = 3.00f, .min_radius = 17}, // LVL 4
{.iterations = 2, .offset = 4.25f, .min_radius = 24}, // LVL 5
{.iterations = 3, .offset = 2.50f, .min_radius = 32}, // LVL 6
{.iterations = 3, .offset = 3.25f, .min_radius = 40}, // LVL 7
{.iterations = 3, .offset = 4.25f, .min_radius = 51}, // LVL 8
{.iterations = 3, .offset = 5.50f, .min_radius = 67}, // LVL 9
{.iterations = 4, .offset = 3.25f, .min_radius = 83}, // LVL 10
{.iterations = 4, .offset = 4.00f, .min_radius = 101}, // LVL 11
{.iterations = 4, .offset = 5.00f, .min_radius = 123}, // LVL 12
{.iterations = 4, .offset = 6.00f, .min_radius = 148}, // LVL 13
{.iterations = 4, .offset = 7.25f, .min_radius = 178}, // LVL 14
{.iterations = 4, .offset = 8.25f, .min_radius = 208}, // LVL 15
{.iterations = 5, .offset = 4.50f, .min_radius = 236}, // LVL 16
{.iterations = 5, .offset = 5.25f, .min_radius = 269}, // LVL 17
{.iterations = 5, .offset = 6.25f, .min_radius = 309}, // LVL 18
{.iterations = 5, .offset = 7.25f, .min_radius = 357}, // LVL 19
{.iterations = 5, .offset = 8.50f, .min_radius = 417}, // LVL 20
{.iterations = 1, .offset = 1.25F, .min_radius = 1}, // LVL 1
{.iterations = 1, .offset = 2.25F, .min_radius = 6}, // LVL 2
{.iterations = 2, .offset = 2.00F, .min_radius = 11}, // LVL 3
{.iterations = 2, .offset = 3.00F, .min_radius = 17}, // LVL 4
{.iterations = 2, .offset = 4.25F, .min_radius = 24}, // LVL 5
{.iterations = 3, .offset = 2.50F, .min_radius = 32}, // LVL 6
{.iterations = 3, .offset = 3.25F, .min_radius = 40}, // LVL 7
{.iterations = 3, .offset = 4.25F, .min_radius = 51}, // LVL 8
{.iterations = 3, .offset = 5.50F, .min_radius = 67}, // LVL 9
{.iterations = 4, .offset = 3.25F, .min_radius = 83}, // LVL 10
{.iterations = 4, .offset = 4.00F, .min_radius = 101}, // LVL 11
{.iterations = 4, .offset = 5.00F, .min_radius = 123}, // LVL 12
{.iterations = 4, .offset = 6.00F, .min_radius = 148}, // LVL 13
{.iterations = 4, .offset = 7.25F, .min_radius = 178}, // LVL 14
{.iterations = 4, .offset = 8.25F, .min_radius = 208}, // LVL 15
{.iterations = 5, .offset = 4.50F, .min_radius = 236}, // LVL 16
{.iterations = 5, .offset = 5.25F, .min_radius = 269}, // LVL 17
{.iterations = 5, .offset = 6.25F, .min_radius = 309}, // LVL 18
{.iterations = 5, .offset = 7.25F, .min_radius = 357}, // LVL 19
{.iterations = 5, .offset = 8.50F, .min_radius = 417}, // LVL 20
};

auto params = ccalloc(1, struct dual_kawase_params);
params->iterations = 0;
params->offset = 1.0f;
params->offset = 1.0F;

if (blur_args->strength <= 0 && blur_args->size) {
// find highest level that approximates blur-strength with the selected
Expand All @@ -453,7 +453,7 @@ struct dual_kawase_params *generate_dual_kawase_params(void *args) {
// - Smallest texture dimensions are halved `iterations`-times
// - Upsample needs pixels two-times `offset` away from the border
// - Plus one for interpolation differences
params->expand = (1 << params->iterations) * 2 * (int)ceil(params->offset) + 1;
params->expand = (1 << params->iterations) * 2 * (int)ceilf(params->offset) + 1;

return params;
}
Expand Down
2 changes: 1 addition & 1 deletion src/backend/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static inline void print_drivers(enum driver drivers) {
const char *seen_drivers[ARR_SIZE(driver_names)];
int driver_count = 0;
for (size_t i = 0; i < ARR_SIZE(driver_names); i++) {
if (drivers & (1ul << i)) {
if (drivers & (1UL << i)) {
seen_drivers[driver_count++] = driver_names[i];
}
}
Expand Down
27 changes: 12 additions & 15 deletions src/backend/gl/blur.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ bool gl_dual_kawase_blur(double opacity, struct gl_blur_context *bctx, const rec

glUniform2f(down_pass->texorig_loc, (GLfloat)extent->x1, (GLfloat)dst_y_fb_coord);

glBindVertexArray(vao[1]);
int nelems = vao_nelems[1];

for (int i = 0; i < iterations; ++i) {
// Scale output width / height by half in each iteration
scale_factor <<= 1;
Expand All @@ -174,8 +177,6 @@ bool gl_dual_kawase_blur(double opacity, struct gl_blur_context *bctx, const rec
assert(bctx->blur_fbos[i]);

glBindTexture(GL_TEXTURE_2D, src_texture);
glBindVertexArray(vao[1]);
auto nelems = vao_nelems[1];
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, bctx->blur_fbos[i]);
glDrawBuffer(GL_COLOR_ATTACHMENT0);

Expand All @@ -194,6 +195,15 @@ bool gl_dual_kawase_blur(double opacity, struct gl_blur_context *bctx, const rec

glUniform2f(up_pass->texorig_loc, (GLfloat)extent->x1, (GLfloat)dst_y_fb_coord);

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, default_mask);

glUniform1i(up_pass->uniform_mask_tex, 1);
glUniform2f(up_pass->uniform_mask_offset, 0.0F, 0.0F);
glUniform1i(up_pass->uniform_mask_inverted, 0);
glUniform1f(up_pass->uniform_mask_corner_radius, 0.0F);
glUniform1f(up_pass->uniform_opacity, 1.0F);

for (int i = iterations - 1; i >= 0; --i) {
// Scale output width / height back by two in each iteration
scale_factor >>= 1;
Expand All @@ -206,28 +216,15 @@ bool gl_dual_kawase_blur(double opacity, struct gl_blur_context *bctx, const rec
int tex_width = src_size.width;
int tex_height = src_size.height;

// The number of indices in the selected vertex array
GLsizei nelems;

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, src_texture);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, default_mask);

glUniform1i(up_pass->uniform_mask_tex, 1);
glUniform2f(up_pass->uniform_mask_offset, 0.0F, 0.0F);
glUniform1i(up_pass->uniform_mask_inverted, 0);
glUniform1f(up_pass->uniform_mask_corner_radius, 0.0F);
if (i > 0) {
assert(bctx->blur_fbos[i - 1]);

// not last pass, draw into next framebuffer
glBindVertexArray(vao[1]);
nelems = vao_nelems[1];
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, bctx->blur_fbos[i - 1]);
glDrawBuffer(GL_COLOR_ATTACHMENT0);

glUniform1f(up_pass->uniform_opacity, (GLfloat)1);
} else {
// last pass, draw directly into the back buffer
if (mask) {
Expand Down
2 changes: 0 additions & 2 deletions src/backend/gl/gl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,6 @@ static void _gl_compose(backend_t *base, struct backend_image *img, GLuint targe
glUseProgram(0);

gl_check_err();

return;
}

/// Convert rectangles in X coordinates to OpenGL vertex and texture coordinates
Expand Down
2 changes: 1 addition & 1 deletion src/backend/gl/glx.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ void glxext_init(Display *dpy, int screen) {
#endif
#undef check_ext

#define lookup(name) (name = (__typeof__(name))glXGetProcAddress((GLubyte *)#name))
#define lookup(name) ((name) = (__typeof__(name))glXGetProcAddress((GLubyte *)#name))
// Checking if the returned function pointer is NULL is not really necessary,
// or maybe not even useful, since glXGetProcAddress might always return
// something. We are doing it just for completeness' sake.
Expand Down
4 changes: 2 additions & 2 deletions src/backend/gl/glx.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#undef glXBindTexImageEXT
#undef glXReleaseTexImageEXT
#include <X11/Xlib.h>
#include <xcb/xcb.h>
#include <xcb/render.h>
#include <xcb/xcb.h>

#include "log.h"
#include "compiler.h"
#include "log.h"
#include "utils.h"
#include "x.h"

Expand Down
21 changes: 14 additions & 7 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ bool parse_long(const char *s, long *dest) {
log_error("Invalid number: %s", s);
return false;
}
while (isspace((unsigned char)*endptr))
while (isspace((unsigned char)*endptr)) {
++endptr;
}
if (*endptr) {
log_error("Trailing characters: %s", s);
return false;
Expand Down Expand Up @@ -216,12 +217,14 @@ conv *parse_blur_kern(const char *src, const char **endptr, bool *hasneg) {

// Get matrix width and height
double val = 0.0;
if (src == (pc = parse_readnum(src, &val)))
if (src == (pc = parse_readnum(src, &val))) {
goto err1;
}
src = pc;
width = (int)val;
if (src == (pc = parse_readnum(src, &val)))
if (src == (pc = parse_readnum(src, &val))) {
goto err1;
}
src = pc;
height = (int)val;

Expand All @@ -234,9 +237,10 @@ conv *parse_blur_kern(const char *src, const char **endptr, bool *hasneg) {
log_error("Blur kernel width/height must be odd.");
goto err1;
}
if (width > 16 || height > 16)
if (width > 16 || height > 16) {
log_warn("Blur kernel width/height too large, may slow down"
"rendering, and/or consume lots of memory");
}

// Allocate memory
conv *matrix = cvalloc(sizeof(conv) + (size_t)(width * height) * sizeof(double));
Expand Down Expand Up @@ -362,8 +366,9 @@ struct conv **parse_blur_kern_lst(const char *src, bool *hasneg, int *count) {
*hasneg = false;
for (unsigned int i = 0;
i < sizeof(CONV_KERN_PREDEF) / sizeof(CONV_KERN_PREDEF[0]); ++i) {
if (!strcmp(CONV_KERN_PREDEF[i].name, src))
if (!strcmp(CONV_KERN_PREDEF[i].name, src)) {
return parse_blur_kern_lst(CONV_KERN_PREDEF[i].kern_str, hasneg, count);
}
}

int nkernels = 1;
Expand Down Expand Up @@ -655,11 +660,13 @@ bool parse_rule_window_shader(c2_lptr_t **res, const char *src, const char *incl
* Add a pattern to a condition linked list.
*/
bool condlst_add(c2_lptr_t **pcondlst, const char *pattern) {
if (!pattern)
if (!pattern) {
return false;
}

if (!c2_parse(pcondlst, pattern, NULL))
if (!c2_parse(pcondlst, pattern, NULL)) {
exit(1);
}

return true;
}
Expand Down
37 changes: 25 additions & 12 deletions src/config_libconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ FILE *open_config_file(const char *cpath, char **ppath) {

if (cpath) {
FILE *ret = fopen(cpath, "r");
if (ret && ppath)
if (ret && ppath) {
*ppath = strdup(cpath);
}
return ret;
}

Expand Down Expand Up @@ -124,9 +125,10 @@ void parse_cfg_condlst(const config_t *pcfg, c2_lptr_t **pcondlst, const char *n
// Parse an array of options
if (config_setting_is_array(setting)) {
int i = config_setting_length(setting);
while (i--)
while (i--) {
condlst_add(pcondlst,
config_setting_get_string_elem(setting, i));
}
}
// Treat it as a single pattern if it's a string
else if (CONFIG_TYPE_STRING == config_setting_type(setting)) {
Expand All @@ -145,18 +147,22 @@ parse_cfg_condlst_corner(options_t *opt, const config_t *pcfg, const char *name)
// Parse an array of options
if (config_setting_is_array(setting)) {
int i = config_setting_length(setting);
while (i--)
while (i--) {
if (!parse_numeric_window_rule(
&opt->corner_radius_rules,
config_setting_get_string_elem(setting, i), 0, INT_MAX))
config_setting_get_string_elem(setting, i), 0,
INT_MAX)) {
exit(1);
}
}
}
// Treat it as a single pattern if it's a string
else if (config_setting_type(setting) == CONFIG_TYPE_STRING) {
if (!parse_numeric_window_rule(&opt->corner_radius_rules,
config_setting_get_string(setting),
0, INT_MAX))
0, INT_MAX)) {
exit(1);
}
}
}
}
Expand All @@ -171,17 +177,21 @@ parse_cfg_condlst_opct(options_t *opt, const config_t *pcfg, const char *name) {
// Parse an array of options
if (config_setting_is_array(setting)) {
int i = config_setting_length(setting);
while (i--)
while (i--) {
if (!parse_numeric_window_rule(
&opt->opacity_rules,
config_setting_get_string_elem(setting, i), 0, 100))
config_setting_get_string_elem(setting, i), 0, 100)) {
exit(1);
}
}
}
// Treat it as a single pattern if it's a string
else if (config_setting_type(setting) == CONFIG_TYPE_STRING) {
if (!parse_numeric_window_rule(
&opt->opacity_rules, config_setting_get_string(setting), 0, 100))
if (!parse_numeric_window_rule(&opt->opacity_rules,
config_setting_get_string(setting),
0, 100)) {
exit(1);
}
}
}
}
Expand Down Expand Up @@ -390,8 +400,9 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
winopt_mask[WINTYPE_POPUP_MENU].opacity = true;
}
// -f (fading_enable)
if (config_lookup_bool(&cfg, "fading", &ival))
if (config_lookup_bool(&cfg, "fading", &ival)) {
*fading_enable = ival;
}
// --no-fading-open-close
lcfg_lookup_bool(&cfg, "no-fading-openclose", &opt->no_fading_openclose);
// --no-fading-destroyed-argb
Expand All @@ -411,8 +422,9 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
opt->shadow_blue = rgb.blue;
}
// --shadow-exclude-reg
if (config_lookup_string(&cfg, "shadow-exclude-reg", &sval))
if (config_lookup_string(&cfg, "shadow-exclude-reg", &sval)) {
opt->shadow_exclude_reg_str = strdup(sval);
}
// --inactive-opacity-override
lcfg_lookup_bool(&cfg, "inactive-opacity-override", &opt->inactive_opacity_override);
// --inactive-dim
Expand Down Expand Up @@ -674,9 +686,10 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
// --xrender-sync-fence
lcfg_lookup_bool(&cfg, "xrender-sync-fence", &opt->xrender_sync_fence);

if (lcfg_lookup_bool(&cfg, "clear-shadow", &bval))
if (lcfg_lookup_bool(&cfg, "clear-shadow", &bval)) {
log_warn("\"clear-shadow\" is removed as an option, and is always"
" enabled now. Consider removing it from your config file");
}

config_setting_t *blur_cfg = config_lookup(&cfg, "blur");
if (blur_cfg) {
Expand Down
Loading

0 comments on commit 367643e

Please sign in to comment.