mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 08:30:42 -05:00
8008f0b7b0
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>
169 lines
6.1 KiB
C
169 lines
6.1 KiB
C
/*
|
|
* Clutter.
|
|
*
|
|
* An OpenGL based 'interactive canvas' library.
|
|
*
|
|
* Copyright (C) 2011 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/>.
|
|
*
|
|
* Author:
|
|
* Emmanuele Bassi <ebassi@linux.intel.com>
|
|
*/
|
|
|
|
#ifndef __CLUTTER_PAINT_NODE_PRIVATE_H__
|
|
#define __CLUTTER_PAINT_NODE_PRIVATE_H__
|
|
|
|
#include <glib-object.h>
|
|
#include <json-glib/json-glib.h>
|
|
#include <clutter/clutter-backend.h>
|
|
#include <clutter/clutter-paint-context.h>
|
|
#include <clutter/clutter-paint-node.h>
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
#define CLUTTER_PAINT_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_PAINT_NODE, ClutterPaintNodeClass))
|
|
#define CLUTTER_IS_PAINT_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_PAINT_NODE))
|
|
#define CLUTTER_PAINT_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_PAINT_NODE, ClutterPaintNodeClass))
|
|
|
|
typedef struct _ClutterPaintOperation ClutterPaintOperation;
|
|
|
|
struct _ClutterPaintNode
|
|
{
|
|
GTypeInstance parent_instance;
|
|
|
|
ClutterPaintNode *parent;
|
|
|
|
ClutterPaintNode *first_child;
|
|
ClutterPaintNode *prev_sibling;
|
|
ClutterPaintNode *next_sibling;
|
|
ClutterPaintNode *last_child;
|
|
|
|
GArray *operations;
|
|
|
|
const gchar *name;
|
|
|
|
guint n_children;
|
|
|
|
volatile int ref_count;
|
|
};
|
|
|
|
struct _ClutterPaintNodeClass
|
|
{
|
|
GTypeClass base_class;
|
|
|
|
void (* finalize) (ClutterPaintNode *node);
|
|
|
|
gboolean (* pre_draw) (ClutterPaintNode *node,
|
|
ClutterPaintContext *paint_context);
|
|
void (* draw) (ClutterPaintNode *node,
|
|
ClutterPaintContext *paint_context);
|
|
void (* post_draw) (ClutterPaintNode *node,
|
|
ClutterPaintContext *paint_context);
|
|
|
|
JsonNode*(* serialize) (ClutterPaintNode *node);
|
|
|
|
CoglFramebuffer *(* get_framebuffer) (ClutterPaintNode *node);
|
|
};
|
|
|
|
#define PAINT_OP_INIT { PAINT_OP_INVALID }
|
|
|
|
typedef enum
|
|
{
|
|
PAINT_OP_INVALID = 0,
|
|
PAINT_OP_TEX_RECT,
|
|
PAINT_OP_TEX_RECTS,
|
|
PAINT_OP_MULTITEX_RECT,
|
|
PAINT_OP_PRIMITIVE
|
|
} PaintOpCode;
|
|
|
|
struct _ClutterPaintOperation
|
|
{
|
|
PaintOpCode opcode;
|
|
|
|
GArray *coords;
|
|
|
|
union {
|
|
float texrect[8];
|
|
|
|
CoglPrimitive *primitive;
|
|
} op;
|
|
};
|
|
|
|
GType _clutter_transform_node_get_type (void) G_GNUC_CONST;
|
|
GType _clutter_dummy_node_get_type (void) G_GNUC_CONST;
|
|
|
|
void _clutter_paint_operation_paint_rectangle (const ClutterPaintOperation *op);
|
|
void _clutter_paint_operation_clip_rectangle (const ClutterPaintOperation *op);
|
|
void _clutter_paint_operation_paint_path (const ClutterPaintOperation *op);
|
|
void _clutter_paint_operation_clip_path (const ClutterPaintOperation *op);
|
|
void _clutter_paint_operation_paint_primitive (const ClutterPaintOperation *op);
|
|
|
|
void clutter_paint_node_init_types (ClutterBackend *clutter_backend);
|
|
gpointer _clutter_paint_node_create (GType gtype);
|
|
|
|
ClutterPaintNode * _clutter_transform_node_new (const graphene_matrix_t *matrix);
|
|
ClutterPaintNode * _clutter_dummy_node_new (ClutterActor *actor,
|
|
CoglFramebuffer *framebuffer);
|
|
|
|
void _clutter_paint_node_dump_tree (ClutterPaintNode *root);
|
|
|
|
G_GNUC_INTERNAL
|
|
void clutter_paint_node_remove_child (ClutterPaintNode *node,
|
|
ClutterPaintNode *child);
|
|
G_GNUC_INTERNAL
|
|
void clutter_paint_node_replace_child (ClutterPaintNode *node,
|
|
ClutterPaintNode *old_child,
|
|
ClutterPaintNode *new_child);
|
|
G_GNUC_INTERNAL
|
|
void clutter_paint_node_remove_all (ClutterPaintNode *node);
|
|
|
|
G_GNUC_INTERNAL
|
|
guint clutter_paint_node_get_n_children (ClutterPaintNode *node);
|
|
|
|
G_GNUC_INTERNAL
|
|
ClutterPaintNode * clutter_paint_node_get_first_child (ClutterPaintNode *node);
|
|
G_GNUC_INTERNAL
|
|
ClutterPaintNode * clutter_paint_node_get_previous_sibling (ClutterPaintNode *node);
|
|
G_GNUC_INTERNAL
|
|
ClutterPaintNode * clutter_paint_node_get_next_sibling (ClutterPaintNode *node);
|
|
G_GNUC_INTERNAL
|
|
ClutterPaintNode * clutter_paint_node_get_last_child (ClutterPaintNode *node);
|
|
G_GNUC_INTERNAL
|
|
ClutterPaintNode * clutter_paint_node_get_parent (ClutterPaintNode *node);
|
|
|
|
|
|
#define CLUTTER_TYPE_EFFECT_NODE (clutter_effect_node_get_type ())
|
|
#define CLUTTER_EFFECT_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_EFFECT_NODE, ClutterEffectNode))
|
|
#define CLUTTER_IS_EFFECT_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_EFFECT_NODE))
|
|
|
|
/**
|
|
* ClutterEffectNode:
|
|
*
|
|
* The #ClutterEffectNode structure is an opaque
|
|
* type whose members cannot be directly accessed.
|
|
*/
|
|
typedef struct _ClutterEffectNode ClutterEffectNode;
|
|
typedef struct _ClutterEffectNode ClutterEffectNodeClass;
|
|
|
|
CLUTTER_EXPORT
|
|
GType clutter_effect_node_get_type (void) G_GNUC_CONST;
|
|
|
|
CLUTTER_EXPORT
|
|
ClutterPaintNode * clutter_effect_node_new (ClutterEffect *effect);
|
|
|
|
G_END_DECLS
|
|
|
|
#endif /* __CLUTTER_PAINT_NODE_PRIVATE_H__ */
|