Merge branch 'master' of github.com:mapbox/llmr-native
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <string>
|
||||
#include <limits>
|
||||
#include <set>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
@@ -92,9 +93,9 @@ struct GenericClass {
|
||||
boost::optional<FunctionProperty> opacity;
|
||||
boost::optional<PropertyTransition> opacity_transition;
|
||||
boost::optional<bool> prerender;
|
||||
boost::optional<FunctionProperty> prerenderBuffer;
|
||||
boost::optional<FunctionProperty> prerenderSize;
|
||||
boost::optional<FunctionProperty> prerenderBlur;
|
||||
boost::optional<float> prerenderBuffer;
|
||||
boost::optional<uint16_t> prerenderSize;
|
||||
boost::optional<uint16_t> prerenderBlur;
|
||||
};
|
||||
|
||||
struct GenericProperties {
|
||||
@@ -221,4 +222,17 @@ const CompositeProperties defaultCompositeProperties;
|
||||
|
||||
}
|
||||
|
||||
|
||||
namespace std {
|
||||
|
||||
template <> struct hash<llmr::TransitionablePropertyKey> {
|
||||
public:
|
||||
inline size_t operator()(llmr::TransitionablePropertyKey prop) const {
|
||||
typedef typename std::underlying_type<llmr::TransitionablePropertyKey>::type type;
|
||||
return std::hash<type>()(static_cast<type>(prop));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -59,15 +59,15 @@ public:
|
||||
std::unordered_map<std::string, TextProperties> texts;
|
||||
std::unordered_map<std::string, RasterProperties> rasters;
|
||||
std::unordered_map<std::string, CompositeProperties> composites;
|
||||
std::map<std::string, std::map<TransitionablePropertyKey, std::string>> effective_classes;
|
||||
std::unordered_map<std::string, std::unordered_map<TransitionablePropertyKey, std::string>> effective_classes;
|
||||
} computed;
|
||||
|
||||
private:
|
||||
bool transitionInProgress(std::string layer_name, TransitionablePropertyKey key);
|
||||
bool transitionExists(std::string layer_name, TransitionablePropertyKey key);
|
||||
bool inNeedOfTransition(std::string layer_name, TransitionablePropertyKey key);
|
||||
uint64_t transitionDuration(std::string layer_name, TransitionablePropertyKey key);
|
||||
uint64_t transitionDelay(std::string layer_name, TransitionablePropertyKey key);
|
||||
bool transitionInProgress(const std::string &layer_name, TransitionablePropertyKey key, time start);
|
||||
bool transitionExists(const std::string &layer_name, TransitionablePropertyKey key) const;
|
||||
bool inNeedOfTransition(const std::string &layer_name, TransitionablePropertyKey key) const;
|
||||
uint64_t transitionDuration(const std::string &layer_name, TransitionablePropertyKey key) const;
|
||||
uint64_t transitionDelay(const std::string &layer_name, TransitionablePropertyKey key) const;
|
||||
|
||||
void cascadeProperties(GenericProperties &properties, const GenericClass& klass, const std::string& layer_name, const std::string& class_name, float z);
|
||||
|
||||
@@ -81,7 +81,7 @@ private:
|
||||
std::unordered_map<std::string, TextProperties> texts;
|
||||
std::unordered_map<std::string, RasterProperties> rasters;
|
||||
std::unordered_map<std::string, CompositeProperties> composites;
|
||||
std::map<std::string, std::map<TransitionablePropertyKey, std::string>> effective_classes;
|
||||
std::unordered_map<std::string, std::unordered_map<TransitionablePropertyKey, std::string>> effective_classes;
|
||||
} previous;
|
||||
|
||||
// Settings values currently being transitioned.
|
||||
@@ -95,8 +95,8 @@ private:
|
||||
std::unordered_map<std::string, CompositeProperties> composites;
|
||||
} transitioning;
|
||||
|
||||
std::map<std::string, std::map<TransitionablePropertyKey, PropertyTransition>> properties_to_transition;
|
||||
std::map<std::string, std::map<TransitionablePropertyKey, std::shared_ptr<util::transition>>> transitions;
|
||||
std::unordered_map<std::string, std::unordered_map<TransitionablePropertyKey, PropertyTransition>> properties_to_transition;
|
||||
std::unordered_map<std::string, std::unordered_map<TransitionablePropertyKey, std::shared_ptr<util::transition>>> transitions;
|
||||
uint64_t default_transition_duration = 0;
|
||||
bool initial_render_complete = false;
|
||||
|
||||
|
||||
@@ -61,21 +61,17 @@ typedef std::vector<GlyphBox> GlyphBoxes;
|
||||
struct PlacedGlyph {
|
||||
explicit PlacedGlyph(const vec2<float> &tl, const vec2<float> &tr,
|
||||
const vec2<float> &bl, const vec2<float> &br,
|
||||
const Rect<uint16_t> &tex, uint32_t width,
|
||||
uint32_t height, float angle, const GlyphBox &glyphBox)
|
||||
const Rect<uint16_t> &tex, float angle, const GlyphBox &glyphBox)
|
||||
: tl(tl),
|
||||
tr(tr),
|
||||
bl(bl),
|
||||
br(br),
|
||||
tex(tex),
|
||||
width(width),
|
||||
height(height),
|
||||
angle(angle),
|
||||
glyphBox(glyphBox) {}
|
||||
|
||||
vec2<float> tl, tr, bl, br;
|
||||
Rect<uint16_t> tex;
|
||||
uint32_t width, height;
|
||||
float angle;
|
||||
GlyphBox glyphBox;
|
||||
};
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
'product_extension': 'app',
|
||||
'mac_bundle': 1,
|
||||
'mac_bundle_resources': [
|
||||
'<!@(find img -type f)',
|
||||
'<(PRODUCT_DIR)/MVKMapKit.bundle'
|
||||
'<!@(find img -type f)'
|
||||
],
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
|
||||
@@ -38,8 +38,6 @@ void TextBucket::addGlyphs(const PlacedGlyphs &glyphs, float placementZoom,
|
||||
const auto &bl = glyph.bl;
|
||||
const auto &br = glyph.br;
|
||||
const auto &tex = glyph.tex;
|
||||
const auto &width = glyph.width;
|
||||
const auto &height = glyph.height;
|
||||
const auto &angle = glyph.angle;
|
||||
|
||||
float minZoom = util::max(
|
||||
@@ -78,13 +76,13 @@ void TextBucket::addGlyphs(const PlacedGlyphs &glyphs, float placementZoom,
|
||||
tex.y, angle, minZoom, placementRange, maxZoom,
|
||||
placementZoom);
|
||||
vertexBuffer.add(glyphAnchor.x, glyphAnchor.y, tr.x, tr.y,
|
||||
tex.x + width, tex.y, angle, minZoom, placementRange,
|
||||
tex.x + tex.w, tex.y, angle, minZoom, placementRange,
|
||||
maxZoom, placementZoom);
|
||||
vertexBuffer.add(glyphAnchor.x, glyphAnchor.y, bl.x, bl.y, tex.x,
|
||||
tex.y + height, angle, minZoom, placementRange,
|
||||
tex.y + tex.h, angle, minZoom, placementRange,
|
||||
maxZoom, placementZoom);
|
||||
vertexBuffer.add(glyphAnchor.x, glyphAnchor.y, br.x, br.y,
|
||||
tex.x + width, tex.y + height, angle, minZoom,
|
||||
tex.x + tex.w, tex.y + tex.h, angle, minZoom,
|
||||
placementRange, maxZoom, placementZoom);
|
||||
|
||||
// add the two triangles, referencing the four coordinates we just
|
||||
|
||||
@@ -56,15 +56,15 @@ void Style::cascadeProperties(GenericProperties &properties, const GenericClass&
|
||||
}
|
||||
|
||||
if (klass.prerenderBuffer) {
|
||||
properties.prerenderBuffer = klass.prerenderBuffer.get().evaluate<double>(z);
|
||||
properties.prerenderBuffer = klass.prerenderBuffer.get();
|
||||
}
|
||||
|
||||
if (klass.prerenderSize) {
|
||||
properties.prerenderSize = klass.prerenderSize.get().evaluate<uint64_t>(z);
|
||||
properties.prerenderSize = klass.prerenderSize.get();
|
||||
}
|
||||
|
||||
if (klass.prerenderBlur) {
|
||||
properties.prerenderBlur = klass.prerenderBlur.get().evaluate<uint64_t>(z);
|
||||
properties.prerenderBlur = klass.prerenderBlur.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ void Style::cascade(float z) {
|
||||
const std::string& layer_name = fill_pair.first;
|
||||
|
||||
// translate
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Translate)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Translate, start)) {
|
||||
|
||||
computed.fills[layer_name].translate = transitioning.fills[layer_name].translate;
|
||||
|
||||
@@ -341,7 +341,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// fill color
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::FillColor)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::FillColor, start)) {
|
||||
|
||||
computed.fills[layer_name].fill_color = transitioning.fills[layer_name].fill_color;
|
||||
|
||||
@@ -360,7 +360,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// stroke color
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::StrokeColor)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::StrokeColor, start)) {
|
||||
|
||||
computed.fills[layer_name].stroke_color = transitioning.fills[layer_name].stroke_color;
|
||||
|
||||
@@ -379,7 +379,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// opacity
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Opacity)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Opacity, start)) {
|
||||
|
||||
computed.fills[layer_name].opacity = transitioning.fills[layer_name].opacity;
|
||||
|
||||
@@ -403,7 +403,7 @@ void Style::cascade(float z) {
|
||||
const std::string& layer_name = line_pair.first;
|
||||
|
||||
// translate
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Translate)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Translate, start)) {
|
||||
|
||||
computed.lines[layer_name].translate = transitioning.lines[layer_name].translate;
|
||||
|
||||
@@ -422,7 +422,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// width
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Width)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Width, start)) {
|
||||
|
||||
computed.lines[layer_name].width = transitioning.lines[layer_name].width;
|
||||
|
||||
@@ -441,7 +441,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// offset
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Offset)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Offset, start)) {
|
||||
|
||||
computed.lines[layer_name].offset = transitioning.lines[layer_name].offset;
|
||||
|
||||
@@ -460,7 +460,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// color
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Color)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Color, start)) {
|
||||
|
||||
computed.lines[layer_name].color = transitioning.lines[layer_name].color;
|
||||
|
||||
@@ -479,7 +479,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// dasharray
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::DashArray)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::DashArray, start)) {
|
||||
|
||||
computed.lines[layer_name].dash_array = transitioning.lines[layer_name].dash_array;
|
||||
|
||||
@@ -498,7 +498,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// opacity
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Opacity)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Opacity, start)) {
|
||||
|
||||
computed.lines[layer_name].opacity = transitioning.lines[layer_name].opacity;
|
||||
|
||||
@@ -522,7 +522,7 @@ void Style::cascade(float z) {
|
||||
const std::string& layer_name = icon_pair.first;
|
||||
|
||||
// translate
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Translate)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Translate, start)) {
|
||||
|
||||
computed.icons[layer_name].translate = transitioning.icons[layer_name].translate;
|
||||
|
||||
@@ -541,7 +541,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// color
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Color)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Color, start)) {
|
||||
|
||||
computed.icons[layer_name].color = transitioning.icons[layer_name].color;
|
||||
|
||||
@@ -560,7 +560,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// opacity
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Opacity)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Opacity, start)) {
|
||||
|
||||
computed.icons[layer_name].opacity = transitioning.icons[layer_name].opacity;
|
||||
|
||||
@@ -579,7 +579,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// radius
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Radius)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Radius, start)) {
|
||||
|
||||
computed.icons[layer_name].radius = transitioning.icons[layer_name].radius;
|
||||
|
||||
@@ -598,7 +598,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// blur
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Blur)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Blur, start)) {
|
||||
|
||||
computed.icons[layer_name].blur = transitioning.icons[layer_name].blur;
|
||||
|
||||
@@ -622,7 +622,7 @@ void Style::cascade(float z) {
|
||||
const std::string& layer_name = text_pair.first;
|
||||
|
||||
// translate
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Translate)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Translate, start)) {
|
||||
|
||||
computed.texts[layer_name].translate = transitioning.texts[layer_name].translate;
|
||||
|
||||
@@ -641,7 +641,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// color
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Color)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Color, start)) {
|
||||
|
||||
computed.texts[layer_name].color = transitioning.texts[layer_name].color;
|
||||
|
||||
@@ -660,7 +660,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// halo
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Halo)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Halo, start)) {
|
||||
|
||||
computed.texts[layer_name].halo = transitioning.texts[layer_name].halo;
|
||||
|
||||
@@ -679,7 +679,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// halo radius
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::HaloRadius)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::HaloRadius, start)) {
|
||||
|
||||
computed.texts[layer_name].halo_radius = transitioning.texts[layer_name].halo_radius;
|
||||
|
||||
@@ -698,7 +698,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// halo blur
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::HaloBlur)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::HaloBlur, start)) {
|
||||
|
||||
computed.texts[layer_name].halo_blur = transitioning.texts[layer_name].halo_blur;
|
||||
|
||||
@@ -717,7 +717,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// opacity
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Opacity)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Opacity, start)) {
|
||||
|
||||
computed.texts[layer_name].opacity = transitioning.texts[layer_name].opacity;
|
||||
|
||||
@@ -741,7 +741,7 @@ void Style::cascade(float z) {
|
||||
const std::string& layer_name = raster_pair.first;
|
||||
|
||||
// opacity
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Opacity)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Opacity, start)) {
|
||||
|
||||
computed.rasters[layer_name].opacity = transitioning.rasters[layer_name].opacity;
|
||||
|
||||
@@ -765,7 +765,7 @@ void Style::cascade(float z) {
|
||||
const std::string& layer_name = composite_pair.first;
|
||||
|
||||
// opacity
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Opacity)) {
|
||||
if (transitionInProgress(layer_name, TransitionablePropertyKey::Opacity, start)) {
|
||||
|
||||
computed.composites[layer_name].opacity = transitioning.composites[layer_name].opacity;
|
||||
|
||||
@@ -787,7 +787,7 @@ void Style::cascade(float z) {
|
||||
// Background
|
||||
{
|
||||
// color
|
||||
if (transitionInProgress("background", TransitionablePropertyKey::Color)) {
|
||||
if (transitionInProgress("background", TransitionablePropertyKey::Color, start)) {
|
||||
|
||||
computed.background.color = transitioning.background.color;
|
||||
|
||||
@@ -806,7 +806,7 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// opacity
|
||||
if (transitionInProgress("background", TransitionablePropertyKey::Opacity)) {
|
||||
if (transitionInProgress("background", TransitionablePropertyKey::Opacity, start)) {
|
||||
|
||||
computed.background.opacity = transitioning.background.opacity;
|
||||
|
||||
@@ -826,31 +826,100 @@ void Style::cascade(float z) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Style::transitionInProgress(std::string layer_name, TransitionablePropertyKey key) {
|
||||
if (!transitionExists(layer_name, key)) return false;
|
||||
bool Style::transitionInProgress(const std::string &layer_name, TransitionablePropertyKey key,
|
||||
time start) {
|
||||
const auto it = transitions.find(layer_name);
|
||||
if (it == transitions.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (transitions[layer_name].find(key)->second->update(util::now()) != util::transition::complete);
|
||||
const auto &const_transition = it->second;
|
||||
const auto const_transition_it = const_transition.find(key);
|
||||
|
||||
if (const_transition_it == const_transition.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return const_transition_it->second->update(start) != util::transition::complete;
|
||||
}
|
||||
|
||||
bool Style::transitionExists(std::string layer_name, TransitionablePropertyKey key) {
|
||||
return (transitions[layer_name].count(key) != 0);
|
||||
bool Style::transitionExists(const std::string &layer_name, TransitionablePropertyKey key) const {
|
||||
const auto it = transitions.find(layer_name);
|
||||
if (it == transitions.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto &const_transition = it->second;
|
||||
return const_transition.find(key) != const_transition.end();
|
||||
}
|
||||
|
||||
bool Style::inNeedOfTransition(std::string layer_name, TransitionablePropertyKey key) {
|
||||
if (!transitionDuration(layer_name, key)) return false;
|
||||
if (transitionExists(layer_name, key)) return false;
|
||||
static const std::string empty_class_name;
|
||||
inline const std::string &
|
||||
find_effective_class(const std::unordered_map<
|
||||
std::string, std::unordered_map<TransitionablePropertyKey, std::string>> &
|
||||
effective_class_keys,
|
||||
const std::string &layer_name, TransitionablePropertyKey key) {
|
||||
const auto effective_class_keys_it = effective_class_keys.find(layer_name);
|
||||
if (effective_class_keys_it != effective_class_keys.end()) {
|
||||
const auto &effective_classes = effective_class_keys_it->second;
|
||||
const auto effective_class_it = effective_classes.find(key);
|
||||
if (effective_class_it != effective_classes.end()) {
|
||||
return effective_class_it->second;
|
||||
}
|
||||
}
|
||||
|
||||
return (computed.effective_classes[layer_name][key] != previous.effective_classes[layer_name][key]);
|
||||
return empty_class_name;
|
||||
}
|
||||
|
||||
uint64_t Style::transitionDuration(std::string layer_name, TransitionablePropertyKey key) {
|
||||
return (properties_to_transition[layer_name].count(key) ?
|
||||
properties_to_transition[layer_name][key].duration :
|
||||
default_transition_duration) * 1_millisecond;
|
||||
bool Style::inNeedOfTransition(const std::string &layer_name, TransitionablePropertyKey key) const {
|
||||
if (!transitionDuration(layer_name, key)) {
|
||||
return false;
|
||||
} else if (transitionExists(layer_name, key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// This is a const version of this code:
|
||||
// return (computed.effective_classes[layer_name][key] !=
|
||||
// previous.effective_classes[layer_name][key]);
|
||||
|
||||
const std::string &computed_class =
|
||||
find_effective_class(computed.effective_classes, layer_name, key);
|
||||
const std::string &previous_class =
|
||||
find_effective_class(previous.effective_classes, layer_name, key);
|
||||
|
||||
return computed_class != previous_class;
|
||||
}
|
||||
|
||||
uint64_t Style::transitionDelay(std::string layer_name, TransitionablePropertyKey key) {
|
||||
return (properties_to_transition[layer_name][key].delay * 1_millisecond);
|
||||
uint64_t Style::transitionDuration(const std::string &layer_name,
|
||||
TransitionablePropertyKey key) const {
|
||||
const auto it = properties_to_transition.find(layer_name);
|
||||
if (it == properties_to_transition.end()) {
|
||||
return default_transition_duration * 1_millisecond;
|
||||
}
|
||||
|
||||
const auto &const_properties_to_transition = it->second;
|
||||
const auto it2 = const_properties_to_transition.find(key);
|
||||
if (it2 != const_properties_to_transition.end()) {
|
||||
return it2->second.duration * 1_millisecond;
|
||||
} else {
|
||||
return default_transition_duration * 1_millisecond;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t Style::transitionDelay(const std::string &layer_name,
|
||||
TransitionablePropertyKey key) const {
|
||||
const auto it = properties_to_transition.find(layer_name);
|
||||
if (it == properties_to_transition.end()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const auto &const_properties_to_transition = it->second;
|
||||
const auto it2 = const_properties_to_transition.find(key);
|
||||
if (it2 != const_properties_to_transition.end()) {
|
||||
return it2->second.delay * 1_millisecond;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool Style::needsTransition() const {
|
||||
|
||||
@@ -525,15 +525,15 @@ void StyleParser::parseGenericClass(GenericClass &klass, JSVal value) {
|
||||
}
|
||||
|
||||
if (value.HasMember("prerender-buffer")) {
|
||||
klass.prerenderBuffer = parseFunction(value["prerender-buffer"]);
|
||||
klass.prerenderBuffer = toNumber<double>(parseValue(value["prerender-buffer"]));
|
||||
}
|
||||
|
||||
if (value.HasMember("prerender-size")) {
|
||||
klass.prerenderBuffer = parseFunction(value["prerender-size"]);
|
||||
klass.prerenderBuffer = toNumber<uint64_t>(parseValue(value["prerender-size"]));
|
||||
}
|
||||
|
||||
if (value.HasMember("prerender-blur")) {
|
||||
klass.prerenderBlur = parseFunction(value["prerender-blur"]);
|
||||
klass.prerenderBlur = toNumber<uint64_t>(parseValue(value["prerender-blur"]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -174,20 +174,8 @@ PlacedGlyphs getGlyphs(Anchor &anchor, float advance, const Shaping &shaping,
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t width = glyph.metrics.width;
|
||||
uint32_t height = glyph.metrics.height;
|
||||
|
||||
width += buffer * 2;
|
||||
height += buffer * 2;
|
||||
|
||||
// Increase to next number divisible by 4, but at least 1.
|
||||
// This is so we can scale down the texture coordinates and pack them
|
||||
// into 2 bytes rather than 4 bytes.
|
||||
width += (4 - width % 4);
|
||||
height += (4 - height % 4);
|
||||
|
||||
float x =
|
||||
(origin.x + placed.x + glyph.metrics.left - buffer + width / 2) *
|
||||
(origin.x + placed.x + glyph.metrics.left - buffer + glyph.rect.w / 2) *
|
||||
fontScale;
|
||||
|
||||
GlyphInstances glyphInstances;
|
||||
@@ -204,8 +192,8 @@ PlacedGlyphs getGlyphs(Anchor &anchor, float advance, const Shaping &shaping,
|
||||
|
||||
const float x1 = origin.x + placed.x + glyph.metrics.left - buffer;
|
||||
const float y1 = origin.y + placed.y - glyph.metrics.top - buffer;
|
||||
const float x2 = x1 + width;
|
||||
const float y2 = y1 + height;
|
||||
const float x2 = x1 + glyph.rect.w;
|
||||
const float y2 = y1 + glyph.rect.h;
|
||||
|
||||
const vec2<float> otl{x1, y1};
|
||||
const vec2<float> otr{x2, y1};
|
||||
@@ -249,7 +237,7 @@ PlacedGlyphs getGlyphs(Anchor &anchor, float advance, const Shaping &shaping,
|
||||
|
||||
// Remember the glyph for later insertion.
|
||||
glyphs.emplace_back(PlacedGlyph{
|
||||
tl, tr, bl, br, glyph.rect, width, height,
|
||||
tl, tr, bl, br, glyph.rect,
|
||||
static_cast<float>(
|
||||
std::fmod((anchor.angle + rotate + instance.offset + 2 * M_PI),
|
||||
(2 * M_PI))),
|
||||
|
||||
Reference in New Issue
Block a user