Skip to content
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

[data] Refactor resources folder #8123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ stxxl.log
screenlog.0

data/styles/*/*/out/*
data/resources-*_design/*
data/symbols/*/design/*
data/drules_proto_design.bin
data/colors_design.txt
data/patterns_design.txt
Expand Down
1 change: 0 additions & 1 deletion android/app/src/main/assets/resources-6plus_clear

This file was deleted.

1 change: 0 additions & 1 deletion android/app/src/main/assets/resources-6plus_dark

This file was deleted.

1 change: 0 additions & 1 deletion android/app/src/main/assets/resources-default

This file was deleted.

1 change: 0 additions & 1 deletion android/app/src/main/assets/resources-hdpi_clear

This file was deleted.

1 change: 0 additions & 1 deletion android/app/src/main/assets/resources-hdpi_dark

This file was deleted.

1 change: 0 additions & 1 deletion android/app/src/main/assets/resources-mdpi_clear

This file was deleted.

1 change: 0 additions & 1 deletion android/app/src/main/assets/resources-mdpi_dark

This file was deleted.

1 change: 0 additions & 1 deletion android/app/src/main/assets/resources-xhdpi_clear

This file was deleted.

1 change: 0 additions & 1 deletion android/app/src/main/assets/resources-xhdpi_dark

This file was deleted.

1 change: 0 additions & 1 deletion android/app/src/main/assets/resources-xxhdpi_clear

This file was deleted.

1 change: 0 additions & 1 deletion android/app/src/main/assets/resources-xxhdpi_dark

This file was deleted.

1 change: 0 additions & 1 deletion android/app/src/main/assets/resources-xxxhdpi_clear

This file was deleted.

1 change: 0 additions & 1 deletion android/app/src/main/assets/resources-xxxhdpi_dark

This file was deleted.

1 change: 1 addition & 0 deletions android/app/src/main/assets/symbols
Binary file removed data/resources-6plus_dark/area-hatching.png
Binary file not shown.
Binary file removed data/resources-6plus_dark/traffic-arrow.png
Binary file not shown.
Binary file removed data/resources-hdpi_clear/area-hatching.png
Binary file not shown.
Binary file removed data/resources-hdpi_clear/traffic-arrow.png
Binary file not shown.
Binary file removed data/resources-hdpi_dark/area-hatching.png
Binary file not shown.
Binary file removed data/resources-hdpi_dark/traffic-arrow.png
Binary file not shown.
Binary file removed data/resources-mdpi_clear/area-hatching.png
Binary file not shown.
Binary file removed data/resources-mdpi_clear/traffic-arrow.png
Binary file not shown.
Binary file removed data/resources-mdpi_dark/area-hatching.png
Binary file not shown.
Binary file removed data/resources-mdpi_dark/traffic-arrow.png
Binary file not shown.
Binary file removed data/resources-xhdpi_clear/area-hatching.png
Binary file not shown.
Binary file removed data/resources-xhdpi_clear/traffic-arrow.png
Binary file not shown.
Binary file removed data/resources-xhdpi_dark/area-hatching.png
Binary file not shown.
Binary file removed data/resources-xhdpi_dark/traffic-arrow.png
Binary file not shown.
Binary file removed data/resources-xxhdpi_clear/area-hatching.png
Binary file not shown.
Binary file removed data/resources-xxhdpi_clear/traffic-arrow.png
Binary file not shown.
Binary file removed data/resources-xxhdpi_dark/area-hatching.png
Binary file not shown.
Binary file removed data/resources-xxhdpi_dark/traffic-arrow.png
Binary file not shown.
Binary file removed data/resources-xxxhdpi_clear/area-hatching.png
Binary file not shown.
Binary file removed data/resources-xxxhdpi_clear/traffic-arrow.png
Binary file not shown.
Binary file removed data/resources-xxxhdpi_dark/area-hatching.png
Binary file not shown.
Binary file removed data/resources-xxxhdpi_dark/traffic-arrow.png
Binary file not shown.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions docs/STRUCTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ Automatically generated:

### Styles and icons

- `resources-default/` -
- `resources-svg/` - social networks icons
- `symbols/` - symbols for different screen DPIs
- `symbols/default/` - default resources used on all sceen DPIs
- `symbols-svg/` - social networks icons
- `search-icons/svg/` - source SVG files for search categories icons
- `styles/` - map [style files](STYLES.md#files)

Automatically [generated](STYLES.md#technical-details):
- `resources-*/` - icons skin files in various resolutions for `dark` and `clear` (light) themes.
- `symbols/` - icons skin files in various resolutions for `dark` and `clear` (light) themes.
- `drules_proto*` - binary drawing rules files.
- `colors.txt`,`patterns.txt`,`visibility.txt`

Expand Down
30 changes: 6 additions & 24 deletions drape/drape_tests/static_texture_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,34 +1,16 @@
#include "testing/testing.hpp"

#include "indexer/map_style.hpp"
#include "indexer/map_style_reader.hpp"

#include "drape/drape_tests/testing_graphics_context.hpp"
#include "drape/static_texture.hpp"

#include <string>
#include <vector>

UNIT_TEST(CheckTrafficArrowTextures)
{
static std::vector<std::string> skinPaths = {"6plus", "mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"};
static std::vector<MapStyle> styles = {MapStyle::MapStyleClear, MapStyle::MapStyleDark,
MapStyle::MapStyleVehicleClear,
MapStyle::MapStyleVehicleDark};

TestingGraphicsContext context;
for (auto const & style : styles)
{
GetStyleReader().SetCurrentStyle(style);
for (size_t i = 0; i < skinPaths.size(); ++i)
{
dp::StaticTexture texture(make_ref(&context), "traffic-arrow", skinPaths[i],
dp::TextureFormat::RGBA8, nullptr);
TEST(texture.IsLoadingCorrect(), ());
dp::StaticTexture texture(make_ref(&context), "traffic-arrow", dp::StaticTexture::kDefaultResource,
dp::TextureFormat::RGBA8, nullptr);
TEST(texture.IsLoadingCorrect(), ());

dp::StaticTexture texture2(make_ref(&context), "area-hatching", skinPaths[i],
dp::TextureFormat::RGBA8, nullptr);
TEST(texture2.IsLoadingCorrect(), ());
}
}
dp::StaticTexture texture2(make_ref(&context), "area-hatching", dp::StaticTexture::kDefaultResource,
dp::TextureFormat::RGBA8, nullptr);
TEST(texture2.IsLoadingCorrect(), ());
}
4 changes: 2 additions & 2 deletions drape/texture_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,10 @@ void TextureManager::Init(ref_ptr<dp::GraphicsContext> context, Params const & p

// Initialize static textures.
m_trafficArrowTexture =
make_unique_dp<StaticTexture>(context, "traffic-arrow.png", m_resPostfix,
make_unique_dp<StaticTexture>(context, "traffic-arrow.png", StaticTexture::kDefaultResource,
dp::TextureFormat::RGBA8, make_ref(m_textureAllocator));
m_hatchingTexture =
make_unique_dp<StaticTexture>(context, "area-hatching.png", m_resPostfix,
make_unique_dp<StaticTexture>(context, "area-hatching.png", StaticTexture::kDefaultResource,
dp::TextureFormat::RGBA8, make_ref(m_textureAllocator));
m_arrowTexture =
CreateArrowTexture(context, make_ref(m_textureAllocator), params.m_arrowTexturePath,
Expand Down
4 changes: 2 additions & 2 deletions drape_frontend/gui/skin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ ReaderPtr<Reader> ResolveGuiSkinFile(std::string const & deviceType)
std::unique_ptr<Reader> reader;
try
{
reader = pl.GetReader("resources-default/" + deviceType + ".ui");
reader = pl.GetReader("symbols/default/" + deviceType + ".ui");
}
catch(FileAbsentException & e)
{
Expand All @@ -299,7 +299,7 @@ ReaderPtr<Reader> ResolveGuiSkinFile(std::string const & deviceType)
{
try
{
reader = pl.GetReader("resources-default/default.ui");
reader = pl.GetReader("symbols/default/default.ui");
}
catch(FileAbsentException & e)
{
Expand Down
31 changes: 16 additions & 15 deletions indexer/map_style_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@

namespace
{
std::string const kSuffixDark = "_dark";
std::string const kSuffixClear = "_clear";
std::string const kSuffixVehicleDark = "_vehicle_dark";
std::string const kSuffixVehicleClear = "_vehicle_clear";
std::string const kSuffixOutdoorsClear = "_outdoors_clear";
std::string const kSuffixOutdoorsDark = "_outdoors_dark";
std::string const kSuffixDark = "dark";
std::string const kSuffixClear = "clear";
std::string const kSuffixVehicleDark = "vehicle_dark";
std::string const kSuffixVehicleClear = "vehicle_clear";
std::string const kSuffixOutdoorsClear = "outdoors_clear";
std::string const kSuffixOutdoorsDark = "outdoors_dark";

std::string const kStylesOverrideDir = "styles";

#ifdef BUILD_DESIGNER
std::string const kSuffixDesignTool = "_design";
std::string const kSuffixDesignTool = "design";
#endif // BUILD_DESIGNER

std::string GetStyleRulesSuffix(MapStyle mapStyle)
Expand All @@ -40,7 +40,7 @@ std::string GetStyleRulesSuffix(MapStyle mapStyle)
case MapStyleOutdoorsDark:
return kSuffixOutdoorsDark;
case MapStyleMerged:
return std::string();
return "";

case MapStyleCount:
break;
Expand Down Expand Up @@ -68,7 +68,7 @@ std::string GetStyleResourcesSuffix(MapStyle mapStyle)
case MapStyleOutdoorsClear:
return kSuffixClear;
case MapStyleMerged:
return std::string();
return "";

case MapStyleCount:
break;
Expand Down Expand Up @@ -101,8 +101,11 @@ bool StyleReader::IsCarNavigationStyle() const

ReaderPtr<Reader> StyleReader::GetDrawingRulesReader() const
{
std::string rulesFile =
std::string("drules_proto") + GetStyleRulesSuffix(GetCurrentStyle()) + ".bin";
std::string rulesFile;
if (const std::string & stylesPrefix = GetStyleRulesSuffix(GetCurrentStyle()); stylesPrefix.empty())
rulesFile = "drules_proto.bin";
else
rulesFile = std::string("drules_proto_") + stylesPrefix + ".bin";

auto overriddenRulesFile =
base::JoinPath(GetPlatform().WritableDir(), kStylesOverrideDir, rulesFile);
Expand All @@ -120,9 +123,7 @@ ReaderPtr<Reader> StyleReader::GetDrawingRulesReader() const
ReaderPtr<Reader> StyleReader::GetResourceReader(std::string const & file,
std::string_view density) const
{
std::string const resourceDir =
std::string("resources-").append(density) + GetStyleResourcesSuffix(GetCurrentStyle());
std::string resFile = base::JoinPath(resourceDir, file);
std::string resFile = base::JoinPath("symbols", std::string{density}, GetStyleResourcesSuffix(GetCurrentStyle()), file);

auto overriddenResFile = base::JoinPath(GetPlatform().WritableDir(), kStylesOverrideDir, resFile);
if (GetPlatform().IsFileExistsByFullPath(overriddenResFile))
Expand All @@ -138,7 +139,7 @@ ReaderPtr<Reader> StyleReader::GetResourceReader(std::string const & file,

ReaderPtr<Reader> StyleReader::GetDefaultResourceReader(std::string const & file) const
{
return GetPlatform().GetReader(base::JoinPath("resources-default", file));
return GetPlatform().GetReader(base::JoinPath("symbols/default", file));
}

StyleReader & GetStyleReader()
Expand Down