From 2cfbdedad7488301cb72c0ba05a450bdca7f7435 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 25 May 2015 17:12:20 +0300 Subject: Add safeDraw method into emotepage. --- src/gui/widgets/emotepage.cpp | 77 ++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 33 deletions(-) (limited to 'src/gui/widgets/emotepage.cpp') diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp index d167f8bd9..7d9506546 100644 --- a/src/gui/widgets/emotepage.cpp +++ b/src/gui/widgets/emotepage.cpp @@ -65,47 +65,25 @@ void EmotePage::draw(Graphics *graphics) { BLOCK_START("EmotePage::draw") - if (!mEmotes) - return; + if (mRedraw) + { + if (!mEmotes) + return; - const std::vector &images = mEmotes->getImages(); + const std::vector &images = mEmotes->getImages(); - const unsigned int width = mDimension.width; - unsigned int x = 0; - unsigned int y = 0; + const unsigned int width = mDimension.width; + unsigned int x = 0; + unsigned int y = 0; - if (isBatchDrawRenders(openGLMode)) - { - if (mRedraw) - { - mRedraw = false; - mVertexes->clear(); - FOR_EACH (std::vector::const_iterator, it, images) - { - const Image *const image = *it; - if (image) - { - graphics->calcTileCollection(mVertexes, image, x, y); - x += emoteWidth; - if (x + emoteWidth > width) - { - x = 0; - y += emoteHeight; - } - } - } - graphics->finalize(mVertexes); - } - graphics->drawTileCollection(mVertexes); - } - else - { + mRedraw = false; + mVertexes->clear(); FOR_EACH (std::vector::const_iterator, it, images) { const Image *const image = *it; if (image) { - graphics->drawImage(image, x, y); + graphics->calcTileCollection(mVertexes, image, x, y); x += emoteWidth; if (x + emoteWidth > width) { @@ -114,11 +92,44 @@ void EmotePage::draw(Graphics *graphics) } } } + graphics->finalize(mVertexes); } + graphics->drawTileCollection(mVertexes); BLOCK_END("EmotePage::draw") } +void EmotePage::safeDraw(Graphics *graphics) +{ + BLOCK_START("EmotePage::safeDraw") + + if (!mEmotes) + return; + + const std::vector &images = mEmotes->getImages(); + + const unsigned int width = mDimension.width; + unsigned int x = 0; + unsigned int y = 0; + + FOR_EACH (std::vector::const_iterator, it, images) + { + const Image *const image = *it; + if (image) + { + graphics->drawImage(image, x, y); + x += emoteWidth; + if (x + emoteWidth > width) + { + x = 0; + y += emoteHeight; + } + } + } + + BLOCK_END("EmotePage::safeDraw") +} + void EmotePage::mousePressed(MouseEvent &event) { mSelectedIndex = getIndexFromGrid(event.getX(), event.getY()); -- cgit v1.2.3-60-g2f50