diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-11-06 21:13:16 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-11-07 12:46:08 +0300 |
commit | d812d9fac7bae4eff66a5ce8275be19d0ca77a32 (patch) | |
tree | 7f9619d23a44202a76282849bb1284773302309f /src/gui | |
parent | 1bcaac517036751a8fee9ff3d6561f5866e6969e (diff) | |
download | plus-d812d9fac7bae4eff66a5ce8275be19d0ca77a32.tar.gz plus-d812d9fac7bae4eff66a5ce8275be19d0ca77a32.tar.bz2 plus-d812d9fac7bae4eff66a5ce8275be19d0ca77a32.tar.xz plus-d812d9fac7bae4eff66a5ce8275be19d0ca77a32.zip |
Add own profiler and profiler info to some code.
Diffstat (limited to 'src/gui')
51 files changed, 202 insertions, 5 deletions
diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index 4f3381dec..3164ca7c5 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -351,6 +351,7 @@ BotCheckerWindow::~BotCheckerWindow() void BotCheckerWindow::slowLogic() { + BLOCK_START("BotCheckerWindow::slowLogic") if (mEnabled && mTableModel) { const unsigned int nowTime = cur_time; @@ -367,6 +368,7 @@ void BotCheckerWindow::slowLogic() mLastUpdateTime = nowTime; } } + BLOCK_END("BotCheckerWindow::slowLogic") } void BotCheckerWindow::action(const gcn::ActionEvent &event) diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 47f6be680..2e78c048c 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -1693,8 +1693,10 @@ void ChatWindow::mouseExited(gcn::MouseEvent& mouseEvent) void ChatWindow::draw(gcn::Graphics* graphics) { + BLOCK_START("ChatWindow::draw") if (!mAutoHide || mHaveMouse) Window::draw(graphics); + BLOCK_END("ChatWindow::draw") } void ChatWindow::updateVisibility() diff --git a/src/gui/connectiondialog.cpp b/src/gui/connectiondialog.cpp index 770507c38..c92f5f53e 100644 --- a/src/gui/connectiondialog.cpp +++ b/src/gui/connectiondialog.cpp @@ -63,6 +63,8 @@ void ConnectionDialog::action(const gcn::ActionEvent &) void ConnectionDialog::draw(gcn::Graphics *graphics) { + BLOCK_START("ConnectionDialog::draw") // Don't draw the window background, only draw the children drawChildren(graphics); + BLOCK_END("ConnectionDialog::draw") } diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index 08ea48dd3..11a8ca3c0 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -90,8 +90,12 @@ DebugWindow::~DebugWindow() void DebugWindow::slowLogic() { + BLOCK_START("DebugWindow::slowLogic") if (!isVisible() || !mTabs) + { + BLOCK_END("DebugWindow::slowLogic") return; + } switch (mTabs->getSelectedTabIndex()) { @@ -109,10 +113,12 @@ void DebugWindow::slowLogic() if (player_node) player_node->tryPingRequest(); + BLOCK_END("DebugWindow::slowLogic") } void DebugWindow::draw(gcn::Graphics *g) { + BLOCK_START("DebugWindow::draw") Window::draw(g); if (player_node) @@ -125,6 +131,7 @@ void DebugWindow::draw(gcn::Graphics *g) -target->getPixelY() + 32 + getHeight() / 2); } } + BLOCK_END("DebugWindow::draw") } void DebugWindow::widgetResized(const gcn::Event &event) diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 6d7baff40..e05e1cc50 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -141,6 +141,7 @@ EquipmentWindow::~EquipmentWindow() void EquipmentWindow::draw(gcn::Graphics *graphics) { + BLOCK_START("EquipmentWindow::draw") // Draw window graphics Window::draw(graphics); Graphics *const g = static_cast<Graphics*>(graphics); @@ -162,7 +163,10 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) } if (!mEquipment) + { + BLOCK_END("EquipmentWindow::draw") return; + } i = 0; for (std::vector<EquipmentBox*>::const_iterator it = mBoxes.begin(), @@ -197,6 +201,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) box->y + mItemPadding); } } + BLOCK_END("EquipmentWindow::draw") } void EquipmentWindow::action(const gcn::ActionEvent &event) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 6e78e3ac8..956b9e8b3 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -258,11 +258,15 @@ Gui::~Gui() void Gui::logic() { + BLOCK_START("Gui::logic") ResourceManager *const resman = ResourceManager::getInstance(); resman->clearScheduled(); if (!mTop) + { + BLOCK_END("Gui::logic") return; + } handleModalFocus(); handleModalMouseInputFocus(); @@ -271,10 +275,12 @@ void Gui::logic() handleMouseInput(); mTop->logic(); + BLOCK_END("Gui::logic") } void Gui::slowLogic() { + BLOCK_START("Gui::slowLogic") Palette::advanceGradients(); // Fade out mouse cursor after extended inactivity @@ -297,14 +303,17 @@ void Gui::slowLogic() mSecureFont->slowLogic(); if (boldFont) boldFont->slowLogic(); + BLOCK_END("Gui::slowLogic") } bool Gui::handleInput() { + BLOCK_START("Gui::handleInput") if (mInput) return handleKeyInput2(); else return false; + BLOCK_END("Gui::handleInput") } bool Gui::handleKeyInput2() @@ -312,6 +321,7 @@ bool Gui::handleKeyInput2() if (!guiInput) return false; + BLOCK_START("Gui::handleKeyInput2") bool consumed(false); while (!mInput->isKeyQueueEmpty()) @@ -376,11 +386,13 @@ bool Gui::handleKeyInput2() } } } // end while + BLOCK_END("Gui::handleKeyInput2") return consumed; } void Gui::draw() { + BLOCK_START("Gui::draw 1") mGraphics->pushClipArea(getTop()->getDimension()); getTop()->draw(mGraphics); @@ -403,6 +415,7 @@ void Gui::draw() } mGraphics->popClipArea(); + BLOCK_END("Gui::draw 1") } void Gui::videoResized() const diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index b591e6c51..d8da5c1e8 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -259,6 +259,7 @@ void KillStats::gainXp(int xp) void KillStats::recalcStats() { + BLOCK_START("KillStats::recalcStats") const int curTime = cur_time; // Need Update Exp Counter @@ -295,10 +296,12 @@ void KillStats::recalcStats() m15minExpNum = newExp; } validateJacko(); + BLOCK_END("KillStats::recalcStats") } void KillStats::update() { + BLOCK_START("KillStats::update") mExpSpeed1Label->setCaption(strprintf(ngettext("Exp speed per %d min: %s", "Exp speed per %d min: %s", 1), 1, toString(m1minSpeed).c_str())); @@ -355,6 +358,7 @@ void KillStats::update() validateJacko(); updateJackoLabel(); + BLOCK_END("KillStats::update") } void KillStats::draw(gcn::Graphics *g) { diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index b773976c3..f155faaea 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -206,10 +206,14 @@ void Minimap::toggle() void Minimap::draw(gcn::Graphics *graphics) { + BLOCK_START("Minimap::draw") Window::draw(graphics); if (!userPalette || !player_node || !viewport) + { + BLOCK_END("Minimap::draw") return; + } Graphics *const graph = static_cast<Graphics*>(graphics); @@ -218,7 +222,10 @@ void Minimap::draw(gcn::Graphics *graphics) graphics->pushClipArea(a); if (!actorSpriteManager) + { + BLOCK_END("Minimap::draw") return; + } mMapOriginX = 0; mMapOriginY = 0; @@ -396,6 +403,7 @@ void Minimap::draw(gcn::Graphics *graphics) graphics->setColor(userPalette->getColor(UserPalette::PC)); graphics->drawRectangle(gcn::Rectangle(x, y, w, h)); graphics->popClipArea(); + BLOCK_END("Minimap::draw") } void Minimap::mouseReleased(gcn::MouseEvent &event) diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index 234218e8c..835c0b250 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -255,6 +255,7 @@ void MiniStatusWindow::updateStatus() void MiniStatusWindow::logic() { + BLOCK_START("MiniStatusWindow::logic") Popup::logic(); for (size_t i = 0, sz = mIcons.size(); i < sz; i++) @@ -262,11 +263,14 @@ void MiniStatusWindow::logic() if (mIcons[i]) mIcons[i]->update(tick_time * 10); } + BLOCK_END("MiniStatusWindow::logic") } void MiniStatusWindow::draw(gcn::Graphics *graphics) { + BLOCK_START("MiniStatusWindow::draw") drawChildren(graphics); + BLOCK_END("MiniStatusWindow::draw") } void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event) diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index ab05a3b49..1eb5e9800 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -745,6 +745,7 @@ void NpcDialog::setAvatarAction(const int actionId) void NpcDialog::logic() { + BLOCK_START("NpcDialog::logic") Window::logic(); if (mShowAvatar && mAvatarBeing) { @@ -760,6 +761,7 @@ void NpcDialog::logic() } } } + BLOCK_END("NpcDialog::logic") } void NpcDialog::clearRows() diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index b5e5757ca..a79fd5fbc 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -308,6 +308,7 @@ void OutfitWindow::copyOutfit(const int src, const int dst) void OutfitWindow::draw(gcn::Graphics *graphics) { + BLOCK_START("OutfitWindow::draw") Window::draw(graphics); Graphics *const g = static_cast<Graphics*>(graphics); @@ -364,6 +365,7 @@ void OutfitWindow::draw(gcn::Graphics *graphics) g->drawImage(image, tPosX, tPosY); } } + BLOCK_END("OutfitWindow::draw") } diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index 33581767d..7ecf7cb4f 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -66,6 +66,7 @@ class SDLTextChunk final void generate(TTF_Font *const font, const float alpha) { + BLOCK_START("SDLTextChunk::generate") SDL_Color sdlCol; sdlCol.b = static_cast<uint8_t>(color.b); sdlCol.r = static_cast<uint8_t>(color.r); @@ -80,11 +81,13 @@ class SDLTextChunk final if (!surface) { img = nullptr; + BLOCK_END("SDLTextChunk::generate") return; } img = imageHelper->createTextSurface(surface, alpha); SDL_FreeSurface(surface); + BLOCK_END("SDLTextChunk::generate") } Image *img; @@ -192,8 +195,12 @@ void SDLFont::drawString(gcn::Graphics *const graphics, const std::string &text, const int x, const int y) { + BLOCK_START("SDLFont::drawString") if (text.empty()) + { + BLOCK_END("SDLFont::drawString") return; + } Graphics *const g = dynamic_cast<Graphics *const>(graphics); @@ -260,11 +267,12 @@ void SDLFont::drawString(gcn::Graphics *const graphics, image->setAlpha(alpha); g->drawImage(image, x, y); } - + BLOCK_END("SDLFont::drawString") } void SDLFont::slowLogic() { + BLOCK_START("SDLFont::slowLogic") if (!mCleanTime) { mCleanTime = cur_time + CLEAN_TIME; @@ -274,6 +282,7 @@ void SDLFont::slowLogic() doClean(); mCleanTime = cur_time + CLEAN_TIME; } + BLOCK_END("SDLFont::slowLogic") } void SDLFont::createSDLTextChunk(SDLTextChunk *const chunk) diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 306c0534f..5cc1c2acb 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -492,6 +492,7 @@ void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent) void ServerDialog::logic() { + BLOCK_START("ServerDialog::logic") { MutexLocker tempLock(&mMutex); if (mDownloadStatus == DOWNLOADING_COMPLETE) @@ -520,6 +521,7 @@ void ServerDialog::logic() } Window::logic(); + BLOCK_END("ServerDialog::logic") } void ServerDialog::downloadServerList() diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index acc3f3948..a9afab262 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -776,12 +776,14 @@ void ShopWindow::processRequest(std::string nick, std::string data, void ShopWindow::updateTimes() { + BLOCK_START("ShopWindow::updateTimes") if (mAnnonceTime + (2 * 60) < cur_time || mAnnonceTime > cur_time) { mBuyAnnounceButton->setEnabled(true); mSellAnnounceButton->setEnabled(true); } + BLOCK_END("ShopWindow::updateTimes") } bool ShopWindow::checkFloodCounter(int &counterTime) const diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 0fc926009..bb59517e5 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -1666,6 +1666,7 @@ void SocialWindow::updateActiveList() void SocialWindow::slowLogic() { + BLOCK_START("SocialWindow::slowLogic") const unsigned int nowTime = cur_time; if (mNeedUpdate && nowTime - mLastUpdateTime > 1) { @@ -1680,6 +1681,7 @@ void SocialWindow::slowLogic() mNeedUpdate = false; mLastUpdateTime = nowTime; } + BLOCK_END("SocialWindow::slowLogic") } void SocialWindow::updateAvatar(std::string name) diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index e156f98be..2abb8979c 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -605,6 +605,7 @@ void UpdaterWindow::addUpdateFile(const ResourceManager *const resman, void UpdaterWindow::logic() { + BLOCK_START("UpdaterWindow::logic") // Update Scroll logic mScrollArea->logic(); @@ -826,6 +827,7 @@ void UpdaterWindow::logic() + toString(static_cast<unsigned>(mDownloadStatus))); break; } + BLOCK_END("UpdaterWindow::logic") } bool UpdaterWindow::validateFile(const std::string &filePath, diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index e7d7ab85d..3fb487811 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -116,6 +116,7 @@ extern MiniStatusWindow *miniStatusWindow; void Viewport::draw(gcn::Graphics *gcnGraphics) { + BLOCK_START("Viewport::draw 1") static int lastTick = tick_time; if (!mMap || !player_node) @@ -123,6 +124,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) gcnGraphics->setColor(gcn::Color(64, 64, 64)); gcnGraphics->fillRectangle( gcn::Rectangle(0, 0, getWidth(), getHeight())); + BLOCK_END("Viewport::draw 1") return; } @@ -265,15 +267,18 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) // Draw contained widgets WindowContainer::draw(gcnGraphics); + BLOCK_END("Viewport::draw 1") } void Viewport::logic() { + BLOCK_START("Viewport::logic") WindowContainer::logic(); // Make the player follow the mouse position // if the mouse is dragged elsewhere than in a window. _followMouse(); + BLOCK_END("Viewport::logic") } void Viewport::_followMouse() diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 425d5fbd8..fa3980024 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -606,6 +606,7 @@ void WhoIsOnline::slowLogic() if (!mAllowUpdate) return; + BLOCK_START("WhoIsOnline::slowLogic") if (mUpdateTimer == 0) mUpdateTimer = cur_time; @@ -658,6 +659,7 @@ void WhoIsOnline::slowLogic() default: break; } + BLOCK_END("WhoIsOnline::slowLogic") } void WhoIsOnline::action(const gcn::ActionEvent &event) diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 1f5556a5d..dcb280596 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -89,8 +89,12 @@ AvatarListBox::~AvatarListBox() void AvatarListBox::draw(gcn::Graphics *gcnGraphics) { + BLOCK_START("AvatarListBox::draw") if (!mListModel || !player_node) + { + BLOCK_END("AvatarListBox::draw") return; + } AvatarListModel *const model = static_cast<AvatarListModel *const>( mListModel); @@ -276,6 +280,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) } setWidth(parent->getWidth() - 10); + BLOCK_END("AvatarListBox::draw") } void AvatarListBox::mousePressed(gcn::MouseEvent &event) diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 4d0e5e32c..1fa563915 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -335,6 +335,7 @@ void BrowserBox::mouseMoved(gcn::MouseEvent &event) void BrowserBox::draw(gcn::Graphics *graphics) { + BLOCK_START("BrowserBox::draw") const gcn::ClipRectangle cr = graphics->getCurrentClipArea(); Graphics *const graphics2 = static_cast<Graphics *const>(graphics); mYStart = cr.y - cr.yOffset; @@ -400,7 +401,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) } } - return; + BLOCK_END("BrowserBox::draw") } int BrowserBox::calcHeight() diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 31bde646f..5a12893a6 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -276,6 +276,7 @@ void Button::updateAlpha() void Button::draw(gcn::Graphics *graphics) { + BLOCK_START("Button::draw") int mode; if (!isEnabled()) @@ -289,7 +290,10 @@ void Button::draw(gcn::Graphics *graphics) const Skin *const skin = button[mode]; if (!skin) + { + BLOCK_END("Button::draw") return; + } updateAlpha(); @@ -409,6 +413,7 @@ void Button::draw(gcn::Graphics *graphics) g2->drawImage(mImages[mode], imageX, imageY); g2->drawText(getCaption(), textX, textY, getAlignment()); } + BLOCK_END("Button::draw") } void Button::mouseReleased(gcn::MouseEvent& mouseEvent) diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 0c2b7ca14..786c77fd2 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -91,6 +91,7 @@ CheckBox::~CheckBox() void CheckBox::draw(gcn::Graphics* graphics) { + BLOCK_START("CheckBox::draw") drawBox(graphics); graphics->setFont(getFont()); @@ -98,6 +99,7 @@ void CheckBox::draw(gcn::Graphics* graphics) graphics->drawText(getCaption(), mPadding + mImageSize + mSpacing, mPadding); + BLOCK_END("CheckBox::draw") } void CheckBox::updateAlpha() diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 0a6657d3e..6079d33a8 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -82,6 +82,7 @@ void Desktop::widgetResized(const gcn::Event &event A_UNUSED) void Desktop::draw(gcn::Graphics *graphics) { + BLOCK_START("Desktop::draw") Graphics *const g = static_cast<Graphics *const>(graphics); if (!mWallpaper || (getWidth() > mWallpaper->getWidth() || @@ -112,6 +113,7 @@ void Desktop::draw(gcn::Graphics *graphics) g->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension())); Container::draw(graphics); + BLOCK_END("Desktop::draw") } void Desktop::setBestFittingWallpaper() diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index a896b4698..bde16760b 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -186,6 +186,7 @@ void DropDown::updateAlpha() void DropDown::draw(gcn::Graphics* graphics) { + BLOCK_START("DropDown::draw") int h; if (mDroppedDown) @@ -227,15 +228,18 @@ void DropDown::draw(gcn::Graphics* graphics) graphics->setColor(mShadowColor); graphics->drawLine(0, h + 1, getWidth(), h + 1); } + BLOCK_END("DropDown::draw") } void DropDown::drawFrame(gcn::Graphics *graphics) { + BLOCK_START("DropDown::drawFrame") const int bs = getFrameSize(); const int w = getWidth() + bs * 2; const int h = getHeight() + bs * 2; static_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, skinRect); + BLOCK_END("DropDown::drawFrame") } void DropDown::drawButton(gcn::Graphics *graphics) diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 95a09533e..756738eb0 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -91,6 +91,7 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics) if (!dropShortcut) return; + BLOCK_START("DropShortcutContainer::draw") if (Client::getGuiAlpha() != mAlpha) { mAlpha = Client::getGuiAlpha(); @@ -113,7 +114,10 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics) const Inventory *const inv = PlayerInfo::getInventory(); if (!inv) + { + BLOCK_END("DropShortcutContainer::draw") return; + } for (unsigned i = 0; i < mMaxItems; i++) { @@ -166,6 +170,7 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics) gcn::Graphics::CENTER); } } + BLOCK_END("DropShortcutContainer::draw") } void DropShortcutContainer::mouseDragged(gcn::MouseEvent &event) diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 79abadf9c..1d1a5a60b 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -104,6 +104,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics) if (!emoteShortcut) return; + BLOCK_START("EmoteShortcutContainer::draw") mAlpha = Client::getGuiAlpha(); if (Client::getGuiAlpha() != mAlpha && mBackgroundImg) mBackgroundImg->setAlpha(mAlpha); @@ -157,6 +158,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics) spr->draw(g, tPosX, tPosY); } } + BLOCK_END("EmoteShortcutContainer::draw") } void EmoteShortcutContainer::mouseDragged(gcn::MouseEvent &event A_UNUSED) diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index f1b41c03f..bb138b456 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -54,6 +54,7 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) if (!mListModel) return; + BLOCK_START("ExtendedListBox::draw") ExtendedListModel *const model = static_cast<ExtendedListModel* const>( mListModel); Graphics *const g = static_cast<Graphics *const>(graphics); @@ -95,4 +96,5 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) image->getWidth() + mImagePadding + mSpacing, y + textPos); } } + BLOCK_END("ExtendedListBox::draw") } diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 39f08340d..935fa833d 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -293,6 +293,7 @@ void GuiTable::draw(gcn::Graphics* graphics) if (!mModel || !getRowHeight()) return; + BLOCK_START("GuiTable::draw") if (Client::getGuiAlpha() != mAlpha) mAlpha = Client::getGuiAlpha(); @@ -386,6 +387,7 @@ void GuiTable::draw(gcn::Graphics* graphics) mTopWidget->draw(graphics); graphics->popClipArea(); } + BLOCK_END("GuiTable::draw") } void GuiTable::moveToTop(gcn::Widget *widget) diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index e152d3c4b..7b4f4857e 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -54,10 +54,12 @@ void Icon::setImage(Image *const image) void Icon::draw(gcn::Graphics *g) { + BLOCK_START("Icon::draw") if (mImage) { Graphics *const graphics = static_cast<Graphics*>(g); graphics->drawImage(mImage, (getWidth() - mImage->mBounds.w) / 2, (getHeight() - mImage->mBounds.h) / 2); } + BLOCK_END("Icon::draw") } diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 616c5caa2..6e9ce1657 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -208,10 +208,14 @@ ItemContainer::~ItemContainer() void ItemContainer::logic() { + BLOCK_START("ItemContainer::logic") gcn::Widget::logic(); if (!mInventory) + { + BLOCK_END("ItemContainer::logic") return; + } const int lastUsedSlot = mInventory->getLastUsedSlot(); @@ -220,6 +224,7 @@ void ItemContainer::logic() mLastUsedSlot = lastUsedSlot; adjustHeight(); } + BLOCK_END("ItemContainer::logic") } void ItemContainer::draw(gcn::Graphics *graphics) @@ -227,6 +232,7 @@ void ItemContainer::draw(gcn::Graphics *graphics) if (!mInventory || !mShowMatrix) return; + BLOCK_START("ItemContainer::draw") Graphics *const g = static_cast<Graphics *const>(graphics); g->setFont(getFont()); @@ -313,6 +319,7 @@ void ItemContainer::draw(gcn::Graphics *graphics) itemY + mEquippedTextPadding, gcn::Graphics::CENTER); } } + BLOCK_END("ItemContainer::draw") } void ItemContainer::selectNone() diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index ccc8cb4c3..44248258c 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -100,9 +100,13 @@ void ItemShortcutContainer::setWidget2(const Widget2 *const widget) void ItemShortcutContainer::draw(gcn::Graphics *graphics) { + BLOCK_START("ItemShortcutContainer::draw") const ItemShortcut *const selShortcut = itemShortcut[mNumber]; if (!selShortcut) + { + BLOCK_END("ItemShortcutContainer::draw") return; + } mAlpha = Client::getGuiAlpha(); if (Client::getGuiAlpha() != mAlpha) @@ -126,7 +130,10 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) const Inventory *const inv = PlayerInfo::getInventory(); if (!inv) + { + BLOCK_END("ItemShortcutContainer::draw") return; + } for (unsigned i = 0; i < mMaxItems; i++) { @@ -231,6 +238,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) gcn::Graphics::CENTER); } } + BLOCK_END("ItemShortcutContainer::draw") } void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event) diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 0286caa7f..2d565a571 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -69,6 +69,7 @@ void Label::init() void Label::draw(gcn::Graphics* graphics) { + BLOCK_START("Label::draw") int textX; const int textY = getHeight() / 2 - getFont()->getHeight() / 2; @@ -92,6 +93,7 @@ void Label::draw(gcn::Graphics* graphics) graphics->setFont(getFont()); graphics->setColor(mForegroundColor); graphics->drawText(getCaption(), textX, textY, getAlignment()); + BLOCK_END("Label::draw") } void Label::adjustSize() diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index b90522229..4de4e360f 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -86,6 +86,7 @@ void ListBox::draw(gcn::Graphics *graphics) if (!mListModel) return; + BLOCK_START("ListBox::draw") updateAlpha(); mHighlightColor.a = static_cast<int>(mAlpha * 255.0f); @@ -109,6 +110,7 @@ void ListBox::draw(gcn::Graphics *graphics) graphics->drawText(mListModel->getElementAt(i), mPadding, y + mPadding); } + BLOCK_END("ListBox::draw") } void ListBox::keyPressed(gcn::KeyEvent &keyEvent) @@ -225,11 +227,13 @@ void ListBox::refocus() void ListBox::adjustSize() { + BLOCK_START("ListBox::adjustSize") if (mListModel) { setHeight(getRowHeight() * mListModel->getNumberOfElements() + 2 * mPadding); } + BLOCK_END("ListBox::adjustSize") } void ListBox::logic() diff --git a/src/gui/widgets/passwordfield.cpp b/src/gui/widgets/passwordfield.cpp index f301f2fe7..512c12761 100644 --- a/src/gui/widgets/passwordfield.cpp +++ b/src/gui/widgets/passwordfield.cpp @@ -33,6 +33,7 @@ PasswordField::PasswordField(const Widget2 *const widget, void PasswordField::draw(gcn::Graphics *graphics) { + BLOCK_START("PasswordField::draw") // std::string uses cow, thus cheap copy const std::string original = mText; if (mPasswordChar) @@ -41,4 +42,5 @@ void PasswordField::draw(gcn::Graphics *graphics) mText = ""; TextField::draw(graphics); mText = original; + BLOCK_END("PasswordField::draw") } diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 747cd91ab..f378373b2 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -97,6 +97,7 @@ void PlayerBox::init(std::string skin) void PlayerBox::draw(gcn::Graphics *graphics) { + BLOCK_START("PlayerBox::draw") if (mBeing) { // Draw character @@ -114,10 +115,12 @@ void PlayerBox::draw(gcn::Graphics *graphics) mBackground.grid[a]->setAlpha(Client::getGuiAlpha()); } } + BLOCK_END("PlayerBox::draw") } void PlayerBox::drawFrame(gcn::Graphics *graphics) { + BLOCK_START("PlayerBox::drawFrame") if (mDrawBackground) { int w, h, bs; @@ -128,4 +131,5 @@ void PlayerBox::drawFrame(gcn::Graphics *graphics) static_cast<Graphics*>(graphics)->drawImageRect( 0, 0, w, h, mBackground); } + BLOCK_END("PlayerBox::drawFrame") } diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index b870d2eb1..03beec766 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -102,6 +102,7 @@ void Popup::setWindowContainer(WindowContainer *const wc) void Popup::draw(gcn::Graphics *graphics) { + BLOCK_START("Popup::draw") Graphics *const g = static_cast<Graphics*>(graphics); if (mRedraw) @@ -116,6 +117,7 @@ void Popup::draw(gcn::Graphics *graphics) // g->drawImageRect(0, 0, getWidth(), getHeight(), mSkin->getBorder()); drawChildren(graphics); + BLOCK_END("Popup::draw") } gcn::Rectangle Popup::getChildrenArea() diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 590447b89..ef3aa19a0 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -90,6 +90,7 @@ ProgressBar::~ProgressBar() void ProgressBar::logic() { + BLOCK_START("ProgressBar::logic") if (mSmoothColorChange && mColorToGo != mColor) { // Smoothly changing the color for a nicer effect. @@ -115,6 +116,7 @@ void ProgressBar::logic() if (mProgressToGo < mProgress) mProgress = std::max(0.0f, mProgress - 0.005f); } + BLOCK_END("ProgressBar::logic") } void ProgressBar::updateAlpha() @@ -139,11 +141,11 @@ void ProgressBar::updateAlpha() void ProgressBar::draw(gcn::Graphics *graphics) { + BLOCK_START("ProgressBar::draw") updateAlpha(); - mColor.a = static_cast<int>(mAlpha * 255); - render(static_cast<Graphics*>(graphics)); + BLOCK_END("ProgressBar::draw") } void ProgressBar::setProgress(const float progress) diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index 936e357ab..10b2bba88 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -65,6 +65,7 @@ void ProgressIndicator::logic() void ProgressIndicator::draw(gcn::Graphics *graphics) { + BLOCK_START("ProgressIndicator::draw") if (mIndicator) { // Draw the indicator centered on the widget @@ -72,4 +73,5 @@ void ProgressIndicator::draw(gcn::Graphics *graphics) const int y = (getHeight() - 32) / 2; mIndicator->draw(static_cast<Graphics*>(graphics), x, y); } + BLOCK_END("ProgressIndicator::draw") } diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 98e1182e1..1c56f787e 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -149,6 +149,7 @@ void RadioButton::drawBox(gcn::Graphics* graphics) void RadioButton::draw(gcn::Graphics* graphics) { + BLOCK_START("RadioButton::draw") drawBox(graphics); graphics->setFont(getFont()); @@ -156,6 +157,7 @@ void RadioButton::draw(gcn::Graphics* graphics) graphics->drawText(getCaption(), mPadding + mImageSize + mSpacing, mPadding); + BLOCK_END("RadioButton::draw") } void RadioButton::mouseEntered(gcn::MouseEvent& event A_UNUSED) diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 0b7b73e6e..5658c6a8f 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -177,8 +177,12 @@ void ScrollArea::init(std::string skinName) void ScrollArea::logic() { + BLOCK_START("ScrollArea::logic") if (!isVisible()) + { + BLOCK_END("ScrollArea::logic") return; + } gcn::ScrollArea::logic(); gcn::Widget *const content = getContent(); @@ -208,6 +212,7 @@ void ScrollArea::logic() setHorizontalScrollAmount(mHScroll - mLeftButtonScrollAmount); else if (mRightButtonPressed) setHorizontalScrollAmount(mHScroll + mRightButtonScrollAmount); + BLOCK_END("ScrollArea::logic") } void ScrollArea::updateAlpha() @@ -236,6 +241,7 @@ void ScrollArea::updateAlpha() void ScrollArea::draw(gcn::Graphics *graphics) { + BLOCK_START("ScrollArea::draw") if (mVBarVisible) { drawUpButton(graphics); @@ -254,10 +260,12 @@ void ScrollArea::draw(gcn::Graphics *graphics) updateAlpha(); drawChildren(graphics); + BLOCK_END("ScrollArea::draw") } void ScrollArea::drawFrame(gcn::Graphics *graphics) { + BLOCK_START("ScrollArea::drawFrame") if (mOpaque) { const int bs = getFrameSize(); @@ -307,6 +315,7 @@ void ScrollArea::drawFrame(gcn::Graphics *graphics) // static_cast<Graphics*>(graphics)-> // drawImageRect(0, 0, w, h, background); } + BLOCK_END("ScrollArea::drawFrame") } void ScrollArea::setOpaque(bool opaque) diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 0134a64c9..86c2e2e67 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -84,8 +84,12 @@ void ShopListBox::setPlayersMoney(const int money) void ShopListBox::draw(gcn::Graphics *gcnGraphics) { + BLOCK_START("ShopListBox::draw") if (!mListModel || !mShopItems) + { + BLOCK_END("ShopListBox::draw") return; + } if (Client::getGuiAlpha() != mAlpha) mAlpha = Client::getGuiAlpha(); @@ -156,6 +160,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) ITEM_ICON_SIZE + mPadding, y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2 + mPadding); } + BLOCK_END("ShopListBox::draw") } void ShopListBox::adjustSize() diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 4ba57b257..1f6a68be9 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -112,9 +112,11 @@ void Slider::updateAlpha() void Slider::draw(gcn::Graphics *graphics) { + BLOCK_START("Slider::draw") if (!buttons[0].grid[HSTART] || !buttons[1].grid[HSTART] || !buttons[0].grid[HEND]) { + BLOCK_END("Slider::draw") return; } @@ -174,6 +176,7 @@ void Slider::draw(gcn::Graphics *graphics) } drawMarker(graphics); + BLOCK_END("Slider::draw") } void Slider::drawMarker(gcn::Graphics *const graphics) const diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index c108930d1..d57b1a092 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -108,12 +108,14 @@ void SliderList::resize() void SliderList::draw(gcn::Graphics *graphics) { + BLOCK_START("SliderList::draw") if (mOldWidth != getWidth()) { resize(); mOldWidth = getWidth(); } Container::draw(graphics); + BLOCK_END("SliderList::draw") } void SliderList::updateLabel() diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index cfc3863eb..10e82676e 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -93,6 +93,7 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics) if (!spellShortcut) return; + BLOCK_START("SpellShortcutContainer::draw") if (Client::getGuiAlpha() != mAlpha) { mAlpha = Client::getGuiAlpha(); @@ -155,7 +156,7 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics) { // Draw the item image being dragged by the cursor. } - + BLOCK_END("SpellShortcutContainer::draw") } void SpellShortcutContainer::mouseDragged(gcn::MouseEvent &event) diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index aea8efb37..6747b19e0 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -147,6 +147,7 @@ void Tab::updateAlpha() void Tab::draw(gcn::Graphics *graphics) { + BLOCK_START("Tab::draw") int mode = TAB_STANDARD; // check which type of tab to draw @@ -184,7 +185,10 @@ void Tab::draw(gcn::Graphics *graphics) const Skin *const skin = tabImg[mode]; if (!skin) + { + BLOCK_END("Tab::draw") return; + } updateAlpha(); @@ -206,6 +210,7 @@ void Tab::draw(gcn::Graphics *graphics) // draw label drawChildren(graphics); + BLOCK_END("Tab::draw") } void Tab::widgetResized(const gcn::Event &event A_UNUSED) diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 0321e5044..ded2986d3 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -129,10 +129,15 @@ Tab *TabbedArea::getTab(const std::string &name) const void TabbedArea::draw(gcn::Graphics *graphics) { + BLOCK_START("TabbedArea::draw") if (mTabs.empty()) + { + BLOCK_END("TabbedArea::draw") return; + } drawChildren(graphics); + BLOCK_END("TabbedArea::draw") } gcn::Widget *TabbedArea::getWidget(const std::string &name) const @@ -274,7 +279,9 @@ void TabbedArea::removeTab(Tab *tab) void TabbedArea::logic() { + BLOCK_START("TabbedArea::logic") logicChildren(); + BLOCK_END("TabbedArea::logic") } void TabbedArea::mousePressed(gcn::MouseEvent &mouseEvent) diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index a31ae59fe..fc9c73a68 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -119,6 +119,7 @@ void TextField::updateAlpha() void TextField::draw(gcn::Graphics *graphics) { + BLOCK_START("TextField::draw") updateAlpha(); if (isFocused()) @@ -131,13 +132,16 @@ void TextField::draw(gcn::Graphics *graphics) graphics->setColor(mForegroundColor); graphics->setFont(getFont()); graphics->drawText(mText, mPadding - mXScroll, mPadding); + BLOCK_END("TextField::draw") } void TextField::drawFrame(gcn::Graphics *graphics) { + BLOCK_START("TextField::drawFrame") const int bs = 2 * getFrameSize(); static_cast<Graphics*>(graphics)->drawImageRect(0, 0, getWidth() + bs, getHeight() + bs, skin); + BLOCK_END("TextField::drawFrame") } void TextField::setNumeric(const bool numeric) diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index f9f0269c0..8468da782 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -78,6 +78,7 @@ TextPreview::~TextPreview() void TextPreview::draw(gcn::Graphics* graphics) { + BLOCK_START("TextPreview::draw") if (Client::getGuiAlpha() != mAlpha) mAlpha = Client::getGuiAlpha(); @@ -112,6 +113,7 @@ void TextPreview::draw(gcn::Graphics* graphics) TextRenderer::renderText(graphics, mText, mPadding + 1, mPadding + 1, gcn::Graphics::LEFT, gcn::Color(mTextColor->r, mTextColor->g, mTextColor->b, alpha), mFont, mOutline, mShadow); + BLOCK_END("TextPreview::draw") } void TextPreview::adjustSize() diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index e4a279e6c..ecf8f0f99 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -186,6 +186,7 @@ void Window::draw(gcn::Graphics *graphics) if (!mSkin) return; + BLOCK_START("Window::draw") Graphics *const g = static_cast<Graphics*>(graphics); bool update = false; @@ -237,6 +238,7 @@ void Window::draw(gcn::Graphics *graphics) { drawChildren(graphics); } + BLOCK_END("Window::draw") } void Window::setContentSize(int width, int height) diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp index 9acba77b2..8c985737c 100644 --- a/src/gui/widgets/windowcontainer.cpp +++ b/src/gui/widgets/windowcontainer.cpp @@ -37,10 +37,12 @@ WindowContainer::WindowContainer(const Widget2 *const widget) : void WindowContainer::logic() { + BLOCK_START("WindowContainer::logic") delete_all(mDeathList); mDeathList.clear(); gcn::Container::logic(); + BLOCK_END("WindowContainer::logic") } void WindowContainer::scheduleDelete(gcn::Widget *const widget) @@ -59,3 +61,12 @@ void WindowContainer::adjustAfterResize(const int oldScreenWidth, window->adjustPositionAfterResize(oldScreenWidth, oldScreenHeight); } } + +#ifdef USE_PROFILER +void WindowContainer::draw(gcn::Graphics* graphics) +{ + BLOCK_START("WindowContainer::draw") + Container::draw(graphics); + BLOCK_END("WindowContainer::draw") +} +#endif diff --git a/src/gui/widgets/windowcontainer.h b/src/gui/widgets/windowcontainer.h index 7a7b77fe1..fd25a1162 100644 --- a/src/gui/widgets/windowcontainer.h +++ b/src/gui/widgets/windowcontainer.h @@ -57,6 +57,10 @@ class WindowContainer : public Container void adjustAfterResize(const int oldScreenWidth, const int oldScreenHeight); +#ifdef USE_PROFILER + void draw(gcn::Graphics* graphics); +#endif + private: /** * List of widgets that are scheduled to be deleted. |