Improve performance of inventory window resize (don't update selection buffer unnecessarily)

deque
scrawl 11 years ago
parent 177de58884
commit 025f50a2df

@ -37,6 +37,7 @@ namespace MWGui
, mLastYSize(0)
, mPreview(new MWRender::InventoryPreview(MWBase::Environment::get().getWorld ()->getPlayerPtr()))
, mPreviewDirty(true)
, mPreviewResize(true)
, mDragAndDrop(dragAndDrop)
, mSelectedItem(-1)
, mGuiMode(GM_Inventory)
@ -100,6 +101,9 @@ namespace MWGui
mPreview.reset(new MWRender::InventoryPreview(mPtr));
mPreview->setup();
mPreviewDirty = true;
mPreviewResize = true;
}
void InventoryWindow::setGuiMode(GuiMode mode)
@ -132,7 +136,7 @@ namespace MWGui
Settings::Manager::getFloat(setting + " h", "Windows") * viewSize.height);
if (size.width != mMainWidget->getWidth() || size.height != mMainWidget->getHeight())
mPreviewDirty = true;
mPreviewResize = true;
mMainWidget->setPosition(pos);
mMainWidget->setSize(size);
@ -340,7 +344,7 @@ namespace MWGui
{
mLastXSize = mMainWidget->getSize().width;
mLastYSize = mMainWidget->getSize().height;
mPreviewDirty = true;
mPreviewResize = true;
}
}
@ -416,9 +420,13 @@ namespace MWGui
else
mSkippedToEquip = ptr;
mItemView->update();
if (isVisible())
{
mItemView->update();
notifyContentChanged();
notifyContentChanged();
}
// else: will be updated in open()
}
void InventoryWindow::onAvatarClicked(MyGUI::Widget* _sender)
@ -505,16 +513,22 @@ namespace MWGui
void InventoryWindow::doRenderUpdate ()
{
mPreview->onFrame();
if (mPreviewDirty)
if (mPreviewResize)
{
mPreviewDirty = false;
mPreviewResize = false;
MyGUI::IntSize size = mAvatarImage->getSize();
mPreview->update (size.width, size.height);
mPreview->resize(size.width, size.height);
mAvatarImage->setImageTexture("CharacterPreview");
mAvatarImage->setImageCoord(MyGUI::IntCoord(0, 0, std::min(512, size.width), std::min(1024, size.height)));
mAvatarImage->setImageTile(MyGUI::IntSize(std::min(512, size.width), std::min(1024, size.height)));
}
if (mPreviewDirty)
{
mPreviewDirty = false;
mPreview->update ();
mAvatarImage->setImageTexture("CharacterPreview");
mArmorRating->setCaptionWithReplacing ("#{sArmor}: "
+ boost::lexical_cast<std::string>(static_cast<int>(mPtr.getClass().getArmorRating(mPtr))));

@ -53,6 +53,7 @@ namespace MWGui
DragAndDrop* mDragAndDrop;
bool mPreviewDirty;
bool mPreviewResize;
int mSelectedItem;
MWWorld::Ptr mPtr;

@ -171,11 +171,22 @@ namespace MWRender
delete mSelectionBuffer;
}
void InventoryPreview::update(int sizeX, int sizeY)
void InventoryPreview::resize(int sizeX, int sizeY)
{
mSizeX = sizeX;
mSizeY = sizeY;
mViewport->setDimensions (0, 0, std::min(1.f, float(mSizeX) / float(512)), std::min(1.f, float(mSizeY) / float(1024)));
mTexture->load();
if (!mRenderTarget)
setupRenderTarget();
mRenderTarget->update();
}
void InventoryPreview::update()
{
mAnimation->updateParts();
MWWorld::InventoryStore &inv = mCharacter.getClass().getInventoryStore(mCharacter);

@ -81,7 +81,8 @@ namespace MWRender
virtual ~InventoryPreview();
virtual void onSetup();
void update(int sizeX, int sizeY);
void update(); // Render preview again, e.g. after changed equipment
void resize(int sizeX, int sizeY);
int getSlotSelected(int posX, int posY);

Loading…
Cancel
Save