[gtk/wip/chergert/glproto: 261/493] check initial flag and count in setters




commit 88b7b5cc018d003d94a9c8a27ec2959638d342ce
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 27 12:48:47 2021 -0800

    check initial flag and count in setters
    
    this helps to ensure we send initial values to the driver which could be
    important if something changes state outside of our frame driver.

 gsk/next/gskgluniformstate.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/gsk/next/gskgluniformstate.c b/gsk/next/gskgluniformstate.c
index d0f558e10f..02de791d20 100644
--- a/gsk/next/gskgluniformstate.c
+++ b/gsk/next/gskgluniformstate.c
@@ -632,7 +632,7 @@ gsk_gl_uniform_state_set_color (GskGLUniformState *state,
       if (color == NULL)
         color = &transparent;
 
-      if (!gdk_rgba_equal (u, color))
+      if (info->initial || !gdk_rgba_equal (u, color))
         {
           REPLACE_UNIFORM (info, u, GSK_GL_UNIFORM_FORMAT_COLOR, 1);
           memcpy (u, color, sizeof *color);
@@ -653,10 +653,11 @@ gsk_gl_uniform_state_set1fv (GskGLUniformState *state,
 
   g_assert (state != NULL);
   g_assert (program > 0);
+  g_assert (count > 0);
 
   if ((u = get_uniform (state, program, GSK_GL_UNIFORM_FORMAT_1FV, count, location, &info)))
     {
-      gboolean changed = memcmp (u, value, sizeof (Uniform1f) * count) != 0;
+      gboolean changed = info->initial || memcmp (u, value, sizeof *u  * count) != 0;
 
       if (changed)
         {
@@ -679,10 +680,11 @@ gsk_gl_uniform_state_set2fv (GskGLUniformState *state,
 
   g_assert (state != NULL);
   g_assert (program > 0);
+  g_assert (count > 0);
 
   if ((u = get_uniform (state, program, GSK_GL_UNIFORM_FORMAT_2FV, count, location, &info)))
     {
-      gboolean changed = memcmp (u, value, sizeof (Uniform2f) * count) != 0;
+      gboolean changed = info->initial || memcmp (u, value, sizeof *u * count) != 0;
 
       if (changed)
         {
@@ -705,10 +707,11 @@ gsk_gl_uniform_state_set3fv (GskGLUniformState *state,
 
   g_assert (state != NULL);
   g_assert (program > 0);
+  g_assert (count > 0);
 
   if ((u = get_uniform (state, program, GSK_GL_UNIFORM_FORMAT_3FV, count, location, &info)))
     {
-      gboolean changed = memcmp (u, value, sizeof (Uniform3f) * count) != 0;
+      gboolean changed = info->initial || memcmp (u, value, sizeof *u * count) != 0;
 
       if (changed)
         {
@@ -731,10 +734,11 @@ gsk_gl_uniform_state_set4fv (GskGLUniformState *state,
 
   g_assert (state != NULL);
   g_assert (program > 0);
+  g_assert (count > 0);
 
   if ((u = get_uniform (state, program, GSK_GL_UNIFORM_FORMAT_4FV, count, location, &info)))
     {
-      gboolean changed = memcmp (u, value, sizeof (Uniform4f) * count) != 0;
+      gboolean changed = info->initial || memcmp (u, value, sizeof *u * count) != 0;
 
       if (changed)
         {


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