clutter: Implement interval progress for CoglColor

For that, rename clutter-graphene and use that C file to define all the
progress functions

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544>
This commit is contained in:
Bilal Elmoussaoui 2024-01-24 15:48:12 +01:00
parent 99415aad4b
commit 531072d482
6 changed files with 40 additions and 35 deletions

View File

@ -25,8 +25,8 @@
#include "cally/cally.h" #include "cally/cally.h"
#include "clutter/clutter-backend-private.h" #include "clutter/clutter-backend-private.h"
#include "clutter/clutter-debug.h" #include "clutter/clutter-debug.h"
#include "clutter/clutter-graphene.h"
#include "clutter/clutter-main.h" #include "clutter/clutter-main.h"
#include "clutter/clutter-private.h"
#include "clutter/clutter-paint-node-private.h" #include "clutter/clutter-paint-node-private.h"
#include "clutter/clutter-settings-private.h" #include "clutter/clutter-settings-private.h"
@ -101,7 +101,7 @@ clutter_context_class_init (ClutterContextClass *klass)
object_class->dispose = clutter_context_dispose; object_class->dispose = clutter_context_dispose;
clutter_graphene_init (); clutter_interval_register_progress_funcs ();
} }
static void static void

View File

@ -1,27 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Authored By Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
*
* Copyright (C) 2019 Endless, Inc
* Copyright (C) 2009, 2010 Intel Corp
*
* 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
void clutter_graphene_init (void);

View File

@ -24,8 +24,6 @@
#include "config.h" #include "config.h"
#include "clutter/clutter-graphene.h"
#include "clutter/clutter-private.h" #include "clutter/clutter-private.h"
#include "clutter/clutter-types.h" #include "clutter/clutter-types.h"
@ -114,8 +112,40 @@ graphene_size_progress (const GValue *a,
return TRUE; return TRUE;
} }
static void
cogl_color_interpolate (const CoglColor *initial,
const CoglColor *final,
gdouble progress,
CoglColor *result)
{
g_return_if_fail (initial != NULL);
g_return_if_fail (final != NULL);
g_return_if_fail (result != NULL);
result->red = initial->red + (final->red - initial->red) * progress;
result->green = initial->green + (final->green - initial->green) * progress;
result->blue = initial->blue + (final->blue - initial->blue) * progress;
result->alpha = initial->alpha + (final->alpha - initial->alpha) * progress;
}
static gboolean
cogl_color_progress (const GValue *a,
const GValue *b,
gdouble progress,
GValue *retval)
{
const CoglColor *a_color = cogl_value_get_color (a);
const CoglColor *b_color = cogl_value_get_color (b);
CoglColor res = { 0, };
cogl_color_interpolate (a_color, b_color, progress, &res);
cogl_value_set_color (retval, &res);
return TRUE;
}
void void
clutter_graphene_init (void) clutter_interval_register_progress_funcs (void)
{ {
clutter_interval_register_progress_func (GRAPHENE_TYPE_MATRIX, clutter_interval_register_progress_func (GRAPHENE_TYPE_MATRIX,
graphene_matrix_progress); graphene_matrix_progress);
@ -127,4 +157,6 @@ clutter_graphene_init (void)
graphene_rect_progress); graphene_rect_progress);
clutter_interval_register_progress_func (GRAPHENE_TYPE_SIZE, clutter_interval_register_progress_func (GRAPHENE_TYPE_SIZE,
graphene_size_progress); graphene_size_progress);
clutter_interval_register_progress_func (COGL_TYPE_COLOR,
cogl_color_progress);
} }

View File

@ -32,7 +32,6 @@
#include "clutter/clutter-event-private.h" #include "clutter/clutter-event-private.h"
#include "clutter/clutter-input-device-private.h" #include "clutter/clutter-input-device-private.h"
#include "clutter/clutter-input-pointer-a11y-private.h" #include "clutter/clutter-input-pointer-a11y-private.h"
#include "clutter/clutter-graphene.h"
#include "clutter/clutter-main.h" #include "clutter/clutter-main.h"
#include "clutter/clutter-mutter.h" #include "clutter/clutter-mutter.h"
#include "clutter/clutter-private.h" #include "clutter/clutter-private.h"

View File

@ -159,6 +159,8 @@ gboolean _clutter_run_progress_function (GType gtype,
void clutter_timeline_cancel_delay (ClutterTimeline *timeline); void clutter_timeline_cancel_delay (ClutterTimeline *timeline);
void clutter_interval_register_progress_funcs (void);
static inline void static inline void
clutter_round_to_256ths (float *f) clutter_round_to_256ths (float *f)
{ {

View File

@ -120,7 +120,6 @@ clutter_sources = [
'clutter-gesture-action.c', 'clutter-gesture-action.c',
'clutter-gesture.c', 'clutter-gesture.c',
'clutter-grab.c', 'clutter-grab.c',
'clutter-graphene.c',
'clutter-grid-layout.c', 'clutter-grid-layout.c',
'clutter-image.c', 'clutter-image.c',
'clutter-input-device.c', 'clutter-input-device.c',
@ -132,6 +131,7 @@ clutter_sources = [
'clutter-input-only-actor.c', 'clutter-input-only-actor.c',
'clutter-virtual-input-device.c', 'clutter-virtual-input-device.c',
'clutter-interval.c', 'clutter-interval.c',
'clutter-interval-progress.c',
'clutter-keyframe-transition.c', 'clutter-keyframe-transition.c',
'clutter-keymap.c', 'clutter-keymap.c',
'clutter-keysyms-table.c', 'clutter-keysyms-table.c',
@ -186,7 +186,6 @@ clutter_private_headers = [
'clutter-event-private.h', 'clutter-event-private.h',
'clutter-flatten-effect.h', 'clutter-flatten-effect.h',
'clutter-frame-private.h', 'clutter-frame-private.h',
'clutter-graphene.h',
'clutter-input-device-private.h', 'clutter-input-device-private.h',
'clutter-input-focus-private.h', 'clutter-input-focus-private.h',
'clutter-input-method-private.h', 'clutter-input-method-private.h',