2007-03-22 14:21:59 -04:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
2010-03-01 07:56:10 -05:00
|
|
|
* Authored By:
|
|
|
|
* Matthew Allum <mallum@openedhand.com>
|
|
|
|
* Emmanuele Bassi <ebassi@linux.intel.com>
|
2007-03-22 14:21:59 -04:00
|
|
|
*
|
2010-03-01 07:56:10 -05:00
|
|
|
* Copyright (C) 2006, 2007, 2008 OpenedHand Ltd
|
|
|
|
* Copyright (C) 2009, 2010 Intel Corp
|
2007-03-22 14:21:59 -04:00
|
|
|
*
|
|
|
|
* 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
|
2010-03-01 07:56:10 -05:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2007-03-22 14:21:59 -04:00
|
|
|
*/
|
|
|
|
|
2007-07-04 10:00:41 -04:00
|
|
|
/**
|
|
|
|
* SECTION:clutter-backend
|
|
|
|
* @short_description: Backend abstraction
|
|
|
|
*
|
|
|
|
* Clutter can be compiled against different backends. Each backend
|
|
|
|
* has to implement a set of functions, in order to be used by Clutter.
|
|
|
|
*
|
|
|
|
* #ClutterBackend is the base class abstracting the various implementation;
|
|
|
|
* it provides a basic API to query the backend for generic information
|
|
|
|
* and settings.
|
|
|
|
*
|
|
|
|
* #ClutterBackend is available since Clutter 0.4
|
|
|
|
*/
|
|
|
|
|
2007-10-12 04:17:00 -04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2007-03-22 14:21:59 -04:00
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-10-21 06:49:37 -04:00
|
|
|
#include "clutter-backend-private.h"
|
2008-04-04 11:02:11 -04:00
|
|
|
#include "clutter-debug.h"
|
2011-02-18 11:27:49 -05:00
|
|
|
#include "clutter-event-private.h"
|
2008-12-23 08:55:51 -05:00
|
|
|
#include "clutter-marshal.h"
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
#include "clutter-private.h"
|
2009-03-30 11:41:02 -04:00
|
|
|
#include "clutter-profile.h"
|
2010-10-21 06:29:09 -04:00
|
|
|
#include "clutter-stage-manager-private.h"
|
|
|
|
#include "clutter-stage-private.h"
|
2011-11-03 12:45:56 -04:00
|
|
|
#include "clutter-stage-window.h"
|
2011-02-15 09:46:20 -05:00
|
|
|
#include "clutter-version.h"
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2009-10-21 18:24:49 -04:00
|
|
|
#include <cogl/cogl.h>
|
|
|
|
|
2011-11-03 13:53:54 -04:00
|
|
|
#ifdef CLUTTER_INPUT_X11
|
|
|
|
#include "x11/clutter-backend-x11.h"
|
|
|
|
#endif
|
|
|
|
#ifdef CLUTTER_INPUT_WIN32
|
|
|
|
#include "win32/clutter-backend-win32.h"
|
|
|
|
#endif
|
|
|
|
#ifdef CLUTTER_INPUT_OSX
|
|
|
|
#include "osx/clutter-backend-osx.h"
|
|
|
|
#endif
|
2011-11-03 14:27:09 -04:00
|
|
|
#ifdef CLUTTER_INPUT_GDK
|
|
|
|
#include "gdk/clutter-backend-gdk.h"
|
|
|
|
#endif
|
2011-11-03 13:53:54 -04:00
|
|
|
#ifdef CLUTTER_INPUT_EVDEV
|
|
|
|
#include "evdev/clutter-device-manager-evdev.h"
|
|
|
|
#endif
|
|
|
|
#ifdef CLUTTER_INPUT_TSLIB
|
|
|
|
/* XXX - should probably warn, here */
|
|
|
|
#include "tslib/clutter-event-tslib.h"
|
|
|
|
#endif
|
2011-05-09 17:45:33 -04:00
|
|
|
#ifdef CLUTTER_INPUT_WAYLAND
|
|
|
|
#include "wayland/clutter-device-manager-wayland.h"
|
|
|
|
#endif
|
2011-11-03 13:53:54 -04:00
|
|
|
|
2011-05-13 11:54:11 -04:00
|
|
|
#ifdef HAVE_CLUTTER_WAYLAND_COMPOSITOR
|
|
|
|
#include <wayland-server.h>
|
|
|
|
#endif
|
|
|
|
|
2007-07-24 12:22:29 -04:00
|
|
|
G_DEFINE_ABSTRACT_TYPE (ClutterBackend, clutter_backend, G_TYPE_OBJECT);
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2008-12-23 10:03:11 -05:00
|
|
|
#define DEFAULT_FONT_NAME "Sans 10"
|
|
|
|
|
2007-05-09 19:31:08 -04:00
|
|
|
#define CLUTTER_BACKEND_GET_PRIVATE(obj) \
|
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_BACKEND, ClutterBackendPrivate))
|
|
|
|
|
|
|
|
struct _ClutterBackendPrivate
|
|
|
|
{
|
2010-06-21 10:42:20 -04:00
|
|
|
cairo_font_options_t *font_options;
|
2007-05-09 19:31:08 -04:00
|
|
|
|
2010-06-21 10:42:20 -04:00
|
|
|
gchar *font_name;
|
Remove Units from the public API
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.
ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.
So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:
- we have to maintain twice the amount of entry points in ClutterActor
- we still do an integer-to-float implicit conversion
- we introduce a weird impedance between pixels and "pixels with
fractionary bits"
- language bindings will have to choose what to bind, and resort
to manually overriding the API
+ *except* for language bindings based on GObject-Introspection, as
they cannot do manual overrides, thus will replicate the entire
set of entry points
For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:
void clutter_actor_set_x (ClutterActor *self,
gfloat x);
void clutter_actor_get_size (ClutterActor *self,
gfloat *width,
gfloat *height);
gfloat clutter_actor_get_height (ClutterActor *self);
etc.
The issues I have identified are:
- we'll have a two cases of compiler warnings:
- printf() format of the return values from %d to %f
- clutter_actor_get_size() taking floats instead of unsigned ints
- we'll have a problem with varargs when passing an integer instead
of a floating point value, except on 64bit platforms where the
size of a float is the same as the size of an int
To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:
- we remove ambiguity in the API with regard to pixels and units
- we remove entry points we get to maintain for the whole 1.0
version of the API
- we make things simpler to bind for both manual language bindings
and automatic (gobject-introspection based) ones
- we have the simplest API possible while still exposing the
capabilities of the underlying GL implementation
2009-05-06 11:44:47 -04:00
|
|
|
|
|
|
|
gfloat units_per_em;
|
2009-10-16 10:25:37 -04:00
|
|
|
gint32 units_serial;
|
2011-02-09 07:20:56 -05:00
|
|
|
|
|
|
|
GList *event_translators;
|
2007-05-09 19:31:08 -04:00
|
|
|
};
|
|
|
|
|
2008-12-23 08:55:51 -05:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
RESOLUTION_CHANGED,
|
|
|
|
FONT_CHANGED,
|
2010-06-21 10:42:20 -04:00
|
|
|
SETTINGS_CHANGED,
|
2008-12-23 08:55:51 -05:00
|
|
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint backend_signals[LAST_SIGNAL] = { 0, };
|
|
|
|
|
2011-05-13 11:54:11 -04:00
|
|
|
/* Global for being able to specify a compositor side wayland display
|
|
|
|
* pointer before clutter initialization */
|
|
|
|
#ifdef HAVE_CLUTTER_WAYLAND_COMPOSITOR
|
|
|
|
static struct wl_display *_wayland_compositor_display;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2007-03-23 19:57:24 -04:00
|
|
|
static void
|
|
|
|
clutter_backend_dispose (GObject *gobject)
|
|
|
|
{
|
2011-02-09 07:20:56 -05:00
|
|
|
ClutterBackendPrivate *priv = CLUTTER_BACKEND (gobject)->priv;
|
2007-05-09 19:31:08 -04:00
|
|
|
|
2011-02-09 07:38:10 -05:00
|
|
|
/* clear the events still in the queue of the main context */
|
|
|
|
_clutter_clear_events_queue ();
|
2007-03-23 19:57:24 -04:00
|
|
|
|
2011-02-09 07:38:10 -05:00
|
|
|
/* remove all event translators */
|
2011-02-09 07:20:56 -05:00
|
|
|
if (priv->event_translators != NULL)
|
|
|
|
{
|
|
|
|
g_list_free (priv->event_translators);
|
|
|
|
priv->event_translators = NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-30 10:00:01 -04:00
|
|
|
G_OBJECT_CLASS (clutter_backend_parent_class)->dispose (gobject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_finalize (GObject *gobject)
|
|
|
|
{
|
|
|
|
ClutterBackend *backend = CLUTTER_BACKEND (gobject);
|
2008-12-23 10:03:11 -05:00
|
|
|
|
2011-12-21 10:13:53 -05:00
|
|
|
g_source_destroy (backend->cogl_source);
|
|
|
|
|
2010-06-30 10:00:01 -04:00
|
|
|
g_free (backend->priv->font_name);
|
2010-06-21 10:42:20 -04:00
|
|
|
clutter_backend_set_font_options (backend, NULL);
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
|
2010-06-30 10:00:01 -04:00
|
|
|
G_OBJECT_CLASS (clutter_backend_parent_class)->finalize (gobject);
|
2007-03-23 19:57:24 -04:00
|
|
|
}
|
|
|
|
|
2009-06-02 13:44:30 -04:00
|
|
|
static gfloat
|
2009-05-07 09:16:01 -04:00
|
|
|
get_units_per_em (ClutterBackend *backend,
|
|
|
|
PangoFontDescription *font_desc)
|
2009-01-22 06:37:52 -05:00
|
|
|
{
|
2009-06-02 13:44:30 -04:00
|
|
|
gfloat units_per_em = -1.0;
|
2009-05-07 09:16:01 -04:00
|
|
|
gboolean free_font_desc = FALSE;
|
2009-01-22 06:37:52 -05:00
|
|
|
gdouble dpi;
|
|
|
|
|
|
|
|
dpi = clutter_backend_get_resolution (backend);
|
|
|
|
|
2009-05-07 09:16:01 -04:00
|
|
|
if (font_desc == NULL)
|
2009-01-22 06:37:52 -05:00
|
|
|
{
|
2010-09-10 09:27:37 -04:00
|
|
|
ClutterSettings *settings;
|
|
|
|
gchar *font_name = NULL;
|
|
|
|
|
|
|
|
settings = clutter_settings_get_default ();
|
|
|
|
g_object_get (settings, "font-name", &font_name, NULL);
|
2009-01-22 06:37:52 -05:00
|
|
|
|
2009-05-07 09:16:01 -04:00
|
|
|
if (G_LIKELY (font_name != NULL && *font_name != '\0'))
|
2009-01-22 06:37:52 -05:00
|
|
|
{
|
2009-05-07 09:16:01 -04:00
|
|
|
font_desc = pango_font_description_from_string (font_name);
|
|
|
|
free_font_desc = TRUE;
|
2010-09-10 09:27:37 -04:00
|
|
|
|
|
|
|
g_free (font_name);
|
2009-05-07 09:16:01 -04:00
|
|
|
}
|
|
|
|
}
|
2009-01-22 06:37:52 -05:00
|
|
|
|
2009-05-07 09:16:01 -04:00
|
|
|
if (font_desc != NULL)
|
|
|
|
{
|
|
|
|
gdouble font_size = 0;
|
|
|
|
gint pango_size;
|
|
|
|
gboolean is_absolute;
|
2009-01-22 06:37:52 -05:00
|
|
|
|
2009-05-07 09:16:01 -04:00
|
|
|
pango_size = pango_font_description_get_size (font_desc);
|
|
|
|
is_absolute = pango_font_description_get_size_is_absolute (font_desc);
|
2009-01-22 06:37:52 -05:00
|
|
|
|
2009-05-07 09:16:01 -04:00
|
|
|
/* "absolute" means "device units" (usually, pixels); otherwise,
|
|
|
|
* it means logical units (points)
|
|
|
|
*/
|
|
|
|
if (is_absolute)
|
|
|
|
font_size = (gdouble) pango_size / PANGO_SCALE;
|
|
|
|
else
|
2011-12-05 06:43:48 -05:00
|
|
|
font_size = dpi * ((gdouble) pango_size / PANGO_SCALE) / 72.0f;
|
2009-05-07 09:16:01 -04:00
|
|
|
|
|
|
|
/* 10 points at 96 DPI is 13.3 pixels */
|
2011-12-05 06:43:48 -05:00
|
|
|
units_per_em = (1.2f * font_size) * dpi / 96.0f;
|
2009-01-22 06:37:52 -05:00
|
|
|
}
|
|
|
|
else
|
2009-05-07 09:16:01 -04:00
|
|
|
units_per_em = -1.0f;
|
|
|
|
|
|
|
|
if (free_font_desc)
|
|
|
|
pango_font_description_free (font_desc);
|
|
|
|
|
|
|
|
return units_per_em;
|
2009-01-22 06:37:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_real_resolution_changed (ClutterBackend *backend)
|
|
|
|
{
|
2009-10-16 10:25:37 -04:00
|
|
|
ClutterBackendPrivate *priv = backend->priv;
|
2010-06-21 10:42:20 -04:00
|
|
|
ClutterMainContext *context;
|
|
|
|
ClutterSettings *settings;
|
2011-12-05 06:42:49 -05:00
|
|
|
gdouble resolution;
|
2010-06-21 10:42:20 -04:00
|
|
|
gint dpi;
|
|
|
|
|
|
|
|
settings = clutter_settings_get_default ();
|
|
|
|
g_object_get (settings, "font-dpi", &dpi, NULL);
|
|
|
|
|
2011-12-05 06:42:49 -05:00
|
|
|
if (dpi < 0)
|
|
|
|
resolution = 96.0;
|
|
|
|
else
|
|
|
|
resolution = dpi / 1024.0;
|
|
|
|
|
2011-02-18 12:18:05 -05:00
|
|
|
context = _clutter_context_get_default ();
|
2010-06-21 10:42:20 -04:00
|
|
|
if (context->font_map != NULL)
|
2011-12-05 06:42:49 -05:00
|
|
|
cogl_pango_font_map_set_resolution (context->font_map, resolution);
|
2009-10-16 10:25:37 -04:00
|
|
|
|
|
|
|
priv->units_per_em = get_units_per_em (backend, NULL);
|
|
|
|
priv->units_serial += 1;
|
2009-05-07 09:16:01 -04:00
|
|
|
|
2010-06-21 10:42:20 -04:00
|
|
|
CLUTTER_NOTE (BACKEND, "Units per em: %.2f", priv->units_per_em);
|
2009-01-22 06:37:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_real_font_changed (ClutterBackend *backend)
|
|
|
|
{
|
2009-10-16 10:25:37 -04:00
|
|
|
ClutterBackendPrivate *priv = backend->priv;
|
|
|
|
|
|
|
|
priv->units_per_em = get_units_per_em (backend, NULL);
|
|
|
|
priv->units_serial += 1;
|
2009-05-07 09:16:01 -04:00
|
|
|
|
2010-06-21 10:42:20 -04:00
|
|
|
CLUTTER_NOTE (BACKEND, "Units per em: %.2f", priv->units_per_em);
|
2009-01-22 06:37:52 -05:00
|
|
|
}
|
|
|
|
|
2011-11-04 11:50:47 -04:00
|
|
|
static gboolean
|
|
|
|
clutter_backend_real_create_context (ClutterBackend *backend,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
ClutterBackendClass *klass;
|
|
|
|
CoglSwapChain *swap_chain;
|
|
|
|
GError *internal_error;
|
|
|
|
|
|
|
|
if (backend->cogl_context != NULL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
klass = CLUTTER_BACKEND_GET_CLASS (backend);
|
|
|
|
|
|
|
|
swap_chain = NULL;
|
|
|
|
internal_error = NULL;
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND, "Creating Cogl renderer");
|
|
|
|
if (klass->get_renderer != NULL)
|
|
|
|
backend->cogl_renderer = klass->get_renderer (backend, &internal_error);
|
|
|
|
else
|
|
|
|
backend->cogl_renderer = cogl_renderer_new ();
|
|
|
|
|
|
|
|
if (backend->cogl_renderer == NULL)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND, "Connecting the renderer");
|
|
|
|
if (!cogl_renderer_connect (backend->cogl_renderer, &internal_error))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND, "Creating Cogl swap chain");
|
|
|
|
swap_chain = cogl_swap_chain_new ();
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND, "Creating Cogl display");
|
|
|
|
if (klass->get_display != NULL)
|
|
|
|
{
|
|
|
|
backend->cogl_display = klass->get_display (backend,
|
|
|
|
backend->cogl_renderer,
|
|
|
|
swap_chain,
|
|
|
|
&internal_error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CoglOnscreenTemplate *tmpl;
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
tmpl = cogl_onscreen_template_new (swap_chain);
|
|
|
|
|
|
|
|
/* XXX: I have some doubts that this is a good design.
|
|
|
|
*
|
|
|
|
* Conceptually should we be able to check an onscreen_template
|
|
|
|
* without more details about the CoglDisplay configuration?
|
|
|
|
*/
|
|
|
|
res = cogl_renderer_check_onscreen_template (backend->cogl_renderer,
|
|
|
|
tmpl,
|
|
|
|
&internal_error);
|
|
|
|
|
|
|
|
if (!res)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
backend->cogl_display = cogl_display_new (backend->cogl_renderer, tmpl);
|
|
|
|
|
|
|
|
/* the display owns the template */
|
|
|
|
cogl_object_unref (tmpl);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (backend->cogl_display == NULL)
|
|
|
|
goto error;
|
|
|
|
|
2011-05-13 11:54:11 -04:00
|
|
|
#ifdef HAVE_CLUTTER_WAYLAND_COMPOSITOR
|
|
|
|
cogl_wayland_display_set_compositor_display (backend->cogl_display,
|
|
|
|
_wayland_compositor_display);
|
|
|
|
#endif
|
|
|
|
|
2011-11-04 11:50:47 -04:00
|
|
|
CLUTTER_NOTE (BACKEND, "Setting up the display");
|
|
|
|
if (!cogl_display_setup (backend->cogl_display, &internal_error))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND, "Creating the Cogl context");
|
|
|
|
backend->cogl_context = cogl_context_new (backend->cogl_display, &internal_error);
|
|
|
|
if (backend->cogl_context == NULL)
|
|
|
|
goto error;
|
|
|
|
|
2011-12-21 10:13:53 -05:00
|
|
|
backend->cogl_source = cogl_glib_source_new (backend->cogl_context,
|
|
|
|
G_PRIORITY_DEFAULT);
|
|
|
|
g_source_attach (backend->cogl_source, NULL);
|
|
|
|
|
2011-11-04 11:50:47 -04:00
|
|
|
/* the display owns the renderer and the swap chain */
|
|
|
|
cogl_object_unref (backend->cogl_renderer);
|
|
|
|
cogl_object_unref (swap_chain);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
error:
|
|
|
|
if (backend->cogl_display != NULL)
|
|
|
|
{
|
|
|
|
cogl_object_unref (backend->cogl_display);
|
|
|
|
backend->cogl_display = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (backend->cogl_renderer != NULL)
|
|
|
|
{
|
|
|
|
cogl_object_unref (backend->cogl_renderer);
|
|
|
|
backend->cogl_renderer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (swap_chain != NULL)
|
|
|
|
cogl_object_unref (swap_chain);
|
|
|
|
|
|
|
|
if (internal_error != NULL)
|
|
|
|
g_propagate_error (error, internal_error);
|
|
|
|
else
|
|
|
|
g_set_error_literal (error, CLUTTER_INIT_ERROR,
|
|
|
|
CLUTTER_INIT_ERROR_BACKEND,
|
|
|
|
_("Unable to initialize the Clutter backend"));
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-11-03 12:45:56 -04:00
|
|
|
static void
|
|
|
|
clutter_backend_real_ensure_context (ClutterBackend *backend,
|
|
|
|
ClutterStage *stage)
|
|
|
|
{
|
|
|
|
ClutterStageWindow *stage_impl;
|
|
|
|
CoglFramebuffer *framebuffer;
|
|
|
|
|
|
|
|
if (stage == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
stage_impl = _clutter_stage_get_window (stage);
|
|
|
|
if (stage_impl == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
framebuffer = _clutter_stage_window_get_active_framebuffer (stage_impl);
|
|
|
|
if (framebuffer == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cogl_set_framebuffer (framebuffer);
|
|
|
|
}
|
|
|
|
|
2011-11-04 12:13:04 -04:00
|
|
|
static ClutterFeatureFlags
|
|
|
|
clutter_backend_real_get_features (ClutterBackend *backend)
|
|
|
|
{
|
|
|
|
ClutterFeatureFlags flags = 0;
|
|
|
|
|
|
|
|
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN))
|
|
|
|
{
|
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl supports multiple onscreen framebuffers");
|
|
|
|
flags |= CLUTTER_FEATURE_STAGE_MULTIPLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl only supports one onscreen framebuffer");
|
|
|
|
flags |= CLUTTER_FEATURE_STAGE_STATIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_THROTTLE))
|
|
|
|
{
|
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl supports swap buffers throttling");
|
|
|
|
flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl doesn't support swap buffers throttling");
|
|
|
|
|
|
|
|
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT))
|
|
|
|
{
|
|
|
|
CLUTTER_NOTE (BACKEND, "Cogl supports swap buffers complete events");
|
|
|
|
flags |= CLUTTER_FEATURE_SWAP_EVENTS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
2011-11-04 15:00:49 -04:00
|
|
|
static ClutterStageWindow *
|
|
|
|
clutter_backend_real_create_stage (ClutterBackend *backend,
|
|
|
|
ClutterStage *wrapper,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
ClutterBackendClass *klass;
|
|
|
|
|
|
|
|
if (!clutter_feature_available (CLUTTER_FEATURE_STAGE_MULTIPLE))
|
|
|
|
{
|
|
|
|
ClutterStageManager *manager = clutter_stage_manager_get_default ();
|
|
|
|
|
|
|
|
if (clutter_stage_manager_get_default_stage (manager) != NULL)
|
|
|
|
{
|
|
|
|
g_set_error (error, CLUTTER_INIT_ERROR,
|
|
|
|
CLUTTER_INIT_ERROR_BACKEND,
|
|
|
|
_("The backend of type '%s' does not support "
|
|
|
|
"creating multiple stages"),
|
|
|
|
G_OBJECT_TYPE_NAME (backend));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
klass = CLUTTER_BACKEND_GET_CLASS (backend);
|
|
|
|
g_assert (klass->stage_window_type != G_TYPE_INVALID);
|
|
|
|
|
|
|
|
return g_object_new (klass->stage_window_type,
|
|
|
|
"backend", backend,
|
|
|
|
"wrapper", wrapper,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2011-11-03 13:53:54 -04:00
|
|
|
static void
|
|
|
|
clutter_backend_real_init_events (ClutterBackend *backend)
|
|
|
|
{
|
|
|
|
const char *input_backend = NULL;
|
|
|
|
|
|
|
|
input_backend = g_getenv ("CLUTTER_INPUT_BACKEND");
|
|
|
|
if (input_backend != NULL)
|
|
|
|
input_backend = g_intern_string (input_backend);
|
|
|
|
|
|
|
|
#ifdef CLUTTER_INPUT_OSX
|
|
|
|
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_OSX) &&
|
|
|
|
(input_backend == NULL || input_backend == I_(CLUTTER_INPUT_OSX)))
|
|
|
|
{
|
|
|
|
_clutter_backend_osx_events_init (backend);
|
|
|
|
}
|
2011-11-04 08:21:11 -04:00
|
|
|
else
|
2011-11-03 13:53:54 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CLUTTER_INPUT_WIN32
|
|
|
|
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_WIN32) &&
|
|
|
|
(input_backend == NULL || input_backend == I_(CLUTTER_INPUT_WIN32)))
|
|
|
|
{
|
|
|
|
_clutter_backend_win32_events_init (backend);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2011-11-04 08:21:11 -04:00
|
|
|
#ifdef CLUTTER_INPUT_X11
|
|
|
|
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_X11) &&
|
|
|
|
(input_backend == NULL || input_backend == I_(CLUTTER_INPUT_X11)))
|
|
|
|
{
|
|
|
|
_clutter_backend_x11_events_init (backend);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2011-11-03 13:53:54 -04:00
|
|
|
#ifdef CLUTTER_INPUT_GDK
|
|
|
|
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_GDK) &&
|
|
|
|
(input_backend == NULL || input_backend == I_(CLUTTER_INPUT_GDK)))
|
|
|
|
{
|
|
|
|
_clutter_backend_gdk_events_init (backend);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
#ifdef CLUTTER_INPUT_EVDEV
|
|
|
|
/* Evdev can be used regardless of the windowing system */
|
|
|
|
if (input_backend != NULL &&
|
|
|
|
strcmp (input_backend, CLUTTER_INPUT_EVDEV) == 0)
|
|
|
|
{
|
|
|
|
_clutter_events_evdev_init (backend);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
#ifdef CLUTTER_INPUT_TSLIB
|
|
|
|
/* Tslib can be used regardless of the windowing system */
|
|
|
|
if (input_backend != NULL &&
|
|
|
|
strcmp (input_backend, CLUTTER_INPUT_TSLIB) == 0)
|
|
|
|
{
|
|
|
|
_clutter_events_tslib_init (backend);
|
|
|
|
}
|
|
|
|
else
|
2011-05-09 17:45:33 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CLUTTER_INPUT_WAYLAND
|
|
|
|
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_WAYLAND) &&
|
|
|
|
(input_backend == NULL || input_backend == I_(CLUTTER_INPUT_WAYLAND)))
|
|
|
|
{
|
|
|
|
_clutter_events_wayland_init (backend);
|
|
|
|
}
|
|
|
|
else
|
2011-11-03 13:53:54 -04:00
|
|
|
#endif
|
|
|
|
if (input_backend != NULL)
|
2011-11-03 14:27:09 -04:00
|
|
|
{
|
|
|
|
if (input_backend != I_(CLUTTER_INPUT_NULL))
|
|
|
|
g_error ("Unrecognized input backend '%s'", input_backend);
|
|
|
|
}
|
2011-11-03 13:53:54 -04:00
|
|
|
else
|
|
|
|
g_error ("Unknown input backend");
|
|
|
|
}
|
|
|
|
|
2011-11-04 15:25:54 -04:00
|
|
|
static ClutterDeviceManager *
|
|
|
|
clutter_backend_real_get_device_manager (ClutterBackend *backend)
|
|
|
|
{
|
|
|
|
if (G_UNLIKELY (backend->device_manager == NULL))
|
|
|
|
{
|
|
|
|
g_critical ("No device manager available, expect broken input");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return backend->device_manager;
|
|
|
|
}
|
|
|
|
|
2011-02-09 07:20:56 -05:00
|
|
|
static gboolean
|
|
|
|
clutter_backend_real_translate_event (ClutterBackend *backend,
|
|
|
|
gpointer native,
|
|
|
|
ClutterEvent *event)
|
|
|
|
{
|
|
|
|
ClutterBackendPrivate *priv = backend->priv;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = priv->event_translators;
|
|
|
|
l != NULL;
|
|
|
|
l = l->next)
|
|
|
|
{
|
|
|
|
ClutterEventTranslator *translator = l->data;
|
|
|
|
ClutterTranslateReturn retval;
|
|
|
|
|
|
|
|
retval = _clutter_event_translator_translate_event (translator,
|
|
|
|
native,
|
|
|
|
event);
|
|
|
|
|
|
|
|
if (retval == CLUTTER_TRANSLATE_QUEUE)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (retval == CLUTTER_TRANSLATE_REMOVE)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
static void
|
|
|
|
clutter_backend_class_init (ClutterBackendClass *klass)
|
|
|
|
{
|
2007-03-23 19:57:24 -04:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2007-03-23 19:57:24 -04:00
|
|
|
gobject_class->dispose = clutter_backend_dispose;
|
2010-06-30 10:00:01 -04:00
|
|
|
gobject_class->finalize = clutter_backend_finalize;
|
2007-05-09 19:31:08 -04:00
|
|
|
|
|
|
|
g_type_class_add_private (gobject_class, sizeof (ClutterBackendPrivate));
|
2008-12-23 08:55:51 -05:00
|
|
|
|
2011-11-04 14:26:33 -04:00
|
|
|
klass->stage_window_type = G_TYPE_INVALID;
|
|
|
|
|
2011-06-13 08:27:46 -04:00
|
|
|
/**
|
|
|
|
* ClutterBackend::resolution-changed:
|
|
|
|
* @backend: the #ClutterBackend that emitted the signal
|
|
|
|
*
|
|
|
|
* The ::resolution-changed signal is emitted each time the font
|
|
|
|
* resolutions has been changed through #ClutterSettings.
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
2008-12-23 08:55:51 -05:00
|
|
|
backend_signals[RESOLUTION_CHANGED] =
|
|
|
|
g_signal_new (I_("resolution-changed"),
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
2009-01-22 06:37:52 -05:00
|
|
|
G_SIGNAL_RUN_FIRST,
|
2008-12-23 08:55:51 -05:00
|
|
|
G_STRUCT_OFFSET (ClutterBackendClass, resolution_changed),
|
|
|
|
NULL, NULL,
|
2010-06-11 10:49:46 -04:00
|
|
|
_clutter_marshal_VOID__VOID,
|
2008-12-23 08:55:51 -05:00
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2011-06-13 08:27:46 -04:00
|
|
|
/**
|
|
|
|
* ClutterBackend::font-changed:
|
|
|
|
* @backend: the #ClutterBackend that emitted the signal
|
|
|
|
*
|
|
|
|
* The ::font-changed signal is emitted each time the font options
|
|
|
|
* have been changed through #ClutterSettings.
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
2008-12-23 08:55:51 -05:00
|
|
|
backend_signals[FONT_CHANGED] =
|
|
|
|
g_signal_new (I_("font-changed"),
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
2009-01-22 06:37:52 -05:00
|
|
|
G_SIGNAL_RUN_FIRST,
|
2008-12-23 08:55:51 -05:00
|
|
|
G_STRUCT_OFFSET (ClutterBackendClass, font_changed),
|
|
|
|
NULL, NULL,
|
2010-06-11 10:49:46 -04:00
|
|
|
_clutter_marshal_VOID__VOID,
|
2008-12-23 08:55:51 -05:00
|
|
|
G_TYPE_NONE, 0);
|
2009-01-22 06:37:52 -05:00
|
|
|
|
2011-06-13 08:27:46 -04:00
|
|
|
/**
|
|
|
|
* ClutterBackend::settings-changed:
|
|
|
|
* @backend: the #ClutterBackend that emitted the signal
|
|
|
|
*
|
|
|
|
* The ::settings-changed signal is emitted each time the #ClutterSettings
|
|
|
|
* properties have been changed.
|
|
|
|
*
|
|
|
|
* Since: 1.4
|
|
|
|
*/
|
2010-06-21 10:42:20 -04:00
|
|
|
backend_signals[SETTINGS_CHANGED] =
|
|
|
|
g_signal_new (I_("settings-changed"),
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (ClutterBackendClass, settings_changed),
|
|
|
|
NULL, NULL,
|
|
|
|
_clutter_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2009-01-22 06:37:52 -05:00
|
|
|
klass->resolution_changed = clutter_backend_real_resolution_changed;
|
|
|
|
klass->font_changed = clutter_backend_real_font_changed;
|
2011-11-03 12:45:56 -04:00
|
|
|
|
2011-11-03 13:53:54 -04:00
|
|
|
klass->init_events = clutter_backend_real_init_events;
|
2011-11-04 15:25:54 -04:00
|
|
|
klass->get_device_manager = clutter_backend_real_get_device_manager;
|
2011-02-09 07:20:56 -05:00
|
|
|
klass->translate_event = clutter_backend_real_translate_event;
|
2011-11-04 11:50:47 -04:00
|
|
|
klass->create_context = clutter_backend_real_create_context;
|
2011-11-03 12:45:56 -04:00
|
|
|
klass->ensure_context = clutter_backend_real_ensure_context;
|
2011-11-04 12:13:04 -04:00
|
|
|
klass->get_features = clutter_backend_real_get_features;
|
2011-11-04 15:00:49 -04:00
|
|
|
klass->create_stage = clutter_backend_real_create_stage;
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_init (ClutterBackend *backend)
|
|
|
|
{
|
2007-05-09 19:31:08 -04:00
|
|
|
ClutterBackendPrivate *priv;
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2009-01-22 06:37:52 -05:00
|
|
|
priv = backend->priv = CLUTTER_BACKEND_GET_PRIVATE (backend);
|
|
|
|
|
|
|
|
priv->units_per_em = -1.0;
|
2009-10-16 10:25:37 -04:00
|
|
|
priv->units_serial = 1;
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-03-23 13:55:13 -04:00
|
|
|
_clutter_backend_add_options (ClutterBackend *backend,
|
|
|
|
GOptionGroup *group)
|
2007-03-22 14:21:59 -04:00
|
|
|
{
|
2007-07-09 17:56:06 -04:00
|
|
|
ClutterBackendClass *klass;
|
|
|
|
|
2011-02-18 12:18:05 -05:00
|
|
|
g_assert (CLUTTER_IS_BACKEND (backend));
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2007-07-09 17:56:06 -04:00
|
|
|
klass = CLUTTER_BACKEND_GET_CLASS (backend);
|
|
|
|
if (klass->add_options)
|
2007-07-24 12:22:29 -04:00
|
|
|
klass->add_options (backend, group);
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2007-03-23 13:55:13 -04:00
|
|
|
_clutter_backend_pre_parse (ClutterBackend *backend,
|
|
|
|
GError **error)
|
2007-03-22 14:21:59 -04:00
|
|
|
{
|
|
|
|
ClutterBackendClass *klass;
|
|
|
|
|
2011-02-18 12:18:05 -05:00
|
|
|
g_assert (CLUTTER_IS_BACKEND (backend));
|
2007-03-22 14:21:59 -04:00
|
|
|
|
|
|
|
klass = CLUTTER_BACKEND_GET_CLASS (backend);
|
|
|
|
if (klass->pre_parse)
|
|
|
|
return klass->pre_parse (backend, error);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2007-03-23 13:55:13 -04:00
|
|
|
_clutter_backend_post_parse (ClutterBackend *backend,
|
|
|
|
GError **error)
|
2007-03-22 14:21:59 -04:00
|
|
|
{
|
|
|
|
ClutterBackendClass *klass;
|
|
|
|
|
2011-02-18 12:18:05 -05:00
|
|
|
g_assert (CLUTTER_IS_BACKEND (backend));
|
2007-03-22 14:21:59 -04:00
|
|
|
|
|
|
|
klass = CLUTTER_BACKEND_GET_CLASS (backend);
|
|
|
|
if (klass->post_parse)
|
|
|
|
return klass->post_parse (backend, error);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-08-13 07:34:07 -04:00
|
|
|
ClutterStageWindow *
|
2008-03-28 18:50:55 -04:00
|
|
|
_clutter_backend_create_stage (ClutterBackend *backend,
|
2008-04-04 11:02:11 -04:00
|
|
|
ClutterStage *wrapper,
|
2008-03-28 18:50:55 -04:00
|
|
|
GError **error)
|
2007-03-22 14:21:59 -04:00
|
|
|
{
|
|
|
|
ClutterBackendClass *klass;
|
2009-08-13 07:34:07 -04:00
|
|
|
ClutterStageWindow *stage_window;
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2011-02-18 12:18:05 -05:00
|
|
|
g_assert (CLUTTER_IS_BACKEND (backend));
|
|
|
|
g_assert (CLUTTER_IS_STAGE (wrapper));
|
2007-03-22 14:21:59 -04:00
|
|
|
|
|
|
|
klass = CLUTTER_BACKEND_GET_CLASS (backend);
|
2010-02-09 11:57:14 -05:00
|
|
|
if (klass->create_stage != NULL)
|
2009-08-13 07:34:07 -04:00
|
|
|
stage_window = klass->create_stage (backend, wrapper, error);
|
2010-02-09 11:57:14 -05:00
|
|
|
else
|
|
|
|
stage_window = NULL;
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2010-02-09 13:33:09 -05:00
|
|
|
if (stage_window == NULL)
|
2008-03-28 18:50:55 -04:00
|
|
|
return NULL;
|
|
|
|
|
2009-08-13 07:34:07 -04:00
|
|
|
g_assert (CLUTTER_IS_STAGE_WINDOW (stage_window));
|
2008-04-04 11:02:11 -04:00
|
|
|
|
2009-08-13 07:34:07 -04:00
|
|
|
return stage_window;
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|
2009-05-13 17:21:48 -04:00
|
|
|
gboolean
|
|
|
|
_clutter_backend_create_context (ClutterBackend *backend,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
ClutterBackendClass *klass;
|
|
|
|
|
|
|
|
klass = CLUTTER_BACKEND_GET_CLASS (backend);
|
|
|
|
|
2011-11-04 11:50:47 -04:00
|
|
|
return klass->create_context (backend, error);
|
2009-05-13 17:21:48 -04:00
|
|
|
}
|
|
|
|
|
2009-11-11 08:26:54 -05:00
|
|
|
void
|
|
|
|
_clutter_backend_ensure_context_internal (ClutterBackend *backend,
|
|
|
|
ClutterStage *stage)
|
|
|
|
{
|
|
|
|
ClutterBackendClass *klass = CLUTTER_BACKEND_GET_CLASS (backend);
|
|
|
|
if (G_LIKELY (klass->ensure_context))
|
|
|
|
klass->ensure_context (backend, stage);
|
|
|
|
}
|
|
|
|
|
2008-03-28 18:50:55 -04:00
|
|
|
void
|
2008-04-04 11:02:11 -04:00
|
|
|
_clutter_backend_ensure_context (ClutterBackend *backend,
|
|
|
|
ClutterStage *stage)
|
2008-03-28 18:50:55 -04:00
|
|
|
{
|
|
|
|
static ClutterStage *current_context_stage = NULL;
|
|
|
|
|
2011-02-18 12:18:05 -05:00
|
|
|
g_assert (CLUTTER_IS_BACKEND (backend));
|
|
|
|
g_assert (CLUTTER_IS_STAGE (stage));
|
2008-03-28 18:50:55 -04:00
|
|
|
|
2008-04-04 13:26:26 -04:00
|
|
|
if (current_context_stage != stage || !CLUTTER_ACTOR_IS_REALIZED (stage))
|
2008-03-28 18:50:55 -04:00
|
|
|
{
|
2009-05-11 07:36:55 -04:00
|
|
|
ClutterStage *new_stage = NULL;
|
|
|
|
|
2008-04-04 11:02:11 -04:00
|
|
|
if (!CLUTTER_ACTOR_IS_REALIZED (stage))
|
|
|
|
{
|
2009-05-11 07:36:55 -04:00
|
|
|
new_stage = NULL;
|
|
|
|
|
2011-10-17 05:24:25 -04:00
|
|
|
CLUTTER_NOTE (BACKEND,
|
2009-05-11 07:36:55 -04:00
|
|
|
"Stage [%p] is not realized, unsetting the stage",
|
2009-05-08 12:17:48 -04:00
|
|
|
stage);
|
2008-04-04 11:02:11 -04:00
|
|
|
}
|
2008-04-04 13:26:26 -04:00
|
|
|
else
|
2009-05-11 07:36:55 -04:00
|
|
|
{
|
|
|
|
new_stage = stage;
|
|
|
|
|
2011-10-17 05:24:25 -04:00
|
|
|
CLUTTER_NOTE (BACKEND,
|
2009-05-11 07:36:55 -04:00
|
|
|
"Setting the new stage [%p]",
|
|
|
|
new_stage);
|
|
|
|
}
|
|
|
|
|
2009-10-21 18:24:49 -04:00
|
|
|
/* XXX: Until Cogl becomes fully responsible for backend windows
|
|
|
|
* Clutter need to manually keep it informed of the current window size
|
|
|
|
*
|
|
|
|
* NB: This must be done after we ensure_context above because Cogl
|
|
|
|
* always assumes there is a current GL context.
|
|
|
|
*/
|
2011-06-14 10:50:42 -04:00
|
|
|
if (new_stage != NULL)
|
2009-10-21 18:24:49 -04:00
|
|
|
{
|
|
|
|
float width, height;
|
|
|
|
|
2011-06-14 10:50:42 -04:00
|
|
|
_clutter_backend_ensure_context_internal (backend, new_stage);
|
|
|
|
|
2009-10-21 18:24:49 -04:00
|
|
|
clutter_actor_get_size (CLUTTER_ACTOR (stage), &width, &height);
|
|
|
|
|
2011-02-22 13:25:29 -05:00
|
|
|
cogl_onscreen_clutter_backend_set_size (width, height);
|
2010-09-07 08:10:55 -04:00
|
|
|
|
|
|
|
/* Eventually we will have a separate CoglFramebuffer for
|
|
|
|
* each stage and each one will track private projection
|
|
|
|
* matrix and viewport state, but until then we need to make
|
|
|
|
* sure we update the projection and viewport whenever we
|
|
|
|
* switch between stages.
|
|
|
|
*
|
|
|
|
* This dirty mechanism will ensure they are asserted before
|
2011-06-14 10:50:42 -04:00
|
|
|
* the next paint...
|
|
|
|
*/
|
2010-09-07 08:10:55 -04:00
|
|
|
_clutter_stage_dirty_viewport (stage);
|
|
|
|
_clutter_stage_dirty_projection (stage);
|
2009-10-21 18:24:49 -04:00
|
|
|
}
|
|
|
|
|
2008-04-01 10:04:46 -04:00
|
|
|
/* FIXME: With a NULL stage and thus no active context it may make more
|
|
|
|
* sense to clean the context but then re call with the default stage
|
|
|
|
* so at least there is some kind of context in place (as to avoid
|
2011-06-14 10:50:42 -04:00
|
|
|
* potential issue of GL calls with no context).
|
2008-04-04 13:26:26 -04:00
|
|
|
*/
|
2009-05-11 07:36:55 -04:00
|
|
|
current_context_stage = new_stage;
|
2008-03-28 18:50:55 -04:00
|
|
|
}
|
2008-04-04 13:26:26 -04:00
|
|
|
else
|
2011-10-17 05:24:25 -04:00
|
|
|
CLUTTER_NOTE (BACKEND, "Stage is the same");
|
2008-03-28 18:50:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-16 05:08:30 -04:00
|
|
|
ClutterFeatureFlags
|
|
|
|
_clutter_backend_get_features (ClutterBackend *backend)
|
2007-03-22 14:21:59 -04:00
|
|
|
{
|
|
|
|
ClutterBackendClass *klass;
|
2010-03-17 13:28:20 -04:00
|
|
|
GError *error;
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2011-02-18 12:18:05 -05:00
|
|
|
g_assert (CLUTTER_IS_BACKEND (backend));
|
2007-03-22 14:21:59 -04:00
|
|
|
|
|
|
|
klass = CLUTTER_BACKEND_GET_CLASS (backend);
|
2009-12-03 12:13:44 -05:00
|
|
|
|
|
|
|
/* we need to have a context here; so we create the
|
|
|
|
* GL context first and the ask for features. if the
|
|
|
|
* context already exists this should be a no-op
|
|
|
|
*/
|
2010-03-17 13:28:20 -04:00
|
|
|
error = NULL;
|
2011-02-18 12:18:05 -05:00
|
|
|
if (klass->create_context != NULL)
|
2010-03-17 13:28:20 -04:00
|
|
|
{
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
res = klass->create_context (backend, &error);
|
|
|
|
if (!res)
|
|
|
|
{
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
g_critical ("Unable to create a context: %s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
g_critical ("Unable to create a context: unknown error");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2009-12-03 12:13:44 -05:00
|
|
|
|
2007-05-16 05:08:30 -04:00
|
|
|
if (klass->get_features)
|
|
|
|
return klass->get_features (backend);
|
|
|
|
|
|
|
|
return 0;
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|
2007-03-23 13:55:13 -04:00
|
|
|
void
|
2007-05-09 19:31:08 -04:00
|
|
|
_clutter_backend_init_events (ClutterBackend *backend)
|
2007-03-23 13:55:13 -04:00
|
|
|
{
|
|
|
|
ClutterBackendClass *klass;
|
2007-05-09 19:31:08 -04:00
|
|
|
|
2011-02-18 12:18:05 -05:00
|
|
|
g_assert (CLUTTER_IS_BACKEND (backend));
|
2007-05-09 19:31:08 -04:00
|
|
|
|
2007-03-23 13:55:13 -04:00
|
|
|
klass = CLUTTER_BACKEND_GET_CLASS (backend);
|
2011-11-03 13:53:54 -04:00
|
|
|
klass->init_events (backend);
|
2007-03-23 13:55:13 -04:00
|
|
|
}
|
|
|
|
|
Remove Units from the public API
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.
ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.
So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:
- we have to maintain twice the amount of entry points in ClutterActor
- we still do an integer-to-float implicit conversion
- we introduce a weird impedance between pixels and "pixels with
fractionary bits"
- language bindings will have to choose what to bind, and resort
to manually overriding the API
+ *except* for language bindings based on GObject-Introspection, as
they cannot do manual overrides, thus will replicate the entire
set of entry points
For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:
void clutter_actor_set_x (ClutterActor *self,
gfloat x);
void clutter_actor_get_size (ClutterActor *self,
gfloat *width,
gfloat *height);
gfloat clutter_actor_get_height (ClutterActor *self);
etc.
The issues I have identified are:
- we'll have a two cases of compiler warnings:
- printf() format of the return values from %d to %f
- clutter_actor_get_size() taking floats instead of unsigned ints
- we'll have a problem with varargs when passing an integer instead
of a floating point value, except on 64bit platforms where the
size of a float is the same as the size of an int
To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:
- we remove ambiguity in the API with regard to pixels and units
- we remove entry points we get to maintain for the whole 1.0
version of the API
- we make things simpler to bind for both manual language bindings
and automatic (gobject-introspection based) ones
- we have the simplest API possible while still exposing the
capabilities of the underlying GL implementation
2009-05-06 11:44:47 -04:00
|
|
|
gfloat
|
2009-05-07 09:16:01 -04:00
|
|
|
_clutter_backend_get_units_per_em (ClutterBackend *backend,
|
|
|
|
PangoFontDescription *font_desc)
|
2009-01-22 06:37:52 -05:00
|
|
|
{
|
|
|
|
ClutterBackendPrivate *priv;
|
|
|
|
|
|
|
|
priv = backend->priv;
|
|
|
|
|
2009-05-07 09:16:01 -04:00
|
|
|
/* recompute for the font description, but do not cache the result */
|
|
|
|
if (font_desc != NULL)
|
|
|
|
return get_units_per_em (backend, font_desc);
|
|
|
|
|
|
|
|
if (priv->units_per_em < 0)
|
|
|
|
priv->units_per_em = get_units_per_em (backend, NULL);
|
2009-01-22 06:37:52 -05:00
|
|
|
|
|
|
|
return priv->units_per_em;
|
|
|
|
}
|
2007-05-09 19:31:08 -04:00
|
|
|
|
2010-06-14 13:01:17 -04:00
|
|
|
void
|
2010-09-08 10:15:57 -04:00
|
|
|
_clutter_backend_copy_event_data (ClutterBackend *backend,
|
|
|
|
const ClutterEvent *src,
|
|
|
|
ClutterEvent *dest)
|
2010-06-14 13:01:17 -04:00
|
|
|
{
|
|
|
|
ClutterBackendClass *klass;
|
|
|
|
|
|
|
|
klass = CLUTTER_BACKEND_GET_CLASS (backend);
|
|
|
|
if (klass->copy_event_data != NULL)
|
|
|
|
klass->copy_event_data (backend, src, dest);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_clutter_backend_free_event_data (ClutterBackend *backend,
|
|
|
|
ClutterEvent *event)
|
|
|
|
{
|
|
|
|
ClutterBackendClass *klass;
|
|
|
|
|
|
|
|
klass = CLUTTER_BACKEND_GET_CLASS (backend);
|
|
|
|
if (klass->free_event_data != NULL)
|
|
|
|
klass->free_event_data (backend, event);
|
|
|
|
}
|
|
|
|
|
2007-03-23 13:55:13 -04:00
|
|
|
/**
|
2009-03-16 11:00:55 -04:00
|
|
|
* clutter_get_default_backend:
|
2007-03-23 13:55:13 -04:00
|
|
|
*
|
2009-01-22 06:37:52 -05:00
|
|
|
* Retrieves the default #ClutterBackend used by Clutter. The
|
|
|
|
* #ClutterBackend holds backend-specific configuration options.
|
2007-03-23 13:55:13 -04:00
|
|
|
*
|
2009-02-16 19:25:20 -05:00
|
|
|
* Return value: (transfer none): the default backend. You should
|
|
|
|
* not ref or unref the returned object. Applications should rarely
|
|
|
|
* need to use this.
|
2007-05-09 19:31:08 -04:00
|
|
|
*
|
2007-03-23 13:55:13 -04:00
|
|
|
* Since: 0.4
|
|
|
|
*/
|
|
|
|
ClutterBackend *
|
|
|
|
clutter_get_default_backend (void)
|
|
|
|
{
|
|
|
|
ClutterMainContext *clutter_context;
|
|
|
|
|
2009-06-17 12:59:54 -04:00
|
|
|
clutter_context = _clutter_context_get_default ();
|
2007-03-23 13:55:13 -04:00
|
|
|
|
|
|
|
return clutter_context->backend;
|
|
|
|
}
|
|
|
|
|
2007-04-19 11:25:53 -04:00
|
|
|
/**
|
|
|
|
* clutter_backend_set_double_click_time:
|
|
|
|
* @backend: a #ClutterBackend
|
|
|
|
* @msec: milliseconds between two button press events
|
|
|
|
*
|
|
|
|
* Sets the maximum time between two button press events, used to
|
|
|
|
* verify whether it's a double click event or not.
|
|
|
|
*
|
|
|
|
* Since: 0.4
|
2010-06-21 10:42:20 -04:00
|
|
|
*
|
|
|
|
* Deprecated: 1.4: Use #ClutterSettings:double-click-time instead
|
2007-04-19 11:25:53 -04:00
|
|
|
*/
|
2007-04-19 11:25:34 -04:00
|
|
|
void
|
|
|
|
clutter_backend_set_double_click_time (ClutterBackend *backend,
|
|
|
|
guint msec)
|
|
|
|
{
|
2010-06-21 10:42:20 -04:00
|
|
|
ClutterSettings *settings = clutter_settings_get_default ();
|
2007-04-19 11:25:34 -04:00
|
|
|
|
2010-06-21 10:42:20 -04:00
|
|
|
g_object_set (settings, "double-click-time", msec, NULL);
|
2007-04-19 11:25:34 -04:00
|
|
|
}
|
|
|
|
|
2007-04-19 11:25:53 -04:00
|
|
|
/**
|
|
|
|
* clutter_backend_get_double_click_time:
|
|
|
|
* @backend: a #ClutterBackend
|
|
|
|
*
|
|
|
|
* Gets the maximum time between two button press events, as set
|
|
|
|
* by clutter_backend_set_double_click_time().
|
|
|
|
*
|
|
|
|
* Return value: a time in milliseconds
|
|
|
|
*
|
|
|
|
* Since: 0.4
|
2010-06-21 10:42:20 -04:00
|
|
|
*
|
|
|
|
* Deprecated: 1.4: Use #ClutterSettings:double-click-time instead
|
2007-04-19 11:25:53 -04:00
|
|
|
*/
|
2007-04-19 11:25:34 -04:00
|
|
|
guint
|
|
|
|
clutter_backend_get_double_click_time (ClutterBackend *backend)
|
|
|
|
{
|
2010-06-21 10:42:20 -04:00
|
|
|
ClutterSettings *settings = clutter_settings_get_default ();
|
|
|
|
gint retval;
|
|
|
|
|
|
|
|
g_object_get (settings, "double-click-time", &retval, NULL);
|
2007-04-19 11:25:34 -04:00
|
|
|
|
2010-06-21 10:42:20 -04:00
|
|
|
return retval;
|
2007-04-19 11:25:34 -04:00
|
|
|
}
|
|
|
|
|
2007-04-19 11:25:53 -04:00
|
|
|
/**
|
|
|
|
* clutter_backend_set_double_click_distance:
|
|
|
|
* @backend: a #ClutterBackend
|
|
|
|
* @distance: a distance, in pixels
|
|
|
|
*
|
|
|
|
* Sets the maximum distance used to verify a double click event.
|
|
|
|
*
|
|
|
|
* Since: 0.4
|
2010-06-21 10:42:20 -04:00
|
|
|
*
|
|
|
|
* Deprecated: 1.4: Use #ClutterSettings:double-click-distance instead
|
2007-04-19 11:25:53 -04:00
|
|
|
*/
|
2007-04-19 11:25:34 -04:00
|
|
|
void
|
|
|
|
clutter_backend_set_double_click_distance (ClutterBackend *backend,
|
|
|
|
guint distance)
|
|
|
|
{
|
2010-06-21 10:42:20 -04:00
|
|
|
ClutterSettings *settings = clutter_settings_get_default ();
|
|
|
|
|
|
|
|
g_object_set (settings, "double-click-distance", distance, NULL);
|
2007-04-19 11:25:34 -04:00
|
|
|
}
|
|
|
|
|
2007-04-19 11:25:53 -04:00
|
|
|
/**
|
|
|
|
* clutter_backend_get_double_click_distance:
|
|
|
|
* @backend: a #ClutterBackend
|
|
|
|
*
|
|
|
|
* Retrieves the distance used to verify a double click event
|
|
|
|
*
|
|
|
|
* Return value: a distance, in pixels.
|
|
|
|
*
|
|
|
|
* Since: 0.4
|
2010-06-21 10:42:20 -04:00
|
|
|
*
|
|
|
|
* Deprecated: 1.4: Use #ClutterSettings:double-click-distance instead
|
2007-04-19 11:25:53 -04:00
|
|
|
*/
|
2007-04-19 11:25:34 -04:00
|
|
|
guint
|
|
|
|
clutter_backend_get_double_click_distance (ClutterBackend *backend)
|
|
|
|
{
|
2010-06-21 10:42:20 -04:00
|
|
|
ClutterSettings *settings = clutter_settings_get_default ();
|
|
|
|
gint retval;
|
2007-04-19 11:25:34 -04:00
|
|
|
|
2010-06-21 10:42:20 -04:00
|
|
|
g_object_get (settings, "double-click-distance", &retval, NULL);
|
|
|
|
|
|
|
|
return retval;
|
2007-04-19 11:25:34 -04:00
|
|
|
}
|
2007-07-31 06:38:23 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_backend_set_resolution:
|
|
|
|
* @backend: a #ClutterBackend
|
|
|
|
* @dpi: the resolution in "dots per inch" (Physical inches aren't
|
|
|
|
* actually involved; the terminology is conventional).
|
|
|
|
*
|
|
|
|
* Sets the resolution for font handling on the screen. This is a
|
|
|
|
* scale factor between points specified in a #PangoFontDescription
|
|
|
|
* and cairo units. The default value is 96, meaning that a 10 point
|
|
|
|
* font will be 13 units high. (10 * 96. / 72. = 13.3).
|
|
|
|
*
|
|
|
|
* Applications should never need to call this function.
|
|
|
|
*
|
|
|
|
* Since: 0.4
|
2010-06-21 10:42:20 -04:00
|
|
|
*
|
|
|
|
* Deprecated: Use #ClutterSettings:font-dpi instead
|
2007-07-31 06:38:23 -04:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_backend_set_resolution (ClutterBackend *backend,
|
|
|
|
gdouble dpi)
|
|
|
|
{
|
2010-06-21 10:42:20 -04:00
|
|
|
ClutterSettings *settings;
|
|
|
|
gint resolution;
|
2007-07-31 06:38:23 -04:00
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_BACKEND (backend));
|
|
|
|
|
|
|
|
if (dpi < 0)
|
2010-06-21 10:42:20 -04:00
|
|
|
resolution = -1;
|
|
|
|
else
|
|
|
|
resolution = dpi * 1024;
|
2008-12-23 08:55:51 -05:00
|
|
|
|
2010-06-21 10:42:20 -04:00
|
|
|
settings = clutter_settings_get_default ();
|
|
|
|
g_object_set (settings, "font-dpi", resolution, NULL);
|
2007-07-31 06:38:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_backend_get_resolution:
|
|
|
|
* @backend: a #ClutterBackend
|
|
|
|
*
|
2010-06-21 13:01:57 -04:00
|
|
|
* Gets the resolution for font handling on the screen.
|
|
|
|
*
|
|
|
|
* The resolution is a scale factor between points specified in a
|
|
|
|
* #PangoFontDescription and cairo units. The default value is 96.0,
|
|
|
|
* meaning that a 10 point font will be 13 units
|
|
|
|
* high (10 * 96. / 72. = 13.3).
|
|
|
|
*
|
|
|
|
* Clutter will set the resolution using the current backend when
|
|
|
|
* initializing; the resolution is also stored in the
|
|
|
|
* #ClutterSettings:font-dpi property.
|
|
|
|
*
|
2007-07-31 06:38:23 -04:00
|
|
|
* Return value: the current resolution, or -1 if no resolution
|
|
|
|
* has been set.
|
|
|
|
*
|
|
|
|
* Since: 0.4
|
|
|
|
*/
|
|
|
|
gdouble
|
|
|
|
clutter_backend_get_resolution (ClutterBackend *backend)
|
|
|
|
{
|
2010-06-21 10:42:20 -04:00
|
|
|
ClutterSettings *settings;
|
|
|
|
gint resolution;
|
|
|
|
|
2007-07-31 06:38:23 -04:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), -1.0);
|
|
|
|
|
2010-06-21 10:42:20 -04:00
|
|
|
settings = clutter_settings_get_default ();
|
|
|
|
g_object_get (settings, "font-dpi", &resolution, NULL);
|
|
|
|
|
2011-12-05 06:42:49 -05:00
|
|
|
if (resolution < 0)
|
|
|
|
return 96.0;
|
|
|
|
|
2010-06-21 10:42:20 -04:00
|
|
|
return resolution / 1024.0;
|
2007-07-31 06:38:23 -04:00
|
|
|
}
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
|
2008-06-12 07:43:25 -04:00
|
|
|
/**
|
|
|
|
* clutter_backend_set_font_options:
|
|
|
|
* @backend: a #ClutterBackend
|
|
|
|
* @options: Cairo font options for the backend, or %NULL
|
|
|
|
*
|
2009-02-26 10:32:48 -05:00
|
|
|
* Sets the new font options for @backend. The #ClutterBackend will
|
|
|
|
* copy the #cairo_font_options_t.
|
|
|
|
*
|
|
|
|
* If @options is %NULL, the first following call to
|
|
|
|
* clutter_backend_get_font_options() will return the default font
|
|
|
|
* options for @backend.
|
2008-06-12 07:43:25 -04:00
|
|
|
*
|
|
|
|
* This function is intended for actors creating a Pango layout
|
|
|
|
* using the PangoCairo API.
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
void
|
2010-06-21 10:42:20 -04:00
|
|
|
clutter_backend_set_font_options (ClutterBackend *backend,
|
2009-02-26 10:32:48 -05:00
|
|
|
const cairo_font_options_t *options)
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
{
|
|
|
|
ClutterBackendPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_BACKEND (backend));
|
|
|
|
|
|
|
|
priv = backend->priv;
|
|
|
|
|
|
|
|
if (priv->font_options != options)
|
|
|
|
{
|
|
|
|
if (priv->font_options)
|
|
|
|
cairo_font_options_destroy (priv->font_options);
|
|
|
|
|
|
|
|
if (options)
|
|
|
|
priv->font_options = cairo_font_options_copy (options);
|
|
|
|
else
|
|
|
|
priv->font_options = NULL;
|
2008-12-23 08:55:51 -05:00
|
|
|
|
|
|
|
g_signal_emit (backend, backend_signals[FONT_CHANGED], 0);
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-12 07:43:25 -04:00
|
|
|
/**
|
|
|
|
* clutter_backend_get_font_options:
|
|
|
|
* @backend: a #ClutterBackend
|
|
|
|
*
|
|
|
|
* Retrieves the font options for @backend.
|
|
|
|
*
|
2009-02-26 10:32:48 -05:00
|
|
|
* Return value: (transfer none): the font options of the #ClutterBackend.
|
|
|
|
* The returned #cairo_font_options_t is owned by the backend and should
|
|
|
|
* not be modified or freed
|
2008-06-12 07:43:25 -04:00
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
2009-02-26 10:32:48 -05:00
|
|
|
const cairo_font_options_t *
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
clutter_backend_get_font_options (ClutterBackend *backend)
|
|
|
|
{
|
|
|
|
ClutterBackendPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), NULL);
|
|
|
|
|
|
|
|
priv = backend->priv;
|
|
|
|
|
|
|
|
if (G_LIKELY (priv->font_options))
|
|
|
|
return priv->font_options;
|
|
|
|
|
|
|
|
priv->font_options = cairo_font_options_create ();
|
|
|
|
|
|
|
|
cairo_font_options_set_hint_style (priv->font_options,
|
|
|
|
CAIRO_HINT_STYLE_NONE);
|
|
|
|
cairo_font_options_set_subpixel_order (priv->font_options,
|
|
|
|
CAIRO_SUBPIXEL_ORDER_DEFAULT);
|
|
|
|
cairo_font_options_set_antialias (priv->font_options,
|
|
|
|
CAIRO_ANTIALIAS_DEFAULT);
|
|
|
|
|
2009-05-07 09:16:01 -04:00
|
|
|
g_signal_emit (backend, backend_signals[FONT_CHANGED], 0);
|
|
|
|
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
return priv->font_options;
|
|
|
|
}
|
2008-06-25 09:05:59 -04:00
|
|
|
|
2008-12-23 11:59:14 -05:00
|
|
|
/**
|
|
|
|
* clutter_backend_set_font_name:
|
|
|
|
* @backend: a #ClutterBackend
|
|
|
|
* @font_name: the name of the font
|
|
|
|
*
|
|
|
|
* Sets the default font to be used by Clutter. The @font_name string
|
|
|
|
* must either be %NULL, which means that the font name from the
|
|
|
|
* default #ClutterBackend will be used; or be something that can
|
|
|
|
* be parsed by the pango_font_description_from_string() function.
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
2010-06-21 10:42:20 -04:00
|
|
|
*
|
|
|
|
* Deprecated: 1.4: Use #ClutterSettings:font-name instead
|
2008-12-23 11:59:14 -05:00
|
|
|
*/
|
2008-12-23 10:03:11 -05:00
|
|
|
void
|
|
|
|
clutter_backend_set_font_name (ClutterBackend *backend,
|
|
|
|
const gchar *font_name)
|
|
|
|
{
|
2010-06-21 10:42:20 -04:00
|
|
|
ClutterSettings *settings = clutter_settings_get_default ();
|
2008-12-23 10:03:11 -05:00
|
|
|
|
2010-06-21 10:42:20 -04:00
|
|
|
g_object_set (settings, "font-name", font_name, NULL);
|
2008-12-23 10:03:11 -05:00
|
|
|
}
|
|
|
|
|
2008-12-23 11:59:14 -05:00
|
|
|
/**
|
|
|
|
* clutter_backend_get_font_name:
|
|
|
|
* @backend: a #ClutterBackend
|
|
|
|
*
|
|
|
|
* Retrieves the default font name as set by
|
|
|
|
* clutter_backend_set_font_name().
|
|
|
|
*
|
|
|
|
* Return value: the font name for the backend. The returned string is
|
|
|
|
* owned by the #ClutterBackend and should never be modified or freed
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
2010-06-21 10:42:20 -04:00
|
|
|
*
|
|
|
|
* Deprecated: 1.4: Use #ClutterSettings:font-name instead
|
2008-12-23 11:59:14 -05:00
|
|
|
*/
|
Eliminate G_CONST_RETURN
The G_CONST_RETURN define in GLib is, and has always been, a bit fuzzy.
We always used it to conform to the platform, at least for public-facing
API.
At first I assumed it has something to do with brain-damaged compilers
or with weird platforms where const was not really supported; sadly,
it's something much, much worse: it's a define that can be toggled at
compile-time to remove const from the signature of public API. This is a
truly terrifying feature that I assume was added in the past century,
and whose inception clearly had something to do with massive doses of
absynthe and opium — because any other explanation would make the
existence of such a feature even worse than assuming drugs had anything
to do with it.
Anyway, and pleasing the gods, this dubious feature is being
removed/deprecated in GLib; see bug:
https://bugzilla.gnome.org/show_bug.cgi?id=644611
Before deprecation, though, we should just remove its usage from the
whole API. We should especially remove its usage from Cally's internals,
since there it never made sense in the first place.
2011-06-07 10:49:20 -04:00
|
|
|
const gchar *
|
2008-12-23 10:03:11 -05:00
|
|
|
clutter_backend_get_font_name (ClutterBackend *backend)
|
|
|
|
{
|
2008-12-23 11:27:54 -05:00
|
|
|
ClutterBackendPrivate *priv;
|
2010-06-21 10:42:20 -04:00
|
|
|
ClutterSettings *settings;
|
2008-12-23 11:27:54 -05:00
|
|
|
|
2008-12-23 10:03:11 -05:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), NULL);
|
|
|
|
|
2008-12-23 11:27:54 -05:00
|
|
|
priv = backend->priv;
|
|
|
|
|
2010-06-21 10:42:20 -04:00
|
|
|
settings = clutter_settings_get_default ();
|
2008-12-23 11:27:54 -05:00
|
|
|
|
2010-06-21 10:42:20 -04:00
|
|
|
/* XXX yuck. but we return a const pointer, so we need to
|
|
|
|
* store it in the backend
|
2009-05-07 09:16:01 -04:00
|
|
|
*/
|
2010-06-21 10:42:20 -04:00
|
|
|
g_free (priv->font_name);
|
|
|
|
g_object_get (settings, "font-name", &priv->font_name, NULL);
|
2008-12-23 11:27:54 -05:00
|
|
|
|
|
|
|
return priv->font_name;
|
2008-12-23 10:03:11 -05:00
|
|
|
}
|
2009-10-16 10:25:37 -04:00
|
|
|
|
|
|
|
gint32
|
|
|
|
_clutter_backend_get_units_serial (ClutterBackend *backend)
|
|
|
|
{
|
|
|
|
return backend->priv->units_serial;
|
|
|
|
}
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 07:32:04 -05:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
_clutter_backend_translate_event (ClutterBackend *backend,
|
|
|
|
gpointer native,
|
|
|
|
ClutterEvent *event)
|
|
|
|
{
|
|
|
|
return CLUTTER_BACKEND_GET_CLASS (backend)->translate_event (backend,
|
|
|
|
native,
|
|
|
|
event);
|
|
|
|
}
|
2011-02-09 07:20:56 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
_clutter_backend_add_event_translator (ClutterBackend *backend,
|
|
|
|
ClutterEventTranslator *translator)
|
|
|
|
{
|
|
|
|
ClutterBackendPrivate *priv = backend->priv;
|
|
|
|
|
|
|
|
if (g_list_find (priv->event_translators, translator) != NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
priv->event_translators =
|
|
|
|
g_list_prepend (priv->event_translators, translator);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_clutter_backend_remove_event_translator (ClutterBackend *backend,
|
|
|
|
ClutterEventTranslator *translator)
|
|
|
|
{
|
|
|
|
ClutterBackendPrivate *priv = backend->priv;
|
|
|
|
|
|
|
|
if (g_list_find (priv->event_translators, translator) == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
priv->event_translators =
|
|
|
|
g_list_remove (priv->event_translators, translator);
|
|
|
|
}
|
2011-08-12 11:25:53 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_backend_get_cogl_context:
|
|
|
|
* @backend: a #ClutterBackend
|
|
|
|
*
|
|
|
|
* Retrieves the #CoglContext associated with the given clutter
|
|
|
|
* @backend. A #CoglContext is required when using some of the
|
|
|
|
* experimental 2.0 Cogl API.
|
|
|
|
*
|
|
|
|
* <note>Since CoglContext is itself experimental API this API should
|
|
|
|
* be considered experimental too.</note>
|
|
|
|
*
|
|
|
|
* <note>This API is not yet supported on OSX because OSX still
|
|
|
|
* uses the stub Cogl winsys and the Clutter backend doesn't
|
|
|
|
* explicitly create a CoglContext.</note>
|
|
|
|
*
|
|
|
|
* Return value: The #CoglContext associated with @backend.
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
* Stability: unstable
|
|
|
|
*/
|
|
|
|
CoglContext *
|
|
|
|
clutter_backend_get_cogl_context (ClutterBackend *backend)
|
|
|
|
{
|
|
|
|
return backend->cogl_context;
|
|
|
|
}
|
2011-05-13 11:54:11 -04:00
|
|
|
|
|
|
|
#ifdef HAVE_CLUTTER_WAYLAND_COMPOSITOR
|
|
|
|
/**
|
|
|
|
* clutter_wayland_set_compositor_display:
|
|
|
|
* @display: A compositor side struct wl_display pointer
|
|
|
|
*
|
|
|
|
* This informs Clutter of your compositor side Wayland display
|
|
|
|
* object. This must be called before calling clutter_init().
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
* Stability: unstable
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_wayland_set_compositor_display (struct wl_display *display)
|
|
|
|
{
|
|
|
|
if (_clutter_context_is_initialized ())
|
|
|
|
{
|
|
|
|
g_warning ("%s() can only be used before calling clutter_init()",
|
|
|
|
G_STRFUNC);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_wayland_compositor_display = display;
|
|
|
|
}
|
|
|
|
#endif
|