meson: add -Wfloat-conversion

This commit is contained in:
Kirill Primak 2022-09-19 00:16:24 +03:00
parent 2ad25b1460
commit cf857ecf7b
31 changed files with 220 additions and 204 deletions

View file

@ -633,7 +633,7 @@ static int init_encoding(struct capture_context *ctx) {
return 1;
ctx->avctx->opaque = ctx;
ctx->avctx->bit_rate = (int)ctx->out_bitrate*1000000.0f;
ctx->avctx->bit_rate = (int)(ctx->out_bitrate * 1000000.0f);
ctx->avctx->pix_fmt = ctx->software_format;
ctx->avctx->time_base = (AVRational){ 1, 1000 };
ctx->avctx->compression_level = 7;

View file

@ -62,10 +62,10 @@ static void render_surface(struct wlr_surface *surface,
}
struct wlr_box box = {
.x = sx * output->scale,
.y = sy * output->scale,
.width = surface->current.width * output->scale,
.height = surface->current.height * output->scale,
.x = (int)(sx * output->scale),
.y = (int)(sy * output->scale),
.width = (int)(surface->current.width * output->scale),
.height = (int)(surface->current.height * output->scale),
};
float matrix[9];
@ -95,7 +95,7 @@ static void output_handle_frame(struct wl_listener *listener, void *data) {
wlr_renderer_begin(renderer, width, height);
float color[4] = {0.3, 0.3, 0.3, 1.0};
float color[4] = {0.3f, 0.3f, 0.3f, 1.0f};
wlr_renderer_clear(renderer, color);
if (output->surface != NULL) {

View file

@ -26,9 +26,9 @@ static void render_frame(void) {
glViewport(0, 0, width, height);
if (keys) {
glClearColor(1.0, 1.0, 1.0, 1.0);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
} else {
glClearColor(0.8, 0.4, 1.0, 1.0);
glClearColor(0.8f, 0.4f, 1.0f, 1.0f);
}
glClear(GL_COLOR_BUFFER_BIT);

View file

@ -39,13 +39,13 @@ struct wl_egl_window *popup_egl_window;
static uint32_t popup_width = 256, popup_height = 256;
struct wlr_egl_surface *popup_egl_surface;
struct wl_callback *popup_frame_callback;
float popup_alpha = 1.0, popup_red = 0.5f;
float popup_alpha = 1.0f, popup_red = 0.5f;
static uint32_t layer = ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND;
static uint32_t anchor = 0;
static uint32_t width = 256, height = 256;
static int32_t margin_top = 0;
static double alpha = 1.0;
static float alpha = 1.0f;
static bool run_display = true;
static bool animate = false;
static enum zwlr_layer_surface_v1_keyboard_interactivity keyboard_interactive =
@ -148,15 +148,15 @@ static void draw(void) {
}
static void draw_popup(void) {
static float alpha_mod = -0.01;
static float alpha_mod = -0.01f;
eglMakeCurrent(egl_display, popup_egl_surface, popup_egl_surface, egl_context);
glViewport(0, 0, popup_width, popup_height);
glClearColor(popup_red * popup_alpha, 0.5f * popup_alpha,
0.5f * popup_alpha, popup_alpha);
popup_alpha += alpha_mod;
if (popup_alpha < 0.01 || popup_alpha >= 1.0f) {
alpha_mod *= -1.0;
if (popup_alpha < 0.01f || popup_alpha >= 1.0f) {
alpha_mod *= -1.0f;
}
glClear(GL_COLOR_BUFFER_BIT);
@ -324,9 +324,9 @@ static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
} else if (input_surface == popup_wl_surface) {
if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
if (button == BTN_LEFT && popup_red <= 0.9f) {
popup_red += 0.1;
popup_red += 0.1f;
} else if (button == BTN_RIGHT && popup_red >= 0.1f) {
popup_red -= 0.1;
popup_red -= 0.1f;
}
}
} else {
@ -541,7 +541,7 @@ int main(int argc, char **argv) {
break;
}
case 't':
alpha = atof(optarg);
alpha = (float)atof(optarg);
break;
case 'm': {
char *endptr = optarg;

View file

@ -82,25 +82,25 @@ static void animate_cat(struct sample_state *sample,
sample->x_offs = l_output->x + 20;
sample->y_offs = l_output->y + 20;
} else if (ur_collision && ul_collision) {
sample->y_vel = fabs(sample->y_vel);
sample->y_vel = fabsf(sample->y_vel);
} else if (lr_collision && ll_collision) {
sample->y_vel = -fabs(sample->y_vel);
sample->y_vel = -fabsf(sample->y_vel);
} else if (ll_collision && ul_collision) {
sample->x_vel = fabs(sample->x_vel);
sample->x_vel = fabsf(sample->x_vel);
} else if (ur_collision && lr_collision) {
sample->x_vel = -fabs(sample->x_vel);
sample->x_vel = -fabsf(sample->x_vel);
} else {
if (ur_collision || lr_collision) {
sample->x_vel = -fabs(sample->x_vel);
sample->x_vel = -fabsf(sample->x_vel);
}
if (ul_collision || ll_collision) {
sample->x_vel = fabs(sample->x_vel);
sample->x_vel = fabsf(sample->x_vel);
}
if (ul_collision || ur_collision) {
sample->y_vel = fabs(sample->y_vel);
sample->y_vel = fabsf(sample->y_vel);
}
if (ll_collision || lr_collision) {
sample->y_vel = -fabs(sample->y_vel);
sample->y_vel = -fabsf(sample->y_vel);
}
}
@ -119,12 +119,12 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
wlr_output_attach_render(wlr_output, NULL);
wlr_renderer_begin(sample->renderer, wlr_output->width, wlr_output->height);
wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1});
wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1.0f});
animate_cat(sample, output->output);
struct wlr_box box = {
.x = sample->x_offs, .y = sample->y_offs,
.x = (int)sample->x_offs, .y = (int)sample->y_offs,
.width = 128, .height = 128,
};
if (wlr_output_layout_intersects(sample->layout, output->output, &box)) {
@ -135,7 +135,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
&local_x, &local_y);
wlr_render_texture(sample->renderer, sample->cat_texture,
wlr_output->transform_matrix, local_x, local_y, 1.0f);
wlr_output->transform_matrix,
(int)local_x, (int)local_y, 1.0f);
}
wlr_renderer_end(sample->renderer);

