
This changes the setup phase of clutter to not be result of calling an init function that sets up a few global singletons, via global singleton setup vfuncs. The way it worked was that mutter first did some initial setup (connecting to the X11 server), then set a "custom backend" setup vfunc global, before calling clutter_init(). During the clutter_init() call, the context and backend was setup by calling the global singleton getters, which implicitly created the backend and context on-demand. This has now changed to mutter explicitly creating a `ClutterContext` (which is actually a `ClutterMainContext`, but with the name shortened to be consistent with `CoglContext` and `MetaContext`), calling it with a backend constructor vfunc and user data pointer. This function now explicitly creates the backend, without having to go via the previously set global vfunc. This changes the behavior of some "get_default()" like functions, which will now fail if called after mutter has shut down, as when it does so, it now destroys the backends and contexts, not only its own, but the clutter ones too. The "ownership" of the clutter backend is also moved to `ClutterContext`, and MetaBackend is changed to fetch it via the clutter context. This also removed the unused option parsing that existed in clutter. In some places, NULL checks for fetching the clutter context, or backend, and fetching the cogl context from the clutter backend, had to be added. The reason for this is that some code that handles EGL contexts attempts to restore the cogl EGL context tracking so that the right EGL context is used by cogl the next time. This makes no sense to do before Cogl and Clutter are even initialized, which was the case. It wasn't noticed because the relevant singletons were initialized on demand via their "getters". Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
138 lines
5.7 KiB
C
138 lines
5.7 KiB
C
/*
|
|
* Clutter.
|
|
*
|
|
* An OpenGL based 'interactive canvas' library.
|
|
*
|
|
* Copyright (C) 2010 Intel Corporation.
|
|
*
|
|
* 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/>.
|
|
*/
|
|
|
|
#ifndef __CLUTTER_BACKEND_PRIVATE_H__
|
|
#define __CLUTTER_BACKEND_PRIVATE_H__
|
|
|
|
#include <clutter/clutter-backend.h>
|
|
#include <clutter/clutter-seat.h>
|
|
#include <clutter/clutter-stage-window.h>
|
|
|
|
#define CLUTTER_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND, ClutterBackendClass))
|
|
#define CLUTTER_IS_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_BACKEND))
|
|
#define CLUTTER_BACKEND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_BACKEND, ClutterBackendClass))
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
typedef struct _ClutterBackendPrivate ClutterBackendPrivate;
|
|
|
|
struct _ClutterBackend
|
|
{
|
|
/*< private >*/
|
|
GObject parent_instance;
|
|
|
|
CoglRenderer *cogl_renderer;
|
|
CoglDisplay *cogl_display;
|
|
CoglContext *cogl_context;
|
|
GSource *cogl_source;
|
|
|
|
CoglOnscreen *dummy_onscreen;
|
|
|
|
cairo_font_options_t *font_options;
|
|
|
|
gchar *font_name;
|
|
|
|
gfloat units_per_em;
|
|
gint32 units_serial;
|
|
|
|
float fallback_resource_scale;
|
|
|
|
ClutterStageWindow *stage_window;
|
|
|
|
ClutterInputMethod *input_method;
|
|
};
|
|
|
|
struct _ClutterBackendClass
|
|
{
|
|
/*< private >*/
|
|
GObjectClass parent_class;
|
|
|
|
/* vfuncs */
|
|
gboolean (* finish_init) (ClutterBackend *backend,
|
|
GError **error);
|
|
ClutterStageWindow * (* create_stage) (ClutterBackend *backend,
|
|
ClutterStage *wrapper,
|
|
GError **error);
|
|
void (* init_features) (ClutterBackend *backend);
|
|
ClutterFeatureFlags (* get_features) (ClutterBackend *backend);
|
|
CoglRenderer * (* get_renderer) (ClutterBackend *backend,
|
|
GError **error);
|
|
CoglDisplay * (* get_display) (ClutterBackend *backend,
|
|
CoglRenderer *renderer,
|
|
CoglSwapChain *swap_chain,
|
|
GError **error);
|
|
gboolean (* create_context) (ClutterBackend *backend,
|
|
GError **error);
|
|
|
|
gboolean (* translate_event) (ClutterBackend *backend,
|
|
gpointer native,
|
|
ClutterEvent *event);
|
|
|
|
ClutterSeat * (* get_default_seat) (ClutterBackend *backend);
|
|
|
|
gboolean (* is_display_server) (ClutterBackend *backend);
|
|
|
|
/* signals */
|
|
void (* resolution_changed) (ClutterBackend *backend);
|
|
void (* font_changed) (ClutterBackend *backend);
|
|
void (* settings_changed) (ClutterBackend *backend);
|
|
};
|
|
|
|
ClutterStageWindow * _clutter_backend_create_stage (ClutterBackend *backend,
|
|
ClutterStage *wrapper,
|
|
GError **error);
|
|
gboolean _clutter_backend_create_context (ClutterBackend *backend,
|
|
GError **error);
|
|
|
|
gboolean _clutter_backend_finish_init (ClutterBackend *backend,
|
|
GError **error);
|
|
|
|
CLUTTER_EXPORT
|
|
gboolean _clutter_backend_translate_event (ClutterBackend *backend,
|
|
gpointer native,
|
|
ClutterEvent *event);
|
|
|
|
ClutterFeatureFlags _clutter_backend_get_features (ClutterBackend *backend);
|
|
|
|
gfloat _clutter_backend_get_units_per_em (ClutterBackend *backend,
|
|
PangoFontDescription *font_desc);
|
|
gint32 _clutter_backend_get_units_serial (ClutterBackend *backend);
|
|
|
|
void clutter_set_allowed_drivers (const char *drivers);
|
|
|
|
CLUTTER_EXPORT
|
|
ClutterStageWindow * clutter_backend_get_stage_window (ClutterBackend *backend);
|
|
|
|
CLUTTER_EXPORT
|
|
void clutter_backend_set_fallback_resource_scale (ClutterBackend *backend,
|
|
float fallback_resource_scale);
|
|
|
|
float clutter_backend_get_fallback_resource_scale (ClutterBackend *backend);
|
|
|
|
gboolean clutter_backend_is_display_server (ClutterBackend *backend);
|
|
|
|
CLUTTER_EXPORT
|
|
void clutter_backend_destroy (ClutterBackend *backend);
|
|
|
|
G_END_DECLS
|
|
|
|
#endif /* __CLUTTER_BACKEND_PRIVATE_H__ */
|