[gtk/wip/chergert/glproto: 66/94] use bitfields instead of flags




commit c08bba95750f4c61a15710f2c6f97406824e02f1
Author: Christian Hergert <chergert redhat com>
Date:   Mon Dec 28 15:57:16 2020 -0800

    use bitfields instead of flags
    
    no reason to use flags, we already have a bitfield here

 gsk/next/gskglcommandqueue.c        |  2 +-
 gsk/next/gskgluniformstate.c        | 15 ++++++++-------
 gsk/next/gskgluniformstateprivate.h | 10 +++-------
 3 files changed, 12 insertions(+), 15 deletions(-)
---
diff --git a/gsk/next/gskglcommandqueue.c b/gsk/next/gskglcommandqueue.c
index 4d9ffc4c5d..b7ae72508b 100644
--- a/gsk/next/gskglcommandqueue.c
+++ b/gsk/next/gskglcommandqueue.c
@@ -867,7 +867,7 @@ apply_uniform (GskGLUniformState      *state,
       break;
 
     case GSK_GL_UNIFORM_FORMAT_ROUNDED_RECT:
-      if (info->flags & GSK_GL_UNIFORM_FLAGS_SEND_CORNERS)
+      if (info->send_corners)
         glUniform4fv (location, 3, (const float *)&data->rounded_rect[0]);
       else
         glUniform4fv (location, 1, (const float *)&data->rounded_rect[0]);
diff --git a/gsk/next/gskgluniformstate.c b/gsk/next/gskgluniformstate.c
index ed041a513b..3a14d958e1 100644
--- a/gsk/next/gskgluniformstate.c
+++ b/gsk/next/gskgluniformstate.c
@@ -104,10 +104,11 @@ program_changed (GskGLUniformState *state,
 {
   if (info->changed == FALSE)
     {
-      info->changed = TRUE;
-      if (info->format == GSK_GL_UNIFORM_FORMAT_MATRIX)
-        info->flags |= GSK_GL_UNIFORM_FLAGS_MATRIX_SET;
       g_assert (program < state->program_info->len);
+
+      info->changed = TRUE;
+      info->initial = FALSE;
+
       g_array_index (state->program_info, ProgramInfo, program).n_changed++;
     }
 }
@@ -462,13 +463,13 @@ gsk_gl_uniform_state_set_rounded_rect (GskGLUniformState    *state,
         {
           REPLACE_UNIFORM (info, u, GSK_GL_UNIFORM_FORMAT_ROUNDED_RECT, 1);
 
-          if (!(info->flags & GSK_GL_UNIFORM_FLAGS_SEND_CORNERS))
+          if (!info->send_corners)
             {
               if (!graphene_size_equal (&u->corner[0], &rounded_rect->corner[0]) ||
                   !graphene_size_equal (&u->corner[1], &rounded_rect->corner[1]) ||
                   !graphene_size_equal (&u->corner[2], &rounded_rect->corner[2]) ||
                   !graphene_size_equal (&u->corner[3], &rounded_rect->corner[3]))
-                info->flags |= GSK_GL_UNIFORM_FLAGS_SEND_CORNERS;
+                info->send_corners = TRUE;
             }
 
           memcpy (u, rounded_rect, sizeof *rounded_rect);
@@ -492,7 +493,7 @@ gsk_gl_uniform_state_set_matrix (GskGLUniformState       *state,
 
   if ((u = get_uniform (state, program, GSK_GL_UNIFORM_FORMAT_MATRIX, 1, location, &info)))
     {
-      if (info->flags & GSK_GL_UNIFORM_FLAGS_MATRIX_SET)
+      if (!info->initial)
         {
           if (graphene_matrix_equal_fast (u, matrix) ||
               graphene_matrix_equal (u, matrix))
@@ -714,7 +715,7 @@ gsk_gl_uniform_state_snapshot (GskGLUniformState         *state,
       callback (info, i, user_data);
 
       info->changed = FALSE;
-      info->flags = 0;
+      info->send_corners = FALSE;
     }
 
   program_info->n_changed = 0;
diff --git a/gsk/next/gskgluniformstateprivate.h b/gsk/next/gskgluniformstateprivate.h
index 74b5869d0c..9416a842cf 100644
--- a/gsk/next/gskgluniformstateprivate.h
+++ b/gsk/next/gskgluniformstateprivate.h
@@ -36,7 +36,9 @@ typedef struct _GskGLUniformInfo
   guint changed : 1;
   guint format : 5;
   guint array_count : 6;
-  guint flags : 4;
+  guint initial : 1;
+  guint send_corners : 1;
+  guint unused : 2;
   guint offset : 16;
 } GskGLUniformInfo;
 
@@ -56,12 +58,6 @@ typedef void (*GskGLUniformStateCallback) (const GskGLUniformInfo *info,
                                            guint                   location,
                                            gpointer                user_data);
 
-typedef enum _GskGLUniformFlags
-{
-  GSK_GL_UNIFORM_FLAGS_SEND_CORNERS = 1 << 0,
-  GSK_GL_UNIFORM_FLAGS_MATRIX_SET   = 1 << 1,
-} GskGLUniformFlags;
-
 typedef enum _GskGLUniformKind
 {
   GSK_GL_UNIFORM_FORMAT_1F = 1,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]