2011-08-26 18:16:12 -04:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010,2011 Intel Corporation.
|
|
|
|
* 2011 Giovanni Campagna <scampa.giovanni@gmail.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
* Authors:
|
|
|
|
* Matthew Allum
|
|
|
|
* Emmanuele Bassi
|
|
|
|
* Robert Bragg
|
|
|
|
* Neil Roberts
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include "clutter-backend-eglnative.h"
|
2011-09-21 13:05:03 -04:00
|
|
|
|
2011-08-26 18:16:12 -04:00
|
|
|
/* This is a Cogl based backend */
|
|
|
|
#include "cogl/clutter-stage-cogl.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_EVDEV
|
2011-12-05 09:01:30 -05:00
|
|
|
#include "evdev/clutter-device-manager-evdev.h"
|
2011-08-26 18:16:12 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "clutter-debug.h"
|
|
|
|
#include "clutter-private.h"
|
|
|
|
#include "clutter-main.h"
|
|
|
|
#include "clutter-stage-private.h"
|
|
|
|
|
|
|
|
#ifdef COGL_HAS_EGL_SUPPORT
|
|
|
|
#include "clutter-egl.h"
|
|
|
|
#endif
|
2011-10-03 07:25:53 -04:00
|
|
|
|
|
|
|
#define clutter_backend_egl_native_get_type _clutter_backend_egl_native_get_type
|
2011-09-21 13:05:03 -04:00
|
|
|
|
2011-11-04 12:52:44 -04:00
|
|
|
G_DEFINE_TYPE (ClutterBackendEglNative, clutter_backend_egl_native, CLUTTER_TYPE_BACKEND);
|
2011-08-26 18:16:12 -04:00
|
|
|
|
|
|
|
static void
|
2011-10-03 07:25:53 -04:00
|
|
|
clutter_backend_egl_native_dispose (GObject *gobject)
|
2011-08-26 18:16:12 -04:00
|
|
|
{
|
|
|
|
ClutterBackendEglNative *backend_egl_native = CLUTTER_BACKEND_EGL_NATIVE (gobject);
|
|
|
|
|
|
|
|
if (backend_egl_native->event_timer != NULL)
|
|
|
|
{
|
|
|
|
g_timer_destroy (backend_egl_native->event_timer);
|
|
|
|
backend_egl_native->event_timer = NULL;
|
|
|
|
}
|
2011-10-03 07:25:53 -04:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (clutter_backend_egl_native_parent_class)->dispose (gobject);
|
2011-08-26 18:16:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-10-03 07:25:53 -04:00
|
|
|
clutter_backend_egl_native_class_init (ClutterBackendEglNativeClass *klass)
|
2011-08-26 18:16:12 -04:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass);
|
|
|
|
|
2011-10-03 07:25:53 -04:00
|
|
|
gobject_class->dispose = clutter_backend_egl_native_dispose;
|
2011-08-26 18:16:12 -04:00
|
|
|
|
2011-11-04 14:27:08 -04:00
|
|
|
backend_class->stage_window_type = CLUTTER_TYPE_STAGE_COGL;
|
2011-08-26 18:16:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-10-03 07:25:53 -04:00
|
|
|
clutter_backend_egl_native_init (ClutterBackendEglNative *backend_egl_native)
|
2011-08-26 18:16:12 -04:00
|
|
|
{
|
|
|
|
backend_egl_native->event_timer = g_timer_new ();
|
|
|
|
}
|
|
|
|
|
2011-10-03 07:25:53 -04:00
|
|
|
/**
|
|
|
|
* clutter_eglx_display:
|
|
|
|
*
|
|
|
|
* Retrieves the EGL display used by Clutter.
|
|
|
|
*
|
|
|
|
* Return value: the EGL display, or 0
|
|
|
|
*
|
|
|
|
* Since: 0.6
|
|
|
|
*
|
|
|
|
* Deprecated: 1.6: Use clutter_egl_get_egl_display() instead.
|
|
|
|
*/
|
|
|
|
EGLDisplay
|
|
|
|
clutter_eglx_display (void)
|
|
|
|
{
|
|
|
|
return clutter_egl_get_egl_display ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_egl_display:
|
|
|
|
*
|
|
|
|
* Retrieves the EGL display used by Clutter.
|
|
|
|
*
|
|
|
|
* Return value: the EGL display used by Clutter, or 0
|
|
|
|
*
|
|
|
|
* Since: 0.6
|
|
|
|
*
|
|
|
|
* Deprecated: 1.6: Use clutter_egl_get_egl_display() instead.
|
|
|
|
*/
|
|
|
|
EGLDisplay
|
|
|
|
clutter_egl_display (void)
|
|
|
|
{
|
|
|
|
return clutter_egl_get_egl_display ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_egl_get_egl_display:
|
|
|
|
*
|
|
|
|
* Retrieves the EGL display used by Clutter, if it supports the
|
|
|
|
* EGL windowing system and if it is running using an EGL backend.
|
|
|
|
*
|
|
|
|
* Return value: the EGL display used by Clutter, or 0
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
|
|
|
EGLDisplay
|
|
|
|
clutter_egl_get_egl_display (void)
|
|
|
|
{
|
|
|
|
ClutterBackend *backend;
|
|
|
|
|
|
|
|
if (!_clutter_context_is_initialized ())
|
|
|
|
{
|
|
|
|
g_critical ("The Clutter backend has not been initialized yet");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
backend = clutter_get_default_backend ();
|
|
|
|
|
|
|
|
if (!CLUTTER_IS_BACKEND_EGL_NATIVE (backend))
|
|
|
|
{
|
|
|
|
g_critical ("The Clutter backend is not an EGL backend");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if COGL_HAS_EGL_SUPPORT
|
|
|
|
return cogl_egl_context_get_egl_display (backend->cogl_context);
|
|
|
|
#else
|
|
|
|
return 0;
|
2011-08-26 18:16:12 -04:00
|
|
|
#endif
|
2011-09-21 13:05:03 -04:00
|
|
|
}
|