clutter: Add color manager type
This type is intended to carry color related state that is "global", without having to add more and more things to ClutterContext. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3897>
This commit is contained in:
parent
f78948a1de
commit
cd2bf776b1
6 changed files with 159 additions and 0 deletions
115
clutter/clutter/clutter-color-manager.c
Normal file
115
clutter/clutter/clutter-color-manager.c
Normal file
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2024 Red Hat
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "clutter/clutter-color-manager.h"
|
||||
|
||||
#include "clutter/clutter-context.h"
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_CONTEXT,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec *obj_props[N_PROPS];
|
||||
|
||||
struct _ClutterColorManager
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
ClutterContext *context;
|
||||
};
|
||||
|
||||
G_DEFINE_FINAL_TYPE (ClutterColorManager, clutter_color_manager, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
clutter_color_manager_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterColorManager *color_manager = CLUTTER_COLOR_MANAGER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CONTEXT:
|
||||
color_manager->context = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_color_manager_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterColorManager *color_manager = CLUTTER_COLOR_MANAGER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CONTEXT:
|
||||
g_value_set_object (value, color_manager->context);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_color_manager_class_init (ClutterColorManagerClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->set_property = clutter_color_manager_set_property;
|
||||
object_class->get_property = clutter_color_manager_get_property;
|
||||
|
||||
/**
|
||||
* ClutterColorManager:context:
|
||||
*
|
||||
* The associated ClutterContext.
|
||||
*/
|
||||
obj_props[PROP_CONTEXT] =
|
||||
g_param_spec_object ("context", NULL, NULL,
|
||||
CLUTTER_TYPE_CONTEXT,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS |
|
||||
G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, obj_props);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_color_manager_init (ClutterColorManager *color_manager)
|
||||
{
|
||||
}
|
34
clutter/clutter/clutter-color-manager.h
Normal file
34
clutter/clutter/clutter-color-manager.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2024 Red Hat
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
#error "Only <clutter/clutter.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include "clutter/clutter-types.h"
|
||||
|
||||
#define CLUTTER_TYPE_COLOR_MANAGER (clutter_color_manager_get_type ())
|
||||
CLUTTER_EXPORT
|
||||
G_DECLARE_FINAL_TYPE (ClutterColorManager, clutter_color_manager,
|
||||
CLUTTER, COLOR_MANAGER, GObject)
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "cally/cally.h"
|
||||
#include "clutter/clutter-backend-private.h"
|
||||
#include "clutter/clutter-color-manager.h"
|
||||
#include "clutter/clutter-debug.h"
|
||||
#include "clutter/clutter-main.h"
|
||||
#include "clutter/clutter-private.h"
|
||||
|
@ -80,6 +81,7 @@ typedef struct _ClutterContextPrivate
|
|||
{
|
||||
ClutterTextDirection text_direction;
|
||||
|
||||
ClutterColorManager *color_manager;
|
||||
ClutterPipelineCache *pipeline_cache;
|
||||
} ClutterContextPrivate;
|
||||
|
||||
|
@ -92,6 +94,7 @@ clutter_context_dispose (GObject *object)
|
|||
ClutterContextPrivate *priv = clutter_context_get_instance_private (context);
|
||||
|
||||
g_clear_object (&priv->pipeline_cache);
|
||||
g_clear_object (&priv->color_manager);
|
||||
g_clear_pointer (&context->events_queue, g_async_queue_unref);
|
||||
g_clear_pointer (&context->backend, clutter_backend_destroy);
|
||||
|
||||
|
@ -274,6 +277,9 @@ clutter_context_new (ClutterContextFlags flags,
|
|||
g_async_queue_new_full ((GDestroyNotify) clutter_event_free);
|
||||
context->last_repaint_id = 1;
|
||||
|
||||
priv->color_manager = g_object_new (CLUTTER_TYPE_COLOR_MANAGER,
|
||||
"context", context,
|
||||
NULL);
|
||||
priv->pipeline_cache = g_object_new (CLUTTER_TYPE_PIPELINE_CACHE, NULL);
|
||||
|
||||
if (!clutter_context_init_real (context, flags, error))
|
||||
|
|
|
@ -48,6 +48,7 @@ typedef struct _ClutterFrame ClutterFrame;
|
|||
typedef struct _ClutterFrameInfo ClutterFrameInfo;
|
||||
typedef struct _ClutterLayoutMeta ClutterLayoutMeta;
|
||||
typedef struct _ClutterActorMeta ClutterActorMeta;
|
||||
typedef struct _ClutterColorManager ClutterColorManager;
|
||||
typedef struct _ClutterLayoutManager ClutterLayoutManager;
|
||||
typedef struct _ClutterActorIter ClutterActorIter;
|
||||
typedef struct _ClutterPaintContext ClutterPaintContext;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "clutter/clutter-brightness-contrast-effect.h"
|
||||
#include "clutter/clutter-click-action.h"
|
||||
#include "clutter/clutter-clone.h"
|
||||
#include "clutter/clutter-color-manager.h"
|
||||
#include "clutter/clutter-color-state.h"
|
||||
#include "clutter/clutter-colorize-effect.h"
|
||||
#include "clutter/clutter-constraint.h"
|
||||
|
|
|
@ -17,6 +17,7 @@ clutter_headers = [
|
|||
'clutter-brightness-contrast-effect.h',
|
||||
'clutter-click-action.h',
|
||||
'clutter-clone.h',
|
||||
'clutter-color-manager.h',
|
||||
'clutter-color-state.h',
|
||||
'clutter-colorize-effect.h',
|
||||
'clutter-constraint.h',
|
||||
|
@ -101,6 +102,7 @@ clutter_sources = [
|
|||
'clutter-brightness-contrast-effect.c',
|
||||
'clutter-click-action.c',
|
||||
'clutter-clone.c',
|
||||
'clutter-color-manager.c',
|
||||
'clutter-color-state.c',
|
||||
'clutter-colorize-effect.c',
|
||||
'clutter-constraint.c',
|
||||
|
|
Loading…
Reference in a new issue