mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-29 16:05:59 +01:00
Fix surface buffer uploading
This commit is contained in:
parent
18f1538108
commit
10eee58d2d
2 changed files with 28 additions and 15 deletions
|
@ -38,6 +38,7 @@ struct wlr_surface {
|
||||||
|
|
||||||
float buffer_to_surface_matrix[16];
|
float buffer_to_surface_matrix[16];
|
||||||
float surface_to_buffer_matrix[16];
|
float surface_to_buffer_matrix[16];
|
||||||
|
bool reupload_buffer;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct wl_signal commit;
|
struct wl_signal commit;
|
||||||
|
|
|
@ -206,8 +206,13 @@ static void surface_commit(struct wl_client *client,
|
||||||
surface->current.buffer = surface->pending.buffer;
|
surface->current.buffer = surface->pending.buffer;
|
||||||
}
|
}
|
||||||
if ((surface->pending.invalid & WLR_SURFACE_INVALID_SURFACE_DAMAGE)) {
|
if ((surface->pending.invalid & WLR_SURFACE_INVALID_SURFACE_DAMAGE)) {
|
||||||
|
int32_t oldw = surface->current.buffer_width;
|
||||||
|
int32_t oldh = surface->current.buffer_height;
|
||||||
wlr_surface_update_size(surface);
|
wlr_surface_update_size(surface);
|
||||||
|
|
||||||
|
surface->reupload_buffer = oldw != surface->current.buffer_width ||
|
||||||
|
oldh != surface->current.buffer_height;
|
||||||
|
|
||||||
pixman_region32_union(&surface->current.surface_damage,
|
pixman_region32_union(&surface->current.surface_damage,
|
||||||
&surface->current.surface_damage,
|
&surface->current.surface_damage,
|
||||||
&surface->pending.surface_damage);
|
&surface->pending.surface_damage);
|
||||||
|
@ -257,29 +262,36 @@ void wlr_surface_flush_damage(struct wlr_surface *surface) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pixman_region32_t damage = surface->current.buffer_damage;
|
|
||||||
if (!pixman_region32_not_empty(&damage)) {
|
|
||||||
goto release;
|
|
||||||
}
|
|
||||||
int n;
|
|
||||||
pixman_box32_t *rects = pixman_region32_rectangles(&damage, &n);
|
|
||||||
uint32_t format = wl_shm_buffer_get_format(buffer);
|
uint32_t format = wl_shm_buffer_get_format(buffer);
|
||||||
for (int i = 0; i < n; ++i) {
|
if (surface->reupload_buffer) {
|
||||||
pixman_box32_t rect = rects[i];
|
wlr_texture_upload_shm(surface->texture, format, buffer);
|
||||||
if (!wlr_texture_update_shm(surface->texture, format,
|
} else {
|
||||||
rect.x1, rect.y1,
|
pixman_region32_t damage = surface->current.buffer_damage;
|
||||||
rect.x2 - rect.x1,
|
if (!pixman_region32_not_empty(&damage)) {
|
||||||
rect.y2 - rect.y1,
|
goto release;
|
||||||
buffer)) {
|
}
|
||||||
break;
|
int n;
|
||||||
|
pixman_box32_t *rects = pixman_region32_rectangles(&damage, &n);
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
pixman_box32_t rect = rects[i];
|
||||||
|
if (!wlr_texture_update_shm(surface->texture, format,
|
||||||
|
rect.x1, rect.y1,
|
||||||
|
rect.x2 - rect.x1,
|
||||||
|
rect.y2 - rect.y1,
|
||||||
|
buffer)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
release:
|
||||||
pixman_region32_fini(&surface->current.surface_damage);
|
pixman_region32_fini(&surface->current.surface_damage);
|
||||||
pixman_region32_init(&surface->current.surface_damage);
|
pixman_region32_init(&surface->current.surface_damage);
|
||||||
|
|
||||||
pixman_region32_fini(&surface->current.buffer_damage);
|
pixman_region32_fini(&surface->current.buffer_damage);
|
||||||
pixman_region32_init(&surface->current.buffer_damage);
|
pixman_region32_init(&surface->current.buffer_damage);
|
||||||
release:
|
|
||||||
wl_resource_queue_event(surface->current.buffer, WL_BUFFER_RELEASE);
|
wl_resource_queue_event(surface->current.buffer, WL_BUFFER_RELEASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue