-
Notifications
You must be signed in to change notification settings - Fork 343
gnome-calculator causes the example compositor to segfault #100
Comments
It does not crash for me but simply not show anything. diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h
index 9b13d9c..f076516 100644
--- a/include/wlr/types/wlr_surface.h
+++ b/include/wlr/types/wlr_surface.h
@@ -38,6 +38,7 @@ struct wlr_surface {
float buffer_to_surface_matrix[16];
float surface_to_buffer_matrix[16];
+ bool reupload_buffer;
struct {
struct wl_signal commit;
diff --git a/types/wlr_surface.c b/types/wlr_surface.c
index 50de2e4..43f8f65 100644
--- a/types/wlr_surface.c
+++ b/types/wlr_surface.c
@@ -206,8 +206,13 @@ static void surface_commit(struct wl_client *client,
surface->current.buffer = surface->pending.buffer;
}
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);
+ surface->reupload_buffer = oldw != surface->current.buffer_width ||
+ oldh != surface->current.buffer_height;
+
pixman_region32_union(&surface->current.surface_damage,
&surface->current.surface_damage,
&surface->pending.surface_damage);
@@ -257,29 +262,36 @@ void wlr_surface_flush_damage(struct wlr_surface *surface) {
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);
- 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;
+ if (surface->reupload_buffer) {
+ wlr_texture_upload_shm(surface->texture, format, buffer);
+ } else {
+ 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);
+ 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_init(&surface->current.surface_damage);
pixman_region32_fini(&surface->current.buffer_damage);
pixman_region32_init(&surface->current.buffer_damage);
-release:
+
wl_resource_queue_event(surface->current.buffer, WL_BUFFER_RELEASE);
} |
We should probably have wlr_surface take care of it. We can probably do it without that bool though, right? |
We could check if the region to be updated exceeds the current dimension of the texture |
Nah, what if the buffer is made smaller? IMO wlr_surface should handle this. I can see why the bool is necessary, though. I'd merge a PR like this. |
I would rather not merge this at the moment. It can probably be done without an extra bool. |
This is @acrisci's domain, there was some discussion on that point in #83. IIUC our implementation is to the letter of the spec, and reading it looks right to me.
It uses |
Right, oversaw this (am a bit behind with the wlr_surface implementation). |
I'm working on this today. I recommend testing with this: #include <gtk/gtk.h>
int main(int argc, char *argv[]) {
gtk_init (&argc, &argv);
GtkWidget *widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (widget), "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show(widget);
gtk_main();
} Compile:
Run:
|
fixed by #106 |
Shortly before the crash.
The text was updated successfully, but these errors were encountered: