opt:Reduce unnecessary buffer scale

This commit is contained in:
DreamMaoMao 2025-04-10 11:27:39 +08:00
parent e0fdbc99e1
commit 5ae688eefb

View file

@ -4455,6 +4455,14 @@ void scene_buffer_apply_size(struct wlr_scene_buffer *buffer, int sx, int sy,
return;
}
if(scale_data->height_scale == 1 && scale_data->width_scale < 1) {
return;
}
if(scale_data->height_scale < 1 && scale_data->width_scale == 1) {
return;
}
struct wlr_scene_surface *scene_surface = wlr_scene_surface_try_from_buffer(buffer);
if(scene_surface == NULL) return;
@ -4464,8 +4472,8 @@ void scene_buffer_apply_size(struct wlr_scene_buffer *buffer, int sx, int sy,
uint32_t surface_width = surface->current.width;
uint32_t surface_height = surface->current.height;
surface_width *= scale_data->width_scale;
surface_height *= scale_data->height_scale;
surface_width = scale_data->width_scale < 1 ? surface_width : scale_data->width_scale * surface_width;
surface_height = scale_data->height_scale < 1 ? surface_height : scale_data->height_scale * surface_height;
if (surface_width > scale_data->width && wlr_subsurface_try_from_wlr_surface(surface) == NULL) {
surface_width = scale_data->width;