diff options
author | Thanasis Antoniou | 2019-07-21 23:19:00 +0300 |
---|---|---|
committer | Thanasis Antoniou | 2019-07-21 23:19:00 +0300 |
commit | 286054b857c63cc7b0706eb5acfb85f21ce1e4b2 (patch) | |
tree | a8ab1774fc81d910cee3fb92c67db9a5d5b3a1b8 /engines | |
parent | 886e18f936539fd90e61690dbb07fda950bc340a (diff) | |
download | scummvm-rg350-286054b857c63cc7b0706eb5acfb85f21ce1e4b2.tar.gz scummvm-rg350-286054b857c63cc7b0706eb5acfb85f21ce1e4b2.tar.bz2 scummvm-rg350-286054b857c63cc7b0706eb5acfb85f21ce1e4b2.zip |
BLADERUNNER: Avoid redundant calls to wordWrapText for the same text
Diffstat (limited to 'engines')
-rw-r--r-- | engines/bladerunner/subtitles.cpp | 8 | ||||
-rw-r--r-- | engines/bladerunner/subtitles.h | 3 |
2 files changed, 9 insertions, 2 deletions
diff --git a/engines/bladerunner/subtitles.cpp b/engines/bladerunner/subtitles.cpp index 36daee3d4c..df38552e2c 100644 --- a/engines/bladerunner/subtitles.cpp +++ b/engines/bladerunner/subtitles.cpp @@ -364,8 +364,12 @@ void Subtitles::draw(Graphics::Surface &s) { return; } - Common::Array<Common::U32String> lines; - _font->wordWrapText(_currentText, kTextMaxWidth, lines); + // This check is done so that lines won't be re-calculated multiple times for the same text + if (_currentText != _prevText) { + lines.clear(); + _prevText = _currentText; + _font->wordWrapText(_currentText, kTextMaxWidth, lines); + } int y = s.h - (kMarginBottom + MAX(kPreferedLine, lines.size()) * _font->getFontHeight()); diff --git a/engines/bladerunner/subtitles.h b/engines/bladerunner/subtitles.h index 1de059b071..b84e0cf704 100644 --- a/engines/bladerunner/subtitles.h +++ b/engines/bladerunner/subtitles.h @@ -75,6 +75,9 @@ class Subtitles { bool _isVisible; bool _forceShowWhenNoSpeech; Common::U32String _currentText; + Common::U32String _prevText; + + Common::Array<Common::U32String> lines; bool _gameSubsResourceEntriesFound[kMaxTextResourceEntries]; // false if a TRE file did not open successfully bool _isSystemActive; // true if the whole subtitles subsystem should be disabled (due to missing required resources) |