summaryrefslogtreecommitdiff
path: root/cogl
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2016-02-22 13:19:54 -0500
committerRay Strode <rstrode@redhat.com>2016-02-22 13:39:04 -0500
commit1c1ad69f26b0ec637ee0904f1e07e5567de09563 (patch)
tree81a1c27d8e809959e17bdc39eebf783441330c67 /cogl
parent96d8be620a415ae5493f2b040aa37d4d57a0fc51 (diff)
downloadmutter-1c1ad69f26b0ec637ee0904f1e07e5567de09563.tar.gz
winsys-egl-kms: dont create 0x0 surface
commit 188752158 changed cogl to stop needlessly creating its own monitor output configuration when mutter would just soon overwrite it anyway. Unfortunately, that commit is causing a crash in some cases because cogl will now create and later draw to a 0x0 egl surface until mutter sets the monitor layout. This commit changes cogl to avoid creating and using a surface, before it knows how big of a surface to create. https://bugzilla.gnome.org/show_bug.cgi?id=758073
Diffstat (limited to 'cogl')
-rw-r--r--cogl/winsys/cogl-winsys-egl-kms.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/cogl/winsys/cogl-winsys-egl-kms.c b/cogl/winsys/cogl-winsys-egl-kms.c
index 6d7049db3..4da1f1410 100644
--- a/cogl/winsys/cogl-winsys-egl-kms.c
+++ b/cogl/winsys/cogl-winsys-egl-kms.c
@@ -909,7 +909,8 @@ _cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
if (kms_onscreen->pending_surface)
{
free_current_bo (onscreen);
- gbm_surface_destroy (kms_onscreen->surface);
+ if (kms_onscreen->surface)
+ gbm_surface_destroy (kms_onscreen->surface);
kms_onscreen->surface = kms_onscreen->pending_surface;
kms_onscreen->pending_surface = NULL;
}
@@ -1030,6 +1031,15 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
kms_onscreen = g_slice_new0 (CoglOnscreenKMS);
egl_onscreen->platform = kms_onscreen;
+ /* If a kms_fd is set then the display width and height
+ * won't be available until cogl_kms_display_set_layout
+ * is called. In that case, defer creating the surface
+ * until then.
+ */
+ if (kms_display->width == 0 ||
+ kms_display->height == 0)
+ return TRUE;
+
kms_onscreen->surface =
gbm_surface_create (kms_renderer->gbm,
kms_display->width,
@@ -1265,8 +1275,24 @@ cogl_kms_display_set_layout (CoglDisplay *display,
if (kms_onscreen->pending_surface)
gbm_surface_destroy (kms_onscreen->pending_surface);
- kms_onscreen->pending_surface = new_surface;
- kms_onscreen->pending_egl_surface = new_egl_surface;
+ /* If there's already a surface, wait until the next swap to switch
+ * it out, otherwise, if we're just starting up we can use the new
+ * surface right away.
+ */
+ if (kms_onscreen->surface != NULL)
+ {
+ kms_onscreen->pending_surface = new_surface;
+ kms_onscreen->pending_egl_surface = new_egl_surface;
+ }
+ else
+ {
+ CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (kms_display->onscreen);
+
+ kms_onscreen->surface = new_surface;
+ egl_onscreen->egl_surface = new_egl_surface;
+
+ _cogl_framebuffer_winsys_update_size (framebuffer, width, height);
+ }
}
kms_display->width = width;