[Scummvm-git-logs] scummvm master -> 54b84aaedd583d618df1980a8352fdde09683796
djsrv
dservilla at gmail.com
Fri Jul 30 20:55:27 UTC 2021
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
29197c191c GRAPHICS: MACGUI: Fix font memory leaks
ad780d761c GRAPHICS: MACGUI: Handle TTF fonts with slant
54b84aaedd GRAPHICS: MACGUI: Fix desktop memory leak
Commit: 29197c191c93579b2718dbc7c66de9addfb5712d
https://github.com/scummvm/scummvm/commit/29197c191c93579b2718dbc7c66de9addfb5712d
Author: djsrv (dservilla at gmail.com)
Date: 2021-07-30T16:43:57-04:00
Commit Message:
GRAPHICS: MACGUI: Fix font memory leaks
Changed paths:
graphics/macgui/macfontmanager.cpp
graphics/macgui/macfontmanager.h
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index a392b3525a..7087182011 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -181,6 +181,10 @@ MacFontManager::~MacFontManager() {
delete it->_value;
for (Common::HashMap<int, Common::SeekableReadStream *>::iterator it = _ttfData.begin(); it != _ttfData.end(); it++)
delete it->_value;
+ for (Common::HashMap<Common::String, MacFont *>::iterator it = _fontRegistry.begin(); it != _fontRegistry.end(); it++)
+ delete it->_value;
+ for (Common::HashMap<Common::String, MacFontFamily *>::iterator it = _fontFamilies.begin(); it != _fontFamilies.end(); it++)
+ delete it->_value;
}
void MacFontManager::setLocalizedFonts() {
@@ -419,7 +423,9 @@ void MacFontManager::loadFonts(Common::MacResManager *fontFile) {
delete fond;
- if (!fontFamilyUsed)
+ if (fontFamilyUsed)
+ _fontFamilies[familyName] = fontFamily;
+ else
delete fontFamily;
}
}
diff --git a/graphics/macgui/macfontmanager.h b/graphics/macgui/macfontmanager.h
index dd959d0162..3c506aad1a 100644
--- a/graphics/macgui/macfontmanager.h
+++ b/graphics/macgui/macfontmanager.h
@@ -35,6 +35,7 @@ namespace Common {
namespace Graphics {
class MacFONTFont;
+class MacFontFamily;
enum {
kMacFontNonStandard = -1,
@@ -182,6 +183,7 @@ private:
uint32 _mode;
Common::Language _language;
Common::HashMap<Common::String, MacFont *> _fontRegistry;
+ Common::HashMap<Common::String, MacFontFamily *> _fontFamilies;
Common::HashMap<int, FontInfo *> _fontInfo;
Common::HashMap<Common::String, int> _fontIds;
Commit: ad780d761c071274365619aa168532cb0f3dfb1a
https://github.com/scummvm/scummvm/commit/ad780d761c071274365619aa168532cb0f3dfb1a
Author: djsrv (dservilla at gmail.com)
Date: 2021-07-30T16:43:57-04:00
Commit Message:
GRAPHICS: MACGUI: Handle TTF fonts with slant
Changed paths:
graphics/macgui/macfontmanager.cpp
graphics/macgui/macfontmanager.h
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index 7087182011..8c370190b1 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -179,7 +179,7 @@ MacFontManager::~MacFontManager() {
delete it->_value;
for (Common::HashMap<int, const Graphics::Font *>::iterator it = _uniFonts.begin(); it != _uniFonts.end(); it++)
delete it->_value;
- for (Common::HashMap<int, Common::SeekableReadStream *>::iterator it = _ttfData.begin(); it != _ttfData.end(); it++)
+ for (Common::HashMap<Common::String, Common::SeekableReadStream *>::iterator it = _ttfData.begin(); it != _ttfData.end(); it++)
delete it->_value;
for (Common::HashMap<Common::String, MacFont *>::iterator it = _fontRegistry.begin(); it != _fontRegistry.end(); it++)
delete it->_value;
@@ -322,7 +322,7 @@ void MacFontManager::loadJapaneseFonts() {
}
}
- _ttfData[_fontIds.getValOrDefault(fontName, kMacFontNonStandard)] = stream;
+ _ttfData[fontName + "-0-0"] = stream;
}
delete dat;
@@ -389,7 +389,8 @@ void MacFontManager::loadFonts(Common::MacResManager *fontFile) {
if (!fontstream) {
// The sfnt resource should be just a copy of a TTF
fontstream = fontFile->getResource(MKTAG('s', 'f', 'n', 't'), (*assoc)[i]._fontID);
- _ttfData[_fontIds.getValOrDefault(familyName, kMacFontNonStandard)] = fontstream;
+ Common::String fontName = Common::String::format("%s-%d-0", familyName.c_str(), (*assoc)[i]._fontStyle | familySlant);
+ _ttfData[fontName] = fontstream;
continue;
}
#endif
@@ -638,6 +639,15 @@ Common::String MacFontManager::getFontName(uint16 id) {
void MacFontManager::generateFontSubstitute(MacFont &macFont) {
Common::String name;
+#ifdef USE_FREETYPE2
+ // Check if we have TTF data for this font.
+ name = getFontName(macFont.getId(), 0, macFont.getSlant());
+ if (_ttfData.contains(name)) {
+ generateTTFFont(macFont, _ttfData[name]);
+ return;
+ }
+#endif
+
// Try to see if we have regular font
if (macFont.getSlant() != kMacFontRegular) {
name = getFontName(macFont.getId(), macFont.getSize(), kMacFontRegular);
@@ -649,14 +659,6 @@ void MacFontManager::generateFontSubstitute(MacFont &macFont) {
}
}
-#ifdef USE_FREETYPE2
- // Checking if it's a TTF font. Restrict it only to regular fonts now
- if (_ttfData.contains(macFont.getId()) && macFont.getSlant() == kMacFontRegular) {
- generateTTFFont(macFont, _ttfData[macFont.getId()]);
- return;
- }
-#endif
-
// Now try twice size
name = getFontName(macFont.getId(), macFont.getSize() * 2, macFont.getSlant());
if (_fontRegistry.contains(name) && !_fontRegistry[name]->isGenerated()) {
diff --git a/graphics/macgui/macfontmanager.h b/graphics/macgui/macfontmanager.h
index 3c506aad1a..e3251a77a4 100644
--- a/graphics/macgui/macfontmanager.h
+++ b/graphics/macgui/macfontmanager.h
@@ -193,7 +193,7 @@ private:
/* Unicode font */
Common::HashMap<int, const Graphics::Font *> _uniFonts;
- Common::HashMap<int, Common::SeekableReadStream *> _ttfData;
+ Common::HashMap<Common::String, Common::SeekableReadStream *> _ttfData;
};
} // End of namespace Graphics
Commit: 54b84aaedd583d618df1980a8352fdde09683796
https://github.com/scummvm/scummvm/commit/54b84aaedd583d618df1980a8352fdde09683796
Author: djsrv (dservilla at gmail.com)
Date: 2021-07-30T16:43:57-04:00
Commit Message:
GRAPHICS: MACGUI: Fix desktop memory leak
Changed paths:
graphics/macgui/macwindowmanager.cpp
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index dd5c060978..ded8b1db09 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -241,6 +241,7 @@ MacWindowManager::~MacWindowManager() {
delete _fontMan;
delete _screenCopy;
+ _desktopBmp->free();
delete _desktopBmp;
delete _desktop;
@@ -789,7 +790,6 @@ void MacWindowManager::loadDesktop() {
bmpDecoder.loadStream(*file);
source = bmpDecoder.getSurface()->convertTo(_desktopBmp->getSupportedPixelFormat(), bmpDecoder.getPalette());
- _desktopBmp->create(source->w, source->h, _desktopBmp->getSupportedPixelFormat());
_desktopBmp->copyFrom(*source);
delete file;
More information about the Scummvm-git-logs
mailing list