HaikuDepot: TextDocument-Layout and -View optimize drawing...
... by drawing only the paragraphs that intersect with the update rect.
This commit is contained in:
parent
375dff4eaa
commit
d6bd4f068d
|
@ -88,14 +88,19 @@ TextDocumentLayout::Height()
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextDocumentLayout::Draw(BView* view, const BPoint& offset)
|
TextDocumentLayout::Draw(BView* view, const BPoint& offset,
|
||||||
|
const BRect& updateRect)
|
||||||
{
|
{
|
||||||
_ValidateLayout();
|
_ValidateLayout();
|
||||||
|
|
||||||
int layoutCount = fParagraphLayouts.CountItems();
|
int layoutCount = fParagraphLayouts.CountItems();
|
||||||
for (int i = 0; i < layoutCount; i++) {
|
for (int i = 0; i < layoutCount; i++) {
|
||||||
const ParagraphLayoutInfo& layout = fParagraphLayouts.ItemAtFast(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,8 @@ public:
|
||||||
{ return fWidth; }
|
{ return fWidth; }
|
||||||
|
|
||||||
float Height();
|
float Height();
|
||||||
void Draw(BView* view, const BPoint& offset);
|
void Draw(BView* view, const BPoint& offset,
|
||||||
|
const BRect& updateRect);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _Init();
|
void _Init();
|
||||||
|
|
|
@ -36,7 +36,7 @@ TextDocumentView::Draw(BRect updateRect)
|
||||||
FillRect(updateRect, B_SOLID_LOW);
|
FillRect(updateRect, B_SOLID_LOW);
|
||||||
|
|
||||||
fTextDocumentLayout.SetWidth(_TextLayoutWidth(Bounds().Width()));
|
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;
|
fTextDocument = document;
|
||||||
fTextDocumentLayout.SetTextDocument(fTextDocument);
|
fTextDocumentLayout.SetTextDocument(fTextDocument);
|
||||||
InvalidateLayout();
|
InvalidateLayout();
|
||||||
|
_UpdateScrollBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue