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

Minor clang-tidying #8109

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
141 changes: 68 additions & 73 deletions drape_frontend/drape_engine.cpp

Large diffs are not rendered by default.

139 changes: 69 additions & 70 deletions drape_frontend/drape_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#include "platform/location.hpp"

#include "geometry/polyline2d.hpp"
#include "geometry/screenbase.hpp"
#include "geometry/triangle2d.hpp"

Expand Down Expand Up @@ -109,56 +108,56 @@ class DrapeEngine
OnGraphicsContextInitialized m_onGraphicsContextInitialized;
};

DrapeEngine(Params && params);
explicit DrapeEngine(Params && params);
~DrapeEngine();

void RecoverSurface(int w, int h, bool recreateContextDependentResources);

void Resize(int w, int h);
void Invalidate();
void Invalidate() const;

void SetVisibleViewport(m2::RectD const & rect) const;

void AddTouchEvent(TouchEvent const & event);
void Scale(double factor, m2::PointD const & pxPoint, bool isAnim);
void Move(double factorX, double factorY, bool isAnim);
void Scroll(double distanceX, double distanceY);
void Rotate(double azimuth, bool isAnim);
void AddTouchEvent(TouchEvent const & event) const;
void Scale(double factor, m2::PointD const & pxPoint, bool isAnim) const;
void Move(double factorX, double factorY, bool isAnim) const;
void Scroll(double distanceX, double distanceY) const;
void Rotate(double azimuth, bool isAnim) const;

void ScaleAndSetCenter(m2::PointD const & centerPt, double scaleFactor, bool isAnim,
bool trackVisibleViewport);
bool trackVisibleViewport) const;

// If zoom == -1 then current zoom will not be changed.
void SetModelViewCenter(m2::PointD const & centerPt, int zoom, bool isAnim,
bool trackVisibleViewport);
bool trackVisibleViewport) const;
void SetModelViewRect(m2::RectD const & rect, bool applyRotation, int zoom, bool isAnim,
bool useVisibleViewport);
void SetModelViewAnyRect(m2::AnyRectD const & rect, bool isAnim, bool useVisibleViewport);
bool useVisibleViewport) const;
void SetModelViewAnyRect(m2::AnyRectD const & rect, bool isAnim, bool useVisibleViewport) const;

using ModelViewChangedHandler = FrontendRenderer::ModelViewChangedHandler;
void SetModelViewListener(ModelViewChangedHandler && fn);

#if defined(OMIM_OS_DESKTOP)
using GraphicsReadyHandler = FrontendRenderer::GraphicsReadyHandler;
void NotifyGraphicsReady(GraphicsReadyHandler const & fn, bool needInvalidate);
void NotifyGraphicsReady(GraphicsReadyHandler const & fn, bool needInvalidate) const;
#endif

void ClearUserMarksGroup(kml::MarkGroupId groupId);
void ChangeVisibilityUserMarksGroup(kml::MarkGroupId groupId, bool isVisible);
void UpdateUserMarks(UserMarksProvider * provider, bool firstTime);
void InvalidateUserMarks();
void ClearUserMarksGroup(kml::MarkGroupId groupId) const;
void ChangeVisibilityUserMarksGroup(kml::MarkGroupId groupId, bool isVisible) const;
void UpdateUserMarks(UserMarksProvider const * provider, bool firstTime) const;
void InvalidateUserMarks() const;

void SetRenderingEnabled(ref_ptr<dp::GraphicsContextFactory> contextFactory = nullptr);
void SetRenderingDisabled(bool const destroySurface);
void InvalidateRect(m2::RectD const & rect);
void UpdateMapStyle();
void SetRenderingEnabled(ref_ptr<dp::GraphicsContextFactory> contextFactory = nullptr) const;
void SetRenderingDisabled(bool destroySurface) const;
void InvalidateRect(m2::RectD const & rect) const;
void UpdateMapStyle() const;