View file

@ -87,9 +87,9 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
wlr_output_commit(wlr_output);
//TODO rotate with a delta time
rotation += 0.05;
rotation += 0.05f;
if (rotation > 2 * M_PI) {
rotation = 0.f;
rotation = 0.0f;
}
sample->last_frame = now;

View file

@ -91,17 +91,17 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
wlr_renderer_begin(sample->renderer, wlr_output->width, wlr_output->height);
wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1});
float distance = 0.8f * (1 - sample->distance);
float distance = 0.8f * (float)(1.0 - sample->distance);
float tool_color[4] = { distance, distance, distance, 1 };
for (size_t i = 0; sample->button && i < 4; ++i) {
tool_color[i] = sample->tool_color[i];
}
float scale = 4;
float pad_width = sample->width_mm * scale;
float pad_height = sample->height_mm * scale;
float left = width / 2.0f - pad_width / 2.0f;
float top = height / 2.0f - pad_height / 2.0f;
int pad_width = (int)(sample->width_mm * scale);
int pad_height = (int)(sample->height_mm * scale);
int left = (int)(width / 2.0f - pad_width / 2.0f);
int top = (int)(height / 2.0f - pad_height / 2.0f);
const struct wlr_box box = {
.x = left, .y = top,
.width = pad_width, .height = pad_height,
@ -111,18 +111,18 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
if (sample->proximity) {
struct wlr_box box = {
.x = (sample->x * pad_width) - 8 * (sample->pressure + 1) + left,
.y = (sample->y * pad_height) - 8 * (sample->pressure + 1) + top,
.width = 16 * (sample->pressure + 1),
.height = 16 * (sample->pressure + 1),
.x = (int)((sample->x * pad_width) - 8 * (sample->pressure + 1) + left),
.y = (int)((sample->y * pad_height) - 8 * (sample->pressure + 1) + top),
.width = (int)(16 * (sample->pressure + 1)),
.height = (int)(16 * (sample->pressure + 1)),
};
float matrix[9];
wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL,
sample->ring, wlr_output->transform_matrix);
(float)sample->ring, wlr_output->transform_matrix);
wlr_render_quad_with_matrix(sample->renderer, tool_color, matrix);
box.x += sample->x_tilt;
box.y += sample->y_tilt;
box.x += (int)sample->x_tilt;
box.y += (int)sample->y_tilt;
box.width /= 2;
box.height /= 2;
wlr_render_rect(sample->renderer, &box, tool_color,

View file

@ -69,9 +69,9 @@ struct wlr_egl_surface *egl_surface;
static void draw(void) {
eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context);
float color[] = {1.0, 1.0, 0.0, 1.0};
color[0] = enabled * 1.0;
color[1] = entered * 1.0;
float color[] = {1.0f, 1.0f, 0.0f, 1.0f};
color[0] = enabled * 1.0f;
color[1] = entered * 1.0f;
glViewport(0, 0, width, height);
glClearColor(color[0], color[1], color[2], 1.0);