Skip to content
Browse files

HaikuDepot: TextDocument-Layout and -View optimize drawing...

 ... by drawing only the paragraphs that intersect with the
 update rect.
  • Loading branch information...
1 parent 375dff4 commit d6bd4f068d6d4cca343041aa6c3db4c6228d2ef3 @stippi stippi committed Sep 8, 2013
View
9 src/apps/haiku-depot/textview/TextDocumentLayout.cpp
@@ -88,14 +88,19 @@ TextDocumentLayout::Height()
void
-TextDocumentLayout::Draw(BView* view, const BPoint& offset)
+TextDocumentLayout::Draw(BView* view, const BPoint& offset,
+ const BRect& updateRect)
{
_ValidateLayout();
int layoutCount = fParagraphLayouts.CountItems();
for (int i = 0; i < layoutCount; i++) {
const ParagraphLayoutInfo& layout = fParagraphLayouts.ItemAtFast(i);
- layout.layout->Draw(view, BPoint(offset.x, offset.y + layout.y));
+ BPoint location(offset.x, offset.y + layout.y);
+ if (location.y > updateRect.bottom)
+ break;
+ if (location.y + layout.layout->Height() > updateRect.top)
+ layout.layout->Draw(view, location);
}
}
View
3 src/apps/haiku-depot/textview/TextDocumentLayout.h
@@ -83,7 +83,8 @@ class TextDocumentLayout : public BReferenceable {
{ return fWidth; }
float Height();
- void Draw(BView* view, const BPoint& offset);
+ void Draw(BView* view, const BPoint& offset,
+ const BRect& updateRect);
private:
void _Init();
View
3 src/apps/haiku-depot/textview/TextDocumentView.cpp
@@ -36,7 +36,7 @@ TextDocumentView::Draw(BRect updateRect)
FillRect(updateRect, B_SOLID_LOW);
fTextDocumentLayout.SetWidth(_TextLayoutWidth(Bounds().Width()));
- fTextDocumentLayout.Draw(this, BPoint(fInsetLeft, fInsetTop));
+ fTextDocumentLayout.Draw(this, BPoint(fInsetLeft, fInsetTop), updateRect);
}
@@ -107,6 +107,7 @@ TextDocumentView::SetTextDocument(const TextDocumentRef& document)
fTextDocument = document;
fTextDocumentLayout.SetTextDocument(fTextDocument);
InvalidateLayout();
+ _UpdateScrollBars();
}

0 comments on commit d6bd4f0

Please sign in to comment.
Something went wrong with that request. Please try again.