Cleaned up code

This commit is contained in:
Robert Osfield 2018-09-11 09:03:01 +01:00
parent 22e6f6038f
commit 8780347f2f

View File

@ -328,25 +328,22 @@ Glyph* Font::getGlyph(const FontResolution& fontRes, unsigned int charcode)
FontResolution fontResUsed(0,0); FontResolution fontResUsed(0,0);
if (_implementation->supportsMultipleFontResolutions()) fontResUsed = fontRes; if (_implementation->supportsMultipleFontResolutions()) fontResUsed = fontRes;
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_glyphMapMutex);
FontSizeGlyphMap::iterator itr = _sizeGlyphMap.find(fontResUsed);
if (itr!=_sizeGlyphMap.end())
{ {
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_glyphMapMutex); GlyphMap& glyphmap = itr->second;
FontSizeGlyphMap::iterator itr = _sizeGlyphMap.find(fontResUsed); GlyphMap::iterator gitr = glyphmap.find(charcode);
if (itr!=_sizeGlyphMap.end()) if (gitr!=glyphmap.end()) return gitr->second.get();
{
GlyphMap& glyphmap = itr->second;
GlyphMap::iterator gitr = glyphmap.find(charcode);
if (gitr!=glyphmap.end()) return gitr->second.get();
}
Glyph* glyph = _implementation->getGlyph(fontResUsed, charcode);
if (glyph)
{
//addGlyph(fontResUsed, charcode, glyph);
_sizeGlyphMap[fontResUsed][charcode] = glyph;
return glyph;
}
else return 0;
} }
Glyph* glyph = _implementation->getGlyph(fontResUsed, charcode);
if (glyph)
{
_sizeGlyphMap[fontResUsed][charcode] = glyph;
return glyph;
}
else return 0;
} }
Glyph3D* Font::getGlyph3D(const FontResolution &fontRes, unsigned int charcode) Glyph3D* Font::getGlyph3D(const FontResolution &fontRes, unsigned int charcode)
@ -356,24 +353,22 @@ Glyph3D* Font::getGlyph3D(const FontResolution &fontRes, unsigned int charcode)
FontResolution fontResUsed(0,0); FontResolution fontResUsed(0,0);
if (_implementation->supportsMultipleFontResolutions()) fontResUsed = fontRes; if (_implementation->supportsMultipleFontResolutions()) fontResUsed = fontRes;
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_glyphMapMutex);
FontSizeGlyph3DMap::iterator itr = _sizeGlyph3DMap.find(fontResUsed);
if (itr!=_sizeGlyph3DMap.end())
{ {
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_glyphMapMutex); Glyph3DMap& glyphmap = itr->second;
FontSizeGlyph3DMap::iterator itr = _sizeGlyph3DMap.find(fontResUsed); Glyph3DMap::iterator gitr = glyphmap.find(charcode);
if (itr!=_sizeGlyph3DMap.end()) if (gitr!=glyphmap.end()) return gitr->second.get();
{
Glyph3DMap& glyphmap = itr->second;
Glyph3DMap::iterator gitr = glyphmap.find(charcode);
if (gitr!=glyphmap.end()) return gitr->second.get();
}
Glyph3D* glyph = _implementation->getGlyph3D(fontResUsed, charcode);
if (glyph)
{
_sizeGlyph3DMap[fontResUsed][charcode] = glyph;
return glyph;
}
else return 0;
} }
Glyph3D* glyph = _implementation->getGlyph3D(fontResUsed, charcode);
if (glyph)
{
_sizeGlyph3DMap[fontResUsed][charcode] = glyph;
return glyph;
}
else return 0;
} }
void Font::setThreadSafeRefUnref(bool threadSafe) void Font::setThreadSafeRefUnref(bool threadSafe)