[mutter/gbsneto/graphene-frustrum: 7/26] clutter/util: Generalize ROUND_TO_256THS
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/graphene-frustrum: 7/26] clutter/util: Generalize ROUND_TO_256THS
- Date: Tue, 13 Oct 2020 19:29:53 +0000 (UTC)
commit 3dd556f8399b61b3f62b34df42f9e74a266c3acc
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Oct 13 08:23:56 2020 -0300
clutter/util: Generalize ROUND_TO_256THS
It'll be reused in other bits of the Clutter codebase. Move it to
an inline function in clutter-private.h
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
clutter/clutter/clutter-private.h | 6 ++++++
clutter/clutter/clutter-util.c | 20 ++++++++++----------
2 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/clutter/clutter/clutter-private.h b/clutter/clutter/clutter-private.h
index a504b74ba8..594a73b862 100644
--- a/clutter/clutter/clutter-private.h
+++ b/clutter/clutter/clutter-private.h
@@ -268,6 +268,12 @@ gboolean _clutter_run_progress_function (GType gtype,
void clutter_timeline_cancel_delay (ClutterTimeline *timeline);
+static inline void
+clutter_round_to_256ths (float *f)
+{
+ *f = roundf ((*f) * 256) / 256;
+}
+
static inline int64_t
us (int64_t us)
{
diff --git a/clutter/clutter/clutter-util.c b/clutter/clutter/clutter-util.c
index f598332c8f..5f7fab0e15 100644
--- a/clutter/clutter/clutter-util.c
+++ b/clutter/clutter/clutter-util.c
@@ -47,8 +47,6 @@
#define MTX_GL_SCALE_Y(y,w,v1,v2) ((v1) - (((((y) / (w)) + 1.0f) / 2.0f) * (v1)) + (v2))
#define MTX_GL_SCALE_Z(z,w,v1,v2) (MTX_GL_SCALE_X ((z), (w), (v1), (v2)))
-#define ROUND_TO_256THS(x) (roundf ((x) * 256) / 256)
-
typedef struct
{
float x;
@@ -108,14 +106,16 @@ _clutter_util_fully_transform_vertices (const graphene_matrix_t *modelview,
ClutterVertex4 vertex_tmp = vertices_tmp[i];
graphene_point3d_t *vertex_out = &vertices_out[i];
/* Finally translate from OpenGL coords to window coords */
- vertex_out->x = ROUND_TO_256THS (MTX_GL_SCALE_X (vertex_tmp.x,
- vertex_tmp.w,
- viewport[2],
- viewport[0]));
- vertex_out->y = ROUND_TO_256THS (MTX_GL_SCALE_Y (vertex_tmp.y,
- vertex_tmp.w,
- viewport[3],
- viewport[1]));
+ vertex_out->x = MTX_GL_SCALE_X (vertex_tmp.x,
+ vertex_tmp.w,
+ viewport[2],
+ viewport[0]);
+ vertex_out->y = MTX_GL_SCALE_Y (vertex_tmp.y,
+ vertex_tmp.w,
+ viewport[3],
+ viewport[1]);
+ clutter_round_to_256ths (&vertex_out->x);
+ clutter_round_to_256ths (&vertex_out->y);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]