diff options
author | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2020-10-10 18:02:00 +0300 |
---|---|---|
committer | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2020-10-10 18:02:00 +0300 |
commit | 70d4dc2c01729d164c077fd166a0ea93050a817f (patch) | |
tree | ff035d3d74eec952d07b42024ef8b0a8519aaa60 | |
parent | e1f17de218f148881ab8417f331fed7a8ddafd62 (diff) | |
download | metacity-70d4dc2c01729d164c077fd166a0ea93050a817f.tar.gz |
compositor-xrender: use GRand to generate random numbers
-rw-r--r-- | src/compositor/meta-compositor-xrender.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/compositor/meta-compositor-xrender.c b/src/compositor/meta-compositor-xrender.c index 77aca305..4c7ea2b4 100644 --- a/src/compositor/meta-compositor-xrender.c +++ b/src/compositor/meta-compositor-xrender.c @@ -100,6 +100,7 @@ typedef struct gboolean prefs_listener_added; guint show_redraw : 1; + GRand *rand; } MetaCompositorXRenderPrivate; G_DEFINE_TYPE_WITH_PRIVATE (MetaCompositorXRender, @@ -865,6 +866,9 @@ timeout_debug (MetaCompositorXRender *self) priv->show_redraw = (g_getenv ("METACITY_DEBUG_REDRAWS") != NULL); + if (priv->show_redraw) + priv->rand = g_rand_new (); + return FALSE; } @@ -948,6 +952,8 @@ meta_compositor_xrender_finalize (GObject *object) } } + g_clear_pointer (&priv->rand, g_rand_free); + G_OBJECT_CLASS (meta_compositor_xrender_parent_class)->finalize (object); } @@ -1371,9 +1377,9 @@ meta_compositor_xrender_draw (MetaCompositorXRender *self, /* Make a random colour overlay */ overlay = solid_picture (xdisplay, TRUE, 1, /* 0.3, alpha */ - ((double) (rand () % 100)) / 100.0, - ((double) (rand () % 100)) / 100.0, - ((double) (rand () % 100)) / 100.0); + g_rand_double (priv->rand), + g_rand_double (priv->rand), + g_rand_double (priv->rand)); XRenderComposite (xdisplay, PictOpOver, overlay, None, priv->root_picture, 0, 0, 0, 0, 0, 0, screen_width, screen_height); |