[Scummvm-git-logs] scummvm master -> 286054b857c63cc7b0706eb5acfb85f21ce1e4b2

antoniou79 antoniou at cti.gr
Sun Jul 21 22:20:10 CEST 2019


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
286054b857 BLADERUNNER: Avoid redundant calls to wordWrapText for the same text


Commit: 286054b857c63cc7b0706eb5acfb85f21ce1e4b2
    https://github.com/scummvm/scummvm/commit/286054b857c63cc7b0706eb5acfb85f21ce1e4b2
Author: Thanasis Antoniou (a.antoniou79 at gmail.com)
Date: 2019-07-21T23:19:00+03:00

Commit Message:
BLADERUNNER: Avoid redundant calls to wordWrapText for the same text

Changed paths:
    engines/bladerunner/subtitles.cpp
    engines/bladerunner/subtitles.h


diff --git a/engines/bladerunner/subtitles.cpp b/engines/bladerunner/subtitles.cpp
index 36daee3..df38552 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 1de059b..b84e0cf 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)





More information about the Scummvm-git-logs mailing list