From 24dd26625caeccbaadd9a7681422b30d0b303e4b Mon Sep 17 00:00:00 2001 From: rachytski Date: Tue, 4 Dec 2012 18:45:45 +0300 Subject: [PATCH] renamed SkinPage into ResourceCache. --- graphics/area_renderer.cpp | 2 +- graphics/geometry_batcher.cpp | 38 ++++---- graphics/geometry_batcher.hpp | 6 +- graphics/graphics.pro | 4 +- graphics/graphics_tests/screengl_test.cpp | 4 +- graphics/opengl/geometry_renderer.hpp | 2 +- graphics/path_renderer.cpp | 2 +- .../{skin_page.cpp => resource_cache.cpp} | 92 +++++++++--------- .../{skin_page.hpp => resource_cache.hpp} | 12 +-- graphics/shape_renderer.cpp | 2 +- graphics/skin.cpp | 96 +++++++++---------- graphics/skin.hpp | 10 +- graphics/skin_loader.cpp | 4 +- graphics/skin_loader.hpp | 4 +- graphics/text_element.cpp | 2 +- graphics/text_element.hpp | 2 +- map/drawer.cpp | 4 +- map/drawer.hpp | 2 +- 18 files changed, 144 insertions(+), 144 deletions(-) rename graphics/{skin_page.cpp => resource_cache.cpp} (76%) rename graphics/{skin_page.hpp => resource_cache.hpp} (93%) diff --git a/graphics/area_renderer.cpp b/graphics/area_renderer.cpp index f7aba20de8..d4498769af 100644 --- a/graphics/area_renderer.cpp +++ b/graphics/area_renderer.cpp @@ -1,7 +1,7 @@ #include "area_renderer.hpp" #include "resource_style.hpp" #include "skin.hpp" -#include "skin_page.hpp" +#include "resource_cache.hpp" #include "opengl/base_texture.hpp" diff --git a/graphics/geometry_batcher.cpp b/graphics/geometry_batcher.cpp index 7bdefc827c..1d59777d59 100644 --- a/graphics/geometry_batcher.cpp +++ b/graphics/geometry_batcher.cpp @@ -2,7 +2,7 @@ #include "skin.hpp" #include "color.hpp" #include "resource_manager.hpp" -#include "skin_page.hpp" +#include "resource_cache.hpp" #include "resource_style.hpp" #include "opengl/base_texture.hpp" @@ -45,7 +45,7 @@ namespace graphics { discardPipeline(i); freePipeline(i); - if (m_skin->page(i)->type() != SkinPage::EStatic) + if (m_skin->page(i)->type() != ResourceCache::EStatic) freeTexture(i); } } @@ -72,13 +72,13 @@ namespace graphics { switch (m_type) { - case SkinPage::EPrimary: + case ResourceCache::EPrimary: m_storage = resourceManager->primaryStorages()->Reserve(); break; - case SkinPage::EFonts: + case ResourceCache::EFonts: m_storage = resourceManager->smallStorages()->Reserve(); break; - case SkinPage::EStatic: + case ResourceCache::EStatic: m_storage = resourceManager->smallStorages()->Reserve(); break; default: @@ -126,13 +126,13 @@ namespace graphics else switch (pipeline.m_type) { - case SkinPage::EPrimary: + case ResourceCache::EPrimary: storagePool = resourceManager()->primaryStorages(); break; - case SkinPage::EFonts: + case ResourceCache::EFonts: storagePool = resourceManager()->smallStorages(); break; - case SkinPage::EStatic: + case ResourceCache::EStatic: storagePool = resourceManager()->smallStorages(); break; default: @@ -155,8 +155,8 @@ namespace graphics /// settings proper skin page type according to useGuiResources flag if (m_useGuiResources) for (size_t i = 0; i < m_skin->pagesCount(); ++i) - if (m_skin->page(i)->type() != SkinPage::EStatic) - m_skin->page(i)->setType(SkinPage::ELightWeight); + if (m_skin->page(i)->type() != ResourceCache::EStatic) + m_skin->page(i)->setType(ResourceCache::ELightWeight); m_pipelines.resize(m_skin->pagesCount()); @@ -312,16 +312,16 @@ namespace graphics switch (m_skin->page(pipelineID)->type()) { - case SkinPage::EPrimary: + case ResourceCache::EPrimary: texturePool = resourceManager()->primaryTextures(); break; - case SkinPage::EFonts: + case ResourceCache::EFonts: texturePool = resourceManager()->fontTextures(); break; - case SkinPage::ELightWeight: + case ResourceCache::ELightWeight: texturePool = resourceManager()->guiThreadTextures(); break; - case SkinPage::EStatic: + case ResourceCache::EStatic: LOG(LWARNING, ("texture with EStatic can't be freed.")); return; } @@ -345,21 +345,21 @@ namespace graphics base_t::discardStorage(pipeline.m_storage); } - bool GeometryBatcher::flushPipeline(shared_ptr const & skinPage, + bool GeometryBatcher::flushPipeline(shared_ptr const & resourceCache, int pipelineID) { GeometryPipeline & pipeline = m_pipelines[pipelineID]; if (pipeline.m_currentIndex) { - if (skinPage->hasData()) + if (resourceCache->hasData()) { - uploadStyles(&skinPage->uploadQueue()[0], skinPage->uploadQueue().size(), skinPage->texture()); - skinPage->clearUploadQueue(); + uploadStyles(&resourceCache->uploadQueue()[0], resourceCache->uploadQueue().size(), resourceCache->texture()); + resourceCache->clearUploadQueue(); } unlockPipeline(pipelineID); - drawGeometry(skinPage->texture(), + drawGeometry(resourceCache->texture(), pipeline.m_storage, pipeline.m_currentIndex, 0, diff --git a/graphics/geometry_batcher.hpp b/graphics/geometry_batcher.hpp index 6f339b7bcd..9b98c9319c 100644 --- a/graphics/geometry_batcher.hpp +++ b/graphics/geometry_batcher.hpp @@ -7,7 +7,7 @@ #include "opengl/storage.hpp" #include "display_list_renderer.hpp" -#include "skin_page.hpp" +#include "resource_cache.hpp" #include "resource_manager.hpp" #include "../std/vector.hpp" @@ -61,7 +61,7 @@ namespace graphics /// @} bool m_useGuiResources; - SkinPage::EType m_type; + ResourceCache::EType m_type; int verticesLeft(); int indicesLeft(); @@ -108,7 +108,7 @@ namespace graphics void beginFrame(); void endFrame(); - bool flushPipeline(shared_ptr const & skinPage, int pipelineID); + bool flushPipeline(shared_ptr const & resourceCache, int pipelineID); void unlockPipeline(int pipelineID); void discardPipeline(int pipelineID); diff --git a/graphics/graphics.pro b/graphics/graphics.pro index 93d5fef60f..79fb1db974 100644 --- a/graphics/graphics.pro +++ b/graphics/graphics.pro @@ -36,7 +36,7 @@ SOURCES += \ resource_style.cpp \ color.cpp \ skin_loader.cpp \ - skin_page.cpp \ + resource_cache.cpp \ glyph_cache.cpp \ glyph_cache_impl.cpp \ ft2_debug.cpp \ @@ -100,7 +100,7 @@ HEADERS += \ pen_info.hpp \ resource_style.hpp \ color.hpp \ - skin_page.hpp \ + resource_cache.hpp \ render_target.hpp \ glyph_cache.hpp \ data_formats.hpp \ diff --git a/graphics/graphics_tests/screengl_test.cpp b/graphics/graphics_tests/screengl_test.cpp index 58943f73f7..44473d53aa 100644 --- a/graphics/graphics_tests/screengl_test.cpp +++ b/graphics/graphics_tests/screengl_test.cpp @@ -123,7 +123,7 @@ namespace }; - struct TestDrawPathWithSkinPageMiss : public TestDrawPathBase + struct TestDrawPathWithResourceCacheMiss : public TestDrawPathBase { typedef TestDrawPathBase base_t; @@ -1379,7 +1379,7 @@ namespace // UNIT_TEST_GL(TestDrawSGIConvex); UNIT_TEST_GL(TestDrawPoly); UNIT_TEST_GL(TestDrawSolidRect); - UNIT_TEST_GL(TestDrawPathWithSkinPageMiss); + UNIT_TEST_GL(TestDrawPathWithResourceCacheMiss); UNIT_TEST_GL(TestDrawPathWithOffset); UNIT_TEST_GL(TestDrawPathJoin); UNIT_TEST_GL(TestDrawPathSolid1PX); diff --git a/graphics/opengl/geometry_renderer.hpp b/graphics/opengl/geometry_renderer.hpp index e543aa2dec..fa577cb4ed 100644 --- a/graphics/opengl/geometry_renderer.hpp +++ b/graphics/opengl/geometry_renderer.hpp @@ -1,7 +1,7 @@ #pragma once #include "../defines.hpp" -#include "../skin_page.hpp" +#include "../resource_cache.hpp" #include "clipper.hpp" diff --git a/graphics/path_renderer.cpp b/graphics/path_renderer.cpp index ec365aa338..24b34bece1 100644 --- a/graphics/path_renderer.cpp +++ b/graphics/path_renderer.cpp @@ -1,7 +1,7 @@ #include "path_renderer.hpp" #include "resource_style.hpp" #include "skin.hpp" -#include "skin_page.hpp" +#include "resource_cache.hpp" #include "opengl/base_texture.hpp" diff --git a/graphics/skin_page.cpp b/graphics/resource_cache.cpp similarity index 76% rename from graphics/skin_page.cpp rename to graphics/resource_cache.cpp index ca6ff54915..64e811bc13 100644 --- a/graphics/skin_page.cpp +++ b/graphics/resource_cache.cpp @@ -1,4 +1,4 @@ -#include "skin_page.hpp" +#include "resource_cache.hpp" #include "opengl/texture.hpp" #include "opengl/data_traits.hpp" @@ -15,12 +15,12 @@ namespace graphics { typedef gl::Texture TDynamicTexture; - SkinPage::SkinPage() + ResourceCache::ResourceCache() : m_type(EStatic), m_pipelineID(0) {} - SkinPage::SkinPage(shared_ptr const & resourceManager, + ResourceCache::ResourceCache(shared_ptr const & resourceManager, char const * name, uint8_t pipelineID) : m_texture(resourceManager->getTexture(name)), @@ -30,7 +30,7 @@ namespace graphics { } - SkinPage::SkinPage(shared_ptr const & resourceManager, + ResourceCache::ResourceCache(shared_ptr const & resourceManager, EType type, uint8_t pipelineID) : m_resourceManager(resourceManager), @@ -40,10 +40,10 @@ namespace graphics createPacker(); /// clear handles will be called only upon handles overflow, /// as the texture overflow is processed separately - m_packer.addOverflowFn(bind(&SkinPage::clearHandles, this), 0); + m_packer.addOverflowFn(bind(&ResourceCache::clearHandles, this), 0); } - void SkinPage::clearHandles() + void ResourceCache::clearHandles() { clearPenInfoHandles(); clearColorHandles(); @@ -54,18 +54,18 @@ namespace graphics m_packer.reset(); } - void SkinPage::clearUploadQueue() + void ResourceCache::clearUploadQueue() { m_uploadQueue.clear(); } - void SkinPage::clear() + void ResourceCache::clear() { clearHandles(); clearUploadQueue(); } - void SkinPage::clearColorHandles() + void ResourceCache::clearColorHandles() { for (TColorMap::const_iterator it = m_colorMap.begin(); it != m_colorMap.end(); ++it) m_styles.erase(it->second); @@ -73,7 +73,7 @@ namespace graphics m_colorMap.clear(); } - void SkinPage::clearPenInfoHandles() + void ResourceCache::clearPenInfoHandles() { for (TPenInfoMap::const_iterator it = m_penInfoMap.begin(); it != m_penInfoMap.end(); ++it) m_styles.erase(it->second); @@ -81,7 +81,7 @@ namespace graphics m_penInfoMap.clear(); } - void SkinPage::clearCircleInfoHandles() + void ResourceCache::clearCircleInfoHandles() { for (TCircleInfoMap::const_iterator it = m_circleInfoMap.begin(); it != m_circleInfoMap.end(); ++it) m_styles.erase(it->second); @@ -89,7 +89,7 @@ namespace graphics m_circleInfoMap.clear(); } - void SkinPage::clearFontHandles() + void ResourceCache::clearFontHandles() { for (TGlyphMap::const_iterator it = m_glyphMap.begin(); it != m_glyphMap.end(); ++it) m_styles.erase(it->second); @@ -97,7 +97,7 @@ namespace graphics m_glyphMap.clear(); } - void SkinPage::clearImageInfoHandles() + void ResourceCache::clearImageInfoHandles() { for (TImageInfoMap::const_iterator it = m_imageInfoMap.begin(); it != m_imageInfoMap.end(); @@ -107,7 +107,7 @@ namespace graphics m_imageInfoMap.clear(); } - uint32_t SkinPage::findImageInfo(ImageInfo const & ii) const + uint32_t ResourceCache::findImageInfo(ImageInfo const & ii) const { TImageInfoMap::const_iterator it = m_imageInfoMap.find(ii); if (it == m_imageInfoMap.end()) @@ -116,7 +116,7 @@ namespace graphics return it->second; } - uint32_t SkinPage::mapImageInfo(ImageInfo const & ii) + uint32_t ResourceCache::mapImageInfo(ImageInfo const & ii) { uint32_t foundHandle = findImageInfo(ii); if (foundHandle != m_packer.invalidHandle()) @@ -135,12 +135,12 @@ namespace graphics return h; } - bool SkinPage::hasRoom(ImageInfo const & ii) const + bool ResourceCache::hasRoom(ImageInfo const & ii) const { return m_packer.hasRoom(ii.width() + 4, ii.height() + 4); } - uint32_t SkinPage::findColor(graphics::Color const & c) const + uint32_t ResourceCache::findColor(graphics::Color const & c) const { TColorMap::const_iterator it = m_colorMap.find(c); if (it == m_colorMap.end()) @@ -149,7 +149,7 @@ namespace graphics return it->second; } - uint32_t SkinPage::mapColor(graphics::Color const & c) + uint32_t ResourceCache::mapColor(graphics::Color const & c) { uint32_t foundHandle = findColor(c); @@ -169,12 +169,12 @@ namespace graphics return h; } - bool SkinPage::hasRoom(Color const & ) const + bool ResourceCache::hasRoom(Color const & ) const { return m_packer.hasRoom(2, 2); } - uint32_t SkinPage::findSymbol(char const * symbolName) const + uint32_t ResourceCache::findSymbol(char const * symbolName) const { TPointNameMap::const_iterator it = m_pointNameMap.find(symbolName); if (it == m_pointNameMap.end()) @@ -183,7 +183,7 @@ namespace graphics return it->second; } - uint32_t SkinPage::findGlyph(GlyphKey const & g) const + uint32_t ResourceCache::findGlyph(GlyphKey const & g) const { TGlyphMap::const_iterator it = m_glyphMap.find(g); if (it == m_glyphMap.end()) @@ -192,7 +192,7 @@ namespace graphics return it->second; } - uint32_t SkinPage::mapGlyph(graphics::GlyphKey const & g, graphics::GlyphCache * glyphCache) + uint32_t ResourceCache::mapGlyph(graphics::GlyphKey const & g, graphics::GlyphCache * glyphCache) { uint32_t foundHandle = findGlyph(g); if (foundHandle != m_packer.invalidHandle()) @@ -217,18 +217,18 @@ namespace graphics return m_glyphMap[g]; } - bool SkinPage::hasRoom(GlyphKey const & gk, GlyphCache * glyphCache) const + bool ResourceCache::hasRoom(GlyphKey const & gk, GlyphCache * glyphCache) const { shared_ptr gi = glyphCache->getGlyphInfo(gk); return m_packer.hasRoom(gi->m_metrics.m_width + 4, gi->m_metrics.m_height + 4); } - bool SkinPage::hasRoom(m2::PointU const * sizes, size_t cnt) const + bool ResourceCache::hasRoom(m2::PointU const * sizes, size_t cnt) const { return m_packer.hasRoom(sizes, cnt); } - uint32_t SkinPage::findCircleInfo(CircleInfo const & circleInfo) const + uint32_t ResourceCache::findCircleInfo(CircleInfo const & circleInfo) const { TCircleInfoMap::const_iterator it = m_circleInfoMap.find(circleInfo); if (it == m_circleInfoMap.end()) @@ -237,7 +237,7 @@ namespace graphics return it->second; } - uint32_t SkinPage::mapCircleInfo(CircleInfo const & circleInfo) + uint32_t ResourceCache::mapCircleInfo(CircleInfo const & circleInfo) { uint32_t foundHandle = findCircleInfo(circleInfo); @@ -259,13 +259,13 @@ namespace graphics return m_circleInfoMap[circleInfo]; } - bool SkinPage::hasRoom(CircleInfo const & circleInfo) const + bool ResourceCache::hasRoom(CircleInfo const & circleInfo) const { m2::PointU sz = circleInfo.patternSize(); return m_packer.hasRoom(sz.x, sz.y); } - uint32_t SkinPage::findPenInfo(PenInfo const & penInfo) const + uint32_t ResourceCache::findPenInfo(PenInfo const & penInfo) const { TPenInfoMap::const_iterator it = m_penInfoMap.find(penInfo); if (it == m_penInfoMap.end()) @@ -274,7 +274,7 @@ namespace graphics return it->second; } - uint32_t SkinPage::mapPenInfo(PenInfo const & penInfo) + uint32_t ResourceCache::mapPenInfo(PenInfo const & penInfo) { uint32_t foundHandle = findPenInfo(penInfo); @@ -301,49 +301,49 @@ namespace graphics return m_penInfoMap[penInfo]; } - bool SkinPage::hasRoom(const PenInfo &penInfo) const + bool ResourceCache::hasRoom(const PenInfo &penInfo) const { m2::PointU p = penInfo.patternSize(); return m_packer.hasRoom(p.x, p.y); } - void SkinPage::setType(SkinPage::EType type) + void ResourceCache::setType(ResourceCache::EType type) { m_type = type; createPacker(); if (m_type != EStatic) - m_packer.addOverflowFn(bind(&SkinPage::clearHandles, this), 0); + m_packer.addOverflowFn(bind(&ResourceCache::clearHandles, this), 0); } - SkinPage::EType SkinPage::type() const + ResourceCache::EType ResourceCache::type() const { return m_type; } - bool SkinPage::hasData() + bool ResourceCache::hasData() { return !m_uploadQueue.empty(); } - SkinPage::TUploadQueue const & SkinPage::uploadQueue() const + ResourceCache::TUploadQueue const & ResourceCache::uploadQueue() const { return m_uploadQueue; } - void SkinPage::checkTexture() const + void ResourceCache::checkTexture() const { if ((m_type != EStatic) && (m_texture == 0)) reserveTexture(); } - void SkinPage::setPipelineID(uint8_t pipelineID) + void ResourceCache::setPipelineID(uint8_t pipelineID) { m_pipelineID = pipelineID; for (TStyles::iterator it = m_styles.begin(); it != m_styles.end(); ++it) it->second->m_pipelineID = pipelineID; } - ResourceStyle * SkinPage::fromID(uint32_t idx) const + ResourceStyle * ResourceCache::fromID(uint32_t idx) const { TStyles::const_iterator it = m_styles.find(idx); @@ -353,23 +353,23 @@ namespace graphics return it->second.get(); } - void SkinPage::addOverflowFn(overflowFn fn, int priority) + void ResourceCache::addOverflowFn(overflowFn fn, int priority) { m_packer.addOverflowFn(fn, priority); } - shared_ptr const & SkinPage::texture() const + shared_ptr const & ResourceCache::texture() const { checkTexture(); return m_texture; } - bool SkinPage::hasTexture() const + bool ResourceCache::hasTexture() const { return m_texture != 0; } - void SkinPage::setTexture(shared_ptr const & texture) + void ResourceCache::setTexture(shared_ptr const & texture) { m_texture = texture; m_packer = m2::Packer(texture->width(), @@ -377,12 +377,12 @@ namespace graphics 0x00FFFFFF - 1); } - void SkinPage::resetTexture() + void ResourceCache::resetTexture() { m_texture.reset(); } - void SkinPage::reserveTexture() const + void ResourceCache::reserveTexture() const { switch (m_type) { @@ -400,7 +400,7 @@ namespace graphics } } - void SkinPage::createPacker() + void ResourceCache::createPacker() { switch (m_type) { @@ -424,7 +424,7 @@ namespace graphics } } - shared_ptr const & SkinPage::resourceManager() const + shared_ptr const & ResourceCache::resourceManager() const { return m_resourceManager; } diff --git a/graphics/skin_page.hpp b/graphics/resource_cache.hpp similarity index 93% rename from graphics/skin_page.hpp rename to graphics/resource_cache.hpp index 3a370a21b8..56e74cd0e8 100644 --- a/graphics/skin_page.hpp +++ b/graphics/resource_cache.hpp @@ -24,7 +24,7 @@ namespace graphics class ResourceManager; struct GlyphInfo; - class SkinPage + class ResourceCache { public: @@ -102,17 +102,17 @@ namespace graphics void setPipelineID(uint8_t pipelineID); /// creation of detached page - SkinPage(); + ResourceCache(); /// creation of a static page - SkinPage(shared_ptr const & resourceManager, + ResourceCache(shared_ptr const & resourceManager, char const * name, uint8_t pipelineID); /// creation of a dynamic page - SkinPage(shared_ptr const & resourceManager, - EType type, - uint8_t pipelineID); + ResourceCache(shared_ptr const & resourceManager, + EType type, + uint8_t pipelineID); void reserveTexture() const; void resetTexture(); diff --git a/graphics/shape_renderer.cpp b/graphics/shape_renderer.cpp index 816d646d7b..99ff3730ae 100644 --- a/graphics/shape_renderer.cpp +++ b/graphics/shape_renderer.cpp @@ -2,7 +2,7 @@ #include "skin.hpp" #include "pen_info.hpp" #include "resource_style.hpp" -#include "skin_page.hpp" +#include "resource_cache.hpp" #include "opengl/base_texture.hpp" diff --git a/graphics/skin.cpp b/graphics/skin.cpp index bb9c4aab6f..8d103ed4d1 100644 --- a/graphics/skin.cpp +++ b/graphics/skin.cpp @@ -1,5 +1,5 @@ #include "skin.hpp" -#include "skin_page.hpp" +#include "resource_cache.hpp" #include "resource_style.hpp" #include "resource_manager.hpp" @@ -14,44 +14,44 @@ namespace graphics { Skin::Skin(shared_ptr const & resourceManager, - Skin::TSkinPages const & pages) - : m_pages(pages), - m_staticPagesCount(pages.size()), + Skin::TResourceCaches const & caches) + : m_caches(caches), + m_staticPagesCount(caches.size()), m_resourceManager(resourceManager) { - m_textPage = m_pages.size(); + m_textPage = m_caches.size(); addTextPages(1); - m_startDynamicPage = m_dynamicPage = m_pages.size(); + m_startDynamicPage = m_dynamicPage = m_caches.size(); m_dynamicPagesCount = 2; addDynamicPages(m_dynamicPagesCount); } void Skin::addTextPages(int count) { - m_pages.reserve(m_pages.size() + count); + m_caches.reserve(m_caches.size() + count); addClearPageFn(bind(&Skin::clearPageHandles, this, _1), 0); for (int i = 0; i < count; ++i) { - uint8_t pipelineID = (uint8_t)m_pages.size(); - m_pages.push_back(make_shared_ptr(new SkinPage(m_resourceManager, SkinPage::EFonts, pipelineID))); - m_pages.back()->addOverflowFn(bind(&Skin::onTextOverflow, this, pipelineID), 0); + uint8_t pipelineID = (uint8_t)m_caches.size(); + m_caches.push_back(make_shared_ptr(new ResourceCache(m_resourceManager, ResourceCache::EFonts, pipelineID))); + m_caches.back()->addOverflowFn(bind(&Skin::onTextOverflow, this, pipelineID), 0); } } void Skin::addDynamicPages(int count) { - m_pages.reserve(m_pages.size() + count); + m_caches.reserve(m_caches.size() + count); addClearPageFn(bind(&Skin::clearPageHandles, this, _1), 0); for (int i = 0; i < count; ++i) { - uint8_t pipelineID = (uint8_t)m_pages.size(); - m_pages.push_back(make_shared_ptr(new SkinPage(m_resourceManager, SkinPage::EPrimary, pipelineID))); - m_pages.back()->addOverflowFn(bind(&Skin::onDynamicOverflow, this, pipelineID), 0); + uint8_t pipelineID = (uint8_t)m_caches.size(); + m_caches.push_back(make_shared_ptr(new ResourceCache(m_resourceManager, ResourceCache::EPrimary, pipelineID))); + m_caches.back()->addOverflowFn(bind(&Skin::onDynamicOverflow, this, pipelineID), 0); } } @@ -79,15 +79,15 @@ namespace graphics id_pair_t p = unpackID(id); - ASSERT(p.first < m_pages.size(), ()); - return m_pages[p.first]->fromID(p.second); + ASSERT(p.first < m_caches.size(), ()); + return m_caches[p.first]->fromID(p.second); } uint32_t Skin::mapSymbol(char const * symbolName) { - for (uint8_t i = 0; i < m_pages.size(); ++i) + for (uint8_t i = 0; i < m_caches.size(); ++i) { - uint32_t res = m_pages[i]->findSymbol(symbolName); + uint32_t res = m_caches[i]->findSymbol(symbolName); if (res != invalidPageHandle()) return packID(i, res); } @@ -99,68 +99,68 @@ namespace graphics { uint32_t res = invalidPageHandle(); - for (uint8_t i = 0; i < m_pages.size(); ++i) + for (uint8_t i = 0; i < m_caches.size(); ++i) { - res = m_pages[i]->findColor(c); + res = m_caches[i]->findColor(c); if (res != invalidPageHandle()) return packID(i, res); } - if (!m_pages[m_dynamicPage]->hasRoom(c)) + if (!m_caches[m_dynamicPage]->hasRoom(c)) flushDynamicPage(); - return packID(m_dynamicPage, m_pages[m_dynamicPage]->mapColor(c)); + return packID(m_dynamicPage, m_caches[m_dynamicPage]->mapColor(c)); } uint32_t Skin::mapPenInfo(PenInfo const & penInfo) { uint32_t res = invalidPageHandle(); - for (uint8_t i = 0; i < m_pages.size(); ++i) + for (uint8_t i = 0; i < m_caches.size(); ++i) { - res = m_pages[i]->findPenInfo(penInfo); + res = m_caches[i]->findPenInfo(penInfo); if (res != invalidPageHandle()) return packID(i, res); } - if (!m_pages[m_dynamicPage]->hasRoom(penInfo)) + if (!m_caches[m_dynamicPage]->hasRoom(penInfo)) flushDynamicPage(); - return packID(m_dynamicPage, m_pages[m_dynamicPage]->mapPenInfo(penInfo)); + return packID(m_dynamicPage, m_caches[m_dynamicPage]->mapPenInfo(penInfo)); } uint32_t Skin::mapCircleInfo(CircleInfo const & circleInfo) { uint32_t res = invalidPageHandle(); - for (uint8_t i = 0; i < m_pages.size(); ++i) + for (uint8_t i = 0; i < m_caches.size(); ++i) { - res = m_pages[i]->findCircleInfo(circleInfo); + res = m_caches[i]->findCircleInfo(circleInfo); if (res != invalidPageHandle()) return packID(i, res); } - if (!m_pages[m_dynamicPage]->hasRoom(circleInfo)) + if (!m_caches[m_dynamicPage]->hasRoom(circleInfo)) flushDynamicPage(); - return packID(m_dynamicPage, m_pages[m_dynamicPage]->mapCircleInfo(circleInfo)); + return packID(m_dynamicPage, m_caches[m_dynamicPage]->mapCircleInfo(circleInfo)); } uint32_t Skin::mapImageInfo(ImageInfo const & imageInfo) { uint32_t res = invalidPageHandle(); - for (uint8_t i = 0; i < m_pages.size(); ++i) + for (uint8_t i = 0; i < m_caches.size(); ++i) { - res = m_pages[i]->findImageInfo(imageInfo); + res = m_caches[i]->findImageInfo(imageInfo); if (res != invalidPageHandle()) return packID(i, res); } - if (!m_pages[m_dynamicPage]->hasRoom(imageInfo)) + if (!m_caches[m_dynamicPage]->hasRoom(imageInfo)) flushDynamicPage(); - return packID(m_dynamicPage, m_pages[m_dynamicPage]->mapImageInfo(imageInfo)); + return packID(m_dynamicPage, m_caches[m_dynamicPage]->mapImageInfo(imageInfo)); } bool Skin::mapPenInfo(PenInfo const * penInfos, uint32_t * styleIDS, size_t count) @@ -172,12 +172,12 @@ namespace graphics do { - styleIDS[i] = m_pages[m_dynamicPage]->findPenInfo(penInfos[i]); + styleIDS[i] = m_caches[m_dynamicPage]->findPenInfo(penInfos[i]); if ((styleIDS[i] == invalidPageHandle()) || (unpackID(styleIDS[i]).first != m_dynamicPage)) { /// try to pack on the currentDynamicPage - while (!m_pages[m_dynamicPage]->hasRoom(penInfos[i])) + while (!m_caches[m_dynamicPage]->hasRoom(penInfos[i])) { /// no room - flush the page flushDynamicPage(); @@ -196,7 +196,7 @@ namespace graphics i = 0; } - styleIDS[i] = packID(m_dynamicPage, m_pages[m_dynamicPage]->mapPenInfo(penInfos[i])); + styleIDS[i] = packID(m_dynamicPage, m_caches[m_dynamicPage]->mapPenInfo(penInfos[i])); } ++i; @@ -210,28 +210,28 @@ namespace graphics { uint32_t res = invalidPageHandle(); - for (uint8_t i = 0; i < m_pages.size(); ++i) + for (uint8_t i = 0; i < m_caches.size(); ++i) { - res = m_pages[i]->findGlyph(gk); + res = m_caches[i]->findGlyph(gk); if (res != invalidPageHandle()) return packID(i, res); } - if (!m_pages[m_textPage]->hasRoom(gk, glyphCache)) + if (!m_caches[m_textPage]->hasRoom(gk, glyphCache)) flushTextPage(); - return packID(m_textPage, m_pages[m_textPage]->mapGlyph(gk, glyphCache)); + return packID(m_textPage, m_caches[m_textPage]->mapGlyph(gk, glyphCache)); } - shared_ptr const & Skin::page(int i) const + shared_ptr const & Skin::page(int i) const { - ASSERT(i < m_pages.size(), ()); - return m_pages[i]; + ASSERT(i < m_caches.size(), ()); + return m_caches[i]; } size_t Skin::pagesCount() const { - return m_pages.size(); + return m_caches.size(); } void Skin::addClearPageFn(clearPageFn fn, int priority) @@ -306,7 +306,7 @@ namespace graphics int Skin::nextPage(int i) const { - ASSERT(i < m_pages.size(), ()); + ASSERT(i < m_caches.size(), ()); if (isDynamicPage(i)) return nextDynamicPage(); @@ -355,7 +355,7 @@ namespace graphics void Skin::clearHandles() { - for (unsigned i = 0; i < m_pages.size(); ++i) - m_pages[i]->clear(); + for (unsigned i = 0; i < m_caches.size(); ++i) + m_caches[i]->clear(); } } diff --git a/graphics/skin.hpp b/graphics/skin.hpp index 0abec18af8..7ea72f3573 100644 --- a/graphics/skin.hpp +++ b/graphics/skin.hpp @@ -23,7 +23,7 @@ namespace graphics class BaseTexture; } - class SkinPage; + class ResourceCache; class ResourceManager; struct ResourceStyle; struct PenInfo; @@ -37,13 +37,13 @@ namespace graphics { public: - typedef vector > TSkinPages; + typedef vector > TResourceCaches; typedef function clearPageFn; typedef function overflowFn; private: - TSkinPages m_pages; + TResourceCaches m_caches; uint8_t m_startDynamicPage; uint8_t m_dynamicPage; @@ -57,7 +57,7 @@ namespace graphics shared_ptr m_resourceManager; Skin(shared_ptr const & resourceManager, - TSkinPages const & pages); + TResourceCaches const & pages); friend class SkinLoader; @@ -135,7 +135,7 @@ namespace graphics /// is getting cleared. void addClearPageFn(clearPageFn fn, int priority); - shared_ptr const & page(int i) const; + shared_ptr const & page(int i) const; size_t pagesCount() const; diff --git a/graphics/skin_loader.cpp b/graphics/skin_loader.cpp index 8185ef18ac..f1543c92c1 100644 --- a/graphics/skin_loader.cpp +++ b/graphics/skin_loader.cpp @@ -2,7 +2,7 @@ #include "skin_loader.hpp" #include "resource_manager.hpp" #include "resource_style.hpp" -#include "skin_page.hpp" +#include "resource_cache.hpp" #include "../base/string_utils.hpp" @@ -46,7 +46,7 @@ namespace graphics void SkinLoader::popPage() { - m_pages.push_back(make_shared_ptr(new SkinPage(m_resourceManager, m_fileName.c_str(), m_pages.size()))); + m_pages.push_back(make_shared_ptr(new ResourceCache(m_resourceManager, m_fileName.c_str(), m_pages.size()))); TStylesList::iterator prevIt = m_stylesList.end(); diff --git a/graphics/skin_loader.hpp b/graphics/skin_loader.hpp index 6bbff02a34..e132bff3f0 100644 --- a/graphics/skin_loader.hpp +++ b/graphics/skin_loader.hpp @@ -37,7 +37,7 @@ namespace graphics } class ResourceManager; - class SkinPage; + class ResourceCache; struct ResourceStyle; struct GlyphStyle; @@ -79,7 +79,7 @@ namespace graphics /// skin-specific parameters - vector > m_pages; + vector > m_pages; /// skin-page specific parameters string m_fileName; diff --git a/graphics/text_element.cpp b/graphics/text_element.cpp index 9795d5841f..5dece92cd4 100644 --- a/graphics/text_element.cpp +++ b/graphics/text_element.cpp @@ -1,7 +1,7 @@ #include "text_element.hpp" #include "screen.hpp" #include "skin.hpp" -#include "skin_page.hpp" +#include "resource_cache.hpp" #include "resource_manager.hpp" #include "overlay_renderer.hpp" #include "resource_style.hpp" diff --git a/graphics/text_element.hpp b/graphics/text_element.hpp index 5d68fee30b..2271dd9b52 100644 --- a/graphics/text_element.hpp +++ b/graphics/text_element.hpp @@ -16,7 +16,7 @@ namespace graphics { class ResourceManager; class Skin; - class SkinPage; + class ResourceCache; class OverlayRenderer; class TextElement : public OverlayElement diff --git a/map/drawer.cpp b/map/drawer.cpp index cc4294deb0..59a508c18b 100644 --- a/map/drawer.cpp +++ b/map/drawer.cpp @@ -59,7 +59,7 @@ Drawer::Drawer(Params const & params) m_pScreen->setSkin(m_pSkin); if (m_pSkin) - m_pSkin->addClearPageFn(bind(&Drawer::ClearSkinPage, ThreadSlot(), _1), 0); + m_pSkin->addClearPageFn(bind(&Drawer::ClearResourceCache, ThreadSlot(), _1), 0); } namespace @@ -83,7 +83,7 @@ namespace }; } -void Drawer::ClearSkinPage(size_t threadSlot, uint8_t pipelineID) +void Drawer::ClearResourceCache(size_t threadSlot, uint8_t pipelineID) { drule::rules().ForEachRule(DoMakeInvalidRule(threadSlot, pipelineID)); } diff --git a/map/drawer.hpp b/map/drawer.hpp index d75cee34ad..223dbbd065 100644 --- a/map/drawer.hpp +++ b/map/drawer.hpp @@ -75,7 +75,7 @@ class Drawer shared_ptr m_pScreen; shared_ptr m_pSkin; - static void ClearSkinPage(size_t threadSlot, uint8_t pipelineID); + static void ClearResourceCache(size_t threadSlot, uint8_t pipelineID); typedef pair FeatureID;