diff --git a/cogl/winsys/cogl-winsys-egl-feature-functions.h b/cogl/winsys/cogl-winsys-egl-feature-functions.h index e9797240c..9c8dcca4a 100644 --- a/cogl/winsys/cogl-winsys-egl-feature-functions.h +++ b/cogl/winsys/cogl-winsys-egl-feature-functions.h @@ -88,18 +88,3 @@ COGL_WINSYS_FEATURE_FUNCTION (EGLBoolean, eglUnbindWaylandDisplay, struct wl_display *wayland_display)) COGL_WINSYS_FEATURE_END () #endif -COGL_WINSYS_FEATURE_BEGIN (surfaceless_opengl, - "KHR\0", - "surfaceless_opengl\0", - COGL_EGL_WINSYS_FEATURE_SURFACELESS_OPENGL) -COGL_WINSYS_FEATURE_END () -COGL_WINSYS_FEATURE_BEGIN (surfaceless_gles1, - "KHR\0", - "surfaceless_gles1\0", - COGL_EGL_WINSYS_FEATURE_SURFACELESS_GLES1) -COGL_WINSYS_FEATURE_END () -COGL_WINSYS_FEATURE_BEGIN (surfaceless_gles2, - "KHR\0", - "surfaceless_gles2\0", - COGL_EGL_WINSYS_FEATURE_SURFACELESS_GLES2) -COGL_WINSYS_FEATURE_END () diff --git a/cogl/winsys/cogl-winsys-egl-kms.c b/cogl/winsys/cogl-winsys-egl-kms.c index f3417315b..a4928e833 100644 --- a/cogl/winsys/cogl-winsys-egl-kms.c +++ b/cogl/winsys/cogl-winsys-egl-kms.c @@ -79,6 +79,7 @@ typedef struct _CoglDisplayKMS int width, height; CoglBool pending_set_crtc; CoglBool pending_swap_notify; + struct gbm_surface *dummy_gbm_surface; } CoglDisplayKMS; typedef struct _CoglFlipKMS @@ -388,8 +389,6 @@ _cogl_winsys_egl_display_setup (CoglDisplay *display, CoglDisplayKMS *kms_display; CoglRendererEGL *egl_renderer = display->renderer->winsys; CoglRendererKMS *kms_renderer = egl_renderer->platform; - CoglEGLWinsysFeature surfaceless_feature = 0; - const char *surfaceless_feature_name = ""; drmModeRes *resources; CoglOutputKMS *output0, *output1; CoglBool mirror; @@ -397,33 +396,6 @@ _cogl_winsys_egl_display_setup (CoglDisplay *display, kms_display = g_slice_new0 (CoglDisplayKMS); egl_display->platform = kms_display; - switch (display->renderer->driver) - { - case COGL_DRIVER_GL: - surfaceless_feature = COGL_EGL_WINSYS_FEATURE_SURFACELESS_OPENGL; - surfaceless_feature_name = "opengl"; - break; - case COGL_DRIVER_GLES1: - surfaceless_feature = COGL_EGL_WINSYS_FEATURE_SURFACELESS_GLES1; - surfaceless_feature_name = "gles1"; - break; - case COGL_DRIVER_GLES2: - surfaceless_feature = COGL_EGL_WINSYS_FEATURE_SURFACELESS_GLES2; - surfaceless_feature_name = "gles2"; - break; - case COGL_DRIVER_ANY: - g_return_val_if_reached (FALSE); - } - - if (!(egl_renderer->private_features & surfaceless_feature)) - { - g_set_error (error, COGL_WINSYS_ERROR, - COGL_WINSYS_ERROR_INIT, - "EGL_KHR_surfaceless_%s extension not available", - surfaceless_feature_name); - return FALSE; - } - resources = drmModeGetResources (kms_renderer->fd); if (!resources) { @@ -538,10 +510,39 @@ _cogl_winsys_egl_context_created (CoglDisplay *display, GError **error) { CoglDisplayEGL *egl_display = display->winsys; + CoglDisplayKMS *kms_display = egl_display->platform; + CoglRenderer *renderer = display->renderer; + CoglRendererEGL *egl_renderer = renderer->winsys; + CoglRendererKMS *kms_renderer = egl_renderer->platform; + + kms_display->dummy_gbm_surface = gbm_surface_create (kms_renderer->gbm, + 16, 16, + GBM_FORMAT_XRGB8888, + GBM_BO_USE_RENDERING); + if (!kms_display->dummy_gbm_surface) + { + g_set_error (error, COGL_WINSYS_ERROR, + COGL_WINSYS_ERROR_CREATE_CONTEXT, + "Failed to create dummy GBM surface"); + return FALSE; + } + + egl_display->dummy_surface = + eglCreateWindowSurface (egl_renderer->edpy, + egl_display->egl_config, + (NativeWindowType) kms_display->dummy_gbm_surface, + NULL); + if (egl_display->dummy_surface == EGL_NO_SURFACE) + { + g_set_error (error, COGL_WINSYS_ERROR, + COGL_WINSYS_ERROR_CREATE_CONTEXT, + "Failed to create dummy EGL surface"); + return FALSE; + } if (!_cogl_winsys_egl_make_current (display, - EGL_NO_SURFACE, - EGL_NO_SURFACE, + egl_display->dummy_surface, + egl_display->dummy_surface, egl_display->egl_context)) { g_set_error (error, COGL_WINSYS_ERROR, @@ -556,6 +557,22 @@ _cogl_winsys_egl_context_created (CoglDisplay *display, static void _cogl_winsys_egl_cleanup_context (CoglDisplay *display) { + CoglDisplayEGL *egl_display = display->winsys; + CoglDisplayKMS *kms_display = egl_display->platform; + CoglRenderer *renderer = display->renderer; + CoglRendererEGL *egl_renderer = renderer->winsys; + + if (egl_display->dummy_surface != EGL_NO_SURFACE) + { + eglDestroySurface (egl_renderer->edpy, egl_display->dummy_surface); + egl_display->dummy_surface = EGL_NO_SURFACE; + } + + if (kms_display->dummy_gbm_surface != NULL) + { + gbm_surface_destroy (kms_display->dummy_gbm_surface); + kms_display->dummy_gbm_surface = NULL; + } } static void diff --git a/cogl/winsys/cogl-winsys-egl-private.h b/cogl/winsys/cogl-winsys-egl-private.h index 265a423a7..eeb7028ce 100644 --- a/cogl/winsys/cogl-winsys-egl-private.h +++ b/cogl/winsys/cogl-winsys-egl-private.h @@ -68,10 +68,7 @@ typedef enum _CoglEGLWinsysFeature { COGL_EGL_WINSYS_FEATURE_SWAP_REGION =1L<<0, COGL_EGL_WINSYS_FEATURE_EGL_IMAGE_FROM_X11_PIXMAP =1L<<1, - COGL_EGL_WINSYS_FEATURE_EGL_IMAGE_FROM_WAYLAND_BUFFER =1L<<2, - COGL_EGL_WINSYS_FEATURE_SURFACELESS_OPENGL =1L<<3, - COGL_EGL_WINSYS_FEATURE_SURFACELESS_GLES1 =1L<<4, - COGL_EGL_WINSYS_FEATURE_SURFACELESS_GLES2 =1L<<5 + COGL_EGL_WINSYS_FEATURE_EGL_IMAGE_FROM_WAYLAND_BUFFER =1L<<2 } CoglEGLWinsysFeature; typedef struct _CoglRendererEGL