1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Move HSV color conversion to a separate source file.

This commit is contained in:
Bartosz Taudul
2020-04-02 01:04:40 +02:00
parent 2303f18d39
commit b2c2bfc2aa
5 changed files with 58 additions and 28 deletions
+1 -28
View File
@@ -28,6 +28,7 @@
#include "tracy_pdqsort.h"
#include "TracyBadVersion.hpp"
#include "TracyColor.hpp"
#include "TracyFileRead.hpp"
#include "TracyFileWrite.hpp"
#include "TracyFilesystem.hpp"
@@ -14767,34 +14768,6 @@ uint32_t View::GetZoneColor( const ZoneEvent& ev, uint64_t thread, int depth )
}
}
static uint32_t GetHsvColor( uint64_t hue, int value )
{
const uint8_t h = ( hue * 11400714819323198485ull ) & 0xFF;
const uint8_t s = 108;
const uint8_t v = std::max( 96, 170 - value * 8 );
const uint8_t reg = h / 43;
const uint8_t rem = ( h - ( reg * 43 ) ) * 6;
const uint8_t p = ( v * ( 255 - s ) ) >> 8;
const uint8_t q = ( v * ( 255 - ( ( s * rem ) >> 8 ) ) ) >> 8;
const uint8_t t = ( v * ( 255 - ( ( s * ( 255 - rem ) ) >> 8 ) ) ) >> 8;
uint8_t r, g, b;
switch( reg )
{
case 0: r = v; g = t; b = p; break;
case 1: r = q; g = v; b = p; break;
case 2: r = p; g = v; b = t; break;
case 3: r = p; g = q; b = v; break;
case 4: r = t; g = p; b = v; break;
default: r = v; g = p; b = q; break;
}
return 0xFF000000 | ( r << 16 ) | ( g << 8 ) | b;
}
uint32_t View::GetThreadColor( uint64_t thread, int depth )
{
if( m_vd.dynamicColors == 0 ) return 0xFFCC5555;