summaryrefslogtreecommitdiff
path: root/src/gui/widgets/tab.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-03-26 05:07:12 +0200
committerAndrei Karas <akaras@inbox.ru>2011-03-26 05:50:44 +0200
commit8403dcf857c9cc639e8162edd5d4df4af07274bc (patch)
tree2f127213e0df4691b06c549a8f20b3d5225b9220 /src/gui/widgets/tab.cpp
parentfc24490f1ecd186f3c294915fadee62c3053d841 (diff)
downloadmanaplus-8403dcf857c9cc639e8162edd5d4df4af07274bc.tar.gz
manaplus-8403dcf857c9cc639e8162edd5d4df4af07274bc.tar.bz2
manaplus-8403dcf857c9cc639e8162edd5d4df4af07274bc.tar.xz
manaplus-8403dcf857c9cc639e8162edd5d4df4af07274bc.zip
Precalculation vertexes for improving draw speed.
Implemented in Software and fast OpenGL backends. Not all controls using this mode because some limitations. Known issue: impossible compile without opengl. Will be fixed in next commits.
Diffstat (limited to 'src/gui/widgets/tab.cpp')
-rw-r--r--src/gui/widgets/tab.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index 6a2b05cd4..78165dc18 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -25,6 +25,7 @@
#include "client.h"
#include "configuration.h"
#include "graphics.h"
+#include "graphicsvertexes.h"
#include "log.h"
#include "gui/palette.h"
@@ -68,7 +69,10 @@ static TabData const data[TAB_COUNT] =
ImageRect Tab::tabImg[TAB_COUNT];
Tab::Tab() : gcn::Tab(),
- mTabColor(&Theme::getThemeColor(Theme::TAB))
+ mTabColor(&Theme::getThemeColor(Theme::TAB)),
+ mVertexes(new GraphicsVertexes()),
+ mRedraw(true),
+ mMode(0)
{
init();
}
@@ -82,6 +86,8 @@ Tab::~Tab()
for (int mode = 0; mode < TAB_COUNT; mode++)
for_each(tabImg[mode].grid, tabImg[mode].grid + 9, dtor<Image*>());
}
+ delete mVertexes;
+ mVertexes = 0;
}
void Tab::init()
@@ -90,6 +96,8 @@ void Tab::init()
setFrameSize(0);
mFlash = 0;
+ addWidgetListener(this);
+
if (mInstances == 0)
{
// Load the skin
@@ -179,8 +187,18 @@ void Tab::draw(gcn::Graphics *graphics)
updateAlpha();
// draw tab
- static_cast<Graphics*>(graphics)->
- drawImageRect(0, 0, getWidth(), getHeight(), tabImg[mode]);
+ if (mRedraw || mode != mMode)
+ {
+ mMode = mode;
+ mRedraw = false;
+ static_cast<Graphics*>(graphics)->calcWindow(mVertexes, 0, 0, getWidth(),
+ getHeight(), tabImg[mode]);
+ }
+
+ static_cast<Graphics*>(graphics)->drawImageRect2(mVertexes, tabImg[mode]);
+
+// static_cast<Graphics*>(graphics)->
+// drawImageRect(0, 0, getWidth(), getHeight(), tabImg[mode]);
// draw label
drawChildren(graphics);
@@ -195,3 +213,13 @@ void Tab::setFlash(int flash)
{
mFlash = flash;
}
+
+void Tab::widgetResized(const gcn::Event &event _UNUSED_)
+{
+ mRedraw = true;
+}
+
+void Tab::widgetMoved(const gcn::Event &event _UNUSED_)
+{
+ mRedraw = true;
+}