treewide: fix various build warnings; ignore vendored headers in formatting job

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I7af033c8d3f437e5574b050223cbc16a6a6a6964
This commit is contained in:
raf 2026-04-16 21:04:05 +03:00
commit 3719dbccd5
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
10 changed files with 95 additions and 81 deletions

View file

@ -6,7 +6,7 @@
#include <GLES2/gl2.h>
#include "../include/chroma.h"
#include "../include/stb_image.h"
#include "../include/vendor/stb_image.h"
// Convert filter quality enum to OpenGL parameters
static void get_gl_filter_params(chroma_filter_quality_t quality,
@ -64,14 +64,14 @@ static void calculate_texture_coords(chroma_scale_mode_t scale_mode,
// Center image at original size
// Calculate how much of the texture to show
{
float image_aspect = (float)image_width / image_height;
float output_aspect = (float)output_width / output_height;
float image_aspect = (float)image_width / (float)image_height;
float output_aspect = (float)output_width / (float)output_height;
if (image_aspect > output_aspect) {
// Image is wider - fit width, show center portion vertically
float visible_height = (float)image_width / output_aspect;
float v_offset =
(image_height - visible_height) / (2.0f * image_height);
float v_offset = ((float)image_height - visible_height) /
(2.0f * (float)image_height);
u1 = 0.0f;
v1 = v_offset;
u2 = 1.0f;
@ -79,7 +79,8 @@ static void calculate_texture_coords(chroma_scale_mode_t scale_mode,
} else {
// Image is taller - fit height, show center portion horizontally
float visible_width = (float)image_height * output_aspect;
float u_offset = (image_width - visible_width) / (2.0f * image_width);
float u_offset =
((float)image_width - visible_width) / (2.0f * (float)image_width);
u1 = u_offset;
v1 = 0.0f;
u2 = 1.0f - u_offset;
@ -91,14 +92,14 @@ static void calculate_texture_coords(chroma_scale_mode_t scale_mode,
case CHROMA_SCALE_FIT:
// Fit image within output, maintaining aspect ratio
{
float image_aspect = (float)image_width / image_height;
float output_aspect = (float)output_width / output_height;
float image_aspect = (float)image_width / (float)image_height;
float output_aspect = (float)output_width / (float)output_height;
if (image_aspect > output_aspect) {
// Image is wider - fit width, add borders top/bottom
float scaled_height = (float)output_width / image_aspect;
float v_border =
(output_height - scaled_height) / (2.0f * output_height);
float v_border = ((float)output_height - scaled_height) /
(2.0f * (float)output_height);
u1 = 0.0f;
v1 = v_border;
u2 = 1.0f;
@ -106,7 +107,8 @@ static void calculate_texture_coords(chroma_scale_mode_t scale_mode,
} else {
// Image is taller - fit height, add borders left/right
float scaled_width = (float)output_height * image_aspect;
float u_border = (output_width - scaled_width) / (2.0f * output_width);
float u_border =
((float)output_width - scaled_width) / (2.0f * (float)output_width);
u1 = u_border;
v1 = 0.0f;
u2 = 1.0f - u_border;
@ -119,21 +121,23 @@ static void calculate_texture_coords(chroma_scale_mode_t scale_mode,
default:
// Fill entire output, crop if necessary
{
float image_aspect = (float)image_width / image_height;
float output_aspect = (float)output_width / output_height;
float image_aspect = (float)image_width / (float)image_height;
float output_aspect = (float)output_width / (float)output_height;
if (image_aspect > output_aspect) {
// Image is wider - crop left/right
float crop_width = image_height * output_aspect;
float u_crop = (image_width - crop_width) / (2.0f * image_width);
float crop_width = (float)image_height * output_aspect;
float u_crop =
((float)image_width - crop_width) / (2.0f * (float)image_width);
u1 = u_crop;
v1 = 0.0f;
u2 = 1.0f - u_crop;
v2 = 1.0f;
} else {
// Image is taller - crop top/bottom
float crop_height = image_width / output_aspect;
float v_crop = (image_height - crop_height) / (2.0f * image_height);
float crop_height = (float)image_width / output_aspect;
float v_crop =
((float)image_height - crop_height) / (2.0f * (float)image_height);
u1 = 0.0f;
v1 = v_crop;
u2 = 1.0f;
@ -336,7 +340,8 @@ static int update_texture_from_image(chroma_output_t *output,
// Could this b made more accurate?
if (output->image && output->image->loaded) {
size_t texture_size = (size_t)output->image->width *
output->image->height * output->image->channels;
(size_t)output->image->height *
(size_t)output->image->channels;
chroma_log_resource_deallocation("gpu_texture", texture_size,
"texture replacement");
}
@ -349,7 +354,8 @@ static int update_texture_from_image(chroma_output_t *output,
glBindTexture(GL_TEXTURE_2D, output->texture_id);
// Log GPU texture allocation
size_t texture_size = (size_t)image->width * image->height * image->channels;
size_t texture_size =
(size_t)image->width * (size_t)image->height * (size_t)image->channels;
chroma_log_resource_allocation("gpu_texture", texture_size, image->path);
// Set texture parameters
@ -398,8 +404,8 @@ static int update_texture_from_image(chroma_output_t *output,
// Only free image data when ALL outputs using it have uploaded
if (total_using > 0 && uploaded_count >= total_using) {
size_t freed_bytes =
(size_t)image->width * image->height * image->channels;
size_t freed_bytes = (size_t)image->width * (size_t)image->height *
(size_t)image->channels;
stbi_image_free(image->data);
image->data = NULL;
chroma_log("INFO",
@ -580,8 +586,8 @@ int chroma_surface_create(chroma_state_t *state, chroma_output_t *output) {
}
// Configure layer surface
zwlr_layer_surface_v1_set_size(output->layer_surface, output->width,
output->height);
zwlr_layer_surface_v1_set_size(output->layer_surface, (uint32_t)output->width,
(uint32_t)output->height);
zwlr_layer_surface_v1_set_anchor(output->layer_surface,
ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
@ -626,8 +632,7 @@ int chroma_surface_create(chroma_state_t *state, chroma_output_t *output) {
output->width, output->height);
// Log surface creation resource allocation
size_t surface_size =
(size_t)output->width * output->height * 4; // estimate RGBA surface
size_t surface_size = (size_t)output->width * (size_t)output->height * 4;
chroma_log_resource_allocation("egl_surface", surface_size, "output surface");
return CHROMA_OK;
@ -663,8 +668,7 @@ void chroma_surface_destroy(chroma_output_t *output) {
}
// Log surface destruction
size_t surface_size =
(size_t)output->width * output->height * 4; // estimate RGBA surface
size_t surface_size = (size_t)output->width * (size_t)output->height * 4;
chroma_log_resource_deallocation("egl_surface", surface_size,
"output surface cleanup");
@ -749,13 +753,13 @@ int chroma_render_wallpaper(chroma_state_t *state, chroma_output_t *output) {
GLint position_attr = glGetAttribLocation(output->shader_program, "position");
GLint texcoord_attr = glGetAttribLocation(output->shader_program, "texcoord");
glEnableVertexAttribArray(position_attr);
glVertexAttribPointer(position_attr, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float),
(void *)0);
glEnableVertexAttribArray((GLuint)position_attr);
glVertexAttribPointer((GLuint)position_attr, 2, GL_FLOAT, GL_FALSE,
4 * sizeof(float), (void *)0);
glEnableVertexAttribArray(texcoord_attr);
glVertexAttribPointer(texcoord_attr, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float),
(void *)(2 * sizeof(float)));
glEnableVertexAttribArray((GLuint)texcoord_attr);
glVertexAttribPointer((GLuint)texcoord_attr, 2, GL_FLOAT, GL_FALSE,
4 * sizeof(float), (void *)(2 * sizeof(float)));
// Draw
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);