From 77e28d4a772c369777a344a6b07a22851be6ddf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 20 Nov 2014 07:18:26 +0100 Subject: [PATCH] mir: only allow to set foreign surfaces with hardware buffer And return a CoglBool accordingly. --- cogl/cogl-onscreen.h | 4 +++- cogl/winsys/cogl-winsys-egl-mir.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) 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 *