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
|
// Find out where the window is scrolled to
|
||||||
int vx,vy; // Top left corner of client
|
int vy; // Top of the client
|
||||||
GetViewStart(&vx,&vy);
|
GetViewStart(NULL, &vy);
|
||||||
vy *= wxPG_PIXELS_PER_UNIT;
|
vy *= wxPG_PIXELS_PER_UNIT;
|
||||||
|
|
||||||
// Update everything inside the box
|
// Update everything inside the box
|
||||||
@@ -1875,11 +1875,8 @@ void wxPropertyGrid::OnPaint( wxPaintEvent& WXUNUSED(event) )
|
|||||||
r.x = 0;
|
r.x = 0;
|
||||||
r.width = GetClientSize().x;
|
r.width = GetClientSize().x;
|
||||||
|
|
||||||
r.y = vy;
|
|
||||||
r.height = GetClientSize().y;
|
|
||||||
|
|
||||||
// Repaint this rectangle
|
// 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.
|
// This blits the buffer (if used) to the window DC.
|
||||||
delete dcPtr;
|
delete dcPtr;
|
||||||
@@ -1985,7 +1982,7 @@ void wxPropertyGrid::DrawItems( wxDC& dc,
|
|||||||
{
|
{
|
||||||
tempItemsRect = wxRect(0, topItemY,
|
tempItemsRect = wxRect(0, topItemY,
|
||||||
m_pState->GetVirtualWidth(),
|
m_pState->GetVirtualWidth(),
|
||||||
bottomItemY);
|
bottomItemY - topItemY + 1);
|
||||||
itemsRect = &tempItemsRect;
|
itemsRect = &tempItemsRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1999,9 +1996,8 @@ void wxPropertyGrid::DrawItems( wxDC& dc,
|
|||||||
|
|
||||||
if ( m_pState->DoGetRoot()->GetChildCount() > 0 )
|
if ( m_pState->DoGetRoot()->GetChildCount() > 0 )
|
||||||
{
|
{
|
||||||
// paintFinishY and drawBottomY are in buffer/physical space
|
int paintFinishY = DoDrawItems(dc, itemsRect) + 1 - vy;
|
||||||
int paintFinishY = DoDrawItems(dc, itemsRect);
|
int drawBottomY = itemsRect->y + itemsRect->height - 1 - vy;
|
||||||
int drawBottomY = itemsRect->y + itemsRect->height - vy;
|
|
||||||
|
|
||||||
// Clear area beyond last painted property
|
// Clear area beyond last painted property
|
||||||
if ( paintFinishY < drawBottomY )
|
if ( paintFinishY < drawBottomY )
|
||||||
@@ -2010,7 +2006,7 @@ void wxPropertyGrid::DrawItems( wxDC& dc,
|
|||||||
dc.SetBrush(m_colEmptySpace);
|
dc.SetBrush(m_colEmptySpace);
|
||||||
dc.DrawRectangle(0, paintFinishY,
|
dc.DrawRectangle(0, paintFinishY,
|
||||||
m_width,
|
m_width,
|
||||||
drawBottomY );
|
drawBottomY-paintFinishY+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2047,10 +2043,14 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
|||||||
if ( !lastItem )
|
if ( !lastItem )
|
||||||
lastItem = GetLastItem( wxPG_ITERATE_VISIBLE );
|
lastItem = GetLastItem( wxPG_ITERATE_VISIBLE );
|
||||||
|
|
||||||
if ( IsFrozen() || m_height < 1 || firstItem == NULL )
|
int vy;
|
||||||
return itemsRect->y;
|
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") );
|
wxS("no items added") );
|
||||||
wxASSERT( m_pState->DoGetRoot()->GetChildCount() );
|
wxASSERT( m_pState->DoGetRoot()->GetChildCount() );
|
||||||
|
|
||||||
@@ -2060,7 +2060,7 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
|||||||
int lastItemBottomY;
|
int lastItemBottomY;
|
||||||
|
|
||||||
firstItemTopY = itemsRect->y;
|
firstItemTopY = itemsRect->y;
|
||||||
lastItemBottomY = itemsRect->y + itemsRect->height;
|
lastItemBottomY = itemsRect->y + itemsRect->height - 1;
|
||||||
|
|
||||||
// Align y coordinates to item boundaries
|
// Align y coordinates to item boundaries
|
||||||
firstItemTopY -= firstItemTopY % lh;
|
firstItemTopY -= firstItemTopY % lh;
|
||||||
@@ -2093,20 +2093,18 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
|||||||
#if WXWIN_COMPATIBILITY_3_0
|
#if WXWIN_COMPATIBILITY_3_0
|
||||||
int xRelMod = 0;
|
int xRelMod = 0;
|
||||||
|
|
||||||
// Buffer's y = 0, so align itemsRect and coordinates to that
|
|
||||||
if ( isBuffered )
|
if ( isBuffered )
|
||||||
{
|
{
|
||||||
xRelMod = itemsRect->x;
|
xRelMod = itemsRect->x;
|
||||||
// itemsRect conversion
|
// itemsRect conversion
|
||||||
firstItemTopY -= itemsRect->y;
|
firstItemTopY -= vy;
|
||||||
lastItemBottomY -= itemsRect->y;
|
lastItemBottomY -= vy;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// Buffer's y = 0, so align itemsRect and coordinates to that
|
|
||||||
int xRelMod = itemsRect->x;
|
int xRelMod = itemsRect->x;
|
||||||
// itemsRect conversion
|
// itemsRect conversion
|
||||||
firstItemTopY -= itemsRect->y;
|
firstItemTopY -= vy;
|
||||||
lastItemBottomY -= itemsRect->y;
|
lastItemBottomY -= vy;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int x = m_marginWidth - xRelMod;
|
int x = m_marginWidth - xRelMod;
|
||||||
@@ -2512,7 +2510,7 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc,
|
|||||||
y += rowHeight;
|
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.x -= vx;
|
||||||
r.y -= vy;
|
r.y -= vy;
|
||||||
RefreshRect(r);
|
RefreshRect(r);
|
||||||
|
Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user