[gtk/wip/chergert/glproto] next: distribute hash bits more



commit 29b5a7ef2260dcfc16ff09b008e202d501eaa6bb
Author: Christian Hergert <chergert redhat com>
Date:   Tue Feb 23 12:54:32 2021 -0800

    next: distribute hash bits more

 gsk/next/gskgldriver.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/gsk/next/gskgldriver.c b/gsk/next/gskgldriver.c
index 2e42a92af7..efe098643b 100644
--- a/gsk/next/gskgldriver.c
+++ b/gsk/next/gskgldriver.c
@@ -53,11 +53,18 @@ texture_key_hash (gconstpointer v)
 {
   const GskTextureKey *k = (const GskTextureKey *)v;
 
-  return GPOINTER_TO_UINT (k->pointer)
-         + (guint)(k->scale_x * 100)
-         + (guint)(k->scale_y * 100)
-         + (guint)k->filter * 2 +
-         + (guint)k->pointer_is_child;
+  /* Optimize for 0..3 where 0 is the scaled out case. Usually
+   * we'll be squarely on 1 or 2 for standard vs HiDPI. When rendering
+   * to a texture scaled out like in node-editor, we might be < 1.
+   */
+  guint scale_x = floorf (k->scale_x);
+  guint scale_y = floorf (k->scale_y);
+
+  return GPOINTER_TO_SIZE (k->pointer) ^
+    ((scale_x << 8) |
+     (scale_y << 6) |
+     (k->filter << 1) |
+     k->pointer_is_child);
 }
 
 static gboolean


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