diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-09-02 22:04:34 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-09-02 22:04:34 +0300 |
commit | 99a07142cccf792dd35b611edd1b41cb307b5847 (patch) | |
tree | 58734795019f1da88e8aa5aa12b7cc4043878fbc /src/gui/widgets/emotepage.cpp | |
parent | 370cb1fa897604e5d7bf9543881afad80f45f3ba (diff) | |
download | plus-99a07142cccf792dd35b611edd1b41cb307b5847.tar.gz plus-99a07142cccf792dd35b611edd1b41cb307b5847.tar.bz2 plus-99a07142cccf792dd35b611edd1b41cb307b5847.tar.xz plus-99a07142cccf792dd35b611edd1b41cb307b5847.zip |
improve chat emote window draw speed.
Diffstat (limited to 'src/gui/widgets/emotepage.cpp')
-rw-r--r-- | src/gui/widgets/emotepage.cpp | 63 |
1 files changed, 54 insertions, 9 deletions
diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp index 0ab05b6e3..ce61a865f 100644 --- a/src/gui/widgets/emotepage.cpp +++ b/src/gui/widgets/emotepage.cpp @@ -20,6 +20,8 @@ #include "gui/widgets/emotepage.h" +#include "graphicsvertexes.h" + #include "resources/imageset.h" #include "resources/resourcemanager.h" @@ -34,11 +36,16 @@ namespace EmotePage::EmotePage(const Widget2 *const widget) : gcn::Widget(), Widget2(widget), + gcn::MouseListener(), + gcn::WidgetListener(), mEmotes(ResourceManager::getInstance()->getImageSet( "graphics/sprites/chatemotes.png", emoteWidth, emoteHeight)), - mSelectedIndex(-1) + mVertexes(new ImageCollection), + mSelectedIndex(-1), + mRedraw(true) { addMouseListener(this); + addWidgetListener(this); } EmotePage::~EmotePage() @@ -48,6 +55,8 @@ EmotePage::~EmotePage() mEmotes->decRef(); mEmotes = nullptr; } + delete mVertexes; + mVertexes = nullptr; } void EmotePage::draw(gcn::Graphics *graphics) @@ -64,17 +73,43 @@ void EmotePage::draw(gcn::Graphics *graphics) unsigned int x = 0; unsigned int y = 0; - FOR_EACH (std::vector<Image*>::const_iterator, it, images) + if (openGLMode != RENDER_SAFE_OPENGL) + { + if (mRedraw) + { + mRedraw = false; + mVertexes->clear(); + FOR_EACH (std::vector<Image*>::const_iterator, it, images) + { + const Image *const image = *it; + if (image) + { + g->calcTile(mVertexes, image, x, y); + x += emoteWidth; + if (x + emoteWidth > width) + { + x = 0; + y += emoteHeight; + } + } + } + } + g->drawTile(mVertexes); + } + else { - const Image *const image = *it; - if (image) + FOR_EACH (std::vector<Image*>::const_iterator, it, images) { - g->drawImage(image, x, y); - x += emoteWidth; - if (x + emoteWidth > width) + const Image *const image = *it; + if (image) { - x = 0; - y += emoteHeight; + g->drawImage(image, x, y); + x += emoteWidth; + if (x + emoteWidth > width) + { + x = 0; + y += emoteHeight; + } } } } @@ -104,3 +139,13 @@ void EmotePage::resetAction() { mSelectedIndex = -1; } + +void EmotePage::widgetResized(const gcn::Event &event A_UNUSED) +{ + mRedraw = true; +} + +void EmotePage::widgetMoved(const gcn::Event &event A_UNUSED) +{ + mRedraw = true; +} |