[mutter/gbsneto/graphene2: 20/45] cogl: Add Graphene utility functions to Cogl
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/graphene2: 20/45] cogl: Add Graphene utility functions to Cogl
- Date: Sat, 7 Sep 2019 11:18:55 +0000 (UTC)
commit 92a58d9afad0682b86568948efe2298ad73419ae
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Feb 27 16:02:37 2019 -0300
cogl: Add Graphene utility functions to Cogl
cogl/cogl/cogl-graphene-utils.c | 78 +++++++++++++++++++++++++++++++++++++++++
cogl/cogl/cogl-graphene-utils.h | 54 ++++++++++++++++++++++++++++
cogl/cogl/cogl.h | 1 +
cogl/cogl/cogl.symbols | 3 ++
cogl/cogl/libmutter-cogl.map | 1 +
cogl/cogl/meson.build | 2 ++
6 files changed, 139 insertions(+)
---
diff --git a/cogl/cogl/cogl-graphene-utils.c b/cogl/cogl/cogl-graphene-utils.c
new file mode 100644
index 000000000..dc2b71088
--- /dev/null
+++ b/cogl/cogl/cogl-graphene-utils.c
@@ -0,0 +1,78 @@
+/*
+ * Cogl
+ *
+ * A Low Level GPU Graphics and Utilities API
+ *
+ * Copyright (C) 2019 Endless, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ *
+ *
+ * Authors:
+ * Georges Basile Stavracas Neto <gbsneto gnome org>
+ */
+
+#include "cogl-graphene-utils.h"
+#include "cogl-matrix-private.h"
+
+#include <stdint.h>
+
+gboolean
+cogl_graphene_matrix_equal (const graphene_matrix_t *matrix_a,
+ const graphene_matrix_t *matrix_b)
+{
+ graphene_vec4_t row_a, row_b;
+
+#define COMPARE_MATRIX_ROW(row) \
+ G_STMT_START { \
+ graphene_matrix_get_row (matrix_a, row, &row_a); \
+ graphene_matrix_get_row (matrix_b, row, &row_b); \
+ if (!graphene_vec4_equal (&row_a, &row_b)) \
+ return FALSE; \
+ } G_STMT_END
+
+ COMPARE_MATRIX_ROW (0);
+ COMPARE_MATRIX_ROW (1);
+ COMPARE_MATRIX_ROW (2);
+ COMPARE_MATRIX_ROW (3);
+
+#undef COMPARE_MATRIX_ROW
+
+ return TRUE;
+}
+
+void
+cogl_matrix_to_graphene_matrix (const CoglMatrix *matrix,
+ graphene_matrix_t *res)
+{
+ graphene_matrix_init_from_float (res, (float *)matrix);
+}
+
+void
+graphene_matrix_to_cogl_matrix (const graphene_matrix_t *matrix,
+ CoglMatrix *res)
+{
+ float data[16];
+
+ graphene_matrix_to_float (matrix, data);
+ cogl_matrix_init_from_array (res, data);
+}
diff --git a/cogl/cogl/cogl-graphene-utils.h b/cogl/cogl/cogl-graphene-utils.h
new file mode 100644
index 000000000..6df17e67d
--- /dev/null
+++ b/cogl/cogl/cogl-graphene-utils.h
@@ -0,0 +1,54 @@
+/*
+ * Cogl
+ *
+ * A Low Level GPU Graphics and Utilities API
+ *
+ * Copyright (C) 2019 Endless, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ *
+ *
+ * Authors:
+ * Georges Basile Stavracas Neto <gbsneto gnome org>
+ */
+
+#ifndef COGL_GRAPHENE_UTILS_H
+#define COGL_GRAPHENE_UTILS_H
+
+#include "cogl-matrix.h"
+
+#include <graphene.h>
+#include <glib-object.h>
+
+gboolean
+cogl_graphene_matrix_equal (const graphene_matrix_t *matrix_a,
+ const graphene_matrix_t *matrix_b);
+
+void
+cogl_matrix_to_graphene_matrix (const CoglMatrix *matrix,
+ graphene_matrix_t *res);
+
+void
+graphene_matrix_to_cogl_matrix (const graphene_matrix_t *matrix,
+ CoglMatrix *res);
+
+#endif /* COGL_GRAPHENE_UTILS_H */
diff --git a/cogl/cogl/cogl.h b/cogl/cogl/cogl.h
index aa25c199a..14dbb1701 100644
--- a/cogl/cogl/cogl.h
+++ b/cogl/cogl/cogl.h
@@ -63,6 +63,7 @@
#include <cogl/cogl1-context.h>
#include <cogl/cogl-bitmap.h>
#include <cogl/cogl-color.h>
+#include <cogl/cogl-graphene-utils.h>
#include <cogl/cogl-matrix.h>
#include <cogl/cogl-matrix-stack.h>
#include <cogl/cogl-offscreen.h>
diff --git a/cogl/cogl/cogl.symbols b/cogl/cogl/cogl.symbols
index 9e1516ab9..4eb08e301 100644
--- a/cogl/cogl/cogl.symbols
+++ b/cogl/cogl/cogl.symbols
@@ -520,6 +520,7 @@ cogl_matrix_stack_rotate_quaternion
cogl_matrix_stack_scale
cogl_matrix_stack_set
cogl_matrix_stack_translate
+cogl_matrix_to_graphene_matrix
cogl_matrix_transform_point
cogl_matrix_transform_points
cogl_matrix_translate
@@ -1016,3 +1017,5 @@ _cogl_texture_get_format
cogl_fence_closure_get_user_data
cogl_framebuffer_add_fence_callback
cogl_framebuffer_cancel_fence_callback
+
+graphene_matrix_to_cogl_matrix
diff --git a/cogl/cogl/libmutter-cogl.map b/cogl/cogl/libmutter-cogl.map
index 9f2f16ba0..6b82a79c4 100644
--- a/cogl/cogl/libmutter-cogl.map
+++ b/cogl/cogl/libmutter-cogl.map
@@ -48,6 +48,7 @@ global:
_cogl_pixel_format_get_bytes_per_pixel*;
_cogl_system_error_quark;
_cogl_util_next_p2;
+ graphene_matrix_to_cogl_matrix;
local:
*;
};
diff --git a/cogl/cogl/meson.build b/cogl/cogl/meson.build
index 6c7d5ad6d..55882b241 100644
--- a/cogl/cogl/meson.build
+++ b/cogl/cogl/meson.build
@@ -98,6 +98,7 @@ cogl_headers = [
cogl_nonintrospected_headers = [
'cogl-deprecated.h',
+ 'cogl-graphene-utils.h',
'cogl-pango.h',
'cogl-renderer.h',
'cogl-swap-chain.h',
@@ -214,6 +215,7 @@ cogl_sources = [
'cogl-i18n-private.h',
'cogl-debug.h',
'cogl-debug-options.h',
+ 'cogl-graphene-utils.c',
'cogl-gpu-info.c',
'cogl-gpu-info-private.h',
'cogl-context-private.h',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]