mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-29 01:03:46 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -6,7 +6,8 @@ namespace df
|
||||
{
|
||||
|
||||
// static
|
||||
bool Animation::GetCachedProperty(TPropertyCache const & properties, Object object, ObjectProperty property, PropertyValue & value)
|
||||
bool Animation::GetCachedProperty(TPropertyCache const & properties, Object object, ObjectProperty property,
|
||||
PropertyValue & value)
|
||||
{
|
||||
auto const it = properties.find(std::make_pair(object, property));
|
||||
if (it != properties.end())
|
||||
@@ -18,7 +19,8 @@ bool Animation::GetCachedProperty(TPropertyCache const & properties, Object obje
|
||||
}
|
||||
|
||||
// static
|
||||
void Animation::GetCurrentScreen(TPropertyCache const & properties, ScreenBase const & screen, ScreenBase & currentScreen)
|
||||
void Animation::GetCurrentScreen(TPropertyCache const & properties, ScreenBase const & screen,
|
||||
ScreenBase & currentScreen)
|
||||
{
|
||||
currentScreen = screen;
|
||||
|
||||
@@ -46,10 +48,8 @@ bool Animation::HasSameObjects(Animation const & animation) const
|
||||
{
|
||||
TAnimObjects const & objects = animation.GetObjects();
|
||||
for (auto const & object : objects)
|
||||
{
|
||||
if (HasObject(object))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -129,4 +129,4 @@ std::string DebugPrint(Animation::ObjectProperty const & property)
|
||||
return "Unknown property";
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -52,18 +52,11 @@ public:
|
||||
ValuePointD
|
||||
};
|
||||
|
||||
PropertyValue()
|
||||
{}
|
||||
PropertyValue() {}
|
||||
|
||||
explicit PropertyValue(double value)
|
||||
: m_type(Type::ValueD)
|
||||
, m_valueD(value)
|
||||
{}
|
||||
explicit PropertyValue(double value) : m_type(Type::ValueD), m_valueD(value) {}
|
||||
|
||||
explicit PropertyValue(m2::PointD const & value)
|
||||
: m_type(Type::ValuePointD)
|
||||
, m_valuePointD(value)
|
||||
{}
|
||||
explicit PropertyValue(m2::PointD const & value) : m_type(Type::ValuePointD), m_valuePointD(value) {}
|
||||
|
||||
Type m_type;
|
||||
union
|
||||
@@ -88,9 +81,21 @@ public:
|
||||
virtual ~Animation() = default;
|
||||
|
||||
virtual void Init(ScreenBase const & screen, TPropertyCache const & properties) {}
|
||||
virtual void OnStart() { if (m_onStartAction != nullptr) m_onStartAction(this); }
|
||||
virtual void OnFinish() { if (m_onFinishAction != nullptr) m_onFinishAction(this); }
|
||||
virtual void Interrupt() { if (m_onInterruptAction != nullptr) m_onInterruptAction(this); }
|
||||
virtual void OnStart()
|
||||
{
|
||||
if (m_onStartAction != nullptr)
|
||||
m_onStartAction(this);
|
||||
}
|
||||
virtual void OnFinish()
|
||||
{
|
||||
if (m_onFinishAction != nullptr)
|
||||
m_onFinishAction(this);
|
||||
}
|
||||
virtual void Interrupt()
|
||||
{
|
||||
if (m_onInterruptAction != nullptr)
|
||||
m_onInterruptAction(this);
|
||||
}
|
||||
|
||||
virtual Type GetType() const = 0;
|
||||
virtual std::string GetCustomType() const { return std::string(); }
|
||||
@@ -130,13 +135,15 @@ public:
|
||||
|
||||
void SetCouldBeInterrupted(bool enable) { m_couldBeInterrupted = enable; }
|
||||
void SetCouldBeBlended(bool enable) { m_couldBeBlended = enable; }
|
||||
|
||||
|
||||
void SetCouldBeRewinded(bool enable) { m_couldBeRewinded = enable; }
|
||||
bool CouldBeRewinded() const { return m_couldBeRewinded; }
|
||||
|
||||
protected:
|
||||
static void GetCurrentScreen(TPropertyCache const & properties, ScreenBase const & screen, ScreenBase & currentScreen);
|
||||
static bool GetCachedProperty(TPropertyCache const & properties, Object object, ObjectProperty property, PropertyValue & value);
|
||||
static void GetCurrentScreen(TPropertyCache const & properties, ScreenBase const & screen,
|
||||
ScreenBase & currentScreen);
|
||||
static bool GetCachedProperty(TPropertyCache const & properties, Object object, ObjectProperty property,
|
||||
PropertyValue & value);
|
||||
|
||||
static bool GetMinDuration(Interpolator const & interpolator, double & minDuration);
|
||||
static bool GetMaxDuration(Interpolator const & interpolator, double & maxDuration);
|
||||
@@ -159,5 +166,4 @@ std::string DebugPrint(Animation::Type const & type);
|
||||
std::string DebugPrint(Animation::Object const & object);
|
||||
std::string DebugPrint(Animation::ObjectProperty const & property);
|
||||
|
||||
} // namespace df
|
||||
|
||||
} // namespace df
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace df
|
||||
namespace df
|
||||
{
|
||||
|
||||
ArrowAnimation::ArrowAnimation(m2::PointD const & startPos, m2::PointD const & endPos, double moveDuration,
|
||||
double startAngle, double endAngle)
|
||||
double startAngle, double endAngle)
|
||||
: Animation(true /* couldBeInterrupted */, true /* couldBeBlended */)
|
||||
, m_positionInterpolator(moveDuration, 0.0 /* delay */, startPos, endPos)
|
||||
, m_angleInterpolator(startAngle, endAngle)
|
||||
@@ -28,10 +28,8 @@ void ArrowAnimation::Init(ScreenBase const & screen, TPropertyCache const & prop
|
||||
minDuration = m_positionInterpolator.GetMinDuration();
|
||||
maxDuration = m_positionInterpolator.GetMaxDuration();
|
||||
|
||||
m_positionInterpolator = PositionInterpolator(m_positionInterpolator.GetDuration(),
|
||||
0.0 /* delay */,
|
||||
value.m_valuePointD,
|
||||
m_positionInterpolator.GetTargetPosition());
|
||||
m_positionInterpolator = PositionInterpolator(m_positionInterpolator.GetDuration(), 0.0 /* delay */,
|
||||
value.m_valuePointD, m_positionInterpolator.GetTargetPosition());
|
||||
|
||||
m_positionInterpolator.SetMinDuration(minDuration);
|
||||
m_positionInterpolator.SetMaxDuration(maxDuration);
|
||||
@@ -56,7 +54,7 @@ void ArrowAnimation::Init(ScreenBase const & screen, TPropertyCache const & prop
|
||||
|
||||
Animation::TAnimObjects const & ArrowAnimation::GetObjects() const
|
||||
{
|
||||
return m_objects;
|
||||
return m_objects;
|
||||
}
|
||||
|
||||
bool ArrowAnimation::HasObject(Object object) const
|
||||
@@ -166,7 +164,8 @@ bool ArrowAnimation::GetProperty(Object object, ObjectProperty property, bool ta
|
||||
case Animation::ObjectProperty::Position:
|
||||
if (m_positionInterpolator.IsActive())
|
||||
{
|
||||
value = PropertyValue(targetValue ? m_positionInterpolator.GetTargetPosition() : m_positionInterpolator.GetPosition());
|
||||
value = PropertyValue(targetValue ? m_positionInterpolator.GetTargetPosition()
|
||||
: m_positionInterpolator.GetPosition());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -177,12 +176,10 @@ bool ArrowAnimation::GetProperty(Object object, ObjectProperty property, bool ta
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
ASSERT(false, ("Wrong property:", static_cast<int>(property)));
|
||||
default: ASSERT(false, ("Wrong property:", static_cast<int>(property)));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace df
|
||||
class ArrowAnimation : public Animation
|
||||
{
|
||||
public:
|
||||
ArrowAnimation(m2::PointD const & startPos, m2::PointD const & endPos, double moveDuration,
|
||||
double startAngle, double endAngle);
|
||||
ArrowAnimation(m2::PointD const & startPos, m2::PointD const & endPos, double moveDuration, double startAngle,
|
||||
double endAngle);
|
||||
|
||||
void Init(ScreenBase const & screen, TPropertyCache const & properties) override;
|
||||
|
||||
@@ -43,4 +43,4 @@ private:
|
||||
AngleInterpolator m_angleInterpolator;
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
namespace df
|
||||
{
|
||||
|
||||
MapFollowAnimation::MapFollowAnimation(ScreenBase const & screen,
|
||||
m2::PointD const & globalUserPosition,
|
||||
m2::PointD const & endPixelPosition,
|
||||
double endScale, double endAngle,
|
||||
MapFollowAnimation::MapFollowAnimation(ScreenBase const & screen, m2::PointD const & globalUserPosition,
|
||||
m2::PointD const & endPixelPosition, double endScale, double endAngle,
|
||||
bool isAutoZoom)
|
||||
: Animation(true /* couldBeInterrupted */, true /* couldBeBlended */)
|
||||
, m_isAutoZoom(isAutoZoom)
|
||||
@@ -37,7 +35,8 @@ void MapFollowAnimation::Init(ScreenBase const & screen, TPropertyCache const &
|
||||
|
||||
m_offset = currentScreen.PtoG(currentScreen.P3dtoP(m_endPixelPosition)) - m_globalPosition;
|
||||
double const averageScale = m_isAutoZoom ? currentScreen.GetScale() : (currentScreen.GetScale() + m_endScale) / 2.0;
|
||||
double const moveDuration = PositionInterpolator::GetMoveDuration(m_offset.Length(), screen.PixelRectIn3d(), averageScale);
|
||||
double const moveDuration =
|
||||
PositionInterpolator::GetMoveDuration(m_offset.Length(), screen.PixelRectIn3d(), averageScale);
|
||||
m_offsetInterpolator = PositionInterpolator(moveDuration, 0.0, m_offset, m2::PointD(0.0, 0.0));
|
||||
|
||||
m_offsetInterpolator.SetMinDuration(minDuration);
|
||||
@@ -156,7 +155,6 @@ double MapFollowAnimation::GetMinDuration() const
|
||||
return minDuration;
|
||||
}
|
||||
|
||||
|
||||
double MapFollowAnimation::CalculateDuration() const
|
||||
{
|
||||
double duration = std::max(m_angleInterpolator.GetDuration(), m_offsetInterpolator.GetDuration());
|
||||
@@ -180,15 +178,16 @@ bool MapFollowAnimation::GetTargetProperty(Object object, ObjectProperty propert
|
||||
return GetProperty(object, property, true /* targetValue */, value);
|
||||
}
|
||||
|
||||
bool MapFollowAnimation::GetProperty(Object object, ObjectProperty property, bool targetValue, PropertyValue & value) const
|
||||
bool MapFollowAnimation::GetProperty(Object object, ObjectProperty property, bool targetValue,
|
||||
PropertyValue & value) const
|
||||
{
|
||||
if (property == Animation::ObjectProperty::Position)
|
||||
{
|
||||
ScreenBase tmp = AnimationSystem::Instance().GetLastScreen();
|
||||
if (targetValue)
|
||||
{
|
||||
tmp.SetFromParams(m_globalPosition, m_angleInterpolator.GetTargetAngle(), m_isAutoZoom ? m_scaleInterpolator.GetScale()
|
||||
: m_scaleInterpolator.GetTargetScale());
|
||||
tmp.SetFromParams(m_globalPosition, m_angleInterpolator.GetTargetAngle(),
|
||||
m_isAutoZoom ? m_scaleInterpolator.GetScale() : m_scaleInterpolator.GetTargetScale());
|
||||
tmp.MatchGandP3d(m_globalPosition, m_endPixelPosition);
|
||||
}
|
||||
else
|
||||
@@ -230,4 +229,4 @@ bool MapFollowAnimation::HasPixelOffset() const
|
||||
return m_offsetInterpolator.IsActive();
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -9,25 +9,16 @@ namespace df
|
||||
class MapFollowAnimation : public Animation
|
||||
{
|
||||
public:
|
||||
MapFollowAnimation(ScreenBase const & screen,
|
||||
m2::PointD const & globalUserPosition,
|
||||
m2::PointD const & endPixelPosition,
|
||||
double endScale, double endAngle,
|
||||
bool isAutoZoom);
|
||||
MapFollowAnimation(ScreenBase const & screen, m2::PointD const & globalUserPosition,
|
||||
m2::PointD const & endPixelPosition, double endScale, double endAngle, bool isAutoZoom);
|
||||
|
||||
void Init(ScreenBase const & screen, TPropertyCache const & properties) override;
|
||||
|
||||
Animation::Type GetType() const override { return Animation::Type::MapFollow; }
|
||||
|
||||
TAnimObjects const & GetObjects() const override
|
||||
{
|
||||
return m_objects;
|
||||
}
|
||||
TAnimObjects const & GetObjects() const override { return m_objects; }
|
||||
|
||||
bool HasObject(Object object) const override
|
||||
{
|
||||
return object == Animation::Object::MapPlane;
|
||||
}
|
||||
bool HasObject(Object object) const override { return object == Animation::Object::MapPlane; }
|
||||
|
||||
TObjectProperties const & GetProperties(Object object) const override;
|
||||
bool HasProperty(Object object, ObjectProperty property) const override;
|
||||
@@ -70,4 +61,4 @@ private:
|
||||
TAnimObjects m_objects;
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "drape_frontend/animation/base_interpolator.hpp"
|
||||
#include "drape_frontend/animation/interpolation_holder.hpp"
|
||||
#include "drape_frontend/animation/base_interpolator.hpp"
|
||||
|
||||
#include "base/assert.hpp"
|
||||
|
||||
|
||||
@@ -23,4 +23,4 @@ double InterpolateAngle(double startAngle, double endAngle, double t)
|
||||
return startAngle + ang::GetShortestDistance(startAngle, endAngle) * t;
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "geometry/any_rect2d.hpp"
|
||||
#include "geometry/point2d.hpp"
|
||||
#include "geometry/rect2d.hpp"
|
||||
#include "geometry/any_rect2d.hpp"
|
||||
|
||||
namespace df
|
||||
{
|
||||
@@ -11,4 +11,4 @@ double InterpolateDouble(double startV, double endV, double t);
|
||||
m2::PointD InterpolatePoint(m2::PointD const & startPt, m2::PointD const & endPt, double t);
|
||||
double InterpolateAngle(double startAngle, double endAngle, double t);
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -103,8 +103,8 @@ PositionInterpolator::PositionInterpolator()
|
||||
: PositionInterpolator(0.0 /* duration */, 0.0 /* delay */, m2::PointD(), m2::PointD())
|
||||
{}
|
||||
|
||||
PositionInterpolator::PositionInterpolator(double duration, double delay,
|
||||
m2::PointD const & startPosition, m2::PointD const & endPosition)
|
||||
PositionInterpolator::PositionInterpolator(double duration, double delay, m2::PointD const & startPosition,
|
||||
m2::PointD const & endPosition)
|
||||
: Interpolator(duration, delay)
|
||||
, m_startPosition(startPosition)
|
||||
, m_endPosition(endPosition)
|
||||
@@ -118,9 +118,8 @@ PositionInterpolator::PositionInterpolator(m2::PointD const & startPosition, m2:
|
||||
: PositionInterpolator(0.0 /* delay */, startPosition, endPosition, convertor)
|
||||
{}
|
||||
|
||||
PositionInterpolator::PositionInterpolator(double delay,
|
||||
m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
ScreenBase const & convertor)
|
||||
PositionInterpolator::PositionInterpolator(double delay, m2::PointD const & startPosition,
|
||||
m2::PointD const & endPosition, ScreenBase const & convertor)
|
||||
: Interpolator(PositionInterpolator::GetMoveDuration(startPosition, endPosition, convertor), delay)
|
||||
, m_startPosition(startPosition)
|
||||
, m_endPosition(endPosition)
|
||||
@@ -134,9 +133,8 @@ PositionInterpolator::PositionInterpolator(m2::PointD const & startPosition, m2:
|
||||
: PositionInterpolator(0.0 /* delay */, startPosition, endPosition, viewportRect, scale)
|
||||
{}
|
||||
|
||||
PositionInterpolator::PositionInterpolator(double delay,
|
||||
m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
m2::RectD const & viewportRect, double scale)
|
||||
PositionInterpolator::PositionInterpolator(double delay, m2::PointD const & startPosition,
|
||||
m2::PointD const & endPosition, m2::RectD const & viewportRect, double scale)
|
||||
: Interpolator(PositionInterpolator::GetMoveDuration(startPosition, endPosition, viewportRect, scale), delay)
|
||||
, m_startPosition(startPosition)
|
||||
, m_endPosition(endPosition)
|
||||
@@ -145,7 +143,7 @@ PositionInterpolator::PositionInterpolator(double delay,
|
||||
SetActive((GetDuration() > 0.0) && (m_startPosition != m_endPosition));
|
||||
}
|
||||
|
||||
//static
|
||||
// static
|
||||
double PositionInterpolator::GetMoveDuration(double globalDistance, m2::RectD const & viewportRect, double scale)
|
||||
{
|
||||
double constexpr kMinMoveDuration = 0.2;
|
||||
@@ -166,22 +164,20 @@ double PositionInterpolator::GetMoveDuration(double globalDistance, m2::RectD co
|
||||
return CalcAnimSpeedDuration(pixelLength, pixelSpeed);
|
||||
}
|
||||
|
||||
//static
|
||||
// static
|
||||
double PositionInterpolator::GetMoveDuration(m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
m2::RectD const & viewportRect, double scale)
|
||||
m2::RectD const & viewportRect, double scale)
|
||||
{
|
||||
return GetMoveDuration(endPosition.Length(startPosition), viewportRect, scale);
|
||||
}
|
||||
|
||||
//static
|
||||
double PositionInterpolator::GetMoveDuration(m2::PointD const & startPosition,
|
||||
m2::PointD const & endPosition,
|
||||
// static
|
||||
double PositionInterpolator::GetMoveDuration(m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
ScreenBase const & convertor)
|
||||
{
|
||||
return GetMoveDuration(startPosition, endPosition, convertor.PixelRectIn3d(), convertor.GetScale());
|
||||
}
|
||||
|
||||
|
||||
void PositionInterpolator::Advance(double elapsedSeconds)
|
||||
{
|
||||
TBase::Advance(elapsedSeconds);
|
||||
@@ -235,9 +231,7 @@ void ScaleInterpolator::Finish()
|
||||
m_scale = m_endScale;
|
||||
}
|
||||
|
||||
AngleInterpolator::AngleInterpolator()
|
||||
: AngleInterpolator(0.0 /* startAngle */, 0.0 /* endAngle */)
|
||||
{}
|
||||
AngleInterpolator::AngleInterpolator() : AngleInterpolator(0.0 /* startAngle */, 0.0 /* endAngle */) {}
|
||||
|
||||
AngleInterpolator::AngleInterpolator(double startAngle, double endAngle)
|
||||
: AngleInterpolator(0.0 /* delay */, startAngle, endAngle)
|
||||
@@ -282,4 +276,4 @@ void AngleInterpolator::Finish()
|
||||
m_angle = m_endAngle;
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
static double constexpr kInvalidDuration = -1.0;
|
||||
void SetMaxDuration(double maxDuration);
|
||||
void SetMinDuration(double minDuration);
|
||||
void SetMinDuration(double minDuration);
|
||||
double GetMaxDuration() const;
|
||||
double GetMinDuration() const;
|
||||
|
||||
@@ -41,27 +41,23 @@ private:
|
||||
bool m_isActive;
|
||||
};
|
||||
|
||||
class PositionInterpolator: public Interpolator
|
||||
class PositionInterpolator : public Interpolator
|
||||
{
|
||||
using TBase = Interpolator;
|
||||
|
||||
public:
|
||||
PositionInterpolator();
|
||||
PositionInterpolator(double duration, double delay,
|
||||
m2::PointD const & startPosition, m2::PointD const & endPosition);
|
||||
PositionInterpolator(double duration, double delay, m2::PointD const & startPosition, m2::PointD const & endPosition);
|
||||
|
||||
PositionInterpolator(m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
PositionInterpolator(m2::PointD const & startPosition, m2::PointD const & endPosition, ScreenBase const & convertor);
|
||||
|
||||
PositionInterpolator(double delay, m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
ScreenBase const & convertor);
|
||||
|
||||
PositionInterpolator(double delay,
|
||||
m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
ScreenBase const & convertor);
|
||||
PositionInterpolator(m2::PointD const & startPosition, m2::PointD const & endPosition, m2::RectD const & viewportRect,
|
||||
double scale);
|
||||
|
||||
PositionInterpolator(m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
m2::RectD const & viewportRect, double scale);
|
||||
|
||||
PositionInterpolator(double delay,
|
||||
m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
PositionInterpolator(double delay, m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
m2::RectD const & viewportRect, double scale);
|
||||
|
||||
static double GetMoveDuration(double globalDistance, m2::RectD const & viewportRect, double scale);
|
||||
@@ -85,7 +81,7 @@ private:
|
||||
m2::PointD m_position;
|
||||
};
|
||||
|
||||
class ScaleInterpolator: public Interpolator
|
||||
class ScaleInterpolator : public Interpolator
|
||||
{
|
||||
using TBase = Interpolator;
|
||||
|
||||
@@ -110,7 +106,7 @@ private:
|
||||
double m_scale;
|
||||
};
|
||||
|
||||
class AngleInterpolator: public Interpolator
|
||||
class AngleInterpolator : public Interpolator
|
||||
{
|
||||
using TBase = Interpolator;
|
||||
|
||||
@@ -136,4 +132,4 @@ private:
|
||||
double m_angle;
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
namespace df
|
||||
{
|
||||
|
||||
MapLinearAnimation::MapLinearAnimation(m2::PointD const & startPos, m2::PointD const & endPos,
|
||||
double startAngle, double endAngle,
|
||||
double startScale, double endScale, ScreenBase const & convertor)
|
||||
MapLinearAnimation::MapLinearAnimation(m2::PointD const & startPos, m2::PointD const & endPos, double startAngle,
|
||||
double endAngle, double startScale, double endScale,
|
||||
ScreenBase const & convertor)
|
||||
: Animation(true /* couldBeInterrupted */, false /* couldBeBlended */)
|
||||
, m_angleInterpolator(startAngle, endAngle)
|
||||
, m_positionInterpolator(startPos, endPos, convertor)
|
||||
@@ -27,8 +27,7 @@ MapLinearAnimation::MapLinearAnimation(m2::PointD const & startPos, m2::PointD c
|
||||
m_properties.insert(Animation::ObjectProperty::Scale);
|
||||
}
|
||||
|
||||
MapLinearAnimation::MapLinearAnimation()
|
||||
: Animation(true /* couldBeInterrupted */, false /* couldBeBlended */)
|
||||
MapLinearAnimation::MapLinearAnimation() : Animation(true /* couldBeInterrupted */, false /* couldBeBlended */)
|
||||
{
|
||||
m_objects.insert(Animation::Object::MapPlane);
|
||||
}
|
||||
@@ -60,16 +59,15 @@ void MapLinearAnimation::Init(ScreenBase const & screen, TPropertyCache const &
|
||||
m_angleInterpolator.SetMaxDuration(maxDuration);
|
||||
}
|
||||
|
||||
void MapLinearAnimation::SetMove(m2::PointD const & startPos, m2::PointD const & endPos,
|
||||
ScreenBase const & convertor)
|
||||
void MapLinearAnimation::SetMove(m2::PointD const & startPos, m2::PointD const & endPos, ScreenBase const & convertor)
|
||||
{
|
||||
m_positionInterpolator = PositionInterpolator(startPos, endPos, convertor);
|
||||
if (m_positionInterpolator.IsActive())
|
||||
m_properties.insert(Animation::ObjectProperty::Position);
|
||||
}
|
||||
|
||||
void MapLinearAnimation::SetMove(m2::PointD const & startPos, m2::PointD const & endPos,
|
||||
m2::RectD const & viewportRect, double scale)
|
||||
void MapLinearAnimation::SetMove(m2::PointD const & startPos, m2::PointD const & endPos, m2::RectD const & viewportRect,
|
||||
double scale)
|
||||
{
|
||||
m_positionInterpolator = PositionInterpolator(startPos, endPos, viewportRect, scale);
|
||||
if (m_positionInterpolator.IsActive())
|
||||
@@ -194,8 +192,7 @@ double MapLinearAnimation::GetMinDuration() const
|
||||
|
||||
bool MapLinearAnimation::IsFinished() const
|
||||
{
|
||||
return m_angleInterpolator.IsFinished() && m_scaleInterpolator.IsFinished() &&
|
||||
m_positionInterpolator.IsFinished();
|
||||
return m_angleInterpolator.IsFinished() && m_scaleInterpolator.IsFinished() && m_positionInterpolator.IsFinished();
|
||||
}
|
||||
|
||||
bool MapLinearAnimation::GetProperty(Object object, ObjectProperty property, PropertyValue & value) const
|
||||
@@ -208,7 +205,8 @@ bool MapLinearAnimation::GetTargetProperty(Object object, ObjectProperty propert
|
||||
return GetProperty(object, property, true /* targetValue */, value);
|
||||
}
|
||||
|
||||
bool MapLinearAnimation::GetProperty(Object object, ObjectProperty property, bool targetValue, PropertyValue & value) const
|
||||
bool MapLinearAnimation::GetProperty(Object object, ObjectProperty property, bool targetValue,
|
||||
PropertyValue & value) const
|
||||
{
|
||||
ASSERT_EQUAL(static_cast<int>(object), static_cast<int>(Animation::Object::MapPlane), ());
|
||||
|
||||
@@ -217,7 +215,8 @@ bool MapLinearAnimation::GetProperty(Object object, ObjectProperty property, boo
|
||||
case Animation::ObjectProperty::Position:
|
||||
if (m_positionInterpolator.IsActive())
|
||||
{
|
||||
value = PropertyValue(targetValue ? m_positionInterpolator.GetTargetPosition() : m_positionInterpolator.GetPosition());
|
||||
value = PropertyValue(targetValue ? m_positionInterpolator.GetTargetPosition()
|
||||
: m_positionInterpolator.GetPosition());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -235,11 +234,10 @@ bool MapLinearAnimation::GetProperty(Object object, ObjectProperty property, boo
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
ASSERT(false, ("Wrong property:", static_cast<int>(property)));
|
||||
default: ASSERT(false, ("Wrong property:", static_cast<int>(property)));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -8,8 +8,7 @@ namespace df
|
||||
class MapLinearAnimation : public Animation
|
||||
{
|
||||
public:
|
||||
MapLinearAnimation(m2::PointD const & startPos, m2::PointD const & endPos,
|
||||
double startAngle, double endAngle,
|
||||
MapLinearAnimation(m2::PointD const & startPos, m2::PointD const & endPos, double startAngle, double endAngle,
|
||||
double startScale, double endScale, ScreenBase const & convertor);
|
||||
MapLinearAnimation();
|
||||
|
||||
@@ -22,15 +21,9 @@ public:
|
||||
|
||||
Animation::Type GetType() const override { return Animation::Type::MapLinear; }
|
||||
|
||||
TAnimObjects const & GetObjects() const override
|
||||
{
|
||||
return m_objects;
|
||||
}
|
||||
TAnimObjects const & GetObjects() const override { return m_objects; }
|
||||
|
||||
bool HasObject(Object object) const override
|
||||
{
|
||||
return object == Animation::Object::MapPlane;
|
||||
}
|
||||
bool HasObject(Object object) const override { return object == Animation::Object::MapPlane; }
|
||||
|
||||
TObjectProperties const & GetProperties(Object object) const override;
|
||||
bool HasProperty(Object object, ObjectProperty property) const override;
|
||||
|
||||
@@ -6,16 +6,14 @@ namespace df
|
||||
|
||||
OpacityAnimation::OpacityAnimation(double duration, double startOpacity, double endOpacity)
|
||||
: OpacityAnimation(duration, 0.0, startOpacity, endOpacity)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
OpacityAnimation::OpacityAnimation(double duration, double delay, double startOpacity, double endOpacity)
|
||||
: BaseInterpolator(duration, delay)
|
||||
, m_startOpacity(startOpacity)
|
||||
, m_endOpacity(endOpacity)
|
||||
, m_opacity(startOpacity)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void OpacityAnimation::Advance(double elapsedSeconds)
|
||||
{
|
||||
@@ -23,4 +21,4 @@ void OpacityAnimation::Advance(double elapsedSeconds)
|
||||
m_opacity = InterpolateDouble(m_startOpacity, m_endOpacity, GetT());
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace df
|
||||
|
||||
@@ -7,9 +7,7 @@
|
||||
namespace df
|
||||
{
|
||||
|
||||
ParallelAnimation::ParallelAnimation()
|
||||
: Animation(true /* couldBeInterrupted */, true /* couldBeBlended */)
|
||||
{}
|
||||
ParallelAnimation::ParallelAnimation() : Animation(true /* couldBeInterrupted */, true /* couldBeBlended */) {}
|
||||
|
||||
void ParallelAnimation::Init(ScreenBase const & screen, TPropertyCache const & properties)
|
||||
{
|
||||
@@ -55,10 +53,8 @@ bool ParallelAnimation::HasTargetProperty(Object object, ObjectProperty property
|
||||
{
|
||||
ASSERT(!m_animations.empty(), ());
|
||||
for (auto const & anim : m_animations)
|
||||
{
|
||||
if (anim->HasTargetProperty(object, property))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -119,10 +115,8 @@ bool ParallelAnimation::GetProperty(Object object, ObjectProperty property, Prop
|
||||
{
|
||||
ASSERT(!m_animations.empty(), ());
|
||||
for (auto const & anim : m_animations)
|
||||
{
|
||||
if (anim->HasProperty(object, property))
|
||||
return anim->GetProperty(object, property, value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -130,10 +124,8 @@ bool ParallelAnimation::GetTargetProperty(Object object, ObjectProperty property
|
||||
{
|
||||
ASSERT(!m_animations.empty(), ());
|
||||
for (auto const & anim : m_animations)
|
||||
{
|
||||
if (anim->HasProperty(object, property))
|
||||
return anim->GetTargetProperty(object, property, value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -211,4 +203,4 @@ void ParallelAnimation::ObtainObjectProperties()
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -47,12 +47,12 @@ public:
|
||||
bool GetProperty(Object object, ObjectProperty property, PropertyValue & value) const override;
|
||||
bool GetTargetProperty(Object object, ObjectProperty property, PropertyValue & value) const override;
|
||||
|
||||
template<typename T> T const * FindAnimation(Animation::Type type, char const * customType = nullptr) const
|
||||
template <typename T>
|
||||
T const * FindAnimation(Animation::Type type, char const * customType = nullptr) const
|
||||
{
|
||||
for (auto const & anim : m_animations)
|
||||
{
|
||||
if ((anim->GetType() == type) &&
|
||||
(customType == nullptr || anim->GetCustomType() == customType))
|
||||
if ((anim->GetType() == type) && (customType == nullptr || anim->GetCustomType() == customType))
|
||||
{
|
||||
ASSERT(dynamic_cast<T const *>(anim.get()) != nullptr, ());
|
||||
return static_cast<T const *>(anim.get());
|
||||
@@ -71,4 +71,4 @@ private:
|
||||
std::string m_customType;
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -27,7 +27,8 @@ void MapScaleAnimation::Init(ScreenBase const & screen, TPropertyCache const & p
|
||||
double const minDuration = m_scaleInterpolator.GetMinDuration();
|
||||
double const maxDuration = m_scaleInterpolator.GetMaxDuration();
|
||||
|
||||
m_scaleInterpolator = ScaleInterpolator(currentScreen.GetScale(), m_scaleInterpolator.GetTargetScale(), false /* isAutoZoom */);
|
||||
m_scaleInterpolator =
|
||||
ScaleInterpolator(currentScreen.GetScale(), m_scaleInterpolator.GetTargetScale(), false /* isAutoZoom */);
|
||||
|
||||
m_scaleInterpolator.SetMinDuration(minDuration);
|
||||
m_scaleInterpolator.SetMaxDuration(maxDuration);
|
||||
@@ -85,7 +86,8 @@ bool MapScaleAnimation::IsFinished() const
|
||||
return m_scaleInterpolator.IsFinished();
|
||||
}
|
||||
|
||||
bool MapScaleAnimation::GetProperty(Object object, ObjectProperty property, bool targetValue, PropertyValue & value) const
|
||||
bool MapScaleAnimation::GetProperty(Object object, ObjectProperty property, bool targetValue,
|
||||
PropertyValue & value) const
|
||||
{
|
||||
ASSERT_EQUAL(static_cast<int>(object), static_cast<int>(Animation::Object::MapPlane), ());
|
||||
|
||||
@@ -116,4 +118,4 @@ bool MapScaleAnimation::GetProperty(Object object, ObjectProperty property, Prop
|
||||
return GetProperty(object, property, false /* targetValue */, value);
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -9,22 +9,16 @@ namespace df
|
||||
class MapScaleAnimation : public Animation
|
||||
{
|
||||
public:
|
||||
MapScaleAnimation(double startScale, double endScale,
|
||||
m2::PointD const & globalScaleCenter, m2::PointD const & pxScaleCenter);
|
||||
MapScaleAnimation(double startScale, double endScale, m2::PointD const & globalScaleCenter,
|
||||
m2::PointD const & pxScaleCenter);
|
||||
|
||||
void Init(ScreenBase const & screen, TPropertyCache const & properties) override;
|
||||
|
||||
Animation::Type GetType() const override { return Animation::Type::MapScale; }
|
||||
|
||||
TAnimObjects const & GetObjects() const override
|
||||
{
|
||||
return m_objects;
|
||||
}
|
||||
TAnimObjects const & GetObjects() const override { return m_objects; }
|
||||
|
||||
bool HasObject(Object object) const override
|
||||
{
|
||||
return object == Animation::Object::MapPlane;
|
||||
}
|
||||
bool HasObject(Object object) const override { return object == Animation::Object::MapPlane; }
|
||||
|
||||
TObjectProperties const & GetProperties(Object object) const override;
|
||||
bool HasProperty(Object object, ObjectProperty property) const override;
|
||||
@@ -52,5 +46,4 @@ private:
|
||||
TAnimObjects m_objects;
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
|
||||
} // namespace df
|
||||
|
||||
@@ -7,10 +7,7 @@
|
||||
namespace df
|
||||
{
|
||||
|
||||
SequenceAnimation::SequenceAnimation()
|
||||
: Animation(true /* couldBeInterrupted */, true /* couldBeBlended */)
|
||||
{
|
||||
}
|
||||
SequenceAnimation::SequenceAnimation() : Animation(true /* couldBeInterrupted */, true /* couldBeBlended */) {}
|
||||
|
||||
void SequenceAnimation::Init(ScreenBase const & screen, TPropertyCache const & properties)
|
||||
{
|
||||
@@ -18,9 +15,15 @@ void SequenceAnimation::Init(ScreenBase const & screen, TPropertyCache const & p
|
||||
m_animations.front()->Init(screen, properties);
|
||||
}
|
||||
|
||||
std::string SequenceAnimation::GetCustomType() const { return m_customType; }
|
||||
std::string SequenceAnimation::GetCustomType() const
|
||||
{
|
||||
return m_customType;
|
||||
}
|
||||
|
||||
void SequenceAnimation::SetCustomType(std::string const & type) { m_customType = type; }
|
||||
void SequenceAnimation::SetCustomType(std::string const & type)
|
||||
{
|
||||
m_customType = type;
|
||||
}
|
||||
|
||||
Animation::TAnimObjects const & SequenceAnimation::GetObjects() const
|
||||
{
|
||||
@@ -51,10 +54,8 @@ bool SequenceAnimation::HasTargetProperty(Object object, ObjectProperty property
|
||||
{
|
||||
ASSERT(!m_animations.empty(), ());
|
||||
for (auto const & anim : m_animations)
|
||||
{
|
||||
if (anim->HasTargetProperty(object, property))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -192,4 +193,4 @@ void SequenceAnimation::ObtainObjectProperties()
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -35,8 +35,8 @@ public:
|
||||
double GetMinDuration() const override;
|
||||
bool IsFinished() const override;
|
||||
|
||||
bool GetProperty(Object object, ObjectProperty property, PropertyValue &value) const override;
|
||||
bool GetTargetProperty(Object object, ObjectProperty property, PropertyValue &value) const override;
|
||||
bool GetProperty(Object object, ObjectProperty property, PropertyValue & value) const override;
|
||||
bool GetTargetProperty(Object object, ObjectProperty property, PropertyValue & value) const override;
|
||||
|
||||
void AddAnimation(drape_ptr<Animation> && animation);
|
||||
|
||||
@@ -56,5 +56,4 @@ private:
|
||||
std::string m_customType;
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
|
||||
} // namespace df
|
||||
|
||||
@@ -9,22 +9,20 @@ namespace df
|
||||
class ShowHideAnimation::ShowHideInterpolator : public BaseInterpolator
|
||||
{
|
||||
public:
|
||||
ShowHideInterpolator(ShowHideAnimation::EState & state, double startT, double endT,
|
||||
double duration)
|
||||
: BaseInterpolator(duration), m_state(state), m_startT(startT), m_endT(endT)
|
||||
ShowHideInterpolator(ShowHideAnimation::EState & state, double startT, double endT, double duration)
|
||||
: BaseInterpolator(duration)
|
||||
, m_state(state)
|
||||
, m_startT(startT)
|
||||
, m_endT(endT)
|
||||
{
|
||||
m_state = m_endT > m_startT ? ShowHideAnimation::STATE_SHOW_DIRECTION
|
||||
: ShowHideAnimation::STATE_HIDE_DIRECTION;
|
||||
m_state = m_endT > m_startT ? ShowHideAnimation::STATE_SHOW_DIRECTION : ShowHideAnimation::STATE_HIDE_DIRECTION;
|
||||
}
|
||||
|
||||
void Advance(double elapsedSeconds) override
|
||||
{
|
||||
BaseInterpolator::Advance(elapsedSeconds);
|
||||
if (IsFinished())
|
||||
{
|
||||
m_state = m_endT > m_startT ? ShowHideAnimation::STATE_VISIBLE
|
||||
: ShowHideAnimation::STATE_INVISIBLE;
|
||||
}
|
||||
m_state = m_endT > m_startT ? ShowHideAnimation::STATE_VISIBLE : ShowHideAnimation::STATE_INVISIBLE;
|
||||
}
|
||||
|
||||
double GetCurrentT() const { return m_startT + (m_endT - m_startT) * GetT(); }
|
||||
@@ -57,7 +55,7 @@ void ShowHideAnimation::Show()
|
||||
|
||||
void ShowHideAnimation::ShowAnimated()
|
||||
{
|
||||
RefreshInterpolator({{ STATE_VISIBLE, STATE_SHOW_DIRECTION }}, 1.0);
|
||||
RefreshInterpolator({{STATE_VISIBLE, STATE_SHOW_DIRECTION}}, 1.0);
|
||||
}
|
||||
|
||||
void ShowHideAnimation::Hide()
|
||||
@@ -72,7 +70,7 @@ void ShowHideAnimation::Hide()
|
||||
|
||||
void ShowHideAnimation::HideAnimated()
|
||||
{
|
||||
RefreshInterpolator({{ STATE_INVISIBLE, STATE_HIDE_DIRECTION }}, 0.0);
|
||||
RefreshInterpolator({{STATE_INVISIBLE, STATE_HIDE_DIRECTION}}, 0.0);
|
||||
}
|
||||
|
||||
ShowHideAnimation::EState ShowHideAnimation::GetState() const
|
||||
|
||||
@@ -16,6 +16,7 @@ class ValueMapping
|
||||
using TRangePoint = std::pair<double, TValue>;
|
||||
using TRangeVector = buffer_vector<TRangePoint, 8>;
|
||||
using TRangeIter = typename TRangeVector::const_iterator;
|
||||
|
||||
public:
|
||||
ValueMapping() = default;
|
||||
|
||||
@@ -71,4 +72,4 @@ private:
|
||||
TRangeVector m_ranges;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace df
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
namespace df
|
||||
{
|
||||
double const kMaxAnimationTimeSec = 1.5; // in seconds
|
||||
double const kMaxAnimationTimeSec = 1.5; // in seconds
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -54,10 +54,7 @@ public:
|
||||
return m_value;
|
||||
}
|
||||
|
||||
bool IsEmpty() const
|
||||
{
|
||||
return m_counter == 0;
|
||||
}
|
||||
bool IsEmpty() const { return m_counter == 0; }
|
||||
|
||||
private:
|
||||
Animation::PropertyValue m_value;
|
||||
@@ -72,17 +69,16 @@ void AnimationSystem::UpdateLastScreen(ScreenBase const & currentScreen)
|
||||
|
||||
bool AnimationSystem::GetScreen(ScreenBase const & currentScreen, ScreenBase & screen)
|
||||
{
|
||||
return GetScreen(currentScreen, std::bind(&AnimationSystem::GetProperty, this, _1, _2, _3),
|
||||
screen);
|
||||
return GetScreen(currentScreen, std::bind(&AnimationSystem::GetProperty, this, _1, _2, _3), screen);
|
||||
}
|
||||
|
||||
void AnimationSystem::GetTargetScreen(ScreenBase const & currentScreen, ScreenBase & screen)
|
||||
{
|
||||
GetScreen(currentScreen, std::bind(&AnimationSystem::GetTargetProperty, this, _1, _2, _3),
|
||||
screen);
|
||||
GetScreen(currentScreen, std::bind(&AnimationSystem::GetTargetProperty, this, _1, _2, _3), screen);
|
||||
}
|
||||
|
||||
bool AnimationSystem::GetScreen(ScreenBase const & currentScreen, TGetPropertyFn const & getPropertyFn, ScreenBase & screen)
|
||||
bool AnimationSystem::GetScreen(ScreenBase const & currentScreen, TGetPropertyFn const & getPropertyFn,
|
||||
ScreenBase & screen)
|
||||
{
|
||||
ASSERT(getPropertyFn != nullptr, ());
|
||||
|
||||
@@ -135,16 +131,12 @@ bool AnimationSystem::AnimationExists(Animation::Object object) const
|
||||
if (!m_animationChain.empty())
|
||||
{
|
||||
for (auto const & anim : *(m_animationChain.front()))
|
||||
{
|
||||
if (anim->HasObject(object))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (auto const & prop : m_propertyCache)
|
||||
{
|
||||
if (prop.first.first == object)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -240,7 +232,7 @@ void AnimationSystem::CombineAnimation(drape_ptr<Animation> && animation)
|
||||
|
||||
startImmediately = false;
|
||||
}
|
||||
|
||||
|
||||
PushAnimation(std::move(animation));
|
||||
}
|
||||
|
||||
@@ -281,8 +273,8 @@ void AnimationSystem::FinishAnimations(std::function<bool(std::shared_ptr<Animat
|
||||
if (predicate(anim))
|
||||
{
|
||||
#ifdef DEBUG_ANIMATIONS
|
||||
LOG(LINFO, ("Finish animation", anim->GetType(), ", rewind:", rewind,
|
||||
", couldBeRewinded:", anim->CouldBeRewinded()));
|
||||
LOG(LINFO,
|
||||
("Finish animation", anim->GetType(), ", rewind:", rewind, ", couldBeRewinded:", anim->CouldBeRewinded()));
|
||||
changed = true;
|
||||
#endif
|
||||
finishAnimations.splice(finishAnimations.end(), frontList, it++);
|
||||
@@ -335,23 +327,21 @@ void AnimationSystem::FinishAnimations(std::function<bool(std::shared_ptr<Animat
|
||||
|
||||
void AnimationSystem::FinishAnimations(Animation::Type type, bool rewind, bool finishAll)
|
||||
{
|
||||
FinishAnimations([&type](std::shared_ptr<Animation> const & anim) { return anim->GetType() == type; },
|
||||
rewind, finishAll);
|
||||
FinishAnimations([&type](std::shared_ptr<Animation> const & anim) { return anim->GetType() == type; }, rewind,
|
||||
finishAll);
|
||||
}
|
||||
|
||||
void AnimationSystem::FinishAnimations(Animation::Type type, std::string const & customType,
|
||||
bool rewind, bool finishAll)
|
||||
void AnimationSystem::FinishAnimations(Animation::Type type, std::string const & customType, bool rewind,
|
||||
bool finishAll)
|
||||
{
|
||||
FinishAnimations([&type, &customType](std::shared_ptr<Animation> const & anim)
|
||||
{
|
||||
return anim->GetType() == type && anim->GetCustomType() == customType;
|
||||
}, rewind, finishAll);
|
||||
{ return anim->GetType() == type && anim->GetCustomType() == customType; }, rewind, finishAll);
|
||||
}
|
||||
|
||||
void AnimationSystem::FinishObjectAnimations(Animation::Object object, bool rewind, bool finishAll)
|
||||
{
|
||||
FinishAnimations([&object](std::shared_ptr<Animation> const & anim) { return anim->HasObject(object); },
|
||||
rewind, finishAll);
|
||||
FinishAnimations([&object](std::shared_ptr<Animation> const & anim) { return anim->HasObject(object); }, rewind,
|
||||
finishAll);
|
||||
}
|
||||
|
||||
void AnimationSystem::Advance(double elapsedSeconds)
|
||||
@@ -366,13 +356,9 @@ void AnimationSystem::Advance(double elapsedSeconds)
|
||||
auto & anim = *it;
|
||||
anim->Advance(elapsedSeconds);
|
||||
if (anim->IsFinished())
|
||||
{
|
||||
finishedAnimations.splice(finishedAnimations.end(), frontList, it++);
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
for (auto & anim : finishedAnimations)
|
||||
{
|
||||
@@ -397,7 +383,6 @@ void AnimationSystem::Print()
|
||||
auto & anim = *it;
|
||||
LOG(LINFO, ("Type:", anim->GetType()));
|
||||
}
|
||||
|
||||
}
|
||||
LOG(LINFO, ("========================Animation chain end========================"));
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@ public:
|
||||
void PushAnimation(drape_ptr<Animation> && animation);
|
||||
|
||||
void FinishAnimations(Animation::Type type, bool rewind, bool finishAll);
|
||||
void FinishAnimations(Animation::Type type, std::string const & customType, bool rewind,
|
||||
bool finishAll);
|
||||
void FinishAnimations(Animation::Type type, std::string const & customType, bool rewind, bool finishAll);
|
||||
void FinishObjectAnimations(Animation::Object object, bool rewind, bool finishAll);
|
||||
|
||||
template<typename T> T const * FindAnimation(Animation::Type type, char const * customType = nullptr) const
|
||||
template <typename T>
|
||||
T const * FindAnimation(Animation::Type type, char const * customType = nullptr) const
|
||||
{
|
||||
for (auto & pList : m_animationChain)
|
||||
{
|
||||
@@ -65,20 +65,20 @@ public:
|
||||
ScreenBase const & GetLastScreen() { return m_lastScreen; }
|
||||
void SaveAnimationResult(Animation const & animation);
|
||||
|
||||
private:
|
||||
private:
|
||||
AnimationSystem() = default;
|
||||
|
||||
using TGetPropertyFn = std::function<bool(Animation::Object object, Animation::ObjectProperty property,
|
||||
Animation::PropertyValue & value)>;
|
||||
bool GetScreen(ScreenBase const & currentScreen, TGetPropertyFn const & getPropertyFn, ScreenBase & screen);
|
||||
Animation::PropertyValue & value)>;
|
||||
bool GetScreen(ScreenBase const & currentScreen, TGetPropertyFn const & getPropertyFn, ScreenBase & screen);
|
||||
|
||||
bool GetProperty(Animation::Object object, Animation::ObjectProperty property,
|
||||
Animation::PropertyValue & value) const;
|
||||
bool GetTargetProperty(Animation::Object object, Animation::ObjectProperty property,
|
||||
Animation::PropertyValue & value) const;
|
||||
Animation::PropertyValue & value) const;
|
||||
void StartNextAnimations();
|
||||
void FinishAnimations(std::function<bool(std::shared_ptr<Animation> const &)> const & predicate,
|
||||
bool rewind, bool finishAll);
|
||||
void FinishAnimations(std::function<bool(std::shared_ptr<Animation> const &)> const & predicate, bool rewind,
|
||||
bool finishAll);
|
||||
|
||||
#ifdef DEBUG_ANIMATIONS
|
||||
void Print();
|
||||
@@ -86,8 +86,7 @@ private:
|
||||
|
||||
using TAnimationList = std::list<std::shared_ptr<Animation>>;
|
||||
using TAnimationChain = std::deque<std::shared_ptr<TAnimationList>>;
|
||||
using TPropertyCache = std::map<std::pair<Animation::Object, Animation::ObjectProperty>,
|
||||
Animation::PropertyValue>;
|
||||
using TPropertyCache = std::map<std::pair<Animation::Object, Animation::ObjectProperty>, Animation::PropertyValue>;
|
||||
|
||||
TAnimationChain m_animationChain;
|
||||
mutable TPropertyCache m_propertyCache;
|
||||
|
||||
@@ -12,4 +12,4 @@ bool IsAnimationAllowed(double duration, ScreenBase const & screen)
|
||||
return duration > 0.0 && duration <= kMaxAnimationTimeSec;
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -7,4 +7,4 @@ namespace df
|
||||
|
||||
bool IsAnimationAllowed(double duration, ScreenBase const & screen);
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -78,8 +78,8 @@ public:
|
||||
for (std::pair<int, TValue> const & v : zoomValues)
|
||||
{
|
||||
int const filtered = v.second.m_readPoints - v.second.m_neededPoints;
|
||||
LOG(LINFO, ("Zoom =", v.first, "Filtered", 100 * filtered / (double)v.second.m_readPoints, "% (",
|
||||
filtered, "out of", v.second.m_readPoints, "points)"));
|
||||
LOG(LINFO, ("Zoom =", v.first, "Filtered", 100 * filtered / (double)v.second.m_readPoints, "% (", filtered,
|
||||
"out of", v.second.m_readPoints, "points)"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,26 +134,18 @@ void ExtractLineParams(LineRuleProto const & lineRule, LineViewParams & params)
|
||||
|
||||
switch (lineRule.cap())
|
||||
{
|
||||
case ::ROUNDCAP : params.m_cap = dp::RoundCap;
|
||||
break;
|
||||
case ::BUTTCAP : params.m_cap = dp::ButtCap;
|
||||
break;
|
||||
case ::SQUARECAP: params.m_cap = dp::SquareCap;
|
||||
break;
|
||||
default:
|
||||
CHECK(false, ());
|
||||
case ::ROUNDCAP: params.m_cap = dp::RoundCap; break;
|
||||
case ::BUTTCAP: params.m_cap = dp::ButtCap; break;
|
||||
case ::SQUARECAP: params.m_cap = dp::SquareCap; break;
|
||||
default: CHECK(false, ());
|
||||
}
|
||||
|
||||
switch (lineRule.join())
|
||||
{
|
||||
case ::NOJOIN : params.m_join = dp::MiterJoin;
|
||||
break;
|
||||
case ::ROUNDJOIN : params.m_join = dp::RoundJoin;
|
||||
break;
|
||||
case ::BEVELJOIN : params.m_join = dp::BevelJoin;
|
||||
break;
|
||||
default:
|
||||
CHECK(false, ());
|
||||
case ::NOJOIN: params.m_join = dp::MiterJoin; break;
|
||||
case ::ROUNDJOIN: params.m_join = dp::RoundJoin; break;
|
||||
case ::BEVELJOIN: params.m_join = dp::BevelJoin; break;
|
||||
default: CHECK(false, ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,13 +190,12 @@ dp::Anchor GetAnchor(int offsetX, int offsetY)
|
||||
m2::PointF GetOffset(int offsetX, int offsetY)
|
||||
{
|
||||
double const vs = VisualParams::Instance().GetVisualScale();
|
||||
return { static_cast<float>(offsetX * vs), static_cast<float>(offsetY * vs) };
|
||||
return {static_cast<float>(offsetX * vs), static_cast<float>(offsetY * vs)};
|
||||
}
|
||||
|
||||
bool IsSymbolRoadShield(ftypes::RoadShield const & shield)
|
||||
{
|
||||
return shield.m_type == ftypes::RoadShieldType::US_Interstate ||
|
||||
shield.m_type == ftypes::RoadShieldType::US_Highway;
|
||||
return shield.m_type == ftypes::RoadShieldType::US_Interstate || shield.m_type == ftypes::RoadShieldType::US_Highway;
|
||||
}
|
||||
|
||||
std::string GetRoadShieldSymbolName(ftypes::RoadShield const & shield, double fontScale)
|
||||
@@ -216,9 +207,7 @@ std::string GetRoadShieldSymbolName(ftypes::RoadShield const & shield, double fo
|
||||
else if (shield.m_type == ftypes::RoadShieldType::US_Highway)
|
||||
result = shield.m_name.size() <= 2 ? "shield-us-hw-thin" : "shield-us-hw-wide";
|
||||
else
|
||||
{
|
||||
ASSERT(false, ("This shield type doesn't support symbols:", shield.m_type));
|
||||
}
|
||||
|
||||
if (fontScale > 1.0)
|
||||
result += "-scaled";
|
||||
@@ -228,8 +217,7 @@ std::string GetRoadShieldSymbolName(ftypes::RoadShield const & shield, double fo
|
||||
|
||||
bool IsColoredRoadShield(ftypes::RoadShield const & shield)
|
||||
{
|
||||
return shield.m_type == ftypes::RoadShieldType::Default ||
|
||||
shield.m_type == ftypes::RoadShieldType::UK_Highway ||
|
||||
return shield.m_type == ftypes::RoadShieldType::Default || shield.m_type == ftypes::RoadShieldType::UK_Highway ||
|
||||
shield.m_type == ftypes::RoadShieldType::Generic_White ||
|
||||
shield.m_type == ftypes::RoadShieldType::Generic_Blue ||
|
||||
shield.m_type == ftypes::RoadShieldType::Generic_Green ||
|
||||
@@ -250,8 +238,7 @@ void UpdateRoadShieldTextFont(dp::FontDecl & font, ftypes::RoadShield const & sh
|
||||
{RoadShieldType::US_Interstate, kRoadShieldWhiteTextColor},
|
||||
{RoadShieldType::US_Highway, kRoadShieldBlackTextColor},
|
||||
{RoadShieldType::Generic_Red, kRoadShieldWhiteTextColor},
|
||||
{RoadShieldType::Generic_Orange, kRoadShieldBlackTextColor}
|
||||
};
|
||||
{RoadShieldType::Generic_Orange, kRoadShieldBlackTextColor}};
|
||||
|
||||
if (auto const * cl = kColors.Find(shield.m_type); cl)
|
||||
font.m_color = df::GetColorConstant(*cl);
|
||||
@@ -266,8 +253,7 @@ dp::Color GetRoadShieldColor(dp::Color const & baseColor, ftypes::RoadShield con
|
||||
{RoadShieldType::Generic_Blue, kRoadShieldBlueBackgroundColor},
|
||||
{RoadShieldType::UK_Highway, kRoadShieldGreenBackgroundColor},
|
||||
{RoadShieldType::Generic_Red, kRoadShieldRedBackgroundColor},
|
||||
{RoadShieldType::Generic_Orange, kRoadShieldOrangeBackgroundColor}
|
||||
};
|
||||
{RoadShieldType::Generic_Orange, kRoadShieldOrangeBackgroundColor}};
|
||||
|
||||
if (auto const * cl = kColors.Find(shield.m_type); cl)
|
||||
return df::GetColorConstant(*cl);
|
||||
@@ -277,10 +263,8 @@ dp::Color GetRoadShieldColor(dp::Color const & baseColor, ftypes::RoadShield con
|
||||
|
||||
float GetRoadShieldOutlineWidth(float baseWidth, ftypes::RoadShield const & shield)
|
||||
{
|
||||
if (shield.m_type == ftypes::RoadShieldType::UK_Highway ||
|
||||
shield.m_type == ftypes::RoadShieldType::Generic_Blue ||
|
||||
shield.m_type == ftypes::RoadShieldType::Generic_Green ||
|
||||
shield.m_type == ftypes::RoadShieldType::Generic_Red)
|
||||
if (shield.m_type == ftypes::RoadShieldType::UK_Highway || shield.m_type == ftypes::RoadShieldType::Generic_Blue ||
|
||||
shield.m_type == ftypes::RoadShieldType::Generic_Green || shield.m_type == ftypes::RoadShieldType::Generic_Red)
|
||||
return 0.0f;
|
||||
|
||||
return baseWidth;
|
||||
@@ -290,18 +274,24 @@ dp::Anchor GetShieldAnchor(uint8_t shieldIndex, uint8_t shieldCount)
|
||||
{
|
||||
switch (shieldCount)
|
||||
{
|
||||
case 2:
|
||||
if (shieldIndex == 0) return dp::Bottom;
|
||||
return dp::Top;
|
||||
case 3:
|
||||
if (shieldIndex == 0) return dp::RightBottom;
|
||||
else if (shieldIndex == 1) return dp::LeftBottom;
|
||||
return dp::Top;
|
||||
case 4:
|
||||
if (shieldIndex == 0) return dp::RightBottom;
|
||||
else if (shieldIndex == 1) return dp::LeftBottom;
|
||||
else if (shieldIndex == 2) return dp::RightTop;
|
||||
return dp::LeftTop;
|
||||
case 2:
|
||||
if (shieldIndex == 0)
|
||||
return dp::Bottom;
|
||||
return dp::Top;
|
||||
case 3:
|
||||
if (shieldIndex == 0)
|
||||
return dp::RightBottom;
|
||||
else if (shieldIndex == 1)
|
||||
return dp::LeftBottom;
|
||||
return dp::Top;
|
||||
case 4:
|
||||
if (shieldIndex == 0)
|
||||
return dp::RightBottom;
|
||||
else if (shieldIndex == 1)
|
||||
return dp::LeftBottom;
|
||||
else if (shieldIndex == 2)
|
||||
return dp::RightTop;
|
||||
return dp::LeftTop;
|
||||
}
|
||||
// A single shield.
|
||||
return dp::Center;
|
||||
@@ -322,8 +312,7 @@ m2::PointF GetShieldOffset(dp::Anchor anchor, double paddingWidth, double paddin
|
||||
return offset;
|
||||
}
|
||||
|
||||
void CalculateRoadShieldPositions(std::vector<double> const & offsets,
|
||||
m2::SharedSpline const & spline,
|
||||
void CalculateRoadShieldPositions(std::vector<double> const & offsets, m2::SharedSpline const & spline,
|
||||
std::vector<m2::PointD> & shieldPositions)
|
||||
{
|
||||
ASSERT(!offsets.empty(), ());
|
||||
@@ -342,8 +331,8 @@ void CalculateRoadShieldPositions(std::vector<double> const & offsets,
|
||||
}
|
||||
} // namespace
|
||||
|
||||
BaseApplyFeature::BaseApplyFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape,
|
||||
FeatureType & f, CaptionDescription const & captions)
|
||||
BaseApplyFeature::BaseApplyFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape, FeatureType & f,
|
||||
CaptionDescription const & captions)
|
||||
: m_insertShape(insertShape)
|
||||
, m_f(f)
|
||||
, m_captions(captions)
|
||||
@@ -361,8 +350,7 @@ void BaseApplyFeature::FillCommonParams(CommonOverlayViewParams & p) const
|
||||
}
|
||||
|
||||
void ApplyPointFeature::ExtractCaptionParams(CaptionDefProto const * primaryProto,
|
||||
CaptionDefProto const * secondaryProto,
|
||||
TextViewParams & params) const
|
||||
CaptionDefProto const * secondaryProto, TextViewParams & params) const
|
||||
{
|
||||
FillCommonParams(params);
|
||||
params.m_depthLayer = DepthLayer::OverlayLayer;
|
||||
@@ -419,7 +407,8 @@ double BaseApplyFeature::PriorityToDepth(int priority, drule::TypeT ruleType, do
|
||||
{
|
||||
// Note we don't adjust priorities of "point-styles" according to layer=*,
|
||||
// because their priorities are used for displacement logic only.
|
||||
/// @todo(pastk) we might want to hide e.g. a trash bin under man_made=bridge or a bench on underground railway station?
|
||||
/// @todo(pastk) we might want to hide e.g. a trash bin under man_made=bridge or a bench on underground railway
|
||||
/// station?
|
||||
|
||||
// Check overlays priorities range.
|
||||
ASSERT(-drule::kOverlaysMaxPriority <= depth && depth < drule::kOverlaysMaxPriority, (depth, m_f.DebugString()));
|
||||
@@ -457,8 +446,8 @@ void ApplyPointFeature::ProcessPointRules(SymbolRuleProto const * symbolRule, Ca
|
||||
params.m_symbolName = symbolRule->name();
|
||||
ASSERT_GREATER_OR_EQUAL(symbolRule->min_distance(), 0, ());
|
||||
auto const & vp = df::VisualParams::Instance();
|
||||
params.m_extendingSize = static_cast<uint32_t>(vp.GetVisualScale() * symbolRule->min_distance() *
|
||||
vp.GetPoiExtendScale());
|
||||
params.m_extendingSize =
|
||||
static_cast<uint32_t>(vp.GetVisualScale() * symbolRule->min_distance() * vp.GetPoiExtendScale());
|
||||
params.m_posZ = m_posZ;
|
||||
params.m_hasArea = HasArea();
|
||||
params.m_prioritized = createdByEditor;
|
||||
@@ -497,9 +486,9 @@ void ApplyPointFeature::ProcessPointRules(SymbolRuleProto const * symbolRule, Ca
|
||||
params.m_titleDecl.m_anchor = GetAnchor(0, 1);
|
||||
|
||||
params.m_startOverlayRank = symbolRule ? dp::OverlayRank1 : dp::OverlayRank0;
|
||||
auto shape = make_unique_dp<TextShape>(centerPoint, params, m_tileKey, symbolSize,
|
||||
m2::PointF(0.0f, 0.0f) /* symbolOffset */,
|
||||
dp::Center /* symbolAnchor */, 0 /* textIndex */);
|
||||
auto shape =
|
||||
make_unique_dp<TextShape>(centerPoint, params, m_tileKey, symbolSize, m2::PointF(0.0f, 0.0f) /* symbolOffset */,
|
||||
dp::Center /* symbolAnchor */, 0 /* textIndex */);
|
||||
m_insertShape(std::move(shape));
|
||||
}
|
||||
|
||||
@@ -527,14 +516,13 @@ void ApplyPointFeature::ProcessPointRules(SymbolRuleProto const * symbolRule, Ca
|
||||
}
|
||||
}
|
||||
m_insertShape(make_unique_dp<TextShape>(centerPoint, params, m_tileKey, symbolSize,
|
||||
m2::PointF(0.0f, 0.0f) /* symbolOffset */,
|
||||
dp::Center /* symbolAnchor */, 0 /* textIndex */));
|
||||
m2::PointF(0.0f, 0.0f) /* symbolOffset */, dp::Center /* symbolAnchor */,
|
||||
0 /* textIndex */));
|
||||
}
|
||||
}
|
||||
|
||||
ApplyAreaFeature::ApplyAreaFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape,
|
||||
FeatureType & f, double currentScaleGtoP, bool isBuilding,
|
||||
float minPosZ, float posZ,
|
||||
ApplyAreaFeature::ApplyAreaFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape, FeatureType & f,
|
||||
double currentScaleGtoP, bool isBuilding, float minPosZ, float posZ,
|
||||
CaptionDescription const & captions)
|
||||
: TBase(tileKey, insertShape, f, captions)
|
||||
, m_minPosZ(minPosZ)
|
||||
@@ -556,8 +544,8 @@ void ApplyAreaFeature::operator()(m2::PointD const & p1, m2::PointD const & p2,
|
||||
|
||||
m2::PointD const v1 = p2 - p1;
|
||||
m2::PointD const v2 = p3 - p1;
|
||||
//TODO(pastk) : degenerate triangles filtering should be done in the generator.
|
||||
// ASSERT(!v1.IsAlmostZero() && !v2.IsAlmostZero(), ());
|
||||
// TODO(pastk) : degenerate triangles filtering should be done in the generator.
|
||||
// ASSERT(!v1.IsAlmostZero() && !v2.IsAlmostZero(), ());
|
||||
if (v1.IsAlmostZero() || v2.IsAlmostZero())
|
||||
return;
|
||||
|
||||
@@ -584,8 +572,7 @@ void ApplyAreaFeature::operator()(m2::PointD const & p1, m2::PointD const & p2,
|
||||
m2::ClipTriangleByRect(m_tileRect, p1, p3, p2, clipFunctor);
|
||||
}
|
||||
|
||||
void ApplyAreaFeature::ProcessBuildingPolygon(m2::PointD const & p1, m2::PointD const & p2,
|
||||
m2::PointD const & p3)
|
||||
void ApplyAreaFeature::ProcessBuildingPolygon(m2::PointD const & p1, m2::PointD const & p2, m2::PointD const & p3)
|
||||
{
|
||||
// For building we must filter degenerate polygons because now we have to reconstruct
|
||||
// building outline by bunch of polygons.
|
||||
@@ -649,8 +636,7 @@ bool ApplyAreaFeature::IsDuplicatedEdge(Edge const & edge)
|
||||
return false;
|
||||
}
|
||||
|
||||
m2::PointD ApplyAreaFeature::CalculateNormal(m2::PointD const & p1, m2::PointD const & p2,
|
||||
m2::PointD const & p3) const
|
||||
m2::PointD ApplyAreaFeature::CalculateNormal(m2::PointD const & p1, m2::PointD const & p2, m2::PointD const & p3) const
|
||||
{
|
||||
m2::PointD const tangent = (p2 - p1).Normalize();
|
||||
m2::PointD normal = m2::PointD(-tangent.y, tangent.x);
|
||||
@@ -751,9 +737,8 @@ void ApplyAreaFeature::ProcessRule(AreaRuleProto const & areaRule, double areaDe
|
||||
if (m_isBuilding && !isHatching)
|
||||
{
|
||||
/// @todo Make borders work for non-building areas too.
|
||||
outline.m_generateOutline = areaRule.has_border() &&
|
||||
areaRule.color() != areaRule.border().color() &&
|
||||
areaRule.border().width() > 0.0;
|
||||
outline.m_generateOutline =
|
||||
areaRule.has_border() && areaRule.color() != areaRule.border().color() && areaRule.border().width() > 0.0;
|
||||
if (outline.m_generateOutline)
|
||||
params.m_outlineColor = ToDrapeColor(areaRule.border().color());
|
||||
|
||||
@@ -765,8 +750,8 @@ void ApplyAreaFeature::ProcessRule(AreaRuleProto const & areaRule, double areaDe
|
||||
}
|
||||
|
||||
// see ProcessAreaRules: isHatching first, - !isHatching last.
|
||||
m_insertShape(make_unique_dp<AreaShape>(!isHatching ? std::move(m_triangles) : m_triangles,
|
||||
std::move(outline), params));
|
||||
m_insertShape(
|
||||
make_unique_dp<AreaShape>(!isHatching ? std::move(m_triangles) : m_triangles, std::move(outline), params));
|
||||
}
|
||||
|
||||
ApplyLineFeatureGeometry::ApplyLineFeatureGeometry(TileKey const & tileKey, TInsertShapeFn const & insertShape,
|
||||
@@ -780,7 +765,7 @@ ApplyLineFeatureGeometry::ApplyLineFeatureGeometry(TileKey const & tileKey, TIns
|
||||
m_spline.Reset(new m2::Spline(f.GetPointsCount()));
|
||||
}
|
||||
|
||||
void ApplyLineFeatureGeometry::operator() (m2::PointD const & point)
|
||||
void ApplyLineFeatureGeometry::operator()(m2::PointD const & point)
|
||||
{
|
||||
#ifdef LINES_GENERATION_CALC_FILTERED_POINTS
|
||||
++m_readCount;
|
||||
@@ -791,19 +776,15 @@ void ApplyLineFeatureGeometry::operator() (m2::PointD const & point)
|
||||
m_spline->AddPoint(point);
|
||||
m_lastAddedPoint = point;
|
||||
}
|
||||
else if (m_simplify && ((m_spline->GetSize() > 1 && point.SquaredLength(m_lastAddedPoint) < m_minSegmentSqrLength) ||
|
||||
m_spline->IsProlonging(point)))
|
||||
{
|
||||
m_spline->ReplacePoint(point);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_simplify &&
|
||||
((m_spline->GetSize() > 1 && point.SquaredLength(m_lastAddedPoint) < m_minSegmentSqrLength) ||
|
||||
m_spline->IsProlonging(point)))
|
||||
{
|
||||
m_spline->ReplacePoint(point);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_spline->AddPoint(point);
|
||||
m_lastAddedPoint = point;
|
||||
}
|
||||
m_spline->AddPoint(point);
|
||||
m_lastAddedPoint = point;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -834,7 +815,7 @@ void ApplyLineFeatureGeometry::ProcessLineRules(Stylist::LineRulesT const & line
|
||||
m2::SmoothPaths(guidePointsForSmooth, 4 /* newPointsPerSegmentCount */, m2::kCentripetalAlpha, clippedPaths);
|
||||
|
||||
ASSERT(m_clippedSplines.empty(), ());
|
||||
std::function<void (m2::SharedSpline &&)> inserter = base::MakeBackInsertFunctor(m_clippedSplines);
|
||||
std::function<void(m2::SharedSpline &&)> inserter = base::MakeBackInsertFunctor(m_clippedSplines);
|
||||
for (auto & path : clippedPaths)
|
||||
m2::ClipPathByRect(m_tileRect, std::move(path), inserter);
|
||||
}
|
||||
@@ -897,12 +878,10 @@ ApplyLineFeatureAdditional::ApplyLineFeatureAdditional(TileKey const & tileKey,
|
||||
}
|
||||
|
||||
void ApplyLineFeatureAdditional::GetRoadShieldsViewParams(ref_ptr<dp::TextureManager> texMng,
|
||||
ftypes::RoadShield const & shield,
|
||||
uint8_t shieldIndex, uint8_t shieldCount,
|
||||
TextViewParams & textParams,
|
||||
ftypes::RoadShield const & shield, uint8_t shieldIndex,
|
||||
uint8_t shieldCount, TextViewParams & textParams,
|
||||
ColoredSymbolViewParams & symbolParams,
|
||||
PoiSymbolViewParams & poiParams,
|
||||
m2::PointD & shieldPixelSize)
|
||||
PoiSymbolViewParams & poiParams, m2::PointD & shieldPixelSize)
|
||||
{
|
||||
ASSERT(m_shieldRule, ());
|
||||
|
||||
@@ -979,7 +958,8 @@ void ApplyLineFeatureAdditional::GetRoadShieldsViewParams(ref_ptr<dp::TextureMan
|
||||
texMng->GetSymbolRegion(poiParams.m_symbolName, region);
|
||||
float const symBorderWidth = (region.GetPixelSize().x - textWidthInPixels) * 0.5f;
|
||||
float const symBorderHeight = (region.GetPixelSize().y - textHeightInPixels) * 0.5f;
|
||||
textParams.m_titleDecl.m_primaryOffset = poiParams.m_offset + GetShieldOffset(anchor, symBorderWidth, symBorderHeight);
|
||||
textParams.m_titleDecl.m_primaryOffset =
|
||||
poiParams.m_offset + GetShieldOffset(anchor, symBorderWidth, symBorderHeight);
|
||||
shieldPixelSize = region.GetPixelSize();
|
||||
}
|
||||
|
||||
@@ -995,10 +975,8 @@ void ApplyLineFeatureAdditional::GetRoadShieldsViewParams(ref_ptr<dp::TextureMan
|
||||
}
|
||||
}
|
||||
|
||||
bool ApplyLineFeatureAdditional::CheckShieldsNearby(m2::PointD const & shieldPos,
|
||||
m2::PointD const & shieldPixelSize,
|
||||
uint32_t minDistanceInPixels,
|
||||
std::vector<m2::RectD> & shields)
|
||||
bool ApplyLineFeatureAdditional::CheckShieldsNearby(m2::PointD const & shieldPos, m2::PointD const & shieldPixelSize,
|
||||
uint32_t minDistanceInPixels, std::vector<m2::RectD> & shields)
|
||||
{
|
||||
// Here we calculate extended rect to skip the same shields nearby.
|
||||
m2::PointD const skippingArea(2 * minDistanceInPixels, 2 * minDistanceInPixels);
|
||||
@@ -1006,10 +984,8 @@ bool ApplyLineFeatureAdditional::CheckShieldsNearby(m2::PointD const & shieldPos
|
||||
m2::PointD const shieldMercatorHalfSize = extendedPixelSize / m_currentScaleGtoP * 0.5;
|
||||
m2::RectD shieldRect(shieldPos - shieldMercatorHalfSize, shieldPos + shieldMercatorHalfSize);
|
||||
for (auto const & r : shields)
|
||||
{
|
||||
if (r.IsIntersect(shieldRect))
|
||||
return false;
|
||||
}
|
||||
shields.push_back(shieldRect);
|
||||
return true;
|
||||
}
|
||||
@@ -1078,8 +1054,7 @@ void ApplyLineFeatureAdditional::ProcessAdditionalLineRules(PathTextRuleProto co
|
||||
{
|
||||
double const pixelLength = 300.0 * vs;
|
||||
std::vector<double> offsets;
|
||||
PathTextLayout::CalculatePositions(spline->GetLength(), m_currentScaleGtoP,
|
||||
pixelLength, offsets);
|
||||
PathTextLayout::CalculatePositions(spline->GetLength(), m_currentScaleGtoP, pixelLength, offsets);
|
||||
if (!offsets.empty())
|
||||
CalculateRoadShieldPositions(offsets, spline, shieldPositions);
|
||||
}
|
||||
@@ -1104,8 +1079,8 @@ void ApplyLineFeatureAdditional::ProcessAdditionalLineRules(PathTextRuleProto co
|
||||
ColoredSymbolViewParams symbolParams;
|
||||
PoiSymbolViewParams poiParams;
|
||||
m2::PointD shieldPixelSize;
|
||||
GetRoadShieldsViewParams(texMng, shield, shieldIndex, static_cast<uint8_t>(roadShields.size()),
|
||||
textParams, symbolParams, poiParams, shieldPixelSize);
|
||||
GetRoadShieldsViewParams(texMng, shield, shieldIndex, static_cast<uint8_t>(roadShields.size()), textParams,
|
||||
symbolParams, poiParams, shieldPixelSize);
|
||||
|
||||
auto & generatedShieldRects = generatedRoadShields[shield];
|
||||
generatedShieldRects.reserve(10);
|
||||
@@ -1114,10 +1089,9 @@ void ApplyLineFeatureAdditional::ProcessAdditionalLineRules(PathTextRuleProto co
|
||||
if (!CheckShieldsNearby(shieldPos, shieldPixelSize, scaledMinDistance, generatedShieldRects))
|
||||
continue;
|
||||
|
||||
m_insertShape(make_unique_dp<TextShape>(shieldPos, textParams, m_tileKey,
|
||||
m2::PointF(0.0f, 0.0f) /* symbolSize */,
|
||||
m2::PointF(0.0f, 0.0f) /* symbolOffset */,
|
||||
dp::Center /* symbolAnchor */, textIndex));
|
||||
m_insertShape(make_unique_dp<TextShape>(shieldPos, textParams, m_tileKey, m2::PointF(0.0f, 0.0f) /* symbolSize */,
|
||||
m2::PointF(0.0f, 0.0f) /* symbolOffset */, dp::Center /* symbolAnchor */,
|
||||
textIndex));
|
||||
if (IsColoredRoadShield(shield))
|
||||
m_insertShape(make_unique_dp<ColoredSymbolShape>(shieldPos, symbolParams, m_tileKey, textIndex));
|
||||
else if (IsSymbolRoadShield(shield))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "drape_frontend/shape_view_params.hpp"
|
||||
#include "drape_frontend/stylist.hpp"
|
||||
#include "drape_frontend/tile_key.hpp"
|
||||
#include "drape_frontend/shape_view_params.hpp"
|
||||
|
||||
#include "drape/drape_diagnostics.hpp"
|
||||
#include "drape/pointers.hpp"
|
||||
@@ -22,7 +22,7 @@ class CaptionDefProto;
|
||||
namespace dp
|
||||
{
|
||||
class TextureManager;
|
||||
} // namespace dp
|
||||
} // namespace dp
|
||||
|
||||
namespace df
|
||||
{
|
||||
@@ -36,8 +36,8 @@ using TInsertShapeFn = std::function<void(drape_ptr<MapShape> && shape)>;
|
||||
class BaseApplyFeature
|
||||
{
|
||||
public:
|
||||
BaseApplyFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape,
|
||||
FeatureType & f, CaptionDescription const & captions);
|
||||
BaseApplyFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape, FeatureType & f,
|
||||
CaptionDescription const & captions);
|
||||
|
||||
virtual ~BaseApplyFeature() = default;
|
||||
|
||||
@@ -66,10 +66,10 @@ public:
|
||||
ref_ptr<dp::TextureManager> texMng);
|
||||
|
||||
protected:
|
||||
void ExtractCaptionParams(CaptionDefProto const * primaryProto,
|
||||
CaptionDefProto const * secondaryProto,
|
||||
void ExtractCaptionParams(CaptionDefProto const * primaryProto, CaptionDefProto const * secondaryProto,
|
||||
TextViewParams & params) const;
|
||||
float m_posZ = 0.0f;
|
||||
|
||||
private:
|
||||
virtual bool HasArea() const { return false; }
|
||||
};
|
||||
@@ -79,9 +79,8 @@ class ApplyAreaFeature : public ApplyPointFeature
|
||||
using TBase = ApplyPointFeature;
|
||||
|
||||
public:
|
||||
ApplyAreaFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape,
|
||||
FeatureType & f, double currentScaleGtoP, bool isBuilding,
|
||||
float minPosZ, float posZ,
|
||||
ApplyAreaFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape, FeatureType & f,
|
||||
double currentScaleGtoP, bool isBuilding, float minPosZ, float posZ,
|
||||
CaptionDescription const & captions);
|
||||
|
||||
void operator()(m2::PointD const & p1, m2::PointD const & p2, m2::PointD const & p3);
|
||||
@@ -96,7 +95,7 @@ public:
|
||||
bool operator==(Edge const & edge) const
|
||||
{
|
||||
return (m_startIndex == edge.m_startIndex && m_endIndex == edge.m_endIndex) ||
|
||||
(m_startIndex == edge.m_endIndex && m_endIndex == edge.m_startIndex);
|
||||
(m_startIndex == edge.m_endIndex && m_endIndex == edge.m_startIndex);
|
||||
}
|
||||
|
||||
int m_startIndex = -1;
|
||||
@@ -142,10 +141,10 @@ class ApplyLineFeatureGeometry : public BaseApplyFeature
|
||||
using TBase = BaseApplyFeature;
|
||||
|
||||
public:
|
||||
ApplyLineFeatureGeometry(TileKey const & tileKey, TInsertShapeFn const & insertShape,
|
||||
FeatureType & f, double currentScaleGtoP);
|
||||
ApplyLineFeatureGeometry(TileKey const & tileKey, TInsertShapeFn const & insertShape, FeatureType & f,
|
||||
double currentScaleGtoP);
|
||||
|
||||
void operator() (m2::PointD const & point);
|
||||
void operator()(m2::PointD const & point);
|
||||
bool HasGeometry() const { return m_spline->IsValid(); }
|
||||
void ProcessLineRules(Stylist::LineRulesT const & lineRules);
|
||||
|
||||
@@ -172,8 +171,8 @@ class ApplyLineFeatureAdditional : public BaseApplyFeature
|
||||
using TBase = BaseApplyFeature;
|
||||
|
||||
public:
|
||||
ApplyLineFeatureAdditional(TileKey const & tileKey, TInsertShapeFn const & insertShape,
|
||||
FeatureType & f, double currentScaleGtoP, CaptionDescription const & captions,
|
||||
ApplyLineFeatureAdditional(TileKey const & tileKey, TInsertShapeFn const & insertShape, FeatureType & f,
|
||||
double currentScaleGtoP, CaptionDescription const & captions,
|
||||
std::vector<m2::SharedSpline> && clippedSplines);
|
||||
|
||||
void ProcessAdditionalLineRules(PathTextRuleProto const * pathtextRule, ShieldRuleProto const * shieldRule,
|
||||
@@ -181,17 +180,12 @@ public:
|
||||
GeneratedRoadShields & generatedRoadShields);
|
||||
|
||||
private:
|
||||
void GetRoadShieldsViewParams(ref_ptr<dp::TextureManager> texMng,
|
||||
ftypes::RoadShield const & shield,
|
||||
uint8_t shieldIndex, uint8_t shieldCount,
|
||||
TextViewParams & textParams,
|
||||
ColoredSymbolViewParams & symbolParams,
|
||||
PoiSymbolViewParams & poiParams,
|
||||
void GetRoadShieldsViewParams(ref_ptr<dp::TextureManager> texMng, ftypes::RoadShield const & shield,
|
||||
uint8_t shieldIndex, uint8_t shieldCount, TextViewParams & textParams,
|
||||
ColoredSymbolViewParams & symbolParams, PoiSymbolViewParams & poiParams,
|
||||
m2::PointD & shieldPixelSize);
|
||||
bool CheckShieldsNearby(m2::PointD const & shieldPos,
|
||||
m2::PointD const & shieldPixelSize,
|
||||
uint32_t minDistanceInPixels,
|
||||
std::vector<m2::RectD> & shields);
|
||||
bool CheckShieldsNearby(m2::PointD const & shieldPos, m2::PointD const & shieldPixelSize,
|
||||
uint32_t minDistanceInPixels, std::vector<m2::RectD> & shields);
|
||||
|
||||
std::vector<m2::SharedSpline> m_clippedSplines;
|
||||
double const m_currentScaleGtoP;
|
||||
@@ -201,4 +195,4 @@ private:
|
||||
};
|
||||
|
||||
extern dp::Color ToDrapeColor(uint32_t src);
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -45,9 +45,8 @@ void AreaShape::Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::Batcher>
|
||||
DrawArea(context, batcher, colorUv, outlineUv, region.GetTexture());
|
||||
}
|
||||
|
||||
void AreaShape::DrawArea(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::Batcher> batcher,
|
||||
m2::PointD const & colorUv, m2::PointD const & outlineUv,
|
||||
ref_ptr<dp::Texture> texture) const
|
||||
void AreaShape::DrawArea(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::Batcher> batcher, m2::PointD const & colorUv,
|
||||
m2::PointD const & outlineUv, ref_ptr<dp::Texture> texture) const
|
||||
{
|
||||
glsl::vec2 const uv = glsl::ToVec2(colorUv);
|
||||
|
||||
@@ -120,8 +119,7 @@ void AreaShape::DrawHatchingArea(ref_ptr<dp::GraphicsContext> context, ref_ptr<d
|
||||
}
|
||||
|
||||
void AreaShape::DrawArea3D(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::Batcher> batcher,
|
||||
m2::PointD const & colorUv, m2::PointD const & outlineUv,
|
||||
ref_ptr<dp::Texture> texture) const
|
||||
m2::PointD const & colorUv, m2::PointD const & outlineUv, ref_ptr<dp::Texture> texture) const
|
||||
{
|
||||
CHECK(!m_buildingOutline.m_indices.empty(), ());
|
||||
CHECK_EQUAL(m_buildingOutline.m_normals.size() * 2, m_buildingOutline.m_indices.size(), ());
|
||||
|
||||
@@ -24,8 +24,7 @@ struct BuildingOutline
|
||||
class AreaShape : public MapShape
|
||||
{
|
||||
public:
|
||||
AreaShape(std::vector<m2::PointD> triangleList, BuildingOutline && buildingOutline,
|
||||
AreaViewParams const & params);
|
||||
AreaShape(std::vector<m2::PointD> triangleList, BuildingOutline && buildingOutline, AreaViewParams const & params);
|
||||
|
||||
void Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::Batcher> batcher,
|
||||
ref_ptr<dp::TextureManager> textures) const override;
|
||||
@@ -35,20 +34,14 @@ private:
|
||||
{
|
||||
return glsl::ToVec2(ConvertToLocal(vertex, m_params.m_tileCenter, kShapeCoordScalar));
|
||||
}
|
||||
glsl::vec3 ToShapeVertex3(m2::PointD const & vertex) const
|
||||
{
|
||||
return { ToShapeVertex2(vertex), m_params.m_depth };
|
||||
}
|
||||
glsl::vec3 ToShapeVertex3(m2::PointD const & vertex) const { return {ToShapeVertex2(vertex), m_params.m_depth}; }
|
||||
|
||||
void DrawArea(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::Batcher> batcher,
|
||||
m2::PointD const & colorUv, m2::PointD const & outlineUv,
|
||||
ref_ptr<dp::Texture> texture) const;
|
||||
void DrawArea3D(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::Batcher> batcher,
|
||||
m2::PointD const & colorUv, m2::PointD const & outlineUv,
|
||||
ref_ptr<dp::Texture> texture) const;
|
||||
void DrawHatchingArea(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::Batcher> batcher,
|
||||
m2::PointD const & colorUv, ref_ptr<dp::Texture> texture,
|
||||
ref_ptr<dp::Texture> hatchingTexture) const;
|
||||
void DrawArea(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::Batcher> batcher, m2::PointD const & colorUv,
|
||||
m2::PointD const & outlineUv, ref_ptr<dp::Texture> texture) const;
|
||||
void DrawArea3D(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::Batcher> batcher, m2::PointD const & colorUv,
|
||||
m2::PointD const & outlineUv, ref_ptr<dp::Texture> texture) const;
|
||||
void DrawHatchingArea(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::Batcher> batcher, m2::PointD const & colorUv,
|
||||
ref_ptr<dp::Texture> texture, ref_ptr<dp::Texture> hatchingTexture) const;
|
||||
|
||||
std::vector<m2::PointD> m_vertexes;
|
||||
BuildingOutline m_buildingOutline;
|
||||
|
||||
@@ -52,8 +52,8 @@ std::string const kDefaultArrowShadowMesh = "arrow_shadow.obj";
|
||||
|
||||
std::string_view const kMainFileId = "main_obj_file_id";
|
||||
|
||||
using TLoadingCompletion = std::function<void(
|
||||
std::vector<float> positions, std::vector<float> normals, std::vector<float> texCoords)>;
|
||||
using TLoadingCompletion =
|
||||
std::function<void(std::vector<float> positions, std::vector<float> normals, std::vector<float> texCoords)>;
|
||||
using TLoadingFailure = std::function<void(std::string const &)>;
|
||||
|
||||
namespace fast_obj_adapter
|
||||
@@ -102,10 +102,7 @@ unsigned long FileSize(void * file, void * userData)
|
||||
class FastObjMeshGuard
|
||||
{
|
||||
public:
|
||||
explicit FastObjMeshGuard(fastObjMesh * mesh)
|
||||
: m_mesh(mesh)
|
||||
{
|
||||
}
|
||||
explicit FastObjMeshGuard(fastObjMesh * mesh) : m_mesh(mesh) {}
|
||||
|
||||
~FastObjMeshGuard()
|
||||
{
|
||||
@@ -117,8 +114,8 @@ private:
|
||||
fastObjMesh * const m_mesh;
|
||||
};
|
||||
|
||||
bool LoadMesh(std::string const & pathToMesh, bool isDefaultResource,
|
||||
TLoadingCompletion const & completionHandler, TLoadingFailure const & failureHandler)
|
||||
bool LoadMesh(std::string const & pathToMesh, bool isDefaultResource, TLoadingCompletion const & completionHandler,
|
||||
TLoadingFailure const & failureHandler)
|
||||
{
|
||||
CHECK(completionHandler != nullptr, ());
|
||||
CHECK(failureHandler != nullptr, ());
|
||||
@@ -126,9 +123,8 @@ bool LoadMesh(std::string const & pathToMesh, bool isDefaultResource,
|
||||
fastObjMesh * meshData = nullptr;
|
||||
try
|
||||
{
|
||||
ReaderPtr<Reader> reader = isDefaultResource
|
||||
? GetStyleReader().GetDefaultResourceReader(pathToMesh)
|
||||
: GetPlatform().GetReader(pathToMesh);
|
||||
ReaderPtr<Reader> reader =
|
||||
isDefaultResource ? GetStyleReader().GetDefaultResourceReader(pathToMesh) : GetPlatform().GetReader(pathToMesh);
|
||||
ReaderSource source(reader);
|
||||
|
||||
// Read OBJ file.
|
||||
@@ -158,15 +154,13 @@ bool LoadMesh(std::string const & pathToMesh, bool isDefaultResource,
|
||||
{
|
||||
if (meshData->position_count > 1)
|
||||
{
|
||||
memcpy(&positions[i * kComponentsInVertex],
|
||||
&meshData->positions[meshData->indices[i].p * kComponentsInVertex],
|
||||
memcpy(&positions[i * kComponentsInVertex], &meshData->positions[meshData->indices[i].p * kComponentsInVertex],
|
||||
sizeof(float) * kComponentsInVertex);
|
||||
}
|
||||
|
||||
if (meshData->normal_count > 1)
|
||||
{
|
||||
memcpy(&normals[i * kComponentsInNormal],
|
||||
&meshData->normals[meshData->indices[i].n * kComponentsInNormal],
|
||||
memcpy(&normals[i * kComponentsInNormal], &meshData->normals[meshData->indices[i].n * kComponentsInNormal],
|
||||
sizeof(float) * kComponentsInNormal);
|
||||
}
|
||||
|
||||
@@ -201,44 +195,40 @@ Arrow3d::PreloadedData Arrow3d::PreloadMesh(std::optional<Arrow3dCustomDecl> con
|
||||
// Load arrow mesh.
|
||||
auto const & meshPath = customDecl ? customDecl->m_arrowMeshPath : kDefaultArrowMesh;
|
||||
data.m_meshData = PreloadedMeshData{};
|
||||
if (!LoadMesh(
|
||||
meshPath, useDefaultResource,
|
||||
[&](std::vector<float> positions, std::vector<float> normals,
|
||||
std::vector<float> texCoords)
|
||||
{
|
||||
if (!positions.empty())
|
||||
{
|
||||
if (normals.empty())
|
||||
normals =
|
||||
dp::MeshObject::GenerateNormalsForTriangles(positions, kComponentsInNormal);
|
||||
if (!LoadMesh(meshPath, useDefaultResource,
|
||||
[&](std::vector<float> positions, std::vector<float> normals, std::vector<float> texCoords)
|
||||
{
|
||||
if (!positions.empty())
|
||||
{
|
||||
if (normals.empty())
|
||||
normals = dp::MeshObject::GenerateNormalsForTriangles(positions, kComponentsInNormal);
|
||||
|
||||
data.m_meshData->m_positions = std::move(positions);
|
||||
data.m_meshData->m_normals = std::move(normals);
|
||||
data.m_meshData->m_positions = std::move(positions);
|
||||
data.m_meshData->m_normals = std::move(normals);
|
||||
|
||||
// Texture coordinates.
|
||||
ref_ptr<dp::StaticTexture> arrowTexture = texMng->GetArrowTexture();
|
||||
CHECK(arrowTexture != nullptr, ("Arrow texture must be initialized before the mesh"));
|
||||
// NOTE: texture must be loaded before the mesh.
|
||||
if (arrowTexture->IsLoadingCorrect() && !texCoords.empty())
|
||||
{
|
||||
data.m_arrowMeshTexturingEnabled = true;
|
||||
data.m_meshData->m_texCoords = std::move(texCoords);
|
||||
}
|
||||
else
|
||||
{
|
||||
data.m_arrowMeshTexturingEnabled = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
data.m_meshData.reset();
|
||||
}
|
||||
},
|
||||
[&](std::string const & reason)
|
||||
{
|
||||
data.m_meshData.reset();
|
||||
LOG(LERROR, ("Arrow3D mesh was not loaded:", reason));
|
||||
}))
|
||||
// Texture coordinates.
|
||||
ref_ptr<dp::StaticTexture> arrowTexture = texMng->GetArrowTexture();
|
||||
CHECK(arrowTexture != nullptr, ("Arrow texture must be initialized before the mesh"));
|
||||
// NOTE: texture must be loaded before the mesh.
|
||||
if (arrowTexture->IsLoadingCorrect() && !texCoords.empty())
|
||||
{
|
||||
data.m_arrowMeshTexturingEnabled = true;
|
||||
data.m_meshData->m_texCoords = std::move(texCoords);
|
||||
}
|
||||
else
|
||||
{
|
||||
data.m_arrowMeshTexturingEnabled = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
data.m_meshData.reset();
|
||||
}
|
||||
}, [&](std::string const & reason)
|
||||
{
|
||||
data.m_meshData.reset();
|
||||
LOG(LERROR, ("Arrow3D mesh was not loaded:", reason));
|
||||
}))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
@@ -248,39 +238,34 @@ Arrow3d::PreloadedData Arrow3d::PreloadMesh(std::optional<Arrow3dCustomDecl> con
|
||||
if (!shadowMeshPath.empty())
|
||||
{
|
||||
data.m_shadowMeshData = PreloadedMeshData{};
|
||||
LoadMesh(
|
||||
shadowMeshPath, useDefaultResource,
|
||||
[&](std::vector<float> positions, std::vector<float> /* normals */,
|
||||
std::vector<float> texCoords)
|
||||
{
|
||||
// NOTE: Shadow mesh must contain texture coordinates. They're used to create soft shadow.
|
||||
if (!positions.empty() && !texCoords.empty())
|
||||
{
|
||||
data.m_shadowMeshData->m_positions = std::move(positions);
|
||||
data.m_shadowMeshData->m_texCoords = std::move(texCoords);
|
||||
}
|
||||
else
|
||||
{
|
||||
data.m_shadowMeshData.reset();
|
||||
}
|
||||
},
|
||||
[&](std::string const & reason)
|
||||
{
|
||||
data.m_shadowMeshData.reset();
|
||||
LOG(LWARNING, ("Arrow3D shadow mesh was not loaded:", reason));
|
||||
});
|
||||
LoadMesh(shadowMeshPath, useDefaultResource,
|
||||
[&](std::vector<float> positions, std::vector<float> /* normals */, std::vector<float> texCoords)
|
||||
{
|
||||
// NOTE: Shadow mesh must contain texture coordinates. They're used to create soft shadow.
|
||||
if (!positions.empty() && !texCoords.empty())
|
||||
{
|
||||
data.m_shadowMeshData->m_positions = std::move(positions);
|
||||
data.m_shadowMeshData->m_texCoords = std::move(texCoords);
|
||||
}
|
||||
else
|
||||
{
|
||||
data.m_shadowMeshData.reset();
|
||||
}
|
||||
}, [&](std::string const & reason)
|
||||
{
|
||||
data.m_shadowMeshData.reset();
|
||||
LOG(LWARNING, ("Arrow3D shadow mesh was not loaded:", reason));
|
||||
});
|
||||
}
|
||||
|
||||
if (customDecl.has_value())
|
||||
{
|
||||
data.m_texCoordFlipping = glsl::vec2{customDecl->m_flipTexCoordU ? 1.0f : 0.0f,
|
||||
customDecl->m_flipTexCoordV ? 1.0f : 0.0f};
|
||||
data.m_meshOffset =
|
||||
glsl::vec3{customDecl->m_offset.x, customDecl->m_offset.y, customDecl->m_offset.z};
|
||||
data.m_meshEulerAngles = glsl::vec3{customDecl->m_eulerAngles.x, customDecl->m_eulerAngles.y,
|
||||
customDecl->m_eulerAngles.z};
|
||||
data.m_meshScale =
|
||||
glsl::vec3{customDecl->m_scale.x, customDecl->m_scale.y, customDecl->m_scale.z};
|
||||
data.m_texCoordFlipping =
|
||||
glsl::vec2{customDecl->m_flipTexCoordU ? 1.0f : 0.0f, customDecl->m_flipTexCoordV ? 1.0f : 0.0f};
|
||||
data.m_meshOffset = glsl::vec3{customDecl->m_offset.x, customDecl->m_offset.y, customDecl->m_offset.z};
|
||||
data.m_meshEulerAngles =
|
||||
glsl::vec3{customDecl->m_eulerAngles.x, customDecl->m_eulerAngles.y, customDecl->m_eulerAngles.z};
|
||||
data.m_meshScale = glsl::vec3{customDecl->m_scale.x, customDecl->m_scale.y, customDecl->m_scale.z};
|
||||
data.m_enableShadow = customDecl->m_enableShadow;
|
||||
data.m_enableOutline = customDecl->m_enableOutline;
|
||||
}
|
||||
@@ -334,8 +319,7 @@ Arrow3d::Arrow3d(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::TextureManage
|
||||
|
||||
m_arrowMesh.SetBuffer(kTexCoordBufferInd, std::move(preloadedData.m_meshData->m_texCoords),
|
||||
sizeof(float) * kComponentsInTexCoord);
|
||||
m_arrowMesh.SetAttribute("a_texCoords", kTexCoordBufferInd, 0 /* offset */,
|
||||
kComponentsInTexCoord);
|
||||
m_arrowMesh.SetAttribute("a_texCoords", kTexCoordBufferInd, 0 /* offset */, kComponentsInTexCoord);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,22 +331,22 @@ Arrow3d::Arrow3d(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::TextureManage
|
||||
|
||||
// Positions.
|
||||
CHECK(!preloadedData.m_shadowMeshData->m_positions.empty(), ());
|
||||
m_shadowMesh->SetBuffer(kVerticesBufferInd,
|
||||
std::move(preloadedData.m_shadowMeshData->m_positions),
|
||||
m_shadowMesh->SetBuffer(kVerticesBufferInd, std::move(preloadedData.m_shadowMeshData->m_positions),
|
||||
sizeof(float) * kComponentsInVertex);
|
||||
m_shadowMesh->SetAttribute("a_pos", kVerticesBufferInd, 0 /* offset */, kComponentsInVertex);
|
||||
|
||||
// Texture coordinates.
|
||||
CHECK(!preloadedData.m_shadowMeshData->m_texCoords.empty(), ());
|
||||
m_shadowMesh->SetBuffer(kTexCoordShadowBufferInd,
|
||||
std::move(preloadedData.m_shadowMeshData->m_texCoords),
|
||||
m_shadowMesh->SetBuffer(kTexCoordShadowBufferInd, std::move(preloadedData.m_shadowMeshData->m_texCoords),
|
||||
sizeof(float) * kComponentsInTexCoord);
|
||||
m_shadowMesh->SetAttribute("a_texCoords", kTexCoordShadowBufferInd, 0 /* offset */,
|
||||
kComponentsInTexCoord);
|
||||
m_shadowMesh->SetAttribute("a_texCoords", kTexCoordShadowBufferInd, 0 /* offset */, kComponentsInTexCoord);
|
||||
}
|
||||
}
|
||||
|
||||
bool Arrow3d::IsValid() const { return m_isValid; }
|
||||
bool Arrow3d::IsValid() const
|
||||
{
|
||||
return m_isValid;
|
||||
}
|
||||
|
||||
// static
|
||||
double Arrow3d::GetMaxBottomSize()
|
||||
@@ -371,27 +355,48 @@ double Arrow3d::GetMaxBottomSize()
|
||||
return kBottomSize * arrow3d::kArrowSize * arrow3d::kArrow3dScaleMax * kOutlineScale;
|
||||
}
|
||||
|
||||
void Arrow3d::SetPosition(m2::PointD const & position) { m_position = position; }
|
||||
void Arrow3d::SetPosition(m2::PointD const & position)
|
||||
{
|
||||
m_position = position;
|
||||
}
|
||||
|
||||
void Arrow3d::SetAzimuth(double azimuth)
|
||||
{
|
||||
m_azimuth = azimuth;
|
||||
}
|
||||
|
||||
void Arrow3d::SetPositionObsolete(bool obsolete) { m_obsoletePosition = obsolete; }
|
||||
void Arrow3d::SetPositionObsolete(bool obsolete)
|
||||
{
|
||||
m_obsoletePosition = obsolete;
|
||||
}
|
||||
|
||||
void Arrow3d::SetMeshOffset(glsl::vec3 const & offset) { m_meshOffset = offset; }
|
||||
void Arrow3d::SetMeshOffset(glsl::vec3 const & offset)
|
||||
{
|
||||
m_meshOffset = offset;
|
||||
}
|
||||
|
||||
void Arrow3d::SetMeshRotation(glsl::vec3 const & eulerAngles) { m_meshEulerAngles = eulerAngles; }
|
||||
void Arrow3d::SetMeshRotation(glsl::vec3 const & eulerAngles)
|
||||
{
|
||||
m_meshEulerAngles = eulerAngles;
|
||||
}
|
||||
|
||||
void Arrow3d::SetMeshScale(glsl::vec3 const & scale) { m_meshScale = scale; }
|
||||
void Arrow3d::SetMeshScale(glsl::vec3 const & scale)
|
||||
{
|
||||
m_meshScale = scale;
|
||||
}
|
||||
|
||||
void Arrow3d::SetShadowEnabled(bool enabled) { m_enableShadow = enabled; }
|
||||
void Arrow3d::SetShadowEnabled(bool enabled)
|
||||
{
|
||||
m_enableShadow = enabled;
|
||||
}
|
||||
|
||||
void Arrow3d::SetOutlineEnabled(bool enabled) { m_enableOutline = enabled; }
|
||||
void Arrow3d::SetOutlineEnabled(bool enabled)
|
||||
{
|
||||
m_enableOutline = enabled;
|
||||
}
|
||||
|
||||
void Arrow3d::Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng,
|
||||
ScreenBase const & screen, bool routingMode)
|
||||
void Arrow3d::Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng, ScreenBase const & screen,
|
||||
bool routingMode)
|
||||
{
|
||||
// Render shadow.
|
||||
if (m_shadowMesh && m_enableShadow && screen.isPerspective())
|
||||
@@ -405,38 +410,34 @@ void Arrow3d::Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramM
|
||||
if (m_shadowMesh && m_enableOutline && routingMode)
|
||||
{
|
||||
dp::Color const outlineColor = df::GetColorConstant(df::kArrow3DOutlineColor);
|
||||
RenderArrow(context, mng, *m_shadowMesh, screen, gpu::Program::Arrow3dOutline, outlineColor,
|
||||
0.0f /* dz */, kOutlineScale /* scaleFactor */);
|
||||
RenderArrow(context, mng, *m_shadowMesh, screen, gpu::Program::Arrow3dOutline, outlineColor, 0.0f /* dz */,
|
||||
kOutlineScale /* scaleFactor */);
|
||||
}
|
||||
|
||||
// Render arrow.
|
||||
if (m_arrowMeshTexturingEnabled)
|
||||
{
|
||||
// Use only alpha channel from arrow color for textured meshes.
|
||||
auto const color =
|
||||
dp::Color(255, 255, 255,
|
||||
m_obsoletePosition ? df::GetColorConstant(df::kArrow3DObsoleteColor).GetAlpha()
|
||||
: df::GetColorConstant(df::kArrow3DColor).GetAlpha());
|
||||
auto const color = dp::Color(255, 255, 255,
|
||||
m_obsoletePosition ? df::GetColorConstant(df::kArrow3DObsoleteColor).GetAlpha()
|
||||
: df::GetColorConstant(df::kArrow3DColor).GetAlpha());
|
||||
|
||||
RenderArrow(context, mng, m_arrowMesh, screen, gpu::Program::Arrow3dTextured, color,
|
||||
0.0f /* dz */, 1.0f /* scaleFactor */);
|
||||
RenderArrow(context, mng, m_arrowMesh, screen, gpu::Program::Arrow3dTextured, color, 0.0f /* dz */,
|
||||
1.0f /* scaleFactor */);
|
||||
}
|
||||
else
|
||||
{
|
||||
dp::Color const color =
|
||||
df::GetColorConstant(m_obsoletePosition ? df::kArrow3DObsoleteColor : df::kArrow3DColor);
|
||||
RenderArrow(context, mng, m_arrowMesh, screen, gpu::Program::Arrow3d, color, 0.0f /* dz */,
|
||||
1.0f /* scaleFactor */);
|
||||
dp::Color const color = df::GetColorConstant(m_obsoletePosition ? df::kArrow3DObsoleteColor : df::kArrow3DColor);
|
||||
RenderArrow(context, mng, m_arrowMesh, screen, gpu::Program::Arrow3d, color, 0.0f /* dz */, 1.0f /* scaleFactor */);
|
||||
}
|
||||
}
|
||||
|
||||
void Arrow3d::RenderArrow(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng,
|
||||
dp::MeshObject & mesh, ScreenBase const & screen, gpu::Program program,
|
||||
dp::Color const & color, float dz, float scaleFactor)
|
||||
void Arrow3d::RenderArrow(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng, dp::MeshObject & mesh,
|
||||
ScreenBase const & screen, gpu::Program program, dp::Color const & color, float dz,
|
||||
float scaleFactor)
|
||||
{
|
||||
gpu::Arrow3dProgramParams params;
|
||||
auto [transform, normalTransform] =
|
||||
CalculateTransform(screen, dz, scaleFactor, context->GetApiVersion());
|
||||
auto [transform, normalTransform] = CalculateTransform(screen, dz, scaleFactor, context->GetApiVersion());
|
||||
params.m_transform = std::move(transform);
|
||||
params.m_normalTransform = std::move(normalTransform);
|
||||
params.m_color = glsl::ToVec4(color);
|
||||
@@ -446,8 +447,7 @@ void Arrow3d::RenderArrow(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::Pro
|
||||
mesh.Render(context, gpuProgram, m_state, mng->GetParamsSetter(), params);
|
||||
}
|
||||
|
||||
std::pair<glsl::mat4, glsl::mat4> Arrow3d::CalculateTransform(ScreenBase const & screen, float dz,
|
||||
float scaleFactor,
|
||||
std::pair<glsl::mat4, glsl::mat4> Arrow3d::CalculateTransform(ScreenBase const & screen, float dz, float scaleFactor,
|
||||
dp::ApiVersion apiVersion) const
|
||||
{
|
||||
double arrowScale = VisualParams::Instance().GetVisualScale() * arrow3d::kArrowSize * scaleFactor;
|
||||
@@ -459,36 +459,30 @@ std::pair<glsl::mat4, glsl::mat4> Arrow3d::CalculateTransform(ScreenBase const &
|
||||
|
||||
glm::quat const qx = glm::angleAxis(m_meshEulerAngles.x, glm::vec3{1.0f, 0.0f, 0.0f});
|
||||
glm::quat const qy = glm::angleAxis(m_meshEulerAngles.y, glm::vec3{0.0f, 1.0f, 0.0f});
|
||||
glm::quat qz =
|
||||
glm::angleAxis(static_cast<float>(m_azimuth + screen.GetAngle() + m_meshEulerAngles.z),
|
||||
glm::vec3{0.0f, 0.0f, -1.0f});
|
||||
glm::quat qz = glm::angleAxis(static_cast<float>(m_azimuth + screen.GetAngle() + m_meshEulerAngles.z),
|
||||
glm::vec3{0.0f, 0.0f, -1.0f});
|
||||
auto const rotationMatrix = glm::mat4_cast(qz * qy * qx);
|
||||
|
||||
qz = glm::angleAxis(static_cast<float>(m_meshEulerAngles.z), glm::vec3{0.0f, 0.0f, -1.0f});
|
||||
auto const normalMatrix = glm::mat4_cast(qz * qy * qx);
|
||||
|
||||
auto const scaleMatrix = glm::scale(
|
||||
glm::mat4(1.0f),
|
||||
glm::vec3{arrowScale, arrowScale, screen.isPerspective() ? arrowScale : 1.0} * m_meshScale);
|
||||
glm::mat4(1.0f), glm::vec3{arrowScale, arrowScale, screen.isPerspective() ? arrowScale : 1.0} * m_meshScale);
|
||||
|
||||
auto const translationMatrix = glm::translate(glm::mat4(1.0f), m_meshOffset);
|
||||
|
||||
auto postProjectionScale =
|
||||
glm::vec3{2.0f / screen.PixelRect().SizeX(), 2.0f / screen.PixelRect().SizeY(), 1.0f};
|
||||
auto postProjectionScale = glm::vec3{2.0f / screen.PixelRect().SizeX(), 2.0f / screen.PixelRect().SizeY(), 1.0f};
|
||||
postProjectionScale.z =
|
||||
screen.isPerspective()
|
||||
? std::min(postProjectionScale.x, postProjectionScale.y) * screen.GetScale3d()
|
||||
: 0.1f;
|
||||
screen.isPerspective() ? std::min(postProjectionScale.x, postProjectionScale.y) * screen.GetScale3d() : 0.1f;
|
||||
auto const postProjectionScaleMatrix = glm::scale(glm::mat4(1.0f), postProjectionScale);
|
||||
|
||||
m2::PointD const pos = screen.GtoP(m_position);
|
||||
auto const dX = static_cast<float>(2.0 * pos.x / screen.PixelRect().SizeX() - 1.0);
|
||||
auto const dY = static_cast<float>(2.0 * pos.y / screen.PixelRect().SizeY() - 1.0);
|
||||
auto const postProjectionTranslationMatrix =
|
||||
glm::translate(glm::mat4(1.0f), glm::vec3{dX, -dY, dz});
|
||||
auto const postProjectionTranslationMatrix = glm::translate(glm::mat4(1.0f), glm::vec3{dX, -dY, dz});
|
||||
|
||||
auto modelTransform = postProjectionTranslationMatrix * postProjectionScaleMatrix * scaleMatrix *
|
||||
translationMatrix * rotationMatrix;
|
||||
auto modelTransform =
|
||||
postProjectionTranslationMatrix * postProjectionScaleMatrix * scaleMatrix * translationMatrix * rotationMatrix;
|
||||
|
||||
if (screen.isPerspective())
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace df
|
||||
class Arrow3d
|
||||
{
|
||||
using Base = dp::MeshObject;
|
||||
|
||||
public:
|
||||
struct PreloadedMeshData
|
||||
{
|
||||
@@ -57,8 +58,7 @@ public:
|
||||
static PreloadedData PreloadMesh(std::optional<Arrow3dCustomDecl> const & customDecl,
|
||||
ref_ptr<dp::TextureManager> texMng);
|
||||
|
||||
Arrow3d(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::TextureManager> texMng,
|
||||
PreloadedData && preloadedData);
|
||||
Arrow3d(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::TextureManager> texMng, PreloadedData && preloadedData);
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
@@ -78,17 +78,16 @@ public:
|
||||
void SetShadowEnabled(bool enabled);
|
||||
void SetOutlineEnabled(bool enabled);
|
||||
|
||||
void Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng,
|
||||
ScreenBase const & screen, bool routingMode);
|
||||
void Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng, ScreenBase const & screen,
|
||||
bool routingMode);
|
||||
|
||||
private:
|
||||
// Returns transform matrix and normal transform matrix.
|
||||
std::pair<glsl::mat4, glsl::mat4> CalculateTransform(ScreenBase const & screen, float dz,
|
||||
float scaleFactor,
|
||||
std::pair<glsl::mat4, glsl::mat4> CalculateTransform(ScreenBase const & screen, float dz, float scaleFactor,
|
||||
dp::ApiVersion apiVersion) const;
|
||||
void RenderArrow(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng,
|
||||
dp::MeshObject & mesh, ScreenBase const & screen, gpu::Program program,
|
||||
dp::Color const & color, float dz, float scaleFactor);
|
||||
void RenderArrow(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng, dp::MeshObject & mesh,
|
||||
ScreenBase const & screen, gpu::Program program, dp::Color const & color, float dz,
|
||||
float scaleFactor);
|
||||
|
||||
dp::MeshObject m_arrowMesh;
|
||||
bool const m_arrowMeshTexturingEnabled;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -35,16 +35,15 @@ class MetalineManager;
|
||||
class BackendRenderer : public BaseRenderer
|
||||
{
|
||||
public:
|
||||
using TUpdateCurrentCountryFn = std::function<void (m2::PointD const &, int)>;
|
||||
using TUpdateCurrentCountryFn = std::function<void(m2::PointD const &, int)>;
|
||||
|
||||
struct Params : BaseRenderer::Params
|
||||
{
|
||||
Params(dp::ApiVersion apiVersion, ref_ptr<ThreadsCommutator> commutator,
|
||||
ref_ptr<dp::GraphicsContextFactory> factory, ref_ptr<dp::TextureManager> texMng,
|
||||
MapDataProvider const & model, TUpdateCurrentCountryFn const & updateCurrentCountryFn,
|
||||
ref_ptr<RequestedTiles> requestedTiles, bool allow3dBuildings, bool trafficEnabled,
|
||||
bool isolinesEnabled, bool simplifiedTrafficColors,
|
||||
std::optional<Arrow3dCustomDecl> arrow3dCustomDecl,
|
||||
ref_ptr<RequestedTiles> requestedTiles, bool allow3dBuildings, bool trafficEnabled, bool isolinesEnabled,
|
||||
bool simplifiedTrafficColors, std::optional<Arrow3dCustomDecl> arrow3dCustomDecl,
|
||||
OnGraphicsContextInitialized const & onGraphicsContextInitialized)
|
||||
: BaseRenderer::Params(apiVersion, commutator, factory, texMng, onGraphicsContextInitialized)
|
||||
, m_model(model)
|
||||
@@ -74,7 +73,7 @@ public:
|
||||
|
||||
protected:
|
||||
std::unique_ptr<threads::IRoutine> CreateRoutine() override;
|
||||
|
||||
|
||||
void RenderFrame() override;
|
||||
|
||||
void OnContextCreate() override;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace dp
|
||||
{
|
||||
extern void RenderFrameMediator(std::function<void()> && renderFrameFunction);
|
||||
} // namespace dp
|
||||
#define RENDER_FRAME_MEDIATOR(renderFunction) dp::RenderFrameMediator([this]{ renderFunction; })
|
||||
#define RENDER_FRAME_MEDIATOR(renderFunction) dp::RenderFrameMediator([this] { renderFunction; })
|
||||
#else
|
||||
#define RENDER_FRAME_MEDIATOR(renderFunction) renderFunction
|
||||
#endif
|
||||
@@ -46,19 +46,17 @@ void BaseRenderer::StopThread()
|
||||
|
||||
// wake up render thread if necessary
|
||||
if (!m_isEnabled)
|
||||
{
|
||||
WakeUp();
|
||||
}
|
||||
|
||||
// wait for render thread completion
|
||||
m_selfThread.Join();
|
||||
}
|
||||
|
||||
|
||||
void BaseRenderer::IterateRenderLoop()
|
||||
{
|
||||
RENDER_FRAME_MEDIATOR(IterateRenderLoopImpl());
|
||||
}
|
||||
|
||||
|
||||
void BaseRenderer::IterateRenderLoopImpl()
|
||||
{
|
||||
RenderFrame();
|
||||
@@ -155,8 +153,7 @@ void BaseRenderer::CheckRenderingEnabled()
|
||||
else
|
||||
{
|
||||
bool const isDrawContext = m_threadName == ThreadsCommutator::RenderThread;
|
||||
context = isDrawContext ? m_contextFactory->GetDrawContext() :
|
||||
m_contextFactory->GetResourcesUploadContext();
|
||||
context = isDrawContext ? m_contextFactory->GetDrawContext() : m_contextFactory->GetResourcesUploadContext();
|
||||
context->SetRenderingEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
BaseRenderer(ThreadsCommutator::ThreadName name, Params const & params);
|
||||
|
||||
bool CanReceiveMessages();
|
||||
|
||||
|
||||
void IterateRenderLoop();
|
||||
|
||||
void SetRenderingEnabled(ref_ptr<dp::GraphicsContextFactory> contextFactory);
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
|
||||
bool IsRenderingEnabled() const;
|
||||
|
||||
dp::ApiVersion GetApiVersion() const { return m_apiVersion; };
|
||||
dp::ApiVersion GetApiVersion() const { return m_apiVersion; }
|
||||
|
||||
protected:
|
||||
dp::ApiVersion m_apiVersion;
|
||||
@@ -67,9 +67,9 @@ protected:
|
||||
void CreateContext();
|
||||
|
||||
void CheckRenderingEnabled();
|
||||
|
||||
|
||||
virtual std::unique_ptr<threads::IRoutine> CreateRoutine() = 0;
|
||||
|
||||
|
||||
virtual void RenderFrame() = 0;
|
||||
|
||||
virtual void OnContextCreate() = 0;
|
||||
@@ -80,7 +80,7 @@ protected:
|
||||
|
||||
private:
|
||||
using TCompletionHandler = std::function<void()>;
|
||||
|
||||
|
||||
void IterateRenderLoopImpl();
|
||||
|
||||
threads::Thread m_selfThread;
|
||||
|
||||
@@ -16,11 +16,10 @@ template <typename TKey, typename TKeyComparator>
|
||||
class BatchersPool final
|
||||
{
|
||||
public:
|
||||
using TFlushFn = std::function<void (TKey const & key, dp::RenderState const & state,
|
||||
drape_ptr<dp::RenderBucket> && buffer)>;
|
||||
using TFlushFn =
|
||||
std::function<void(TKey const & key, dp::RenderState const & state, drape_ptr<dp::RenderBucket> && buffer)>;
|
||||
|
||||
BatchersPool(int initBatchersCount, TFlushFn const & flushFn,
|
||||
uint32_t indexBufferSize, uint32_t vertexBufferSize)
|
||||
BatchersPool(int initBatchersCount, TFlushFn const & flushFn, uint32_t indexBufferSize, uint32_t vertexBufferSize)
|
||||
: m_flushFn(flushFn)
|
||||
, m_pool(initBatchersCount, dp::BatcherFactory(indexBufferSize, vertexBufferSize))
|
||||
{}
|
||||
@@ -63,7 +62,7 @@ public:
|
||||
auto it = m_batchers.find(key);
|
||||
ASSERT(it != m_batchers.end(), ());
|
||||
ASSERT_GREATER(it->second.second, 0, ());
|
||||
if ((--it->second.second)== 0)
|
||||
if ((--it->second.second) == 0)
|
||||
{
|
||||
dp::Batcher * batcher = it->second.first;
|
||||
batcher->EndSession(context);
|
||||
|
||||
@@ -78,8 +78,7 @@ void CirclesPackHandle::GetAttributeMutation(ref_ptr<dp::AttributeBufferMutator>
|
||||
ASSERT_EQUAL(node.first.GetElementSize(), sizeof(CirclesPackDynamicVertex), ());
|
||||
ASSERT_EQUAL(node.second.m_count, m_buffer.size(), ());
|
||||
|
||||
uint32_t const bytesCount =
|
||||
static_cast<uint32_t>(m_buffer.size()) * sizeof(CirclesPackDynamicVertex);
|
||||
uint32_t const bytesCount = static_cast<uint32_t>(m_buffer.size()) * sizeof(CirclesPackDynamicVertex);
|
||||
void * buffer = mutator->AllocateMutationBuffer(bytesCount);
|
||||
memcpy(buffer, m_buffer.data(), bytesCount);
|
||||
|
||||
@@ -97,7 +96,10 @@ bool CirclesPackHandle::Update(ScreenBase const & screen)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CirclesPackHandle::IndexesRequired() const { return false; }
|
||||
bool CirclesPackHandle::IndexesRequired() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m2::RectD CirclesPackHandle::GetPixelRect(ScreenBase const & screen, bool perspective) const
|
||||
{
|
||||
@@ -106,15 +108,13 @@ m2::RectD CirclesPackHandle::GetPixelRect(ScreenBase const & screen, bool perspe
|
||||
return m2::RectD();
|
||||
}
|
||||
|
||||
void CirclesPackHandle::GetPixelShape(ScreenBase const & screen, bool perspective,
|
||||
Rects & rects) const
|
||||
void CirclesPackHandle::GetPixelShape(ScreenBase const & screen, bool perspective, Rects & rects) const
|
||||
{
|
||||
UNUSED_VALUE(screen);
|
||||
UNUSED_VALUE(perspective);
|
||||
}
|
||||
|
||||
void CirclesPackHandle::SetPoint(size_t index, m2::PointD const & position, float radius,
|
||||
dp::Color const & color)
|
||||
void CirclesPackHandle::SetPoint(size_t index, m2::PointD const & position, float radius, dp::Color const & color)
|
||||
{
|
||||
size_t const bufferIndex = index * dp::Batcher::VertexPerQuad;
|
||||
ASSERT_LESS_OR_EQUAL(bufferIndex + dp::Batcher::VertexPerQuad, m_buffer.size(), ());
|
||||
@@ -161,8 +161,7 @@ void CirclesPackShape::Draw(ref_ptr<dp::GraphicsContext> context, CirclesPackRen
|
||||
|
||||
dp::Batcher batcher(data.m_pointsCount * kIndicesInPoint, data.m_pointsCount * kVerticesInPoint);
|
||||
batcher.SetBatcherHash(static_cast<uint64_t>(BatcherBucket::Overlay));
|
||||
dp::SessionGuard guard(context, batcher,
|
||||
[&data](dp::RenderState const & state, drape_ptr<dp::RenderBucket> && b)
|
||||
dp::SessionGuard guard(context, batcher, [&data](dp::RenderState const & state, drape_ptr<dp::RenderBucket> && b)
|
||||
{
|
||||
data.m_bucket = std::move(b);
|
||||
data.m_state = state;
|
||||
@@ -170,14 +169,10 @@ void CirclesPackShape::Draw(ref_ptr<dp::GraphicsContext> context, CirclesPackRen
|
||||
|
||||
drape_ptr<dp::OverlayHandle> handle = make_unique_dp<CirclesPackHandle>(data.m_pointsCount);
|
||||
|
||||
dp::AttributeProvider provider(2 /* stream count */,
|
||||
static_cast<uint32_t>(staticVertexData.size()));
|
||||
provider.InitStream(0 /* stream index */, GetCirclesPackStaticBindingInfo(),
|
||||
make_ref(staticVertexData.data()));
|
||||
provider.InitStream(1 /* stream index */, GetCirclesPackDynamicBindingInfo(),
|
||||
make_ref(dynamicVertexData.data()));
|
||||
batcher.InsertListOfStrip(context, GetCirclesPackState(), make_ref(&provider),
|
||||
std::move(handle), kVerticesInPoint);
|
||||
dp::AttributeProvider provider(2 /* stream count */, static_cast<uint32_t>(staticVertexData.size()));
|
||||
provider.InitStream(0 /* stream index */, GetCirclesPackStaticBindingInfo(), make_ref(staticVertexData.data()));
|
||||
provider.InitStream(1 /* stream index */, GetCirclesPackDynamicBindingInfo(), make_ref(dynamicVertexData.data()));
|
||||
batcher.InsertListOfStrip(context, GetCirclesPackState(), make_ref(&provider), std::move(handle), kVerticesInPoint);
|
||||
|
||||
context->Flush();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "drape_frontend/map_shape.hpp"
|
||||
#include "drape_frontend/shape_view_params.hpp"
|
||||
#include "drape_frontend/render_state_extension.hpp"
|
||||
#include "drape_frontend/shape_view_params.hpp"
|
||||
|
||||
#include "drape/overlay_handle.hpp"
|
||||
#include "drape/pointers.hpp"
|
||||
@@ -37,9 +37,7 @@ struct CirclesPackDynamicVertex
|
||||
using TColor = glsl::vec4;
|
||||
|
||||
CirclesPackDynamicVertex() = default;
|
||||
CirclesPackDynamicVertex(TPosition const & pos, TColor const & color)
|
||||
: m_position(pos), m_color(color)
|
||||
{}
|
||||
CirclesPackDynamicVertex(TPosition const & pos, TColor const & color) : m_position(pos), m_color(color) {}
|
||||
|
||||
TPosition m_position;
|
||||
TColor m_color;
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
if (colors == nullptr)
|
||||
return;
|
||||
|
||||
const char * name = nullptr;
|
||||
char const * name = nullptr;
|
||||
json_t * colorInfo = nullptr;
|
||||
json_object_foreach(colors, name, colorInfo)
|
||||
{
|
||||
@@ -128,7 +128,10 @@ dp::Color GetColorConstant(ColorConstant const & constant)
|
||||
return ToDrapeColor(color);
|
||||
}
|
||||
|
||||
std::map<std::string, dp::Color> const & GetTransitClearColors() { return TransitColors().GetClearColors(); }
|
||||
std::map<std::string, dp::Color> const & GetTransitClearColors()
|
||||
{
|
||||
return TransitColors().GetClearColors();
|
||||
}
|
||||
|
||||
void LoadTransitColors()
|
||||
{
|
||||
|
||||
@@ -19,4 +19,4 @@ void LoadTransitColors();
|
||||
|
||||
ColorConstant GetTransitColorName(ColorConstant const & localName);
|
||||
ColorConstant GetTransitTextColorName(ColorConstant const & localName);
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -46,10 +46,9 @@ class DynamicSquareHandle : public dp::SquareHandle
|
||||
|
||||
public:
|
||||
DynamicSquareHandle(dp::OverlayID const & id, dp::Anchor anchor, m2::PointD const & gbPivot,
|
||||
std::vector<m2::PointF> const & pxSizes, m2::PointD const & pxOffset,
|
||||
uint64_t priority, bool isBound, int minVisibleScale, bool isBillboard)
|
||||
: TBase(id, anchor, gbPivot, m2::PointD::Zero(), pxOffset, priority, isBound, minVisibleScale,
|
||||
isBillboard)
|
||||
std::vector<m2::PointF> const & pxSizes, m2::PointD const & pxOffset, uint64_t priority,
|
||||
bool isBound, int minVisibleScale, bool isBillboard)
|
||||
: TBase(id, anchor, gbPivot, m2::PointD::Zero(), pxOffset, priority, isBound, minVisibleScale, isBillboard)
|
||||
, m_pxSizes(pxSizes)
|
||||
{
|
||||
ASSERT_GREATER(pxSizes.size(), 0, ());
|
||||
@@ -80,8 +79,7 @@ ColoredSymbolShape::ColoredSymbolShape(m2::PointD const & mercatorPt, ColoredSym
|
||||
, m_needOverlay(needOverlay)
|
||||
{}
|
||||
|
||||
ColoredSymbolShape::ColoredSymbolShape(m2::PointD const & mercatorPt,
|
||||
ColoredSymbolViewParams const & params,
|
||||
ColoredSymbolShape::ColoredSymbolShape(m2::PointD const & mercatorPt, ColoredSymbolViewParams const & params,
|
||||
TileKey const & tileKey, uint32_t textIndex,
|
||||
std::vector<m2::PointF> const & overlaySizes)
|
||||
: m_point(mercatorPt)
|
||||
@@ -107,16 +105,12 @@ void ColoredSymbolShape::Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::
|
||||
V::TTexCoord const uv(colorUv.x, colorUv.y, 0.0f, 0.0f);
|
||||
V::TTexCoord const uvOutline(outlineUv.x, outlineUv.y, 0.0f, 0.0f);
|
||||
|
||||
glsl::vec2 const pt = glsl::ToVec2(ConvertToLocal(m_point, m_params.m_tileCenter,
|
||||
kShapeCoordScalar));
|
||||
glsl::vec2 const pt = glsl::ToVec2(ConvertToLocal(m_point, m_params.m_tileCenter, kShapeCoordScalar));
|
||||
glsl::vec3 const position = glsl::vec3(pt, m_params.m_depth);
|
||||
|
||||
buffer_vector<V, 48> buffer;
|
||||
|
||||
auto norm = [this](float x, float y)
|
||||
{
|
||||
return ShiftNormal(glsl::vec2(x, y), m_params);
|
||||
};
|
||||
auto norm = [this](float x, float y) { return ShiftNormal(glsl::vec2(x, y), m_params); };
|
||||
|
||||
m2::PointU pixelSize;
|
||||
if (m_params.m_shape == ColoredSymbolViewParams::Shape::Circle)
|
||||
@@ -143,8 +137,8 @@ void ColoredSymbolShape::Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::
|
||||
}
|
||||
else if (m_params.m_shape == ColoredSymbolViewParams::Shape::Rectangle)
|
||||
{
|
||||
pixelSize = m2::PointU(static_cast<uint32_t>(m_params.m_sizeInPixels.x),
|
||||
static_cast<uint32_t>(m_params.m_sizeInPixels.y));
|
||||
pixelSize =
|
||||
m2::PointU(static_cast<uint32_t>(m_params.m_sizeInPixels.x), static_cast<uint32_t>(m_params.m_sizeInPixels.y));
|
||||
float const halfWidth = 0.5f * m_params.m_sizeInPixels.x;
|
||||
float const halfHeight = 0.5f * m_params.m_sizeInPixels.y;
|
||||
float const v = halfWidth * halfWidth + halfHeight * halfHeight;
|
||||
@@ -170,8 +164,8 @@ void ColoredSymbolShape::Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::
|
||||
}
|
||||
else if (m_params.m_shape == ColoredSymbolViewParams::Shape::RoundedRectangle)
|
||||
{
|
||||
pixelSize = m2::PointU(static_cast<uint32_t>(m_params.m_sizeInPixels.x),
|
||||
static_cast<uint32_t>(m_params.m_sizeInPixels.y));
|
||||
pixelSize =
|
||||
m2::PointU(static_cast<uint32_t>(m_params.m_sizeInPixels.x), static_cast<uint32_t>(m_params.m_sizeInPixels.y));
|
||||
float const halfWidth = 0.5f * m_params.m_sizeInPixels.x;
|
||||
float const halfHeight = 0.5f * m_params.m_sizeInPixels.y;
|
||||
float const halfWidthBody = halfWidth - m_params.m_radiusInPixels;
|
||||
@@ -279,16 +273,14 @@ void ColoredSymbolShape::Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::
|
||||
if (!m_overlaySizes.empty())
|
||||
{
|
||||
handle = make_unique_dp<DynamicSquareHandle>(
|
||||
overlayId, m_params.m_anchor, m_point, m_overlaySizes, m2::PointD(m_params.m_offset),
|
||||
GetOverlayPriority(), true /* isBound */, m_params.m_minVisibleScale,
|
||||
true /* isBillboard */);
|
||||
overlayId, m_params.m_anchor, m_point, m_overlaySizes, m2::PointD(m_params.m_offset), GetOverlayPriority(),
|
||||
true /* isBound */, m_params.m_minVisibleScale, true /* isBillboard */);
|
||||
}
|
||||
else
|
||||
{
|
||||
handle = make_unique_dp<dp::SquareHandle>(
|
||||
overlayId, m_params.m_anchor, m_point, m2::PointD(pixelSize),
|
||||
m2::PointD(m_params.m_offset), GetOverlayPriority(), true /* isBound */,
|
||||
m_params.m_minVisibleScale, true /* isBillboard */);
|
||||
handle = make_unique_dp<dp::SquareHandle>(overlayId, m_params.m_anchor, m_point, m2::PointD(pixelSize),
|
||||
m2::PointD(m_params.m_offset), GetOverlayPriority(), true /* isBound */,
|
||||
m_params.m_minVisibleScale, true /* isBillboard */);
|
||||
}
|
||||
|
||||
if (m_params.m_specialDisplacement == SpecialDisplacement::UserMark ||
|
||||
|
||||
@@ -10,11 +10,11 @@ namespace df
|
||||
class ColoredSymbolShape : public MapShape
|
||||
{
|
||||
public:
|
||||
ColoredSymbolShape(m2::PointD const & mercatorPt, ColoredSymbolViewParams const & params,
|
||||
TileKey const & tileKey, uint32_t textIndex, bool needOverlay = true);
|
||||
ColoredSymbolShape(m2::PointD const & mercatorPt, ColoredSymbolViewParams const & params, TileKey const & tileKey,
|
||||
uint32_t textIndex, bool needOverlay = true);
|
||||
|
||||
ColoredSymbolShape(m2::PointD const & mercatorPt, ColoredSymbolViewParams const & params,
|
||||
TileKey const & tileKey, uint32_t textIndex, std::vector<m2::PointF> const & overlaySizes);
|
||||
ColoredSymbolShape(m2::PointD const & mercatorPt, ColoredSymbolViewParams const & params, TileKey const & tileKey,
|
||||
uint32_t textIndex, std::vector<m2::PointF> const & overlaySizes);
|
||||
|
||||
void Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::Batcher> batcher,
|
||||
ref_ptr<dp::TextureManager> textures) const override;
|
||||
|
||||
@@ -14,9 +14,7 @@ struct CustomFeaturesContext
|
||||
{
|
||||
CustomFeatures const m_features;
|
||||
|
||||
explicit CustomFeaturesContext(CustomFeatures && features)
|
||||
: m_features(std::move(features))
|
||||
{}
|
||||
explicit CustomFeaturesContext(CustomFeatures && features) : m_features(std::move(features)) {}
|
||||
|
||||
bool NeedDiscardGeometry(FeatureID const & id) const
|
||||
{
|
||||
@@ -29,4 +27,4 @@ struct CustomFeaturesContext
|
||||
|
||||
using CustomFeaturesContextPtr = std::shared_ptr<CustomFeaturesContext>;
|
||||
using CustomFeaturesContextWeakPtr = std::weak_ptr<CustomFeaturesContext>;
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -75,8 +75,7 @@ void DebugRectRenderer::SetArrow(ref_ptr<dp::GraphicsContext> context, m2::Point
|
||||
m_arrowMeshes[m_currentArrowMesh]->UpdateBuffer(context, 0 /* bufferInd */, vertices);
|
||||
}
|
||||
|
||||
void DebugRectRenderer::SetRect(ref_ptr<dp::GraphicsContext> context, m2::RectF const & rect,
|
||||
ScreenBase const & screen)
|
||||
void DebugRectRenderer::SetRect(ref_ptr<dp::GraphicsContext> context, m2::RectF const & rect, ScreenBase const & screen)
|
||||
{
|
||||
std::vector<float> vertices;
|
||||
PixelPointToScreenSpace(screen, rect.LeftBottom(), vertices);
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace df
|
||||
class DebugRectRenderer : public dp::DebugRenderer
|
||||
{
|
||||
using Base = dp::MeshObject;
|
||||
|
||||
public:
|
||||
DebugRectRenderer(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program,
|
||||
ref_ptr<gpu::ProgramParamsSetter> paramsSetter);
|
||||
@@ -24,18 +25,17 @@ public:
|
||||
void SetEnabled(bool enabled);
|
||||
|
||||
bool IsEnabled() const override;
|
||||
void DrawRect(ref_ptr<dp::GraphicsContext> context, ScreenBase const & screen,
|
||||
m2::RectF const & rect, dp::Color const & color) override;
|
||||
void DrawRect(ref_ptr<dp::GraphicsContext> context, ScreenBase const & screen, m2::RectF const & rect,
|
||||
dp::Color const & color) override;
|
||||
void DrawArrow(ref_ptr<dp::GraphicsContext> context, ScreenBase const & screen,
|
||||
dp::OverlayTree::DisplacementData const & data) override;
|
||||
|
||||
void FinishRendering();
|
||||
|
||||
private:
|
||||
void SetArrow(ref_ptr<dp::GraphicsContext> context, m2::PointF const & arrowStart,
|
||||
m2::PointF const & arrowEnd, ScreenBase const & screen);
|
||||
void SetRect(ref_ptr<dp::GraphicsContext> context, m2::RectF const & rect,
|
||||
ScreenBase const & screen);
|
||||
void SetArrow(ref_ptr<dp::GraphicsContext> context, m2::PointF const & arrowStart, m2::PointF const & arrowEnd,
|
||||
ScreenBase const & screen);
|
||||
void SetRect(ref_ptr<dp::GraphicsContext> context, m2::RectF const & rect, ScreenBase const & screen);
|
||||
|
||||
std::vector<drape_ptr<dp::MeshObject>> m_rectMeshes;
|
||||
std::vector<drape_ptr<dp::MeshObject>> m_arrowMeshes;
|
||||
@@ -48,4 +48,3 @@ private:
|
||||
bool m_isEnabled = false;
|
||||
};
|
||||
} // namespace df
|
||||
|
||||
|
||||
@@ -19,8 +19,7 @@ void DrapeApi::AddLine(std::string const & id, DrapeApiLineData const & data)
|
||||
auto const it = m_lines.find(id);
|
||||
if (it != m_lines.end())
|
||||
{
|
||||
threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<DrapeApiRemoveMessage>(id),
|
||||
threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, make_unique_dp<DrapeApiRemoveMessage>(id),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
@@ -28,8 +27,7 @@ void DrapeApi::AddLine(std::string const & id, DrapeApiLineData const & data)
|
||||
|
||||
TLines lines;
|
||||
lines.insert(std::make_pair(id, data));
|
||||
threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<DrapeApiAddLinesMessage>(lines),
|
||||
threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, make_unique_dp<DrapeApiAddLinesMessage>(lines),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
@@ -41,8 +39,7 @@ void DrapeApi::RemoveLine(std::string const & id)
|
||||
|
||||
auto & threadCommutator = lock.Get()->m_threadCommutator;
|
||||
m_lines.erase(id);
|
||||
threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<DrapeApiRemoveMessage>(id),
|
||||
threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, make_unique_dp<DrapeApiRemoveMessage>(id),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
@@ -71,7 +68,6 @@ void DrapeApi::Invalidate()
|
||||
MessagePriority::Normal);
|
||||
|
||||
threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<DrapeApiAddLinesMessage>(m_lines),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<DrapeApiAddLinesMessage>(m_lines), MessagePriority::Normal);
|
||||
}
|
||||
} // namespace df
|
||||
|
||||
@@ -18,10 +18,7 @@ struct DrapeApiLineData
|
||||
{
|
||||
DrapeApiLineData() = default;
|
||||
|
||||
DrapeApiLineData(std::vector<m2::PointD> const & points,
|
||||
dp::Color const & color)
|
||||
: m_points(points)
|
||||
, m_color(color)
|
||||
DrapeApiLineData(std::vector<m2::PointD> const & points, dp::Color const & color) : m_points(points), m_color(color)
|
||||
{}
|
||||
|
||||
DrapeApiLineData & ShowPoints(bool markPoints)
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
void BuildText(ref_ptr<dp::GraphicsContext> context, std::string const & str,
|
||||
dp::FontDecl const & font, m2::PointD const & position, m2::PointD const & center,
|
||||
ref_ptr<dp::TextureManager> textures, dp::Batcher & batcher)
|
||||
void BuildText(ref_ptr<dp::GraphicsContext> context, std::string const & str, dp::FontDecl const & font,
|
||||
m2::PointD const & position, m2::PointD const & center, ref_ptr<dp::TextureManager> textures,
|
||||
dp::Batcher & batcher)
|
||||
{
|
||||
gui::StaticLabel::LabelResult result;
|
||||
gui::StaticLabel::CacheStaticText(str, "\n", dp::LeftTop, font, textures, result);
|
||||
@@ -33,8 +33,8 @@ void BuildText(ref_ptr<dp::GraphicsContext> context, std::string const & str,
|
||||
|
||||
namespace df
|
||||
{
|
||||
void DrapeApiBuilder::BuildLines(ref_ptr<dp::GraphicsContext> context,
|
||||
DrapeApi::TLines & lines, ref_ptr<dp::TextureManager> textures,
|
||||
void DrapeApiBuilder::BuildLines(ref_ptr<dp::GraphicsContext> context, DrapeApi::TLines & lines,
|
||||
ref_ptr<dp::TextureManager> textures,
|
||||
std::vector<drape_ptr<DrapeApiRenderProperty>> & properties)
|
||||
{
|
||||
properties.reserve(lines.size());
|
||||
@@ -48,10 +48,8 @@ void DrapeApiBuilder::BuildLines(ref_ptr<dp::GraphicsContext> context,
|
||||
std::string const & id = line.first;
|
||||
|
||||
DrapeApiLineData & data = line.second;
|
||||
base::Unique(data.m_points, [](m2::PointD const & p1, m2::PointD const & p2)
|
||||
{
|
||||
return p1.EqualDxDy(p2, kMwmPointAccuracy);
|
||||
});
|
||||
base::Unique(data.m_points,
|
||||
[](m2::PointD const & p1, m2::PointD const & p2) { return p1.EqualDxDy(p2, kMwmPointAccuracy); });
|
||||
|
||||
m2::RectD rect;
|
||||
for (auto const & p : data.m_points)
|
||||
@@ -62,8 +60,8 @@ void DrapeApiBuilder::BuildLines(ref_ptr<dp::GraphicsContext> context,
|
||||
auto property = make_unique_dp<DrapeApiRenderProperty>();
|
||||
property->m_center = rect.Center();
|
||||
{
|
||||
dp::SessionGuard guard(context, batcher, [&property, &id](dp::RenderState const & state,
|
||||
drape_ptr<dp::RenderBucket> && b)
|
||||
dp::SessionGuard guard(context, batcher,
|
||||
[&property, &id](dp::RenderState const & state, drape_ptr<dp::RenderBucket> && b)
|
||||
{
|
||||
property->m_id = id;
|
||||
property->m_buckets.emplace_back(state, std::move(b));
|
||||
@@ -94,8 +92,8 @@ void DrapeApiBuilder::BuildLines(ref_ptr<dp::GraphicsContext> context,
|
||||
cvp.m_radiusInPixels = data.m_width * 2.0f;
|
||||
for (m2::PointD const & pt : data.m_points)
|
||||
{
|
||||
ColoredSymbolShape(m2::PointD(pt), cvp, TileKey(), 0 /* textIndex */,
|
||||
false /* need overlay */).Draw(context, make_ref(&batcher), textures);
|
||||
ColoredSymbolShape(m2::PointD(pt), cvp, TileKey(), 0 /* textIndex */, false /* need overlay */)
|
||||
.Draw(context, make_ref(&batcher), textures);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +103,8 @@ void DrapeApiBuilder::BuildLines(ref_ptr<dp::GraphicsContext> context,
|
||||
size_t index = 0;
|
||||
for (m2::PointD const & pt : data.m_points)
|
||||
{
|
||||
if (index > 0 && !data.m_markPoints) break;
|
||||
if (index > 0 && !data.m_markPoints)
|
||||
break;
|
||||
|
||||
std::string s;
|
||||
if (data.m_markPoints)
|
||||
|
||||
@@ -22,8 +22,7 @@ struct DrapeApiRenderProperty
|
||||
class DrapeApiBuilder
|
||||
{
|
||||
public:
|
||||
void BuildLines(ref_ptr<dp::GraphicsContext> context, DrapeApi::TLines & lines,
|
||||
ref_ptr<dp::TextureManager> textures,
|
||||
void BuildLines(ref_ptr<dp::GraphicsContext> context, DrapeApi::TLines & lines, ref_ptr<dp::TextureManager> textures,
|
||||
std::vector<drape_ptr<DrapeApiRenderProperty>> & properties);
|
||||
};
|
||||
} // namespace df
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
|
||||
namespace df
|
||||
{
|
||||
void DrapeApiRenderer::AddRenderProperties(
|
||||
ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng,
|
||||
std::vector<drape_ptr<DrapeApiRenderProperty>> && properties)
|
||||
void DrapeApiRenderer::AddRenderProperties(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng,
|
||||
std::vector<drape_ptr<DrapeApiRenderProperty>> && properties)
|
||||
{
|
||||
if (properties.empty())
|
||||
return;
|
||||
@@ -32,9 +31,9 @@ void DrapeApiRenderer::AddRenderProperties(
|
||||
|
||||
void DrapeApiRenderer::RemoveRenderProperty(std::string const & id)
|
||||
{
|
||||
m_properties.erase(std::remove_if(m_properties.begin(), m_properties.end(),
|
||||
[&id](auto const & p) { return p->m_id == id; }),
|
||||
m_properties.end());
|
||||
m_properties.erase(
|
||||
std::remove_if(m_properties.begin(), m_properties.end(), [&id](auto const & p) { return p->m_id == id; }),
|
||||
m_properties.end());
|
||||
}
|
||||
|
||||
void DrapeApiRenderer::Clear()
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace
|
||||
{
|
||||
std::string_view constexpr kLocationStateMode = "LastLocationStateMode";
|
||||
std::string_view constexpr kLastEnterBackground = "LastEnterBackground";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
DrapeEngine::DrapeEngine(Params && params)
|
||||
: m_myPositionModeChanged(std::move(params.m_myPositionModeChanged))
|
||||
@@ -54,48 +54,34 @@ DrapeEngine::DrapeEngine(Params && params)
|
||||
|
||||
std::vector<PostprocessRenderer::Effect> effects;
|
||||
|
||||
// bool enabledAntialiasing;
|
||||
// if (!settings::Get(dp::kSupportedAntialiasing, enabledAntialiasing))
|
||||
// enabledAntialiasing = false;
|
||||
// bool enabledAntialiasing;
|
||||
// if (!settings::Get(dp::kSupportedAntialiasing, enabledAntialiasing))
|
||||
// enabledAntialiasing = false;
|
||||
|
||||
// Turn off AA for a while by energy-saving issues.
|
||||
//if (enabledAntialiasing)
|
||||
// if (enabledAntialiasing)
|
||||
//{
|
||||
// LOG(LINFO, ("Antialiasing is enabled"));
|
||||
// effects.push_back(PostprocessRenderer::Antialiasing);
|
||||
//}
|
||||
|
||||
MyPositionController::Params mpParams(mode,
|
||||
base::Timer::LocalTime() - m_startBackgroundTime,
|
||||
params.m_hints,
|
||||
params.m_isRoutingActive,
|
||||
params.m_isAutozoomEnabled,
|
||||
MyPositionController::Params mpParams(mode, base::Timer::LocalTime() - m_startBackgroundTime, params.m_hints,
|
||||
params.m_isRoutingActive, params.m_isAutozoomEnabled,
|
||||
std::bind(&DrapeEngine::MyPositionModeChanged, this, _1, _2));
|
||||
|
||||
FrontendRenderer::Params frParams(params.m_apiVersion,
|
||||
make_ref(m_threadCommutator),
|
||||
params.m_factory,
|
||||
make_ref(m_textureManager),
|
||||
std::move(mpParams),
|
||||
m_viewport,
|
||||
std::bind(&DrapeEngine::ModelViewChanged, this, _1),
|
||||
std::bind(&DrapeEngine::TapEvent, this, _1),
|
||||
std::bind(&DrapeEngine::UserPositionChanged, this, _1, _2),
|
||||
make_ref(m_requestedTiles),
|
||||
std::move(params.m_overlaysShowStatsCallback),
|
||||
params.m_allow3dBuildings,
|
||||
params.m_trafficEnabled,
|
||||
params.m_blockTapEvents,
|
||||
std::move(effects),
|
||||
params.m_onGraphicsContextInitialized,
|
||||
std::move(params.m_renderInjectionHandler));
|
||||
FrontendRenderer::Params frParams(
|
||||
params.m_apiVersion, make_ref(m_threadCommutator), params.m_factory, make_ref(m_textureManager),
|
||||
std::move(mpParams), m_viewport, std::bind(&DrapeEngine::ModelViewChanged, this, _1),
|
||||
std::bind(&DrapeEngine::TapEvent, this, _1), std::bind(&DrapeEngine::UserPositionChanged, this, _1, _2),
|
||||
make_ref(m_requestedTiles), std::move(params.m_overlaysShowStatsCallback), params.m_allow3dBuildings,
|
||||
params.m_trafficEnabled, params.m_blockTapEvents, std::move(effects), params.m_onGraphicsContextInitialized,
|
||||
std::move(params.m_renderInjectionHandler));
|
||||
|
||||
BackendRenderer::Params brParams(
|
||||
params.m_apiVersion, frParams.m_commutator, frParams.m_oglContextFactory, frParams.m_texMng,
|
||||
params.m_model, params.m_model.UpdateCurrentCountryFn(), make_ref(m_requestedTiles),
|
||||
params.m_allow3dBuildings, params.m_trafficEnabled, params.m_isolinesEnabled,
|
||||
params.m_simplifiedTrafficColors, std::move(params.m_arrow3dCustomDecl),
|
||||
params.m_onGraphicsContextInitialized);
|
||||
BackendRenderer::Params brParams(params.m_apiVersion, frParams.m_commutator, frParams.m_oglContextFactory,
|
||||
frParams.m_texMng, params.m_model, params.m_model.UpdateCurrentCountryFn(),
|
||||
make_ref(m_requestedTiles), params.m_allow3dBuildings, params.m_trafficEnabled,
|
||||
params.m_isolinesEnabled, params.m_simplifiedTrafficColors,
|
||||
std::move(params.m_arrow3dCustomDecl), params.m_onGraphicsContextInitialized);
|
||||
|
||||
m_backend = make_unique_dp<BackendRenderer>(std::move(brParams));
|
||||
m_frontend = make_unique_dp<FrontendRenderer>(std::move(frParams));
|
||||
@@ -135,8 +121,7 @@ void DrapeEngine::RecoverSurface(int w, int h, bool recreateContextDependentReso
|
||||
if (m_choosePositionMode)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<ShowChoosePositionMarkMessage>(),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<ShowChoosePositionMarkMessage>(), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
if (recreateContextDependentResources)
|
||||
@@ -144,8 +129,7 @@ void DrapeEngine::RecoverSurface(int w, int h, bool recreateContextDependentReso
|
||||
RecacheGui(false);
|
||||
RecacheMapShapes();
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<RecoverContextDependentResourcesMessage>(),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<RecoverContextDependentResourcesMessage>(), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
ResizeImpl(w, h);
|
||||
@@ -155,22 +139,19 @@ void DrapeEngine::Resize(int w, int h)
|
||||
{
|
||||
ASSERT_GREATER(w, 0, ());
|
||||
ASSERT_GREATER(h, 0, ());
|
||||
if (m_viewport.GetHeight() != static_cast<uint32_t>(h) ||
|
||||
m_viewport.GetWidth() != static_cast<uint32_t>(w))
|
||||
if (m_viewport.GetHeight() != static_cast<uint32_t>(h) || m_viewport.GetWidth() != static_cast<uint32_t>(w))
|
||||
ResizeImpl(w, h);
|
||||
}
|
||||
|
||||
void DrapeEngine::SetVisibleViewport(m2::RectD const & rect) const
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<SetVisibleViewportMessage>(rect),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, make_unique_dp<SetVisibleViewportMessage>(rect),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::Invalidate()
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<InvalidateMessage>(),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, make_unique_dp<InvalidateMessage>(),
|
||||
MessagePriority::High);
|
||||
}
|
||||
|
||||
@@ -207,23 +188,21 @@ void DrapeEngine::MakeFrameActive()
|
||||
void DrapeEngine::ScaleAndSetCenter(m2::PointD const & centerPt, double scaleFactor, bool isAnim,
|
||||
bool trackVisibleViewport)
|
||||
{
|
||||
PostUserEvent(make_unique_dp<SetCenterEvent>(scaleFactor, centerPt, isAnim,
|
||||
trackVisibleViewport,
|
||||
PostUserEvent(make_unique_dp<SetCenterEvent>(scaleFactor, centerPt, isAnim, trackVisibleViewport,
|
||||
nullptr /* parallelAnimCreator */));
|
||||
}
|
||||
|
||||
void DrapeEngine::SetModelViewCenter(m2::PointD const & centerPt, int zoom, bool isAnim,
|
||||
bool trackVisibleViewport)
|
||||
void DrapeEngine::SetModelViewCenter(m2::PointD const & centerPt, int zoom, bool isAnim, bool trackVisibleViewport)
|
||||
{
|
||||
PostUserEvent(make_unique_dp<SetCenterEvent>(centerPt, zoom, isAnim, trackVisibleViewport,
|
||||
nullptr /* parallelAnimCreator */));
|
||||
PostUserEvent(
|
||||
make_unique_dp<SetCenterEvent>(centerPt, zoom, isAnim, trackVisibleViewport, nullptr /* parallelAnimCreator */));
|
||||
}
|
||||
|
||||
void DrapeEngine::SetModelViewRect(m2::RectD const & rect, bool applyRotation, int zoom, bool isAnim,
|
||||
bool useVisibleViewport)
|
||||
{
|
||||
PostUserEvent(make_unique_dp<SetRectEvent>(rect, applyRotation, zoom, isAnim, useVisibleViewport,
|
||||
nullptr /* parallelAnimCreator */ ));
|
||||
nullptr /* parallelAnimCreator */));
|
||||
}
|
||||
|
||||
void DrapeEngine::SetModelViewAnyRect(m2::AnyRectD const & rect, bool isAnim, bool useVisibleViewport)
|
||||
@@ -234,8 +213,7 @@ void DrapeEngine::SetModelViewAnyRect(m2::AnyRectD const & rect, bool isAnim, bo
|
||||
void DrapeEngine::ClearUserMarksGroup(kml::MarkGroupId groupId)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<ClearUserMarkGroupMessage>(groupId),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<ClearUserMarkGroupMessage>(groupId), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::ChangeVisibilityUserMarksGroup(kml::MarkGroupId groupId, bool isVisible)
|
||||
@@ -247,15 +225,13 @@ void DrapeEngine::ChangeVisibilityUserMarksGroup(kml::MarkGroupId groupId, bool
|
||||
|
||||
void DrapeEngine::InvalidateUserMarks()
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<InvalidateUserMarksMessage>(),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, make_unique_dp<InvalidateUserMarksMessage>(),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::UpdateUserMarks(UserMarksProvider * provider, bool firstTime)
|
||||
{
|
||||
auto const updatedGroupIds = firstTime ? provider->GetAllGroupIds()
|
||||
: provider->GetUpdatedGroupIds();
|
||||
auto const updatedGroupIds = firstTime ? provider->GetAllGroupIds() : provider->GetUpdatedGroupIds();
|
||||
if (updatedGroupIds.empty())
|
||||
return;
|
||||
|
||||
@@ -267,10 +243,7 @@ void DrapeEngine::UpdateUserMarks(UserMarksProvider * provider, bool firstTime)
|
||||
std::unordered_map<kml::MarkGroupId, drape_ptr<IDCollections>> groupsVisibleIds;
|
||||
|
||||
auto const groupFilter = [&](kml::MarkGroupId groupId)
|
||||
{
|
||||
return provider->IsGroupVisible(groupId) &&
|
||||
(provider->GetBecameVisibleGroupIds().count(groupId) == 0);
|
||||
};
|
||||
{ return provider->IsGroupVisible(groupId) && (provider->GetBecameVisibleGroupIds().count(groupId) == 0); };
|
||||
|
||||
using GroupFilter = std::function<bool(kml::MarkGroupId groupId)>;
|
||||
|
||||
@@ -278,20 +251,16 @@ void DrapeEngine::UpdateUserMarks(UserMarksProvider * provider, bool firstTime)
|
||||
GroupFilter const & filter, IDCollections & collection)
|
||||
{
|
||||
for (auto const markId : markIds)
|
||||
{
|
||||
if (filter == nullptr || filter(provider->GetUserPointMark(markId)->GetGroupId()))
|
||||
collection.m_markIds.push_back(markId);
|
||||
}
|
||||
|
||||
for (auto const lineId : lineIds)
|
||||
{
|
||||
if (filter == nullptr || filter(provider->GetUserLineMark(lineId)->GetGroupId()))
|
||||
collection.m_lineIds.push_back(lineId);
|
||||
}
|
||||
};
|
||||
|
||||
auto const collectRenderData = [&](kml::MarkIdSet const & markIds, kml::TrackIdSet const & lineIds,
|
||||
GroupFilter const & filter)
|
||||
auto const collectRenderData =
|
||||
[&](kml::MarkIdSet const & markIds, kml::TrackIdSet const & lineIds, GroupFilter const & filter)
|
||||
{
|
||||
for (auto const markId : markIds)
|
||||
{
|
||||
@@ -316,8 +285,8 @@ void DrapeEngine::UpdateUserMarks(UserMarksProvider * provider, bool firstTime)
|
||||
|
||||
if (provider->IsGroupVisible(groupId))
|
||||
{
|
||||
collectIds(provider->GetGroupPointIds(groupId), provider->GetGroupLineIds(groupId),
|
||||
nullptr /* filter */, *visibleIdCollection);
|
||||
collectIds(provider->GetGroupPointIds(groupId), provider->GetGroupLineIds(groupId), nullptr /* filter */,
|
||||
*visibleIdCollection);
|
||||
collectRenderData(provider->GetGroupPointIds(groupId), provider->GetGroupLineIds(groupId),
|
||||
nullptr /* filter */);
|
||||
}
|
||||
@@ -331,51 +300,43 @@ void DrapeEngine::UpdateUserMarks(UserMarksProvider * provider, bool firstTime)
|
||||
auto visibleIdCollection = make_unique_dp<IDCollections>();
|
||||
if (provider->IsGroupVisible(groupId))
|
||||
{
|
||||
collectIds(provider->GetGroupPointIds(groupId), provider->GetGroupLineIds(groupId),
|
||||
nullptr /* filter */, *visibleIdCollection);
|
||||
collectIds(provider->GetGroupPointIds(groupId), provider->GetGroupLineIds(groupId), nullptr /* filter */,
|
||||
*visibleIdCollection);
|
||||
}
|
||||
groupsVisibleIds.emplace(groupId, std::move(visibleIdCollection));
|
||||
}
|
||||
|
||||
collectIds(provider->GetCreatedMarkIds(), provider->GetCreatedLineIds(),
|
||||
groupFilter, *justCreatedIdCollection);
|
||||
collectIds(provider->GetRemovedMarkIds(), provider->GetRemovedLineIds(),
|
||||
nullptr /* filter */, *removedIdCollection);
|
||||
collectIds(provider->GetCreatedMarkIds(), provider->GetCreatedLineIds(), groupFilter, *justCreatedIdCollection);
|
||||
collectIds(provider->GetRemovedMarkIds(), provider->GetRemovedLineIds(), nullptr /* filter */,
|
||||
*removedIdCollection);
|
||||
|
||||
collectRenderData(provider->GetCreatedMarkIds(), provider->GetCreatedLineIds(), groupFilter);
|
||||
collectRenderData(provider->GetUpdatedMarkIds(), provider->GetUpdatedLineIds(), groupFilter);
|
||||
|
||||
for (auto const groupId : provider->GetBecameVisibleGroupIds())
|
||||
{
|
||||
collectRenderData(provider->GetGroupPointIds(groupId), provider->GetGroupLineIds(groupId),
|
||||
nullptr /* filter */);
|
||||
}
|
||||
collectRenderData(provider->GetGroupPointIds(groupId), provider->GetGroupLineIds(groupId), nullptr /* filter */);
|
||||
|
||||
for (auto const groupId : provider->GetBecameInvisibleGroupIds())
|
||||
{
|
||||
collectIds(provider->GetGroupPointIds(groupId), provider->GetGroupLineIds(groupId),
|
||||
nullptr /* filter */, *removedIdCollection);
|
||||
collectIds(provider->GetGroupPointIds(groupId), provider->GetGroupLineIds(groupId), nullptr /* filter */,
|
||||
*removedIdCollection);
|
||||
}
|
||||
}
|
||||
|
||||
if (!marksRenderCollection->empty() || !linesRenderCollection->empty() ||
|
||||
!removedIdCollection->IsEmpty() || !justCreatedIdCollection->IsEmpty())
|
||||
if (!marksRenderCollection->empty() || !linesRenderCollection->empty() || !removedIdCollection->IsEmpty() ||
|
||||
!justCreatedIdCollection->IsEmpty())
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<UpdateUserMarksMessage>(
|
||||
std::move(justCreatedIdCollection),
|
||||
std::move(removedIdCollection),
|
||||
std::move(marksRenderCollection),
|
||||
std::move(linesRenderCollection)),
|
||||
MessagePriority::Normal);
|
||||
m_threadCommutator->PostMessage(
|
||||
ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<UpdateUserMarksMessage>(std::move(justCreatedIdCollection), std::move(removedIdCollection),
|
||||
std::move(marksRenderCollection), std::move(linesRenderCollection)),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
for (auto & v : groupsVisibleIds)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<UpdateUserMarkGroupMessage>(
|
||||
v.first,
|
||||
std::move(v.second)),
|
||||
make_unique_dp<UpdateUserMarkGroupMessage>(v.first, std::move(v.second)),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
}
|
||||
@@ -398,22 +359,19 @@ void DrapeEngine::SetRenderingDisabled(bool const destroySurface)
|
||||
|
||||
void DrapeEngine::InvalidateRect(m2::RectD const & rect)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<InvalidateRectMessage>(rect),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, make_unique_dp<InvalidateRectMessage>(rect),
|
||||
MessagePriority::High);
|
||||
}
|
||||
|
||||
void DrapeEngine::UpdateMapStyle()
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<UpdateMapStyleMessage>(),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, make_unique_dp<UpdateMapStyleMessage>(),
|
||||
MessagePriority::High);
|
||||
}
|
||||
|
||||
void DrapeEngine::RecacheMapShapes()
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<MapShapesRecacheMessage>(),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, make_unique_dp<MapShapesRecacheMessage>(),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
@@ -431,8 +389,7 @@ void DrapeEngine::RecacheGui(bool needResetOldGui)
|
||||
|
||||
void DrapeEngine::PostUserEvent(drape_ptr<UserEvent> && e)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<PostUserEventMessage>(std::move(e)),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, make_unique_dp<PostUserEventMessage>(std::move(e)),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
@@ -480,8 +437,7 @@ void DrapeEngine::ResizeImpl(int w, int h)
|
||||
|
||||
void DrapeEngine::SetCompassInfo(location::CompassInfo const & info)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<CompassInfoMessage>(info),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, make_unique_dp<CompassInfoMessage>(info),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
@@ -517,13 +473,11 @@ void DrapeEngine::StopLocationFollow()
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::FollowRoute(int preferredZoomLevel, int preferredZoomLevel3d, bool enableAutoZoom,
|
||||
bool isArrowGlued)
|
||||
void DrapeEngine::FollowRoute(int preferredZoomLevel, int preferredZoomLevel3d, bool enableAutoZoom, bool isArrowGlued)
|
||||
{
|
||||
m_threadCommutator->PostMessage(
|
||||
ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<FollowRouteMessage>(preferredZoomLevel, preferredZoomLevel3d, enableAutoZoom,
|
||||
isArrowGlued),
|
||||
make_unique_dp<FollowRouteMessage>(preferredZoomLevel, preferredZoomLevel3d, enableAutoZoom, isArrowGlued),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
@@ -551,30 +505,27 @@ void DrapeEngine::SetUserPositionListener(UserPositionChangedHandler && fn)
|
||||
m_userPositionChangedHandler = std::move(fn);
|
||||
}
|
||||
|
||||
void DrapeEngine::SelectObject(SelectionShape::ESelectedObject obj, m2::PointD const & pt,
|
||||
FeatureID const & featureId, bool isAnim,
|
||||
bool isGeometrySelectionAllowed, bool isSelectionShapeVisible)
|
||||
void DrapeEngine::SelectObject(SelectionShape::ESelectedObject obj, m2::PointD const & pt, FeatureID const & featureId,
|
||||
bool isAnim, bool isGeometrySelectionAllowed, bool isSelectionShapeVisible)
|
||||
{
|
||||
m_threadCommutator->PostMessage(
|
||||
ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<SelectObjectMessage>(obj, pt, featureId, isAnim, isGeometrySelectionAllowed,
|
||||
isSelectionShapeVisible),
|
||||
MessagePriority::Normal);
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<SelectObjectMessage>(
|
||||
obj, pt, featureId, isAnim, isGeometrySelectionAllowed, isSelectionShapeVisible),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::DeselectObject(bool restoreViewport)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<SelectObjectMessage>(SelectObjectMessage::DismissTag(), restoreViewport),
|
||||
MessagePriority::Normal);
|
||||
m_threadCommutator->PostMessage(
|
||||
ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<SelectObjectMessage>(SelectObjectMessage::DismissTag(), restoreViewport), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
dp::DrapeID DrapeEngine::AddSubroute(SubrouteConstPtr subroute)
|
||||
{
|
||||
dp::DrapeID const id = GenerateDrapeID();
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<AddSubrouteMessage>(id, subroute),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<AddSubrouteMessage>(id, subroute), MessagePriority::Normal);
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -587,8 +538,7 @@ void DrapeEngine::RemoveSubroute(dp::DrapeID subrouteId, bool deactivateFollowin
|
||||
|
||||
void DrapeEngine::DeactivateRouteFollowing()
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<DeactivateRouteFollowingMessage>(),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, make_unique_dp<DeactivateRouteFollowingMessage>(),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
@@ -611,14 +561,12 @@ dp::DrapeID DrapeEngine::AddRoutePreviewSegment(m2::PointD const & startPt, m2::
|
||||
void DrapeEngine::RemoveRoutePreviewSegment(dp::DrapeID segmentId)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<RemoveRoutePreviewSegmentMessage>(segmentId),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<RemoveRoutePreviewSegmentMessage>(segmentId), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::RemoveAllRoutePreviewSegments()
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<RemoveRoutePreviewSegmentMessage>(),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, make_unique_dp<RemoveRoutePreviewSegmentMessage>(),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
@@ -632,60 +580,50 @@ void DrapeEngine::SetWidgetLayout(gui::TWidgetsLayoutInfo && info)
|
||||
itInfo->second.m_pixelPivot = layout.second;
|
||||
}
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<GuiLayerLayoutMessage>(m_widgetsLayout),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<GuiLayerLayoutMessage>(m_widgetsLayout), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::AllowAutoZoom(bool allowAutoZoom)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<AllowAutoZoomMessage>(allowAutoZoom),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, make_unique_dp<AllowAutoZoomMessage>(allowAutoZoom),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::Allow3dMode(bool allowPerspectiveInNavigation, bool allow3dBuildings)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<Allow3dBuildingsMessage>(allow3dBuildings),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<Allow3dBuildingsMessage>(allow3dBuildings), MessagePriority::Normal);
|
||||
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<Allow3dModeMessage>(allowPerspectiveInNavigation,
|
||||
allow3dBuildings),
|
||||
make_unique_dp<Allow3dModeMessage>(allowPerspectiveInNavigation, allow3dBuildings),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::SetMapLangIndex(int8_t mapLangIndex)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<SetMapLangIndexMessage>(mapLangIndex),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<SetMapLangIndexMessage>(mapLangIndex), MessagePriority::Normal);
|
||||
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<SetMapLangIndexMessage>(mapLangIndex),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, make_unique_dp<SetMapLangIndexMessage>(mapLangIndex),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::EnablePerspective()
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<EnablePerspectiveMessage>(),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, make_unique_dp<EnablePerspectiveMessage>(),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::UpdateGpsTrackPoints(std::vector<df::GpsTrackPoint> && toAdd,
|
||||
std::vector<uint32_t> && toRemove)
|
||||
void DrapeEngine::UpdateGpsTrackPoints(std::vector<df::GpsTrackPoint> && toAdd, std::vector<uint32_t> && toRemove)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<UpdateGpsTrackPointsMessage>(std::move(toAdd),
|
||||
std::move(toRemove)),
|
||||
make_unique_dp<UpdateGpsTrackPointsMessage>(std::move(toAdd), std::move(toRemove)),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::ClearGpsTrackPoints()
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<ClearGpsTrackPointsMessage>(),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, make_unique_dp<ClearGpsTrackPointsMessage>(),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
@@ -698,24 +636,22 @@ void DrapeEngine::EnableChoosePositionMode(bool enable, std::vector<m2::Triangle
|
||||
{
|
||||
StopLocationFollow();
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<ShowChoosePositionMarkMessage>(),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<ShowChoosePositionMarkMessage>(), MessagePriority::Normal);
|
||||
kineticScroll = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
RecacheGui(true);
|
||||
}
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<SetAddNewPlaceModeMessage>(enable, std::move(boundAreaTriangles),
|
||||
kineticScroll, optionalPosition),
|
||||
MessagePriority::Normal);
|
||||
m_threadCommutator->PostMessage(
|
||||
ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<SetAddNewPlaceModeMessage>(enable, std::move(boundAreaTriangles), kineticScroll, optionalPosition),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::BlockTapEvents(bool block)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<BlockTapEventsMessage>(block),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, make_unique_dp<BlockTapEventsMessage>(block),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
@@ -734,8 +670,7 @@ void DrapeEngine::OnEnterForeground()
|
||||
{
|
||||
double const backgroundTime = base::Timer::LocalTime() - m_startBackgroundTime;
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<OnEnterForegroundMessage>(backgroundTime),
|
||||
MessagePriority::High);
|
||||
make_unique_dp<OnEnterForegroundMessage>(backgroundTime), MessagePriority::High);
|
||||
}
|
||||
|
||||
void DrapeEngine::OnEnterBackground()
|
||||
@@ -752,9 +687,9 @@ void DrapeEngine::OnEnterBackground()
|
||||
/// especially Android with its AppBackgroundTracker.
|
||||
m_frontend->OnEnterBackground();
|
||||
|
||||
// m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
// make_unique_dp<OnEnterBackgroundMessage>(),
|
||||
// MessagePriority::High);
|
||||
// m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
// make_unique_dp<OnEnterBackgroundMessage>(),
|
||||
// MessagePriority::High);
|
||||
}
|
||||
|
||||
void DrapeEngine::RequestSymbolsSize(std::vector<std::string> const & symbols,
|
||||
@@ -768,8 +703,7 @@ void DrapeEngine::RequestSymbolsSize(std::vector<std::string> const & symbols,
|
||||
void DrapeEngine::EnableTraffic(bool trafficEnabled)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<EnableTrafficMessage>(trafficEnabled),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<EnableTrafficMessage>(trafficEnabled), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::UpdateTraffic(traffic::TrafficInfo const & info)
|
||||
@@ -793,8 +727,7 @@ void DrapeEngine::UpdateTraffic(traffic::TrafficInfo const & info)
|
||||
void DrapeEngine::ClearTrafficCache(MwmSet::MwmId const & mwmId)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<ClearTrafficDataMessage>(mwmId),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<ClearTrafficDataMessage>(mwmId), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::SetSimplifiedTrafficColors(bool simplified)
|
||||
@@ -807,22 +740,19 @@ void DrapeEngine::SetSimplifiedTrafficColors(bool simplified)
|
||||
void DrapeEngine::EnableTransitScheme(bool enable)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<EnableTransitSchemeMessage>(enable),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<EnableTransitSchemeMessage>(enable), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::ClearTransitSchemeCache(MwmSet::MwmId const & mwmId)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<ClearTransitSchemeDataMessage>(mwmId),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<ClearTransitSchemeDataMessage>(mwmId), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::ClearAllTransitSchemeCache()
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<ClearAllTransitSchemeDataMessage>(),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<ClearAllTransitSchemeDataMessage>(), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::UpdateTransitScheme(TransitDisplayInfos && transitDisplayInfos)
|
||||
@@ -835,8 +765,7 @@ void DrapeEngine::UpdateTransitScheme(TransitDisplayInfos && transitDisplayInfos
|
||||
void DrapeEngine::EnableIsolines(bool enable)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<EnableIsolinesMessage>(enable),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<EnableIsolinesMessage>(enable), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::SetFontScaleFactor(double scaleFactor)
|
||||
@@ -856,22 +785,19 @@ void DrapeEngine::RunScenario(ScenarioManager::ScenarioData && scenarioData,
|
||||
void DrapeEngine::SetCustomFeatures(df::CustomFeatures && ids)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<SetCustomFeaturesMessage>(std::move(ids)),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<SetCustomFeaturesMessage>(std::move(ids)), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::RemoveCustomFeatures(MwmSet::MwmId const & mwmId)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<RemoveCustomFeaturesMessage>(mwmId),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<RemoveCustomFeaturesMessage>(mwmId), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::RemoveAllCustomFeatures()
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<RemoveCustomFeaturesMessage>(),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<RemoveCustomFeaturesMessage>(), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::SetPosteffectEnabled(PostprocessRenderer::Effect effect, bool enabled)
|
||||
@@ -889,23 +815,20 @@ void DrapeEngine::SetPosteffectEnabled(PostprocessRenderer::Effect effect, bool
|
||||
|
||||
void DrapeEngine::RunFirstLaunchAnimation()
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<RunFirstLaunchAnimationMessage>(),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, make_unique_dp<RunFirstLaunchAnimationMessage>(),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::ShowDebugInfo(bool shown)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<ShowDebugInfoMessage>(shown),
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, make_unique_dp<ShowDebugInfoMessage>(shown),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::EnableDebugRectRendering(bool enabled)
|
||||
{
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<EnableDebugRectRenderingMessage>(enabled),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<EnableDebugRectRenderingMessage>(enabled), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
drape_ptr<UserMarkRenderParams> DrapeEngine::GenerateMarkRenderInfo(UserPointMark const * mark)
|
||||
@@ -952,15 +875,12 @@ drape_ptr<UserLineRenderParams> DrapeEngine::GenerateLineRenderInfo(UserLineMark
|
||||
renderInfo->m_depthLayer = mark->GetDepthLayer();
|
||||
|
||||
mark->ForEachGeometry([&renderInfo](std::vector<m2::PointD> && points)
|
||||
{
|
||||
renderInfo->m_splines.emplace_back(std::move(points));
|
||||
});
|
||||
{ renderInfo->m_splines.emplace_back(std::move(points)); });
|
||||
|
||||
renderInfo->m_layers.reserve(mark->GetLayerCount());
|
||||
for (size_t layerIndex = 0, layersCount = mark->GetLayerCount(); layerIndex < layersCount; ++layerIndex)
|
||||
{
|
||||
renderInfo->m_layers.emplace_back(mark->GetColor(layerIndex),
|
||||
mark->GetWidth(layerIndex),
|
||||
renderInfo->m_layers.emplace_back(mark->GetColor(layerIndex), mark->GetWidth(layerIndex),
|
||||
mark->GetDepth(layerIndex));
|
||||
}
|
||||
return renderInfo;
|
||||
@@ -979,8 +899,7 @@ void DrapeEngine::UpdateVisualScale(double vs, bool needStopRendering)
|
||||
RecacheGui(false);
|
||||
RecacheMapShapes();
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<RecoverContextDependentResourcesMessage>(),
|
||||
MessagePriority::Normal);
|
||||
make_unique_dp<RecoverContextDependentResourcesMessage>(), MessagePriority::Normal);
|
||||
}
|
||||
|
||||
void DrapeEngine::UpdateMyPositionRoutingOffset(bool useDefault, int offsetY)
|
||||
@@ -992,8 +911,8 @@ void DrapeEngine::UpdateMyPositionRoutingOffset(bool useDefault, int offsetY)
|
||||
|
||||
void DrapeEngine::SetCustomArrow3d(std::optional<Arrow3dCustomDecl> arrow3dCustomDecl)
|
||||
{
|
||||
m_threadCommutator->PostMessage(
|
||||
ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<Arrow3dRecacheMessage>(std::move(arrow3dCustomDecl)), MessagePriority::High);
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<Arrow3dRecacheMessage>(std::move(arrow3dCustomDecl)),
|
||||
MessagePriority::High);
|
||||
}
|
||||
} // namespace df
|
||||
|
||||
@@ -52,14 +52,12 @@ class DrapeEngine
|
||||
public:
|
||||
struct Params
|
||||
{
|
||||
Params(dp::ApiVersion apiVersion, ref_ptr<dp::GraphicsContextFactory> factory,
|
||||
dp::Viewport const & viewport, MapDataProvider const & model, Hints const & hints,
|
||||
double vs, double fontsScaleFactor, gui::TWidgetsInitInfo && info,
|
||||
location::TMyPositionModeChanged && myPositionModeChanged, bool allow3dBuildings,
|
||||
bool trafficEnabled, bool isolinesEnabled, bool blockTapEvents,
|
||||
bool showChoosePositionMark, std::vector<m2::TriangleD> && boundAreaTriangles,
|
||||
bool isRoutingActive, bool isAutozoomEnabled, bool simplifiedTrafficColors,
|
||||
std::optional<Arrow3dCustomDecl> arrow3dCustomDecl,
|
||||
Params(dp::ApiVersion apiVersion, ref_ptr<dp::GraphicsContextFactory> factory, dp::Viewport const & viewport,
|
||||
MapDataProvider const & model, Hints const & hints, double vs, double fontsScaleFactor,
|
||||
gui::TWidgetsInitInfo && info, location::TMyPositionModeChanged && myPositionModeChanged,
|
||||
bool allow3dBuildings, bool trafficEnabled, bool isolinesEnabled, bool blockTapEvents,
|
||||
bool showChoosePositionMark, std::vector<m2::TriangleD> && boundAreaTriangles, bool isRoutingActive,
|
||||
bool isAutozoomEnabled, bool simplifiedTrafficColors, std::optional<Arrow3dCustomDecl> arrow3dCustomDecl,
|
||||
OverlaysShowStatsCallback && overlaysShowStatsCallback,
|
||||
OnGraphicsContextInitialized && onGraphicsContextInitialized,
|
||||
dp::RenderInjectionHandler && renderInjectionHandler)
|
||||
@@ -130,14 +128,11 @@ public:
|
||||
|
||||
void MakeFrameActive();
|
||||
|
||||
void ScaleAndSetCenter(m2::PointD const & centerPt, double scaleFactor, bool isAnim,
|
||||
bool trackVisibleViewport);
|
||||
void ScaleAndSetCenter(m2::PointD const & centerPt, double scaleFactor, bool isAnim, bool trackVisibleViewport);
|
||||
|
||||
// If zoom == -1 then current zoom will not be changed.
|
||||
void SetModelViewCenter(m2::PointD const & centerPt, int zoom, bool isAnim,
|
||||
bool trackVisibleViewport);
|
||||
void SetModelViewRect(m2::RectD const & rect, bool applyRotation, int zoom, bool isAnim,
|
||||
bool useVisibleViewport);
|
||||
void SetModelViewCenter(m2::PointD const & centerPt, int zoom, bool isAnim, bool trackVisibleViewport);
|
||||
void SetModelViewRect(m2::RectD const & rect, bool applyRotation, int zoom, bool isAnim, bool useVisibleViewport);
|
||||
void SetModelViewAnyRect(m2::AnyRectD const & rect, bool isAnim, bool useVisibleViewport);
|
||||
|
||||
using ModelViewChangedHandler = FrontendRenderer::ModelViewChangedHandler;
|
||||
@@ -159,8 +154,7 @@ public:
|
||||
void UpdateMapStyle();
|
||||
|
||||
void SetCompassInfo(location::CompassInfo const & info);
|
||||
void SetGpsInfo(location::GpsInfo const & info, bool isNavigable,
|
||||
location::RouteMatchingInfo const & routeInfo);
|
||||
void SetGpsInfo(location::GpsInfo const & info, bool isNavigable, location::RouteMatchingInfo const & routeInfo);
|
||||
void SwitchMyPositionNextMode();
|
||||
void LoseLocation();
|
||||
void StopLocationFollow();
|
||||
@@ -170,15 +164,13 @@ public:
|
||||
using UserPositionChangedHandler = FrontendRenderer::UserPositionChangedHandler;
|
||||
void SetUserPositionListener(UserPositionChangedHandler && fn);
|
||||
|
||||
void SelectObject(SelectionShape::ESelectedObject obj, m2::PointD const & pt,
|
||||
FeatureID const & featureID, bool isAnim, bool isGeometrySelectionAllowed,
|
||||
bool isSelectionShapeVisible);
|
||||
void SelectObject(SelectionShape::ESelectedObject obj, m2::PointD const & pt, FeatureID const & featureID,
|
||||
bool isAnim, bool isGeometrySelectionAllowed, bool isSelectionShapeVisible);
|
||||
void DeselectObject(bool restoreViewport);
|
||||
|
||||
dp::DrapeID AddSubroute(SubrouteConstPtr subroute);
|
||||
void RemoveSubroute(dp::DrapeID subrouteId, bool deactivateFollowing);
|
||||
void FollowRoute(int preferredZoomLevel, int preferredZoomLevel3d, bool enableAutoZoom,
|
||||
bool isArrowGlued);
|
||||
void FollowRoute(int preferredZoomLevel, int preferredZoomLevel3d, bool enableAutoZoom, bool isArrowGlued);
|
||||
void DeactivateRouteFollowing();
|
||||
void SetSubrouteVisibility(dp::DrapeID subrouteId, bool isVisible);
|
||||
dp::DrapeID AddRoutePreviewSegment(m2::PointD const & startPt, m2::PointD const & finishPt);
|
||||
@@ -192,11 +184,11 @@ public:
|
||||
void Allow3dMode(bool allowPerspectiveInNavigation, bool allow3dBuildings);
|
||||
void EnablePerspective();
|
||||
|
||||
void UpdateGpsTrackPoints(std::vector<df::GpsTrackPoint> && toAdd,
|
||||
std::vector<uint32_t> && toRemove);
|
||||
void UpdateGpsTrackPoints(std::vector<df::GpsTrackPoint> && toAdd, std::vector<uint32_t> && toRemove);
|
||||
void ClearGpsTrackPoints();
|
||||
|
||||
void EnableChoosePositionMode(bool enable, std::vector<m2::TriangleD> && boundAreaTriangles, m2::PointD const * optionalPosition);
|
||||
void EnableChoosePositionMode(bool enable, std::vector<m2::TriangleD> && boundAreaTriangles,
|
||||
m2::PointD const * optionalPosition);
|
||||
void BlockTapEvents(bool block);
|
||||
|
||||
void SetKineticScrollEnabled(bool enabled);
|
||||
@@ -208,8 +200,7 @@ public:
|
||||
|
||||
using TRequestSymbolsSizeCallback = std::function<void(std::map<std::string, m2::PointF> &&)>;
|
||||
|
||||
void RequestSymbolsSize(std::vector<std::string> const & symbols,
|
||||
TRequestSymbolsSizeCallback const & callback);
|
||||
void RequestSymbolsSize(std::vector<std::string> const & symbols, TRequestSymbolsSizeCallback const & callback);
|
||||
|
||||
void EnableTraffic(bool trafficEnabled);
|
||||
void UpdateTraffic(traffic::TrafficInfo const & info);
|
||||
@@ -225,8 +216,7 @@ public:
|
||||
|
||||
void SetFontScaleFactor(double scaleFactor);
|
||||
|
||||
void RunScenario(ScenarioManager::ScenarioData && scenarioData,
|
||||
ScenarioManager::ScenarioCallback const & onStartFn,
|
||||
void RunScenario(ScenarioManager::ScenarioData && scenarioData, ScenarioManager::ScenarioCallback const & onStartFn,
|
||||
ScenarioManager::ScenarioCallback const & onFinishFn);
|
||||
|
||||
/// @name Custom features are features that we render in a different way.
|
||||
@@ -253,7 +243,7 @@ public:
|
||||
|
||||
void SetCustomArrow3d(std::optional<Arrow3dCustomDecl> arrow3dCustomDecl);
|
||||
|
||||
dp::ApiVersion GetApiVersion() const { return m_frontend->GetApiVersion(); };
|
||||
dp::ApiVersion GetApiVersion() const { return m_frontend->GetApiVersion(); }
|
||||
|
||||
private:
|
||||
void AddUserEvent(drape_ptr<UserEvent> && e);
|
||||
|
||||
@@ -26,16 +26,16 @@ public:
|
||||
return m_engine != nullptr;
|
||||
}
|
||||
|
||||
template <typename Function, typename ... Args>
|
||||
void SafeCall(Function && f, Args && ... functionArgs)
|
||||
template <typename Function, typename... Args>
|
||||
void SafeCall(Function && f, Args &&... functionArgs)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if (m_engine != nullptr)
|
||||
(m_engine.get()->*f)(std::forward<Args>(functionArgs)...);
|
||||
}
|
||||
|
||||
template <typename Function, typename ... Args>
|
||||
dp::DrapeID SafeCallWithResult(Function && f, Args && ... functionArgs)
|
||||
template <typename Function, typename... Args>
|
||||
dp::DrapeID SafeCallWithResult(Function && f, Args &&... functionArgs)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if (m_engine != nullptr)
|
||||
@@ -53,16 +53,9 @@ private:
|
||||
class DrapeEngineLockGuard
|
||||
{
|
||||
public:
|
||||
explicit DrapeEngineLockGuard(DrapeEngineSafePtr & enginePtr)
|
||||
: m_ptr(enginePtr)
|
||||
{
|
||||
m_ptr.m_mutex.lock();
|
||||
}
|
||||
explicit DrapeEngineLockGuard(DrapeEngineSafePtr & enginePtr) : m_ptr(enginePtr) { m_ptr.m_mutex.lock(); }
|
||||
|
||||
~DrapeEngineLockGuard()
|
||||
{
|
||||
m_ptr.m_mutex.unlock();
|
||||
}
|
||||
~DrapeEngineLockGuard() { m_ptr.m_mutex.unlock(); }
|
||||
|
||||
explicit operator bool() { return m_ptr.m_engine != nullptr; }
|
||||
|
||||
|
||||
@@ -8,14 +8,10 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
glsl::mat4 const kTestMatrix1 = glsl::mat4(1.0f, 2.0f, 3.0f, 4.0f,
|
||||
1.0f, 2.0f, 3.0f, 4.0f,
|
||||
1.0f, 2.0f, 3.0f, 4.0f,
|
||||
1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glsl::mat4 const kTestMatrix2 = glsl::mat4(4.0f, 3.0f, 2.0f, 1.0f,
|
||||
4.0f, 3.0f, 2.0f, 1.0f,
|
||||
4.0f, 3.0f, 2.0f, 1.0f,
|
||||
4.0f, 3.0f, 2.0f, 1.0f);
|
||||
glsl::mat4 const kTestMatrix1 =
|
||||
glsl::mat4(1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glsl::mat4 const kTestMatrix2 =
|
||||
glsl::mat4(4.0f, 3.0f, 2.0f, 1.0f, 4.0f, 3.0f, 2.0f, 1.0f, 4.0f, 3.0f, 2.0f, 1.0f, 4.0f, 3.0f, 2.0f, 1.0f);
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(FrameValues_SetTo)
|
||||
|
||||
@@ -38,34 +38,30 @@ UNIT_TEST(Navigator_Scale2Points)
|
||||
ScreenBase const & screen = navigator.Screen();
|
||||
TEST_EQUAL(screen.ClipRect(), m2::RectD(0, 0, 8, 4), ());
|
||||
|
||||
navigator.StartScale(screen.GtoP(m2::PointD(1, 1)),
|
||||
screen.GtoP(m2::PointD(7, 1)));
|
||||
navigator.StopScale(screen.GtoP(m2::PointD(1, 1)),
|
||||
screen.GtoP(m2::PointD(4, 1)));
|
||||
navigator.StartScale(screen.GtoP(m2::PointD(1, 1)), screen.GtoP(m2::PointD(7, 1)));
|
||||
navigator.StopScale(screen.GtoP(m2::PointD(1, 1)), screen.GtoP(m2::PointD(4, 1)));
|
||||
TEST_EQUAL(screen.ClipRect(), m2::RectD(-1, -1, 15, 7), ());
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
void CheckNavigator(df::Navigator const & nav)
|
||||
void CheckNavigator(df::Navigator const & nav)
|
||||
{
|
||||
typedef m2::PointD P;
|
||||
m2::RectD clipR = nav.Screen().ClipRect();
|
||||
|
||||
P arr[] = {clipR.LeftTop(), clipR.RightTop(), clipR.RightBottom(), clipR.LeftBottom(), clipR.Center()};
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
|
||||
{
|
||||
typedef m2::PointD P;
|
||||
m2::RectD clipR = nav.Screen().ClipRect();
|
||||
|
||||
P arr[] = { clipR.LeftTop(), clipR.RightTop(),
|
||||
clipR.RightBottom(), clipR.LeftBottom(),
|
||||
clipR.Center() };
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
|
||||
{
|
||||
P const & pxP = arr[i];
|
||||
P const gP = nav.PtoG(pxP);
|
||||
P const pxP2 = nav.GtoP(gP);
|
||||
TEST(AlmostEqualAbs(pxP.x, pxP2.x, 0.00001), (pxP.x, pxP2.x));
|
||||
TEST(AlmostEqualAbs(pxP.y, pxP2.y, 0.00001), (pxP.y, pxP2.y));
|
||||
}
|
||||
P const & pxP = arr[i];
|
||||
P const gP = nav.PtoG(pxP);
|
||||
P const pxP2 = nav.GtoP(gP);
|
||||
TEST(AlmostEqualAbs(pxP.x, pxP2.x, 0.00001), (pxP.x, pxP2.x));
|
||||
TEST(AlmostEqualAbs(pxP.y, pxP2.y, 0.00001), (pxP.y, pxP2.y));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(Navigator_G2P_P2G)
|
||||
{
|
||||
@@ -83,6 +79,6 @@ UNIT_TEST(Navigator_G2P_P2G)
|
||||
navigator.Scale(center, 3.0);
|
||||
CheckNavigator(navigator);
|
||||
|
||||
navigator.Scale(center, 1/3.0);
|
||||
navigator.Scale(center, 1 / 3.0);
|
||||
CheckNavigator(navigator);
|
||||
}
|
||||
|
||||
@@ -10,13 +10,11 @@ namespace
|
||||
bool IsSmooth(m2::SplineEx const & spline)
|
||||
{
|
||||
for (size_t i = 0, sz = spline.GetDirections().size(); i + 1 < sz; ++i)
|
||||
{
|
||||
if (!df::IsValidSplineTurn(spline.GetDirections()[i], spline.GetDirections()[i + 1]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(Rounding_Spline)
|
||||
{
|
||||
|
||||
@@ -19,6 +19,6 @@ UNIT_TEST(Stylist_IsHatching)
|
||||
TEST(checker(cl.GetTypeByPath({"boundary", "national_park"})), ());
|
||||
|
||||
TEST(checker(cl.GetTypeByPath({"landuse", "military", "danger_area"})), ());
|
||||
|
||||
|
||||
TEST(checker(cl.GetTypeByPath({"amenity", "prison"})), ());
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@ namespace
|
||||
class UserEventStreamTest : df::UserEventStream::Listener
|
||||
{
|
||||
public:
|
||||
explicit UserEventStreamTest(bool filtrateTouches)
|
||||
: m_filtrate(filtrateTouches)
|
||||
explicit UserEventStreamTest(bool filtrateTouches) : m_filtrate(filtrateTouches)
|
||||
{
|
||||
m_stream.SetTestBridge(std::bind(&UserEventStreamTest::TestBridge, this, _1));
|
||||
}
|
||||
@@ -40,16 +39,13 @@ public:
|
||||
void OnScaleEnded() override {}
|
||||
void OnTouchMapAction(df::TouchEvent::ETouchType touchType, bool isMapTouch) override {}
|
||||
void OnAnimatedScaleEnded() override {}
|
||||
bool OnNewVisibleViewport(m2::RectD const & oldViewport, m2::RectD const & newViewport,
|
||||
bool needOffset, m2::PointD & gOffset) override
|
||||
bool OnNewVisibleViewport(m2::RectD const & oldViewport, m2::RectD const & newViewport, bool needOffset,
|
||||
m2::PointD & gOffset) override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void AddUserEvent(df::TouchEvent const & event)
|
||||
{
|
||||
m_stream.AddEvent(make_unique_dp<df::TouchEvent>(event));
|
||||
}
|
||||
void AddUserEvent(df::TouchEvent const & event) { m_stream.AddEvent(make_unique_dp<df::TouchEvent>(event)); }
|
||||
|
||||
void SetRect(m2::RectD const & r)
|
||||
{
|
||||
@@ -58,10 +54,7 @@ public:
|
||||
nullptr /* parallelAnimCreator */));
|
||||
}
|
||||
|
||||
void AddExpectation(char const * action)
|
||||
{
|
||||
m_expectation.push_back(action);
|
||||
}
|
||||
void AddExpectation(char const * action) { m_expectation.push_back(action); }
|
||||
|
||||
void RunTest()
|
||||
{
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "geometry/mercator.hpp"
|
||||
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
namespace df
|
||||
@@ -81,7 +80,7 @@ void DrapeMeasurer::Start()
|
||||
#endif
|
||||
}
|
||||
|
||||
void DrapeMeasurer::Stop(bool forceProcessRealtimeStats /* = false */ )
|
||||
void DrapeMeasurer::Stop(bool forceProcessRealtimeStats /* = false */)
|
||||
{
|
||||
using namespace std::chrono;
|
||||
if (!m_isEnabled)
|
||||
@@ -90,11 +89,8 @@ void DrapeMeasurer::Stop(bool forceProcessRealtimeStats /* = false */ )
|
||||
m_isEnabled = false;
|
||||
|
||||
#ifndef DRAPE_MEASURER_BENCHMARK
|
||||
if ((forceProcessRealtimeStats && m_realtimeTotalFramesCount > 0) ||
|
||||
m_realtimeTotalFramesCount >= 1000)
|
||||
{
|
||||
if ((forceProcessRealtimeStats && m_realtimeTotalFramesCount > 0) || m_realtimeTotalFramesCount >= 1000)
|
||||
m_realtimeTotalFramesCount = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -127,8 +123,7 @@ void DrapeMeasurer::EndScenePreparing()
|
||||
if (!m_isEnabled)
|
||||
return;
|
||||
|
||||
m_maxScenePreparingTime = max(m_maxScenePreparingTime,
|
||||
std::chrono::steady_clock::now() - m_startScenePreparingTime);
|
||||
m_maxScenePreparingTime = max(m_maxScenePreparingTime, std::chrono::steady_clock::now() - m_startScenePreparingTime);
|
||||
}
|
||||
|
||||
void DrapeMeasurer::StartShapesGeneration()
|
||||
@@ -159,11 +154,11 @@ std::string DrapeMeasurer::GeneratingStatistic::ToString() const
|
||||
ss << " ----- Generation statistic report ----- \n";
|
||||
ss << " Max scene preparing time, ms = " << m_maxScenePreparingTimeInMs << "\n";
|
||||
ss << " Shapes total generation time, ms = " << m_shapeGenTimeInMs << "\n";
|
||||
ss << " Shapes total count = " << m_shapesCount
|
||||
<< ", (" << static_cast<double>(m_shapeGenTimeInMs) / m_shapesCount << " ms per shape)\n";
|
||||
ss << " Shapes total count = " << m_shapesCount << ", (" << static_cast<double>(m_shapeGenTimeInMs) / m_shapesCount
|
||||
<< " ms per shape)\n";
|
||||
ss << " Overlay shapes total generation time, ms = " << m_overlayShapeGenTimeInMs << "\n";
|
||||
ss << " Overlay shapes total count = " << m_overlayShapesCount
|
||||
<< ", (" << static_cast<double>(m_overlayShapeGenTimeInMs) / m_overlayShapesCount << " ms per overlay)\n";
|
||||
ss << " Overlay shapes total count = " << m_overlayShapesCount << ", ("
|
||||
<< static_cast<double>(m_overlayShapeGenTimeInMs) / m_overlayShapesCount << " ms per overlay)\n";
|
||||
ss << " ----- Generation statistic report ----- \n";
|
||||
|
||||
return ss.str();
|
||||
@@ -175,8 +170,7 @@ DrapeMeasurer::GeneratingStatistic DrapeMeasurer::GetGeneratingStatistic()
|
||||
|
||||
GeneratingStatistic statistic;
|
||||
statistic.m_shapesCount = m_totalShapesCount;
|
||||
statistic.m_shapeGenTimeInMs =
|
||||
static_cast<uint32_t>(duration_cast<milliseconds>(m_totalShapesGenTime).count());
|
||||
statistic.m_shapeGenTimeInMs = static_cast<uint32_t>(duration_cast<milliseconds>(m_totalShapesGenTime).count());
|
||||
|
||||
statistic.m_overlayShapesCount = m_totalOverlayShapesCount;
|
||||
statistic.m_overlayShapeGenTimeInMs =
|
||||
@@ -204,8 +198,8 @@ std::string DrapeMeasurer::RenderStatistic::ToString() const
|
||||
ss << " FPS Distribution:\n";
|
||||
for (auto const & fps : m_fpsDistribution)
|
||||
{
|
||||
ss << " " << fps.first << "-" << (fps.first + 10) << ": " << std::setprecision(4)
|
||||
<< fps.second * 100.0f << "%\n";
|
||||
ss << " " << fps.first << "-" << (fps.first + 10) << ": " << std::setprecision(4) << fps.second * 100.0f
|
||||
<< "%\n";
|
||||
}
|
||||
}
|
||||
ss << " ----- Render statistic report ----- \n";
|
||||
@@ -228,10 +222,8 @@ DrapeMeasurer::RenderStatistic DrapeMeasurer::GetRenderStatistic()
|
||||
totalCount += fps.second;
|
||||
|
||||
if (totalCount != 0)
|
||||
{
|
||||
for (auto const & fps : m_fpsDistribution)
|
||||
statistic.m_fpsDistribution[fps.first] = static_cast<float>(fps.second) / totalCount;
|
||||
}
|
||||
|
||||
statistic.m_immediateRenderingMinFPS = m_immediateRenderingMinFps;
|
||||
if (m_immediateRenderingFramesCount > 0)
|
||||
@@ -436,12 +428,9 @@ void DrapeMeasurer::TakeGPUMemorySnapshot()
|
||||
auto itMax = m_maxSnapshotValues.m_tagStats.find(tagPair.first);
|
||||
if (itMax != m_maxSnapshotValues.m_tagStats.end())
|
||||
{
|
||||
itMax->second.m_objectsCount = std::max(itMax->second.m_objectsCount,
|
||||
tagPair.second.m_objectsCount);
|
||||
itMax->second.m_alocatedInMb = std::max(itMax->second.m_alocatedInMb,
|
||||
tagPair.second.m_alocatedInMb);
|
||||
itMax->second.m_usedInMb = std::max(itMax->second.m_alocatedInMb,
|
||||
tagPair.second.m_usedInMb);
|
||||
itMax->second.m_objectsCount = std::max(itMax->second.m_objectsCount, tagPair.second.m_objectsCount);
|
||||
itMax->second.m_alocatedInMb = std::max(itMax->second.m_alocatedInMb, tagPair.second.m_alocatedInMb);
|
||||
itMax->second.m_usedInMb = std::max(itMax->second.m_alocatedInMb, tagPair.second.m_usedInMb);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -461,10 +450,9 @@ void DrapeMeasurer::TakeGPUMemorySnapshot()
|
||||
}
|
||||
}
|
||||
|
||||
m_maxSnapshotValues.m_summaryAllocatedInMb = std::max(snap.m_summaryAllocatedInMb,
|
||||
m_maxSnapshotValues.m_summaryAllocatedInMb);
|
||||
m_maxSnapshotValues.m_summaryUsedInMb = std::max(snap.m_summaryUsedInMb,
|
||||
m_maxSnapshotValues.m_summaryUsedInMb);
|
||||
m_maxSnapshotValues.m_summaryAllocatedInMb =
|
||||
std::max(snap.m_summaryAllocatedInMb, m_maxSnapshotValues.m_summaryAllocatedInMb);
|
||||
m_maxSnapshotValues.m_summaryUsedInMb = std::max(snap.m_summaryUsedInMb, m_maxSnapshotValues.m_summaryUsedInMb);
|
||||
|
||||
m_summarySnapshotValues.m_summaryAllocatedInMb += snap.m_summaryAllocatedInMb;
|
||||
m_summarySnapshotValues.m_summaryUsedInMb += snap.m_summaryUsedInMb;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "drape/drape_diagnostics.hpp"
|
||||
#include "drape/utils/gpu_mem_tracker.hpp"
|
||||
#include "drape/utils/glyph_usage_tracker.hpp"
|
||||
#include "drape/utils/gpu_mem_tracker.hpp"
|
||||
|
||||
#include "geometry/rect2d.hpp"
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
#include "base/timer.hpp"
|
||||
|
||||
#include <chrono>
|
||||
#include <drape/drape_global.hpp>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <drape/drape_global.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace df
|
||||
{
|
||||
|
||||
@@ -11,8 +11,7 @@ DrapeNotifier::DrapeNotifier(ref_ptr<ThreadsCommutator> commutator)
|
||||
{}
|
||||
|
||||
uint64_t DrapeNotifier::Notify(ThreadsCommutator::ThreadName threadName,
|
||||
base::DelayedThreadPool::Duration const & duration, bool repeating,
|
||||
Functor && functor)
|
||||
base::DelayedThreadPool::Duration const & duration, bool repeating, Functor && functor)
|
||||
{
|
||||
uint64_t const notifyId = m_counter++;
|
||||
NotifyImpl(threadName, duration, repeating, notifyId, std::move(functor));
|
||||
@@ -20,14 +19,13 @@ uint64_t DrapeNotifier::Notify(ThreadsCommutator::ThreadName threadName,
|
||||
}
|
||||
|
||||
void DrapeNotifier::NotifyImpl(ThreadsCommutator::ThreadName threadName,
|
||||
base::DelayedThreadPool::Duration const & duration, bool repeating,
|
||||
uint64_t notifyId, Functor && functor)
|
||||
base::DelayedThreadPool::Duration const & duration, bool repeating, uint64_t notifyId,
|
||||
Functor && functor)
|
||||
{
|
||||
dp::DrapeRoutine::RunDelayed(duration,
|
||||
[this, threadName, duration, repeating, notifyId, functor = std::move(functor)]() mutable
|
||||
[this, threadName, duration, repeating, notifyId, functor = std::move(functor)]() mutable
|
||||
{
|
||||
m_commutator->PostMessage(threadName,
|
||||
make_unique_dp<NotifyRenderThreadMessage>(functor, notifyId),
|
||||
m_commutator->PostMessage(threadName, make_unique_dp<NotifyRenderThreadMessage>(functor, notifyId),
|
||||
MessagePriority::Normal);
|
||||
if (repeating)
|
||||
NotifyImpl(threadName, duration, repeating, notifyId, std::move(functor));
|
||||
|
||||
@@ -20,14 +20,12 @@ public:
|
||||
|
||||
explicit DrapeNotifier(ref_ptr<ThreadsCommutator> commutator);
|
||||
|
||||
uint64_t Notify(ThreadsCommutator::ThreadName threadName,
|
||||
base::DelayedThreadPool::Duration const & duration,
|
||||
uint64_t Notify(ThreadsCommutator::ThreadName threadName, base::DelayedThreadPool::Duration const & duration,
|
||||
bool repeating, Functor && functor);
|
||||
|
||||
private:
|
||||
void NotifyImpl(ThreadsCommutator::ThreadName threadName,
|
||||
base::DelayedThreadPool::Duration const & duration, bool repeating,
|
||||
uint64_t notifyId, Functor && functor);
|
||||
void NotifyImpl(ThreadsCommutator::ThreadName threadName, base::DelayedThreadPool::Duration const & duration,
|
||||
bool repeating, uint64_t notifyId, Functor && functor);
|
||||
|
||||
ref_ptr<ThreadsCommutator> m_commutator;
|
||||
std::atomic<uint64_t> m_counter;
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
#include "drape_frontend/engine_context.hpp"
|
||||
|
||||
#include "drape_frontend/message_subclasses.hpp"
|
||||
#include "drape/texture_manager.hpp"
|
||||
#include "drape_frontend/message_subclasses.hpp"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace df
|
||||
{
|
||||
EngineContext::EngineContext(TileKey tileKey,
|
||||
ref_ptr<ThreadsCommutator> commutator,
|
||||
ref_ptr<dp::TextureManager> texMng,
|
||||
ref_ptr<MetalineManager> metalineMng,
|
||||
CustomFeaturesContextWeakPtr customFeaturesContext,
|
||||
bool is3dBuildingsEnabled,
|
||||
bool isTrafficEnabled,
|
||||
bool isolinesEnabled,
|
||||
EngineContext::EngineContext(TileKey tileKey, ref_ptr<ThreadsCommutator> commutator, ref_ptr<dp::TextureManager> texMng,
|
||||
ref_ptr<MetalineManager> metalineMng, CustomFeaturesContextWeakPtr customFeaturesContext,
|
||||
bool is3dBuildingsEnabled, bool isTrafficEnabled, bool isolinesEnabled,
|
||||
int8_t mapLangIndex)
|
||||
: m_tileKey(tileKey)
|
||||
, m_commutator(commutator)
|
||||
@@ -66,7 +61,6 @@ void EngineContext::EndReadTile()
|
||||
|
||||
void EngineContext::PostMessage(drape_ptr<Message> && message)
|
||||
{
|
||||
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread, std::move(message),
|
||||
MessagePriority::Normal);
|
||||
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread, std::move(message), MessagePriority::Normal);
|
||||
}
|
||||
} // namespace df
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include "drape_frontend/custom_features_context.hpp"
|
||||
#include "drape_frontend/map_shape.hpp"
|
||||
#include "drape_frontend/tile_utils.hpp"
|
||||
#include "drape_frontend/threads_commutator.hpp"
|
||||
#include "drape_frontend/tile_utils.hpp"
|
||||
#include "drape_frontend/traffic_generator.hpp"
|
||||
|
||||
#include "drape/constants.hpp"
|
||||
@@ -24,15 +24,9 @@ class MetalineManager;
|
||||
class EngineContext
|
||||
{
|
||||
public:
|
||||
EngineContext(TileKey tileKey,
|
||||
ref_ptr<ThreadsCommutator> commutator,
|
||||
ref_ptr<dp::TextureManager> texMng,
|
||||
ref_ptr<MetalineManager> metalineMng,
|
||||
CustomFeaturesContextWeakPtr customFeaturesContext,
|
||||
bool is3dBuildingsEnabled,
|
||||
bool isTrafficEnabled,
|
||||
bool isolinesEnabled,
|
||||
int8_t mapLangIndex);
|
||||
EngineContext(TileKey tileKey, ref_ptr<ThreadsCommutator> commutator, ref_ptr<dp::TextureManager> texMng,
|
||||
ref_ptr<MetalineManager> metalineMng, CustomFeaturesContextWeakPtr customFeaturesContext,
|
||||
bool is3dBuildingsEnabled, bool isTrafficEnabled, bool isolinesEnabled, int8_t mapLangIndex);
|
||||
|
||||
TileKey const & GetTileKey() const { return m_tileKey; }
|
||||
bool Is3dBuildingsEnabled() const { return m_3dBuildingsEnabled; }
|
||||
|
||||
@@ -9,25 +9,26 @@
|
||||
|
||||
namespace df
|
||||
{
|
||||
#define DECLARE_SETTER(name, field) \
|
||||
template<typename T> struct Check##name \
|
||||
{ \
|
||||
private: \
|
||||
static void Detect(...); \
|
||||
template<typename U> static decltype(std::declval<U>().field) Detect(U const &); \
|
||||
public: \
|
||||
static constexpr bool Value = !std::is_same<void, decltype(Detect(std::declval<T>()))>::value; \
|
||||
}; \
|
||||
template <typename ParamsType> \
|
||||
std::enable_if_t<Check##name<ParamsType>::Value> \
|
||||
name(ParamsType & params) const \
|
||||
{ \
|
||||
params.field = field; \
|
||||
} \
|
||||
template <typename ParamsType> \
|
||||
std::enable_if_t<!Check##name<ParamsType>::Value> \
|
||||
name(ParamsType & params) const {}
|
||||
|
||||
#define DECLARE_SETTER(name, field) \
|
||||
template <typename T> \
|
||||
struct Check##name \
|
||||
{ \
|
||||
private: \
|
||||
static void Detect(...); \
|
||||
template <typename U> \
|
||||
static decltype(std::declval<U>().field) Detect(U const &); \
|
||||
\
|
||||
public: \
|
||||
static constexpr bool Value = !std::is_same<void, decltype(Detect(std::declval<T>()))>::value; \
|
||||
}; \
|
||||
template <typename ParamsType> \
|
||||
std::enable_if_t<Check##name<ParamsType>::Value> name(ParamsType & params) const \
|
||||
{ \
|
||||
params.field = field; \
|
||||
} \
|
||||
template <typename ParamsType> \
|
||||
std::enable_if_t<!Check##name<ParamsType>::Value> name(ParamsType & params) const \
|
||||
{}
|
||||
|
||||
struct FrameValues
|
||||
{
|
||||
|
||||
1503
libs/drape_frontend/frontend_renderer.cpp
Executable file → Normal file
1503
libs/drape_frontend/frontend_renderer.cpp
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
46
libs/drape_frontend/frontend_renderer.hpp
Executable file → Normal file
46
libs/drape_frontend/frontend_renderer.hpp
Executable file → Normal file
@@ -7,11 +7,11 @@
|
||||
#include "drape_frontend/gui/layer_render.hpp"
|
||||
#include "drape_frontend/my_position_controller.hpp"
|
||||
#include "drape_frontend/overlays_tracker.hpp"
|
||||
#include "drape_frontend/postprocess_renderer.hpp"
|
||||
#include "drape_frontend/render_group.hpp"
|
||||
#include "drape_frontend/render_state_extension.hpp"
|
||||
#include "drape_frontend/requested_tiles.hpp"
|
||||
#include "drape_frontend/route_renderer.hpp"
|
||||
#include "drape_frontend/postprocess_renderer.hpp"
|
||||
#include "drape_frontend/threads_commutator.hpp"
|
||||
#include "drape_frontend/traffic_renderer.hpp"
|
||||
#include "drape_frontend/transit_scheme_renderer.hpp"
|
||||
@@ -74,9 +74,10 @@ struct TapInfo
|
||||
* Each RenderLayer contains several RenderGroups, one per each tile and RenderState.
|
||||
* Each RenderGroup contains several RenderBuckets holding VertexArrayBuffers and optional OverlayHandles.
|
||||
*/
|
||||
class FrontendRenderer : public BaseRenderer,
|
||||
public MyPositionController::Listener,
|
||||
public UserEventStream::Listener
|
||||
class FrontendRenderer
|
||||
: public BaseRenderer
|
||||
, public MyPositionController::Listener
|
||||
, public UserEventStream::Listener
|
||||
{
|
||||
public:
|
||||
using ModelViewChangedHandler = std::function<void(ScreenBase const & screen)>;
|
||||
@@ -90,13 +91,11 @@ public:
|
||||
ref_ptr<dp::GraphicsContextFactory> factory, ref_ptr<dp::TextureManager> texMng,
|
||||
MyPositionController::Params && myPositionParams, dp::Viewport viewport,
|
||||
ModelViewChangedHandler && modelViewChangedHandler, TapEventInfoHandler && tapEventHandler,
|
||||
UserPositionChangedHandler && positionChangedHandler,
|
||||
ref_ptr<RequestedTiles> requestedTiles,
|
||||
OverlaysShowStatsCallback && overlaysShowStatsCallback,
|
||||
bool allow3dBuildings, bool trafficEnabled, bool blockTapEvents,
|
||||
std::vector<PostprocessRenderer::Effect> && enabledEffects,
|
||||
UserPositionChangedHandler && positionChangedHandler, ref_ptr<RequestedTiles> requestedTiles,
|
||||
OverlaysShowStatsCallback && overlaysShowStatsCallback, bool allow3dBuildings, bool trafficEnabled,
|
||||
bool blockTapEvents, std::vector<PostprocessRenderer::Effect> && enabledEffects,
|
||||
OnGraphicsContextInitialized const & onGraphicsContextInitialized,
|
||||
dp::RenderInjectionHandler&& renderInjectionHandler)
|
||||
dp::RenderInjectionHandler && renderInjectionHandler)
|
||||
: BaseRenderer::Params(apiVersion, commutator, factory, texMng, onGraphicsContextInitialized)
|
||||
, m_myPositionParams(std::move(myPositionParams))
|
||||
, m_viewport(viewport)
|
||||
@@ -138,13 +137,12 @@ public:
|
||||
void ChangeModelView(m2::PointD const & center, int zoomLevel,
|
||||
TAnimationCreator const & parallelAnimCreator) override;
|
||||
void ChangeModelView(double azimuth, TAnimationCreator const & parallelAnimCreator) override;
|
||||
void ChangeModelView(m2::RectD const & rect,
|
||||
void ChangeModelView(m2::RectD const & rect, TAnimationCreator const & parallelAnimCreator) override;
|
||||
void ChangeModelView(m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero, int preferredZoomLevel,
|
||||
Animation::TAction const & onFinishAction,
|
||||
TAnimationCreator const & parallelAnimCreator) override;
|
||||
void ChangeModelView(m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero,
|
||||
int preferredZoomLevel, Animation::TAction const & onFinishAction,
|
||||
void ChangeModelView(double autoScale, m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero,
|
||||
TAnimationCreator const & parallelAnimCreator) override;
|
||||
void ChangeModelView(double autoScale, m2::PointD const & userPos, double azimuth,
|
||||
m2::PointD const & pxZero, TAnimationCreator const & parallelAnimCreator) override;
|
||||
|
||||
drape_ptr<ScenarioManager> const & GetScenarioManager() const { return m_scenarioManager; }
|
||||
location::EMyPositionMode GetMyPositionMode() const { return m_myPositionController->GetCurrentMode(); }
|
||||
@@ -197,8 +195,7 @@ private:
|
||||
bool HasTransitRouteData() const;
|
||||
bool HasRouteData() const;
|
||||
|
||||
ScreenBase const & ProcessEvents(bool & modelViewChanged, bool & viewportChanged,
|
||||
bool & needActiveFrame);
|
||||
ScreenBase const & ProcessEvents(bool & modelViewChanged, bool & viewportChanged, bool & needActiveFrame);
|
||||
void PrepareScene(ScreenBase const & modelView);
|
||||
void UpdateScene(ScreenBase const & modelView);
|
||||
void BuildOverlayTree(ScreenBase const & modelView);
|
||||
@@ -233,8 +230,8 @@ private:
|
||||
void OnScaleEnded() override;
|
||||
void OnAnimatedScaleEnded() override;
|
||||
void OnTouchMapAction(TouchEvent::ETouchType touchType, bool isMapTouch) override;
|
||||
bool OnNewVisibleViewport(m2::RectD const & oldViewport, m2::RectD const & newViewport,
|
||||
bool needOffset, m2::PointD & gOffset) override;
|
||||
bool OnNewVisibleViewport(m2::RectD const & oldViewport, m2::RectD const & newViewport, bool needOffset,
|
||||
m2::PointD & gOffset) override;
|
||||
|
||||
class Routine : public threads::IRoutine
|
||||
{
|
||||
@@ -253,15 +250,14 @@ private:
|
||||
void UpdateOverlayTree(ScreenBase const & modelView, drape_ptr<RenderGroup> & renderGroup);
|
||||
void EndUpdateOverlayTree();
|
||||
|
||||
template<typename TRenderGroup>
|
||||
template <typename TRenderGroup>
|
||||
void AddToRenderGroup(dp::RenderState const & state, drape_ptr<dp::RenderBucket> && renderBucket,
|
||||
TileKey const & newTile);
|
||||
|
||||
using TRenderGroupRemovePredicate = std::function<bool(drape_ptr<RenderGroup> const &)>;
|
||||
void RemoveRenderGroupsLater(TRenderGroupRemovePredicate const & predicate);
|
||||
|
||||
void FollowRoute(int preferredZoomLevel, int preferredZoomLevelIn3d, bool enableAutoZoom,
|
||||
bool isArrowGlued);
|
||||
void FollowRoute(int preferredZoomLevel, int preferredZoomLevelIn3d, bool enableAutoZoom, bool isArrowGlued);
|
||||
|
||||
bool CheckRouteRecaching(ref_ptr<BaseSubrouteData> subrouteData);
|
||||
|
||||
@@ -288,8 +284,7 @@ private:
|
||||
void ScheduleOverlayCollecting();
|
||||
|
||||
void SearchInNonDisplaceableUserMarksLayer(ScreenBase const & modelView, DepthLayer layerId,
|
||||
m2::RectD const & selectionRect,
|
||||
dp::TOverlayContainer & result);
|
||||
m2::RectD const & selectionRect, dp::TOverlayContainer & result);
|
||||
|
||||
drape_ptr<gpu::ProgramManager> m_gpuProgramManager;
|
||||
|
||||
@@ -373,8 +368,7 @@ private:
|
||||
|
||||
struct FollowRouteData
|
||||
{
|
||||
FollowRouteData(int preferredZoomLevel, int preferredZoomLevelIn3d, bool enableAutoZoom,
|
||||
bool isArrowGlued)
|
||||
FollowRouteData(int preferredZoomLevel, int preferredZoomLevelIn3d, bool enableAutoZoom, bool isArrowGlued)
|
||||
: m_preferredZoomLevel(preferredZoomLevel)
|
||||
, m_preferredZoomLevelIn3d(preferredZoomLevelIn3d)
|
||||
, m_enableAutoZoom(enableAutoZoom)
|
||||
|
||||
@@ -27,21 +27,19 @@ int const kMinVisibleZoomLevel = 5;
|
||||
uint32_t const kAveragePointsCount = 512;
|
||||
|
||||
// Radius of circles depending on zoom levels.
|
||||
std::array<float, 20> const kRadiusInPixel =
|
||||
{
|
||||
// 1 2 3 4 5 6 7 8 9 10
|
||||
0.8f, 0.8f, 1.5f, 2.5f, 2.5f, 2.5f, 2.5f, 2.5f, 2.5f, 2.5f,
|
||||
//11 12 13 14 15 16 17 18 19 20
|
||||
2.5f, 2.5f, 2.5f, 2.5f, 3.0f, 4.0f, 4.5f, 4.5f, 5.0f, 5.5f
|
||||
};
|
||||
std::array<float, 20> const kRadiusInPixel = {
|
||||
// 1 2 3 4 5 6 7 8 9 10
|
||||
0.8f, 0.8f, 1.5f, 2.5f, 2.5f, 2.5f, 2.5f, 2.5f, 2.5f, 2.5f,
|
||||
// 11 12 13 14 15 16 17 18 19 20
|
||||
2.5f, 2.5f, 2.5f, 2.5f, 3.0f, 4.0f, 4.5f, 4.5f, 5.0f, 5.5f};
|
||||
|
||||
double const kHumanSpeed = 2.6; // meters per second
|
||||
double const kCarSpeed = 6.2; // meters per second
|
||||
double const kHumanSpeed = 2.6; // meters per second
|
||||
double const kCarSpeed = 6.2; // meters per second
|
||||
uint8_t const kMinDayAlpha = 90;
|
||||
uint8_t const kMaxDayAlpha = 144;
|
||||
uint8_t const kMinNightAlpha = 50;
|
||||
uint8_t const kMaxNightAlpha = 102;
|
||||
double const kUnknownDistanceTime = 5 * 60; // seconds
|
||||
double const kUnknownDistanceTime = 5 * 60; // seconds
|
||||
|
||||
double const kDistanceScalar = 0.4;
|
||||
|
||||
@@ -51,7 +49,7 @@ bool GpsPointsSortPredicate(GpsTrackPoint const & pt1, GpsTrackPoint const & pt2
|
||||
return pt1.m_id < pt2.m_id;
|
||||
}
|
||||
#endif
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
GpsTrackRenderer::GpsTrackRenderer(TRenderDataRequestFn const & dataRequestFn)
|
||||
: m_dataRequestFn(dataRequestFn)
|
||||
@@ -64,8 +62,7 @@ GpsTrackRenderer::GpsTrackRenderer(TRenderDataRequestFn const & dataRequestFn)
|
||||
m_handlesCache.reserve(8);
|
||||
}
|
||||
|
||||
void GpsTrackRenderer::AddRenderData(ref_ptr<dp::GraphicsContext> context,
|
||||
ref_ptr<gpu::ProgramManager> mng,
|
||||
void GpsTrackRenderer::AddRenderData(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng,
|
||||
drape_ptr<CirclesPackRenderData> && renderData)
|
||||
{
|
||||
drape_ptr<CirclesPackRenderData> data = std::move(renderData);
|
||||
@@ -84,19 +81,15 @@ void GpsTrackRenderer::ClearRenderData()
|
||||
m_needUpdate = true;
|
||||
}
|
||||
|
||||
void GpsTrackRenderer::UpdatePoints(std::vector<GpsTrackPoint> const & toAdd,
|
||||
std::vector<uint32_t> const & toRemove)
|
||||
void GpsTrackRenderer::UpdatePoints(std::vector<GpsTrackPoint> const & toAdd, std::vector<uint32_t> const & toRemove)
|
||||
{
|
||||
bool recreateSpline = false;
|
||||
if (!toRemove.empty())
|
||||
{
|
||||
size_t const szBefore = m_points.size();
|
||||
base::EraseIf(m_points, [&toRemove](GpsTrackPoint const & pt)
|
||||
{
|
||||
return base::IsExist(toRemove, pt.m_id);
|
||||
});
|
||||
base::EraseIf(m_points, [&toRemove](GpsTrackPoint const & pt) { return base::IsExist(toRemove, pt.m_id); });
|
||||
|
||||
if (szBefore > m_points.size()) // if removed any
|
||||
if (szBefore > m_points.size()) // if removed any
|
||||
{
|
||||
recreateSpline = true;
|
||||
m_needUpdate = true;
|
||||
@@ -111,13 +104,13 @@ void GpsTrackRenderer::UpdatePoints(std::vector<GpsTrackPoint> const & toAdd,
|
||||
m_needUpdate = true;
|
||||
}
|
||||
|
||||
if (recreateSpline) // Recreate Spline only if Remove (Clear) was invoked.
|
||||
if (recreateSpline) // Recreate Spline only if Remove (Clear) was invoked.
|
||||
{
|
||||
m_pointsSpline = m2::Spline(m_points.size());
|
||||
for (auto const & p : m_points)
|
||||
m_pointsSpline.AddPoint(p.m_point);
|
||||
}
|
||||
else // Simple append points otherwise.
|
||||
else // Simple append points otherwise.
|
||||
{
|
||||
for (auto const & p : toAdd)
|
||||
m_pointsSpline.AddPoint(p.m_point);
|
||||
@@ -133,8 +126,8 @@ size_t GpsTrackRenderer::GetAvailablePointsCount() const
|
||||
return pointsCount;
|
||||
}
|
||||
|
||||
dp::Color GpsTrackRenderer::CalculatePointColor(size_t pointIndex, m2::PointD const & curPoint,
|
||||
double lengthFromStart, double fullLength) const
|
||||
dp::Color GpsTrackRenderer::CalculatePointColor(size_t pointIndex, m2::PointD const & curPoint, double lengthFromStart,
|
||||
double fullLength) const
|
||||
{
|
||||
ASSERT_LESS(pointIndex, m_points.size(), ());
|
||||
if (pointIndex + 1 == m_points.size())
|
||||
@@ -158,8 +151,7 @@ dp::Color GpsTrackRenderer::CalculatePointColor(size_t pointIndex, m2::PointD co
|
||||
if ((end.m_timestamp - start.m_timestamp) > kUnknownDistanceTime)
|
||||
{
|
||||
dp::Color const color = df::GetColorConstant(df::kTrackUnknownDistanceColor);
|
||||
return dp::Color(color.GetRed(), color.GetGreen(), color.GetBlue(),
|
||||
static_cast<uint8_t>(alpha));
|
||||
return dp::Color(color.GetRed(), color.GetGreen(), color.GetBlue(), static_cast<uint8_t>(alpha));
|
||||
}
|
||||
|
||||
double const length = (end.m_point - start.m_point).Length();
|
||||
@@ -168,8 +160,7 @@ dp::Color GpsTrackRenderer::CalculatePointColor(size_t pointIndex, m2::PointD co
|
||||
|
||||
double const speed = std::max(start.m_speedMPS * (1.0 - td) + end.m_speedMPS * td, 0.0);
|
||||
dp::Color const color = GetColorBySpeed(speed);
|
||||
return dp::Color(color.GetRed(), color.GetGreen(), color.GetBlue(),
|
||||
static_cast<uint8_t>(alpha));
|
||||
return dp::Color(color.GetRed(), color.GetGreen(), color.GetBlue(), static_cast<uint8_t>(alpha));
|
||||
}
|
||||
|
||||
dp::Color GpsTrackRenderer::GetColorBySpeed(double speed) const
|
||||
@@ -244,14 +235,12 @@ void GpsTrackRenderer::RenderTrack(ref_ptr<dp::GraphicsContext> context, ref_ptr
|
||||
while (!it.BeginAgain())
|
||||
{
|
||||
m2::PointD const pt = it.m_pos;
|
||||
m2::RectD pointRect(pt.x - radiusMercator, pt.y - radiusMercator,
|
||||
pt.x + radiusMercator, pt.y + radiusMercator);
|
||||
m2::RectD pointRect(pt.x - radiusMercator, pt.y - radiusMercator, pt.x + radiusMercator, pt.y + radiusMercator);
|
||||
if (screen.ClipRect().IsIntersect(pointRect))
|
||||
{
|
||||
dp::Color const color = CalculatePointColor(it.GetIndex(), pt, lengthFromStart, fullLength);
|
||||
m2::PointD const convertedPt = MapShape::ConvertToLocal(pt, m_pivot, kShapeCoordScalar);
|
||||
m_handlesCache[cacheIndex].first->SetPoint(m_handlesCache[cacheIndex].second,
|
||||
convertedPt, m_radius, color);
|
||||
m_handlesCache[cacheIndex].first->SetPoint(m_handlesCache[cacheIndex].second, convertedPt, m_radius, color);
|
||||
m_handlesCache[cacheIndex].second++;
|
||||
if (m_handlesCache[cacheIndex].second >= m_handlesCache[cacheIndex].first->GetPointsCount())
|
||||
cacheIndex++;
|
||||
@@ -271,8 +260,8 @@ void GpsTrackRenderer::RenderTrack(ref_ptr<dp::GraphicsContext> context, ref_ptr
|
||||
for (size_t i = 0; i < m_points.size(); i++)
|
||||
{
|
||||
m2::PointD const convertedPt = MapShape::ConvertToLocal(m_points[i].m_point, m_pivot, kShapeCoordScalar);
|
||||
m_handlesCache[cacheIndex].first->SetPoint(m_handlesCache[cacheIndex].second, convertedPt,
|
||||
m_radius * 1.2, dp::Color(0, 0, 255, 255));
|
||||
m_handlesCache[cacheIndex].first->SetPoint(m_handlesCache[cacheIndex].second, convertedPt, m_radius * 1.2,
|
||||
dp::Color(0, 0, 255, 255));
|
||||
m_handlesCache[cacheIndex].second++;
|
||||
if (m_handlesCache[cacheIndex].second >= m_handlesCache[cacheIndex].first->GetPointsCount())
|
||||
cacheIndex++;
|
||||
@@ -308,10 +297,8 @@ void GpsTrackRenderer::RenderTrack(ref_ptr<dp::GraphicsContext> context, ref_ptr
|
||||
mng->GetParamsSetter()->Apply(context, program, params);
|
||||
|
||||
for (size_t i = 0; i < m_renderData.size(); i++)
|
||||
{
|
||||
if (m_handlesCache[i].second != 0)
|
||||
m_renderData[i]->m_bucket->Render(context, state.GetDrawAsLine());
|
||||
}
|
||||
}
|
||||
|
||||
void GpsTrackRenderer::Update()
|
||||
|
||||
@@ -27,11 +27,10 @@ public:
|
||||
void AddRenderData(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng,
|
||||
drape_ptr<CirclesPackRenderData> && renderData);
|
||||
|
||||
void UpdatePoints(std::vector<GpsTrackPoint> const & toAdd,
|
||||
std::vector<uint32_t> const & toRemove);
|
||||
void UpdatePoints(std::vector<GpsTrackPoint> const & toAdd, std::vector<uint32_t> const & toRemove);
|
||||
|
||||
void RenderTrack(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng,
|
||||
ScreenBase const & screen, int zoomLevel, FrameValues const & frameValues);
|
||||
void RenderTrack(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng, ScreenBase const & screen,
|
||||
int zoomLevel, FrameValues const & frameValues);
|
||||
|
||||
void Update();
|
||||
void Clear();
|
||||
@@ -39,8 +38,8 @@ public:
|
||||
|
||||
private:
|
||||
size_t GetAvailablePointsCount() const;
|
||||
dp::Color CalculatePointColor(size_t pointIndex, m2::PointD const & curPoint,
|
||||
double lengthFromStart, double fullLength) const;
|
||||
dp::Color CalculatePointColor(size_t pointIndex, m2::PointD const & curPoint, double lengthFromStart,
|
||||
double fullLength) const;
|
||||
dp::Color GetColorBySpeed(double speed) const;
|
||||
|
||||
TRenderDataRequestFn m_dataRequestFn;
|
||||
|
||||
@@ -19,7 +19,8 @@ namespace
|
||||
struct ChoosePositionMarkVertex
|
||||
{
|
||||
ChoosePositionMarkVertex(glsl::vec2 const & position, glsl::vec2 const & texCoord)
|
||||
: m_position(position), m_texCoord(texCoord)
|
||||
: m_position(position)
|
||||
, m_texCoord(texCoord)
|
||||
{}
|
||||
|
||||
glsl::vec2 m_position;
|
||||
@@ -31,8 +32,7 @@ class ChoosePositionMarkHandle : public Handle
|
||||
using TBase = Handle;
|
||||
|
||||
public:
|
||||
ChoosePositionMarkHandle(uint32_t id, m2::PointF const & pivot)
|
||||
: Handle(id, dp::Center, pivot)
|
||||
ChoosePositionMarkHandle(uint32_t id, m2::PointF const & pivot) : Handle(id, dp::Center, pivot)
|
||||
{
|
||||
SetIsVisible(true);
|
||||
}
|
||||
@@ -54,13 +54,11 @@ drape_ptr<ShapeRenderer> ChoosePositionMark::Draw(ref_ptr<dp::GraphicsContext> c
|
||||
m2::RectF const texRect = region.GetTexRect();
|
||||
|
||||
ASSERT_EQUAL(m_position.m_anchor, dp::Center, ());
|
||||
ChoosePositionMarkVertex vertexes[] =
|
||||
{
|
||||
ChoosePositionMarkVertex(glsl::vec2(-halfSize.x, halfSize.y), glsl::ToVec2(texRect.LeftTop())),
|
||||
ChoosePositionMarkVertex(glsl::vec2(-halfSize.x, -halfSize.y), glsl::ToVec2(texRect.LeftBottom())),
|
||||
ChoosePositionMarkVertex(glsl::vec2(halfSize.x, halfSize.y), glsl::ToVec2(texRect.RightTop())),
|
||||
ChoosePositionMarkVertex(glsl::vec2(halfSize.x, -halfSize.y), glsl::ToVec2(texRect.RightBottom()))
|
||||
};
|
||||
ChoosePositionMarkVertex vertexes[] = {
|
||||
ChoosePositionMarkVertex(glsl::vec2(-halfSize.x, halfSize.y), glsl::ToVec2(texRect.LeftTop())),
|
||||
ChoosePositionMarkVertex(glsl::vec2(-halfSize.x, -halfSize.y), glsl::ToVec2(texRect.LeftBottom())),
|
||||
ChoosePositionMarkVertex(glsl::vec2(halfSize.x, halfSize.y), glsl::ToVec2(texRect.RightTop())),
|
||||
ChoosePositionMarkVertex(glsl::vec2(halfSize.x, -halfSize.y), glsl::ToVec2(texRect.RightBottom()))};
|
||||
|
||||
auto state = df::CreateRenderState(gpu::Program::TexturingGui, df::DepthLayer::GuiLayer);
|
||||
state.SetColorTexture(region.GetTexture());
|
||||
@@ -86,8 +84,8 @@ drape_ptr<ShapeRenderer> ChoosePositionMark::Draw(ref_ptr<dp::GraphicsContext> c
|
||||
|
||||
provider.InitStream(0, info, make_ref(&vertexes));
|
||||
|
||||
drape_ptr<dp::OverlayHandle> handle = make_unique_dp<ChoosePositionMarkHandle>(
|
||||
GuiHandleChoosePositionMark, m_position.m_pixelPivot);
|
||||
drape_ptr<dp::OverlayHandle> handle =
|
||||
make_unique_dp<ChoosePositionMarkHandle>(GuiHandleChoosePositionMark, m_position.m_pixelPivot);
|
||||
|
||||
drape_ptr<ShapeRenderer> renderer = make_unique_dp<ShapeRenderer>();
|
||||
dp::Batcher batcher(dp::Batcher::IndexPerQuad, dp::Batcher::VertexPerQuad);
|
||||
|
||||
@@ -9,7 +9,6 @@ class ChoosePositionMark : public Shape
|
||||
public:
|
||||
explicit ChoosePositionMark(gui::Position const & position) : Shape(position) {}
|
||||
|
||||
drape_ptr<ShapeRenderer> Draw(ref_ptr<dp::GraphicsContext> context,
|
||||
ref_ptr<dp::TextureManager> tex) const;
|
||||
drape_ptr<ShapeRenderer> Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::TextureManager> tex) const;
|
||||
};
|
||||
} // namespace gui
|
||||
|
||||
@@ -22,9 +22,7 @@ namespace
|
||||
{
|
||||
struct CompassVertex
|
||||
{
|
||||
CompassVertex(glsl::vec2 const & position, glsl::vec2 const & texCoord)
|
||||
: m_position(position)
|
||||
, m_texCoord(texCoord)
|
||||
CompassVertex(glsl::vec2 const & position, glsl::vec2 const & texCoord) : m_position(position), m_texCoord(texCoord)
|
||||
{}
|
||||
|
||||
glsl::vec2 m_position;
|
||||
@@ -36,8 +34,7 @@ class CompassHandle : public TappableHandle
|
||||
using TBase = TappableHandle;
|
||||
|
||||
public:
|
||||
CompassHandle(uint32_t id, m2::PointF const & pivot, m2::PointF const & size,
|
||||
Shape::TTapHandler const & tapHandler)
|
||||
CompassHandle(uint32_t id, m2::PointF const & pivot, m2::PointF const & size, Shape::TTapHandler const & tapHandler)
|
||||
: TappableHandle(id, dp::Center, pivot, size)
|
||||
, m_tapHandler(tapHandler)
|
||||
, m_animation(false, 0.25)
|
||||
@@ -100,13 +97,10 @@ drape_ptr<ShapeRenderer> Compass::Draw(ref_ptr<dp::GraphicsContext> context, ref
|
||||
auto const texRect = region.GetTexRect();
|
||||
|
||||
ASSERT_EQUAL(m_position.m_anchor, dp::Center, ());
|
||||
CompassVertex vertexes[] =
|
||||
{
|
||||
CompassVertex(glsl::vec2(-halfSize.x, halfSize.y), glsl::ToVec2(texRect.LeftTop())),
|
||||
CompassVertex(glsl::vec2(-halfSize.x, -halfSize.y), glsl::ToVec2(texRect.LeftBottom())),
|
||||
CompassVertex(glsl::vec2(halfSize.x, halfSize.y), glsl::ToVec2(texRect.RightTop())),
|
||||
CompassVertex(glsl::vec2(halfSize.x, -halfSize.y), glsl::ToVec2(texRect.RightBottom()))
|
||||
};
|
||||
CompassVertex vertexes[] = {CompassVertex(glsl::vec2(-halfSize.x, halfSize.y), glsl::ToVec2(texRect.LeftTop())),
|
||||
CompassVertex(glsl::vec2(-halfSize.x, -halfSize.y), glsl::ToVec2(texRect.LeftBottom())),
|
||||
CompassVertex(glsl::vec2(halfSize.x, halfSize.y), glsl::ToVec2(texRect.RightTop())),
|
||||
CompassVertex(glsl::vec2(halfSize.x, -halfSize.y), glsl::ToVec2(texRect.RightBottom()))};
|
||||
|
||||
auto state = df::CreateRenderState(gpu::Program::TexturingGui, df::DepthLayer::GuiLayer);
|
||||
state.SetColorTexture(region.GetTexture());
|
||||
@@ -132,9 +126,8 @@ drape_ptr<ShapeRenderer> Compass::Draw(ref_ptr<dp::GraphicsContext> context, ref
|
||||
|
||||
provider.InitStream(0, info, make_ref(&vertexes));
|
||||
|
||||
drape_ptr<dp::OverlayHandle> handle = make_unique_dp<CompassHandle>(EGuiHandle::GuiHandleCompass,
|
||||
m_position.m_pixelPivot,
|
||||
region.GetPixelSize(), tapHandler);
|
||||
drape_ptr<dp::OverlayHandle> handle = make_unique_dp<CompassHandle>(
|
||||
EGuiHandle::GuiHandleCompass, m_position.m_pixelPivot, region.GetPixelSize(), tapHandler);
|
||||
|
||||
drape_ptr<ShapeRenderer> renderer = make_unique_dp<ShapeRenderer>();
|
||||
dp::Batcher batcher(dp::Batcher::IndexPerQuad, dp::Batcher::VertexPerQuad);
|
||||
|
||||
@@ -9,8 +9,7 @@ class Compass : public Shape
|
||||
public:
|
||||
explicit Compass(gui::Position const & position) : Shape(position) {}
|
||||
|
||||
drape_ptr<ShapeRenderer> Draw(ref_ptr<dp::GraphicsContext> context,
|
||||
ref_ptr<dp::TextureManager> tex,
|
||||
drape_ptr<ShapeRenderer> Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::TextureManager> tex,
|
||||
TTapHandler const & tapHandler) const;
|
||||
};
|
||||
} // namespace gui
|
||||
|
||||
@@ -20,8 +20,8 @@ class CopyrightHandle : public StaticLabelHandle
|
||||
using TBase = StaticLabelHandle;
|
||||
|
||||
public:
|
||||
CopyrightHandle(uint32_t id, ref_ptr<dp::TextureManager> textureManager,
|
||||
dp::Anchor anchor, m2::PointF const & pivot, dp::TGlyphs && glyphs)
|
||||
CopyrightHandle(uint32_t id, ref_ptr<dp::TextureManager> textureManager, dp::Anchor anchor, m2::PointF const & pivot,
|
||||
dp::TGlyphs && glyphs)
|
||||
: TBase(id, textureManager, anchor, pivot, std::move(glyphs))
|
||||
{
|
||||
SetIsVisible(true);
|
||||
@@ -43,8 +43,7 @@ public:
|
||||
|
||||
if (m_animation == nullptr)
|
||||
{
|
||||
m_animation = make_unique_dp<df::OpacityAnimation>(kCopyrightHideTime,
|
||||
kCopyrightVisibleTime, 1.0f, 0.0f);
|
||||
m_animation = make_unique_dp<df::OpacityAnimation>(kCopyrightHideTime, kCopyrightVisibleTime, 1.0f, 0.0f);
|
||||
}
|
||||
else if (m_animation->IsFinished())
|
||||
{
|
||||
@@ -61,37 +60,32 @@ private:
|
||||
};
|
||||
} // namespace
|
||||
|
||||
CopyrightLabel::CopyrightLabel(Position const & position)
|
||||
: TBase(position)
|
||||
{}
|
||||
CopyrightLabel::CopyrightLabel(Position const & position) : TBase(position) {}
|
||||
|
||||
drape_ptr<ShapeRenderer> CopyrightLabel::Draw(ref_ptr<dp::GraphicsContext> context,
|
||||
ref_ptr<dp::TextureManager> tex) const
|
||||
{
|
||||
StaticLabel::LabelResult result;
|
||||
auto glyphs = StaticLabel::CacheStaticText("Map data © OpenStreetMap", "", m_position.m_anchor,
|
||||
DrapeGui::GetGuiTextFont(), tex, result);
|
||||
DrapeGui::GetGuiTextFont(), tex, result);
|
||||
|
||||
dp::AttributeProvider provider(1 /*stream count*/, static_cast<uint32_t>(result.m_buffer.size()));
|
||||
provider.InitStream(0 /*stream index*/, StaticLabel::Vertex::GetBindingInfo(),
|
||||
make_ref(result.m_buffer.data()));
|
||||
provider.InitStream(0 /*stream index*/, StaticLabel::Vertex::GetBindingInfo(), make_ref(result.m_buffer.data()));
|
||||
|
||||
auto const vertexCount = static_cast<uint32_t>(result.m_buffer.size());
|
||||
ASSERT(vertexCount % dp::Batcher::VertexPerQuad == 0, ());
|
||||
auto const indexCount = dp::Batcher::IndexPerQuad * vertexCount / dp::Batcher::VertexPerQuad;
|
||||
|
||||
drape_ptr<dp::OverlayHandle> handle = make_unique_dp<CopyrightHandle>(GuiHandleCopyright,
|
||||
tex, m_position.m_anchor,
|
||||
m_position.m_pixelPivot,
|
||||
std::move(glyphs));
|
||||
drape_ptr<dp::OverlayHandle> handle = make_unique_dp<CopyrightHandle>(GuiHandleCopyright, tex, m_position.m_anchor,
|
||||
m_position.m_pixelPivot, std::move(glyphs));
|
||||
|
||||
drape_ptr<ShapeRenderer> renderer = make_unique_dp<ShapeRenderer>();
|
||||
dp::Batcher batcher(indexCount, vertexCount);
|
||||
batcher.SetBatcherHash(static_cast<uint64_t>(df::BatcherBucket::Default));
|
||||
using namespace std::placeholders;
|
||||
dp::SessionGuard guard(context, batcher, std::bind(&ShapeRenderer::AddShape, renderer.get(), _1, _2));
|
||||
batcher.InsertListOfStrip(context, result.m_state, make_ref(&provider),
|
||||
std::move(handle), dp::Batcher::VertexPerQuad);
|
||||
batcher.InsertListOfStrip(context, result.m_state, make_ref(&provider), std::move(handle),
|
||||
dp::Batcher::VertexPerQuad);
|
||||
|
||||
return renderer;
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ class DebugLabelHandle : public MutableLabelHandle
|
||||
using TBase = MutableLabelHandle;
|
||||
|
||||
public:
|
||||
DebugLabelHandle(uint32_t id, dp::Anchor anchor, m2::PointF const & pivot,
|
||||
ref_ptr<dp::TextureManager> tex, TUpdateDebugLabelFn const & onUpdateFn)
|
||||
DebugLabelHandle(uint32_t id, dp::Anchor anchor, m2::PointF const & pivot, ref_ptr<dp::TextureManager> tex,
|
||||
TUpdateDebugLabelFn const & onUpdateFn)
|
||||
: MutableLabelHandle(id, anchor, pivot)
|
||||
, m_onUpdateFn(onUpdateFn)
|
||||
{
|
||||
@@ -68,16 +68,14 @@ void DebugInfoLabels::AddLabel(ref_ptr<dp::TextureManager> tex, std::string cons
|
||||
#ifdef RENDER_DEBUG_INFO_LABELS
|
||||
uint32_t const id = GuiHandleDebugLabel + m_labelsCount;
|
||||
|
||||
params.m_handleCreator = [id, onUpdateFn, tex](dp::Anchor anchor, m2::PointF const & pivot) {
|
||||
return make_unique_dp<DebugLabelHandle>(id, anchor, pivot, tex, onUpdateFn);
|
||||
};
|
||||
params.m_handleCreator = [id, onUpdateFn, tex](dp::Anchor anchor, m2::PointF const & pivot)
|
||||
{ return make_unique_dp<DebugLabelHandle>(id, anchor, pivot, tex, onUpdateFn); };
|
||||
#endif
|
||||
m_labelsParams.push_back(params);
|
||||
++m_labelsCount;
|
||||
}
|
||||
|
||||
drape_ptr<ShapeRenderer> DebugInfoLabels::Draw(ref_ptr<dp::GraphicsContext> context,
|
||||
ref_ptr<dp::TextureManager> tex)
|
||||
drape_ptr<ShapeRenderer> DebugInfoLabels::Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::TextureManager> tex)
|
||||
{
|
||||
drape_ptr<ShapeRenderer> renderer = make_unique_dp<ShapeRenderer>();
|
||||
|
||||
@@ -86,8 +84,8 @@ drape_ptr<ShapeRenderer> DebugInfoLabels::Draw(ref_ptr<dp::GraphicsContext> cont
|
||||
for (auto & params : m_labelsParams)
|
||||
{
|
||||
params.m_pivot.y = pos.y;
|
||||
m2::PointF textSize = MutableLabelDrawer::Draw(context, params, tex,
|
||||
std::bind(&ShapeRenderer::AddShape, renderer.get(), _1, _2));
|
||||
m2::PointF textSize =
|
||||
MutableLabelDrawer::Draw(context, params, tex, std::bind(&ShapeRenderer::AddShape, renderer.get(), _1, _2));
|
||||
pos.y += 2 * textSize.y;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,8 @@ class DebugInfoLabels : public Shape
|
||||
public:
|
||||
explicit DebugInfoLabels(gui::Position const & position) : Shape(position) {}
|
||||
|
||||
void AddLabel(ref_ptr<dp::TextureManager> tex, std::string const & caption,
|
||||
TUpdateDebugLabelFn const & onUpdateFn);
|
||||
drape_ptr<ShapeRenderer> Draw(ref_ptr<dp::GraphicsContext> context,
|
||||
ref_ptr<dp::TextureManager> tex);
|
||||
void AddLabel(ref_ptr<dp::TextureManager> tex, std::string const & caption, TUpdateDebugLabelFn const & onUpdateFn);
|
||||
drape_ptr<ShapeRenderer> Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::TextureManager> tex);
|
||||
|
||||
private:
|
||||
std::vector<MutableLabelDrawer::Params> m_labelsParams;
|
||||
|
||||
@@ -15,9 +15,7 @@ struct DrapeGui::Impl
|
||||
RulerHelper m_rulerHelper;
|
||||
};
|
||||
|
||||
DrapeGui::DrapeGui()
|
||||
: m_impl(new Impl())
|
||||
{}
|
||||
DrapeGui::DrapeGui() : m_impl(new Impl()) {}
|
||||
|
||||
DrapeGui & DrapeGui::Instance()
|
||||
{
|
||||
@@ -69,7 +67,7 @@ void DrapeGui::ConnectOnCompassTappedHandler(Shape::TTapHandler const & handler)
|
||||
|
||||
void DrapeGui::CallOnCompassTappedHandler()
|
||||
{
|
||||
if(m_onCompassTappedHandler != nullptr)
|
||||
if (m_onCompassTappedHandler != nullptr)
|
||||
m_onCompassTappedHandler();
|
||||
}
|
||||
} // namespace gui
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
#include <array>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace gui
|
||||
{
|
||||
namespace
|
||||
{
|
||||
glsl::vec2 GetNormalsAndMask(dp::TextureManager::GlyphRegion const & glyph, float xOffset, float yOffset, float textRatio,
|
||||
std::array<glsl::vec2, 4> & normals, std::array<glsl::vec2, 4> & maskTexCoord)
|
||||
glsl::vec2 GetNormalsAndMask(dp::TextureManager::GlyphRegion const & glyph, float xOffset, float yOffset,
|
||||
float textRatio, std::array<glsl::vec2, 4> & normals,
|
||||
std::array<glsl::vec2, 4> & maskTexCoord)
|
||||
{
|
||||
m2::PointF const pixelSize = glyph.GetPixelSize() * textRatio;
|
||||
m2::RectF const & r = glyph.GetTexRect();
|
||||
@@ -109,14 +109,14 @@ StaticLabel::LabelResult::LabelResult()
|
||||
m_state.SetDepthTestEnabled(false);
|
||||
}
|
||||
|
||||
dp::TGlyphs StaticLabel::CacheStaticText(std::string const & text, char const * delimiters,
|
||||
dp::Anchor anchor, dp::FontDecl const & font,
|
||||
ref_ptr<dp::TextureManager> mng, LabelResult & result)
|
||||
dp::TGlyphs StaticLabel::CacheStaticText(std::string const & text, char const * delimiters, dp::Anchor anchor,
|
||||
dp::FontDecl const & font, ref_ptr<dp::TextureManager> mng,
|
||||
LabelResult & result)
|
||||
{
|
||||
ASSERT(!text.empty(), ());
|
||||
|
||||
auto const textRatio = font.m_size *
|
||||
static_cast<float>(df::VisualParams::Instance().GetVisualScale() / dp::kBaseFontSizePixels);
|
||||
auto const textRatio =
|
||||
font.m_size * static_cast<float>(df::VisualParams::Instance().GetVisualScale() / dp::kBaseFontSizePixels);
|
||||
|
||||
dp::TextureManager::TMultilineGlyphsBuffer buffers;
|
||||
auto const shapedLines = mng->ShapeMultilineText(dp::kBaseFontSizePixels, text, delimiters, buffers);
|
||||
@@ -132,10 +132,8 @@ dp::TGlyphs StaticLabel::CacheStaticText(std::string const & text, char const *
|
||||
|
||||
ref_ptr<dp::Texture> texture = buffers[0][0].GetTexture();
|
||||
for (dp::TextureManager::TGlyphsBuffer const & b : buffers)
|
||||
{
|
||||
for (dp::TextureManager::GlyphRegion const & reg : b)
|
||||
ASSERT(texture == reg.GetTexture(), ());
|
||||
}
|
||||
#endif
|
||||
|
||||
dp::TextureManager::ColorRegion color;
|
||||
@@ -174,7 +172,8 @@ dp::TGlyphs StaticLabel::CacheStaticText(std::string const & text, char const *
|
||||
std::array<glsl::vec2, 4> normals, maskTex;
|
||||
|
||||
dp::TextureManager::GlyphRegion const & glyph = regions[j];
|
||||
glsl::vec2 offsets = GetNormalsAndMask(glyph, glyphMetrics.m_xOffset, glyphMetrics.m_yOffset, textRatio, normals, maskTex);
|
||||
glsl::vec2 offsets =
|
||||
GetNormalsAndMask(glyph, glyphMetrics.m_xOffset, glyphMetrics.m_yOffset, textRatio, normals, maskTex);
|
||||
|
||||
glsl::vec3 position = glsl::vec3(0.0, 0.0, depth);
|
||||
|
||||
@@ -289,10 +288,7 @@ MutableLabel::PrecacheResult::PrecacheResult()
|
||||
m_state.SetDepthTestEnabled(false);
|
||||
}
|
||||
|
||||
MutableLabel::MutableLabel(dp::Anchor anchor)
|
||||
: m_anchor(anchor)
|
||||
{
|
||||
}
|
||||
MutableLabel::MutableLabel(dp::Anchor anchor) : m_anchor(anchor) {}
|
||||
|
||||
void MutableLabel::SetMaxLength(uint16_t maxLength)
|
||||
{
|
||||
@@ -313,7 +309,8 @@ void MutableLabel::Precache(PrecacheParams const & params, PrecacheResult & resu
|
||||
{
|
||||
SetMaxLength(static_cast<uint16_t>(params.m_maxLength));
|
||||
|
||||
m_textRatio = params.m_font.m_size * static_cast<float>(df::VisualParams::Instance().GetVisualScale()) / dp::kBaseFontSizePixels;
|
||||
m_textRatio = params.m_font.m_size * static_cast<float>(df::VisualParams::Instance().GetVisualScale()) /
|
||||
dp::kBaseFontSizePixels;
|
||||
|
||||
// TODO(AB): Is this shaping/precaching really needed if the text changes every frame?
|
||||
m_shapedText = mng->ShapeSingleTextLine(dp::kBaseFontSizePixels, params.m_alphabet, &m_glyphRegions);
|
||||
@@ -379,21 +376,22 @@ void MutableLabel::SetText(LabelResult & result, std::string text, ref_ptr<dp::T
|
||||
ASSERT_EQUAL(m_glyphRegions.size(), m_shapedText.m_glyphs.size(), ());
|
||||
for (size_t i = 0; i < m_glyphRegions.size(); ++i)
|
||||
{
|
||||
std::array<glsl::vec2, 4> normals, maskTex;
|
||||
dp::TextureManager::GlyphRegion const & glyph = m_glyphRegions[i];
|
||||
auto const & metrics = m_shapedText.m_glyphs[i];
|
||||
glsl::vec2 const offsets = GetNormalsAndMask(glyph, metrics.m_xOffset, metrics.m_yOffset, m_textRatio, normals, maskTex);
|
||||
std::array<glsl::vec2, 4> normals, maskTex;
|
||||
dp::TextureManager::GlyphRegion const & glyph = m_glyphRegions[i];
|
||||
auto const & metrics = m_shapedText.m_glyphs[i];
|
||||
glsl::vec2 const offsets =
|
||||
GetNormalsAndMask(glyph, metrics.m_xOffset, metrics.m_yOffset, m_textRatio, normals, maskTex);
|
||||
|
||||
ASSERT_EQUAL(normals.size(), maskTex.size(), ());
|
||||
ASSERT_EQUAL(normals.size(), maskTex.size(), ());
|
||||
|
||||
for (size_t i = 0; i < normals.size(); ++i)
|
||||
result.m_buffer.emplace_back(pen + normals[i], maskTex[i]);
|
||||
for (size_t i = 0; i < normals.size(); ++i)
|
||||
result.m_buffer.emplace_back(pen + normals[i], maskTex[i]);
|
||||
|
||||
float const advance = metrics.m_xAdvance * m_textRatio;
|
||||
length += advance + offsets.x;
|
||||
// TODO(AB): yAdvance is always zero for horizontal layouts.
|
||||
pen += glsl::vec2(advance, metrics.m_yAdvance * m_textRatio);
|
||||
maxHeight = std::max(maxHeight, offsets.y + glyph.GetPixelHeight() * m_textRatio);
|
||||
float const advance = metrics.m_xAdvance * m_textRatio;
|
||||
length += advance + offsets.x;
|
||||
// TODO(AB): yAdvance is always zero for horizontal layouts.
|
||||
pen += glsl::vec2(advance, metrics.m_yAdvance * m_textRatio);
|
||||
maxHeight = std::max(maxHeight, offsets.y + glyph.GetPixelHeight() * m_textRatio);
|
||||
}
|
||||
|
||||
glsl::vec2 anchorModifier = glsl::vec2(-length / 2.0f, maxHeight / 2.0f);
|
||||
@@ -494,8 +492,7 @@ void MutableLabelHandle::SetContent(std::string const & content)
|
||||
}
|
||||
|
||||
m2::PointF MutableLabelDrawer::Draw(ref_ptr<dp::GraphicsContext> context, Params const & params,
|
||||
ref_ptr<dp::TextureManager> mng,
|
||||
dp::Batcher::TFlushFn && flushFn)
|
||||
ref_ptr<dp::TextureManager> mng, dp::Batcher::TFlushFn && flushFn)
|
||||
{
|
||||
uint32_t const vertexCount = dp::Batcher::VertexPerQuad * params.m_maxLength;
|
||||
uint32_t const indexCount = dp::Batcher::IndexPerQuad * params.m_maxLength;
|
||||
@@ -526,16 +523,15 @@ m2::PointF MutableLabelDrawer::Draw(ref_ptr<dp::GraphicsContext> context, Params
|
||||
dp::Batcher batcher(indexCount, vertexCount);
|
||||
batcher.SetBatcherHash(static_cast<uint64_t>(df::BatcherBucket::Default));
|
||||
dp::SessionGuard const guard(context, batcher, std::move(flushFn));
|
||||
batcher.InsertListOfStrip(context, staticData.m_state, make_ref(&provider),
|
||||
std::move(handle), dp::Batcher::VertexPerQuad);
|
||||
batcher.InsertListOfStrip(context, staticData.m_state, make_ref(&provider), std::move(handle),
|
||||
dp::Batcher::VertexPerQuad);
|
||||
}
|
||||
|
||||
return staticData.m_maxPixelSize;
|
||||
}
|
||||
|
||||
StaticLabelHandle::StaticLabelHandle(uint32_t id, ref_ptr<dp::TextureManager> textureManager,
|
||||
dp::Anchor anchor, m2::PointF const & pivot,
|
||||
dp::TGlyphs && glyphs)
|
||||
StaticLabelHandle::StaticLabelHandle(uint32_t id, ref_ptr<dp::TextureManager> textureManager, dp::Anchor anchor,
|
||||
m2::PointF const & pivot, dp::TGlyphs && glyphs)
|
||||
: TBase(id, anchor, pivot)
|
||||
, m_glyphs(std::move(glyphs))
|
||||
, m_textureManager(std::move(textureManager))
|
||||
|
||||
@@ -23,8 +23,8 @@ public:
|
||||
struct Vertex
|
||||
{
|
||||
Vertex() = default;
|
||||
Vertex(glsl::vec3 const & pos, glsl::vec2 const & color, glsl::vec2 const & outline,
|
||||
glsl::vec2 const & normal, glsl::vec2 const & mask)
|
||||
Vertex(glsl::vec3 const & pos, glsl::vec2 const & color, glsl::vec2 const & outline, glsl::vec2 const & normal,
|
||||
glsl::vec2 const & mask)
|
||||
: m_position(pos)
|
||||
, m_colorTexCoord(color)
|
||||
, m_outlineColorTexCoord(outline)
|
||||
@@ -52,8 +52,7 @@ public:
|
||||
};
|
||||
|
||||
static dp::TGlyphs CacheStaticText(std::string const & text, char const * delim, dp::Anchor anchor,
|
||||
dp::FontDecl const & font, ref_ptr<dp::TextureManager> mng,
|
||||
LabelResult & result);
|
||||
dp::FontDecl const & font, ref_ptr<dp::TextureManager> mng, LabelResult & result);
|
||||
};
|
||||
|
||||
class MutableLabel
|
||||
@@ -62,8 +61,7 @@ public:
|
||||
struct StaticVertex
|
||||
{
|
||||
StaticVertex() = default;
|
||||
StaticVertex(glsl::vec3 const & position, glsl::vec2 const & color,
|
||||
glsl::vec2 const & outlineColor)
|
||||
StaticVertex(glsl::vec3 const & position, glsl::vec2 const & color, glsl::vec2 const & outlineColor)
|
||||
: m_position(position)
|
||||
, m_color(color)
|
||||
, m_outline(outlineColor)
|
||||
@@ -79,10 +77,7 @@ public:
|
||||
struct DynamicVertex
|
||||
{
|
||||
DynamicVertex() = default;
|
||||
DynamicVertex(glsl::vec2 const & normal, glsl::vec2 const & mask)
|
||||
: m_normal(normal)
|
||||
, m_maskTexCoord(mask)
|
||||
{}
|
||||
DynamicVertex(glsl::vec2 const & normal, glsl::vec2 const & mask) : m_normal(normal), m_maskTexCoord(mask) {}
|
||||
|
||||
static dp::BindingInfo const & GetBindingInfo();
|
||||
|
||||
@@ -114,8 +109,7 @@ public:
|
||||
m2::RectF m_boundRect;
|
||||
};
|
||||
|
||||
void Precache(PrecacheParams const & params, PrecacheResult & result,
|
||||
ref_ptr<dp::TextureManager> mng);
|
||||
void Precache(PrecacheParams const & params, PrecacheResult & result, ref_ptr<dp::TextureManager> mng);
|
||||
|
||||
void SetText(LabelResult & result, std::string text, ref_ptr<dp::TextureManager> mng);
|
||||
|
||||
@@ -141,8 +135,7 @@ class MutableLabelHandle : public Handle
|
||||
public:
|
||||
MutableLabelHandle(uint32_t id, dp::Anchor anchor, m2::PointF const & pivot);
|
||||
|
||||
MutableLabelHandle(uint32_t id, dp::Anchor anchor, m2::PointF const & pivot,
|
||||
ref_ptr<dp::TextureManager> textures);
|
||||
MutableLabelHandle(uint32_t id, dp::Anchor anchor, m2::PointF const & pivot, ref_ptr<dp::TextureManager> textures);
|
||||
|
||||
void GetAttributeMutation(ref_ptr<dp::AttributeBufferMutator> mutator) const override;
|
||||
|
||||
@@ -180,8 +173,8 @@ public:
|
||||
};
|
||||
|
||||
// Return maximum pixel size.
|
||||
static m2::PointF Draw(ref_ptr<dp::GraphicsContext> context, Params const & params,
|
||||
ref_ptr<dp::TextureManager> mng, dp::Batcher::TFlushFn && flushFn);
|
||||
static m2::PointF Draw(ref_ptr<dp::GraphicsContext> context, Params const & params, ref_ptr<dp::TextureManager> mng,
|
||||
dp::Batcher::TFlushFn && flushFn);
|
||||
};
|
||||
|
||||
class StaticLabelHandle : public Handle
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "drape_frontend/gui/layer_render.hpp"
|
||||
#include "drape_frontend/gui/choose_position_mark.hpp"
|
||||
#include "drape_frontend/gui/compass.hpp"
|
||||
#include "drape_frontend/gui/copyright_label.hpp"
|
||||
#include "drape_frontend/gui/debug_label.hpp"
|
||||
#include "drape_frontend/gui/drape_gui.hpp"
|
||||
#include "drape_frontend/gui/gui_text.hpp"
|
||||
#include "drape_frontend/gui/layer_render.hpp"
|
||||
#include "drape_frontend/gui/ruler.hpp"
|
||||
#include "drape_frontend/gui/ruler_helper.hpp"
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
#include "base/stl_helpers.hpp"
|
||||
|
||||
#include <ios>
|
||||
#include <functional>
|
||||
#include <ios>
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
|
||||
@@ -39,8 +39,8 @@ void LayerRenderer::Build(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::Pro
|
||||
r.second->Build(context, mng);
|
||||
}
|
||||
|
||||
void LayerRenderer::Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng,
|
||||
bool routingActive, ScreenBase const & screen)
|
||||
void LayerRenderer::Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng, bool routingActive,
|
||||
ScreenBase const & screen)
|
||||
{
|
||||
if (HasWidget(gui::WIDGET_RULER))
|
||||
{
|
||||
@@ -157,8 +157,10 @@ namespace
|
||||
class ScaleFpsLabelHandle : public MutableLabelHandle
|
||||
{
|
||||
using TBase = MutableLabelHandle;
|
||||
|
||||
public:
|
||||
ScaleFpsLabelHandle(uint32_t id, ref_ptr<dp::TextureManager> textures, std::string const & apiLabel, Position const & position)
|
||||
ScaleFpsLabelHandle(uint32_t id, ref_ptr<dp::TextureManager> textures, std::string const & apiLabel,
|
||||
Position const & position)
|
||||
: TBase(id, position.m_anchor, position.m_pixelPivot, textures)
|
||||
, m_apiLabel(apiLabel)
|
||||
{
|
||||
@@ -198,9 +200,8 @@ drape_ptr<LayerRenderer> LayerCacher::RecacheWidgets(ref_ptr<dp::GraphicsContext
|
||||
TWidgetsInitInfo const & initInfo,
|
||||
ref_ptr<dp::TextureManager> textures)
|
||||
{
|
||||
using TCacheShape = std::function<void(ref_ptr<dp::GraphicsContext>, Position anchor,
|
||||
ref_ptr<LayerRenderer> renderer,
|
||||
ref_ptr<dp::TextureManager> textures)>;
|
||||
using TCacheShape = std::function<void(ref_ptr<dp::GraphicsContext>, Position anchor, ref_ptr<LayerRenderer> renderer,
|
||||
ref_ptr<dp::TextureManager> textures)>;
|
||||
static std::map<EWidget, TCacheShape> cacheFunctions{
|
||||
{WIDGET_COMPASS, std::bind(&LayerCacher::CacheCompass, this, _1, _2, _3, _4)},
|
||||
{WIDGET_RULER, std::bind(&LayerCacher::CacheRuler, this, _1, _2, _3, _4)},
|
||||
@@ -246,8 +247,8 @@ drape_ptr<LayerRenderer> LayerCacher::RecacheDebugLabels(ref_ptr<dp::GraphicsCon
|
||||
auto const vs = static_cast<float>(df::VisualParams::Instance().GetVisualScale());
|
||||
DebugInfoLabels debugLabels = DebugInfoLabels(Position(m2::PointF(10.0f * vs, 50.0f * vs), dp::Center));
|
||||
|
||||
debugLabels.AddLabel(textures, "visible: km2, readed: km2, ratio:",
|
||||
[](ScreenBase const & screen, string & content) -> bool
|
||||
debugLabels.AddLabel(textures,
|
||||
"visible: km2, readed: km2, ratio:", [](ScreenBase const & screen, string & content) -> bool
|
||||
{
|
||||
double const sizeX = screen.PixelRectIn3d().SizeX();
|
||||
double const sizeY = screen.PixelRectIn3d().SizeY();
|
||||
@@ -267,12 +268,10 @@ drape_ptr<LayerRenderer> LayerCacher::RecacheDebugLabels(ref_ptr<dp::GraphicsCon
|
||||
m2::PointD const p2_2d = screen.PtoG(m2::PointD(sizeX_2d, sizeY_2d));
|
||||
m2::PointD const p3_2d = screen.PtoG(m2::PointD(sizeX_2d, 0.0));
|
||||
|
||||
double const areaGTotal = mercator::AreaOnEarth(p0_2d, p1_2d, p2_2d) +
|
||||
mercator::AreaOnEarth(p2_2d, p3_2d, p0_2d);
|
||||
double const areaGTotal = mercator::AreaOnEarth(p0_2d, p1_2d, p2_2d) + mercator::AreaOnEarth(p2_2d, p3_2d, p0_2d);
|
||||
|
||||
std::ostringstream out;
|
||||
out << std::fixed << std::setprecision(2)
|
||||
<< "visible: " << areaG / 1000000.0 << " km2"
|
||||
out << std::fixed << std::setprecision(2) << "visible: " << areaG / 1000000.0 << " km2"
|
||||
<< ", readed: " << areaGTotal / 1000000.0 << " km2"
|
||||
<< ", ratio: " << areaGTotal / areaG;
|
||||
content.assign(out.str());
|
||||
@@ -289,36 +288,30 @@ drape_ptr<LayerRenderer> LayerCacher::RecacheDebugLabels(ref_ptr<dp::GraphicsCon
|
||||
double const scale = distanceG / screen.PixelRect().SizeX();
|
||||
|
||||
std::ostringstream out;
|
||||
out << std::fixed << std::setprecision(2)
|
||||
<< "scale2d: " << scale << " m/px"
|
||||
out << std::fixed << std::setprecision(2) << "scale2d: " << scale << " m/px"
|
||||
<< ", scale2d * vs: " << scale * vs << " m/px";
|
||||
content.assign(out.str());
|
||||
return true;
|
||||
});
|
||||
|
||||
debugLabels.AddLabel(textures, "distance: m",
|
||||
[](ScreenBase const & screen, string & content) -> bool
|
||||
debugLabels.AddLabel(textures, "distance: m", [](ScreenBase const & screen, string & content) -> bool
|
||||
{
|
||||
double const sizeX = screen.PixelRectIn3d().SizeX();
|
||||
double const sizeY = screen.PixelRectIn3d().SizeY();
|
||||
|
||||
double const distance = mercator::DistanceOnEarth(
|
||||
screen.PtoG(screen.P3dtoP(m2::PointD(sizeX / 2.0, 0.0))),
|
||||
screen.PtoG(screen.P3dtoP(m2::PointD(sizeX / 2.0, sizeY))));
|
||||
double const distance = mercator::DistanceOnEarth(screen.PtoG(screen.P3dtoP(m2::PointD(sizeX / 2.0, 0.0))),
|
||||
screen.PtoG(screen.P3dtoP(m2::PointD(sizeX / 2.0, sizeY))));
|
||||
|
||||
std::ostringstream out;
|
||||
out << std::fixed << std::setprecision(2)
|
||||
<< "distance: " << distance << " m";
|
||||
out << std::fixed << std::setprecision(2) << "distance: " << distance << " m";
|
||||
content.assign(out.str());
|
||||
return true;
|
||||
});
|
||||
|
||||
debugLabels.AddLabel(textures, "angle: ",
|
||||
[](ScreenBase const & screen, string & content) -> bool
|
||||
debugLabels.AddLabel(textures, "angle: ", [](ScreenBase const & screen, string & content) -> bool
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << std::fixed << std::setprecision(2)
|
||||
<< "angle: " << screen.GetRotationAngle() * 180.0 / math::pi;
|
||||
out << std::fixed << std::setprecision(2) << "angle: " << screen.GetRotationAngle() * 180.0 / math::pi;
|
||||
content.assign(out.str());
|
||||
return true;
|
||||
});
|
||||
@@ -336,8 +329,8 @@ void LayerCacher::CacheCompass(ref_ptr<dp::GraphicsContext> context, Position co
|
||||
ref_ptr<LayerRenderer> renderer, ref_ptr<dp::TextureManager> textures)
|
||||
{
|
||||
Compass compass = Compass(position);
|
||||
drape_ptr<ShapeRenderer> shape = compass.Draw(context, textures,
|
||||
std::bind(&DrapeGui::CallOnCompassTappedHandler, &DrapeGui::Instance()));
|
||||
drape_ptr<ShapeRenderer> shape =
|
||||
compass.Draw(context, textures, std::bind(&DrapeGui::CallOnCompassTappedHandler, &DrapeGui::Instance()));
|
||||
|
||||
renderer->AddShapeRenderer(WIDGET_COMPASS, std::move(shape));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "drape_frontend/gui/skin.hpp"
|
||||
#include "drape_frontend/gui/shape.hpp"
|
||||
#include "drape_frontend/gui/skin.hpp"
|
||||
|
||||
#include "shaders/program_manager.hpp"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
namespace dp
|
||||
{
|
||||
class GraphicsContext;
|
||||
class GraphicsContext;
|
||||
} // namespace dp
|
||||
|
||||
namespace gui
|
||||
@@ -57,8 +57,7 @@ private:
|
||||
class LayerCacher
|
||||
{
|
||||
public:
|
||||
drape_ptr<LayerRenderer> RecacheWidgets(ref_ptr<dp::GraphicsContext> context,
|
||||
TWidgetsInitInfo const & initInfo,
|
||||
drape_ptr<LayerRenderer> RecacheWidgets(ref_ptr<dp::GraphicsContext> context, TWidgetsInitInfo const & initInfo,
|
||||
ref_ptr<dp::TextureManager> textures);
|
||||
drape_ptr<LayerRenderer> RecacheChoosePositionMark(ref_ptr<dp::GraphicsContext> context,
|
||||
ref_ptr<dp::TextureManager> textures);
|
||||
@@ -69,15 +68,15 @@ public:
|
||||
#endif
|
||||
|
||||
private:
|
||||
void CacheCompass(ref_ptr<dp::GraphicsContext> context, Position const & position,
|
||||
ref_ptr<LayerRenderer> renderer, ref_ptr<dp::TextureManager> textures);
|
||||
void CacheRuler(ref_ptr<dp::GraphicsContext> context, Position const & position,
|
||||
ref_ptr<LayerRenderer> renderer, ref_ptr<dp::TextureManager> textures);
|
||||
void CacheCopyright(ref_ptr<dp::GraphicsContext> context, Position const & position,
|
||||
ref_ptr<LayerRenderer> renderer, ref_ptr<dp::TextureManager> textures);
|
||||
void CacheCompass(ref_ptr<dp::GraphicsContext> context, Position const & position, ref_ptr<LayerRenderer> renderer,
|
||||
ref_ptr<dp::TextureManager> textures);
|
||||
void CacheRuler(ref_ptr<dp::GraphicsContext> context, Position const & position, ref_ptr<LayerRenderer> renderer,
|
||||
ref_ptr<dp::TextureManager> textures);
|
||||
void CacheCopyright(ref_ptr<dp::GraphicsContext> context, Position const & position, ref_ptr<LayerRenderer> renderer,
|
||||
ref_ptr<dp::TextureManager> textures);
|
||||
void CacheScaleFpsLabel(ref_ptr<dp::GraphicsContext> context, Position const & position,
|
||||
ref_ptr<LayerRenderer> renderer, ref_ptr<dp::TextureManager> textures);
|
||||
void CacheWatermark(ref_ptr<dp::GraphicsContext> context, Position const & position,
|
||||
ref_ptr<LayerRenderer> renderer, ref_ptr<dp::TextureManager> textures);
|
||||
void CacheWatermark(ref_ptr<dp::GraphicsContext> context, Position const & position, ref_ptr<LayerRenderer> renderer,
|
||||
ref_ptr<dp::TextureManager> textures);
|
||||
};
|
||||
} // namespace gui
|
||||
|
||||
@@ -38,12 +38,12 @@ dp::BindingInfo GetBindingInfo()
|
||||
uint8_t offset = 0;
|
||||
offset += dp::FillDecl<glsl::vec2, RulerVertex>(0, "a_position", info, offset);
|
||||
offset += dp::FillDecl<glsl::vec2, RulerVertex>(1, "a_normal", info, offset);
|
||||
/*offset += */dp::FillDecl<glsl::vec2, RulerVertex>(2, "a_colorTexCoords", info, offset);
|
||||
/*offset += */ dp::FillDecl<glsl::vec2, RulerVertex>(2, "a_colorTexCoords", info, offset);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
template<typename TBase>
|
||||
template <typename TBase>
|
||||
class BaseRulerHandle : public TBase
|
||||
{
|
||||
public:
|
||||
@@ -65,21 +65,18 @@ public:
|
||||
m_animation.HideAnimated();
|
||||
m_isVisibleAtEnd = false;
|
||||
}
|
||||
else
|
||||
else if (helper.IsTextDirty())
|
||||
{
|
||||
if (helper.IsTextDirty())
|
||||
m_isAppearing = !m_isAppearing;
|
||||
if (m_isAppearing)
|
||||
{
|
||||
m_isAppearing = !m_isAppearing;
|
||||
if (m_isAppearing)
|
||||
{
|
||||
m_animation.ShowAnimated();
|
||||
m_isVisibleAtEnd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_animation.HideAnimated();
|
||||
m_isVisibleAtEnd = false;
|
||||
}
|
||||
m_animation.ShowAnimated();
|
||||
m_isVisibleAtEnd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_animation.HideAnimated();
|
||||
m_isVisibleAtEnd = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,8 +128,8 @@ class RulerTextHandle : public BaseRulerHandle<MutableLabelHandle>
|
||||
using TBase = BaseRulerHandle<MutableLabelHandle>;
|
||||
|
||||
public:
|
||||
RulerTextHandle(uint32_t id, dp::Anchor anchor, m2::PointF const & pivot,
|
||||
bool isAppearing, ref_ptr<dp::TextureManager> textures)
|
||||
RulerTextHandle(uint32_t id, dp::Anchor anchor, m2::PointF const & pivot, bool isAppearing,
|
||||
ref_ptr<dp::TextureManager> textures)
|
||||
: TBase(id, anchor, pivot, isAppearing)
|
||||
, m_firstUpdate(true)
|
||||
{
|
||||
@@ -192,10 +189,9 @@ void Ruler::DrawRuler(ref_ptr<dp::GraphicsContext> context, ShapeControl & contr
|
||||
glsl::vec2 texCoord = glsl::ToVec2(reg.GetTexRect().Center());
|
||||
float const h = RulerHelper::GetRulerHalfHeight();
|
||||
|
||||
glsl::vec2 normals[] =
|
||||
{
|
||||
glsl::vec2(-1.0, 0.0),
|
||||
glsl::vec2(1.0, 0.0),
|
||||
glsl::vec2 normals[] = {
|
||||
glsl::vec2(-1.0, 0.0),
|
||||
glsl::vec2(1.0, 0.0),
|
||||
};
|
||||
|
||||
dp::Anchor anchor = m_position.m_anchor;
|
||||
@@ -221,13 +217,12 @@ void Ruler::DrawRuler(ref_ptr<dp::GraphicsContext> context, ShapeControl & contr
|
||||
batcher.SetBatcherHash(static_cast<uint64_t>(df::BatcherBucket::Default));
|
||||
dp::SessionGuard guard(context, batcher, std::bind(&ShapeControl::AddShape, &control, _1, _2));
|
||||
batcher.InsertTriangleStrip(context, state, make_ref(&provider),
|
||||
make_unique_dp<RulerHandle>(EGuiHandle::GuiHandleRuler,
|
||||
m_position.m_anchor, m_position.m_pixelPivot, isAppearing));
|
||||
make_unique_dp<RulerHandle>(EGuiHandle::GuiHandleRuler, m_position.m_anchor,
|
||||
m_position.m_pixelPivot, isAppearing));
|
||||
}
|
||||
}
|
||||
|
||||
void Ruler::DrawText(ref_ptr<dp::GraphicsContext> context,
|
||||
ShapeControl & control, ref_ptr<dp::TextureManager> tex,
|
||||
void Ruler::DrawText(ref_ptr<dp::GraphicsContext> context, ShapeControl & control, ref_ptr<dp::TextureManager> tex,
|
||||
bool isAppearing) const
|
||||
{
|
||||
std::string alphabet;
|
||||
@@ -240,10 +235,8 @@ void Ruler::DrawText(ref_ptr<dp::GraphicsContext> context,
|
||||
params.m_maxLength = maxTextLength;
|
||||
params.m_font = DrapeGui::GetGuiTextFont();
|
||||
params.m_pivot = m_position.m_pixelPivot + m2::PointF(0.0f, RulerHelper::GetVerticalTextOffset());
|
||||
params.m_handleCreator = [isAppearing, tex](dp::Anchor anchor, m2::PointF const & pivot) {
|
||||
return make_unique_dp<RulerTextHandle>(EGuiHandle::GuiHandleRulerLabel, anchor, pivot,
|
||||
isAppearing, tex);
|
||||
};
|
||||
params.m_handleCreator = [isAppearing, tex](dp::Anchor anchor, m2::PointF const & pivot)
|
||||
{ return make_unique_dp<RulerTextHandle>(EGuiHandle::GuiHandleRulerLabel, anchor, pivot, isAppearing, tex); };
|
||||
|
||||
MutableLabelDrawer::Draw(context, params, tex, std::bind(&ShapeControl::AddShape, &control, _1, _2));
|
||||
}
|
||||
|
||||
@@ -7,15 +7,13 @@ namespace gui
|
||||
class Ruler : public Shape
|
||||
{
|
||||
public:
|
||||
explicit Ruler(Position const & position)
|
||||
: Shape(position)
|
||||
{}
|
||||
explicit Ruler(Position const & position) : Shape(position) {}
|
||||
drape_ptr<ShapeRenderer> Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::TextureManager> tex) const;
|
||||
|
||||
private:
|
||||
void DrawRuler(ref_ptr<dp::GraphicsContext> context, ShapeControl & control,
|
||||
ref_ptr<dp::TextureManager> tex, bool isAppearing) const;
|
||||
void DrawText(ref_ptr<dp::GraphicsContext> context, ShapeControl & control,
|
||||
ref_ptr<dp::TextureManager> tex, bool isAppearing) const;
|
||||
void DrawRuler(ref_ptr<dp::GraphicsContext> context, ShapeControl & control, ref_ptr<dp::TextureManager> tex,
|
||||
bool isAppearing) const;
|
||||
void DrawText(ref_ptr<dp::GraphicsContext> context, ShapeControl & control, ref_ptr<dp::TextureManager> tex,
|
||||
bool isAppearing) const;
|
||||
};
|
||||
} // namespace gui
|
||||
|
||||
@@ -37,66 +37,24 @@ struct UnitValue
|
||||
|
||||
// TODO: Localize these strings.
|
||||
UnitValue constexpr g_arrFeets[] = {
|
||||
{ "10 ft", 10 },
|
||||
{ "20 ft", 20 },
|
||||
{ "50 ft", 50 },
|
||||
{ "100 ft", 100 },
|
||||
{ "200 ft", 200 },
|
||||
{ "0.1 mi", 528 },
|
||||
{ "0.2 mi", 528 * 2 },
|
||||
{ "0.5 mi", 528 * 5 },
|
||||
{ "1 mi", 5280 },
|
||||
{ "2 mi", 2 * 5280 },
|
||||
{ "5 mi", 5 * 5280 },
|
||||
{ "10 mi", 10 * 5280 },
|
||||
{ "20 mi", 20 * 5280 },
|
||||
{ "50 mi", 50 * 5280 },
|
||||
{ "100 mi", 100 * 5280 },
|
||||
{ "200 mi", 200 * 5280 },
|
||||
{ "500 mi", 500 * 5280 }
|
||||
};
|
||||
{"10 ft", 10}, {"20 ft", 20}, {"50 ft", 50}, {"100 ft", 100}, {"200 ft", 200},
|
||||
{"0.1 mi", 528}, {"0.2 mi", 528 * 2}, {"0.5 mi", 528 * 5}, {"1 mi", 5280}, {"2 mi", 2 * 5280},
|
||||
{"5 mi", 5 * 5280}, {"10 mi", 10 * 5280}, {"20 mi", 20 * 5280}, {"50 mi", 50 * 5280}, {"100 mi", 100 * 5280},
|
||||
{"200 mi", 200 * 5280}, {"500 mi", 500 * 5280}};
|
||||
|
||||
UnitValue constexpr g_arrYards[] = {
|
||||
{ "50 yd", 50 },
|
||||
{ "100 yd", 100 },
|
||||
{ "200 yd", 200 },
|
||||
{ "500 yd", 500 },
|
||||
{ "0.5 mi", 1760 / 2 },
|
||||
{ "1 mi", 1760 },
|
||||
{ "2 mi", 2 * 1760 },
|
||||
{ "5 mi", 5 * 1760 },
|
||||
{ "10 mi", 10 * 1760 },
|
||||
{ "20 mi", 20 * 1760 },
|
||||
{ "50 mi", 50 * 1760 },
|
||||
{ "100 mi", 100 * 1760 },
|
||||
{ "200 mi", 200 * 1760 },
|
||||
{ "500 mi", 500 * 1760 }
|
||||
};
|
||||
{"50 yd", 50}, {"100 yd", 100}, {"200 yd", 200}, {"500 yd", 500}, {"0.5 mi", 1760 / 2},
|
||||
{"1 mi", 1760}, {"2 mi", 2 * 1760}, {"5 mi", 5 * 1760}, {"10 mi", 10 * 1760}, {"20 mi", 20 * 1760},
|
||||
{"50 mi", 50 * 1760}, {"100 mi", 100 * 1760}, {"200 mi", 200 * 1760}, {"500 mi", 500 * 1760}};
|
||||
|
||||
// TODO: fix ruler text to the current zoom level, i.e. make it 100m for z16 always
|
||||
// (ruler length will vary still). It'll make debugging and user support easier as
|
||||
// we'll be able to tell zoom level of a screenshot by looking at the ruler.
|
||||
UnitValue constexpr g_arrMeters[] = {
|
||||
{ "1 m", 1 },
|
||||
{ "2 m", 2 },
|
||||
{ "5 m", 5 },
|
||||
{ "10 m", 10 },
|
||||
{ "20 m", 20 },
|
||||
{ "50 m", 50 },
|
||||
{ "100 m", 100 },
|
||||
{ "200 m", 200 },
|
||||
{ "500 m", 500 },
|
||||
{ "1 km", 1000 },
|
||||
{ "2 km", 2000 },
|
||||
{ "5 km", 5000 },
|
||||
{ "10 km", 10000 },
|
||||
{ "20 km", 20000 },
|
||||
{ "50 km", 50000 },
|
||||
{ "100 km", 100000 },
|
||||
{ "200 km", 200000 },
|
||||
{ "500 km", 500000 },
|
||||
{ "1000 km", 1000000 }
|
||||
};
|
||||
UnitValue constexpr g_arrMeters[] = {{"1 m", 1}, {"2 m", 2}, {"5 m", 5}, {"10 m", 10},
|
||||
{"20 m", 20}, {"50 m", 50}, {"100 m", 100}, {"200 m", 200},
|
||||
{"500 m", 500}, {"1 km", 1000}, {"2 km", 2000}, {"5 km", 5000},
|
||||
{"10 km", 10000}, {"20 km", 20000}, {"50 km", 50000}, {"100 km", 100000},
|
||||
{"200 km", 200000}, {"500 km", 500000}, {"1000 km", 1000000}};
|
||||
|
||||
double Identity(double val)
|
||||
{
|
||||
@@ -138,11 +96,8 @@ void RulerHelper::Update(ScreenBase const & screen)
|
||||
}
|
||||
|
||||
int drawScale = df::GetDrawTileScale(screen);
|
||||
if (m_currentDrawScale < kVisibleRulerBottomScale &&
|
||||
drawScale >= kVisibleRulerBottomScale)
|
||||
{
|
||||
if (m_currentDrawScale < kVisibleRulerBottomScale && drawScale >= kVisibleRulerBottomScale)
|
||||
SetTextDirty();
|
||||
}
|
||||
|
||||
m_currentDrawScale = drawScale;
|
||||
}
|
||||
@@ -217,13 +172,10 @@ void RulerHelper::GetTextInitInfo(std::string & alphabet, uint32_t & size)
|
||||
std::for_each(std::begin(g_arrMeters), std::end(g_arrMeters), functor);
|
||||
std::for_each(std::begin(g_arrYards), std::end(g_arrYards), functor);
|
||||
|
||||
std::for_each(begin(symbols), end(symbols), [&alphabet](char c)
|
||||
{
|
||||
alphabet.push_back(c);
|
||||
});
|
||||
std::for_each(begin(symbols), end(symbols), [&alphabet](char c) { alphabet.push_back(c); });
|
||||
alphabet.append("<>");
|
||||
|
||||
size = static_cast<uint32_t>(result) + 2; // add 2 char for symbols "< " and "> ".
|
||||
size = static_cast<uint32_t>(result) + 2; // add 2 char for symbols "< " and "> ".
|
||||
}
|
||||
|
||||
double RulerHelper::CalcMetersDiff(double value)
|
||||
@@ -251,10 +203,10 @@ double RulerHelper::CalcMetersDiff(double value)
|
||||
m_rulerText = std::string("< ") + arrU[0].m_s;
|
||||
result = kMinMetersWidth - 1.0;
|
||||
}
|
||||
else if (arrU[count-1].m_i <= v)
|
||||
else if (arrU[count - 1].m_i <= v)
|
||||
{
|
||||
m_rangeIndex = kMaxUnitValue;
|
||||
m_rulerText = std::string("> ") + arrU[count-1].m_s;
|
||||
m_rulerText = std::string("> ") + arrU[count - 1].m_s;
|
||||
result = kMaxMetersWidth + 1.0;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -16,10 +16,7 @@ public:
|
||||
return static_cast<uint32_t>(1.0 / m_frameTime);
|
||||
}
|
||||
|
||||
bool IsPaused() const
|
||||
{
|
||||
return m_isPaused;
|
||||
}
|
||||
bool IsPaused() const { return m_isPaused; }
|
||||
|
||||
void SetFrameTime(double frameTime, bool isActiveFrame)
|
||||
{
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
namespace gui
|
||||
{
|
||||
Handle::Handle(uint32_t id, dp::Anchor anchor, m2::PointF const & pivot)
|
||||
: dp::OverlayHandle(dp::OverlayID(FeatureID(MwmSet::MwmId{}, id)), anchor, 0 /* priority */,
|
||||
1 /* minVisibleScale */, false /* isBillboard */)
|
||||
: dp::OverlayHandle(dp::OverlayID(FeatureID(MwmSet::MwmId{}, id)), anchor, 0 /* priority */, 1 /* minVisibleScale */,
|
||||
false /* isBillboard */)
|
||||
, m_pivot(glsl::ToVec2(pivot))
|
||||
{}
|
||||
|
||||
@@ -46,8 +46,7 @@ m2::RectD Handle::GetPixelRect(ScreenBase const & screen, bool perspective) cons
|
||||
return {};
|
||||
}
|
||||
|
||||
void Handle::GetPixelShape(ScreenBase const & screen, bool perspective,
|
||||
dp::OverlayHandle::Rects & rects) const
|
||||
void Handle::GetPixelShape(ScreenBase const & screen, bool perspective, dp::OverlayHandle::Rects & rects) const
|
||||
{
|
||||
// There is no need to check intersection of gui elements.
|
||||
UNUSED_VALUE(screen);
|
||||
@@ -62,8 +61,8 @@ bool TappableHandle::IsTapped(m2::RectD const & touchArea) const
|
||||
|
||||
if (m_anchor == dp::Anchor::Center)
|
||||
{
|
||||
m2::RectD rect(m_pivot.x - m_size.x * 0.5, m_pivot.y - m_size.y * 0.5,
|
||||
m_pivot.x + m_size.x * 0.5, m_pivot.y + m_size.y * 0.5);
|
||||
m2::RectD rect(m_pivot.x - m_size.x * 0.5, m_pivot.y - m_size.y * 0.5, m_pivot.x + m_size.x * 0.5,
|
||||
m_pivot.y + m_size.y * 0.5);
|
||||
return rect.Intersect(touchArea);
|
||||
}
|
||||
else
|
||||
@@ -82,9 +81,7 @@ ShapeRenderer::~ShapeRenderer()
|
||||
void ShapeRenderer::Build(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng)
|
||||
{
|
||||
ForEachShapeInfo([context, mng](ShapeControl::ShapeInfo & info) mutable
|
||||
{
|
||||
info.m_buffer->Build(context, mng->GetProgram(info.m_state.GetProgram<gpu::Program>()));
|
||||
});
|
||||
{ info.m_buffer->Build(context, mng->GetProgram(info.m_state.GetProgram<gpu::Program>())); });
|
||||
}
|
||||
|
||||
void ShapeRenderer::Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng,
|
||||
@@ -137,10 +134,8 @@ void ShapeRenderer::AddShapeControl(ShapeControl && control)
|
||||
void ShapeRenderer::SetPivot(m2::PointF const & pivot)
|
||||
{
|
||||
for (auto & control : m_shapes)
|
||||
{
|
||||
for (auto & info : control.m_shapesInfo)
|
||||
info.m_handle->SetPivot(glsl::ToVec2(pivot));
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeRenderer::ForEachShapeControl(TShapeControlEditFn const & fn)
|
||||
@@ -151,9 +146,7 @@ void ShapeRenderer::ForEachShapeControl(TShapeControlEditFn const & fn)
|
||||
void ShapeRenderer::ForEachShapeInfo(ShapeRenderer::TShapeInfoEditFn const & fn)
|
||||
{
|
||||
ForEachShapeControl([&fn](ShapeControl & shape)
|
||||
{
|
||||
std::for_each(shape.m_shapesInfo.begin(), shape.m_shapesInfo.end(), fn);
|
||||
});
|
||||
{ std::for_each(shape.m_shapesInfo.begin(), shape.m_shapesInfo.end(), fn); });
|
||||
}
|
||||
|
||||
ref_ptr<Handle> ShapeRenderer::ProcessTapEvent(m2::RectD const & touchArea)
|
||||
@@ -180,8 +173,7 @@ ref_ptr<Handle> ShapeRenderer::FindHandle(FeatureID const & id)
|
||||
return resultHandle;
|
||||
}
|
||||
|
||||
ShapeControl::ShapeInfo::ShapeInfo(dp::RenderState const & state,
|
||||
drape_ptr<dp::VertexArrayBuffer> && buffer,
|
||||
ShapeControl::ShapeInfo::ShapeInfo(dp::RenderState const & state, drape_ptr<dp::VertexArrayBuffer> && buffer,
|
||||
drape_ptr<Handle> && handle)
|
||||
: m_state(state)
|
||||
, m_buffer(std::move(buffer))
|
||||
|
||||
@@ -48,7 +48,8 @@ class TappableHandle : public Handle
|
||||
|
||||
public:
|
||||
TappableHandle(uint32_t id, dp::Anchor anchor, m2::PointF const & pivot, m2::PointF size)
|
||||
: Handle(id, anchor, pivot), m_size(size)
|
||||
: Handle(id, anchor, pivot)
|
||||
, m_size(size)
|
||||
{}
|
||||
|
||||
bool IsTapped(m2::RectD const & touchArea) const override;
|
||||
@@ -66,8 +67,7 @@ struct ShapeControl
|
||||
struct ShapeInfo
|
||||
{
|
||||
ShapeInfo() : m_state(df::CreateRenderState(gpu::Program::TexturingGui, df::DepthLayer::GuiLayer)) {}
|
||||
ShapeInfo(dp::RenderState const & state, drape_ptr<dp::VertexArrayBuffer> && buffer,
|
||||
drape_ptr<Handle> && handle);
|
||||
ShapeInfo(dp::RenderState const & state, drape_ptr<dp::VertexArrayBuffer> && buffer, drape_ptr<Handle> && handle);
|
||||
|
||||
void Destroy();
|
||||
|
||||
@@ -111,9 +111,7 @@ private:
|
||||
class Shape
|
||||
{
|
||||
public:
|
||||
explicit Shape(gui::Position const & position)
|
||||
: m_position(position)
|
||||
{}
|
||||
explicit Shape(gui::Position const & position) : m_position(position) {}
|
||||
|
||||
using TTapHandler = std::function<void()>;
|
||||
|
||||
|
||||
@@ -37,9 +37,7 @@ dp::Anchor ParseValueAnchor(std::string_view value)
|
||||
if (value == "bottom")
|
||||
return dp::Bottom;
|
||||
else
|
||||
{
|
||||
ASSERT(false, ());
|
||||
}
|
||||
|
||||
return dp::Center;
|
||||
}
|
||||
@@ -71,9 +69,7 @@ public:
|
||||
Offset
|
||||
};
|
||||
|
||||
ResolverParser()
|
||||
: m_element(Element::Empty)
|
||||
{}
|
||||
ResolverParser() : m_element(Element::Empty) {}
|
||||
|
||||
void Parse(std::string_view attr, char const * value)
|
||||
{
|
||||
@@ -96,26 +92,15 @@ public:
|
||||
else if (m_element == Element::Relative)
|
||||
m_resolver.AddRelative(ParseValueAnchor(value));
|
||||
else
|
||||
{
|
||||
ASSERT(false, ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
m_resolver = PositionResolver();
|
||||
}
|
||||
void Reset() { m_resolver = PositionResolver(); }
|
||||
|
||||
PositionResolver const & GetResolver() const
|
||||
{
|
||||
return m_resolver;
|
||||
}
|
||||
PositionResolver const & GetResolver() const { return m_resolver; }
|
||||
|
||||
void SetElement(Element e)
|
||||
{
|
||||
m_element = e;
|
||||
}
|
||||
void SetElement(Element e) { m_element = e; }
|
||||
|
||||
private:
|
||||
Element m_element;
|
||||
@@ -125,9 +110,7 @@ private:
|
||||
class SkinLoader
|
||||
{
|
||||
public:
|
||||
explicit SkinLoader(std::map<EWidget, std::pair<PositionResolver, PositionResolver>> & skin)
|
||||
: m_skin(skin)
|
||||
{}
|
||||
explicit SkinLoader(std::map<EWidget, std::pair<PositionResolver, PositionResolver>> & skin) : m_skin(skin) {}
|
||||
|
||||
bool Push(std::string_view element)
|
||||
{
|
||||
@@ -144,18 +127,14 @@ public:
|
||||
else if (element == "copyright")
|
||||
m_currentElement = WIDGET_COPYRIGHT;
|
||||
else
|
||||
{
|
||||
ASSERT(false, ());
|
||||
}
|
||||
}
|
||||
else if (!m_inConfiguration)
|
||||
{
|
||||
if (element == "portrait" || element == "landscape")
|
||||
m_inConfiguration = true;
|
||||
else
|
||||
{
|
||||
ASSERT(false, ());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -166,9 +145,7 @@ public:
|
||||
else if (element == "offset")
|
||||
m_parser.SetElement(ResolverParser::Element::Offset);
|
||||
else
|
||||
{
|
||||
ASSERT(false, ());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -190,17 +167,13 @@ public:
|
||||
m_parser.Reset();
|
||||
m_inConfiguration = false;
|
||||
}
|
||||
else if (element == "ruler" || element == "compass" || element == "copyright" ||
|
||||
element == "country_status")
|
||||
else if (element == "ruler" || element == "compass" || element == "copyright" || element == "country_status")
|
||||
{
|
||||
m_inElement = false;
|
||||
}
|
||||
}
|
||||
|
||||
void AddAttr(std::string_view attribute, char const * value)
|
||||
{
|
||||
m_parser.Parse(attribute, value);
|
||||
}
|
||||
void AddAttr(std::string_view attribute, char const * value) { m_parser.Parse(attribute, value); }
|
||||
|
||||
void CharData(std::string const &) {}
|
||||
|
||||
@@ -213,7 +186,7 @@ private:
|
||||
|
||||
std::map<EWidget, std::pair<PositionResolver, PositionResolver>> & m_skin;
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Position PositionResolver::Resolve(int w, int h, double vs) const
|
||||
{
|
||||
@@ -222,18 +195,18 @@ Position PositionResolver::Resolve(int w, int h, double vs) const
|
||||
m2::PointF offset = m_offset * vs;
|
||||
|
||||
if (m_resolveAnchor & dp::Left)
|
||||
resultX = offset.x;
|
||||
resultX = offset.x;
|
||||
else if (m_resolveAnchor & dp::Right)
|
||||
resultX = w - offset.x;
|
||||
resultX = w - offset.x;
|
||||
else
|
||||
resultX += offset.x;
|
||||
resultX += offset.x;
|
||||
|
||||
if (m_resolveAnchor & dp::Top)
|
||||
resultY = offset.y;
|
||||
resultY = offset.y;
|
||||
else if (m_resolveAnchor & dp::Bottom)
|
||||
resultY = h - offset.y;
|
||||
resultY = h - offset.y;
|
||||
else
|
||||
resultY += offset.y;
|
||||
resultY += offset.y;
|
||||
|
||||
return Position(m2::PointF(resultX, resultY), m_elementAnchor);
|
||||
}
|
||||
@@ -258,11 +231,10 @@ void PositionResolver::SetOffsetY(float y)
|
||||
m_offset.y = y;
|
||||
}
|
||||
|
||||
Skin::Skin(ReaderPtr<Reader> const & reader, float visualScale)
|
||||
: m_visualScale(visualScale)
|
||||
Skin::Skin(ReaderPtr<Reader> const & reader, float visualScale) : m_visualScale(visualScale)
|
||||
{
|
||||
SkinLoader loader(m_resolvers);
|
||||
ReaderSource<ReaderPtr<Reader> > source(reader);
|
||||
ReaderSource<ReaderPtr<Reader>> source(reader);
|
||||
if (!ParseXML(source, loader))
|
||||
LOG(LERROR, ("Error parsing gui skin"));
|
||||
}
|
||||
@@ -290,9 +262,9 @@ ReaderPtr<Reader> ResolveGuiSkinFile(std::string const & deviceType)
|
||||
{
|
||||
reader = pl.GetReader("symbols/default/" + deviceType + ".ui");
|
||||
}
|
||||
catch(FileAbsentException & e)
|
||||
catch (FileAbsentException & e)
|
||||
{
|
||||
LOG(LINFO, ("Gui skin for : ", deviceType ,"not found"));
|
||||
LOG(LINFO, ("Gui skin for : ", deviceType, "not found"));
|
||||
}
|
||||
|
||||
if (!reader)
|
||||
@@ -301,7 +273,7 @@ ReaderPtr<Reader> ResolveGuiSkinFile(std::string const & deviceType)
|
||||
{
|
||||
reader = pl.GetReader("symbols/default/default.ui");
|
||||
}
|
||||
catch(FileAbsentException & e)
|
||||
catch (FileAbsentException & e)
|
||||
{
|
||||
LOG(LINFO, ("Default gui skin not found"));
|
||||
throw e;
|
||||
|
||||
@@ -42,20 +42,11 @@ enum EGuiHandle
|
||||
|
||||
struct Position
|
||||
{
|
||||
Position()
|
||||
: m_pixelPivot(m2::PointF::Zero())
|
||||
, m_anchor(dp::Center)
|
||||
{}
|
||||
Position() : m_pixelPivot(m2::PointF::Zero()), m_anchor(dp::Center) {}
|
||||
|
||||
explicit Position(dp::Anchor anchor)
|
||||
: m_pixelPivot(m2::PointF::Zero())
|
||||
, m_anchor(anchor)
|
||||
{}
|
||||
explicit Position(dp::Anchor anchor) : m_pixelPivot(m2::PointF::Zero()), m_anchor(anchor) {}
|
||||
|
||||
Position(m2::PointF const & pt, dp::Anchor anchor)
|
||||
: m_pixelPivot(pt)
|
||||
, m_anchor(anchor)
|
||||
{}
|
||||
Position(m2::PointF const & pt, dp::Anchor anchor) : m_pixelPivot(pt), m_anchor(anchor) {}
|
||||
|
||||
m2::PointF m_pixelPivot;
|
||||
dp::Anchor m_anchor;
|
||||
|
||||
@@ -45,15 +45,9 @@ public:
|
||||
|
||||
Animation::Type GetType() const override { return Animation::Type::KineticScroll; }
|
||||
|
||||
TAnimObjects const & GetObjects() const override
|
||||
{
|
||||
return m_objects;
|
||||
}
|
||||
TAnimObjects const & GetObjects() const override { return m_objects; }
|
||||
|
||||
bool HasObject(Object object) const override
|
||||
{
|
||||
return m_objects.find(object) != m_objects.end();
|
||||
}
|
||||
bool HasObject(Object object) const override { return m_objects.find(object) != m_objects.end(); }
|
||||
|
||||
TObjectProperties const & GetProperties(Object object) const override
|
||||
{
|
||||
@@ -79,10 +73,7 @@ public:
|
||||
double GetDuration() const override { return m_duration; }
|
||||
bool IsFinished() const override { return m_elapsedTime >= m_duration; }
|
||||
|
||||
void Advance(double elapsedSeconds) override
|
||||
{
|
||||
m_elapsedTime += elapsedSeconds;
|
||||
}
|
||||
void Advance(double elapsedSeconds) override { m_elapsedTime += elapsedSeconds; }
|
||||
|
||||
void Finish() override
|
||||
{
|
||||
@@ -107,10 +98,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
double GetT() const
|
||||
{
|
||||
return IsFinished() ? 1.0 : m_elapsedTime / m_duration;
|
||||
}
|
||||
double GetT() const { return IsFinished() ? 1.0 : m_elapsedTime / m_duration; }
|
||||
|
||||
m2::PointD m_endPos;
|
||||
m2::PointD m_direction;
|
||||
@@ -137,9 +125,7 @@ void KineticScroller::Update(ScreenBase const & modelView)
|
||||
if (m_points.size() > 1)
|
||||
{
|
||||
auto it = std::find_if(m_points.begin(), m_points.end(), [&nowTime](auto const & e)
|
||||
{
|
||||
return GetDurationSeconds(nowTime, e.second) <= kTimeWindowSec;
|
||||
});
|
||||
{ return GetDurationSeconds(nowTime, e.second) <= kTimeWindowSec; });
|
||||
|
||||
// Keep last point always.
|
||||
if (it == m_points.end())
|
||||
|
||||
@@ -22,24 +22,19 @@ class TextureCoordGenerator
|
||||
{
|
||||
public:
|
||||
explicit TextureCoordGenerator(dp::TextureManager::StippleRegion const & region)
|
||||
: m_region(region), m_maskSize(m_region.GetMaskPixelSize())
|
||||
: m_region(region)
|
||||
, m_maskSize(m_region.GetMaskPixelSize())
|
||||
{}
|
||||
|
||||
glsl::vec4 GetTexCoordsByDistance(float distance, bool isLeft) const
|
||||
{
|
||||
m2::RectF const & texRect = m_region.GetTexRect();
|
||||
return { distance / GetMaskLength(), texRect.minX(), texRect.SizeX(), isLeft ? texRect.minY() : texRect.maxY() };
|
||||
return {distance / GetMaskLength(), texRect.minX(), texRect.SizeX(), isLeft ? texRect.minY() : texRect.maxY()};
|
||||
}
|
||||
|
||||
uint32_t GetMaskLength() const
|
||||
{
|
||||
return m_maskSize.x;
|
||||
}
|
||||
uint32_t GetMaskLength() const { return m_maskSize.x; }
|
||||
|
||||
dp::TextureManager::StippleRegion const & GetRegion() const
|
||||
{
|
||||
return m_region;
|
||||
}
|
||||
dp::TextureManager::StippleRegion const & GetRegion() const { return m_region; }
|
||||
|
||||
private:
|
||||
dp::TextureManager::StippleRegion const m_region;
|
||||
@@ -66,70 +61,43 @@ public:
|
||||
, m_colorCoord(glsl::ToVec2(params.m_color.GetTexRect().Center()))
|
||||
{
|
||||
m_geometry.reserve(geomsSize);
|
||||
//m_joinGeom.reserve(joinsSize);
|
||||
// m_joinGeom.reserve(joinsSize);
|
||||
}
|
||||
|
||||
dp::BindingInfo const & GetBindingInfo() override
|
||||
{
|
||||
return TVertex::GetBindingInfo();
|
||||
}
|
||||
dp::BindingInfo const & GetBindingInfo() override { return TVertex::GetBindingInfo(); }
|
||||
|
||||
ref_ptr<void> GetLineData() override
|
||||
{
|
||||
return make_ref(m_geometry.data());
|
||||
}
|
||||
ref_ptr<void> GetLineData() override { return make_ref(m_geometry.data()); }
|
||||
|
||||
uint32_t GetLineSize() override
|
||||
{
|
||||
return static_cast<uint32_t>(m_geometry.size());
|
||||
}
|
||||
uint32_t GetLineSize() override { return static_cast<uint32_t>(m_geometry.size()); }
|
||||
|
||||
// ref_ptr<void> GetJoinData() override
|
||||
// {
|
||||
// return make_ref(m_joinGeom.data());
|
||||
// }
|
||||
// ref_ptr<void> GetJoinData() override
|
||||
// {
|
||||
// return make_ref(m_joinGeom.data());
|
||||
// }
|
||||
|
||||
// uint32_t GetJoinSize() override
|
||||
// {
|
||||
// return static_cast<uint32_t>(m_joinGeom.size());
|
||||
// }
|
||||
// uint32_t GetJoinSize() override
|
||||
// {
|
||||
// return static_cast<uint32_t>(m_joinGeom.size());
|
||||
// }
|
||||
|
||||
float GetHalfWidth()
|
||||
{
|
||||
return m_params.m_pxHalfWidth;
|
||||
}
|
||||
float GetHalfWidth() { return m_params.m_pxHalfWidth; }
|
||||
|
||||
dp::BindingInfo const & GetCapBindingInfo() override
|
||||
{
|
||||
return GetBindingInfo();
|
||||
}
|
||||
dp::BindingInfo const & GetCapBindingInfo() override { return GetBindingInfo(); }
|
||||
|
||||
dp::RenderState GetCapState() override
|
||||
{
|
||||
return GetState();
|
||||
}
|
||||
dp::RenderState GetCapState() override { return GetState(); }
|
||||
|
||||
ref_ptr<void> GetCapData() override
|
||||
{
|
||||
return ref_ptr<void>();
|
||||
}
|
||||
ref_ptr<void> GetCapData() override { return ref_ptr<void>(); }
|
||||
|
||||
uint32_t GetCapSize() override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
uint32_t GetCapSize() override { return 0; }
|
||||
|
||||
float GetSide(bool isLeft) const
|
||||
{
|
||||
return isLeft ? 1.0f : -1.0f;
|
||||
}
|
||||
float GetSide(bool isLeft) const { return isLeft ? 1.0f : -1.0f; }
|
||||
|
||||
protected:
|
||||
using V = TVertex;
|
||||
using TGeometryBuffer = gpu::VBReservedSizeT<V>;
|
||||
|
||||
TGeometryBuffer m_geometry;
|
||||
//TGeometryBuffer m_joinGeom;
|
||||
// TGeometryBuffer m_joinGeom;
|
||||
|
||||
BaseBuilderParams m_params;
|
||||
glsl::vec2 const m_colorCoord;
|
||||
@@ -204,15 +172,9 @@ public:
|
||||
return state;
|
||||
}
|
||||
|
||||
ref_ptr<void> GetCapData() override
|
||||
{
|
||||
return make_ref<void>(m_capGeometry.data());
|
||||
}
|
||||
ref_ptr<void> GetCapData() override { return make_ref<void>(m_capGeometry.data()); }
|
||||
|
||||
uint32_t GetCapSize() override
|
||||
{
|
||||
return static_cast<uint32_t>(m_capGeometry.size());
|
||||
}
|
||||
uint32_t GetCapSize() override { return static_cast<uint32_t>(m_capGeometry.size()); }
|
||||
|
||||
void SubmitVertex(glsl::vec3 const & pivot, glsl::vec2 const & normal, bool isLeft)
|
||||
{
|
||||
@@ -246,8 +208,7 @@ private:
|
||||
CapVertex::TNormal(radius * kSqrt3, -radius, radius),
|
||||
CapVertex::TTexCoord(m_colorCoord));
|
||||
m_capGeometry.emplace_back(CapVertex::TPosition(pos, m_params.m_depth),
|
||||
CapVertex::TNormal(0, 2.0f * radius, radius),
|
||||
CapVertex::TTexCoord(m_colorCoord));
|
||||
CapVertex::TNormal(0, 2.0f * radius, radius), CapVertex::TTexCoord(m_colorCoord));
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -276,10 +237,7 @@ public:
|
||||
return state;
|
||||
}
|
||||
|
||||
void SubmitVertex(glsl::vec3 const & pivot)
|
||||
{
|
||||
m_geometry.emplace_back(pivot, m_colorCoord);
|
||||
}
|
||||
void SubmitVertex(glsl::vec3 const & pivot) { m_geometry.emplace_back(pivot, m_colorCoord); }
|
||||
|
||||
private:
|
||||
int m_lineWidth;
|
||||
@@ -303,10 +261,7 @@ public:
|
||||
, m_baseGtoPScale(params.m_baseGtoP)
|
||||
{}
|
||||
|
||||
float GetMaskLengthG() const
|
||||
{
|
||||
return m_texCoordGen.GetMaskLength() / m_baseGtoPScale;
|
||||
}
|
||||
float GetMaskLengthG() const { return m_texCoordGen.GetMaskLength() / m_baseGtoPScale; }
|
||||
|
||||
dp::RenderState GetState() override
|
||||
{
|
||||
@@ -320,8 +275,8 @@ public:
|
||||
void SubmitVertex(glsl::vec3 const & pivot, glsl::vec2 const & normal, bool isLeft, float offsetFromStart)
|
||||
{
|
||||
float const halfWidth = GetHalfWidth();
|
||||
m_geometry.emplace_back(pivot, TNormal(halfWidth * normal, halfWidth * GetSide(isLeft)),
|
||||
m_colorCoord, m_texCoordGen.GetTexCoordsByDistance(offsetFromStart, isLeft));
|
||||
m_geometry.emplace_back(pivot, TNormal(halfWidth * normal, halfWidth * GetSide(isLeft)), m_colorCoord,
|
||||
m_texCoordGen.GetTexCoordsByDistance(offsetFromStart, isLeft));
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -344,7 +299,8 @@ void LineShape::Construct(TBuilder & builder) const
|
||||
ASSERT(false, ("No implementation"));
|
||||
}
|
||||
|
||||
template <class FnT> void LineShape::ForEachSplineSection(FnT && fn) const
|
||||
template <class FnT>
|
||||
void LineShape::ForEachSplineSection(FnT && fn) const
|
||||
{
|
||||
std::vector<m2::PointD> const & path = m_spline->GetPath();
|
||||
ASSERT(!path.empty(), ());
|
||||
@@ -371,10 +327,8 @@ template <class FnT> void LineShape::ForEachSplineSection(FnT && fn) const
|
||||
|
||||
glsl::vec2 const tangent = glsl::ToVec2(tanlen.first);
|
||||
|
||||
fn(ToShapeVertex2(path[i]), ToShapeVertex2(path[j]),
|
||||
tangent, tanlen.second,
|
||||
{-tangent.y, tangent.x}, {tangent.y, -tangent.x},
|
||||
(i == 0 ? 0x1 : 0) + (j == sz ? 0x2 : 0));
|
||||
fn(ToShapeVertex2(path[i]), ToShapeVertex2(path[j]), tangent, tanlen.second, {-tangent.y, tangent.x},
|
||||
{tangent.y, -tangent.x}, (i == 0 ? 0x1 : 0) + (j == sz ? 0x2 : 0));
|
||||
|
||||
i = j;
|
||||
}
|
||||
@@ -388,14 +342,14 @@ void LineShape::Construct<DashedLineBuilder>(DashedLineBuilder & builder) const
|
||||
|
||||
// Each segment should lie in pattern mask according to the "longest" possible pixel length in current tile.
|
||||
// Since, we calculate vertices once, usually for the "smallest" tile scale, need to apply divide factor here.
|
||||
// In other words, if m_baseGtoPScale = Scale(tileLevel), we should use Scale(tileLevel + 1) to calculate 'maskLengthG'.
|
||||
// In other words, if m_baseGtoPScale = Scale(tileLevel), we should use Scale(tileLevel + 1) to calculate
|
||||
// 'maskLengthG'.
|
||||
/// @todo Logically, the factor should be 2, but drawing artifacts are still present at higher visual scales.
|
||||
/// Use 3 for the best quality, but need to review here, probably I missed something.
|
||||
float const maskLengthG = builder.GetMaskLengthG() / 3;
|
||||
|
||||
float offset = 0;
|
||||
ForEachSplineSection([&](glsl::vec2 const & p1, glsl::vec2 const & p2,
|
||||
glsl::vec2 const & tangent, float toDraw,
|
||||
ForEachSplineSection([&](glsl::vec2 const & p1, glsl::vec2 const & p2, glsl::vec2 const & tangent, float toDraw,
|
||||
glsl::vec2 const & leftNormal, glsl::vec2 const & rightNormal, int)
|
||||
{
|
||||
glsl::vec2 currPivot = p1;
|
||||
@@ -429,8 +383,8 @@ void LineShape::Construct<DashedLineBuilder>(DashedLineBuilder & builder) const
|
||||
offset = nextOffset;
|
||||
if (offset >= maskLengthG)
|
||||
offset = 0;
|
||||
|
||||
} while (toDraw > 0);
|
||||
}
|
||||
while (toDraw > 0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -441,10 +395,8 @@ void LineShape::Construct<SolidLineBuilder>(SolidLineBuilder & builder) const
|
||||
// Skip joins generation for thin lines.
|
||||
bool const generateJoins = builder.GetHalfWidth() > 2.5f;
|
||||
|
||||
ForEachSplineSection([&](glsl::vec2 const & p1, glsl::vec2 const & p2,
|
||||
glsl::vec2 const & tangent, double,
|
||||
glsl::vec2 const & leftNormal, glsl::vec2 const & rightNormal,
|
||||
int flag)
|
||||
ForEachSplineSection([&](glsl::vec2 const & p1, glsl::vec2 const & p2, glsl::vec2 const & tangent, double,
|
||||
glsl::vec2 const & leftNormal, glsl::vec2 const & rightNormal, int flag)
|
||||
{
|
||||
builder.SubmitVertex({p1, m_params.m_depth}, rightNormal, false /* isLeft */);
|
||||
builder.SubmitVertex({p1, m_params.m_depth}, leftNormal, true /* isLeft */);
|
||||
@@ -452,11 +404,11 @@ void LineShape::Construct<SolidLineBuilder>(SolidLineBuilder & builder) const
|
||||
builder.SubmitVertex({p2, m_params.m_depth}, leftNormal, true /* isLeft */);
|
||||
|
||||
// Generate joins.
|
||||
if (flag & 0x1) // p1 - first point
|
||||
if (flag & 0x1) // p1 - first point
|
||||
builder.SubmitCap(p1);
|
||||
if (flag & 0x2) // p2 - last point
|
||||
if (flag & 0x2) // p2 - last point
|
||||
builder.SubmitCap(p2);
|
||||
else if (generateJoins) // p2 - middle point
|
||||
else if (generateJoins) // p2 - middle point
|
||||
builder.SubmitJoin(p2);
|
||||
});
|
||||
}
|
||||
@@ -560,13 +512,13 @@ void LineShape::Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::Batcher>
|
||||
batcher->InsertListOfStrip(context, state, make_ref(&provider), dp::Batcher::VertexPerQuad);
|
||||
|
||||
// Not used, keep comment for possible usage. LineJoin::RoundJoin is processed as _Cap_.
|
||||
// uint32_t const joinSize = m_lineShapeInfo->GetJoinSize();
|
||||
// if (joinSize > 0)
|
||||
// {
|
||||
// dp::AttributeProvider joinsProvider(1, joinSize);
|
||||
// joinsProvider.InitStream(0, m_lineShapeInfo->GetBindingInfo(), m_lineShapeInfo->GetJoinData());
|
||||
// batcher->InsertTriangleList(context, state, make_ref(&joinsProvider));
|
||||
// }
|
||||
// uint32_t const joinSize = m_lineShapeInfo->GetJoinSize();
|
||||
// if (joinSize > 0)
|
||||
// {
|
||||
// dp::AttributeProvider joinsProvider(1, joinSize);
|
||||
// joinsProvider.InitStream(0, m_lineShapeInfo->GetBindingInfo(), m_lineShapeInfo->GetJoinData());
|
||||
// batcher->InsertTriangleList(context, state, make_ref(&joinsProvider));
|
||||
// }
|
||||
|
||||
uint32_t const capSize = m_lineShapeInfo->GetCapSize();
|
||||
if (capSize > 0)
|
||||
@@ -582,4 +534,3 @@ void LineShape::Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::Batcher>
|
||||
}
|
||||
}
|
||||
} // namespace df
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ public:
|
||||
virtual ref_ptr<void> GetLineData() = 0;
|
||||
virtual uint32_t GetLineSize() = 0;
|
||||
|
||||
// virtual ref_ptr<void> GetJoinData() = 0;
|
||||
// virtual uint32_t GetJoinSize() = 0;
|
||||
// virtual ref_ptr<void> GetJoinData() = 0;
|
||||
// virtual uint32_t GetJoinSize() = 0;
|
||||
|
||||
virtual dp::BindingInfo const & GetCapBindingInfo() = 0;
|
||||
virtual dp::RenderState GetCapState() = 0;
|
||||
@@ -47,7 +47,8 @@ private:
|
||||
return glsl::ToVec2(ConvertToLocal(vertex, m_params.m_tileCenter, kShapeCoordScalar));
|
||||
}
|
||||
|
||||
template <class FnT> void ForEachSplineSection(FnT && fn) const;
|
||||
template <class FnT>
|
||||
void ForEachSplineSection(FnT && fn) const;
|
||||
|
||||
template <typename TBuilder>
|
||||
void Construct(TBuilder & builder) const;
|
||||
@@ -60,4 +61,3 @@ private:
|
||||
mutable bool m_isSimple;
|
||||
};
|
||||
} // namespace df
|
||||
|
||||
|
||||
@@ -12,8 +12,7 @@ void UpdateNormalBetweenSegments(LineSegment * segment1, LineSegment * segment2)
|
||||
{
|
||||
ASSERT(segment1 != nullptr && segment2 != nullptr, ());
|
||||
|
||||
float const dotProduct = glsl::dot(segment1->m_leftNormals[EndPoint],
|
||||
segment2->m_leftNormals[StartPoint]);
|
||||
float const dotProduct = glsl::dot(segment1->m_leftNormals[EndPoint], segment2->m_leftNormals[StartPoint]);
|
||||
float const absDotProduct = fabs(dotProduct);
|
||||
float const kEps = 1e-5;
|
||||
|
||||
@@ -24,16 +23,15 @@ void UpdateNormalBetweenSegments(LineSegment * segment1, LineSegment * segment2)
|
||||
}
|
||||
|
||||
float const kMaxScalar = 5;
|
||||
float const crossProduct = glsl::cross(glsl::vec3(segment1->m_tangent, 0),
|
||||
glsl::vec3(segment2->m_tangent, 0)).z;
|
||||
float const crossProduct = glsl::cross(glsl::vec3(segment1->m_tangent, 0), glsl::vec3(segment2->m_tangent, 0)).z;
|
||||
if (crossProduct < 0)
|
||||
{
|
||||
segment1->m_hasLeftJoin[EndPoint] = true;
|
||||
segment2->m_hasLeftJoin[StartPoint] = true;
|
||||
|
||||
// change right-side normals
|
||||
glsl::vec2 averageNormal = glsl::normalize(segment1->m_rightNormals[EndPoint] +
|
||||
segment2->m_rightNormals[StartPoint]);
|
||||
glsl::vec2 averageNormal =
|
||||
glsl::normalize(segment1->m_rightNormals[EndPoint] + segment2->m_rightNormals[StartPoint]);
|
||||
float const cosAngle = glsl::dot(segment1->m_tangent, averageNormal);
|
||||
float const widthScalar = 1.0f / sqrt(1.0f - cosAngle * cosAngle);
|
||||
if (widthScalar < kMaxScalar)
|
||||
@@ -55,8 +53,7 @@ void UpdateNormalBetweenSegments(LineSegment * segment1, LineSegment * segment2)
|
||||
segment2->m_hasLeftJoin[StartPoint] = false;
|
||||
|
||||
// change left-side normals
|
||||
glsl::vec2 averageNormal = glsl::normalize(segment1->m_leftNormals[EndPoint] +
|
||||
segment2->m_leftNormals[StartPoint]);
|
||||
glsl::vec2 averageNormal = glsl::normalize(segment1->m_leftNormals[EndPoint] + segment2->m_leftNormals[StartPoint]);
|
||||
float const cosAngle = glsl::dot(segment1->m_tangent, averageNormal);
|
||||
float const widthScalar = 1.0f / sqrt(1.0f - cosAngle * cosAngle);
|
||||
if (widthScalar < kMaxScalar)
|
||||
@@ -75,9 +72,8 @@ void UpdateNormalBetweenSegments(LineSegment * segment1, LineSegment * segment2)
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void CalculateTangentAndNormals(glsl::vec2 const & pt0, glsl::vec2 const & pt1,
|
||||
glsl::vec2 & tangent, glsl::vec2 & leftNormal,
|
||||
glsl::vec2 & rightNormal)
|
||||
void CalculateTangentAndNormals(glsl::vec2 const & pt0, glsl::vec2 const & pt1, glsl::vec2 & tangent,
|
||||
glsl::vec2 & leftNormal, glsl::vec2 & rightNormal)
|
||||
{
|
||||
tangent = glsl::normalize(pt1 - pt0);
|
||||
leftNormal = glsl::vec2(-tangent.y, tangent.x);
|
||||
@@ -90,9 +86,7 @@ void ConstructLineSegments(std::vector<m2::PointD> const & path, std::vector<gls
|
||||
ASSERT_LESS(1, path.size(), ());
|
||||
|
||||
if (!segmentsColors.empty())
|
||||
{
|
||||
ASSERT_EQUAL(segmentsColors.size() + 1, path.size(), ());
|
||||
}
|
||||
|
||||
m2::PointD prevPoint = path[0];
|
||||
for (size_t i = 1; i < path.size(); ++i)
|
||||
@@ -107,8 +101,8 @@ void ConstructLineSegments(std::vector<m2::PointD> const & path, std::vector<gls
|
||||
segments.emplace_back(glsl::ToVec2(p1), glsl::ToVec2(p2));
|
||||
LineSegment & segment = segments.back();
|
||||
|
||||
CalculateTangentAndNormals(glsl::ToVec2(p1), glsl::ToVec2(p2), segment.m_tangent,
|
||||
segment.m_leftBaseNormal, segment.m_rightBaseNormal);
|
||||
CalculateTangentAndNormals(glsl::ToVec2(p1), glsl::ToVec2(p2), segment.m_tangent, segment.m_leftBaseNormal,
|
||||
segment.m_rightBaseNormal);
|
||||
|
||||
segment.m_leftNormals[StartPoint] = segment.m_leftNormals[EndPoint] = segment.m_leftBaseNormal;
|
||||
segment.m_rightNormals[StartPoint] = segment.m_rightNormals[EndPoint] = segment.m_rightBaseNormal;
|
||||
@@ -130,9 +124,9 @@ void UpdateNormals(LineSegment * segment, LineSegment * prevSegment, LineSegment
|
||||
UpdateNormalBetweenSegments(segment, nextSegment);
|
||||
}
|
||||
|
||||
std::vector<glsl::vec2> GenerateJoinNormals(
|
||||
dp::LineJoin joinType, glsl::vec2 const & normal1, glsl::vec2 const & normal2,
|
||||
float halfWidth, bool isLeft, float widthScalar, std::vector<glsl::vec2> * uv)
|
||||
std::vector<glsl::vec2> GenerateJoinNormals(dp::LineJoin joinType, glsl::vec2 const & normal1,
|
||||
glsl::vec2 const & normal2, float halfWidth, bool isLeft, float widthScalar,
|
||||
std::vector<glsl::vec2> * uv)
|
||||
{
|
||||
std::vector<glsl::vec2> normals;
|
||||
float const eps = 1e-5;
|
||||
@@ -144,12 +138,12 @@ std::vector<glsl::vec2> GenerateJoinNormals(
|
||||
glsl::vec2 const n1 = halfWidth * normal1;
|
||||
glsl::vec2 const n2 = halfWidth * normal2;
|
||||
|
||||
normals = { glsl::vec2(0.0f, 0.0f), isLeft ? n1 : n2, isLeft ? n2 : n1 };
|
||||
normals = {glsl::vec2(0.0f, 0.0f), isLeft ? n1 : n2, isLeft ? n2 : n1};
|
||||
|
||||
if (uv)
|
||||
{
|
||||
*uv = { glsl::vec2(0.5f, 0.5f), isLeft ? glsl::vec2(0.5f, 0.0f) : glsl::vec2(0.5f, 1.0f),
|
||||
isLeft ? glsl::vec2(0.5f, 0.0f) : glsl::vec2(0.5f, 1.0f) };
|
||||
*uv = {glsl::vec2(0.5f, 0.5f), isLeft ? glsl::vec2(0.5f, 0.0f) : glsl::vec2(0.5f, 1.0f),
|
||||
isLeft ? glsl::vec2(0.5f, 0.0f) : glsl::vec2(0.5f, 1.0f)};
|
||||
}
|
||||
}
|
||||
else if (joinType == dp::LineJoin::MiterJoin)
|
||||
@@ -159,16 +153,18 @@ std::vector<glsl::vec2> GenerateJoinNormals(
|
||||
glsl::vec2 const n1 = halfWidth * normal1;
|
||||
glsl::vec2 const n2 = halfWidth * normal2;
|
||||
|
||||
normals = { glsl::vec2(0.0f, 0.0f), isLeft ? n1 : averageNormal, isLeft ? averageNormal : n1,
|
||||
glsl::vec2(0.0f, 0.0f), isLeft ? averageNormal : n2, isLeft ? n2 : averageNormal };
|
||||
normals = {glsl::vec2(0.0f, 0.0f), isLeft ? n1 : averageNormal, isLeft ? averageNormal : n1,
|
||||
glsl::vec2(0.0f, 0.0f), isLeft ? averageNormal : n2, isLeft ? n2 : averageNormal};
|
||||
|
||||
if (uv)
|
||||
{
|
||||
*uv = { glsl::vec2(0.5f, 0.5f), isLeft ? glsl::vec2(0.5f, 0.0f) : glsl::vec2(0.5f, 1.0f),
|
||||
isLeft ? glsl::vec2(0.5f, 0.0f) : glsl::vec2(0.5f, 1.0f),
|
||||
*uv = {glsl::vec2(0.5f, 0.5f),
|
||||
isLeft ? glsl::vec2(0.5f, 0.0f) : glsl::vec2(0.5f, 1.0f),
|
||||
isLeft ? glsl::vec2(0.5f, 0.0f) : glsl::vec2(0.5f, 1.0f),
|
||||
|
||||
glsl::vec2(0.5f, 0.5f), isLeft ? glsl::vec2(0.5f, 0.0f) : glsl::vec2(0.5f, 1.0f),
|
||||
isLeft ? glsl::vec2(0.5f, 0.0f) : glsl::vec2(0.5f, 1.0f) };
|
||||
glsl::vec2(0.5f, 0.5f),
|
||||
isLeft ? glsl::vec2(0.5f, 0.0f) : glsl::vec2(0.5f, 1.0f),
|
||||
isLeft ? glsl::vec2(0.5f, 0.0f) : glsl::vec2(0.5f, 1.0f)};
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -208,9 +204,9 @@ std::vector<glsl::vec2> GenerateJoinNormals(
|
||||
return normals;
|
||||
}
|
||||
|
||||
std::vector<glsl::vec2> GenerateCapNormals(
|
||||
dp::LineCap capType, glsl::vec2 const & normal1, glsl::vec2 const & normal2,
|
||||
glsl::vec2 const & direction, float halfWidth, bool isStart, int segmentsCount)
|
||||
std::vector<glsl::vec2> GenerateCapNormals(dp::LineCap capType, glsl::vec2 const & normal1, glsl::vec2 const & normal2,
|
||||
glsl::vec2 const & direction, float halfWidth, bool isStart,
|
||||
int segmentsCount)
|
||||
{
|
||||
std::vector<glsl::vec2> normals;
|
||||
if (capType == dp::ButtCap)
|
||||
@@ -223,8 +219,7 @@ std::vector<glsl::vec2> GenerateCapNormals(
|
||||
glsl::vec2 const n3 = halfWidth * (normal1 + direction);
|
||||
glsl::vec2 const n4 = halfWidth * (normal2 + direction);
|
||||
|
||||
normals = { n2, isStart ? n4 : n1, isStart ? n1 : n4,
|
||||
n1, isStart ? n4 : n3, isStart ? n3 : n4 };
|
||||
normals = {n2, isStart ? n4 : n1, isStart ? n1 : n4, n1, isStart ? n4 : n3, isStart ? n3 : n4};
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -253,12 +248,11 @@ glsl::vec2 GetNormal(LineSegment const & segment, bool isLeft, ENormalType norma
|
||||
return isLeft ? segment.m_leftBaseNormal : segment.m_rightBaseNormal;
|
||||
|
||||
int const index = (normalType == StartNormal) ? StartPoint : EndPoint;
|
||||
return isLeft ? segment.m_leftWidthScalar[index].x * segment.m_leftNormals[index]:
|
||||
segment.m_rightWidthScalar[index].x * segment.m_rightNormals[index];
|
||||
return isLeft ? segment.m_leftWidthScalar[index].x * segment.m_leftNormals[index]
|
||||
: segment.m_rightWidthScalar[index].x * segment.m_rightNormals[index];
|
||||
}
|
||||
|
||||
float GetProjectionLength(glsl::vec2 const & newPoint, glsl::vec2 const & startPoint,
|
||||
glsl::vec2 const & endPoint)
|
||||
float GetProjectionLength(glsl::vec2 const & newPoint, glsl::vec2 const & startPoint, glsl::vec2 const & endPoint)
|
||||
{
|
||||
glsl::vec2 const v1 = endPoint - startPoint;
|
||||
glsl::vec2 const v2 = newPoint - startPoint;
|
||||
@@ -267,4 +261,3 @@ float GetProjectionLength(glsl::vec2 const & newPoint, glsl::vec2 const & startP
|
||||
return sqrt(squareLen) * math::Clamp(proj, 0.0f, 1.0f);
|
||||
}
|
||||
} // namespace df
|
||||
|
||||
|
||||
@@ -49,25 +49,23 @@ struct LineSegment
|
||||
}
|
||||
};
|
||||
|
||||
void CalculateTangentAndNormals(glsl::vec2 const & pt0, glsl::vec2 const & pt1,
|
||||
glsl::vec2 & tangent, glsl::vec2 & leftNormal,
|
||||
glsl::vec2 & rightNormal);
|
||||
void CalculateTangentAndNormals(glsl::vec2 const & pt0, glsl::vec2 const & pt1, glsl::vec2 & tangent,
|
||||
glsl::vec2 & leftNormal, glsl::vec2 & rightNormal);
|
||||
|
||||
void ConstructLineSegments(std::vector<m2::PointD> const & path, std::vector<glsl::vec4> const & segmentsColors,
|
||||
std::vector<LineSegment> & segments);
|
||||
|
||||
void UpdateNormals(LineSegment * segment, LineSegment * prevSegment, LineSegment * nextSegment);
|
||||
|
||||
std::vector<glsl::vec2> GenerateJoinNormals(
|
||||
dp::LineJoin joinType, glsl::vec2 const & normal1, glsl::vec2 const & normal2,
|
||||
float halfWidth, bool isLeft, float widthScalar, std::vector<glsl::vec2> * uv = nullptr);
|
||||
std::vector<glsl::vec2> GenerateJoinNormals(dp::LineJoin joinType, glsl::vec2 const & normal1,
|
||||
glsl::vec2 const & normal2, float halfWidth, bool isLeft, float widthScalar,
|
||||
std::vector<glsl::vec2> * uv = nullptr);
|
||||
|
||||
std::vector<glsl::vec2> GenerateCapNormals(
|
||||
dp::LineCap capType, glsl::vec2 const & normal1, glsl::vec2 const & normal2,
|
||||
glsl::vec2 const & direction, float halfWidth, bool isStart, int segmentsCount = 8);
|
||||
std::vector<glsl::vec2> GenerateCapNormals(dp::LineCap capType, glsl::vec2 const & normal1, glsl::vec2 const & normal2,
|
||||
glsl::vec2 const & direction, float halfWidth, bool isStart,
|
||||
int segmentsCount = 8);
|
||||
|
||||
glsl::vec2 GetNormal(LineSegment const & segment, bool isLeft, ENormalType normalType);
|
||||
|
||||
float GetProjectionLength(glsl::vec2 const & newPoint, glsl::vec2 const & startPoint, glsl::vec2 const & endPoint);
|
||||
} // namespace df
|
||||
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
namespace df
|
||||
{
|
||||
MapDataProvider::MapDataProvider(TReadIDsFn && idsReader,
|
||||
TReadFeaturesFn && featureReader,
|
||||
MapDataProvider::MapDataProvider(TReadIDsFn && idsReader, TReadFeaturesFn && featureReader,
|
||||
TIsCountryLoadedByNameFn && isCountryLoadedByNameFn,
|
||||
TUpdateCurrentCountryFn && updateCurrentCountryFn)
|
||||
: m_isCountryLoadedByName(std::move(isCountryLoadedByNameFn))
|
||||
@@ -21,14 +20,12 @@ MapDataProvider::MapDataProvider(TReadIDsFn && idsReader,
|
||||
CHECK(m_updateCurrentCountry != nullptr, ());
|
||||
}
|
||||
|
||||
void MapDataProvider::ReadFeaturesID(TReadCallback<FeatureID const> const & fn, m2::RectD const & r,
|
||||
int scale) const
|
||||
void MapDataProvider::ReadFeaturesID(TReadCallback<FeatureID const> const & fn, m2::RectD const & r, int scale) const
|
||||
{
|
||||
m_idsReader(fn, r, scale);
|
||||
}
|
||||
|
||||
void MapDataProvider::ReadFeatures(TReadCallback<FeatureType> const & fn,
|
||||
std::vector<FeatureID> const & ids) const
|
||||
void MapDataProvider::ReadFeatures(TReadCallback<FeatureType> const & fn, std::vector<FeatureID> const & ids) const
|
||||
{
|
||||
m_featureReader(fn, ids);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include "storage/storage_defines.hpp"
|
||||
|
||||
#include "indexer/feature.hpp"
|
||||
#include "geometry/rect2d.hpp"
|
||||
#include "indexer/feature.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
@@ -14,22 +14,19 @@ namespace df
|
||||
class MapDataProvider
|
||||
{
|
||||
public:
|
||||
template <typename T> using TReadCallback = std::function<void(T &)>;
|
||||
using TReadFeaturesFn = std::function<void(TReadCallback<FeatureType> const &,
|
||||
std::vector<FeatureID> const &)>;
|
||||
using TReadIDsFn = std::function<void(TReadCallback<FeatureID const> const &,
|
||||
m2::RectD const &, int)>;
|
||||
template <typename T>
|
||||
using TReadCallback = std::function<void(T &)>;
|
||||
using TReadFeaturesFn = std::function<void(TReadCallback<FeatureType> const &, std::vector<FeatureID> const &)>;
|
||||
using TReadIDsFn = std::function<void(TReadCallback<FeatureID const> const &, m2::RectD const &, int)>;
|
||||
using TIsCountryLoadedFn = std::function<bool(m2::PointD const &)>;
|
||||
using TIsCountryLoadedByNameFn = std::function<bool(std::string_view)>;
|
||||
using TUpdateCurrentCountryFn = std::function<void(m2::PointD const &, int)>;
|
||||
|
||||
MapDataProvider(TReadIDsFn && idsReader,
|
||||
TReadFeaturesFn && featureReader,
|
||||
MapDataProvider(TReadIDsFn && idsReader, TReadFeaturesFn && featureReader,
|
||||
TIsCountryLoadedByNameFn && isCountryLoadedByNameFn,
|
||||
TUpdateCurrentCountryFn && updateCurrentCountryFn);
|
||||
|
||||
void ReadFeaturesID(TReadCallback<FeatureID const> const & fn, m2::RectD const & r,
|
||||
int scale) const;
|
||||
void ReadFeaturesID(TReadCallback<FeatureID const> const & fn, m2::RectD const & r, int scale) const;
|
||||
void ReadFeatures(TReadCallback<FeatureType> const & fn, std::vector<FeatureID> const & ids) const;
|
||||
|
||||
TUpdateCurrentCountryFn const & UpdateCurrentCountryFn() const;
|
||||
|
||||
@@ -52,9 +52,7 @@ using TMapShapes = std::vector<drape_ptr<MapShape>>;
|
||||
class MapShapeMessage : public Message
|
||||
{
|
||||
public:
|
||||
explicit MapShapeMessage(TileKey const & key)
|
||||
: m_tileKey(key)
|
||||
{}
|
||||
explicit MapShapeMessage(TileKey const & key) : m_tileKey(key) {}
|
||||
|
||||
TileKey const & GetKey() const { return m_tileKey; }
|
||||
|
||||
@@ -81,8 +79,7 @@ public:
|
||||
class MapShapeReadedMessage : public MapShapeMessage
|
||||
{
|
||||
public:
|
||||
MapShapeReadedMessage(TileKey const & key, TMapShapes && shapes)
|
||||
: MapShapeMessage(key), m_shapes(std::move(shapes))
|
||||
MapShapeReadedMessage(TileKey const & key, TMapShapes && shapes) : MapShapeMessage(key), m_shapes(std::move(shapes))
|
||||
{}
|
||||
|
||||
Type GetType() const override { return Type::MapShapeReaded; }
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
namespace df
|
||||
{
|
||||
MessageAcceptor::MessageAcceptor()
|
||||
: m_infinityWaiting(false)
|
||||
{}
|
||||
MessageAcceptor::MessageAcceptor() : m_infinityWaiting(false) {}
|
||||
|
||||
bool MessageAcceptor::ProcessSingleMessage(bool waitForMessage)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user