4
* An OpenGL based 'interactive canvas' library.
6
* Copyright (C) 2010,2011 Intel Corporation.
7
* 2011 Giovanni Campagna <scampa.giovanni@gmail.com>
9
* This library is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU Lesser General Public
11
* License as published by the Free Software Foundation; either
12
* version 2 of the License, or (at your option) any later version.
14
* This library is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* Lesser General Public License for more details.
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
31
#include <sys/types.h>
38
#include "clutter-backend-eglnative.h"
40
/* This is a Cogl based backend */
41
#include "cogl/clutter-stage-cogl.h"
44
#include "clutter-device-manager-evdev.h"
47
#include "clutter-debug.h"
48
#include "clutter-private.h"
49
#include "clutter-main.h"
50
#include "clutter-stage-private.h"
52
#ifdef COGL_HAS_EGL_SUPPORT
53
#include "clutter-egl.h"
56
#include "clutter-cex100.h"
58
static gdl_plane_id_t gdl_plane = GDL_PLANE_ID_UPP_C;
59
static guint gdl_n_buffers = CLUTTER_CEX100_TRIPLE_BUFFERING;
61
#define clutter_backend_cex100_get_type _clutter_backend_cex100_get_type
63
G_DEFINE_TYPE (ClutterBackendCex100, clutter_backend_cex100, CLUTTER_TYPE_BACKEND);
66
clutter_backend_cex100_dispose (GObject *gobject)
68
ClutterBackendCex100 *backend_cex100 = CLUTTER_BACKEND_CEX100 (gobject);
70
if (backend_cex100->event_timer != NULL)
72
g_timer_destroy (backend_cex100->event_timer);
73
backend_cex100->event_timer = NULL;
76
G_OBJECT_CLASS (clutter_backend_cex100_parent_class)->dispose (gobject);
80
clutter_backend_cex100_get_display (ClutterBackend *backend,
81
CoglRenderer *renderer,
82
CoglSwapChain *swap_chain,
85
CoglOnscreenTemplate *onscreen_template = NULL;
88
swap_chain = cogl_swap_chain_new ();
90
#if defined(COGL_HAS_GDL_SUPPORT)
91
cogl_swap_chain_set_length (swap_chain, gdl_n_buffers);
94
onscreen_template = cogl_onscreen_template_new (swap_chain);
96
/* XXX: I have some doubts that this is a good design.
97
* Conceptually should we be able to check an onscreen_template
98
* without more details about the CoglDisplay configuration?
100
if (!cogl_renderer_check_onscreen_template (renderer,
105
display = cogl_display_new (renderer, onscreen_template);
107
#if defined(COGL_HAS_GDL_SUPPORT)
108
cogl_gdl_display_set_plane (cogl_display, gdl_plane);
115
clutter_backend_cex100_class_init (ClutterBackendCex100Class *klass)
117
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
118
ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass);
120
gobject_class->dispose = clutter_backend_cex100_dispose;
122
backend_class->stage_window_type = CLUTTER_TYPE_STAGE_COGL;
124
backend_class->get_display = clutter_backend_cex100_get_display;
128
clutter_backend_cex100_init (ClutterBackendCex100 *backend_cex100)
130
backend_cex100->event_timer = g_timer_new ();
134
* clutter_cex100_set_plane:
135
* @plane: a GDL plane
137
* Intel CE3100 and CE4100 have several planes (frame buffers) and a
138
* hardware blender to blend the planes togeteher and produce the final
141
* clutter_cex100_set_plane() let's you configure the GDL plane where
142
* the stage will be drawn. By default Clutter will pick UPP_C
143
* (GDL_PLANE_ID_UPP_C).
145
* <note>This function has to be called before clutter_init()</note>
150
clutter_cex100_set_plane (gdl_plane_id_t plane)
152
g_return_if_fail (plane >= GDL_PLANE_ID_UPP_A && plane <= GDL_PLANE_ID_UPP_E);
158
* clutter_cex100_set_buffering_mode:
159
* @mode: a #ClutterCex100BufferingMode
161
* Configure the buffering mode of the underlying GDL plane. The GDL
162
* surface used by Clutter to draw can be backed up by either one or two
163
* back buffers thus being double or triple buffered, respectively.
165
* Clutter defaults to %CLUTTER_CEX100_TRIPLE_BUFFERING.
167
* <note>This function has to be called before clutter_init()</note>
172
clutter_cex100_set_buffering_mode (ClutterCex100BufferingMode mode)
174
g_return_if_fail (mode == CLUTTER_CEX100_DOUBLE_BUFFERING ||
175
mode == CLUTTER_CEX100_TRIPLE_BUFFERING);
177
gdl_n_buffers = mode;
181
* clutter_cex100_get_egl_display:
183
* Retrieves the EGL display used by Clutter, if it supports the
184
* EGL windowing system and if it is running using an EGL backend.
186
* Return value: the EGL display used by Clutter, or 0
191
clutter_cex100_get_egl_display (void)
193
ClutterBackend *backend;
195
if (!_clutter_context_is_initialized ())
197
g_critical ("The Clutter backend has not been initialized yet");
201
backend = clutter_get_default_backend ();
203
if (!CLUTTER_IS_BACKEND_CEX100 (backend))
205
g_critical ("The Clutter backend is not a CEX100 backend");
209
#if COGL_HAS_EGL_SUPPORT
210
return cogl_egl_context_get_egl_display (backend->cogl_context);