wip! renderer/native: generalize flip_egl_stream

We're going to need to be able to flip secondary egl streams,
so this commit parameterizes the stream and related objects.

A new wrapper function, `flip_primary_egl_stream`, takes over the
previous role of `flip_egl_stream`

fixme no_egl_output_drm_flip_event needs to be handled for secondary
streams
This commit is contained in:
Ray Strode 2018-09-17 10:16:50 -04:00
parent 5d8248d65b
commit 0540e4dc45

View File

@ -1330,25 +1330,18 @@ flip_closure_destroyed (MetaRendererView *view)
#ifdef HAVE_EGL_DEVICE #ifdef HAVE_EGL_DEVICE
static gboolean static gboolean
flip_egl_stream (MetaOnscreenNative *onscreen_native, flip_egl_stream (MetaOnscreenNative *onscreen_native,
MetaGpuKms *gpu_kms,
EGLDisplay egl_display,
EGLStreamKHR *egl_stream,
GClosure *flip_closure) GClosure *flip_closure)
{ {
MetaRendererNativeGpuData *renderer_gpu_data;
EGLDisplay *egl_display;
MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native); MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
MetaGpuKmsFlipClosureContainer *closure_container; MetaGpuKmsFlipClosureContainer *closure_container;
EGLAttrib *acquire_attribs; EGLAttrib *acquire_attribs;
GError *error = NULL; GError *error = NULL;
renderer_gpu_data =
meta_renderer_native_get_gpu_data (onscreen_native->renderer_native,
onscreen_native->render_gpu);
if (renderer_gpu_data->egl.no_egl_output_drm_flip_event)
return FALSE;
closure_container = closure_container =
meta_gpu_kms_wrap_flip_closure (onscreen_native->render_gpu, meta_gpu_kms_wrap_flip_closure (gpu_kms, NULL, flip_closure);
NULL,
flip_closure);
acquire_attribs = (EGLAttrib[]) { acquire_attribs = (EGLAttrib[]) {
EGL_DRM_FLIP_EVENT_DATA_NV, EGL_DRM_FLIP_EVENT_DATA_NV,
@ -1356,10 +1349,9 @@ flip_egl_stream (MetaOnscreenNative *onscreen_native,
EGL_NONE EGL_NONE
}; };
egl_display = renderer_gpu_data->egl_display;
if (!meta_egl_stream_consumer_acquire_attrib (egl, if (!meta_egl_stream_consumer_acquire_attrib (egl,
egl_display, egl_display,
onscreen_native->egl.stream, egl_stream,
acquire_attribs, acquire_attribs,
&error)) &error))
{ {
@ -1368,7 +1360,8 @@ flip_egl_stream (MetaOnscreenNative *onscreen_native,
{ {
g_warning ("Failed to flip EGL stream (%s), relying on clock from " g_warning ("Failed to flip EGL stream (%s), relying on clock from "
"now on", error->message); "now on", error->message);
renderer_gpu_data->egl.no_egl_output_drm_flip_event = TRUE; /* FIXME: need to pass this out i guess
*/
} }
g_error_free (error); g_error_free (error);
meta_gpu_kms_flip_closure_container_free (closure_container); meta_gpu_kms_flip_closure_container_free (closure_container);
@ -1379,6 +1372,29 @@ flip_egl_stream (MetaOnscreenNative *onscreen_native,
return TRUE; return TRUE;
} }
static gboolean
flip_primary_egl_stream (MetaOnscreenNative *onscreen_native,
GClosure *flip_closure)
{
MetaRendererNativeGpuData *renderer_gpu_data;
gboolean ret;
renderer_gpu_data =
meta_renderer_native_get_gpu_data (onscreen_native->renderer_native,
onscreen_native->render_gpu);
if (renderer_gpu_data->egl.no_egl_output_drm_flip_event)
return FALSE;
ret = flip_egl_stream (onscreen_native,
onscreen_native->render_gpu,
renderer_gpu_data->egl_display,
onscreen_native->egl.stream,
flip_closure);
g_closure_ref (flip_closure);
return ret;
}
#endif /* HAVE_EGL_DEVICE */ #endif /* HAVE_EGL_DEVICE */
static void static void
@ -1435,8 +1451,8 @@ meta_onscreen_native_flip_crtc (CoglOnscreen *onscreen,
break; break;
#ifdef HAVE_EGL_DEVICE #ifdef HAVE_EGL_DEVICE
case META_RENDERER_NATIVE_MODE_EGL_DEVICE: case META_RENDERER_NATIVE_MODE_EGL_DEVICE:
if (flip_egl_stream (onscreen_native, if (flip_primary_egl_stream (onscreen_native,
flip_closure)) flip_closure))
onscreen_native->total_pending_flips++; onscreen_native->total_pending_flips++;
*fb_in_use = TRUE; *fb_in_use = TRUE;
break; break;