[gtk/wip/chergert/glproto: 446/526] compile out assertions in some hotter paths




commit e366edcb3b9391e9777068f0c085396415851849
Author: Christian Hergert <chergert redhat com>
Date:   Wed Feb 3 22:04:38 2021 -0800

    compile out assertions in some hotter paths

 gsk/next/gskglcommandqueue.c  | 26 +++++++++++++-------------
 gsk/next/gskgliconlibrary.c   |  6 +++---
 gsk/next/gskglshadowlibrary.c | 10 +++++-----
 gsk/next/gskgltexturepool.c   | 32 +++++++++++++++-----------------
 4 files changed, 36 insertions(+), 38 deletions(-)
---
diff --git a/gsk/next/gskglcommandqueue.c b/gsk/next/gskglcommandqueue.c
index 333cd6746b..5ce3f9782d 100644
--- a/gsk/next/gskglcommandqueue.c
+++ b/gsk/next/gskglcommandqueue.c
@@ -1069,11 +1069,11 @@ gsk_gl_command_queue_create_render_target (GskGLCommandQueue *self,
   GLuint fbo_id = 0;
   GLint texture_id;
 
-  g_return_val_if_fail (GSK_IS_GL_COMMAND_QUEUE (self), FALSE);
-  g_return_val_if_fail (width > 0, FALSE);
-  g_return_val_if_fail (height > 0, FALSE);
-  g_return_val_if_fail (out_fbo_id != NULL, FALSE);
-  g_return_val_if_fail (out_texture_id != NULL, FALSE);
+  g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
+  g_assert (width > 0);
+  g_assert (height > 0);
+  g_assert (out_fbo_id != NULL);
+  g_assert (out_texture_id != NULL);
 
   gsk_gl_command_queue_save (self);
 
@@ -1112,7 +1112,7 @@ gsk_gl_command_queue_create_texture (GskGLCommandQueue *self,
 {
   GLuint texture_id = 0;
 
-  g_return_val_if_fail (GSK_IS_GL_COMMAND_QUEUE (self), -1);
+  g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
 
   if G_UNLIKELY (self->max_texture_size == -1)
     glGetIntegerv (GL_MAX_TEXTURE_SIZE, &self->max_texture_size);
@@ -1147,7 +1147,7 @@ gsk_gl_command_queue_create_framebuffer (GskGLCommandQueue *self)
 {
   GLuint fbo_id;
 
-  g_return_val_if_fail (GSK_IS_GL_COMMAND_QUEUE (self), -1);
+  g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
 
   glGenFramebuffers (1, &fbo_id);
 
@@ -1172,12 +1172,12 @@ gsk_gl_command_queue_upload_texture (GskGLCommandQueue *self,
   gsize bpp;
   int texture_id;
 
-  g_return_val_if_fail (GSK_IS_GL_COMMAND_QUEUE (self), 0);
-  g_return_val_if_fail (!GDK_IS_GL_TEXTURE (texture), 0);
-  g_return_val_if_fail (x_offset + width <= gdk_texture_get_width (texture), 0);
-  g_return_val_if_fail (y_offset + height <= gdk_texture_get_height (texture), 0);
-  g_return_val_if_fail (min_filter == GL_LINEAR || min_filter == GL_NEAREST, 0);
-  g_return_val_if_fail (mag_filter == GL_LINEAR || min_filter == GL_NEAREST, 0);
+  g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
+  g_assert (!GDK_IS_GL_TEXTURE (texture));
+  g_assert (x_offset + width <= gdk_texture_get_width (texture));
+  g_assert (y_offset + height <= gdk_texture_get_height (texture));
+  g_assert (min_filter == GL_LINEAR || min_filter == GL_NEAREST);
+  g_assert (mag_filter == GL_LINEAR || min_filter == GL_NEAREST);
 
   if (width > self->max_texture_size || height > self->max_texture_size)
     {
diff --git a/gsk/next/gskgliconlibrary.c b/gsk/next/gskgliconlibrary.c
index 86b1eca2ec..05afbbe4c7 100644
--- a/gsk/next/gskgliconlibrary.c
+++ b/gsk/next/gskgliconlibrary.c
@@ -88,9 +88,9 @@ gsk_gl_icon_library_add (GskGLIconLibrary     *self,
   int height;
   guint texture_id;
 
-  g_return_if_fail (GSK_IS_GL_ICON_LIBRARY (self));
-  g_return_if_fail (GDK_IS_TEXTURE (key));
-  g_return_if_fail (out_value != NULL);
+  g_assert (GSK_IS_GL_ICON_LIBRARY (self));
+  g_assert (GDK_IS_TEXTURE (key));
+  g_assert (out_value != NULL);
 
   width = key->width;
   height = key->height;
diff --git a/gsk/next/gskglshadowlibrary.c b/gsk/next/gskglshadowlibrary.c
index 79ede9c95d..24a9481fc2 100644
--- a/gsk/next/gskglshadowlibrary.c
+++ b/gsk/next/gskglshadowlibrary.c
@@ -150,9 +150,9 @@ gsk_gl_shadow_library_insert (GskGLShadowLibrary   *self,
 {
   Shadow *shadow;
 
-  g_return_if_fail (GSK_IS_GL_SHADOW_LIBRARY (self));
-  g_return_if_fail (outline != NULL);
-  g_return_if_fail (texture_id != 0);
+  g_assert (GSK_IS_GL_SHADOW_LIBRARY (self));
+  g_assert (outline != NULL);
+  g_assert (texture_id != 0);
 
   gsk_next_driver_mark_texture_permanent (self->driver, texture_id);
 
@@ -172,8 +172,8 @@ gsk_gl_shadow_library_lookup (GskGLShadowLibrary   *self,
 {
   Shadow *ret = NULL;
 
-  g_return_val_if_fail (GSK_IS_GL_SHADOW_LIBRARY (self), 0);
-  g_return_val_if_fail (outline != NULL, 0);
+  g_assert (GSK_IS_GL_SHADOW_LIBRARY (self));
+  g_assert (outline != NULL);
 
   /* Ensure GskRoundedRect  is 12 packed floats without padding
    * so that we can use memcmp instead of float comparisons.
diff --git a/gsk/next/gskgltexturepool.c b/gsk/next/gskgltexturepool.c
index bc1ff47b0c..677238e3b7 100644
--- a/gsk/next/gskgltexturepool.c
+++ b/gsk/next/gskgltexturepool.c
@@ -32,10 +32,10 @@ gsk_gl_texture_free (GskGLTexture *texture)
 {
   if (texture != NULL)
     {
-      g_return_if_fail (texture->width_link.prev == NULL);
-      g_return_if_fail (texture->width_link.next == NULL);
-      g_return_if_fail (texture->height_link.prev == NULL);
-      g_return_if_fail (texture->height_link.next == NULL);
+      g_assert (texture->width_link.prev == NULL);
+      g_assert (texture->width_link.next == NULL);
+      g_assert (texture->height_link.prev == NULL);
+      g_assert (texture->height_link.next == NULL);
 
       if (texture->user)
         g_clear_pointer (&texture->user, gdk_texture_clear_render_data);
@@ -88,15 +88,15 @@ gsk_gl_texture_pool_put (GskGLTexturePool *self,
 {
   GList *sibling;
 
-  g_return_if_fail (self != NULL);
-  g_return_if_fail (texture != NULL);
-  g_return_if_fail (texture->user == NULL);
-  g_return_if_fail (texture->width_link.prev == NULL);
-  g_return_if_fail (texture->width_link.next == NULL);
-  g_return_if_fail (texture->width_link.data == texture);
-  g_return_if_fail (texture->height_link.prev == NULL);
-  g_return_if_fail (texture->height_link.next == NULL);
-  g_return_if_fail (texture->height_link.data == texture);
+  g_assert (self != NULL);
+  g_assert (texture != NULL);
+  g_assert (texture->user == NULL);
+  g_assert (texture->width_link.prev == NULL);
+  g_assert (texture->width_link.next == NULL);
+  g_assert (texture->width_link.data == texture);
+  g_assert (texture->height_link.prev == NULL);
+  g_assert (texture->height_link.next == NULL);
+  g_assert (texture->height_link.data == texture);
 
   if (texture->permanent)
     {
@@ -149,8 +149,6 @@ gsk_gl_texture_pool_get (GskGLTexturePool *self,
 {
   GskGLTexture *texture;
 
-  g_return_val_if_fail (self != NULL, NULL);
-
   if (always_create)
     goto create_texture;
 
@@ -250,8 +248,8 @@ gsk_gl_texture_get_nine_slice (GskGLTexture         *texture,
                                const GskRoundedRect *outline,
                                float                 extra_pixels)
 {
-  g_return_val_if_fail (texture != NULL, NULL);
-  g_return_val_if_fail (outline != NULL, NULL);
+  g_assert (texture != NULL);
+  g_assert (outline != NULL);
 
   if G_UNLIKELY (texture->nine_slice == NULL)
     {


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