void SetCompassInfo(location::CompassInfo const & info);
void SetCompassInfo(location::CompassInfo const & info) const;
void SetGpsInfo(location::GpsInfo const & info, bool isNavigable,
location::RouteMatchingInfo const & routeInfo);
void SwitchMyPositionNextMode();
void LoseLocation();
void StopLocationFollow();
location::RouteMatchingInfo const & routeInfo) const;
void SwitchMyPositionNextMode() const;
void LoseLocation() const;
void StopLocationFollow() const;

using TapEventInfoHandler = FrontendRenderer::TapEventInfoHandler;
void SetTapEventInfoListener(TapEventInfoHandler && fn);
Expand All @@ -167,99 +166,99 @@ class DrapeEngine

void SelectObject(SelectionShape::ESelectedObject obj, m2::PointD const & pt,
FeatureID const & featureID, bool isAnim, bool isGeometrySelectionAllowed,
bool isSelectionShapeVisible);
void DeselectObject();
bool isSelectionShapeVisible) const;
void DeselectObject() const;

dp::DrapeID AddSubroute(SubrouteConstPtr subroute);
void RemoveSubroute(dp::DrapeID subrouteId, bool deactivateFollowing);
void RemoveSubroute(dp::DrapeID subrouteId, bool deactivateFollowing) const;
void FollowRoute(int preferredZoomLevel, int preferredZoomLevel3d, bool enableAutoZoom,
bool isArrowGlued);
void DeactivateRouteFollowing();
void SetSubrouteVisibility(dp::DrapeID subrouteId, bool isVisible);
bool isArrowGlued) const;
void DeactivateRouteFollowing() const;
void SetSubrouteVisibility(dp::DrapeID subrouteId, bool isVisible) const;
dp::DrapeID AddRoutePreviewSegment(m2::PointD const & startPt, m2::PointD const & finishPt);
void RemoveRoutePreviewSegment(dp::DrapeID segmentId);
void RemoveAllRoutePreviewSegments();
void RemoveRoutePreviewSegment(dp::DrapeID segmentId) const;
void RemoveAllRoutePreviewSegments() const;

void SetWidgetLayout(gui::TWidgetsLayoutInfo && info);

void AllowAutoZoom(bool allowAutoZoom);
void AllowAutoZoom(bool allowAutoZoom) const;

void Allow3dMode(bool allowPerspectiveInNavigation, bool allow3dBuildings);
void EnablePerspective();
void Allow3dMode(bool allowPerspectiveInNavigation, bool allow3dBuildings) const;
void EnablePerspective() const;

void UpdateGpsTrackPoints(std::vector<df::GpsTrackPoint> && toAdd,
std::vector<uint32_t> && toRemove);
void ClearGpsTrackPoints();
std::vector<uint32_t> && toRemove) const;
void ClearGpsTrackPoints() const;

void EnableChoosePositionMode(bool enable, std::vector<m2::TriangleD> && boundAreaTriangles,
bool hasPosition, m2::PointD const & position);
void BlockTapEvents(bool block);
void BlockTapEvents(bool block) const;

void SetKineticScrollEnabled(bool enabled);

void OnEnterForeground();
void OnEnterForeground() const;
void OnEnterBackground();

using TRequestSymbolsSizeCallback = std::function<void(std::map<std::string, m2::PointF> &&)>;

void RequestSymbolsSize(std::vector<std::string> const & symbols,
TRequestSymbolsSizeCallback const & callback);
TRequestSymbolsSizeCallback const & callback) const;

void EnableTraffic(bool trafficEnabled);
void UpdateTraffic(traffic::TrafficInfo const & info);
void ClearTrafficCache(MwmSet::MwmId const & mwmId);
void SetSimplifiedTrafficColors(bool simplified);
void EnableTraffic(bool trafficEnabled) const;
void UpdateTraffic(traffic::TrafficInfo const & info) const;
void ClearTrafficCache(MwmSet::MwmId const & mwmId) const;
void SetSimplifiedTrafficColors(bool simplified) const;

void EnableTransitScheme(bool enable);
void UpdateTransitScheme(TransitDisplayInfos && transitDisplayInfos);
void ClearTransitSchemeCache(MwmSet::MwmId const & mwmId);
void ClearAllTransitSchemeCache();
void EnableTransitScheme(bool enable) const;
void UpdateTransitScheme(TransitDisplayInfos && transitDisplayInfos) const;
void ClearTransitSchemeCache(MwmSet::MwmId const & mwmId) const;
void ClearAllTransitSchemeCache() const;

