[gtk/mask-nodes: 367/368] gsk: Add gsk_stroke_hash




commit d05acfb72f7710fcf17554fddd15d24658de032b
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Dec 15 19:06:20 2020 -0500

    gsk: Add gsk_stroke_hash
    
    Not currently used, just leaving this here for later use.

 gsk/gskstroke.c        | 18 ++++++++++++++++++
 gsk/gskstrokeprivate.h |  2 ++
 2 files changed, 20 insertions(+)
---
diff --git a/gsk/gskstroke.c b/gsk/gskstroke.c
index 654f4255e4..c0fcc1997c 100644
--- a/gsk/gskstroke.c
+++ b/gsk/gskstroke.c
@@ -457,3 +457,21 @@ gsk_stroke_get_dash_offset (const GskStroke *self)
 
   return self->dash_offset;
 }
+
+guint
+gsk_stroke_hash (const GskStroke *stroke)
+{
+  guint32 h = 5381;
+  int f;
+
+  h = (h << 5) + h + (guint) (stroke->line_width * 100);
+  h = (h << 5) + h + stroke->line_cap;
+  h = (h << 5) + h + stroke->line_join;
+  h = (h << 5) + h + (guint) (stroke->miter_limit * 100);
+  h = (h << 5) + h + stroke->n_dash;
+  for (int i = 0; i < stroke->n_dash; i++)
+    h = (h << 5) + h + (guint) (stroke->dash[i] * 100);
+  h = (h << 5) + h + (guint) (stroke->dash_offset * 100);
+
+  return h;
+}
diff --git a/gsk/gskstrokeprivate.h b/gsk/gskstrokeprivate.h
index 24594b1e09..cf0335d023 100644
--- a/gsk/gskstrokeprivate.h
+++ b/gsk/gskstrokeprivate.h
@@ -57,6 +57,8 @@ gsk_stroke_clear (GskStroke *stroke)
 void                    gsk_stroke_to_cairo                     (const GskStroke        *self,
                                                                  cairo_t                *cr);
 
+guint                   gsk_stroke_hash                         (const GskStroke        *stroke);
+
 G_END_DECLS
 
 #endif /* __GSK_STROKE_PRIVATE_H__ */


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