Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/drape
diff options
context:
space:
mode:
authorr.kuznetsov <r.kuznetsov@corp.mail.ru>2015-07-08 15:50:43 +0300
committerr.kuznetsov <r.kuznetsov@corp.mail.ru>2015-11-30 16:09:31 +0300
commit99d172530c1077924bbeb002afbf4a34d26c9243 (patch)
tree83deefbd7053040b80936c5011256f57cef4fcc6 /drape
parent7b95adff42ca55aaac61d6f00bad8ffb233da975 (diff)
Added symbols reloading on changing map style
Diffstat (limited to 'drape')
-rw-r--r--drape/symbols_texture.cpp8
-rw-r--r--drape/symbols_texture.hpp2
-rw-r--r--drape/texture.cpp20
-rw-r--r--drape/texture.hpp4
-rw-r--r--drape/texture_manager.cpp14
-rw-r--r--drape/texture_manager.hpp6
6 files changed, 45 insertions, 9 deletions
diff --git a/drape/symbols_texture.cpp b/drape/symbols_texture.cpp
index 9e7761ad37..9a01c33c71 100644
--- a/drape/symbols_texture.cpp
+++ b/drape/symbols_texture.cpp
@@ -166,6 +166,14 @@ void SymbolsTexture::Load(string const & skinPathName)
stbi_image_free(data);
}
+void SymbolsTexture::Invalidate(string const & skinPathName)
+{
+ Destroy();
+ m_definition.clear();
+
+ Load(skinPathName);
+}
+
ref_ptr<Texture::ResourceInfo> SymbolsTexture::FindResource(Texture::Key const & key, bool & newResource)
{
newResource = false;
diff --git a/drape/symbols_texture.hpp b/drape/symbols_texture.hpp
index c165faf453..27e88f63ef 100644
--- a/drape/symbols_texture.hpp
+++ b/drape/symbols_texture.hpp
@@ -33,6 +33,8 @@ public:
ref_ptr<ResourceInfo> FindResource(Key const & key, bool & newResource);
+ void Invalidate(string const & skinPathName);
+
private:
void Fail();
void Load(string const & skinPathName);
diff --git a/drape/texture.cpp b/drape/texture.cpp
index db646439a3..f02870edd2 100644
--- a/drape/texture.cpp
+++ b/drape/texture.cpp
@@ -31,13 +31,7 @@ Texture::Texture()
Texture::~Texture()
{
- if (m_textureID != -1)
- {
- GLFunctions::glDeleteTexture(m_textureID);
-#if defined(TRACK_GPU_MEM)
- dp::GPUMemTracker::Inst().RemoveDeallocated("Texture", m_textureID);
-#endif
- }
+ Destroy();
}
void Texture::Create(uint32_t width, uint32_t height, TextureFormat format)
@@ -86,6 +80,18 @@ void Texture::Create(uint32_t width, uint32_t height, TextureFormat format, ref_
#endif
}
+void Texture::Destroy()
+{
+ if (m_textureID != -1)
+ {
+ GLFunctions::glDeleteTexture(m_textureID);
+ m_textureID = -1;
+#if defined(TRACK_GPU_MEM)
+ dp::GPUMemTracker::Inst().RemoveDeallocated("Texture", m_textureID);
+#endif
+ }
+}
+
void Texture::SetFilterParams(glConst minFilter, glConst magFilter)
{
ASSERT_ID;
diff --git a/drape/texture.hpp b/drape/texture.hpp
index 405c5373c6..705bfcc96e 100644
--- a/drape/texture.hpp
+++ b/drape/texture.hpp
@@ -49,6 +49,7 @@ public:
void Create(uint32_t width, uint32_t height, TextureFormat format);
void Create(uint32_t width, uint32_t height, TextureFormat format, ref_ptr<void> data);
+
void SetFilterParams(glConst minFilter, glConst magFilter);
void SetWrapMode(glConst sMode, glConst tMode);
@@ -69,6 +70,9 @@ public:
static uint32_t GetMaxTextureSize();
+protected:
+ void Destroy();
+
private:
void UnpackFormat(TextureFormat format, glConst & layout, glConst & pixelType);
int32_t GetID() const;
diff --git a/drape/texture_manager.cpp b/drape/texture_manager.cpp
index 36c8d286d6..3908221999 100644
--- a/drape/texture_manager.cpp
+++ b/drape/texture_manager.cpp
@@ -287,8 +287,8 @@ size_t TextureManager::FindHybridGlyphsGroup(TMultilineText const & text)
void TextureManager::Init(Params const & params)
{
GLFunctions::glPixelStore(gl_const::GLUnpackAlignment, 1);
- m_symbolTexture = make_unique_dp<SymbolsTexture>(my::JoinFoldersToPath(string("resources-") + params.m_resPrefix, "symbols"));
+ m_symbolTexture = make_unique_dp<SymbolsTexture>(GetSymbolsTexturePath(params.m_resPostfix));
m_stipplePenTexture = make_unique_dp<StipplePenTexture>(m2::PointU(STIPPLE_TEXTURE_SIZE, STIPPLE_TEXTURE_SIZE));
m_colorTexture = make_unique_dp<ColorTexture>(m2::PointU(COLOR_TEXTURE_SIZE, COLOR_TEXTURE_SIZE));
@@ -319,6 +319,13 @@ void TextureManager::Init(Params const & params)
});
}
+void TextureManager::Invalidate(string const & postfix)
+{
+ ASSERT(m_symbolTexture != nullptr, ());
+ ref_ptr<SymbolsTexture> symbolsTexture = make_ref(m_symbolTexture);
+ symbolsTexture->Invalidate(GetSymbolsTexturePath(postfix));
+}
+
void TextureManager::GetSymbolRegion(string const & symbolName, SymbolRegion & region)
{
GetRegionBase(make_ref(m_symbolTexture), region, SymbolsTexture::SymbolKey(symbolName));
@@ -349,4 +356,9 @@ constexpr size_t TextureManager::GetInvalidGlyphGroup()
return INVALID_GLYPH_GROUP;
}
+string TextureManager::GetSymbolsTexturePath(string const & postfix) const
+{
+ return my::JoinFoldersToPath(string("resources-") + postfix, "symbols");
+}
+
} // namespace dp
diff --git a/drape/texture_manager.hpp b/drape/texture_manager.hpp
index e3ccaf4a68..e0feac940d 100644
--- a/drape/texture_manager.hpp
+++ b/drape/texture_manager.hpp
@@ -65,7 +65,7 @@ public:
struct Params
{
- string m_resPrefix;
+ string m_resPostfix;
GlyphManager::Params m_glyphMngParams;
};
@@ -73,6 +73,8 @@ public:
void Release();
void Init(Params const & params);
+ void Invalidate(string const & postfix);
+
void GetSymbolRegion(string const & symbolName, SymbolRegion & region);
typedef buffer_vector<uint8_t, 8> TStipplePattern;
@@ -209,6 +211,8 @@ private:
static constexpr size_t GetInvalidGlyphGroup();
private:
+ string GetSymbolsTexturePath(string const & postfix) const;
+
drape_ptr<Texture> m_symbolTexture;
drape_ptr<Texture> m_stipplePenTexture;
drape_ptr<Texture> m_colorTexture;