-
-
Notifications
You must be signed in to change notification settings - Fork 880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Working on custom bookmark icons. #2795
base: master
Are you sure you want to change the base?
Conversation
c58c9c1
to
4f42d9f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут много рефакторингов и улучшений, которые надо вынести и помержить отдельно, не затягивая, например jni.
Остальное обсудим, будем делать итерационно, я бы начал с нормальных стилей.
drape_frontend/user_mark_shapes.cpp
Outdated
textures->GetSymbolRegion(backgroundSymbol, backgroundRegion); | ||
CHECK_EQUAL(region.GetTextureIndex(), backgroundRegion.GetTextureIndex(), ()); | ||
if (textures->GetSymbolRegionSafe(background, backgroundRegion)) | ||
CHECK_EQUAL(symbolRegion.GetTextureIndex(), backgroundRegion.GetTextureIndex(), ()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это точно нужно в релизе?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У нас в целом стратегия предпочтения CHECK там где не критично по производительности.
В drape это имеет смысл, потому что много зависит от зоопарка девайсов.
drape_frontend/user_mark_shapes.cpp
Outdated
dp::TextureManager::SymbolRegion region; | ||
textures->GetSymbolRegion(symbolName, region); | ||
symbolSize = region.GetPixelSize(); | ||
textures->GetSymbolRegion(symbolName, symbolRegion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем нужна небезопасная версия без проверки на возвращаемое значение? Кстати, может std::optional будет лучше?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Она все также проверяет, просто дает дополнительный лог.
- Я не сторонник огульного переписывания на optional, тем более что это ничего не дает (ок синтаксис красивее), а иногда еще и ухудшит :)
} | ||
catch (RootException & e) | ||
{ | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Штатно? Лог не нужен?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не нужен, входная строка может быть не обязательно файл.
|
||
int bpp; | ||
m_data = stbi_load_from_memory(buffer.data(), static_cast<int>(buffer.size()), &m_width, &m_height, &bpp, 0); | ||
if (m_data && bpp == 4) // only this fits TextureFormat::RGBA8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Т.е. мы не все картинки сможем поддерживать?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если только делать какую-то "конверсию".
drape_frontend/user_mark_shapes.cpp
Outdated
@@ -120,10 +122,11 @@ std::string GetSymbolNameForZoomLevel(ref_ptr<UserPointMark::SymbolNameZoomInfo> | |||
if (!symbolNames) | |||
return {}; | |||
|
|||
for (auto itName = symbolNames->crbegin(); itName != symbolNames->crend(); ++itName) | |||
auto const & v = symbolNames->m_zoomInfo; | |||
for (auto i = v.crbegin(); i != v.crend(); ++i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше it для итераторов, а i для индексов, тогда проще код читать.
fileSavePath = GenerateValidAndUniqueFilePathForKML(file); | ||
ZipFileReader::UnzipFile(filePath, file, fileSavePath); | ||
} | ||
else if (ext == ".png") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В корне будет плохо держать картинки, при их большом количестве сильно замедлится загрузка меток.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Они будут лежать там где указано в kml, обычно это images, files, ...
- Сильно не замедлится.
map/bookmark_helpers.cpp
Outdated
@@ -296,7 +290,9 @@ std::unique_ptr<kml::FileData> LoadKmlFile(std::string const & file, KmlFileType | |||
|
|||
std::string GetKMLPath(std::string const & filePath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это геттер, который много всего внутри делает, надо его отрефакторить.
if (!bmData.m_iconPath.empty()) | ||
{ | ||
// Check that user icon file is actually present. | ||
if (!GetPlatform().IsFileExistsByFullPath(base::JoinPath(GetBookmarksDirectory(), bmData.m_iconPath))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А зачем именно в CreateBookmark это проверять?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Сейчас это самое логично место. Возможно будет по другому, когда кто-то перепишет все :)
map/map_tests/kmz_unarchive_test.cpp
Outdated
{ | ||
TEST(base::DeleteFileX(filePath), ()); | ||
// Cleanup 'files' folder from "test.kmz". | ||
TEST(Platform::RmDirRecursively(pngDir), ()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Эти тесты поудаляют другие десктопные метки для работы/других кейзов?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, тут стоит пересмотреть логику.
@@ -1338,7 +1337,7 @@ Java_com_mapswithme_maps_Framework_nativeSetMapStyle(JNIEnv * env, jclass, jint | |||
} | |||
|
|||
JNIEXPORT jint JNICALL | |||
Java_com_mapswithme_maps_Framework_nativeGetMapStyle(JNIEnv * env, jclass, jint mapStyle) | |||
Java_com_mapswithme_maps_Framework_nativeGetMapStyle(JNIEnv * env, jclass) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
env тоже удалить тогда
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Давай вмержим 1-4, 7, 9 коммиты?
Давай: #3282 |
Rebase? |
To better support different formats, a newer version of stb_image.h should be used: https://github.com/nothings/stb/blob/master/stb_image.h |
1ecaf69
to
0bf103e
Compare
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
Export is broken on Android ? |
I just did a rebase on the latest master. This is a draft :) |
Ok, that's weird when I export bookmarks, I have a Memory Warning
|
Important requirements for this PR:
|
Accidentally closed previous one #2770.
Closes #2785