void EnableIsolines(bool enable);
void EnableIsolines(bool enable) const;

void SetFontScaleFactor(double scaleFactor);

void RunScenario(ScenarioManager::ScenarioData && scenarioData,
ScenarioManager::ScenarioCallback const & onStartFn,
ScenarioManager::ScenarioCallback const & onFinishFn);
ScenarioManager::ScenarioCallback const & onFinishFn) const;

/// @name Custom features are features that we render in a different way.
/// Value in the map shows if the feature is skipped in process of geometry generation.
/// For all custom features (if they are overlays) statistics will be gathered.
/// @todo Not used now, suspect that it was used for some Ads POIs.
/// @{
void SetCustomFeatures(df::CustomFeatures && ids);
void RemoveCustomFeatures(MwmSet::MwmId const & mwmId);
void RemoveAllCustomFeatures();
void SetCustomFeatures(df::CustomFeatures && ids) const;
void RemoveCustomFeatures(MwmSet::MwmId const & mwmId) const;
void RemoveAllCustomFeatures() const;
/// @}

void SetPosteffectEnabled(PostprocessRenderer::Effect effect, bool enabled);
void EnableDebugRectRendering(bool enabled);
void SetPosteffectEnabled(PostprocessRenderer::Effect effect, bool enabled) const;
void EnableDebugRectRendering(bool enabled) const;

void RunFirstLaunchAnimation();
void RunFirstLaunchAnimation() const;

void ShowDebugInfo(bool shown);
void ShowDebugInfo(bool shown) const;

void UpdateVisualScale(double vs, bool needStopRendering);
void UpdateMyPositionRoutingOffset(bool useDefault, int offsetY);
void UpdateMyPositionRoutingOffset(bool useDefault, int offsetY) const;

location::EMyPositionMode GetMyPositionMode() const;

void SetCustomArrow3d(std::optional<Arrow3dCustomDecl> arrow3dCustomDecl);
void SetCustomArrow3d(std::optional<Arrow3dCustomDecl> arrow3dCustomDecl) const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does modifying function are marked as const? Isn't it changing some internal state? It looks confusing.


dp::ApiVersion GetApiVersion() const { return m_frontend->GetApiVersion(); };

private:
void AddUserEvent(drape_ptr<UserEvent> && e);
void PostUserEvent(drape_ptr<UserEvent> && e);
void ModelViewChanged(ScreenBase const & screen);
void MyPositionModeChanged(location::EMyPositionMode mode, bool routingActive);
void TapEvent(TapInfo const & tapInfo);
void UserPositionChanged(m2::PointD const & position, bool hasPosition);

void ResizeImpl(int w, int h);
void AddUserEvent(drape_ptr<UserEvent> && e) const;
void PostUserEvent(drape_ptr<UserEvent> && e) const;
void ModelViewChanged(ScreenBase const & screen) const;
void MyPositionModeChanged(location::EMyPositionMode mode, bool routingActive) const;
void TapEvent(TapInfo const & tapInfo) const;
void UserPositionChanged(m2::PointD const & position, bool hasPosition) const;

void ResizeImpl(int32_t w, int32_t h);
void RecacheGui(bool needResetOldGui);
void RecacheMapShapes();
void RecacheMapShapes() const;

dp::DrapeID GenerateDrapeID();

Expand Down
16 changes: 6 additions & 10 deletions drape_frontend/gui/drape_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "ruler_helper.hpp"

#include "drape_frontend/color_constants.hpp"
#include "drape_frontend/visual_params.hpp"

#include "base/assert.hpp"

Expand All @@ -16,15 +15,12 @@ struct DrapeGui::Impl
};

DrapeGui::DrapeGui()
: m_impl(new Impl())
: m_impl(std::make_unique<Impl>())
{}

DrapeGui & DrapeGui::Instance()
{
static DrapeGui s_gui;
if (!s_gui.m_impl)
s_gui.m_impl.reset(new Impl());

return s_gui;
}

