[core] code style and remove unused code
This commit is contained in:
@@ -27,10 +27,10 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
enum class RenderState {
|
||||
never,
|
||||
partial,
|
||||
fully
|
||||
enum class RenderState : uint8_t {
|
||||
Never,
|
||||
Partial,
|
||||
Fully,
|
||||
};
|
||||
|
||||
class Map::Impl : public style::Observer {
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
View& view;
|
||||
FileSource& fileSource;
|
||||
|
||||
RenderState renderState = RenderState::never;
|
||||
RenderState renderState = RenderState::Never;
|
||||
Transform transform;
|
||||
|
||||
const MapMode mode;
|
||||
@@ -164,7 +164,7 @@ void Map::render() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (impl->renderState == RenderState::never) {
|
||||
if (impl->renderState == RenderState::Never) {
|
||||
impl->view.notifyMapChange(MapChangeWillStartRenderingMap);
|
||||
}
|
||||
|
||||
@@ -179,9 +179,9 @@ void Map::render() {
|
||||
MapChangeDidFinishRenderingFrame);
|
||||
|
||||
if (!isFullyLoaded()) {
|
||||
impl->renderState = RenderState::partial;
|
||||
} else if (impl->renderState != RenderState::fully) {
|
||||
impl->renderState = RenderState::fully;
|
||||
impl->renderState = RenderState::Partial;
|
||||
} else if (impl->renderState != RenderState::Fully) {
|
||||
impl->renderState = RenderState::Fully;
|
||||
impl->view.notifyMapChange(MapChangeDidFinishRenderingMapFullyRendered);
|
||||
if (impl->loading) {
|
||||
impl->loading = false;
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#include <mbgl/util/transition.hpp>
|
||||
#include <mbgl/util/unitbezier.hpp>
|
||||
#include <mbgl/util/interpolate.hpp>
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
|
||||
namespace mbgl { namespace util {
|
||||
|
||||
UnitBezier ease(0, 0, 0.25, 1);
|
||||
|
||||
transition::~transition() = default;
|
||||
|
||||
template <typename T>
|
||||
transition::state ease_transition<T>::update(const TimePoint& now) const {
|
||||
float t = progress(now);
|
||||
if (t >= 1) {
|
||||
value = to;
|
||||
return complete;
|
||||
} else {
|
||||
value = interpolate(from, to, ease.solve(t, 0.001));
|
||||
return running;
|
||||
}
|
||||
}
|
||||
|
||||
template class ease_transition<double>;
|
||||
|
||||
} // namespace util
|
||||
} // namespace mbgl
|
||||
@@ -1,75 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/chrono.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
class transition : private noncopyable {
|
||||
public:
|
||||
enum state {
|
||||
running,
|
||||
complete
|
||||
};
|
||||
|
||||
inline transition(const TimePoint& start_, const Duration& duration_)
|
||||
: start(start_),
|
||||
duration(duration_) {}
|
||||
|
||||
inline float progress(const TimePoint& now) const {
|
||||
if (duration == Duration::zero()) return 1;
|
||||
if (start > now) return 0;
|
||||
|
||||
return std::chrono::duration<float>(now - start) / duration;
|
||||
}
|
||||
|
||||
virtual state update(const TimePoint& now) const = 0;
|
||||
virtual ~transition();
|
||||
|
||||
protected:
|
||||
const TimePoint start;
|
||||
const Duration duration;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class ease_transition : public transition {
|
||||
public:
|
||||
ease_transition(T from_, T to_, T& value_, const TimePoint& start_, const Duration& duration_)
|
||||
: transition(start_, duration_),
|
||||
from(from_),
|
||||
to(to_),
|
||||
value(value_) {}
|
||||
|
||||
state update(const TimePoint& now) const;
|
||||
|
||||
private:
|
||||
const T from, to;
|
||||
T& value;
|
||||
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class timeout : public transition {
|
||||
public:
|
||||
timeout(T final_value_, T& value_, const TimePoint& start_, const Duration& duration_)
|
||||
: transition(start_, duration_),
|
||||
final_value(final_value_),
|
||||
value(value_) {}
|
||||
|
||||
state update(const TimePoint& now) const {
|
||||
if (progress(now) >= 1) {
|
||||
value = final_value;
|
||||
return complete;
|
||||
} else {
|
||||
return running;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const T final_value;
|
||||
T& value;
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
} // namespace mbgl
|
||||
Reference in New Issue
Block a user