diff options
author | Martin Kiewitz | 2010-01-31 17:45:22 +0000 |
---|---|---|
committer | Martin Kiewitz | 2010-01-31 17:45:22 +0000 |
commit | aaf756e7364658bcde053932907bbf009e1762ab (patch) | |
tree | 1f5ac575c4e5c97de6a28fd8b1856c42a6336328 /engines/sci/graphics/text.cpp | |
parent | 3b411f65767256f3d55fd361a253d06f6426654c (diff) | |
download | scummvm-rg350-aaf756e7364658bcde053932907bbf009e1762ab.tar.gz scummvm-rg350-aaf756e7364658bcde053932907bbf009e1762ab.tar.bz2 scummvm-rg350-aaf756e7364658bcde053932907bbf009e1762ab.zip |
SCI: implemented font caching
svn-id: r47762
Diffstat (limited to 'engines/sci/graphics/text.cpp')
-rw-r--r-- | engines/sci/graphics/text.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/engines/sci/graphics/text.cpp b/engines/sci/graphics/text.cpp index 8d0e64b759..aa97e858ab 100644 --- a/engines/sci/graphics/text.cpp +++ b/engines/sci/graphics/text.cpp @@ -29,6 +29,7 @@ #include "sci/sci.h" #include "sci/engine/state.h" +#include "sci/graphics/cache.h" #include "sci/graphics/ports.h" #include "sci/graphics/paint16.h" #include "sci/graphics/font.h" @@ -36,8 +37,8 @@ namespace Sci { -Text::Text(ResourceManager *resMan, GfxPorts *ports, GfxPaint16 *paint16, GfxScreen *screen) - : _resMan(resMan), _ports(ports), _paint16(paint16), _screen(screen) { +Text::Text(ResourceManager *resMan, GfxCache *cache, GfxPorts *ports, GfxPaint16 *paint16, GfxScreen *screen) + : _resMan(resMan), _cache(cache), _ports(ports), _paint16(paint16), _screen(screen) { init(); } @@ -58,19 +59,15 @@ GuiResourceId Text::GetFontId() { } Font *Text::GetFont() { - if ((_font == NULL) || (_font->getResourceId() != _ports->_curPort->fontId)) { - delete _font; - _font = new Font(_resMan, _screen, _ports->_curPort->fontId); - } + if ((_font == NULL) || (_font->getResourceId() != _ports->_curPort->fontId)) + _font = _cache->getFont(_ports->_curPort->fontId); return _font; } void Text::SetFont(GuiResourceId fontId) { - if ((_font == NULL) || (_font->getResourceId() != fontId)) { - delete _font; - _font = new Font(_resMan, _screen, fontId); - } + if ((_font == NULL) || (_font->getResourceId() != fontId)) + _font = _cache->getFont(fontId); _ports->_curPort->fontId = _font->getResourceId(); _ports->_curPort->fontHeight = _font->getHeight(); |