2016-05-07 15:07:46 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/*
|
2016-05-09 11:51:29 +00:00
|
|
|
* Copyright (C) 2011 Intel Corporation.
|
2016-05-07 15:07:46 +00:00
|
|
|
* Copyright (C) 2016 Red Hat
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*
|
2016-05-09 11:51:29 +00:00
|
|
|
* Authors:
|
|
|
|
* Rob Bradford <rob@linux.intel.com> (from cogl-winsys-egl-kms.c)
|
|
|
|
* Kristian Høgsberg (from eglkms.c)
|
|
|
|
* Benjamin Franzke (from eglkms.c)
|
|
|
|
* Robert Bragg <robert@linux.intel.com> (from cogl-winsys-egl-kms.c)
|
|
|
|
* Neil Roberts <neil@linux.intel.com> (from cogl-winsys-egl-kms.c)
|
|
|
|
* Jonas Ådahl <jadahl@redhat.com>
|
|
|
|
*
|
2016-05-07 15:07:46 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2016-05-09 11:51:29 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <gbm.h>
|
2016-05-09 13:22:01 +00:00
|
|
|
#include <gio/gio.h>
|
|
|
|
#include <glib-object.h>
|
2016-05-09 11:51:29 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <xf86drm.h>
|
2016-05-07 15:07:46 +00:00
|
|
|
|
2016-05-09 11:51:29 +00:00
|
|
|
#include "backends/meta-backend-private.h"
|
2016-06-08 09:05:31 +00:00
|
|
|
#include "backends/meta-renderer-view.h"
|
2016-05-11 08:26:34 +00:00
|
|
|
#include "backends/native/meta-monitor-manager-kms.h"
|
2016-05-07 15:07:46 +00:00
|
|
|
#include "backends/native/meta-renderer-native.h"
|
2016-05-07 15:09:59 +00:00
|
|
|
#include "cogl/cogl.h"
|
2016-06-08 09:05:31 +00:00
|
|
|
#include "core/boxes-private.h"
|
2016-05-07 15:09:59 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
|
|
|
|
PROP_KMS_FD,
|
|
|
|
|
|
|
|
PROP_LAST
|
|
|
|
};
|
2016-05-07 15:07:46 +00:00
|
|
|
|
2016-05-27 07:07:41 +00:00
|
|
|
typedef struct _MetaOnscreenNative
|
|
|
|
{
|
|
|
|
struct gbm_surface *surface;
|
|
|
|
uint32_t current_fb_id;
|
|
|
|
uint32_t next_fb_id;
|
|
|
|
struct gbm_bo *current_bo;
|
|
|
|
struct gbm_bo *next_bo;
|
|
|
|
gboolean pending_swap_notify;
|
|
|
|
|
2016-06-08 09:05:31 +00:00
|
|
|
gboolean pending_set_crtc;
|
|
|
|
|
|
|
|
MetaRendererView *view;
|
|
|
|
int pending_flips;
|
2016-05-27 07:07:41 +00:00
|
|
|
} MetaOnscreenNative;
|
|
|
|
|
2016-05-07 15:07:46 +00:00
|
|
|
struct _MetaRendererNative
|
|
|
|
{
|
|
|
|
MetaRenderer parent;
|
2016-05-07 15:09:59 +00:00
|
|
|
|
|
|
|
int kms_fd;
|
2016-05-09 13:22:01 +00:00
|
|
|
struct gbm_device *gbm;
|
|
|
|
CoglClosure *swap_notify_idle;
|
2016-05-10 02:16:45 +00:00
|
|
|
|
2016-06-08 09:05:31 +00:00
|
|
|
int64_t frame_counter;
|
2016-05-10 02:16:45 +00:00
|
|
|
|
2016-06-08 09:05:31 +00:00
|
|
|
struct gbm_surface *dummy_gbm_surface;
|
2016-05-07 15:07:46 +00:00
|
|
|
};
|
|
|
|
|
2016-05-09 13:22:01 +00:00
|
|
|
static void
|
|
|
|
initable_iface_init (GInitableIface *initable_iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (MetaRendererNative,
|
|
|
|
meta_renderer_native,
|
|
|
|
META_TYPE_RENDERER,
|
|
|
|
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
|
|
|
|
initable_iface_init))
|
2016-05-07 15:07:46 +00:00
|
|
|
|
2016-05-09 11:51:29 +00:00
|
|
|
static const CoglWinsysEGLVtable _cogl_winsys_egl_vtable;
|
|
|
|
static const CoglWinsysVtable *parent_vtable;
|
|
|
|
|
|
|
|
static void
|
2016-06-01 09:53:07 +00:00
|
|
|
meta_renderer_native_disconnect (CoglRenderer *cogl_renderer)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
2016-06-01 09:53:07 +00:00
|
|
|
CoglRendererEGL *egl_renderer = cogl_renderer->winsys;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
if (egl_renderer->edpy != EGL_NO_DISPLAY)
|
|
|
|
eglTerminate (egl_renderer->edpy);
|
|
|
|
|
|
|
|
g_slice_free (CoglRendererEGL, egl_renderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-06-08 09:05:31 +00:00
|
|
|
flush_pending_swap_notify (CoglFramebuffer *framebuffer)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
|
|
|
if (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN)
|
|
|
|
{
|
|
|
|
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
|
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
2016-05-27 07:07:41 +00:00
|
|
|
MetaOnscreenNative *onscreen_native = egl_onscreen->platform;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
2016-05-27 07:07:41 +00:00
|
|
|
if (onscreen_native->pending_swap_notify)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
2016-05-27 07:07:41 +00:00
|
|
|
CoglFrameInfo *info =
|
|
|
|
g_queue_pop_head (&onscreen->pending_frame_infos);
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
_cogl_onscreen_notify_frame_sync (onscreen, info);
|
|
|
|
_cogl_onscreen_notify_complete (onscreen, info);
|
2016-06-08 09:05:31 +00:00
|
|
|
|
2016-05-27 07:07:41 +00:00
|
|
|
onscreen_native->pending_swap_notify = FALSE;
|
2016-06-08 09:05:31 +00:00
|
|
|
cogl_object_unref (onscreen);
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
cogl_object_unref (info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
flush_pending_swap_notify_idle (void *user_data)
|
|
|
|
{
|
2016-06-01 09:53:07 +00:00
|
|
|
CoglContext *cogl_context = user_data;
|
|
|
|
CoglRendererEGL *egl_renderer = cogl_context->display->renderer->winsys;
|
2016-05-09 13:22:01 +00:00
|
|
|
MetaRendererNative *renderer_native = egl_renderer->platform;
|
2016-06-08 09:05:31 +00:00
|
|
|
GList *l;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
/* This needs to be disconnected before invoking the callbacks in
|
|
|
|
* case the callbacks cause it to be queued again */
|
2016-05-09 13:22:01 +00:00
|
|
|
_cogl_closure_disconnect (renderer_native->swap_notify_idle);
|
|
|
|
renderer_native->swap_notify_idle = NULL;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
2016-06-08 09:05:31 +00:00
|
|
|
l = cogl_context->framebuffers;
|
|
|
|
while (l)
|
|
|
|
{
|
|
|
|
GList *next = l->next;
|
|
|
|
CoglFramebuffer *framebuffer = l->data;
|
|
|
|
|
|
|
|
flush_pending_swap_notify (framebuffer);
|
|
|
|
|
|
|
|
l = next;
|
|
|
|
}
|
2016-05-09 11:51:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
free_current_bo (CoglOnscreen *onscreen)
|
|
|
|
{
|
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
2016-05-27 07:07:41 +00:00
|
|
|
MetaOnscreenNative *onscreen_native = egl_onscreen->platform;
|
2016-06-01 09:53:07 +00:00
|
|
|
CoglContext *cogl_context = COGL_FRAMEBUFFER (onscreen)->context;
|
|
|
|
CoglRenderer *cogl_renderer = cogl_context->display->renderer;
|
|
|
|
CoglRendererEGL *egl_renderer = cogl_renderer->winsys;
|
2016-05-09 13:22:01 +00:00
|
|
|
MetaRendererNative *renderer_native = egl_renderer->platform;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
2016-05-27 07:07:41 +00:00
|
|
|
if (onscreen_native->current_fb_id)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
2016-05-09 13:22:01 +00:00
|
|
|
drmModeRmFB (renderer_native->kms_fd,
|
2016-05-27 07:07:41 +00:00
|
|
|
onscreen_native->current_fb_id);
|
|
|
|
onscreen_native->current_fb_id = 0;
|
2016-05-09 11:51:29 +00:00
|
|
|
}
|
2016-05-27 07:07:41 +00:00
|
|
|
if (onscreen_native->current_bo)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
2016-05-27 07:07:41 +00:00
|
|
|
gbm_surface_release_buffer (onscreen_native->surface,
|
|
|
|
onscreen_native->current_bo);
|
|
|
|
onscreen_native->current_bo = NULL;
|
2016-05-09 11:51:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-06-08 09:05:31 +00:00
|
|
|
meta_onscreen_native_queue_swap_notify (CoglOnscreen *onscreen)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
2016-06-08 09:05:31 +00:00
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
2016-05-27 07:07:41 +00:00
|
|
|
MetaOnscreenNative *onscreen_native = egl_onscreen->platform;
|
2016-06-08 09:05:31 +00:00
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
|
|
|
CoglContext *cogl_context =
|
|
|
|
clutter_backend_get_cogl_context (clutter_backend);
|
2016-06-01 09:53:07 +00:00
|
|
|
CoglRenderer *cogl_renderer = cogl_context->display->renderer;
|
|
|
|
CoglRendererEGL *egl_renderer = cogl_renderer->winsys;
|
2016-05-09 13:22:01 +00:00
|
|
|
MetaRendererNative *renderer_native = egl_renderer->platform;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
/* We only want to notify that the swap is complete when the
|
|
|
|
* application calls cogl_context_dispatch so instead of
|
|
|
|
* immediately notifying we queue an idle callback */
|
2016-05-09 13:22:01 +00:00
|
|
|
if (!renderer_native->swap_notify_idle)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
2016-05-09 13:22:01 +00:00
|
|
|
renderer_native->swap_notify_idle =
|
2016-06-01 09:53:07 +00:00
|
|
|
_cogl_poll_renderer_add_idle (cogl_renderer,
|
2016-05-09 11:51:29 +00:00
|
|
|
flush_pending_swap_notify_idle,
|
2016-06-01 09:53:07 +00:00
|
|
|
cogl_context,
|
2016-05-09 11:51:29 +00:00
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2016-06-08 09:05:31 +00:00
|
|
|
/*
|
|
|
|
* The framebuffer will have its own referenc while the swap notify is
|
|
|
|
* pending. Otherwise when destroying the view would drop the pending
|
|
|
|
* notification with if the destruction happens before the idle callback
|
|
|
|
* is invoked.
|
|
|
|
*/
|
|
|
|
cogl_object_ref (onscreen);
|
2016-05-27 07:07:41 +00:00
|
|
|
onscreen_native->pending_swap_notify = TRUE;
|
2016-05-09 11:51:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static CoglBool
|
2016-05-27 07:13:09 +00:00
|
|
|
meta_renderer_native_connect (CoglRenderer *cogl_renderer,
|
|
|
|
CoglError **error)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
|
|
|
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
|
|
|
|
CoglRendererEGL *egl_renderer;
|
|
|
|
|
|
|
|
cogl_renderer->winsys = g_slice_new0 (CoglRendererEGL);
|
|
|
|
egl_renderer = cogl_renderer->winsys;
|
|
|
|
|
|
|
|
egl_renderer->platform_vtable = &_cogl_winsys_egl_vtable;
|
2016-05-09 13:22:01 +00:00
|
|
|
egl_renderer->platform = renderer_native;
|
2016-05-09 11:51:29 +00:00
|
|
|
egl_renderer->edpy = EGL_NO_DISPLAY;
|
|
|
|
|
2016-05-09 13:22:01 +00:00
|
|
|
if (renderer_native->gbm == NULL)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
|
|
|
_cogl_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_INIT,
|
|
|
|
"Couldn't create gbm device");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2016-05-09 13:22:01 +00:00
|
|
|
egl_renderer->edpy =
|
|
|
|
eglGetDisplay ((EGLNativeDisplayType) renderer_native->gbm);
|
2016-05-09 11:51:29 +00:00
|
|
|
if (egl_renderer->edpy == EGL_NO_DISPLAY)
|
|
|
|
{
|
|
|
|
_cogl_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_INIT,
|
|
|
|
"Couldn't get eglDisplay");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_cogl_winsys_egl_renderer_connect_common (cogl_renderer, error))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
fail:
|
2016-05-27 07:13:09 +00:00
|
|
|
meta_renderer_native_disconnect (cogl_renderer);
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglBool
|
2016-06-01 09:53:07 +00:00
|
|
|
meta_renderer_native_setup_egl_display (CoglDisplay *cogl_display,
|
2016-05-27 07:13:09 +00:00
|
|
|
CoglError **error)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
2016-06-01 09:53:07 +00:00
|
|
|
CoglDisplayEGL *egl_display = cogl_display->winsys;
|
|
|
|
CoglRendererEGL *egl_renderer = cogl_display->renderer->winsys;
|
2016-05-09 13:22:01 +00:00
|
|
|
MetaRendererNative *renderer_native = egl_renderer->platform;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
2016-05-10 02:16:45 +00:00
|
|
|
egl_display->platform = renderer_native;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
/* Force a full modeset / drmModeSetCrtc on
|
|
|
|
* the first swap buffers call.
|
|
|
|
*/
|
2016-06-08 09:05:31 +00:00
|
|
|
meta_renderer_native_queue_modes_reset (renderer_native);
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-06-01 09:53:07 +00:00
|
|
|
meta_renderer_native_destroy_egl_display (CoglDisplay *cogl_display)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglBool
|
2016-06-01 09:53:07 +00:00
|
|
|
meta_renderer_native_egl_context_created (CoglDisplay *cogl_display,
|
2016-05-27 07:13:09 +00:00
|
|
|
CoglError **error)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
2016-06-01 09:53:07 +00:00
|
|
|
CoglDisplayEGL *egl_display = cogl_display->winsys;
|
|
|
|
CoglRenderer *cogl_renderer = cogl_display->renderer;
|
|
|
|
CoglRendererEGL *egl_renderer = cogl_renderer->winsys;
|
2016-05-09 13:22:01 +00:00
|
|
|
MetaRendererNative *renderer_native = egl_renderer->platform;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
if ((egl_renderer->private_features &
|
|
|
|
COGL_EGL_WINSYS_FEATURE_SURFACELESS_CONTEXT) == 0)
|
|
|
|
{
|
2016-05-10 02:16:45 +00:00
|
|
|
renderer_native->dummy_gbm_surface =
|
2016-05-09 13:22:01 +00:00
|
|
|
gbm_surface_create (renderer_native->gbm,
|
2016-05-09 11:51:29 +00:00
|
|
|
16, 16,
|
|
|
|
GBM_FORMAT_XRGB8888,
|
|
|
|
GBM_BO_USE_RENDERING);
|
2016-05-10 02:16:45 +00:00
|
|
|
if (!renderer_native->dummy_gbm_surface)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
|
|
|
_cogl_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_CREATE_CONTEXT,
|
|
|
|
"Failed to create dummy GBM surface");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
egl_display->dummy_surface =
|
|
|
|
eglCreateWindowSurface (egl_renderer->edpy,
|
|
|
|
egl_display->egl_config,
|
|
|
|
(EGLNativeWindowType)
|
2016-05-10 02:16:45 +00:00
|
|
|
renderer_native->dummy_gbm_surface,
|
2016-05-09 11:51:29 +00:00
|
|
|
NULL);
|
|
|
|
if (egl_display->dummy_surface == EGL_NO_SURFACE)
|
|
|
|
{
|
|
|
|
_cogl_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_CREATE_CONTEXT,
|
|
|
|
"Failed to create dummy EGL surface");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-01 09:53:07 +00:00
|
|
|
if (!_cogl_winsys_egl_make_current (cogl_display,
|
2016-05-09 11:51:29 +00:00
|
|
|
egl_display->dummy_surface,
|
|
|
|
egl_display->dummy_surface,
|
|
|
|
egl_display->egl_context))
|
|
|
|
{
|
|
|
|
_cogl_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_CREATE_CONTEXT,
|
|
|
|
"Failed to make context current");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-06-01 09:53:07 +00:00
|
|
|
meta_renderer_native_egl_cleanup_context (CoglDisplay *cogl_display)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
2016-06-01 09:53:07 +00:00
|
|
|
CoglDisplayEGL *egl_display = cogl_display->winsys;
|
|
|
|
CoglRenderer *cogl_renderer = cogl_display->renderer;
|
|
|
|
CoglRendererEGL *egl_renderer = cogl_renderer->winsys;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
if (egl_display->dummy_surface != EGL_NO_SURFACE)
|
|
|
|
{
|
|
|
|
eglDestroySurface (egl_renderer->edpy, egl_display->dummy_surface);
|
|
|
|
egl_display->dummy_surface = EGL_NO_SURFACE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-12 06:55:06 +00:00
|
|
|
static void
|
2016-06-08 09:05:31 +00:00
|
|
|
meta_onscreen_native_swap_drm_fb (CoglOnscreen *onscreen)
|
2016-05-12 06:55:06 +00:00
|
|
|
{
|
2016-06-08 09:05:31 +00:00
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
2016-05-27 07:07:41 +00:00
|
|
|
MetaOnscreenNative *onscreen_native = egl_onscreen->platform;
|
2016-05-12 06:55:06 +00:00
|
|
|
|
|
|
|
free_current_bo (onscreen);
|
|
|
|
|
2016-05-27 07:07:41 +00:00
|
|
|
onscreen_native->current_fb_id = onscreen_native->next_fb_id;
|
|
|
|
onscreen_native->next_fb_id = 0;
|
2016-05-12 06:55:06 +00:00
|
|
|
|
2016-05-27 07:07:41 +00:00
|
|
|
onscreen_native->current_bo = onscreen_native->next_bo;
|
|
|
|
onscreen_native->next_bo = NULL;
|
2016-06-08 09:05:31 +00:00
|
|
|
}
|
2016-05-12 06:55:06 +00:00
|
|
|
|
2016-06-08 09:05:31 +00:00
|
|
|
static void
|
|
|
|
on_crtc_flipped (GClosure *closure,
|
|
|
|
MetaRendererView *view)
|
|
|
|
{
|
|
|
|
ClutterStageView *stage_view = CLUTTER_STAGE_VIEW (view);
|
|
|
|
CoglFramebuffer *framebuffer =
|
|
|
|
clutter_stage_view_get_framebuffer (stage_view);
|
|
|
|
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
|
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
|
|
|
MetaOnscreenNative *onscreen_native = egl_onscreen->platform;
|
|
|
|
|
|
|
|
onscreen_native->pending_flips--;
|
|
|
|
if (onscreen_native->pending_flips == 0)
|
|
|
|
{
|
|
|
|
meta_onscreen_native_queue_swap_notify (onscreen);
|
|
|
|
meta_onscreen_native_swap_drm_fb (onscreen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
flip_closure_destroyed (MetaRendererView *view)
|
|
|
|
{
|
|
|
|
ClutterStageView *stage_view = CLUTTER_STAGE_VIEW (view);
|
|
|
|
CoglFramebuffer *framebuffer =
|
|
|
|
clutter_stage_view_get_framebuffer (stage_view);
|
|
|
|
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
|
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
|
|
|
MetaOnscreenNative *onscreen_native = egl_onscreen->platform;
|
|
|
|
|
|
|
|
if (onscreen_native->next_fb_id)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
|
|
|
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
|
|
|
|
|
|
|
|
drmModeRmFB (renderer_native->kms_fd, onscreen_native->next_fb_id);
|
|
|
|
gbm_surface_release_buffer (onscreen_native->surface,
|
|
|
|
onscreen_native->next_bo);
|
|
|
|
onscreen_native->next_bo = NULL;
|
|
|
|
onscreen_native->next_fb_id = 0;
|
|
|
|
|
|
|
|
meta_onscreen_native_queue_swap_notify (onscreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (view);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_onscreen_native_flip_crtc (MetaOnscreenNative *onscreen_native,
|
|
|
|
GClosure *flip_closure,
|
|
|
|
MetaCRTC *crtc,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
gboolean *fb_in_use)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
|
|
|
MetaMonitorManagerKms *monitor_manager_kms =
|
|
|
|
META_MONITOR_MANAGER_KMS (monitor_manager);
|
|
|
|
|
|
|
|
if (!meta_monitor_manager_kms_is_crtc_active (monitor_manager_kms,
|
|
|
|
crtc))
|
|
|
|
{
|
|
|
|
*fb_in_use = FALSE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (meta_monitor_manager_kms_flip_crtc (monitor_manager_kms,
|
|
|
|
crtc,
|
|
|
|
x, y,
|
|
|
|
onscreen_native->next_fb_id,
|
|
|
|
flip_closure))
|
|
|
|
onscreen_native->pending_flips++;
|
|
|
|
|
|
|
|
*fb_in_use = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_onscreen_native_set_crtc_modes (MetaOnscreenNative *onscreen_native)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
|
|
|
MetaMonitorManagerKms *monitor_manager_kms =
|
|
|
|
META_MONITOR_MANAGER_KMS (monitor_manager);
|
|
|
|
MetaRendererView *view = onscreen_native->view;
|
|
|
|
uint32_t next_fb_id = onscreen_native->next_fb_id;
|
|
|
|
MetaMonitorInfo *monitor_info;
|
|
|
|
|
|
|
|
monitor_info = meta_renderer_view_get_monitor_info (view);
|
|
|
|
if (monitor_info)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < monitor_info->n_outputs; i++)
|
|
|
|
{
|
|
|
|
MetaOutput *output = monitor_info->outputs[i];
|
|
|
|
int x = output->crtc->rect.x - monitor_info->rect.x;
|
|
|
|
int y = output->crtc->rect.y - monitor_info->rect.y;
|
|
|
|
|
|
|
|
meta_monitor_manager_kms_apply_crtc_mode (monitor_manager_kms,
|
|
|
|
output->crtc,
|
|
|
|
x, y,
|
|
|
|
next_fb_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < monitor_manager->n_crtcs; i++)
|
|
|
|
{
|
|
|
|
MetaCRTC *crtc = &monitor_manager->crtcs[i];
|
|
|
|
|
|
|
|
meta_monitor_manager_kms_apply_crtc_mode (monitor_manager_kms,
|
|
|
|
crtc,
|
|
|
|
crtc->rect.x, crtc->rect.y,
|
|
|
|
next_fb_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_onscreen_native_flip_crtcs (CoglOnscreen *onscreen)
|
|
|
|
{
|
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
|
|
|
MetaOnscreenNative *onscreen_native = egl_onscreen->platform;
|
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
|
|
|
MetaRendererView *view = onscreen_native->view;
|
|
|
|
GClosure *flip_closure;
|
|
|
|
MetaMonitorInfo *monitor_info;
|
|
|
|
gboolean fb_in_use = FALSE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a closure that either will be invoked or destructed.
|
|
|
|
* Invoking the closure represents a completed flip. If the closure
|
|
|
|
* is destructed before being invoked, the framebuffer references will be
|
|
|
|
* cleaned up accordingly.
|
|
|
|
*
|
|
|
|
* Each successful flip will each own one reference to the closure, thus keep
|
|
|
|
* it alive until either invoked or destructed. If flipping failed, the
|
|
|
|
* closure will be destructed before this function goes out of scope.
|
|
|
|
*/
|
|
|
|
flip_closure = g_cclosure_new (G_CALLBACK (on_crtc_flipped),
|
|
|
|
g_object_ref (view),
|
|
|
|
(GClosureNotify) flip_closure_destroyed);
|
|
|
|
g_closure_set_marshal (flip_closure, g_cclosure_marshal_generic);
|
|
|
|
|
|
|
|
/* Either flip the CRTC's of the monitor info, if we are drawing just part
|
|
|
|
* of the stage, or all of the CRTC's if we are drawing the whole stage.
|
|
|
|
*/
|
|
|
|
monitor_info = meta_renderer_view_get_monitor_info (view);
|
|
|
|
if (monitor_info)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < monitor_info->n_outputs; i++)
|
|
|
|
{
|
|
|
|
MetaOutput *output = monitor_info->outputs[i];
|
|
|
|
int x = output->crtc->rect.x - monitor_info->rect.x;
|
|
|
|
int y = output->crtc->rect.y - monitor_info->rect.y;
|
|
|
|
|
|
|
|
meta_onscreen_native_flip_crtc (onscreen_native, flip_closure,
|
|
|
|
output->crtc, x, y,
|
|
|
|
&fb_in_use);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < monitor_manager->n_crtcs; i++)
|
|
|
|
{
|
|
|
|
MetaCRTC *crtc = &monitor_manager->crtcs[i];
|
|
|
|
|
|
|
|
meta_onscreen_native_flip_crtc (onscreen_native, flip_closure,
|
|
|
|
crtc, crtc->rect.x, crtc->rect.y,
|
|
|
|
&fb_in_use);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the framebuffer is in use, but we don't have any pending flips it means
|
|
|
|
* that flipping is not supported and we set the next framebuffer directly.
|
|
|
|
* Since we won't receive a flip callback, lets just notify listeners
|
|
|
|
* directly.
|
|
|
|
*/
|
|
|
|
if (fb_in_use && onscreen_native->pending_flips == 0)
|
|
|
|
{
|
|
|
|
meta_onscreen_native_queue_swap_notify (onscreen);
|
|
|
|
meta_onscreen_native_swap_drm_fb (onscreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_closure_unref (flip_closure);
|
2016-05-12 06:55:06 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 11:51:29 +00:00
|
|
|
static void
|
2016-05-27 07:13:09 +00:00
|
|
|
meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
|
|
|
const int *rectangles,
|
|
|
|
int n_rectangles)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
2016-05-12 06:55:06 +00:00
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
|
|
|
MetaMonitorManagerKms *monitor_manager_kms =
|
|
|
|
META_MONITOR_MANAGER_KMS (monitor_manager);
|
2016-06-01 09:53:07 +00:00
|
|
|
CoglContext *cogl_context = COGL_FRAMEBUFFER (onscreen)->context;
|
|
|
|
CoglRenderer *cogl_renderer = cogl_context->display->renderer;
|
|
|
|
CoglRendererEGL *egl_renderer = cogl_renderer->winsys;
|
2016-05-09 13:22:01 +00:00
|
|
|
MetaRendererNative *renderer_native = egl_renderer->platform;
|
2016-05-09 11:51:29 +00:00
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
2016-05-27 07:07:41 +00:00
|
|
|
MetaOnscreenNative *onscreen_native = egl_onscreen->platform;
|
2016-06-08 09:05:31 +00:00
|
|
|
CoglFrameInfo *frame_info;
|
|
|
|
MetaRendererView *view;
|
|
|
|
cairo_rectangle_int_t view_layout;
|
2016-05-09 11:51:29 +00:00
|
|
|
uint32_t handle, stride;
|
2016-06-08 09:05:31 +00:00
|
|
|
|
|
|
|
frame_info = g_queue_peek_tail (&onscreen->pending_frame_infos);
|
|
|
|
frame_info->global_frame_counter = renderer_native->frame_counter;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
/* If we already have a pending swap then block until it completes */
|
2016-05-27 07:07:41 +00:00
|
|
|
while (onscreen_native->next_fb_id != 0)
|
2016-05-12 06:55:06 +00:00
|
|
|
meta_monitor_manager_kms_wait_for_flip (monitor_manager_kms);
|
2016-05-09 11:51:29 +00:00
|
|
|
|
2016-06-08 09:05:31 +00:00
|
|
|
view = onscreen_native->view;
|
|
|
|
clutter_stage_view_get_layout (CLUTTER_STAGE_VIEW (view), &view_layout);
|
|
|
|
|
2016-05-09 11:51:29 +00:00
|
|
|
parent_vtable->onscreen_swap_buffers_with_damage (onscreen,
|
|
|
|
rectangles,
|
|
|
|
n_rectangles);
|
|
|
|
|
|
|
|
/* Now we need to set the CRTC to whatever is the front buffer */
|
2016-05-27 07:07:41 +00:00
|
|
|
onscreen_native->next_bo =
|
|
|
|
gbm_surface_lock_front_buffer (onscreen_native->surface);
|
2016-05-09 11:51:29 +00:00
|
|
|
|
2016-05-27 07:07:41 +00:00
|
|
|
stride = gbm_bo_get_stride (onscreen_native->next_bo);
|
|
|
|
handle = gbm_bo_get_handle (onscreen_native->next_bo).u32;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
2016-05-09 13:22:01 +00:00
|
|
|
if (drmModeAddFB (renderer_native->kms_fd,
|
2016-06-08 09:05:31 +00:00
|
|
|
view_layout.width,
|
|
|
|
view_layout.height,
|
2016-05-09 11:51:29 +00:00
|
|
|
24, /* depth */
|
|
|
|
32, /* bpp */
|
|
|
|
stride,
|
|
|
|
handle,
|
2016-05-27 07:07:41 +00:00
|
|
|
&onscreen_native->next_fb_id))
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
|
|
|
g_warning ("Failed to create new back buffer handle: %m");
|
2016-05-27 07:07:41 +00:00
|
|
|
gbm_surface_release_buffer (onscreen_native->surface,
|
|
|
|
onscreen_native->next_bo);
|
|
|
|
onscreen_native->next_bo = NULL;
|
|
|
|
onscreen_native->next_fb_id = 0;
|
2016-05-09 11:51:29 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If this is the first framebuffer to be presented then we now setup the
|
|
|
|
* crtc modes, else we flip from the previous buffer */
|
2016-06-08 09:05:31 +00:00
|
|
|
if (onscreen_native->pending_set_crtc)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
2016-06-08 09:05:31 +00:00
|
|
|
meta_onscreen_native_set_crtc_modes (onscreen_native);
|
|
|
|
onscreen_native->pending_set_crtc = FALSE;
|
2016-05-09 11:51:29 +00:00
|
|
|
}
|
|
|
|
|
2016-06-08 09:05:31 +00:00
|
|
|
meta_onscreen_native_flip_crtcs (onscreen);
|
2016-05-09 11:51:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static CoglBool
|
2016-06-01 09:53:07 +00:00
|
|
|
meta_renderer_native_init_egl_context (CoglContext *cogl_context,
|
2016-05-27 07:13:09 +00:00
|
|
|
CoglError **error)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
2016-06-01 09:53:07 +00:00
|
|
|
COGL_FLAGS_SET (cogl_context->features,
|
2016-05-09 11:51:29 +00:00
|
|
|
COGL_FEATURE_ID_SWAP_BUFFERS_EVENT, TRUE);
|
|
|
|
/* TODO: remove this deprecated feature */
|
2016-06-01 09:53:07 +00:00
|
|
|
COGL_FLAGS_SET (cogl_context->winsys_features,
|
2016-05-09 11:51:29 +00:00
|
|
|
COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT,
|
|
|
|
TRUE);
|
2016-06-01 09:53:07 +00:00
|
|
|
COGL_FLAGS_SET (cogl_context->winsys_features,
|
2016-05-09 11:51:29 +00:00
|
|
|
COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT,
|
|
|
|
TRUE);
|
2016-06-08 09:05:31 +00:00
|
|
|
COGL_FLAGS_SET (cogl_context->winsys_features,
|
|
|
|
COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
meta_renderer_native_create_surface (MetaRendererNative *renderer_native,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
struct gbm_surface **gbm_surface,
|
|
|
|
EGLSurface *egl_surface,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
|
|
|
CoglContext *cogl_context =
|
|
|
|
clutter_backend_get_cogl_context (clutter_backend);
|
|
|
|
CoglDisplay *cogl_display = cogl_context->display;
|
|
|
|
CoglDisplayEGL *egl_display = cogl_display->winsys;
|
|
|
|
CoglRendererEGL *egl_renderer = cogl_display->renderer->winsys;
|
|
|
|
struct gbm_surface *new_gbm_surface;
|
|
|
|
EGLNativeWindowType egl_native_window;
|
|
|
|
EGLSurface new_egl_surface;
|
|
|
|
|
|
|
|
new_gbm_surface = gbm_surface_create (renderer_native->gbm,
|
|
|
|
width, height,
|
|
|
|
GBM_FORMAT_XRGB8888,
|
|
|
|
GBM_BO_USE_SCANOUT |
|
|
|
|
GBM_BO_USE_RENDERING);
|
|
|
|
|
|
|
|
if (!new_gbm_surface)
|
|
|
|
{
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_CREATE_ONSCREEN,
|
|
|
|
"Failed to allocate surface");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
egl_native_window = (EGLNativeWindowType) new_gbm_surface;
|
|
|
|
new_egl_surface = eglCreateWindowSurface (egl_renderer->edpy,
|
|
|
|
egl_display->egl_config,
|
|
|
|
egl_native_window,
|
|
|
|
NULL);
|
|
|
|
if (new_egl_surface == EGL_NO_SURFACE)
|
|
|
|
{
|
|
|
|
gbm_surface_destroy (new_gbm_surface);
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_CREATE_ONSCREEN,
|
|
|
|
"Failed to allocate surface");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*gbm_surface = new_gbm_surface;
|
|
|
|
*egl_surface = new_egl_surface;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglBool
|
2016-05-27 07:13:09 +00:00
|
|
|
meta_renderer_native_init_onscreen (CoglOnscreen *onscreen,
|
|
|
|
CoglError **error)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
|
|
|
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
2016-06-01 09:53:07 +00:00
|
|
|
CoglContext *cogl_context = framebuffer->context;
|
|
|
|
CoglDisplay *cogl_display = cogl_context->display;
|
|
|
|
CoglDisplayEGL *egl_display = cogl_display->winsys;
|
|
|
|
CoglRenderer *cogl_renderer = cogl_display->renderer;
|
|
|
|
CoglRendererEGL *egl_renderer = cogl_renderer->winsys;
|
2016-05-09 13:22:01 +00:00
|
|
|
MetaRendererNative *renderer_native = egl_renderer->platform;
|
2016-05-09 11:51:29 +00:00
|
|
|
CoglOnscreenEGL *egl_onscreen;
|
2016-05-27 07:07:41 +00:00
|
|
|
MetaOnscreenNative *onscreen_native;
|
2016-06-08 09:05:31 +00:00
|
|
|
int width;
|
|
|
|
int height;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
_COGL_RETURN_VAL_IF_FAIL (egl_display->egl_context, FALSE);
|
|
|
|
|
|
|
|
onscreen->winsys = g_slice_new0 (CoglOnscreenEGL);
|
|
|
|
egl_onscreen = onscreen->winsys;
|
|
|
|
|
2016-05-27 07:07:41 +00:00
|
|
|
onscreen_native = g_slice_new0 (MetaOnscreenNative);
|
|
|
|
egl_onscreen->platform = onscreen_native;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
2016-06-08 09:05:31 +00:00
|
|
|
onscreen_native->pending_set_crtc = TRUE;
|
|
|
|
|
2016-05-09 11:51:29 +00:00
|
|
|
/* If a kms_fd is set then the display width and height
|
|
|
|
* won't be available until meta_renderer_native_set_layout
|
|
|
|
* is called. In that case, defer creating the surface
|
|
|
|
* until then.
|
|
|
|
*/
|
2016-06-08 09:05:31 +00:00
|
|
|
width = cogl_framebuffer_get_width (framebuffer);
|
|
|
|
height = cogl_framebuffer_get_height (framebuffer);
|
|
|
|
if (width == 0 || height == 0)
|
2016-05-09 11:51:29 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2016-07-31 21:47:08 +00:00
|
|
|
return meta_renderer_native_create_surface (renderer_native,
|
|
|
|
width, height,
|
|
|
|
&onscreen_native->surface,
|
|
|
|
&egl_onscreen->egl_surface,
|
|
|
|
error);
|
2016-05-09 11:51:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-05-27 07:13:09 +00:00
|
|
|
meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
|
|
|
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
2016-06-01 09:53:07 +00:00
|
|
|
CoglContext *cogl_context = framebuffer->context;
|
|
|
|
CoglRenderer *cogl_renderer = cogl_context->display->renderer;
|
|
|
|
CoglRendererEGL *egl_renderer = cogl_renderer->winsys;
|
2016-05-09 11:51:29 +00:00
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
2016-05-27 07:07:41 +00:00
|
|
|
MetaOnscreenNative *onscreen_native;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
/* If we never successfully allocated then there's nothing to do */
|
|
|
|
if (egl_onscreen == NULL)
|
|
|
|
return;
|
|
|
|
|
2016-05-27 07:07:41 +00:00
|
|
|
onscreen_native = egl_onscreen->platform;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
/* flip state takes a reference on the onscreen so there should
|
|
|
|
* never be outstanding flips when we reach here. */
|
2016-05-27 07:07:41 +00:00
|
|
|
g_return_if_fail (onscreen_native->next_fb_id == 0);
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
free_current_bo (onscreen);
|
|
|
|
|
|
|
|
if (egl_onscreen->egl_surface != EGL_NO_SURFACE)
|
|
|
|
{
|
|
|
|
eglDestroySurface (egl_renderer->edpy, egl_onscreen->egl_surface);
|
|
|
|
egl_onscreen->egl_surface = EGL_NO_SURFACE;
|
|
|
|
}
|
|
|
|
|
2016-05-27 07:07:41 +00:00
|
|
|
if (onscreen_native->surface)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
2016-05-27 07:07:41 +00:00
|
|
|
gbm_surface_destroy (onscreen_native->surface);
|
|
|
|
onscreen_native->surface = NULL;
|
2016-05-09 11:51:29 +00:00
|
|
|
}
|
|
|
|
|
2016-05-27 07:07:41 +00:00
|
|
|
g_slice_free (MetaOnscreenNative, onscreen_native);
|
2016-05-09 11:51:29 +00:00
|
|
|
g_slice_free (CoglOnscreenEGL, onscreen->winsys);
|
|
|
|
onscreen->winsys = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const CoglWinsysEGLVtable
|
|
|
|
_cogl_winsys_egl_vtable = {
|
2016-05-27 07:13:09 +00:00
|
|
|
.display_setup = meta_renderer_native_setup_egl_display,
|
|
|
|
.display_destroy = meta_renderer_native_destroy_egl_display,
|
|
|
|
.context_created = meta_renderer_native_egl_context_created,
|
|
|
|
.cleanup_context = meta_renderer_native_egl_cleanup_context,
|
|
|
|
.context_init = meta_renderer_native_init_egl_context
|
2016-05-09 11:51:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct gbm_device *
|
|
|
|
meta_renderer_native_get_gbm (MetaRendererNative *renderer_native)
|
|
|
|
{
|
2016-05-09 13:22:01 +00:00
|
|
|
return renderer_native->gbm;
|
2016-05-09 11:51:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
meta_renderer_native_get_kms_fd (MetaRendererNative *renderer_native)
|
|
|
|
{
|
|
|
|
return renderer_native->kms_fd;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_renderer_native_queue_modes_reset (MetaRendererNative *renderer_native)
|
|
|
|
{
|
2016-06-08 09:05:31 +00:00
|
|
|
MetaRenderer *renderer = META_RENDERER (renderer_native);
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = meta_renderer_get_views (renderer); l; l = l->next)
|
|
|
|
{
|
|
|
|
ClutterStageView *stage_view = l->data;
|
|
|
|
CoglFramebuffer *framebuffer =
|
|
|
|
clutter_stage_view_get_framebuffer (stage_view);
|
|
|
|
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
|
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
|
|
|
MetaOnscreenNative *onscreen_native = egl_onscreen->platform;
|
|
|
|
|
|
|
|
onscreen_native->pending_set_crtc = TRUE;
|
|
|
|
}
|
2016-05-09 11:51:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2016-06-08 09:05:31 +00:00
|
|
|
meta_renderer_native_set_legacy_view_size (MetaRendererNative *renderer_native,
|
|
|
|
MetaRendererView *view,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GError **error)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
|
|
|
ClutterBackend *clutter_backend = clutter_get_default_backend ();
|
|
|
|
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
|
|
|
CoglDisplay *cogl_display = cogl_context_get_display (cogl_context);
|
2016-06-08 09:05:31 +00:00
|
|
|
CoglRendererEGL *egl_renderer = cogl_display->renderer->winsys;
|
|
|
|
ClutterStageView *stage_view = CLUTTER_STAGE_VIEW (view);
|
|
|
|
cairo_rectangle_int_t view_layout;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
2016-06-08 09:05:31 +00:00
|
|
|
clutter_stage_view_get_layout (stage_view, &view_layout);
|
|
|
|
|
|
|
|
if (width != view_layout.width || height != view_layout.height)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
2016-07-06 05:17:34 +00:00
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
|
|
|
MetaMonitorManagerKms *monitor_manager_kms =
|
|
|
|
META_MONITOR_MANAGER_KMS (monitor_manager);
|
2016-06-08 09:05:31 +00:00
|
|
|
CoglFramebuffer *framebuffer =
|
|
|
|
clutter_stage_view_get_framebuffer (stage_view);
|
|
|
|
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
|
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
2016-05-27 07:07:41 +00:00
|
|
|
MetaOnscreenNative *onscreen_native = egl_onscreen->platform;
|
2016-07-06 05:17:34 +00:00
|
|
|
CoglDisplayEGL *egl_display = cogl_display->winsys;
|
2016-05-09 11:51:29 +00:00
|
|
|
struct gbm_surface *new_surface;
|
|
|
|
EGLSurface new_egl_surface;
|
2016-07-31 21:51:43 +00:00
|
|
|
cairo_rectangle_int_t view_layout;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
2016-07-06 05:17:34 +00:00
|
|
|
/*
|
|
|
|
* Ensure we don't have any pending flips that will want
|
|
|
|
* to swap the current buffer.
|
|
|
|
*/
|
|
|
|
while (onscreen_native->next_fb_id != 0)
|
|
|
|
meta_monitor_manager_kms_wait_for_flip (monitor_manager_kms);
|
|
|
|
|
2016-05-09 11:51:29 +00:00
|
|
|
/* Need to drop the GBM surface and create a new one */
|
|
|
|
|
2016-06-08 09:05:31 +00:00
|
|
|
if (!meta_renderer_native_create_surface (renderer_native,
|
|
|
|
width, height,
|
|
|
|
&new_surface,
|
|
|
|
&new_egl_surface,
|
|
|
|
error))
|
|
|
|
return FALSE;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
2016-07-06 05:17:34 +00:00
|
|
|
if (egl_onscreen->egl_surface)
|
2016-05-09 11:51:29 +00:00
|
|
|
{
|
2016-07-06 05:17:34 +00:00
|
|
|
_cogl_winsys_egl_make_current (cogl_display,
|
|
|
|
egl_display->dummy_surface,
|
|
|
|
egl_display->dummy_surface,
|
|
|
|
egl_display->egl_context);
|
|
|
|
eglDestroySurface (egl_renderer->edpy,
|
|
|
|
egl_onscreen->egl_surface);
|
2016-05-09 11:51:29 +00:00
|
|
|
}
|
|
|
|
|
2016-07-06 05:17:34 +00:00
|
|
|
/*
|
|
|
|
* Release the current buffer and destroy the associated surface. The
|
|
|
|
* kernel will deal with keeping the actual buffer alive until its no
|
|
|
|
* longer used.
|
|
|
|
*/
|
|
|
|
free_current_bo (onscreen);
|
|
|
|
g_clear_pointer (&onscreen_native->surface, gbm_surface_destroy);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update the active gbm and egl surfaces and make sure they they are
|
|
|
|
* used for drawing the coming frame.
|
|
|
|
*/
|
|
|
|
onscreen_native->surface = new_surface;
|
|
|
|
egl_onscreen->egl_surface = new_egl_surface;
|
|
|
|
_cogl_winsys_egl_make_current (cogl_display,
|
|
|
|
egl_onscreen->egl_surface,
|
|
|
|
egl_onscreen->egl_surface,
|
|
|
|
egl_display->egl_context);
|
|
|
|
|
2016-07-31 21:51:43 +00:00
|
|
|
view_layout = (cairo_rectangle_int_t) {
|
|
|
|
.width = width,
|
|
|
|
.height = height
|
|
|
|
};
|
|
|
|
g_object_set (G_OBJECT (view),
|
|
|
|
"layout", &view_layout,
|
|
|
|
NULL);
|
|
|
|
|
2016-07-06 05:17:34 +00:00
|
|
|
_cogl_framebuffer_winsys_update_size (framebuffer, width, height);
|
2016-05-09 11:51:29 +00:00
|
|
|
}
|
|
|
|
|
2016-06-08 09:05:31 +00:00
|
|
|
meta_renderer_native_queue_modes_reset (renderer_native);
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const CoglWinsysVtable *
|
|
|
|
get_native_cogl_winsys_vtable (void)
|
|
|
|
{
|
|
|
|
static CoglBool vtable_inited = FALSE;
|
|
|
|
static CoglWinsysVtable vtable;
|
|
|
|
|
|
|
|
if (!vtable_inited)
|
|
|
|
{
|
|
|
|
/* The this winsys is a subclass of the EGL winsys so we
|
|
|
|
start by copying its vtable */
|
|
|
|
|
|
|
|
parent_vtable = _cogl_winsys_egl_get_vtable ();
|
|
|
|
vtable = *parent_vtable;
|
|
|
|
|
|
|
|
vtable.id = COGL_WINSYS_ID_CUSTOM;
|
|
|
|
vtable.name = "EGL_KMS";
|
|
|
|
|
2016-05-27 07:13:09 +00:00
|
|
|
vtable.renderer_connect = meta_renderer_native_connect;
|
|
|
|
vtable.renderer_disconnect = meta_renderer_native_disconnect;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
2016-05-27 07:13:09 +00:00
|
|
|
vtable.onscreen_init = meta_renderer_native_init_onscreen;
|
|
|
|
vtable.onscreen_deinit = meta_renderer_native_release_onscreen;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
/* The KMS winsys doesn't support swap region */
|
|
|
|
vtable.onscreen_swap_region = NULL;
|
|
|
|
vtable.onscreen_swap_buffers_with_damage =
|
2016-05-27 07:13:09 +00:00
|
|
|
meta_onscreen_native_swap_buffers_with_damage;
|
2016-05-09 11:51:29 +00:00
|
|
|
|
|
|
|
vtable_inited = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return &vtable;
|
|
|
|
}
|
|
|
|
|
2016-05-09 01:59:54 +00:00
|
|
|
static CoglRenderer *
|
|
|
|
meta_renderer_native_create_cogl_renderer (MetaRenderer *renderer)
|
|
|
|
{
|
|
|
|
CoglRenderer *cogl_renderer;
|
|
|
|
|
|
|
|
cogl_renderer = cogl_renderer_new ();
|
|
|
|
cogl_renderer_set_custom_winsys (cogl_renderer,
|
2016-05-09 11:51:29 +00:00
|
|
|
get_native_cogl_winsys_vtable);
|
2016-05-09 01:59:54 +00:00
|
|
|
|
|
|
|
return cogl_renderer;
|
|
|
|
}
|
|
|
|
|
2016-06-08 09:05:31 +00:00
|
|
|
static void
|
|
|
|
meta_onscreen_native_set_view (CoglOnscreen *onscreen,
|
|
|
|
MetaRendererView *view)
|
|
|
|
{
|
|
|
|
CoglOnscreenEGL *egl_onscreen;
|
|
|
|
MetaOnscreenNative *onscreen_native;
|
|
|
|
|
|
|
|
egl_onscreen = onscreen->winsys;
|
|
|
|
onscreen_native = egl_onscreen->platform;
|
|
|
|
onscreen_native->view = view;
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaRendererView *
|
|
|
|
meta_renderer_native_create_legacy_view (MetaRendererNative *renderer_native)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
|
|
|
CoglOnscreen *onscreen;
|
|
|
|
CoglFramebuffer *framebuffer;
|
|
|
|
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
|
|
|
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
|
|
|
cairo_rectangle_int_t view_layout = { 0 };
|
|
|
|
MetaRendererView *view;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
if (!monitor_manager)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
meta_monitor_manager_get_screen_size (monitor_manager,
|
|
|
|
&view_layout.width,
|
|
|
|
&view_layout.height);
|
|
|
|
|
|
|
|
onscreen = cogl_onscreen_new (cogl_context,
|
|
|
|
view_layout.width,
|
|
|
|
view_layout.height);
|
|
|
|
cogl_onscreen_set_swap_throttled (onscreen,
|
|
|
|
_clutter_get_sync_to_vblank ());
|
|
|
|
|
|
|
|
framebuffer = COGL_FRAMEBUFFER (onscreen);
|
|
|
|
if (!cogl_framebuffer_allocate (framebuffer, &error))
|
|
|
|
meta_fatal ("Failed to allocate onscreen framebuffer: %s\n",
|
|
|
|
error->message);
|
|
|
|
|
|
|
|
view = g_object_new (META_TYPE_RENDERER_VIEW,
|
|
|
|
"layout", &view_layout,
|
|
|
|
"framebuffer", framebuffer,
|
|
|
|
NULL);
|
2016-07-20 18:56:07 +00:00
|
|
|
cogl_object_unref (framebuffer);
|
2016-06-08 09:05:31 +00:00
|
|
|
|
|
|
|
meta_onscreen_native_set_view (onscreen, view);
|
|
|
|
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
|
|
|
static MetaRendererView *
|
|
|
|
meta_renderer_native_create_view (MetaRenderer *renderer,
|
|
|
|
MetaMonitorInfo *monitor_info)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
|
|
|
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
|
|
|
CoglOnscreen *onscreen;
|
|
|
|
CoglFramebuffer *framebuffer;
|
|
|
|
MetaRendererView *view;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
onscreen = cogl_onscreen_new (cogl_context,
|
2016-06-12 16:38:35 +00:00
|
|
|
monitor_info->rect.width,
|
|
|
|
monitor_info->rect.height);
|
2016-06-08 09:05:31 +00:00
|
|
|
cogl_onscreen_set_swap_throttled (onscreen,
|
|
|
|
_clutter_get_sync_to_vblank ());
|
|
|
|
|
|
|
|
framebuffer = COGL_FRAMEBUFFER (onscreen);
|
|
|
|
if (!cogl_framebuffer_allocate (framebuffer, &error))
|
|
|
|
meta_fatal ("Failed to allocate onscreen framebuffer: %s\n",
|
|
|
|
error->message);
|
|
|
|
|
|
|
|
view = g_object_new (META_TYPE_RENDERER_VIEW,
|
2016-06-12 16:38:35 +00:00
|
|
|
"layout", &monitor_info->rect,
|
2016-06-08 09:05:31 +00:00
|
|
|
"framebuffer", framebuffer,
|
|
|
|
"monitor-info", monitor_info,
|
|
|
|
NULL);
|
2016-07-20 18:56:07 +00:00
|
|
|
cogl_object_unref (framebuffer);
|
2016-06-08 09:05:31 +00:00
|
|
|
|
|
|
|
meta_onscreen_native_set_view (onscreen, view);
|
|
|
|
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_renderer_native_finish_frame (MetaRendererNative *renderer_native)
|
|
|
|
{
|
|
|
|
renderer_native->frame_counter++;
|
|
|
|
}
|
|
|
|
|
|
|
|
int64_t
|
|
|
|
meta_renderer_native_get_frame_counter (MetaRendererNative *renderer_native)
|
|
|
|
{
|
|
|
|
return renderer_native->frame_counter;
|
|
|
|
}
|
|
|
|
|
2016-05-07 15:09:59 +00:00
|
|
|
static void
|
|
|
|
meta_renderer_native_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_KMS_FD:
|
|
|
|
g_value_set_int (value, renderer_native->kms_fd);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_renderer_native_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_KMS_FD:
|
|
|
|
renderer_native->kms_fd = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-09 13:22:01 +00:00
|
|
|
static void
|
|
|
|
meta_renderer_native_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (object);
|
|
|
|
|
2016-05-10 02:16:45 +00:00
|
|
|
g_clear_pointer (&renderer_native->dummy_gbm_surface, gbm_surface_destroy);
|
2016-05-09 13:22:01 +00:00
|
|
|
g_clear_pointer (&renderer_native->gbm, gbm_device_destroy);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (meta_renderer_native_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
meta_renderer_native_initable_init (GInitable *initable,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (initable);
|
2016-05-10 02:16:45 +00:00
|
|
|
drmModeRes *resources;
|
2016-05-09 13:22:01 +00:00
|
|
|
|
|
|
|
renderer_native->gbm = gbm_create_device (renderer_native->kms_fd);
|
|
|
|
if (!renderer_native->gbm)
|
|
|
|
{
|
2016-05-10 02:16:45 +00:00
|
|
|
g_set_error (error, G_IO_ERROR,
|
2016-05-09 13:22:01 +00:00
|
|
|
G_IO_ERROR_FAILED,
|
|
|
|
"Failed to create gbm device");
|
2016-05-10 02:16:45 +00:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
resources = drmModeGetResources (renderer_native->kms_fd);
|
|
|
|
if (!resources)
|
|
|
|
{
|
|
|
|
g_set_error (error, G_IO_ERROR,
|
|
|
|
G_IO_ERROR_FAILED,
|
|
|
|
"drmModeGetResources failed");
|
|
|
|
goto err_resources;
|
2016-05-09 13:22:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2016-05-10 02:16:45 +00:00
|
|
|
|
|
|
|
err_resources:
|
|
|
|
g_clear_pointer (&renderer_native->gbm, gbm_device_destroy);
|
|
|
|
|
|
|
|
err:
|
|
|
|
return FALSE;
|
2016-05-09 13:22:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
initable_iface_init (GInitableIface *initable_iface)
|
|
|
|
{
|
|
|
|
initable_iface->init = meta_renderer_native_initable_init;
|
|
|
|
}
|
|
|
|
|
2016-05-07 15:07:46 +00:00
|
|
|
static void
|
|
|
|
meta_renderer_native_init (MetaRendererNative *renderer_native)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_renderer_native_class_init (MetaRendererNativeClass *klass)
|
|
|
|
{
|
2016-05-07 15:09:59 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2016-05-09 01:59:54 +00:00
|
|
|
MetaRendererClass *renderer_class = META_RENDERER_CLASS (klass);
|
2016-05-07 15:09:59 +00:00
|
|
|
|
|
|
|
object_class->get_property = meta_renderer_native_get_property;
|
|
|
|
object_class->set_property = meta_renderer_native_set_property;
|
2016-05-09 13:22:01 +00:00
|
|
|
object_class->finalize = meta_renderer_native_finalize;
|
2016-05-07 15:09:59 +00:00
|
|
|
|
2016-05-09 01:59:54 +00:00
|
|
|
renderer_class->create_cogl_renderer = meta_renderer_native_create_cogl_renderer;
|
2016-06-08 09:05:31 +00:00
|
|
|
renderer_class->create_view = meta_renderer_native_create_view;
|
2016-05-09 01:59:54 +00:00
|
|
|
|
2016-05-07 15:09:59 +00:00
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_KMS_FD,
|
|
|
|
g_param_spec_int ("kms-fd",
|
|
|
|
"KMS fd",
|
|
|
|
"The KMS file descriptor",
|
|
|
|
0, G_MAXINT, 0,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2016-05-07 15:07:46 +00:00
|
|
|
}
|
2016-05-09 13:22:01 +00:00
|
|
|
|
|
|
|
MetaRendererNative *
|
|
|
|
meta_renderer_native_new (int kms_fd,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
MetaRendererNative *renderer_native;
|
|
|
|
|
|
|
|
renderer_native = g_object_new (META_TYPE_RENDERER_NATIVE,
|
|
|
|
"kms-fd", kms_fd,
|
|
|
|
NULL);
|
|
|
|
if (!g_initable_init (G_INITABLE (renderer_native), NULL, error))
|
|
|
|
{
|
|
|
|
g_object_unref (renderer_native);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return renderer_native;
|
|
|
|
}
|