diff --git a/cogl/cogl-onscreen.h b/cogl/cogl-onscreen.h index 990a7161e..99a9365d8 100644 --- a/cogl/cogl-onscreen.h +++ b/cogl/cogl-onscreen.h @@ -282,10 +282,12 @@ cogl_mir_onscreen_get_surface (CoglOnscreen *onscreen); * * This function must be called before @onscreen is allocated. * + * Returns: whether @surface has been marked as been set as surface or not. + * * Since: 1.18 * Stability: unstable */ -void +CoglBool cogl_mir_onscreen_set_foreign_surface (CoglOnscreen *onscreen, struct MirSurface *surface); #endif /* COGL_HAS_EGL_PLATFORM_MIR_SUPPORT */ diff --git a/cogl/winsys/cogl-winsys-egl-mir.c b/cogl/winsys/cogl-winsys-egl-mir.c index 5173727d1..c958cfc6f 100644 --- a/cogl/winsys/cogl-winsys-egl-mir.c +++ b/cogl/winsys/cogl-winsys-egl-mir.c @@ -658,17 +658,23 @@ cogl_mir_renderer_get_connection (CoglRenderer *renderer) return NULL; } -void +CoglBool cogl_mir_onscreen_set_foreign_surface (CoglOnscreen *onscreen, MirSurface *surface) { CoglFramebuffer *fb; - _COGL_RETURN_IF_FAIL (mir_surface_is_valid (surface)); + MirSurfaceParameters parameters; + + _COGL_RETURN_VAL_IF_FAIL (mir_surface_is_valid (surface), FALSE); fb = COGL_FRAMEBUFFER (onscreen); - _COGL_RETURN_IF_FAIL (!fb->allocated); + _COGL_RETURN_VAL_IF_FAIL (!fb->allocated, FALSE); + + mir_surface_get_parameters (surface, ¶meters); + _COGL_RETURN_VAL_IF_FAIL (parameters.buffer_usage == mir_buffer_usage_hardware, FALSE); onscreen->foreign_surface = surface; + return TRUE; } MirSurface *