diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 286813fe..366b3183 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -98,7 +98,7 @@ static void* iconTex; static int iconTexSz; static uint8_t* zigzagPx; static int zigzagX, zigzagY; -static void* zigzagTex; +void* zigzagTex; static Backend* bptr; static bool s_customTitle = false; static bool s_isElevated = false; diff --git a/server/TracyImGui.cpp b/server/TracyImGui.cpp index f4aaff84..695294b5 100644 --- a/server/TracyImGui.cpp +++ b/server/TracyImGui.cpp @@ -1,15 +1,11 @@ #include #include -#ifdef _WIN32 -# include -#else -# include -#endif - #include "TracyPrint.hpp" #include "TracyImGui.hpp" +extern void* zigzagTex; + namespace tracy { @@ -26,48 +22,10 @@ bool WasActive() } -void DrawZigZag( ImDrawList* draw, const ImVec2& wpos, double start, double end, double h, uint32_t color, float thickness ) +void DrawZigZag( ImDrawList* draw, const ImVec2& wpos, double start, double end, double h, uint32_t color ) { - const auto dpos = wpos + ImVec2( 0.5f, 0.5f ); - - const auto spanSz = end - start; - if( spanSz <= h * 0.5 ) - { - DrawLine( draw, dpos + ImVec2( start, 0 ), wpos + ImVec2( start + spanSz, round( -spanSz ) ), color, thickness ); - return; - } - - const auto h05 = round( h * 0.5 ); - const auto h2 = h*2; - int steps = int( ( end - start ) / h2 ); - - auto path = (ImVec2*)alloca( sizeof( ImVec2 ) * ( 2 * steps + 4 ) ); - auto ptr = path; - - *ptr++ = dpos + ImVec2( start, 0 ); - *ptr++ = dpos + ImVec2( start + h05, -h05 ); - start += h05; - - while( steps-- ) - { - *ptr++ = dpos + ImVec2( start + h, h05 ); - *ptr++ = dpos + ImVec2( start + h2, -h05 ); - start += h2; - } - - if( end - start <= h ) - { - const auto span = end - start; - *ptr++ = dpos + ImVec2( start + span, round( span - h*0.5 ) ); - } - else - { - const auto span = end - start - h; - *ptr++ = dpos + ImVec2( start + h, h05 ); - *ptr++ = dpos + ImVec2( start + h + span, round( h*0.5 - span ) ); - } - - draw->AddPolyline( path, ptr - path, color, 0, thickness ); + const auto v = ( end - start ) / ( h * 2 ); + draw->AddImage( zigzagTex, wpos + ImVec2( start, -h ), wpos + ImVec2( end, h ), ImVec2( 0, 0 ), ImVec2( v, 1 ), color ); } void DrawStripedRect( ImDrawList* draw, const ImVec2& wpos, double x0, double y0, double x1, double y1, double sw, uint32_t color, bool fix_stripes_in_screen_space, bool inverted ) diff --git a/server/TracyImGui.hpp b/server/TracyImGui.hpp index 2969038b..8e10900a 100644 --- a/server/TracyImGui.hpp +++ b/server/TracyImGui.hpp @@ -26,7 +26,7 @@ extern bool s_wasActive; bool WasActive(); -void DrawZigZag( ImDrawList* draw, const ImVec2& wpos, double start, double end, double h, uint32_t color, float thickness = 1.f ); +void DrawZigZag( ImDrawList* draw, const ImVec2& wpos, double start, double end, double h, uint32_t color ); void DrawStripedRect( ImDrawList* draw, const ImVec2& wpos, double x0, double y0, double x1, double y1, double sw, uint32_t color, bool fix_stripes_in_screen_space, bool inverted ); void DrawHistogramMinMaxLabel( ImDrawList* draw, int64_t tmin, int64_t tmax, ImVec2 wpos, float w, float ty ); diff --git a/server/TracyView_ContextSwitch.cpp b/server/TracyView_ContextSwitch.cpp index a0aa6d4e..55448a6e 100644 --- a/server/TracyView_ContextSwitch.cpp +++ b/server/TracyView_ContextSwitch.cpp @@ -294,7 +294,7 @@ void View::DrawContextSwitchList( const TimelineContext& ctx, const std::vector< } else { - DrawZigZag( draw, wpos + ImVec2( 0, offset + ty05 ), px0, minpx, ty/4, 0xFF888888, 1.5 ); + DrawZigZag( draw, wpos + ImVec2( 0, offset + ty05 ), px0, minpx, ty/4, 0xFF888888 ); if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( minpx, offset + ty + 1 ) ) ) { ImGui::BeginTooltip();