Expand All @@ -44,19 +40,19 @@ void DrapeGui::Destroy()
m_impl.reset();
}

void DrapeGui::SetSurfaceSize(m2::PointF const & size)
void DrapeGui::SetSurfaceSize(m2::PointF size)
{
std::lock_guard<std::mutex> lock(m_surfaceSizeMutex);
std::lock_guard lock(m_surfaceSizeMutex);
m_surfaceSize = size;
}

m2::PointF DrapeGui::GetSurfaceSize() const
{
std::lock_guard<std::mutex> lock(m_surfaceSizeMutex);
std::lock_guard lock(m_surfaceSizeMutex);
return m_surfaceSize;
}

RulerHelper & DrapeGui::GetRulerHelperImpl()
RulerHelper & DrapeGui::GetRulerHelperImpl() const
{
ASSERT(m_impl != nullptr, ());
return m_impl->m_rulerHelper;
Expand All @@ -67,7 +63,7 @@ void DrapeGui::ConnectOnCompassTappedHandler(Shape::TTapHandler const & handler)
m_onCompassTappedHandler = handler;
}

void DrapeGui::CallOnCompassTappedHandler()
void DrapeGui::CallOnCompassTappedHandler() const
{
if(m_onCompassTappedHandler != nullptr)
m_onCompassTappedHandler();
Expand Down
8 changes: 4 additions & 4 deletions drape_frontend/gui/drape_gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DrapeGui
static dp::FontDecl GetGuiTextFont();

void Destroy();
void SetSurfaceSize(m2::PointF const & size);
void SetSurfaceSize(m2::PointF size);
m2::PointF GetSurfaceSize() const;

bool IsInUserAction() const { return m_inUserAction; }
Expand All @@ -37,21 +37,21 @@ class DrapeGui
void DeactivateCopyright() { m_isCopyrightActive = false; }

void ConnectOnCompassTappedHandler(Shape::TTapHandler const & handler);
void CallOnCompassTappedHandler();
void CallOnCompassTappedHandler() const;

ScaleFpsHelper & GetScaleFpsHelper() { return m_scaleFpsHelper; }
ScaleFpsHelper const & GetScaleFpsHelper() const { return m_scaleFpsHelper; }

private:
DrapeGui();
RulerHelper & GetRulerHelperImpl();
RulerHelper & GetRulerHelperImpl() const;

struct Impl;
std::unique_ptr<Impl> m_impl;
bool m_isCopyrightActive = true;

Shape::TTapHandler m_onCompassTappedHandler;
m2::PointF m_surfaceSize;
m2::PointF m_surfaceSize{};
mutable std::mutex m_surfaceSizeMutex;
bool m_inUserAction = false;
ScaleFpsHelper m_scaleFpsHelper;
Expand Down
6 changes: 2 additions & 4 deletions drape_frontend/gui/gui_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,7 @@ ref_ptr<dp::Texture> MutableLabel::SetAlphabet(std::string const & alphabet,
return m_alphabet[0].second.GetTexture();
}

void MutableLabel::Precache(PrecacheParams const & params, PrecacheResult & result,
ref_ptr<dp::TextureManager> mng)
void MutableLabel::Precache(PrecacheParams const & params, PrecacheResult & result, ref_ptr<dp::TextureManager> mng)
{
SetMaxLength(static_cast<uint16_t>(params.m_maxLength));
result.m_state.SetMaskTexture(SetAlphabet(params.m_alphabet, mng));
Expand All @@ -345,8 +344,7 @@ void MutableLabel::Precache(PrecacheParams const & params, PrecacheResult & resu
glsl::vec2 outlineTex = glsl::ToVec2(outlineColor.GetTexRect().Center());

auto const vertexCount = m_maxLength * dp::Batcher::VertexPerQuad;
result.m_buffer.resize(vertexCount,
StaticVertex(glsl::vec3(0.0, 0.0, 0.0), colorTex, outlineTex));
result.m_buffer.resize(vertexCount, StaticVertex(glsl::vec3(0.0, 0.0, 0.0), colorTex, outlineTex));

float depth = 0.0f;
for (size_t i = 0; i < vertexCount; i += 4)
Expand Down