mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-25 23:44:35 +00:00
Move drawing of a single zone line to a separate function.
This commit is contained in:
parent
73df330dd5
commit
c9a982360f
@ -918,47 +918,53 @@ void View::DrawZones()
|
||||
draw->AddText( wpos + ImVec2( 0, offset ), 0xFFFFFFFF, GetThreadString( v.id ) );
|
||||
offset += ostep;
|
||||
|
||||
auto& timeline = v.timeline;
|
||||
auto it = std::lower_bound( timeline.begin(), timeline.end(), m_zvStart, [] ( const auto& l, const auto& r ) { return l->end < r; } );
|
||||
if( it != timeline.end() )
|
||||
{
|
||||
const auto zitend = std::lower_bound( timeline.begin(), timeline.end(), m_zvEnd, [] ( const auto& l, const auto& r ) { return l->start < r; } );
|
||||
while( it < zitend )
|
||||
{
|
||||
auto& ev = **it;
|
||||
const auto& srcFile = m_srcFile[ev.srcloc];
|
||||
const char* func = GetString( srcFile.function );
|
||||
const auto end = GetZoneEnd( ev );
|
||||
const auto zsz = ( ev.end - ev.start ) * pxns;
|
||||
const auto tsz = ImGui::CalcTextSize( func );
|
||||
draw->AddRectFilled( wpos + ImVec2( ( ev.start - m_zvStart ) * pxns, offset ), wpos + ImVec2( ( end - m_zvStart ) * pxns, offset + tsz.y ), 0xDDDD6666, 2.f );
|
||||
draw->AddRect( wpos + ImVec2( ( ev.start - m_zvStart ) * pxns, offset ), wpos + ImVec2( ( end - m_zvStart ) * pxns, offset + tsz.y ), 0xAAAAAAAA, 2.f );
|
||||
if( tsz.x < zsz )
|
||||
{
|
||||
draw->AddText( wpos + ImVec2( ( ev.start - m_zvStart ) * pxns + ( ( end - ev.start ) * pxns - tsz.x ) / 2, offset ), 0xFFFFFFFF, func );
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::PushClipRect( wpos + ImVec2( ( ev.start - m_zvStart ) * pxns, offset ), wpos + ImVec2( ( end - m_zvStart ) * pxns, offset + tsz.y ), true );
|
||||
draw->AddText( wpos + ImVec2( ( ev.start - m_zvStart ) * pxns, offset ), 0xFFFFFFFF, func );
|
||||
ImGui::PopClipRect();
|
||||
}
|
||||
|
||||
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( ( ev.start - m_zvStart ) * pxns, offset ), wpos + ImVec2( ( end - m_zvStart ) * pxns, offset + tsz.y ) ) )
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text( "%s", func );
|
||||
ImGui::Text( "%s:%i", GetString( srcFile.filename ), srcFile.line );
|
||||
ImGui::Text( "Execution time: %s", TimeToString( end - ev.start ) );
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
it++;
|
||||
}
|
||||
}
|
||||
DrawZoneLevel( v.timeline, hover, pxns, wpos, offset );
|
||||
|
||||
offset += ostep * 1.2f;
|
||||
}
|
||||
}
|
||||
|
||||
void View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset )
|
||||
{
|
||||
auto it = std::lower_bound( vec.begin(), vec.end(), m_zvStart, [] ( const auto& l, const auto& r ) { return l->end < r; } );
|
||||
if( it != vec.end() )
|
||||
{
|
||||
auto draw = ImGui::GetWindowDrawList();
|
||||
|
||||
const auto zitend = std::lower_bound( vec.begin(), vec.end(), m_zvEnd, [] ( const auto& l, const auto& r ) { return l->start < r; } );
|
||||
while( it < zitend )
|
||||
{
|
||||
auto& ev = **it;
|
||||
const auto& srcFile = m_srcFile[ev.srcloc];
|
||||
const char* func = GetString( srcFile.function );
|
||||
const auto end = GetZoneEnd( ev );
|
||||
const auto zsz = ( ev.end - ev.start ) * pxns;
|
||||
const auto tsz = ImGui::CalcTextSize( func );
|
||||
draw->AddRectFilled( wpos + ImVec2( ( ev.start - m_zvStart ) * pxns, offset ), wpos + ImVec2( ( end - m_zvStart ) * pxns, offset + tsz.y ), 0xDDDD6666, 2.f );
|
||||
draw->AddRect( wpos + ImVec2( ( ev.start - m_zvStart ) * pxns, offset ), wpos + ImVec2( ( end - m_zvStart ) * pxns, offset + tsz.y ), 0xAAAAAAAA, 2.f );
|
||||
if( tsz.x < zsz )
|
||||
{
|
||||
draw->AddText( wpos + ImVec2( ( ev.start - m_zvStart ) * pxns + ( ( end - ev.start ) * pxns - tsz.x ) / 2, offset ), 0xFFFFFFFF, func );
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::PushClipRect( wpos + ImVec2( ( ev.start - m_zvStart ) * pxns, offset ), wpos + ImVec2( ( end - m_zvStart ) * pxns, offset + tsz.y ), true );
|
||||
draw->AddText( wpos + ImVec2( ( ev.start - m_zvStart ) * pxns, offset ), 0xFFFFFFFF, func );
|
||||
ImGui::PopClipRect();
|
||||
}
|
||||
|
||||
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( ( ev.start - m_zvStart ) * pxns, offset ), wpos + ImVec2( ( end - m_zvStart ) * pxns, offset + tsz.y ) ) )
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text( "%s", func );
|
||||
ImGui::Text( "%s:%i", GetString( srcFile.filename ), srcFile.line );
|
||||
ImGui::Text( "Execution time: %s", TimeToString( end - ev.start ) );
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include "TracySourceLocation.hpp"
|
||||
#include "TracyVector.hpp"
|
||||
|
||||
struct ImVec2;
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
@ -71,6 +73,7 @@ private:
|
||||
void DrawImpl();
|
||||
void DrawFrames();
|
||||
void DrawZones();
|
||||
void DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset );
|
||||
|
||||
std::string m_addr;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user