From 007c495239f0dc111bfc94610fb561320ec27232 Mon Sep 17 00:00:00 2001 From: simonb Date: Sat, 2 Apr 2005 14:59:38 +0000 Subject: Tidy up some redundant pixmap allocs --- ChangeLog | 3 +++ src/FbTk/FbPixmap.hh | 5 +++-- src/FbTk/Menu.cc | 33 ++++++++++++++++++++++----------- src/FbTk/TextButton.cc | 16 ++++++++++++---- 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e92e0b..3ca9965 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 0.9.13 +*05/04/03: + * Tidy up some redundant pixmap allocations (Simon) + Menu.cc TextButton.cc FbPixmap.hh *05/03/23: * added "Fullscreen" as a command (Mathias) CurrentWindow.cc/hh FbCommandFactory.cc diff --git a/src/FbTk/FbPixmap.hh b/src/FbTk/FbPixmap.hh index c00aa99..a1c17a5 100644 --- a/src/FbTk/FbPixmap.hh +++ b/src/FbTk/FbPixmap.hh @@ -70,11 +70,12 @@ public: static Pixmap getRootPixmap(int screen_num); -private: - void free(); void create(Drawable src, unsigned int width, unsigned int height, int depth); + +private: + void free(); Pixmap m_pm; unsigned int m_width, m_height; int m_depth; diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 34f876f..f803709 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -473,12 +473,19 @@ void Menu::updateMenu(int active_index) { // buffer pixmap -> resize buffer pixmap if (m_title_pm.width() != width() || m_title_pm.height() != theme().titleHeight()) { - m_title_pm = FbPixmap(menu.title.window(), - width(), theme().titleHeight(), - menu.title.depth()); - m_real_title_pm = FbPixmap(menu.title.window(), + + if (m_title_pm.drawable() != None) { + m_title_pm.resize(width(), theme().titleHeight()); + m_real_title_pm.resize(width(), theme().titleHeight()); + } else { + m_title_pm.create(menu.title.window(), + width(), theme().titleHeight(), + menu.title.depth()); + m_real_title_pm.create(menu.title.window(), width(), theme().titleHeight(), menu.title.depth()); + } + // set pixmap that we have as real face to the user menu.title.setBackgroundPixmap(m_real_title_pm.drawable()); menu.title.setBufferPixmap(m_real_title_pm.drawable()); @@ -560,13 +567,18 @@ void Menu::updateMenu(int active_index) { if (m_need_update || m_frame_pm.width() != menu.frame.width() || m_frame_pm.height() != menu.frame.height()){ - m_frame_pm = FbTk::FbPixmap(menu.frame.window(), - menu.frame.width(), menu.frame.height(), - menu.frame.depth()); + if (m_frame_pm.drawable() != None) { + m_frame_pm.resize(menu.frame.width(), menu.frame.height()); + m_real_frame_pm.resize(menu.frame.width(), menu.frame.height()); + } else { + m_frame_pm.create(menu.frame.window(), + menu.frame.width(), menu.frame.height(), + menu.frame.depth()); - m_real_frame_pm = FbTk::FbPixmap(menu.frame.window(), - menu.frame.width(), menu.frame.height(), - menu.frame.depth()); + m_real_frame_pm.create(menu.frame.window(), + menu.frame.width(), menu.frame.height(), + menu.frame.depth()); + } if (m_transp.get() != 0) m_transp->setDest(m_real_frame_pm.drawable(), screenNumber()); @@ -591,7 +603,6 @@ void Menu::updateMenu(int active_index) { 0, 0, width(), menu.frame_h); } - } diff --git a/src/FbTk/TextButton.cc b/src/FbTk/TextButton.cc index 30cc62a..e623b9a 100644 --- a/src/FbTk/TextButton.cc +++ b/src/FbTk/TextButton.cc @@ -43,7 +43,10 @@ TextButton::TextButton(const FbTk::FbWindow &parent, } void TextButton::resize(unsigned int width, unsigned int height) { - m_buffer.resize(width, height); + if (this->width() == width && height == this->height()) + return; + + m_buffer.resize(width, height); if (backgroundPixmap() != ParentRelative) FbWindow::setBackgroundPixmap(m_buffer.drawable()); @@ -52,10 +55,16 @@ void TextButton::resize(unsigned int width, unsigned int height) { void TextButton::moveResize(int x, int y, unsigned int width, unsigned int height) { - m_buffer.resize(width, height); + if (this->width() == width && height == this->height() && + x == this->x() && y == this->y()) + return; + + if (this->width() != width || height != this->height()) + m_buffer.resize(width, height); if (backgroundPixmap() != ParentRelative) FbWindow::setBackgroundPixmap(m_buffer.drawable()); + Button::moveResize(x, y, width, height); } @@ -104,7 +113,6 @@ void TextButton::clearArea(int x, int y, unsigned int width, unsigned int height, bool exposure) { if (backgroundPixmap() != ParentRelative) { - if (backgroundPixmap()) { m_buffer.copyArea(backgroundPixmap(), gc(), @@ -120,7 +128,6 @@ void TextButton::clearArea(int x, int y, width, height); } - drawText(); setBufferPixmap(m_buffer.drawable()); @@ -163,6 +170,7 @@ void TextButton::drawText(int x_offset, int y_offset) { gc(), // graphic context text().c_str(), textlen, // string and string size align_x + x_offset + m_left_padding, center_pos + y_offset); // position + } void TextButton::exposeEvent(XExposeEvent &event) { -- cgit v0.11.2