From 8403dcf857c9cc639e8162edd5d4df4af07274bc Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 26 Mar 2011 05:07:12 +0200 Subject: 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. --- src/gui/widgets/tab.cpp | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'src/gui/widgets/tab.cpp') 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()); } + 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)-> - drawImageRect(0, 0, getWidth(), getHeight(), tabImg[mode]); + if (mRedraw || mode != mMode) + { + mMode = mode; + mRedraw = false; + static_cast(graphics)->calcWindow(mVertexes, 0, 0, getWidth(), + getHeight(), tabImg[mode]); + } + + static_cast(graphics)->drawImageRect2(mVertexes, tabImg[mode]); + +// static_cast(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; +} -- cgit v1.2.3-60-g2f50