diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-03-26 05:07:12 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-03-26 05:50:44 +0200 |
commit | 8403dcf857c9cc639e8162edd5d4df4af07274bc (patch) | |
tree | 2f127213e0df4691b06c549a8f20b3d5225b9220 /src/gui/widgets/scrollarea.cpp | |
parent | fc24490f1ecd186f3c294915fadee62c3053d841 (diff) | |
download | mv-8403dcf857c9cc639e8162edd5d4df4af07274bc.tar.gz mv-8403dcf857c9cc639e8162edd5d4df4af07274bc.tar.bz2 mv-8403dcf857c9cc639e8162edd5d4df4af07274bc.tar.xz mv-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/scrollarea.cpp')
-rw-r--r-- | src/gui/widgets/scrollarea.cpp | 56 |
1 files changed, 53 insertions, 3 deletions
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index b11213239..2cc745ccd 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -25,6 +25,7 @@ #include "client.h" #include "configuration.h" #include "graphics.h" +#include "graphicsvertexes.h" #include "log.h" #include "gui/theme.h" @@ -45,7 +46,11 @@ ScrollArea::ScrollArea(): mX(0), mY(0), mHasMouse(false), - mOpaque(true) + mOpaque(true), + mVertexes(new GraphicsVertexes()), + mRedraw(true), + mXOffset(0), + mYOffset(0) { addWidgetListener(this); init(); @@ -56,8 +61,13 @@ ScrollArea::ScrollArea(gcn::Widget *widget): mX(0), mY(0), mHasMouse(false), - mOpaque(true) + mOpaque(true), + mVertexes(new GraphicsVertexes()), + mRedraw(true), + mXOffset(0), + mYOffset(0) { + addWidgetListener(this); init(); } @@ -91,6 +101,8 @@ ScrollArea::~ScrollArea() if (buttons[RIGHT][1]) buttons[RIGHT][1]->decRef(); } + delete mVertexes; + mVertexes = 0; } void ScrollArea::init() @@ -286,6 +298,7 @@ void ScrollArea::draw(gcn::Graphics *graphics) drawHMarker(graphics); } + if (mHBarVisible && mVBarVisible) { graphics->setColor(getBaseColor()); @@ -300,6 +313,7 @@ void ScrollArea::draw(gcn::Graphics *graphics) drawChildren(graphics); } +//void ScrollArea::drawFrame(gcn::Graphics *graphics _UNUSED_) void ScrollArea::drawFrame(gcn::Graphics *graphics) { if (mOpaque) @@ -308,8 +322,38 @@ void ScrollArea::drawFrame(gcn::Graphics *graphics) const int w = getWidth() + bs * 2; const int h = getHeight() + bs * 2; + bool recalc = false; + if (mRedraw) + { + recalc = true; + } + else + { + // because we dont know where parent windows was moved, + // need recalc vertexes + gcn::ClipRectangle &rect = static_cast<Graphics*>( + graphics)->getTopClip(); + if (rect.xOffset != mXOffset || rect.yOffset != mYOffset) + { + recalc = true; + mXOffset = rect.xOffset; + mYOffset = rect.yOffset; + } + } + + if (recalc) + { + mRedraw = false; + static_cast<Graphics*>(graphics)->calcWindow( + mVertexes, 0, 0, w, h, background); + } + + static_cast<Graphics*>(graphics)-> - drawImageRect(0, 0, w, h, background); + drawImageRect2(mVertexes, background); + +// static_cast<Graphics*>(graphics)-> +// drawImageRect(0, 0, w, h, background); } } @@ -441,6 +485,12 @@ void ScrollArea::mouseExited(gcn::MouseEvent& event _UNUSED_) void ScrollArea::widgetResized(const gcn::Event &event _UNUSED_) { + mRedraw = true; getContent()->setSize(getWidth() - 2 * getFrameSize(), getHeight() - 2 * getFrameSize()); } + +void ScrollArea::widgetMoved(const gcn::Event& event _UNUSED_) +{ + mRedraw = true; +} |