26 #include "lv_random.h"
27 #include "lv_common.h"
32 typedef std::minstd_rand Generator;
34 class RandomContext::Impl
48 : m_impl {std::move (rhs.m_impl)}
60 m_impl.swap (rhs.m_impl);
66 m_impl->generator.seed (seed);
71 return m_impl->generator ();
76 #if VISUAL_RANDOM_FAST_FP_RND
84 return get_float () * (max - min + 1) + fm;
86 return get_int () % (max - min + 1) + min;
92 uint32_t irnd = m_impl->generator ();
94 #if VISUAL_RANDOM_FAST_FP_RND
104 value.i[0] = (irnd << 20);
105 value.i[1] = 0x3ff00000 | (irnd >> 12);
106 return value.d - 1.0;
108 return double (irnd) / Generator::max ();
114 uint32_t irnd = m_impl->generator ();
116 #if VISUAL_RANDOM_FAST_FP_RND
124 value.i = 0x3f800000 | (t >> 9);
125 return value.f - 1.0f;
127 return float (irnd) / Generator::max ();