mirror of
https://github.com/brl/mutter.git
synced 2025-02-16 13:24:09 +00:00
cogl: Add Graphene utility functions to Cogl
This commit is contained in:
parent
54f9bebeb8
commit
92a58d9afa
78
cogl/cogl/cogl-graphene-utils.c
Normal file
78
cogl/cogl/cogl-graphene-utils.c
Normal file
@ -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);
|
||||
}
|
54
cogl/cogl/cogl-graphene-utils.h
Normal file
54
cogl/cogl/cogl-graphene-utils.h
Normal file
@ -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 */
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
*;
|
||||
};
|
||||
|
@ -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',
|
||||
|
Loading…
x
Reference in New Issue
Block a user