mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-08 21:37:58 +00:00
[drape] Refactor UpdateVisualScale.
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
committed by
Konstantin Pastbin
parent
2762bd50ae
commit
d1f817c3e6
@@ -17,8 +17,6 @@
|
||||
#include "drape/support_manager.hpp"
|
||||
#include "drape/texture_manager.hpp"
|
||||
|
||||
#include "indexer/scales.hpp"
|
||||
|
||||
#include "platform/platform.hpp"
|
||||
|
||||
#include "base/file_name_utils.hpp"
|
||||
@@ -355,18 +353,37 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message)
|
||||
m_trafficGenerator->InvalidateTexturesCache();
|
||||
m_transitBuilder->RebuildSchemes(m_context, m_texMng);
|
||||
|
||||
// For Vulkan we initialize deferred cleaning up.
|
||||
if (m_context->GetApiVersion() == dp::ApiVersion::Vulkan)
|
||||
{
|
||||
std::vector<drape_ptr<dp::HWTexture>> textures;
|
||||
m_texMng->GetTexturesToCleanup(textures);
|
||||
if (!textures.empty())
|
||||
{
|
||||
m_commutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<CleanupTexturesMessage>(std::move(textures)), MessagePriority::Normal);
|
||||
}
|
||||
}
|
||||
CleanupTextures();
|
||||
break;
|
||||
}
|
||||
|
||||
case Message::Type::VisualScaleChanged:
|
||||
{
|
||||
ref_ptr<VisualScaleChangedMessage> msg = message;
|
||||
msg->FilterDependentMessages();
|
||||
|
||||
CHECK(m_context != nullptr, ());
|
||||
|
||||
dp::TextureManager::Params params;
|
||||
params.m_resPostfix = VisualParams::Instance().GetResourcePostfix();
|
||||
params.m_visualScale = df::VisualParams::Instance().GetVisualScale();
|
||||
#ifdef BUILD_DESIGNER
|
||||
params.m_patterns = "patterns_design.txt";
|
||||
#else
|
||||
params.m_patterns = "patterns.txt";
|
||||
#endif // BUILD_DESIGNER
|
||||
|
||||
m_texMng->OnVisualScaleChanged(m_context, params);
|
||||
|
||||
RecacheMapShapes();
|
||||
RecacheGui(m_lastWidgetsInfo, false /* needResetOldGui */);
|
||||
#ifdef RENDER_DEBUG_INFO_LABELS
|
||||
RecacheDebugLabels();
|
||||
#endif
|
||||
m_trafficGenerator->InvalidateTexturesCache();
|
||||
m_transitBuilder->RebuildSchemes(m_context, m_texMng);
|
||||
|
||||
CleanupTextures();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -611,21 +628,8 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message)
|
||||
m_arrow3dPreloadedData = Arrow3d::PreloadMesh(m_arrow3dCustomDecl, m_texMng);
|
||||
}
|
||||
|
||||
// Recache map shapes.
|
||||
RecacheMapShapes();
|
||||
|
||||
// For Vulkan we initialize deferred cleaning up.
|
||||
if (m_context->GetApiVersion() == dp::ApiVersion::Vulkan)
|
||||
{
|
||||
std::vector<drape_ptr<dp::HWTexture>> textures;
|
||||
m_texMng->GetTexturesToCleanup(textures);
|
||||
if (!textures.empty())
|
||||
{
|
||||
m_commutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<CleanupTexturesMessage>(std::move(textures)), MessagePriority::Normal);
|
||||
}
|
||||
}
|
||||
|
||||
CleanupTextures();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -772,6 +776,18 @@ void BackendRenderer::RecacheMapShapes()
|
||||
m_commutator->PostMessage(ThreadsCommutator::RenderThread, std::move(msg), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void BackendRenderer::CleanupTextures()
|
||||
{
|
||||
// For Vulkan we initialize deferred cleaning up.
|
||||
if (m_context->GetApiVersion() == dp::ApiVersion::Vulkan)
|
||||
{
|
||||
auto textures = m_texMng->GetTexturesToCleanup();
|
||||
if (!textures.empty())
|
||||
m_commutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<CleanupTexturesMessage>(std::move(textures)), MessagePriority::Normal);
|
||||
}
|
||||
}
|
||||
|
||||
void BackendRenderer::FlushGeometry(TileKey const & key, dp::RenderState const & state,
|
||||
drape_ptr<dp::RenderBucket> && buffer)
|
||||
{
|
||||
|
||||
@@ -83,6 +83,7 @@ private:
|
||||
void RecacheGui(gui::TWidgetsInitInfo const & initInfo, bool needResetOldGui);
|
||||
void RecacheChoosePositionMark();
|
||||
void RecacheMapShapes();
|
||||
void CleanupTextures();
|
||||
|
||||
#ifdef RENDER_DEBUG_INFO_LABELS
|
||||
void RecacheDebugLabels();
|
||||
|
||||
@@ -897,10 +897,8 @@ void DrapeEngine::UpdateVisualScale(double vs, bool needStopRendering)
|
||||
if (needStopRendering)
|
||||
SetRenderingEnabled();
|
||||
|
||||
RecacheGui(false);
|
||||
RecacheMapShapes();
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<RecoverContextDependentResourcesMessage>(), MessagePriority::Normal);
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, make_unique_dp<UpdateVisualScaleMessage>(),
|
||||
MessagePriority::High);
|
||||
}
|
||||
|
||||
void DrapeEngine::UpdateMyPositionRoutingOffset(bool useDefault, int offsetY)
|
||||
|
||||
@@ -640,51 +640,11 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
|
||||
break;
|
||||
}
|
||||
|
||||
case Message::Type::RecoverContextDependentResources:
|
||||
{
|
||||
UpdateContextDependentResources();
|
||||
break;
|
||||
}
|
||||
case Message::Type::RecoverContextDependentResources: UpdateContextDependentResources(); break;
|
||||
|
||||
case Message::Type::UpdateMapStyle:
|
||||
{
|
||||
#ifdef BUILD_DESIGNER
|
||||
classificator::Load();
|
||||
#endif // BUILD_DESIGNER
|
||||
case Message::Type::UpdateMapStyle: UpdateAll<SwitchMapStyleMessage>(); break;
|
||||
|
||||
// Clear all graphics.
|
||||
for (RenderLayer & layer : m_layers)
|
||||
{
|
||||
layer.m_renderGroups.clear();
|
||||
layer.m_isDirty = false;
|
||||
}
|
||||
|
||||
// Must be recreated on map style changing.
|
||||
CHECK(m_context != nullptr, ());
|
||||
m_transitBackground = make_unique_dp<ScreenQuadRenderer>(m_context);
|
||||
|
||||
// Invalidate read manager.
|
||||
{
|
||||
BaseBlockingMessage::Blocker blocker;
|
||||
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<InvalidateReadManagerRectMessage>(blocker), MessagePriority::Normal);
|
||||
blocker.Wait();
|
||||
}
|
||||
|
||||
// Delete all messages which can contain render states (and textures references inside).
|
||||
auto f = [this]() { InstantMessageFilter([](ref_ptr<Message> msg) { return msg->ContainsRenderState(); }); };
|
||||
|
||||
// Notify backend renderer and wait for completion.
|
||||
{
|
||||
BaseBlockingMessage::Blocker blocker;
|
||||
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<SwitchMapStyleMessage>(blocker, std::move(f)), MessagePriority::Normal);
|
||||
blocker.Wait();
|
||||
}
|
||||
|
||||
UpdateContextDependentResources();
|
||||
break;
|
||||
}
|
||||
case Message::Type::VisualScaleChanged: UpdateAll<VisualScaleChangedMessage>(); break;
|
||||
|
||||
case Message::Type::AllowAutoZoom:
|
||||
{
|
||||
@@ -1023,6 +983,46 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
|
||||
}
|
||||
}
|
||||
|
||||
template <class MessageT>
|
||||
void FrontendRenderer::UpdateAll()
|
||||
{
|
||||
#ifdef BUILD_DESIGNER
|
||||
classificator::Load();
|
||||
#endif // BUILD_DESIGNER
|
||||
|
||||
// Clear all graphics.
|
||||
for (RenderLayer & layer : m_layers)
|
||||
{
|
||||
layer.m_renderGroups.clear();
|
||||
layer.m_isDirty = false;
|
||||
}
|
||||
|
||||
// Must be recreated on map style changing.
|
||||
CHECK(m_context != nullptr, ());
|
||||
m_transitBackground = make_unique_dp<ScreenQuadRenderer>(m_context);
|
||||
|
||||
// Invalidate read manager.
|
||||
{
|
||||
BaseBlockingMessage::Blocker blocker;
|
||||
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<InvalidateReadManagerRectMessage>(blocker), MessagePriority::Normal);
|
||||
blocker.Wait();
|
||||
}
|
||||
|
||||
// Delete all messages which can contain render states (and textures references inside).
|
||||
auto f = [this]() { InstantMessageFilter([](ref_ptr<Message> msg) { return msg->ContainsRenderState(); }); };
|
||||
|
||||
// Notify backend renderer and wait for completion.
|
||||
{
|
||||
BaseBlockingMessage::Blocker blocker;
|
||||
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread, make_unique_dp<MessageT>(blocker, std::move(f)),
|
||||
MessagePriority::Normal);
|
||||
blocker.Wait();
|
||||
}
|
||||
|
||||
UpdateContextDependentResources();
|
||||
}
|
||||
|
||||
std::unique_ptr<threads::IRoutine> FrontendRenderer::CreateRoutine()
|
||||
{
|
||||
return std::make_unique<Routine>(*this);
|
||||
|
||||
@@ -247,6 +247,9 @@ private:
|
||||
void ReleaseResources();
|
||||
void UpdateContextDependentResources();
|
||||
|
||||
template <class MessageT>
|
||||
void UpdateAll();
|
||||
|
||||
void BeginUpdateOverlayTree(ScreenBase const & modelView);
|
||||
void UpdateOverlayTree(ScreenBase const & modelView, drape_ptr<RenderGroup> & renderGroup);
|
||||
void EndUpdateOverlayTree();
|
||||
|
||||
@@ -103,6 +103,7 @@ std::string DebugPrint(Message::Type msgType)
|
||||
case Message::Type::EnableIsolines: return "EnableIsolines";
|
||||
case Message::Type::OnEnterBackground: return "OnEnterBackground";
|
||||
case Message::Type::Arrow3dRecache: return "Arrow3dRecache";
|
||||
case Message::Type::VisualScaleChanged: return "VisualScaleChanged";
|
||||
}
|
||||
ASSERT(false, ("Unknown message type."));
|
||||
return "Unknown type";
|
||||
|
||||
@@ -103,7 +103,8 @@ public:
|
||||
NotifyGraphicsReady,
|
||||
EnableIsolines,
|
||||
OnEnterBackground,
|
||||
Arrow3dRecache
|
||||
Arrow3dRecache,
|
||||
VisualScaleChanged,
|
||||
};
|
||||
|
||||
virtual ~Message() = default;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "drape_frontend/circles_pack_shape.hpp"
|
||||
#include "drape_frontend/color_constants.hpp"
|
||||
#include "drape_frontend/custom_features_context.hpp"
|
||||
#include "drape_frontend/drape_api.hpp"
|
||||
#include "drape_frontend/drape_api_builder.hpp"
|
||||
@@ -14,8 +13,7 @@
|
||||
#include "drape_frontend/overlay_batcher.hpp"
|
||||
#include "drape_frontend/postprocess_renderer.hpp"
|
||||
#include "drape_frontend/render_node.hpp"
|
||||
#include "drape_frontend/render_state_extension.hpp"
|
||||
#include "drape_frontend/route_builder.hpp"
|
||||
#include "drape_frontend/route_shape.hpp"
|
||||
#include "drape_frontend/selection_shape.hpp"
|
||||
#include "drape_frontend/tile_utils.hpp"
|
||||
#include "drape_frontend/traffic_generator.hpp"
|
||||
@@ -26,13 +24,10 @@
|
||||
|
||||
#include "drape/pointers.hpp"
|
||||
#include "drape/render_bucket.hpp"
|
||||
#include "drape/viewport.hpp"
|
||||
|
||||
#include "platform/location.hpp"
|
||||
|
||||
#include "geometry/polyline2d.hpp"
|
||||
#include "geometry/rect2d.hpp"
|
||||
#include "geometry/screenbase.hpp"
|
||||
#include "geometry/triangle2d.hpp"
|
||||
|
||||
#include <condition_variable>
|
||||
@@ -40,7 +35,6 @@
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace df
|
||||
@@ -737,6 +731,12 @@ public:
|
||||
Type GetType() const override { return Type::UpdateMapStyle; }
|
||||
};
|
||||
|
||||
class UpdateVisualScaleMessage : public Message
|
||||
{
|
||||
public:
|
||||
Type GetType() const override { return Type::VisualScaleChanged; }
|
||||
};
|
||||
|
||||
class FollowRouteMessage : public Message
|
||||
{
|
||||
public:
|
||||
@@ -783,6 +783,14 @@ private:
|
||||
FilterMessagesHandler m_filterMessagesHandler;
|
||||
};
|
||||
|
||||
class VisualScaleChangedMessage : public SwitchMapStyleMessage
|
||||
{
|
||||
public:
|
||||
using SwitchMapStyleMessage::SwitchMapStyleMessage;
|
||||
|
||||
Type GetType() const override { return Type::VisualScaleChanged; }
|
||||
};
|
||||
|
||||
class InvalidateMessage : public Message
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user