cogl/onscreen/egl: Move struct to C file

In praparation for declaring the EGL onscreen part using G_DECLARE*.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
This commit is contained in:
Jonas Ådahl 2020-10-17 09:55:01 +02:00 committed by Robert Mader
parent 760a07cc24
commit 7cf24ccc34
6 changed files with 174 additions and 63 deletions

View File

@ -39,6 +39,7 @@
#include <cogl/cogl-frame-info-private.h>
#include <cogl/cogl-renderer-private.h>
#if defined (COGL_HAS_EGL_SUPPORT)
#include <cogl/winsys/cogl-onscreen-egl.h>
#include <cogl/winsys/cogl-winsys-egl-private.h>
#endif
#include <cogl/winsys/cogl-winsys-private.h>

View File

@ -32,6 +32,26 @@
#include "cogl-trace.h"
#include "winsys/cogl-winsys-egl-private.h"
typedef struct _CoglOnscreenEGL
{
EGLSurface egl_surface;
/* Platform specific data */
void *platform;
} CoglOnscreenEGL;
CoglOnscreenEGL *
cogl_onscreen_egl_new (void)
{
return g_slice_new0 (CoglOnscreenEGL);
}
void
cogl_onscreen_egl_free (CoglOnscreenEGL *onscreen_egl)
{
g_slice_free (CoglOnscreenEGL, onscreen_egl);
}
gboolean
_cogl_winsys_onscreen_egl_init (CoglOnscreen *onscreen,
GError **error)
@ -307,3 +327,29 @@ _cogl_winsys_onscreen_egl_swap_buffers_with_damage (CoglOnscreen *onscreen,
else
eglSwapBuffers (egl_renderer->edpy, egl_onscreen->egl_surface);
}
void
cogl_onscreen_egl_set_platform (CoglOnscreenEGL *onscreen_egl,
gpointer platform)
{
onscreen_egl->platform = platform;
}
gpointer
cogl_onscreen_egl_get_platform (CoglOnscreenEGL *onscreen_egl)
{
return onscreen_egl->platform;
}
void
cogl_onscreen_egl_set_egl_surface (CoglOnscreenEGL *onscreen_egl,
EGLSurface egl_surface)
{
onscreen_egl->egl_surface = egl_surface;
}
EGLSurface
cogl_onscreen_egl_get_egl_surface (CoglOnscreenEGL *onscreen_egl)
{
return onscreen_egl->egl_surface;
}

View File

@ -27,6 +27,15 @@
#define COGL_ONSCREEN_EGL_H
#include "cogl-onscreen.h"
#include "winsys/cogl-winsys-egl-private.h"
typedef struct _CoglOnscreenEGL CoglOnscreenEGL;
COGL_EXPORT CoglOnscreenEGL *
cogl_onscreen_egl_new (void);
COGL_EXPORT void
cogl_onscreen_egl_free (CoglOnscreenEGL *onscreen_egl);
gboolean
_cogl_winsys_onscreen_egl_init (CoglOnscreen *onscreen,
@ -55,4 +64,18 @@ _cogl_winsys_onscreen_egl_swap_buffers_with_damage (CoglOnscreen *onscreen,
CoglFrameInfo *info,
gpointer user_data);
COGL_EXPORT void
cogl_onscreen_egl_set_platform (CoglOnscreenEGL *onscreen_egl,
gpointer platform);
COGL_EXPORT gpointer
cogl_onscreen_egl_get_platform (CoglOnscreenEGL *onscreen_egl);
COGL_EXPORT void
cogl_onscreen_egl_set_egl_surface (CoglOnscreenEGL *onscreen_egl,
EGLSurface egl_surface);
COGL_EXPORT EGLSurface
cogl_onscreen_egl_get_egl_surface (CoglOnscreenEGL *onscreen_egl);
#endif /* COGL_ONSCREEN_EGL_H */

View File

@ -165,14 +165,6 @@ typedef struct _CoglContextEGL
EGLSurface saved_read_surface;
} CoglContextEGL;
typedef struct _CoglOnscreenEGL
{
EGLSurface egl_surface;
/* Platform specific data */
void *platform;
} CoglOnscreenEGL;
COGL_EXPORT const CoglWinsysVtable *
_cogl_winsys_egl_get_vtable (void);

View File

