Skip to content

Commit

Permalink
show both costs in flamegraph
Browse files Browse the repository at this point in the history
  • Loading branch information
lievenhey committed Sep 15, 2022
1 parent 5312c28 commit 6833b8d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/flamegraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,24 @@ void FrameGraphicsItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*
QColor::fromHsv((color.hue() + 120) % 360, color.saturation(), color.value(), color.alpha());

if (cost() > secondaryCost()) {
const auto width = rect().width() * static_cast<float>(secondaryCost()) / (cost() + secondaryCost());
const auto width = rect().width() * static_cast<float>(secondaryCost()) / (cost());
auto mainRect = rect();
mainRect.setWidth(rect().width() - width);
mainRect.setHeight(mainRect.height() / 2);
painter->fillRect(mainRect, color);
auto secondaryRect = rect();
secondaryRect.setWidth(width);
secondaryRect.moveRight(rect().right());
secondaryRect.setHeight(mainRect.height());
secondaryRect.moveBottom(rect().bottom());
painter->fillRect(secondaryRect, secondaryColor);
} else {
const auto width = rect().width() * static_cast<float>(cost()) / (secondaryCost() + cost());
const auto width = rect().width() * static_cast<float>(cost()) / (secondaryCost());
auto mainRect = rect();
// mainRect.setWidth(rect().width() - width);
mainRect.moveRight(rect().right());
mainRect.setWidth(width);
mainRect.setHeight(mainRect.height() / 2);
painter->fillRect(mainRect, color);
auto secondaryRect = rect();
secondaryRect.setWidth(width);
secondaryRect.moveRight(rect().right());
secondaryRect.setHeight(mainRect.height());
secondaryRect.moveBottom(rect().bottom());

painter->fillRect(secondaryRect, secondaryColor);
}
Expand Down

0 comments on commit 6833b8d

Please sign in to comment.