[gtk/wip/chergert/glproto: 308/526] use previous frame to determine new buffer size




commit c2c4c646bc0f3a0f29228a86a5307665dec8f8b1
Author: Christian Hergert <chergert redhat com>
Date:   Tue Jan 26 13:20:32 2021 -0800

    use previous frame to determine new buffer size
    
    just reduce the chance we realloc() a page or few.

 gsk/next/gskgluniformstate.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gsk/next/gskgluniformstate.c b/gsk/next/gskgluniformstate.c
index 25ac2dc3cf..c5f9e7133c 100644
--- a/gsk/next/gskgluniformstate.c
+++ b/gsk/next/gskgluniformstate.c
@@ -783,9 +783,11 @@ gsk_gl_uniform_state_end_frame (GskGLUniformState *state)
   /* After a frame finishes, we want to remove all our copies of uniform
    * data that isn't needed any longer. We just create a new byte array
    * that contains the new data with the gaps removed.
+   *
+   * Create new buffer but with something similar in size to the previous
+   * frame as we can reduce chances of a realloc on the next frame.
    */
-
-  buffer = g_byte_array_sized_new (4096);
+  buffer = g_byte_array_sized_new (state->uniform_data->len);
 
   for (guint i = 0; i < state->program_info->len; i++)
     {


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