@ -45,6 +45,7 @@
#include "cogl-texture-2d-private.h"
#include "cogl-texture-2d.h"
#include "cogl-poll-private.h"
#include "winsys/cogl-onscreen-egl.h"
#include "winsys/cogl-winsys-egl-x11-private.h"
#include "winsys/cogl-winsys-egl-private.h"
@ -87,7 +88,8 @@ find_onscreen_for_xid (CoglContext *context, uint32_t xid)
continue;
egl_onscreen = cogl_onscreen_get_winsys (COGL_ONSCREEN (framebuffer));
xlib_onscreen = egl_onscreen->platform;
xlib_onscreen =
cogl_onscreen_egl_get_platform (egl_onscreen);
if (xlib_onscreen->xwin == (Window)xid)
return COGL_ONSCREEN (framebuffer);
}
@ -105,7 +107,8 @@ flush_pending_resize_notifications_cb (void *data,
{
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
CoglOnscreenEGL *egl_onscreen = cogl_onscreen_get_winsys (onscreen);
CoglOnscreenXlib *xlib_onscreen = egl_onscreen->platform;
CoglOnscreenXlib *xlib_onscreen =
cogl_onscreen_egl_get_platform (egl_onscreen);
if (xlib_onscreen->pending_resize_notify)
{
@ -164,7 +167,7 @@ notify_resize (CoglContext *context,
NULL);
}
xlib_onscreen = egl_onscreen->platform;
xlib_onscreen = cogl_onscreen_egl_get_platform (egl_onscreen);
xlib_onscreen->pending_resize_notify = TRUE;
}
@ -427,6 +430,7 @@ _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
CoglOnscreenXlib *xlib_onscreen;
CoglOnscreenEGL *egl_onscreen = cogl_onscreen_get_winsys (onscreen);
Window xwin;
EGLSurface egl_surface;
/* FIXME: We need to explicitly Select for ConfigureNotify events.
* We need to document that for windows we create then toolkits
@ -501,15 +505,17 @@ _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
}
xlib_onscreen = g_slice_new (CoglOnscreenXlib);
egl_onscreen->platform = xlib_onscreen;
cogl_onscreen_egl_set_platform (egl_onscreen, xlib_onscreen);
xlib_onscreen->xwin = xwin;
egl_onscreen->egl_surface =
egl_surface =
eglCreateWindowSurface (egl_renderer->edpy,
egl_config,
(EGLNativeWindowType) xlib_onscreen->xwin,
NULL);
cogl_onscreen_egl_set_egl_surface (egl_onscreen,
egl_surface);
return TRUE;
}
@ -524,7 +530,8 @@ _cogl_winsys_egl_onscreen_deinit (CoglOnscreen *onscreen)
_cogl_xlib_renderer_get_data (renderer);
CoglXlibTrapState old_state;
CoglOnscreenEGL *egl_onscreen = cogl_onscreen_get_winsys (onscreen);
CoglOnscreenXlib *xlib_onscreen = egl_onscreen->platform;
CoglOnscreenXlib *xlib_onscreen =
cogl_onscreen_egl_get_platform (egl_onscreen);
_cogl_xlib_renderer_trap_errors (renderer, &old_state);
@ -555,7 +562,8 @@ _cogl_winsys_onscreen_set_visibility (CoglOnscreen *onscreen,
CoglXlibRenderer *xlib_renderer =
_cogl_xlib_renderer_get_data (renderer);
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
CoglOnscreenXlib *xlib_onscreen = onscreen_egl->platform;
CoglOnscreenXlib *xlib_onscreen =
cogl_onscreen_egl_get_platform (onscreen_egl);
if (visibility)
XMapWindow (xlib_renderer->xdpy, xlib_onscreen->xwin);
@ -572,7 +580,8 @@ _cogl_winsys_onscreen_set_resizable (CoglOnscreen *onscreen,
CoglXlibRenderer *xlib_renderer =
_cogl_xlib_renderer_get_data (context->display->renderer);
CoglOnscreenEGL *egl_onscreen = cogl_onscreen_get_winsys (onscreen);
CoglOnscreenXlib *xlib_onscreen = egl_onscreen->platform;
CoglOnscreenXlib *xlib_onscreen =
cogl_onscreen_egl_get_platform (egl_onscreen);
XSizeHints *size_hints = XAllocSizeHints ();
@ -606,7 +615,8 @@ static uint32_t
_cogl_winsys_onscreen_x11_get_window_xid (CoglOnscreen *onscreen)
{
CoglOnscreenEGL *egl_onscreen = cogl_onscreen_get_winsys (onscreen);
CoglOnscreenXlib *xlib_onscreen = egl_onscreen->platform;
CoglOnscreenXlib *xlib_onscreen =
cogl_onscreen_egl_get_platform (egl_onscreen);
return xlib_onscreen->xwin;
}

View File

@ -342,7 +342,8 @@ get_supported_egl_modifiers (CoglOnscreen *onscreen,
uint32_t format)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaRendererNative *renderer_native = onscreen_native->renderer_native;
MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
MetaGpu *gpu;
@ -390,7 +391,8 @@ get_supported_modifiers (CoglOnscreen *onscreen,
uint32_t format)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaCrtcKms *crtc_kms = META_CRTC_KMS (onscreen_native->crtc);
MetaGpu *gpu;
g_autoptr (GArray) modifiers = NULL;
@ -408,7 +410,8 @@ static GArray *
get_supported_kms_formats (CoglOnscreen *onscreen)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaCrtcKms *crtc_kms = META_CRTC_KMS (onscreen_native->crtc);
return meta_crtc_kms_copy_drm_format_list (crtc_kms);
@ -443,7 +446,8 @@ init_secondary_gpu_state_gpu_copy_mode (MetaRendererNative *renderer_nat
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
int width, height;
EGLNativeWindowType egl_native_window;
@ -601,7 +605,8 @@ init_secondary_gpu_state_cpu_copy_mode (MetaRendererNative *renderer_nat
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaOnscreenNativeSecondaryGpuState *secondary_gpu_state;
MetaGpuKms *gpu_kms;
MetaKmsDevice *kms_device;
@ -666,7 +671,8 @@ init_secondary_gpu_state (MetaRendererNative *renderer_native,
GError **error)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaGpu *gpu = meta_crtc_get_gpu (onscreen_native->crtc);
MetaRendererNativeGpuData *renderer_gpu_data;
@ -713,7 +719,8 @@ static void
free_current_secondary_bo (CoglOnscreen *onscreen)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaOnscreenNativeSecondaryGpuState *secondary_gpu_state;
secondary_gpu_state = onscreen_native->secondary_gpu_state;
@ -727,7 +734,8 @@ static void
free_current_bo (CoglOnscreen *onscreen)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
g_clear_object (&onscreen_native->gbm.current_fb);
free_current_secondary_bo (onscreen);
@ -995,7 +1003,8 @@ static void
swap_secondary_drm_fb (CoglOnscreen *onscreen)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaOnscreenNativeSecondaryGpuState *secondary_gpu_state;
secondary_gpu_state = onscreen_native->secondary_gpu_state;
@ -1011,7 +1020,8 @@ static void
meta_onscreen_native_swap_drm_fb (CoglOnscreen *onscreen)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
if (!onscreen_native->gbm.next_fb)
return;
@ -1058,7 +1068,8 @@ notify_view_crtc_presented (MetaRendererView *view,
clutter_stage_view_get_onscreen (stage_view);
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaRendererNative *renderer_native = onscreen_native->renderer_native;
CoglFrameInfo *frame_info;
MetaCrtc *crtc;
@ -1257,7 +1268,8 @@ static void
queue_dummy_power_save_page_flip (CoglOnscreen *onscreen)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaRendererNative *renderer_native = onscreen_native->renderer_native;
const unsigned int timeout_ms = 100;
@ -1281,7 +1293,8 @@ meta_onscreen_native_flip_crtc (CoglOnscreen *onscreen,
MetaKmsPageFlipListenerFlag flags)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaRendererNative *renderer_native = onscreen_native->renderer_native;
MetaGpuKms *render_gpu = onscreen_native->render_gpu;
MetaCrtcKms *crtc_kms = META_CRTC_KMS (crtc);
@ -1344,7 +1357,8 @@ meta_onscreen_native_set_crtc_mode (CoglOnscreen *onscreen,
MetaRendererNativeGpuData *renderer_gpu_data)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaCrtcKms *crtc_kms = META_CRTC_KMS (onscreen_native->crtc);
MetaKmsCrtc *kms_crtc = meta_crtc_kms_get_kms_crtc (crtc_kms);
MetaKmsDevice *kms_device = meta_kms_crtc_get_device (kms_crtc);
@ -1382,7 +1396,8 @@ import_shared_framebuffer (CoglOnscreen *onscreen,
MetaOnscreenNativeSecondaryGpuState *secondary_gpu_state)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaGpuKms *gpu_kms;
MetaKmsDevice *kms_device;
struct gbm_device *gbm_device;
@ -1458,7 +1473,8 @@ copy_shared_framebuffer_gpu (CoglOnscreen *onscreen,
gboolean *egl_context_changed)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaRendererNative *renderer_native = renderer_gpu_data->renderer_native;
MetaEgl *egl = meta_renderer_native_get_egl (renderer_native);
GError *error = NULL;
@ -1632,7 +1648,8 @@ copy_shared_framebuffer_primary_gpu (CoglOnscreen *onscre
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaRendererNative *renderer_native = onscreen_native->renderer_native;
MetaRendererNativeGpuData *primary_gpu_data;
MetaDrmBufferDumb *buffer_dumb;
@ -1772,7 +1789,8 @@ static void
update_secondary_gpu_state_pre_swap_buffers (CoglOnscreen *onscreen)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaOnscreenNativeSecondaryGpuState *secondary_gpu_state;
COGL_TRACE_BEGIN_SCOPED (MetaRendererNativeGpuStatePreSwapBuffers,
@ -1827,7 +1845,8 @@ update_secondary_gpu_state_post_swap_buffers (CoglOnscreen *onscreen,
gboolean *egl_context_changed)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaRendererNative *renderer_native = onscreen_native->renderer_native;
MetaOnscreenNativeSecondaryGpuState *secondary_gpu_state;
@ -1867,7 +1886,8 @@ static void
ensure_crtc_modes (CoglOnscreen *onscreen)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer);
CoglRenderer *cogl_renderer = cogl_context->display->renderer;
@ -1899,7 +1919,8 @@ kms_device_from_view (MetaRendererView *view)
clutter_stage_view_get_onscreen (CLUTTER_STAGE_VIEW (view));
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaCrtcKms *crtc_kms = META_CRTC_KMS (onscreen_native->crtc);
MetaKmsCrtc *kms_crtc = meta_crtc_kms_get_kms_crtc (crtc_kms);
@ -1913,7 +1934,8 @@ gpu_from_view (MetaRendererView *view)
clutter_stage_view_get_onscreen (CLUTTER_STAGE_VIEW (view));
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
return meta_crtc_get_gpu (onscreen_native->crtc);
}
@ -2065,7 +2087,8 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
meta_backend_get_monitor_manager (backend);
MetaKms *kms = meta_backend_native_get_kms (backend_native);
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaGpuKms *render_gpu = onscreen_native->render_gpu;
MetaKmsDevice *render_kms_device = meta_gpu_kms_get_kms_device (render_gpu);
ClutterFrame *frame = user_data;
@ -2305,7 +2328,8 @@ meta_onscreen_native_is_buffer_scanout_compatible (CoglOnscreen *onscreen,
uint32_t stride)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
const MetaCrtcConfig *crtc_config;
MetaDrmBuffer *fb;
struct gbm_bo *gbm_bo;
@ -2350,7 +2374,8 @@ meta_onscreen_native_direct_scanout (CoglOnscreen *onscreen,
GError **error)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaGpuKms *render_gpu = onscreen_native->render_gpu;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer);
@ -2469,7 +2494,8 @@ static gboolean
should_surface_be_sharable (CoglOnscreen *onscreen)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
if (META_GPU_KMS (meta_crtc_get_gpu (onscreen_native->crtc)) ==
onscreen_native->render_gpu)
@ -2487,7 +2513,8 @@ meta_renderer_native_create_surface_gbm (CoglOnscreen *onscreen,
GError **error)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaRendererNative *renderer_native = onscreen_native->renderer_native;
MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
@ -2578,7 +2605,8 @@ meta_renderer_native_create_surface_egl_device (CoglOnscreen *onscreen,
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer);
CoglDisplay *cogl_display = cogl_context->display;
CoglDisplayEGL *cogl_display_egl = cogl_display->winsys;
@ -2672,11 +2700,11 @@ meta_renderer_native_init_onscreen (CoglOnscreen *onscreen,
g_return_val_if_fail (cogl_display_egl->egl_context, FALSE);
onscreen_egl = g_slice_new0 (CoglOnscreenEGL);
onscreen_egl = cogl_onscreen_egl_new ();
cogl_onscreen_set_winsys (onscreen, onscreen_egl);
onscreen_native = g_slice_new0 (MetaOnscreenNative);
onscreen_egl->platform = onscreen_native;
cogl_onscreen_egl_set_platform (onscreen_egl, onscreen_native);
/*
* Don't actually initialize anything here, since we may not have the
@ -2697,7 +2725,8 @@ meta_onscreen_native_allocate (CoglOnscreen *onscreen,
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaRendererNativeGpuData *renderer_gpu_data;
struct gbm_surface *gbm_surface;
EGLSurface egl_surface;
@ -2732,7 +2761,7 @@ meta_onscreen_native_allocate (CoglOnscreen *onscreen,
return FALSE;
onscreen_native->gbm.surface = gbm_surface;
onscreen_egl->egl_surface = egl_surface;
cogl_onscreen_egl_set_egl_surface (onscreen_egl, egl_surface);
break;
#ifdef HAVE_EGL_DEVICE
case META_RENDERER_NATIVE_MODE_EGL_DEVICE:
@ -2754,7 +2783,7 @@ meta_onscreen_native_allocate (CoglOnscreen *onscreen,
return FALSE;
onscreen_native->egl.stream = egl_stream;
onscreen_egl->egl_surface = egl_surface;
cogl_onscreen_egl_set_egl_surface (onscreen_egl, egl_surface);
break;
#endif /* HAVE_EGL_DEVICE */
}
@ -2766,10 +2795,13 @@ static void
destroy_egl_surface (CoglOnscreen *onscreen)
{
CoglOnscreenEGL *onscreen_egl = cogl_onscreen_get_winsys (onscreen);
EGLSurface egl_surface;
if (onscreen_egl->egl_surface != EGL_NO_SURFACE)
egl_surface = cogl_onscreen_egl_get_egl_surface (onscreen_egl);
if (cogl_onscreen_egl_get_egl_surface (onscreen_egl) != EGL_NO_SURFACE)
{
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaOnscreenNative *onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer);
@ -2778,9 +2810,9 @@ destroy_egl_surface (CoglOnscreen *onscreen)
meta_egl_destroy_surface (egl,
cogl_renderer_egl->edpy,
onscreen_egl->egl_surface,
egl_surface,
NULL);
onscreen_egl->egl_surface = EGL_NO_SURFACE;
cogl_onscreen_egl_set_egl_surface (onscreen_egl, EGL_NO_SURFACE);
}
}
@ -2795,17 +2827,20 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
MetaOnscreenNative *onscreen_native;
MetaRendererNative *renderer_native;
MetaRendererNativeGpuData *renderer_gpu_data;
EGLSurface egl_surface;
/* If we never successfully allocated then there's nothing to do */
if (onscreen_egl == NULL)
return;
onscreen_native = onscreen_egl->platform;
onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
renderer_native = onscreen_native->renderer_native;
if (onscreen_egl->egl_surface != EGL_NO_SURFACE &&
(cogl_display_egl->current_draw_surface == onscreen_egl->egl_surface ||
cogl_display_egl->current_read_surface == onscreen_egl->egl_surface))
egl_surface = cogl_onscreen_egl_get_egl_surface (onscreen_egl);
if (egl_surface != EGL_NO_SURFACE &&
(cogl_display_egl->current_draw_surface == egl_surface ||
cogl_display_egl->current_read_surface == egl_surface))
{
if (!_cogl_winsys_egl_make_current (cogl_display,
cogl_display_egl->dummy_surface,
@ -2860,7 +2895,7 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
secondary_gpu_state_free);
g_slice_free (MetaOnscreenNative, onscreen_native);
g_slice_free (CoglOnscreenEGL, cogl_onscreen_get_winsys (onscreen));
cogl_onscreen_egl_free (cogl_onscreen_get_winsys (onscreen));
cogl_onscreen_set_winsys (onscreen, NULL);
}
@ -2914,7 +2949,8 @@ meta_renderer_native_create_onscreen (MetaRendererNative *renderer_native,
}
onscreen_egl = cogl_onscreen_get_winsys (onscreen);
onscreen_native = onscreen_egl->platform;
onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
onscreen_native->renderer_native = renderer_native;
onscreen_native->render_gpu = render_gpu;
onscreen_native->output = output;
@ -3038,7 +3074,8 @@ meta_onscreen_native_set_view (CoglOnscreen *onscreen,
MetaOnscreenNative *onscreen_native;
onscreen_egl = cogl_onscreen_get_winsys (onscreen);
onscreen_native = onscreen_egl->platform;
onscreen_native =
cogl_onscreen_egl_get_platform (onscreen_egl);
onscreen_native->view = view;
}
@ -3124,6 +3161,7 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
int onscreen_height;
MetaRectangle view_layout;
MetaRendererView *view;
EGLSurface egl_surface;
GError *error = NULL;
crtc_config = meta_crtc_get_config (crtc);
@ -3212,9 +3250,10 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
/* Ensure we don't point to stale surfaces when creating the offscreen */
onscreen_egl = cogl_onscreen_get_winsys (onscreen);
cogl_display_egl = cogl_display->winsys;
egl_surface = cogl_onscreen_egl_get_egl_surface (onscreen_egl);
_cogl_winsys_egl_make_current (cogl_display,
onscreen_egl->egl_surface,
onscreen_egl->egl_surface,
egl_surface,
egl_surface,
cogl_display_egl->egl_context);
return view;