gl-renderer: Attach buffer during surface state creation if possible
When a renderer switch happens, it is possible that when the surface
state is created, a buffer for the given surface is already available.
In that case, run the attach routine so that the pixel contents are
properly set. Otherwise, it would only be set when a new attach request
is made for that surface.
Also, change the drm backend so that it keeps the buffer reference in
the weston_surface when running with the pixman renderer. The pixman
renderer keeps a reference to it anyway, so it is never released
early.
This makes the renderer transition seamless, without leaving a black
screen as before.
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index 5e1b396..218fca4 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -883,7 +883,8 @@
if (!texture_used)
return;
- if (!pixman_region32_not_empty(&gs->texture_damage))
+ if (!pixman_region32_not_empty(&gs->texture_damage) &&
+ !gs->needs_full_upload)
goto done;
switch (wl_shm_buffer_get_format(buffer->shm_buffer)) {
@@ -1240,6 +1241,11 @@
wl_signal_add(&gr->destroy_signal,
&gs->renderer_destroy_listener);
+ if (surface->buffer_ref.buffer) {
+ gl_renderer_attach(surface, surface->buffer_ref.buffer);
+ gl_renderer_flush_damage(surface);
+ }
+
return 0;
}