diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm index d246bf9c35..7ed7a0c64b 100644 --- a/iphone/Maps/Classes/EAGLView.mm +++ b/iphone/Maps/Classes/EAGLView.mm @@ -94,23 +94,25 @@ NSLog(@"Vendor: %s, Renderer: %s", glGetString(GL_VENDOR), glGetString(GL_RENDERER)); + Platform & pl = GetPlatform(); + resourceManager = shared_ptr(new yg::ResourceManager( bigVBSize, bigIBSize, 4, smallVBSize, smallIBSize, 10, blitVBSize, blitIBSize, 10, 512, 256, 6, 512, 256, 4, - GetPlatform().ReadPathForFile("unicode_blocks.txt").c_str(), - GetPlatform().ReadPathForFile("fonts_whitelist.txt").c_str(), - GetPlatform().ReadPathForFile("fonts_blacklist.txt").c_str(), + "unicode_blocks.txt", + "fonts_whitelist.txt", + "fonts_blacklist.txt", 1 * 1024 * 1024, 500 * 1024, fmt, !yg::gl::g_isBufferObjectsSupported, - !GetPlatform().IsMultiSampled())); + !pl.IsMultiSampled())); Platform::FilesList fonts; - GetPlatform().GetFontNames(fonts); + pl.GetFontNames(fonts); resourceManager->addFonts(fonts); DrawerYG::params_t p; @@ -119,7 +121,7 @@ p.m_frameBuffer = frameBuffer; p.m_glyphCacheID = 1; - drawer = shared_ptr(new DrawerYG(GetPlatform().SkinName(), p)); + drawer = shared_ptr(new DrawerYG(pl.SkinName(), p)); // frameBuffer->onSize(renderBuffer->width(), renderBuffer->height()); // frameBuffer->setRenderTarget(renderBuffer); diff --git a/qt/widgets.cpp b/qt/widgets.cpp index 537651b6b7..7a4bc2da69 100644 --- a/qt/widgets.cpp +++ b/qt/widgets.cpp @@ -35,6 +35,8 @@ namespace qt /// TODO: Show "Please Update Drivers" dialog and close the program. } + Platform & pl = GetPlatform(); + m_renderContext = shared_ptr(new qt::gl::RenderContext(this)); m_resourceManager = make_shared_ptr(new yg::ResourceManager( 50000 * sizeof(yg::gl::Vertex), @@ -50,17 +52,17 @@ namespace qt 10, 512, 256, 5, - GetPlatform().ReadPathForFile("unicode_blocks.txt").c_str(), - GetPlatform().ReadPathForFile("fonts_whitelist.txt").c_str(), - GetPlatform().ReadPathForFile("fonts_blacklist.txt").c_str(), + "unicode_blocks.txt", + "fonts_whitelist.txt", + "fonts_blacklist.txt", 2 * 1024 * 1024, 500 * 1024, yg::Rt8Bpp, !yg::gl::g_isBufferObjectsSupported, - !GetPlatform().IsMultiSampled())); + !pl.IsMultiSampled())); Platform::FilesList fonts; - GetPlatform().GetFontNames(fonts); + pl.GetFontNames(fonts); m_resourceManager->addFonts(fonts); DrawerYG::params_t p; diff --git a/qt_tstfrm/tstwidgets.cpp b/qt_tstfrm/tstwidgets.cpp index ae51956a4c..b7debe696a 100644 --- a/qt_tstfrm/tstwidgets.cpp +++ b/qt_tstfrm/tstwidgets.cpp @@ -56,9 +56,9 @@ void GLDrawWidget::initializeGL() 30, 512, 256, 10, 512, 256, 5, - GetPlatform().ReadPathForFile("unicode_blocks.txt").c_str(), - GetPlatform().ReadPathForFile("fonts_whitelist.txt").c_str(), - GetPlatform().ReadPathForFile("fonts_blacklist.txt").c_str(), + "unicode_blocks.txt", + "fonts_whitelist.txt", + "fonts_blacklist.txt", 2 * 1024 * 1024, 500 * 1024, yg::Rt8Bpp, diff --git a/storage/storage.cpp b/storage/storage.cpp index 847772389e..c756acca1e 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -442,7 +442,7 @@ namespace storage if (m_observerUpdateRequest) { string buffer; - FileReader(GetPlatform().ReadPathForFile(params.m_file)).ReadAsString(buffer); + ReaderPtr(GetPlatform().GetReader(params.m_file)).ReadAsString(buffer); m_observerUpdateRequest(ENewBinaryAvailable, buffer); } } diff --git a/yg/glyph_cache_impl.cpp b/yg/glyph_cache_impl.cpp index ee84f89ef5..bbcb71e1ca 100644 --- a/yg/glyph_cache_impl.cpp +++ b/yg/glyph_cache_impl.cpp @@ -1,5 +1,9 @@ #include "glyph_cache_impl.hpp" +#include "../platform/platform.hpp" + +#include "../coding/reader.hpp" + #include "../base/path_utils.hpp" #include "../base/assert.hpp" @@ -9,7 +13,6 @@ #include <../cache/ftccback.h> #include <../cache/ftccache.h> -#include "../std/fstream.hpp" #include "../std/bind.hpp" @@ -35,7 +38,18 @@ namespace yg void GlyphCacheImpl::initBlocks(string const & fileName) { - ifstream fin(fileName.c_str()); + string buffer; + try + { + ReaderPtr(GetPlatform().GetReader(fileName)).ReadAsString(buffer); + } + catch (RootException const & e) + { + LOG(LERROR, ("Error reading unicode blocks: ", e.what())); + return; + } + + istringstream fin(buffer); while (true) { string name; @@ -59,7 +73,18 @@ namespace yg void GlyphCacheImpl::initFonts(string const & whiteListFile, string const & blackListFile) { { - ifstream fin(whiteListFile.c_str()); + string buffer; + try + { + ReaderPtr(GetPlatform().GetReader(whiteListFile)).ReadAsString(buffer); + } + catch (RootException const & e) + { + LOG(LERROR, ("Error reading white list fonts: ", e.what())); + return; + } + + istringstream fin(buffer); while (true) { string ubName; @@ -81,7 +106,18 @@ namespace yg } { - ifstream fin(blackListFile.c_str()); + string buffer; + try + { + ReaderPtr(GetPlatform().GetReader(blackListFile)).ReadAsString(buffer); + } + catch (RootException const & e) + { + LOG(LERROR, ("Error reading black list fonts: ", e.what())); + return; + } + + istringstream fin(buffer); while (true) { string ubName; diff --git a/yg/resource_manager.cpp b/yg/resource_manager.cpp index 280bdbfbe4..3e6f1e5abc 100644 --- a/yg/resource_manager.cpp +++ b/yg/resource_manager.cpp @@ -105,13 +105,22 @@ namespace yg { if (fileName.empty()) return 0; + SkinLoader loader(resourceManager, dynamicPagesCount, textPagesCount); - FileReader skinFile(GetPlatform().ReadPathForFile(fileName)); - ReaderSource source(skinFile); - bool parseResult = ParseXML(source, loader); - ASSERT(parseResult, ("Invalid skin file structure?")); - if (!parseResult) - throw std::exception(); + + try + { + ReaderPtr skinFile(GetPlatform().GetReader(fileName)); + ReaderSource > source(skinFile); + if (!ParseXML(source, loader)) + MYTHROW(RootException, ("Error parsing skin file: ", fileName)); + } + catch (RootException const & e) + { + LOG(LERROR, ("Error reading skin file: ", e.what())); + return 0; + } + return loader.skin(); } diff --git a/yg/yg_tests/glyph_cache_test.cpp b/yg/yg_tests/glyph_cache_test.cpp index 9f17b82343..65e50dcc6f 100644 --- a/yg/yg_tests/glyph_cache_test.cpp +++ b/yg/yg_tests/glyph_cache_test.cpp @@ -5,17 +5,17 @@ UNIT_TEST(GlyphCacheTest_Main) { - string const path = GetPlatform().WritableDir(); - yg::GlyphCache cache(yg::GlyphCache::Params( - (path + "unicode_blocks.txt").c_str(), - (path + "fonts_whitelist.txt").c_str(), - (path + "fonts_blacklist.txt").c_str(), + "unicode_blocks.txt", + "fonts_whitelist.txt", + "fonts_blacklist.txt", 200000)); + string const path = GetPlatform().WritableDir(); + cache.addFont((path + "01_dejavusans.ttf").c_str()); shared_ptr g1 = cache.getGlyphInfo(yg::GlyphKey('#', 40, true, yg::Color(255, 255, 255, 255))); -// g1->dump(GetPlatform().WritablePathForFile("#_mask.png").c_str()); + //g1->dump(GetPlatform().WritablePathForFile("#_mask.png").c_str()); shared_ptr g2 = cache.getGlyphInfo(yg::GlyphKey('#', 40, false, yg::Color(0, 0, 0, 0))); -// g2->dump(GetPlatform().WritablePathForFile("#.png").c_str()); + //g2->dump(GetPlatform().WritablePathForFile("#.png").c_str()); } diff --git a/yg/yg_tests/skin_test.cpp b/yg/yg_tests/skin_test.cpp index 2e015e7402..85e8cb852c 100644 --- a/yg/yg_tests/skin_test.cpp +++ b/yg/yg_tests/skin_test.cpp @@ -28,13 +28,12 @@ UNIT_TEST(SkinTest_Main) /*uint32_t styleID1 = */skin->mapPenInfo(penInfo1); /*uint32_t styleID2 = */skin->mapPenInfo(penInfo2); + //skin->texture().dump("skin_test0.png"); -// skin->texture().dump("skin_test0.png"); - - /// Overflowing + // Overflowing /*uint32_t styleID3 = */skin->mapPenInfo(penInfo3); -// skin->texture().dump("skin_test1.png"); + //skin->texture().dump("skin_test1.png"); delete skin; }