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/popup.cpp | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'src/gui/widgets/popup.cpp') diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 3d9c3b449..7519d1583 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -25,12 +25,14 @@ #include "configuration.h" #include "graphics.h" +#include "graphicsvertexes.h" #include "log.h" #include "gui/theme.h" #include "gui/viewport.h" #include "gui/widgets/windowcontainer.h" +#include "gui/widgets/window.h" #include "resources/image.h" @@ -41,13 +43,17 @@ Popup::Popup(const std::string &name, const std::string &skin): mMinWidth(100), mMinHeight(40), mMaxWidth(graphics->getWidth()), - mMaxHeight(graphics->getHeight()) + mMaxHeight(graphics->getHeight()), + mVertexes(new GraphicsVertexes()), + mRedraw(true) { logger->log("Popup::Popup(\"%s\")", name.c_str()); if (!windowContainer) throw GCN_EXCEPTION("Popup::Popup(): no windowContainer set"); + addWidgetListener(this); + setPadding(3); // Loads the skin @@ -64,6 +70,9 @@ Popup::~Popup() { logger->log("Popup::~Popup(\"%s\")", mPopupName.c_str()); + delete mVertexes; + mVertexes = 0; + if (mSkin) mSkin->instances--; } @@ -77,7 +86,16 @@ void Popup::draw(gcn::Graphics *graphics) { Graphics *g = static_cast(graphics); - g->drawImageRect(0, 0, getWidth(), getHeight(), mSkin->getBorder()); + if (mRedraw) + { + mRedraw = false; + g->calcWindow(mVertexes, 0, 0, getWidth(), + getHeight(), mSkin->getBorder()); + } + + g->drawImageRect2(mVertexes, mSkin->getBorder()); + +// g->drawImageRect(0, 0, getWidth(), getHeight(), mSkin->getBorder()); drawChildren(graphics); } @@ -103,6 +121,7 @@ void Popup::setContentSize(int width, int height) height = getMaxHeight(); setSize(width, height); + mRedraw = true; } void Popup::setLocationRelativeTo(gcn::Widget *widget) @@ -118,6 +137,7 @@ void Popup::setLocationRelativeTo(gcn::Widget *widget) setPosition(getX() + (wx + (widget->getWidth() - getWidth()) / 2 - x), getY() + (wy + (widget->getHeight() - getHeight()) / 2 - y)); + mRedraw = true; } void Popup::setMinWidth(int width) @@ -161,15 +181,28 @@ void Popup::position(int x, int y) setPosition(posX, posY); setVisible(true); requestMoveToTop(); + mRedraw = true; } void Popup::mouseMoved(gcn::MouseEvent &event _UNUSED_) { if (viewport) viewport->hideBeingPopup(); + mRedraw = true; } void Popup::hide() { setVisible(false); -} \ No newline at end of file + mRedraw = true; +} + +void Popup::widgetResized(const gcn::Event &event _UNUSED_) +{ + mRedraw = true; +} + +void Popup::widgetMoved(const gcn::Event &event _UNUSED_) +{ + mRedraw = true; +} -- cgit v1.2.3-60-g2f50