Implicitly allocate on cogl_wayland_onscreen_get_(shell_)?surface

The idea with the framebuffer allocation is that it will lazily
allocate so that if you don't want to handle errors then you don't
have to be aware that there is an allocation step. In order for this
to work any accessors that get data that is only available after
allocation should implicitly allocate the framebuffer. This patch
makes that change for cogl_wayland_onscreen_get_surface and
cogl_wayland_onscreen_get_shell_surface.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 0c4ba78787323fedd162d7b71b86b460908b9b98)
This commit is contained in:
Neil Roberts 2013-07-03 18:32:00 +01:00
parent 3060d44365
commit 8911da794e

View File

@ -634,33 +634,29 @@ cogl_wayland_renderer_get_shell (CoglRenderer *renderer)
struct wl_surface * struct wl_surface *
cogl_wayland_onscreen_get_surface (CoglOnscreen *onscreen) cogl_wayland_onscreen_get_surface (CoglOnscreen *onscreen)
{ {
CoglFramebuffer *fb; CoglOnscreenEGL *egl_onscreen;
CoglOnscreenWayland *wayland_onscreen;
cogl_framebuffer_allocate (COGL_FRAMEBUFFER (onscreen), NULL);
egl_onscreen = onscreen->winsys;
wayland_onscreen = egl_onscreen->platform;
fb = COGL_FRAMEBUFFER (onscreen);
if (fb->allocated)
{
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
CoglOnscreenWayland *wayland_onscreen = egl_onscreen->platform;
return wayland_onscreen->wayland_surface; return wayland_onscreen->wayland_surface;
}
else
return NULL;
} }
struct wl_shell_surface * struct wl_shell_surface *
cogl_wayland_onscreen_get_shell_surface (CoglOnscreen *onscreen) cogl_wayland_onscreen_get_shell_surface (CoglOnscreen *onscreen)
{ {
CoglFramebuffer *fb; CoglOnscreenEGL *egl_onscreen;
CoglOnscreenWayland *wayland_onscreen;
cogl_framebuffer_allocate (COGL_FRAMEBUFFER (onscreen), NULL);
egl_onscreen = onscreen->winsys;
wayland_onscreen = egl_onscreen->platform;
fb = COGL_FRAMEBUFFER (onscreen);
if (fb->allocated)
{
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
CoglOnscreenWayland *wayland_onscreen = egl_onscreen->platform;
return wayland_onscreen->wayland_shell_surface; return wayland_onscreen->wayland_shell_surface;
}
else
return NULL;
} }
void void