Tidy up some redundant pixmap allocs

This commit is contained in:
simonb 2005-04-02 14:59:38 +00:00
parent 62431956b4
commit 007c495239
4 changed files with 40 additions and 17 deletions

View file

@ -1,5 +1,8 @@
(Format: Year/Month/Day) (Format: Year/Month/Day)
Changes for 0.9.13 Changes for 0.9.13
*05/04/03:
* Tidy up some redundant pixmap allocations (Simon)
Menu.cc TextButton.cc FbPixmap.hh
*05/03/23: *05/03/23:
* added "Fullscreen" as a command (Mathias) * added "Fullscreen" as a command (Mathias)
CurrentWindow.cc/hh FbCommandFactory.cc CurrentWindow.cc/hh FbCommandFactory.cc

View file

@ -70,11 +70,12 @@ public:
static Pixmap getRootPixmap(int screen_num); static Pixmap getRootPixmap(int screen_num);
private:
void free();
void create(Drawable src, void create(Drawable src,
unsigned int width, unsigned int height, unsigned int width, unsigned int height,
int depth); int depth);
private:
void free();
Pixmap m_pm; Pixmap m_pm;
unsigned int m_width, m_height; unsigned int m_width, m_height;
int m_depth; int m_depth;

View file

@ -473,12 +473,19 @@ void Menu::updateMenu(int active_index) {
// buffer pixmap -> resize buffer pixmap // buffer pixmap -> resize buffer pixmap
if (m_title_pm.width() != width() || if (m_title_pm.width() != width() ||
m_title_pm.height() != theme().titleHeight()) { m_title_pm.height() != theme().titleHeight()) {
m_title_pm = FbPixmap(menu.title.window(),
width(), theme().titleHeight(), if (m_title_pm.drawable() != None) {
menu.title.depth()); m_title_pm.resize(width(), theme().titleHeight());
m_real_title_pm = FbPixmap(menu.title.window(), 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(), width(), theme().titleHeight(),
menu.title.depth()); menu.title.depth());
}
// set pixmap that we have as real face to the user // set pixmap that we have as real face to the user
menu.title.setBackgroundPixmap(m_real_title_pm.drawable()); menu.title.setBackgroundPixmap(m_real_title_pm.drawable());
menu.title.setBufferPixmap(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() || if (m_need_update || m_frame_pm.width() != menu.frame.width() ||
m_frame_pm.height() != menu.frame.height()){ m_frame_pm.height() != menu.frame.height()){
m_frame_pm = FbTk::FbPixmap(menu.frame.window(), if (m_frame_pm.drawable() != None) {
menu.frame.width(), menu.frame.height(), m_frame_pm.resize(menu.frame.width(), menu.frame.height());
menu.frame.depth()); 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(), m_real_frame_pm.create(menu.frame.window(),
menu.frame.width(), menu.frame.height(), menu.frame.width(), menu.frame.height(),
menu.frame.depth()); menu.frame.depth());
}
if (m_transp.get() != 0) if (m_transp.get() != 0)
m_transp->setDest(m_real_frame_pm.drawable(), screenNumber()); m_transp->setDest(m_real_frame_pm.drawable(), screenNumber());
@ -591,7 +603,6 @@ void Menu::updateMenu(int active_index) {
0, 0, 0, 0,
width(), menu.frame_h); width(), menu.frame_h);
} }
} }

View file

@ -43,7 +43,10 @@ TextButton::TextButton(const FbTk::FbWindow &parent,
} }
void TextButton::resize(unsigned int width, unsigned int height) { 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) if (backgroundPixmap() != ParentRelative)
FbWindow::setBackgroundPixmap(m_buffer.drawable()); 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, void TextButton::moveResize(int x, int y,
unsigned int width, unsigned int height) { 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) if (backgroundPixmap() != ParentRelative)
FbWindow::setBackgroundPixmap(m_buffer.drawable()); FbWindow::setBackgroundPixmap(m_buffer.drawable());
Button::moveResize(x, y, width, height); Button::moveResize(x, y, width, height);
} }
@ -104,7 +113,6 @@ void TextButton::clearArea(int x, int y,
unsigned int width, unsigned int height, unsigned int width, unsigned int height,
bool exposure) { bool exposure) {
if (backgroundPixmap() != ParentRelative) { if (backgroundPixmap() != ParentRelative) {
if (backgroundPixmap()) { if (backgroundPixmap()) {
m_buffer.copyArea(backgroundPixmap(), m_buffer.copyArea(backgroundPixmap(),
gc(), gc(),
@ -120,7 +128,6 @@ void TextButton::clearArea(int x, int y,
width, height); width, height);
} }
drawText(); drawText();
setBufferPixmap(m_buffer.drawable()); setBufferPixmap(m_buffer.drawable());
@ -163,6 +170,7 @@ void TextButton::drawText(int x_offset, int y_offset) {
gc(), // graphic context gc(), // graphic context
text().c_str(), textlen, // string and string size text().c_str(), textlen, // string and string size
align_x + x_offset + m_left_padding, center_pos + y_offset); // position align_x + x_offset + m_left_padding, center_pos + y_offset); // position
} }
void TextButton::exposeEvent(XExposeEvent &event) { void TextButton::exposeEvent(XExposeEvent &event) {