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/scrollarea.cpp | 56 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) (limited to 'src/gui/widgets/scrollarea.cpp') 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)->getTopClip(); + if (rect.xOffset != mXOffset || rect.yOffset != mYOffset) + { + recalc = true; + mXOffset = rect.xOffset; + mYOffset = rect.yOffset; + } + } + + if (recalc) + { + mRedraw = false; + static_cast(graphics)->calcWindow( + mVertexes, 0, 0, w, h, background); + } + + static_cast(graphics)-> - drawImageRect(0, 0, w, h, background); + drawImageRect2(mVertexes, background); + +// static_cast(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; +} -- cgit v1.2.3-60-g2f50