2018-08-05 14:45:34 +00:00
|
|
|
#ifndef __TRACYDECAYVALUE_HPP__
|
|
|
|
#define __TRACYDECAYVALUE_HPP__
|
|
|
|
|
2022-07-17 11:41:40 +00:00
|
|
|
#include "../public/common/TracyForceInline.hpp"
|
2018-08-05 14:45:34 +00:00
|
|
|
|
|
|
|
namespace tracy
|
|
|
|
{
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
class DecayValue
|
|
|
|
{
|
|
|
|
public:
|
2020-05-07 23:48:37 +00:00
|
|
|
DecayValue( const T& init, bool active = false )
|
2018-08-05 14:45:34 +00:00
|
|
|
: m_value( init )
|
2020-05-07 23:48:37 +00:00
|
|
|
, m_active( active )
|
2018-08-05 14:45:34 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
tracy_force_inline operator const T& () const { return m_value; }
|
2018-10-05 18:39:42 +00:00
|
|
|
tracy_force_inline T operator->() const { return m_value; }
|
2018-08-05 14:45:34 +00:00
|
|
|
|
|
|
|
tracy_force_inline DecayValue& operator=( const T& value )
|
|
|
|
{
|
|
|
|
m_value = value;
|
|
|
|
m_active = true;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
tracy_force_inline void Decay( const T& value )
|
|
|
|
{
|
|
|
|
if( m_active )
|
|
|
|
{
|
|
|
|
m_active = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_value = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
T m_value;
|
|
|
|
bool m_active;
|
|
|
|
};
|
|
|
|
|
2022-07-02 13:20:47 +00:00
|
|
|
static tracy_force_inline uint32_t DarkenColor( uint32_t color )
|
|
|
|
{
|
|
|
|
return 0xFF000000 |
|
|
|
|
( ( ( ( color & 0x00FF0000 ) >> 16 ) * 2 / 3 ) << 16 ) |
|
|
|
|
( ( ( ( color & 0x0000FF00 ) >> 8 ) * 2 / 3 ) << 8 ) |
|
|
|
|
( ( ( ( color & 0x000000FF ) ) * 2 / 3 ) );
|
|
|
|
}
|
|
|
|
|
2018-08-05 14:45:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|