| 300 | } |
| 301 | |
| 302 | void TextureManager::Init(ref_ptr<dp::GraphicsContext> context, Params const & params) |
| 303 | { |
| 304 | CHECK(!m_isInitialized, ()); |
| 305 | |
| 306 | m_resPostfix = params.m_resPostfix; |
| 307 | m_textureAllocator = CreateAllocator(context); |
| 308 | |
| 309 | m_maxTextureSize = std::min(kMaxTextureSize, dp::SupportManager::Instance().GetMaxTextureSize()); |
| 310 | auto const apiVersion = context->GetApiVersion(); |
| 311 | if (apiVersion == dp::ApiVersion::OpenGLES3) |
| 312 | GLFunctions::glPixelStore(gl_const::GLUnpackAlignment, 1); |
| 313 | |
| 314 | // Initialize symbols. |
| 315 | for (auto const & texName : kSymbolTextures) |
| 316 | { |
| 317 | m_symbolTextures.push_back( |
| 318 | make_unique_dp<SymbolsTexture>(context, m_resPostfix, texName, make_ref(m_textureAllocator))); |
| 319 | } |
| 320 | |
| 321 | // Initialize static textures. |
| 322 | m_trafficArrowTexture = make_unique_dp<StaticTexture>(context, "traffic-arrow.png", m_resPostfix, |
| 323 | dp::TextureFormat::RGBA8, make_ref(m_textureAllocator)); |
| 324 | m_hatchingTexture = make_unique_dp<StaticTexture>(context, "area-hatching.png", m_resPostfix, |
| 325 | dp::TextureFormat::RGBA8, make_ref(m_textureAllocator)); |
| 326 | m_arrowTexture = CreateArrowTexture(context, make_ref(m_textureAllocator), params.m_arrowTexturePath, |
| 327 | params.m_arrowTextureUseDefaultResourceFolder); |
| 328 | |
| 329 | // SMAA. |
| 330 | m_smaaAreaTexture = make_unique_dp<StaticTexture>(context, "smaa-area.png", StaticTexture::kDefaultResource, |
| 331 | dp::TextureFormat::RedGreen, make_ref(m_textureAllocator)); |
| 332 | m_smaaSearchTexture = make_unique_dp<StaticTexture>(context, "smaa-search.png", StaticTexture::kDefaultResource, |
| 333 | dp::TextureFormat::Red, make_ref(m_textureAllocator)); |
| 334 | |
| 335 | InitStipplePen(params); |
| 336 | |
| 337 | // Initialize colors (reserved ./data/colors.txt lines count). |
| 338 | std::vector<dp::Color> colors; |
| 339 | colors.reserve(1024); |
| 340 | ParseColorsList(params.m_colors, [&colors](dp::Color const & color) { colors.push_back(color); }); |
| 341 | |
| 342 | m_colorTexture = |
| 343 | make_unique_dp<ColorTexture>(ColorTextureSize(colors.size(), m_maxTextureSize), make_ref(m_textureAllocator)); |
| 344 | |
| 345 | LOG(LINFO, |
| 346 | ("Colors count =", colors.size(), "texture size =", m_colorTexture->GetWidth(), m_colorTexture->GetHeight())); |
| 347 | |
| 348 | ref_ptr<ColorTexture> colorTex = make_ref(m_colorTexture); |
| 349 | for (auto const & c : colors) |
| 350 | colorTex->ReserveColor(c); |
| 351 | |
| 352 | // Initialize glyphs. |
| 353 | m_glyphManager = make_unique_dp<GlyphManager>(params.m_glyphMngParams); |
| 354 | uint32_t constexpr textureSquare = kGlyphsTextureSize * kGlyphsTextureSize; |
| 355 | uint32_t constexpr baseGlyphHeightPixels = static_cast<uint32_t>(dp::kBaseFontSizePixels * kGlyphAreaMultiplier); |
| 356 | uint32_t constexpr averageGlyphSquare = baseGlyphHeightPixels * baseGlyphHeightPixels; |
| 357 | m_maxGlypsCount = static_cast<uint32_t>(ceil(kGlyphAreaCoverage * textureSquare / averageGlyphSquare)); |
| 358 | |
| 359 | std::string_view constexpr kSpace{" "}; |
nothing calls this directly
no test coverage detected