From 2acea5da3c691fab9a5518689a5e624bfeb7351a Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 4 Aug 2018 23:32:53 +0200 Subject: [PATCH] Also draw zig-zag on too-small zones. --- NEWS | 3 ++- server/TracyView.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 80a725a7..3bcda48e 100644 --- a/NEWS +++ b/NEWS @@ -58,7 +58,8 @@ v0.4 (xxxx-xx-xx) - Only one frame set can be active at once. The selected one is used for the frame navigation graph, frame navigation buttons and drawing frame separators. -- Frames too small to be displayed will be replaced with a zig-zag pattern. +- Frames and zones too small to be displayed will be marked with a zig-zag + pattern. v0.3.3 (2018-07-03) ------------------- diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 0cf363af..8c7e1427 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -986,6 +986,14 @@ bool View::DrawZoneFramesHeader() return hover; } +static uint32_t DarkenColor( uint32_t color ) +{ + return 0xFF000000 | + ( std::min( 0xFF, ( ( ( color & 0x00FF0000 ) >> 16 ) * 2 / 3 ) ) << 16 ) | + ( std::min( 0xFF, ( ( ( color & 0x0000FF00 ) >> 8 ) * 2 / 3 ) ) << 8 ) | + ( std::min( 0xFF, ( ( ( color & 0x000000FF ) ) * 2 / 3 ) ) ); +} + static void DrawZigZag( ImDrawList* draw, const ImVec2& wpos, double start, double end, double h, uint32_t color ) { int mode = 0; @@ -1505,6 +1513,7 @@ int View::DrawZoneLevel( const Vector& vec, bool hover, double pxns, num++; } draw->AddRectFilled( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( std::max( px1, px0+MinVisSize ), double( w + 10 ) ), offset + ty ), color ); + DrawZigZag( draw, wpos + ImVec2( 0, offset + ty/2 ), std::max( px0, -10.0 ), std::min( std::max( px1, px0+MinVisSize ), double( w + 10 ) ), ty/4, DarkenColor( color ) ); if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( std::max( px1, px0+MinVisSize ), double( w + 10 ) ), offset + ty ) ) ) { if( num > 1 ) @@ -1774,6 +1783,7 @@ int View::DrawGpuZoneLevel( const Vector& vec, bool hover, double pxn num++; } draw->AddRectFilled( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( std::max( px1, px0+MinVisSize ), double( w + 10 ) ), offset + ty ), color ); + DrawZigZag( draw, wpos + ImVec2( 0, offset + ty/2 ), std::max( px0, -10.0 ), std::min( std::max( px1, px0+MinVisSize ), double( w + 10 ) ), ty/4, DarkenColor( color ) ); if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( std::max( px1, px0+MinVisSize ), double( w + 10 ) ), offset + ty ) ) ) { if( num > 1 )