Redraw only wxPGProperties within update region
Currently all properties within client area are processed for drawing whether they lie inside the update region or not. Processing for drawing is an expensive operation so doing this only for properties being actually repainted should improve performance.
This commit is contained in:
@@ -1861,8 +1861,8 @@ void wxPropertyGrid::OnPaint( wxPaintEvent& WXUNUSED(event) )
|
||||
}
|
||||
|
||||
// Find out where the window is scrolled to
|
||||
int vx,vy; // Top left corner of client
|
||||
GetViewStart(&vx,&vy);
|
||||
int vy; // Top of the client
|
||||
GetViewStart(NULL, &vy);
|
||||
vy *= wxPG_PIXELS_PER_UNIT;
|
||||
|
||||
// Update everything inside the box
|
||||
@@ -1875,11 +1875,8 @@ void wxPropertyGrid::OnPaint( wxPaintEvent& WXUNUSED(event) )
|
||||
r.x = 0;
|
||||
r.width = GetClientSize().x;
|
||||
|
||||
r.y = vy;
|
||||
r.height = GetClientSize().y;
|
||||
|
||||
// Repaint this rectangle
|
||||
DrawItems(*dcPtr, r.y, r.y + r.height, &r);
|
||||
DrawItems(*dcPtr, r.y, r.y + r.height-1, &r);
|
||||
|
||||
// This blits the buffer (if used) to the window DC.
|
||||
delete dcPtr;
|
||||
@@ -1985,7 +1982,7 @@ void wxPropertyGrid::DrawItems( wxDC& dc,
|
||||
{
|
||||
tempItemsRect = wxRect(0, topItemY,
|
||||
m_pState->GetVirtualWidth(),
|
||||
bottomItemY);
|
||||
bottomItemY - topItemY + 1);
|
||||
itemsRect = &tempItemsRect;
|
||||
}
|
||||
|
||||
@@ -1999,9 +1996,8 @@ void wxPropertyGrid::DrawItems( wxDC& dc,
|
||||
|
||||
if ( m_pState->DoGetRoot()->GetChildCount() > 0 )
|
||||
{
|
||||
// paintFinishY and drawBottomY are in buffer/physical space
|
||||
int paintFinishY = DoDrawItems(dc, itemsRect);
|
||||
int drawBottomY = itemsRect->y + itemsRect->height - vy;
|
||||
int paintFinishY = DoDrawItems(dc, itemsRect) + 1 - vy;
|
||||
int drawBottomY = itemsRect->y + itemsRect->height - 1 - vy;
|
||||
|
||||
// Clear area beyond last painted property
|
||||
if ( paintFinishY < drawBottomY )
|
||||
@@ -2010,7 +2006,7 @@ void wxPropertyGrid::DrawItems( wxDC& dc,
|
||||
dc.SetBrush(m_colEmptySpace);
|
||||
dc.DrawRectangle(0, paintFinishY,
|
||||
m_width,
|
||||
drawBottomY );
|
||||
drawBottomY-paintFinishY+1);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2047,10 +2043,14 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
||||
if ( !lastItem )
|
||||
lastItem = GetLastItem( wxPG_ITERATE_VISIBLE );
|
||||
|
||||
if ( IsFrozen() || m_height < 1 || firstItem == NULL )
|
||||
return itemsRect->y;
|
||||
int vy;
|
||||
GetViewStart(NULL, &vy);
|
||||
vy *= wxPG_PIXELS_PER_UNIT;
|
||||
|
||||
wxCHECK_MSG( !m_pState->m_itemsAdded, itemsRect->y,
|
||||
if ( IsFrozen() || m_height < 1 || firstItem == NULL )
|
||||
return vy - 1;
|
||||
|
||||
wxCHECK_MSG( !m_pState->m_itemsAdded, vy - 1,
|
||||
wxS("no items added") );
|
||||
wxASSERT( m_pState->DoGetRoot()->GetChildCount() );
|
||||
|
||||
@@ -2060,7 +2060,7 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
||||
int lastItemBottomY;
|
||||
|
||||
firstItemTopY = itemsRect->y;
|
||||
lastItemBottomY = itemsRect->y + itemsRect->height;
|
||||
lastItemBottomY = itemsRect->y + itemsRect->height - 1;
|
||||
|
||||
// Align y coordinates to item boundaries
|
||||
firstItemTopY -= firstItemTopY % lh;
|
||||
@@ -2093,20 +2093,18 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
int xRelMod = 0;
|
||||
|
||||
// Buffer's y = 0, so align itemsRect and coordinates to that
|
||||
if ( isBuffered )
|
||||
{
|
||||
xRelMod = itemsRect->x;
|
||||
// itemsRect conversion
|
||||
firstItemTopY -= itemsRect->y;
|
||||
lastItemBottomY -= itemsRect->y;
|
||||
firstItemTopY -= vy;
|
||||
lastItemBottomY -= vy;
|
||||
}
|
||||
#else
|
||||
// Buffer's y = 0, so align itemsRect and coordinates to that
|
||||
int xRelMod = itemsRect->x;
|
||||
// itemsRect conversion
|
||||
firstItemTopY -= itemsRect->y;
|
||||
lastItemBottomY -= itemsRect->y;
|
||||
firstItemTopY -= vy;
|
||||
lastItemBottomY -= vy;
|
||||
#endif
|
||||
|
||||
int x = m_marginWidth - xRelMod;
|
||||
@@ -2512,7 +2510,7 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
||||
y += rowHeight;
|
||||
}
|
||||
|
||||
return y;
|
||||
return y - 1 + vy;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -2580,6 +2578,7 @@ void wxPropertyGrid::DrawItems( const wxPGProperty* p1, const wxPGProperty* p2 )
|
||||
r.x -= vx;
|
||||
r.y -= vy;
|
||||
RefreshRect(r);
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user