From 8ca67e49e4da44a580a3723a5ed079d09a8fc382 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 16 Nov 2019 22:58:51 +0100 Subject: [PATCH] Scale frame images in tooltips according to DPI scaling. --- server/TracyView.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 6e0f8c87..c08579b8 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -1102,7 +1102,8 @@ void View::DrawFrames() { assert( m_worker.GetFrameCount( *m_frames ) != 0 ); - const auto Height = 50 * ImGui::GetTextLineHeight() / 15.f; + const auto scale = ImGui::GetTextLineHeight() / 15.f; + const auto Height = 50 * scale; enum { MaxFrameTime = 50 * 1000 * 1000 }; // 50ms @@ -1252,11 +1253,11 @@ void View::DrawFrames() ImGui::Separator(); if( fi->flip ) { - ImGui::Image( m_frameTexture, ImVec2( fi->w, fi->h ), ImVec2( 0, 1 ), ImVec2( 1, 0 ) ); + ImGui::Image( m_frameTexture, ImVec2( fi->w * scale, fi->h * scale ), ImVec2( 0, 1 ), ImVec2( 1, 0 ) ); } else { - ImGui::Image( m_frameTexture, ImVec2( fi->w, fi->h ) ); + ImGui::Image( m_frameTexture, ImVec2( fi->w * scale, fi->h * scale ) ); } } ImGui::EndTooltip(); @@ -1795,6 +1796,7 @@ bool View::DrawZoneFrames( const FrameData& frames ) auto fi = m_worker.GetFrameImage( frames, i ); if( fi ) { + const auto scale = ImGui::GetTextLineHeight() / 15.f; if( fi != m_frameTexturePtr ) { if( !m_frameTexture ) m_frameTexture = MakeTexture(); @@ -1804,11 +1806,11 @@ bool View::DrawZoneFrames( const FrameData& frames ) ImGui::Separator(); if( fi->flip ) { - ImGui::Image( m_frameTexture, ImVec2( fi->w, fi->h ), ImVec2( 0, 1 ), ImVec2( 1, 0 ) ); + ImGui::Image( m_frameTexture, ImVec2( fi->w * scale, fi->h * scale ), ImVec2( 0, 1 ), ImVec2( 1, 0 ) ); } else { - ImGui::Image( m_frameTexture, ImVec2( fi->w, fi->h ) ); + ImGui::Image( m_frameTexture, ImVec2( fi->w * scale, fi->h * scale ) ); } if( ImGui::GetIO().KeyCtrl && ImGui::IsMouseClicked( 0 ) )