[escher] Optimize drawing in scroll view

Change-Id: Ibb3d3a30f6a51df5a410e9040884f8f20e27ee4c
This commit is contained in:
Émilie Feral
2017-04-13 18:48:20 +02:00
parent a6f204d406
commit 0e9092d2e1

View File

@@ -58,9 +58,16 @@ void ScrollView::drawRect(KDContext * ctx, KDRect rect) const {
if (!m_colorBackground) {
return;
}
ctx->fillRect(bounds(), m_backgroundColor);
// Future optimization: avoid drawing behind the content view/
//ctx->fillRect(KDRect(m_leftMargin, m_contentView->bounds().height()+m_topMargin, width-m_leftMargin-m_rightMargin, height- m_contentView->bounds().height())-m_topMargin, m_backgroundColor);
KDCoordinate height = bounds().height();
KDCoordinate width = bounds().width();
KDCoordinate offsetX = m_offset.x();
KDCoordinate offsetY = m_offset.y();
KDCoordinate contentHeight = m_contentView->bounds().height();
KDCoordinate contentWidth = m_contentView->bounds().width();
ctx->fillRect(KDRect(0, 0, width, m_topMargin-offsetY), m_backgroundColor);
ctx->fillRect(KDRect(0, contentHeight+m_topMargin-offsetY, width, height - contentHeight - m_topMargin + offsetY), m_backgroundColor);
ctx->fillRect(KDRect(0, 0, m_leftMargin-offsetX, height), m_backgroundColor);
ctx->fillRect(KDRect(contentWidth + m_leftMargin - offsetX, 0, width - contentWidth - m_leftMargin + offsetX, height), m_backgroundColor);
}