From 937e8601f3091c72c23e4b9621662dc5239209a0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 2 Sep 2013 23:58:55 +0300 Subject: improve avatarlistbox draw speed. --- src/gui/widgets/avatarlistbox.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index aacb3aabe..7b6b0d611 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -23,6 +23,7 @@ #include "actorspritemanager.h" #include "configuration.h" +#include "graphicsvertexes.h" #include "guild.h" #include "maplayer.h" @@ -111,6 +112,9 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) // Draw the list elements graphics->setColorAll(mForegroundColor, mForegroundColor2); + ImageCollection vertexes; + const bool useCaching = openGLMode != RENDER_SAFE_OPENGL; + for (int i = 0, y = 0; i < model->getNumberOfElements(); ++i, y += fontHeight) @@ -125,7 +129,17 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) const Image *const icon = a->getOnline() ? onlineIcon : offlineIcon; if (icon) - graphics->drawImage(icon, mImagePadding, y + mPadding); + { + if (useCaching) + { + graphics->calcTile(&vertexes, icon, + mImagePadding, y + mPadding); + } + else + { + graphics->drawImage(icon, mImagePadding, y + mPadding); + } + } } std::string text; @@ -290,6 +304,9 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) } } + if (useCaching) + graphics->drawTile(&vertexes); + if (parent) setWidth(parent->getWidth() - 10); BLOCK_END("AvatarListBox::draw") -- cgit v1.2.3-70-g09d2