Minor drape fixes #7855
15 changed files with 47 additions and 70 deletions
|
@ -7,7 +7,7 @@
|
|||
#include <memory>
|
||||
#include <numeric>
|
||||
|
||||
namespace
|
||||
namespace buffer_vector_test
|
||||
{
|
||||
template <class TCont>
|
||||
void CheckVector(TCont & cont, size_t count)
|
||||
|
@ -16,7 +16,6 @@ namespace
|
|||
for (size_t i = 0; i < count; ++i)
|
||||
TEST_EQUAL ( cont[i], i, () );
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(BufferVector_PushBackAndRealloc)
|
||||
{
|
||||
|
@ -414,3 +413,4 @@ UNIT_TEST(BufferVector_Erase)
|
|||
TEST_EQUAL(v1[i], v2[i], ());
|
||||
}
|
||||
}
|
||||
} // namespace buffer_vector_test
|
||||
|
|
|
@ -1,36 +1,7 @@
|
|||
#include "message.hpp"
|
||||
|
||||
#include "std/target_os.hpp"
|
||||
|
||||
#include <utf8/unchecked.h>
|
||||
|
||||
std::string DebugPrint(std::string const & t)
|
||||
{
|
||||
#ifdef OMIM_OS_WINDOWS
|
||||
string res;
|
||||
res.push_back('\'');
|
||||
for (string::const_iterator it = t.begin(); it != t.end(); ++it)
|
||||
{
|
||||
static char const toHex[] = "0123456789abcdef";
|
||||
unsigned char const c = static_cast<unsigned char>(*it);
|
||||
if (c >= ' ' && c <= '~')
|
||||
res.push_back(*it);
|
||||
else
|
||||
{
|
||||
res.push_back('\\');
|
||||
res.push_back(toHex[c >> 4]);
|
||||
res.push_back(toHex[c & 0xf]);
|
||||
}
|
||||
}
|
||||
res.push_back('\'');
|
||||
return res;
|
||||
|
||||
#else
|
||||
// Assume like UTF8 string.
|
||||
return t;
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace internal
|
||||
{
|
||||
std::string ToUtf8(std::u16string_view utf16)
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
//@{
|
||||
template <typename T> inline std::string DebugPrint(T const & t);
|
||||
|
||||
std::string DebugPrint(std::string const & t);
|
||||
inline std::string DebugPrint(std::string s) { return s; }
|
||||
inline std::string DebugPrint(char const * t);
|
||||
inline std::string DebugPrint(char * t) { return DebugPrint(static_cast<char const *>(t)); }
|
||||
inline std::string DebugPrint(char t);
|
||||
|
|
|
@ -27,6 +27,7 @@ set(SRC
|
|||
drape_global.hpp
|
||||
drape_routine.hpp
|
||||
dynamic_texture.hpp
|
||||
font_constants.hpp
|
||||
font_texture.cpp
|
||||
font_texture.hpp
|
||||
framebuffer.cpp
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "testing/testing.hpp"
|
||||
|
||||
#include "drape/drape_routine.hpp"
|
||||
#include "drape/font_constants.hpp"
|
||||
#include "drape/font_texture.hpp"
|
||||
#include "drape/glyph_manager.hpp"
|
||||
|
||||
|
@ -99,9 +100,10 @@ UNIT_TEST(UploadingGlyphs)
|
|||
GlyphManager mng(args);
|
||||
DummyGlyphIndex index(m2::PointU(kTextureSize, kTextureSize), make_ref(&mng), make_ref(&glyphGenerator));
|
||||
size_t count = 1; // invalid symbol glyph has mapped internally.
|
||||
count += (index.MapResource(GlyphKey(0x58, GlyphManager::kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
count += (index.MapResource(GlyphKey(0x59, GlyphManager::kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
count += (index.MapResource(GlyphKey(0x61, GlyphManager::kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
using dp::kDynamicGlyphSize;
|
||||
count += (index.MapResource(GlyphKey(0x58, kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
count += (index.MapResource(GlyphKey(0x59, kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
count += (index.MapResource(GlyphKey(0x61, kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
while (index.GetPendingNodesCount() < count)
|
||||
;
|
||||
|
||||
|
@ -118,12 +120,12 @@ UNIT_TEST(UploadingGlyphs)
|
|||
index.UploadResources(make_ref(&context), make_ref(&tex));
|
||||
|
||||
count = 0;
|
||||
count += (index.MapResource(GlyphKey(0x68, GlyphManager::kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
count += (index.MapResource(GlyphKey(0x30, GlyphManager::kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
count += (index.MapResource(GlyphKey(0x62, GlyphManager::kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
count += (index.MapResource(GlyphKey(0x65, GlyphManager::kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
count += (index.MapResource(GlyphKey(0x400, GlyphManager::kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
count += (index.MapResource(GlyphKey(0x401, GlyphManager::kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
count += (index.MapResource(GlyphKey(0x68, kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
count += (index.MapResource(GlyphKey(0x30, kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
count += (index.MapResource(GlyphKey(0x62, kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
count += (index.MapResource(GlyphKey(0x65, kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
count += (index.MapResource(GlyphKey(0x400, kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
count += (index.MapResource(GlyphKey(0x401, kDynamicGlyphSize)) != nullptr) ? 1 : 0;
|
||||
while (index.GetPendingNodesCount() < count)
|
||||
;
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#include "testing/testing.hpp"
|
||||
|
||||
#include "drape/bidi.hpp"
|
||||
#include "drape/drape_tests/img.hpp"
|
||||
|
||||
#include "drape/bidi.hpp"
|
||||
#include "drape/font_constants.hpp"
|
||||
#include "drape/glyph_manager.hpp"
|
||||
|
||||
#include "platform/platform.hpp"
|
||||
|
@ -48,7 +50,7 @@ public:
|
|||
std::vector<dp::GlyphManager::Glyph> glyphs;
|
||||
auto generateGlyph = [this, &glyphs](strings::UniChar c)
|
||||
{
|
||||
dp::GlyphManager::Glyph g = m_mng->GetGlyph(c, dp::GlyphManager::kDynamicGlyphSize);
|
||||
dp::GlyphManager::Glyph g = m_mng->GetGlyph(c, dp::kDynamicGlyphSize);
|
||||
glyphs.push_back(dp::GlyphManager::GenerateGlyph(g, m_mng->GetSdfScale()));
|
||||
g.m_image.Destroy();
|
||||
};
|
||||
|
|
7
drape/font_constants.hpp
Normal file
7
drape/font_constants.hpp
Normal file
|
@ -0,0 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
namespace dp
|
||||
{
|
||||
uint32_t constexpr kSdfBorder = 4;
|
||||
int constexpr kDynamicGlyphSize = -1;
|
||||
} // namespace dp
|
|
@ -1,13 +1,9 @@
|
|||
#include "drape/font_texture.hpp"
|
||||
|
||||
#include "drape/font_constants.hpp"
|
||||
#include "drape/pointers.hpp"
|
||||
|
||||
#include "platform/platform.hpp"
|
||||
#include "coding/reader.hpp"
|
||||
|
||||
#include "base/logging.hpp"
|
||||
#include "base/stl_helpers.hpp"
|
||||
#include "base/string_utils.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
@ -100,7 +96,7 @@ GlyphIndex::GlyphIndex(m2::PointU const & size, ref_ptr<GlyphManager> mng,
|
|||
uint32_t constexpr kPredefinedGlyphsCount = 128;
|
||||
for (uint32_t i = 0; i < kPredefinedGlyphsCount; ++i)
|
||||
{
|
||||
auto const key = GlyphKey(i, GlyphManager::kDynamicGlyphSize);
|
||||
auto const key = GlyphKey(i, kDynamicGlyphSize);
|
||||
|
||||
MapResource(key, newResource);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "drape/glyph_manager.hpp"
|
||||
|
||||
#include "drape/font_constants.hpp"
|
||||
|
||||
#include "platform/platform.hpp"
|
||||
|
||||
#include "coding/reader.hpp"
|
||||
|
@ -242,8 +244,7 @@ public:
|
|||
};
|
||||
|
||||
result.m_code = unicodePoint;
|
||||
result.m_fixedSize = isSdf ? GlyphManager::kDynamicGlyphSize
|
||||
: static_cast<int>(baseHeight);
|
||||
result.m_fixedSize = isSdf ? kDynamicGlyphSize : static_cast<int>(baseHeight);
|
||||
FT_Done_Glyph(glyph);
|
||||
|
||||
return result;
|
||||
|
@ -474,7 +475,7 @@ GlyphManager::GlyphManager(GlyphManager::Params const & params)
|
|||
node.second = static_cast<int>(uniBlock.m_end + 1 - uniBlock.m_start + m_impl->m_fonts.size());
|
||||
});
|
||||
|
||||
for (CoverNode & node : coverInfo)
|
||||
for (CoverNode const & node : coverInfo)
|
||||
{
|
||||
UnicodeBlock & uniBlock = m_impl->m_blocks[node.first];
|
||||
uniBlock.m_fontsWeight.resize(m_impl->m_fonts.size(), 0);
|
||||
|
@ -612,8 +613,8 @@ GlyphManager::Glyph GlyphManager::GenerateGlyph(Glyph const & glyph, uint32_t sd
|
|||
|
||||
img.GenerateSDF(1.0f / static_cast<float>(sdfScale));
|
||||
|
||||
ASSERT(img.GetWidth() == glyph.m_image.m_width, ());
|
||||
ASSERT(img.GetHeight() == glyph.m_image.m_height, ());
|
||||
ASSERT_EQUAL(img.GetWidth(), glyph.m_image.m_width, ());
|
||||
ASSERT_EQUAL(img.GetHeight(), glyph.m_image.m_height, ());
|
||||
|
||||
size_t const bufferSize = base::NextPowOf2(glyph.m_image.m_width * glyph.m_image.m_height);
|
||||
resultGlyph.m_image.m_data = SharedBufferManager::instance().reserveSharedBuffer(bufferSize);
|
||||
|
|
|
@ -9,15 +9,11 @@
|
|||
|
||||
namespace dp
|
||||
{
|
||||
uint32_t constexpr kSdfBorder = 4;
|
||||
|
||||
struct UnicodeBlock;
|
||||
|
||||
class GlyphManager
|
||||
{
|
||||
public:
|
||||
static int constexpr kDynamicGlyphSize = -1;
|
||||
|
||||
struct Params
|
||||
{
|
||||
std::string m_uniBlocks;
|
||||
|
|
|
@ -329,7 +329,7 @@ uint32_t TextureManager::GetNumberOfUnfoundCharacters(strings::UniString const &
|
|||
HybridGlyphGroup const & group)
|
||||
{
|
||||
uint32_t cnt = 0;
|
||||
for (auto const & c : text)
|
||||
for (auto const c : text)
|
||||
{
|
||||
if (group.m_glyphs.find(std::make_pair(c, fixedHeight)) == group.m_glyphs.end())
|
||||
cnt++;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "base/string_utils.hpp"
|
||||
|
||||
#include "drape/bidi.hpp"
|
||||
#include "drape/font_constants.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
@ -130,7 +131,7 @@ void StaticLabel::CacheStaticText(std::string const & text, char const * delim,
|
|||
result.m_alphabet.insert(str.begin(), str.end());
|
||||
|
||||
dp::TextureManager::TMultilineGlyphsBuffer buffers;
|
||||
mng->GetGlyphRegions(textParts, dp::GlyphManager::kDynamicGlyphSize, buffers);
|
||||
mng->GetGlyphRegions(textParts, dp::kDynamicGlyphSize, buffers);
|
||||
|
||||
#ifdef DEBUG
|
||||
ASSERT_EQUAL(textParts.size(), buffers.size(), ());
|
||||
|
@ -307,7 +308,7 @@ ref_ptr<dp::Texture> MutableLabel::SetAlphabet(std::string const & alphabet,
|
|||
base::SortUnique(str);
|
||||
|
||||
dp::TextureManager::TGlyphsBuffer buffer;
|
||||
mng->GetGlyphRegions(str, dp::GlyphManager::kDynamicGlyphSize, buffer);
|
||||
mng->GetGlyphRegions(str, dp::kDynamicGlyphSize, buffer);
|
||||
m_alphabet.reserve(buffer.size());
|
||||
|
||||
ASSERT_EQUAL(str.size(), buffer.size(), ());
|
||||
|
@ -495,7 +496,7 @@ bool MutableLabelHandle::Update(ScreenBase const & screen)
|
|||
alphabetStr.push_back(node.first);
|
||||
|
||||
m_glyphsReady = m_textureManager->AreGlyphsReady(alphabetStr,
|
||||
dp::GlyphManager::kDynamicGlyphSize);
|
||||
dp::kDynamicGlyphSize);
|
||||
}
|
||||
|
||||
if (!m_glyphsReady)
|
||||
|
@ -592,7 +593,7 @@ StaticLabelHandle::StaticLabelHandle(uint32_t id, ref_ptr<dp::TextureManager> te
|
|||
bool StaticLabelHandle::Update(ScreenBase const & screen)
|
||||
{
|
||||
if (!m_glyphsReady)
|
||||
m_glyphsReady = m_textureManager->AreGlyphsReady(m_alphabet, dp::GlyphManager::kDynamicGlyphSize);
|
||||
m_glyphsReady = m_textureManager->AreGlyphsReady(m_alphabet, dp::kDynamicGlyphSize);
|
||||
|
||||
if (!m_glyphsReady)
|
||||
return false;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "drape/bidi.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <iterator> // std::reverse_iterator
|
||||
#include <numeric>
|
||||
|
||||
namespace df
|
||||
|
@ -297,7 +297,7 @@ void TextLayout::Init(strings::UniString && text, float fontSize, bool isSdf, re
|
|||
float const fontScale = static_cast<float>(vpi.GetFontScale());
|
||||
float const baseSize = static_cast<float>(vpi.GetGlyphBaseSize());
|
||||
m_textSizeRatio = isSdf ? (fontSize * fontScale / baseSize) : 1.0f;
|
||||
m_fixedHeight = isSdf ? dp::GlyphManager::kDynamicGlyphSize
|
||||
m_fixedHeight = isSdf ? dp::kDynamicGlyphSize
|
||||
: static_cast<int>(fontSize * fontScale);
|
||||
textures->GetGlyphRegions(m_text, m_fixedHeight, m_metrics);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "drape_frontend/shape_view_params.hpp"
|
||||
|
||||
#include "drape/font_constants.hpp"
|
||||
#include "drape/glsl_types.hpp"
|
||||
#include "drape/pointers.hpp"
|
||||
#include "drape/texture_manager.hpp"
|
||||
|
@ -44,7 +45,7 @@ protected:
|
|||
dp::TextureManager::TGlyphsBuffer m_metrics;
|
||||
strings::UniString m_text;
|
||||
float m_textSizeRatio = 0.0f;
|
||||
int m_fixedHeight = dp::GlyphManager::kDynamicGlyphSize;
|
||||
int m_fixedHeight = dp::kDynamicGlyphSize;
|
||||
};
|
||||
|
||||
class StraightTextLayout : public TextLayout
|
||||
|
@ -78,10 +79,9 @@ private:
|
|||
void Cache(TGenerator & generator) const
|
||||
{
|
||||
size_t beginOffset = 0;
|
||||
for (std::pair<size_t, glsl::vec2> const & node : m_offsets)
|
||||
for (auto const & [endOffset, coordinates] : m_offsets)
|
||||
{
|
||||
size_t const endOffset = node.first;
|
||||
generator.SetPenPosition(node.second);
|
||||
generator.SetPenPosition(coordinates);
|
||||
for (size_t index = beginOffset; index < endOffset && index < m_metrics.size(); ++index)
|
||||
generator(m_metrics[index]);
|
||||
beginOffset = endOffset;
|
||||
|
|
|
@ -177,7 +177,7 @@ if (PLATFORM_MAC)
|
|||
set(BUNDLE_VERSION ${APP_VERSION})
|
||||
endif()
|
||||
|
||||
configure_file(${PROJECT_SOURCE_DIR}/res/Info.plist.in ${PROJECT_SOURCE_DIR}/res/Info.plist)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/res/Info.plist.in ${CMAKE_CURRENT_SOURCE_DIR}/res/Info.plist)
|
||||
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
|
|
Reference in a new issue