[mutter/gbsneto/graphene-matrix: 35/104] clutter: Add progress function for CoglMatrix
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/graphene-matrix: 35/104] clutter: Add progress function for CoglMatrix
- Date: Tue, 6 Oct 2020 14:43:25 +0000 (UTC)
commit 42255c6df0d8b49809665bd663396f59039a0068
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Sep 8 20:14:50 2020 -0300
clutter: Add progress function for CoglMatrix
So that we can remove the custom ClutterMatrix type that plagues
the codebase.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
clutter/clutter/clutter-cogl.c | 110 +++++++++++++++++++++++++++++++++++++++++
clutter/clutter/clutter-cogl.h | 30 +++++++++++
clutter/clutter/clutter-main.c | 2 +
clutter/clutter/meson.build | 2 +
4 files changed, 144 insertions(+)
---
diff --git a/clutter/clutter/clutter-cogl.c b/clutter/clutter/clutter-cogl.c
new file mode 100644
index 0000000000..2ba1b16128
--- /dev/null
+++ b/clutter/clutter/clutter-cogl.c
@@ -0,0 +1,110 @@
+/*
+ * Clutter.
+ *
+ * An OpenGL based 'interactive canvas' library.
+ *
+ * Authored By Georges Basile Stavracas Neto <georges stavracas gmail com>
+ *
+ * Copyright (C) 2009, 2010 Intel Corp
+ * Copyright (C) 2020 Endless OS Foundation LLC
+ *
+ * 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 "clutter-build-config.h"
+
+#include "clutter-cogl.h"
+
+#include "clutter-private.h"
+#include "clutter-types.h"
+
+static gboolean
+cogl_matrix_progress (const GValue *a,
+ const GValue *b,
+ gdouble progress,
+ GValue *retval)
+{
+ const CoglMatrix *matrix1 = g_value_get_boxed (a);
+ const CoglMatrix *matrix2 = g_value_get_boxed (b);
+ graphene_point3d_t scale1 = GRAPHENE_POINT3D_INIT (1.f, 1.f, 1.f);
+ float shear1[3] = { 0.f, 0.f, 0.f };
+ graphene_point3d_t rotate1 = GRAPHENE_POINT3D_INIT_ZERO;
+ graphene_point3d_t translate1 = GRAPHENE_POINT3D_INIT_ZERO;
+ ClutterVertex4 perspective1 = { 0.f, 0.f, 0.f, 0.f };
+ graphene_point3d_t scale2 = GRAPHENE_POINT3D_INIT (1.f, 1.f, 1.f);
+ float shear2[3] = { 0.f, 0.f, 0.f };
+ graphene_point3d_t rotate2 = GRAPHENE_POINT3D_INIT_ZERO;
+ graphene_point3d_t translate2 = GRAPHENE_POINT3D_INIT_ZERO;
+ ClutterVertex4 perspective2 = { 0.f, 0.f, 0.f, 0.f };
+ graphene_point3d_t scale_res = GRAPHENE_POINT3D_INIT (1.f, 1.f, 1.f);
+ float shear_res = 0.f;
+ graphene_point3d_t rotate_res = GRAPHENE_POINT3D_INIT_ZERO;
+ graphene_point3d_t translate_res = GRAPHENE_POINT3D_INIT_ZERO;
+ ClutterVertex4 perspective_res = { 0.f, 0.f, 0.f, 0.f };
+ CoglMatrix res;
+
+ cogl_matrix_init_identity (&res);
+
+ _clutter_util_matrix_decompose (matrix1,
+ &scale1, shear1, &rotate1, &translate1,
+ &perspective1);
+ _clutter_util_matrix_decompose (matrix2,
+ &scale2, shear2, &rotate2, &translate2,
+ &perspective2);
+
+ /* perspective */
+ _clutter_util_vertex4_interpolate (&perspective1, &perspective2, progress, &perspective_res);
+ res.wx = perspective_res.x;
+ res.wy = perspective_res.y;
+ res.wz = perspective_res.z;
+ res.ww = perspective_res.w;
+
+ /* translation */
+ graphene_point3d_interpolate (&translate1, &translate2, progress, &translate_res);
+ cogl_matrix_translate (&res, translate_res.x, translate_res.y, translate_res.z);
+
+ /* rotation */
+ graphene_point3d_interpolate (&rotate1, &rotate2, progress, &rotate_res);
+ cogl_matrix_rotate (&res, rotate_res.x, 1.0f, 0.0f, 0.0f);
+ cogl_matrix_rotate (&res, rotate_res.y, 0.0f, 1.0f, 0.0f);
+ cogl_matrix_rotate (&res, rotate_res.z, 0.0f, 0.0f, 1.0f);
+
+ /* skew */
+ shear_res = shear1[2] + (shear2[2] - shear1[2]) * progress; /* YZ */
+ if (shear_res != 0.f)
+ _clutter_util_matrix_skew_yz (&res, shear_res);
+
+ shear_res = shear1[1] + (shear2[1] - shear1[1]) * progress; /* XZ */
+ if (shear_res != 0.f)
+ _clutter_util_matrix_skew_xz (&res, shear_res);
+
+ shear_res = shear1[0] + (shear2[0] - shear1[0]) * progress; /* XY */
+ if (shear_res != 0.f)
+ _clutter_util_matrix_skew_xy (&res, shear_res);
+
+ /* scale */
+ graphene_point3d_interpolate (&scale1, &scale2, progress, &scale_res);
+ cogl_matrix_scale (&res, scale_res.x, scale_res.y, scale_res.z);
+
+ g_value_set_boxed (retval, &res);
+
+ return TRUE;
+}
+
+void
+clutter_cogl_init (void)
+{
+ clutter_interval_register_progress_func (COGL_GTYPE_TYPE_MATRIX,
+ cogl_matrix_progress);
+}
diff --git a/clutter/clutter/clutter-cogl.h b/clutter/clutter/clutter-cogl.h
new file mode 100644
index 0000000000..432151b2e5
--- /dev/null
+++ b/clutter/clutter/clutter-cogl.h
@@ -0,0 +1,30 @@
+/*
+ * Clutter.
+ *
+ * An OpenGL based 'interactive canvas' library.
+ *
+ * Authored By Georges Basile Stavracas Neto <georges stavracas gmail com>
+ *
+ * Copyright (C) 2009, 2010 Intel Corp
+ * Copyright (C) 2020 Endless OS Foundation LLC
+ *
+ * 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_COGL_H
+#define CLUTTER_COGL_H
+
+void clutter_cogl_init (void);
+
+#endif
diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c
index 1dbca4782d..78e717704e 100644
--- a/clutter/clutter/clutter-main.c
+++ b/clutter/clutter/clutter-main.c
@@ -53,6 +53,7 @@
#include "clutter-actor-private.h"
#include "clutter-backend-private.h"
+#include "clutter-cogl.h"
#include "clutter-config.h"
#include "clutter-debug.h"
#include "clutter-event-private.h"
@@ -2020,6 +2021,7 @@ clutter_base_init (void)
g_type_init ();
#endif
+ clutter_cogl_init ();
clutter_graphene_init ();
}
}
diff --git a/clutter/clutter/meson.build b/clutter/clutter/meson.build
index 18994df8d1..067669c7f4 100644
--- a/clutter/clutter/meson.build
+++ b/clutter/clutter/meson.build
@@ -109,6 +109,7 @@ clutter_sources = [
'clutter-child-meta.c',
'clutter-click-action.c',
'clutter-clone.c',
+ 'clutter-cogl.c',
'clutter-color.c',
'clutter-colorize-effect.c',
'clutter-constraint.c',
@@ -183,6 +184,7 @@ clutter_private_headers = [
'clutter-actor-private.h',
'clutter-backend-private.h',
'clutter-bezier.h',
+ 'clutter-cogl.h',
'clutter-constraint-private.h',
'clutter-content-private.h',
'clutter-damage-history.h',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]