Avoid calling PenLocation for every char.
PenLocation is retrieved from app_server (because DrawString changes it there), so this made drawing very slow.
This commit is contained in:
@@ -47,21 +47,8 @@ TermView::~TermView()
|
|||||||
void
|
void
|
||||||
TermView::AttachedToWindow()
|
TermView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
|
BView::AttachedToWindow();
|
||||||
MakeFocus();
|
MakeFocus();
|
||||||
|
|
||||||
VTermScreenCell cell;
|
|
||||||
VTermPos firstPos;
|
|
||||||
firstPos.row = 0;
|
|
||||||
firstPos.col = 0;
|
|
||||||
_GetCell(firstPos, cell);
|
|
||||||
|
|
||||||
rgb_color background;
|
|
||||||
background.red = cell.bg.red;
|
|
||||||
background.green = cell.bg.green;
|
|
||||||
background.blue = cell.bg.blue;
|
|
||||||
background.alpha = 255;
|
|
||||||
|
|
||||||
SetViewColor(background);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -110,15 +97,14 @@ TermView::Draw(BRect updateRect)
|
|||||||
SetHighColor(foreground);
|
SetHighColor(foreground);
|
||||||
}
|
}
|
||||||
|
|
||||||
BPoint penLocation = PenLocation();
|
FillRect(BRect(x,
|
||||||
FillRect(BRect(penLocation.x,
|
y - ceil(height.ascent) + 1,
|
||||||
penLocation.y - ceil(height.ascent) + 1,
|
x + cell.width * fFontWidth - 1,
|
||||||
penLocation.x + cell.width * fFontWidth - 1,
|
y + ceil(height.descent) + ceil(height.leading)),
|
||||||
penLocation.y + ceil(height.descent) + ceil(height.leading)),
|
|
||||||
B_SOLID_LOW);
|
B_SOLID_LOW);
|
||||||
|
|
||||||
if (cell.chars[0] == 0) {
|
if (cell.chars[0] == 0) {
|
||||||
DrawString(" ");
|
x += fFontWidth;
|
||||||
pos.col ++;
|
pos.col ++;
|
||||||
} else {
|
} else {
|
||||||
char buffer[VTERM_MAX_CHARS_PER_CELL];
|
char buffer[VTERM_MAX_CHARS_PER_CELL];
|
||||||
@@ -126,6 +112,7 @@ TermView::Draw(BRect updateRect)
|
|||||||
VTERM_MAX_CHARS_PER_CELL);
|
VTERM_MAX_CHARS_PER_CELL);
|
||||||
|
|
||||||
DrawString(buffer);
|
DrawString(buffer);
|
||||||
|
x += StringWidth(buffer);
|
||||||
pos.col += cell.width;
|
pos.col += cell.width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,6 +196,20 @@ TermView::_Init()
|
|||||||
vterm_screen_reset(fTermScreen, 1);
|
vterm_screen_reset(fTermScreen, 1);
|
||||||
|
|
||||||
vterm_parser_set_utf8(fTerm, 1);
|
vterm_parser_set_utf8(fTerm, 1);
|
||||||
|
|
||||||
|
VTermScreenCell cell;
|
||||||
|
VTermPos firstPos;
|
||||||
|
firstPos.row = 0;
|
||||||
|
firstPos.col = 0;
|
||||||
|
_GetCell(firstPos, cell);
|
||||||
|
|
||||||
|
rgb_color background;
|
||||||
|
background.red = cell.bg.red;
|
||||||
|
background.green = cell.bg.green;
|
||||||
|
background.blue = cell.bg.blue;
|
||||||
|
background.alpha = 255;
|
||||||
|
|
||||||
|
SetViewColor(background);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user