mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Optimize drawing messages.
This commit is contained in:
parent
d21040e3d8
commit
e5865cb23e
@ -1839,7 +1839,7 @@ void View::DrawZones()
|
|||||||
ImGui::InvisibleButton( "##zones", ImVec2( w, h ) );
|
ImGui::InvisibleButton( "##zones", ImVec2( w, h ) );
|
||||||
bool hover = ImGui::IsItemHovered();
|
bool hover = ImGui::IsItemHovered();
|
||||||
|
|
||||||
auto timespan = m_zvEnd - m_zvStart;
|
const auto timespan = m_zvEnd - m_zvStart;
|
||||||
auto pxns = w / double( timespan );
|
auto pxns = w / double( timespan );
|
||||||
|
|
||||||
if( hover )
|
if( hover )
|
||||||
@ -1848,6 +1848,8 @@ void View::DrawZones()
|
|||||||
HandleZoneViewMouse( timespan, wpos, w, pxns );
|
HandleZoneViewMouse( timespan, wpos, w, pxns );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto nspx = 1.0 / pxns;
|
||||||
|
|
||||||
// zones
|
// zones
|
||||||
LockHighlight nextLockHighlight { -1 };
|
LockHighlight nextLockHighlight { -1 };
|
||||||
const auto ty = ImGui::GetFontSize();
|
const auto ty = ImGui::GetFontSize();
|
||||||
@ -1870,17 +1872,31 @@ void View::DrawZones()
|
|||||||
|
|
||||||
while( it < end )
|
while( it < end )
|
||||||
{
|
{
|
||||||
|
const auto next = std::upper_bound( it, v->messages.end(), (*it)->time + MinVisSize * nspx, [] ( const auto& lhs, const auto& rhs ) { return lhs < rhs->time; } );
|
||||||
|
const auto dist = std::distance( it, next );
|
||||||
|
|
||||||
const auto px = ( (*it)->time - m_zvStart ) * pxns;
|
const auto px = ( (*it)->time - m_zvStart ) * pxns;
|
||||||
|
if( dist > 1 )
|
||||||
|
{
|
||||||
|
draw->AddTriangleFilled( wpos + ImVec2( px - (ty - to) * 0.5, offset + to ), wpos + ImVec2( px + (ty - to) * 0.5, offset + to ), wpos + ImVec2( px, offset + to + th ), 0xFFDDDDDD );
|
||||||
|
}
|
||||||
draw->AddTriangle( wpos + ImVec2( px - (ty - to) * 0.5, offset + to ), wpos + ImVec2( px + (ty - to) * 0.5, offset + to ), wpos + ImVec2( px, offset + to + th ), 0xFFDDDDDD );
|
draw->AddTriangle( wpos + ImVec2( px - (ty - to) * 0.5, offset + to ), wpos + ImVec2( px + (ty - to) * 0.5, offset + to ), wpos + ImVec2( px, offset + to + th ), 0xFFDDDDDD );
|
||||||
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( px - (ty - to) * 0.5 - 1, offset ), wpos + ImVec2( px + (ty - to) * 0.5 + 1, offset + ty ) ) )
|
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( px - (ty - to) * 0.5 - 1, offset ), wpos + ImVec2( px + (ty - to) * 0.5 + 1, offset + ty ) ) )
|
||||||
{
|
{
|
||||||
ImGui::BeginTooltip();
|
ImGui::BeginTooltip();
|
||||||
ImGui::Text( "%s", TimeToString( (*it)->time - m_frames[0] ) );
|
if( dist > 1 )
|
||||||
ImGui::Text( "%s", (*it)->literal ? GetString( (*it)->str ) : (*it)->txt );
|
{
|
||||||
|
ImGui::Text( "%i messages", (int)dist );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGui::Text( "%s", TimeToString( (*it)->time - m_frames[0] ) );
|
||||||
|
ImGui::Text( "%s", (*it)->literal ? GetString( (*it)->str ) : (*it)->txt );
|
||||||
|
}
|
||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
m_msgHighlight = *it;
|
m_msgHighlight = *it;
|
||||||
}
|
}
|
||||||
++it;
|
it = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user