mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 12:23:53 +00:00
Make plot color/value formatting generic utilities.
Previous implementations of these functions (in TracyView) are still used throughout the code. They will be removed in subsequent commits.
This commit is contained in:
parent
1736fb387a
commit
55a82ea714
@ -1,6 +1,9 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "TracyColor.hpp"
|
||||||
|
#include "TracyPrint.hpp"
|
||||||
#include "TracyUtility.hpp"
|
#include "TracyUtility.hpp"
|
||||||
|
#include "TracyWorker.hpp"
|
||||||
|
|
||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
@ -137,4 +140,42 @@ void TooltipNormalizedName( const char* name, const char* normalized )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t GetPlotColor( const PlotData& plot, const Worker& worker )
|
||||||
|
{
|
||||||
|
switch( plot.type )
|
||||||
|
{
|
||||||
|
case PlotType::User:
|
||||||
|
if( plot.color != 0 ) return plot.color | 0xFF000000;
|
||||||
|
return GetHsvColor( charutil::hash( worker.GetString( plot.name ) ), -10 );
|
||||||
|
case PlotType::Memory:
|
||||||
|
return 0xFF2266CC;
|
||||||
|
case PlotType::SysTime:
|
||||||
|
return 0xFFBAB220;
|
||||||
|
default:
|
||||||
|
assert( false );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* FormatPlotValue( double val, PlotValueFormatting format )
|
||||||
|
{
|
||||||
|
static char buf[64];
|
||||||
|
switch( format )
|
||||||
|
{
|
||||||
|
case PlotValueFormatting::Number:
|
||||||
|
return RealToString( val );
|
||||||
|
break;
|
||||||
|
case PlotValueFormatting::Memory:
|
||||||
|
return MemSizeToString( val );
|
||||||
|
break;
|
||||||
|
case PlotValueFormatting::Percentage:
|
||||||
|
sprintf( buf, "%.2f%%", val );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert( false );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,13 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#include "TracyEvent.hpp"
|
||||||
|
|
||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class Worker;
|
||||||
|
|
||||||
enum class ShortenName : uint8_t
|
enum class ShortenName : uint8_t
|
||||||
{
|
{
|
||||||
Never,
|
Never,
|
||||||
@ -22,6 +25,9 @@ void TooltipNormalizedName( const char* name, const char* normalized );
|
|||||||
|
|
||||||
static inline const char* ShortenZoneName( ShortenName type, const char* name ) { ImVec2 tsz = {}; return ShortenZoneName( type, name, tsz, 0 ); }
|
static inline const char* ShortenZoneName( ShortenName type, const char* name ) { ImVec2 tsz = {}; return ShortenZoneName( type, name, tsz, 0 ); }
|
||||||
|
|
||||||
|
uint32_t GetPlotColor( const PlotData& plot, const Worker& worker );
|
||||||
|
const char* FormatPlotValue( double val, PlotValueFormatting format );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user