From 7201cf5fe281507962c3b47ba65111e2b2572ded Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 4 Feb 2017 16:22:38 +0100 Subject: [PATCH] ItemWidget: skip setImageTexture if the icon has not changed --- apps/openmw/mwgui/itemwidget.cpp | 22 +++++++++++++++++----- apps/openmw/mwgui/itemwidget.hpp | 3 +++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwgui/itemwidget.cpp b/apps/openmw/mwgui/itemwidget.cpp index fe7cb79de..a31eb9c76 100644 --- a/apps/openmw/mwgui/itemwidget.cpp +++ b/apps/openmw/mwgui/itemwidget.cpp @@ -67,20 +67,30 @@ namespace MWGui void ItemWidget::setIcon(const std::string &icon) { - if (mItemShadow) - mItemShadow->setImageTexture(icon); - if (mItem) - mItem->setImageTexture(icon); + if (mCurrentIcon != icon) + { + mCurrentIcon = icon; + + if (mItemShadow) + mItemShadow->setImageTexture(icon); + if (mItem) + mItem->setImageTexture(icon); + } } void ItemWidget::setFrame(const std::string &frame, const MyGUI::IntCoord &coord) { if (mFrame) { - mFrame->setImageTexture(frame); mFrame->setImageTile(MyGUI::IntSize(coord.width, coord.height)); // Why is this needed? MyGUI bug? mFrame->setImageCoord(coord); } + + if (mCurrentFrame != frame) + { + mCurrentFrame = frame; + mFrame->setImageTexture(frame); + } } void ItemWidget::setIcon(const MWWorld::Ptr &ptr) @@ -105,6 +115,8 @@ namespace MWGui mItemShadow->setImageTexture(""); mItem->setImageTexture(""); mText->setCaption(""); + mCurrentIcon.clear(); + mCurrentFrame.clear(); return; } diff --git a/apps/openmw/mwgui/itemwidget.hpp b/apps/openmw/mwgui/itemwidget.hpp index ce9f58f50..dd1717d11 100644 --- a/apps/openmw/mwgui/itemwidget.hpp +++ b/apps/openmw/mwgui/itemwidget.hpp @@ -47,6 +47,9 @@ namespace MWGui MyGUI::ImageBox* mItemShadow; MyGUI::ImageBox* mFrame; MyGUI::TextBox* mText; + + std::string mCurrentIcon; + std::string mCurrentFrame; }; }