From ea34719cb0292c355f5f3059fca6ae35ce842ee8 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 17 Oct 2003 14:26:33 +0000 Subject: [PATCH] Fixed FIXME in blitting code. Small speed-up in wxBitmap::Rescale(). The rescaling code still makes X11 crash with a memory problem. This can be seen in the image sample when you scroll up and down with the mouse often so that the smiley that gets blit appears and disappears often. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@24209 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/bitmap.cpp | 12 ++++++++++-- src/gtk/dcclient.cpp | 32 +++++++++++++++++++++----------- src/gtk1/bitmap.cpp | 12 ++++++++++-- src/gtk1/dcclient.cpp | 32 +++++++++++++++++++++----------- 4 files changed, 62 insertions(+), 26 deletions(-) diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index b36c4d42ff..c2afddf156 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -1050,11 +1050,19 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, for (int h = 0; h < height; h++) { char outbyte = 0; + int old_x = -1; + guint32 old_pixval; for (int w=0; wm_selected.GetWidth(); wxCoord bm_height = memDC->m_selected.GetHeight(); - // get clip coords - wxRegion tmp( xx,yy,ww,hh ); - tmp.Intersect( m_currentClippingRegion ); - wxCoord cx,cy,cw,ch; - tmp.GetBox(cx,cy,cw,ch); - // interpret userscale of src too double xsc,ysc; memDC->GetUserScale(&xsc,&ysc); @@ -1273,16 +1267,32 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord bm_ww = XLOG2DEVREL( bm_width ); wxCoord bm_hh = YLOG2DEVREL( bm_height ); - // scale bitmap if required - wxBitmap use_bitmap; + // Get clip coords for the bitmap. If we don't + // use wxBitmap::Rescale(), which can clip the + // bitmap, these are the same as the original + // coordinates + wxCoord cx = xx; + wxCoord cy = yy; + wxCoord cw = ww; + wxCoord ch = hh; + // Scale bitmap if required + wxBitmap use_bitmap; if ((bm_width != bm_ww) || (bm_height != bm_hh)) { - use_bitmap = memDC->m_selected.Rescale(cx-xx,cy-yy,cw,ch,bm_ww,bm_hh); + // This indicates that the blitting code below will get + // a clipped bitmap and therefore needs to move the origin + // accordingly + wxRegion tmp( xx,yy,ww,hh ); + tmp.Intersect( m_currentClippingRegion ); + tmp.GetBox(cx,cy,cw,ch); + + // Scale and clipped bitmap + use_bitmap = memDC->m_selected.Rescale(cx-xx,cy-yy,cw,ch,bm_ww,bm_hh); } else { - // FIXME: use cx,cy,cw,ch here, too? + // Don't scale bitmap use_bitmap = memDC->m_selected; } @@ -1453,7 +1463,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) pango_layout_set_text( layout, (const char*)data, strlen((const char*)data) ); - if (abs(m_scaleY - 1.0) < 0.00001) + if (fabs(m_scaleY - 1.0) < 0.00001) { // If there is a user or actually any scale applied to // the device context, scale the font. diff --git a/src/gtk1/bitmap.cpp b/src/gtk1/bitmap.cpp index b36c4d42ff..c2afddf156 100644 --- a/src/gtk1/bitmap.cpp +++ b/src/gtk1/bitmap.cpp @@ -1050,11 +1050,19 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, for (int h = 0; h < height; h++) { char outbyte = 0; + int old_x = -1; + guint32 old_pixval; for (int w=0; wm_selected.GetWidth(); wxCoord bm_height = memDC->m_selected.GetHeight(); - // get clip coords - wxRegion tmp( xx,yy,ww,hh ); - tmp.Intersect( m_currentClippingRegion ); - wxCoord cx,cy,cw,ch; - tmp.GetBox(cx,cy,cw,ch); - // interpret userscale of src too double xsc,ysc; memDC->GetUserScale(&xsc,&ysc); @@ -1273,16 +1267,32 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord bm_ww = XLOG2DEVREL( bm_width ); wxCoord bm_hh = YLOG2DEVREL( bm_height ); - // scale bitmap if required - wxBitmap use_bitmap; + // Get clip coords for the bitmap. If we don't + // use wxBitmap::Rescale(), which can clip the + // bitmap, these are the same as the original + // coordinates + wxCoord cx = xx; + wxCoord cy = yy; + wxCoord cw = ww; + wxCoord ch = hh; + // Scale bitmap if required + wxBitmap use_bitmap; if ((bm_width != bm_ww) || (bm_height != bm_hh)) { - use_bitmap = memDC->m_selected.Rescale(cx-xx,cy-yy,cw,ch,bm_ww,bm_hh); + // This indicates that the blitting code below will get + // a clipped bitmap and therefore needs to move the origin + // accordingly + wxRegion tmp( xx,yy,ww,hh ); + tmp.Intersect( m_currentClippingRegion ); + tmp.GetBox(cx,cy,cw,ch); + + // Scale and clipped bitmap + use_bitmap = memDC->m_selected.Rescale(cx-xx,cy-yy,cw,ch,bm_ww,bm_hh); } else { - // FIXME: use cx,cy,cw,ch here, too? + // Don't scale bitmap use_bitmap = memDC->m_selected; } @@ -1453,7 +1463,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) pango_layout_set_text( layout, (const char*)data, strlen((const char*)data) ); - if (abs(m_scaleY - 1.0) < 0.00001) + if (fabs(m_scaleY - 1.0) < 0.00001) { // If there is a user or actually any scale applied to // the device context, scale the font.