Don't draw off-screen plots.

This commit is contained in:
Bartosz Taudul 2018-04-20 23:00:26 +02:00
parent cd7a1cffe8
commit 9fc14d2faf
2 changed files with 155 additions and 144 deletions

View File

@ -1055,7 +1055,7 @@ void View::DrawZones()
if( m_drawPlots ) if( m_drawPlots )
{ {
offset = DrawPlots( offset, pxns, wpos, hover ); offset = DrawPlots( offset, pxns, wpos, hover, yMin, yMax );
} }
const auto scrollPos = ImGui::GetScrollY(); const auto scrollPos = ImGui::GetScrollY();
@ -2206,7 +2206,7 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
enum { PlotHeight = 100 }; enum { PlotHeight = 100 };
int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover ) int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, float yMin, float yMax )
{ {
enum { MaxPoints = 512 }; enum { MaxPoints = 512 };
float tmpvec[MaxPoints*2]; float tmpvec[MaxPoints*2];
@ -2221,10 +2221,12 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover )
for( const auto& v : m_worker.GetPlots() ) for( const auto& v : m_worker.GetPlots() )
{ {
if( !Visible( v ) ) continue; if( !Visible( v ) ) continue;
assert( !v->data.empty() ); assert( !v->data.empty() );
bool& showFull = ShowFull( v ); bool& showFull = ShowFull( v );
auto yPos = wpos.y + offset;
if( yPos + ty >= yMin && yPos <= yMax )
{
if( showFull ) if( showFull )
{ {
draw->AddTriangleFilled( wpos + ImVec2( to/2, offset + to/2 ), wpos + ImVec2( ty - to/2, offset + to/2 ), wpos + ImVec2( ty * 0.5, offset + to/2 + th ), 0xFF44DDDD ); draw->AddTriangleFilled( wpos + ImVec2( to/2, offset + to/2 ), wpos + ImVec2( ty - to/2, offset + to/2 ), wpos + ImVec2( ty * 0.5, offset + to/2 + th ), 0xFF44DDDD );
@ -2265,10 +2267,14 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover )
ImGui::EndTooltip(); ImGui::EndTooltip();
} }
}
offset += ty; offset += ty;
if( showFull ) if( showFull )
{
auto yPos = wpos.y + offset;
if( yPos + PlotHeight >= yMin && yPos <= yMax )
{ {
const auto& vec = v->data; const auto& vec = v->data;
auto it = std::lower_bound( vec.begin(), vec.end(), m_zvStart - m_worker.GetDelay(), [] ( const auto& l, const auto& r ) { return l.time < r; } ); auto it = std::lower_bound( vec.begin(), vec.end(), m_zvStart - m_worker.GetDelay(), [] ( const auto& l, const auto& r ) { return l.time < r; } );
@ -2387,6 +2393,11 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover )
draw->AddLine( wpos + ImVec2( 0, offset + ty - 1 ), wpos + ImVec2( w, offset + ty - 1 ), 0x8844DDDD ); draw->AddLine( wpos + ImVec2( 0, offset + ty - 1 ), wpos + ImVec2( w, offset + ty - 1 ), 0x8844DDDD );
offset += ty; offset += ty;
} }
else
{
offset += PlotHeight;
}
}
offset += 0.2 * ty; offset += 0.2 * ty;
} }

View File

@ -69,7 +69,7 @@ private:
int DrawZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth ); int DrawZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth );
int DrawGpuZoneLevel( const Vector<GpuEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth, uint64_t thread ); int DrawGpuZoneLevel( const Vector<GpuEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth, uint64_t thread );
int DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, int offset, LockHighlight& highlight, float yMin, float yMax ); int DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, int offset, LockHighlight& highlight, float yMin, float yMax );
int DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover ); int DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, float yMin, float yMax );
void DrawPlotPoint( const ImVec2& wpos, float x, float y, int offset, uint32_t color, bool hover, bool hasPrev, double val, double prev, bool merged ); void DrawPlotPoint( const ImVec2& wpos, float x, float y, int offset, uint32_t color, bool hover, bool hasPrev, double val, double prev, bool merged );
void DrawOptions(); void DrawOptions();
void DrawMessages(); void DrawMessages();