switch from low/high to from/to
This commit is contained in:
@@ -375,12 +375,12 @@ void Painter::renderTileLayer(const Tile& tile, util::ptr<StyleLayer> layer_desc
|
||||
void Painter::renderBackground(util::ptr<StyleLayer> layer_desc) {
|
||||
const BackgroundProperties& properties = layer_desc->getProperties<BackgroundProperties>();
|
||||
|
||||
if (properties.image.low.size()) {
|
||||
if (properties.image.to.size()) {
|
||||
if ((properties.opacity >= 1.0f) != (pass == RenderPass::Opaque))
|
||||
return;
|
||||
|
||||
SpriteAtlasPosition imagePosA = spriteAtlas.getPosition(properties.image.low, true);
|
||||
SpriteAtlasPosition imagePosB = spriteAtlas.getPosition(properties.image.high, true);
|
||||
SpriteAtlasPosition imagePosA = spriteAtlas.getPosition(properties.image.from, true);
|
||||
SpriteAtlasPosition imagePosB = spriteAtlas.getPosition(properties.image.to, true);
|
||||
float zoomFraction = state.getZoomFraction();
|
||||
|
||||
useProgram(patternShader->program);
|
||||
@@ -401,11 +401,11 @@ void Painter::renderBackground(util::ptr<StyleLayer> layer_desc) {
|
||||
mat3 matrixA;
|
||||
matrix::identity(matrixA);
|
||||
matrix::scale(matrixA, matrixA,
|
||||
1.0f / (sizeA[0] * properties.image.lowScale),
|
||||
1.0f / (sizeA[1] * properties.image.lowScale));
|
||||
1.0f / (sizeA[0] * properties.image.fromScale),
|
||||
1.0f / (sizeA[1] * properties.image.fromScale));
|
||||
matrix::translate(matrixA, matrixA,
|
||||
std::fmod(center[0] * 512, sizeA[0] * properties.image.lowScale),
|
||||
std::fmod(center[1] * 512, sizeA[1] * properties.image.lowScale));
|
||||
std::fmod(center[0] * 512, sizeA[0] * properties.image.fromScale),
|
||||
std::fmod(center[1] * 512, sizeA[1] * properties.image.fromScale));
|
||||
matrix::rotate(matrixA, matrixA, -state.getAngle());
|
||||
matrix::scale(matrixA, matrixA,
|
||||
scale * state.getWidth() / 2,
|
||||
@@ -415,11 +415,11 @@ void Painter::renderBackground(util::ptr<StyleLayer> layer_desc) {
|
||||
mat3 matrixB;
|
||||
matrix::identity(matrixB);
|
||||
matrix::scale(matrixB, matrixB,
|
||||
1.0f / (sizeB[0] * properties.image.highScale),
|
||||
1.0f / (sizeB[1] * properties.image.highScale));
|
||||
1.0f / (sizeB[0] * properties.image.toScale),
|
||||
1.0f / (sizeB[1] * properties.image.toScale));
|
||||
matrix::translate(matrixB, matrixB,
|
||||
std::fmod(center[0] * 512, sizeB[0] * properties.image.highScale),
|
||||
std::fmod(center[1] * 512, sizeB[1] * properties.image.highScale));
|
||||
std::fmod(center[0] * 512, sizeB[0] * properties.image.toScale),
|
||||
std::fmod(center[1] * 512, sizeB[1] * properties.image.toScale));
|
||||
matrix::rotate(matrixB, matrixB, -state.getAngle());
|
||||
matrix::scale(matrixB, matrixB,
|
||||
scale * state.getWidth() / 2,
|
||||
|
||||
@@ -33,13 +33,13 @@ void Painter::renderFill(FillBucket& bucket, util::ptr<StyleLayer> layer_desc, c
|
||||
stroke_color[3] *= properties.opacity;
|
||||
}
|
||||
|
||||
const bool pattern = properties.image.low.size();
|
||||
const bool pattern = properties.image.from.size();
|
||||
|
||||
bool outline = properties.antialias && !pattern && properties.stroke_color != properties.fill_color;
|
||||
bool fringeline = properties.antialias && !pattern && properties.stroke_color == properties.fill_color;
|
||||
|
||||
// Because we're drawing top-to-bottom, and we update the stencil mask
|
||||
// below, we have to draw the outline first (!)
|
||||
// befrom, we have to draw the outline first (!)
|
||||
if (outline && pass == RenderPass::Translucent) {
|
||||
useProgram(outlineShader->program);
|
||||
outlineShader->u_matrix = vtxMatrix;
|
||||
@@ -59,20 +59,20 @@ void Painter::renderFill(FillBucket& bucket, util::ptr<StyleLayer> layer_desc, c
|
||||
if (pattern) {
|
||||
// Image fill.
|
||||
if (pass == RenderPass::Translucent) {
|
||||
const SpriteAtlasPosition posA = spriteAtlas.getPosition(properties.image.low, true);
|
||||
const SpriteAtlasPosition posB = spriteAtlas.getPosition(properties.image.high, true);
|
||||
const SpriteAtlasPosition posA = spriteAtlas.getPosition(properties.image.from, true);
|
||||
const SpriteAtlasPosition posB = spriteAtlas.getPosition(properties.image.to, true);
|
||||
float factor = 8.0 / std::pow(2, state.getIntegerZoom() - id.z);
|
||||
|
||||
mat3 patternMatrixA;
|
||||
matrix::identity(patternMatrixA);
|
||||
matrix::scale(patternMatrixA, patternMatrixA,
|
||||
1.0f / (posA.size[0] * factor * properties.image.lowScale),
|
||||
1.0f / (posA.size[1] * factor * properties.image.lowScale));
|
||||
1.0f / (posA.size[0] * factor * properties.image.fromScale),
|
||||
1.0f / (posA.size[1] * factor * properties.image.fromScale));
|
||||
mat3 patternMatrixB;
|
||||
matrix::identity(patternMatrixB);
|
||||
matrix::scale(patternMatrixB, patternMatrixB,
|
||||
1.0f / (posB.size[0] * factor * properties.image.highScale),
|
||||
1.0f / (posB.size[1] * factor * properties.image.highScale));
|
||||
1.0f / (posB.size[0] * factor * properties.image.toScale),
|
||||
1.0f / (posB.size[1] * factor * properties.image.toScale));
|
||||
|
||||
useProgram(patternShader->program);
|
||||
patternShader->u_matrix = vtxMatrix;
|
||||
|
||||
@@ -70,7 +70,7 @@ void Painter::renderLine(LineBucket& bucket, util::ptr<StyleLayer> layer_desc, c
|
||||
bucket.drawPoints(*linejoinShader);
|
||||
}
|
||||
|
||||
if (properties.dash_array.low.size()) {
|
||||
if (properties.dash_array.from.size()) {
|
||||
|
||||
useProgram(linesdfShader->program);
|
||||
|
||||
@@ -81,14 +81,14 @@ void Painter::renderLine(LineBucket& bucket, util::ptr<StyleLayer> layer_desc, c
|
||||
linesdfShader->u_blur = blur;
|
||||
linesdfShader->u_color = color;
|
||||
|
||||
LinePatternPos posA = lineAtlas.getDashPosition(properties.dash_array.low, bucket.properties.cap == CapType::Round);
|
||||
LinePatternPos posB = lineAtlas.getDashPosition(properties.dash_array.high, bucket.properties.cap == CapType::Round);
|
||||
LinePatternPos posA = lineAtlas.getDashPosition(properties.dash_array.from, bucket.properties.cap == CapType::Round);
|
||||
LinePatternPos posB = lineAtlas.getDashPosition(properties.dash_array.to, bucket.properties.cap == CapType::Round);
|
||||
lineAtlas.bind();
|
||||
|
||||
float patternratio = std::pow(2.0, std::floor(std::log2(state.getScale())) - id.z) / 8.0;
|
||||
float scaleXA = patternratio / posA.width / properties.dash_line_width / properties.dash_array.lowScale;
|
||||
float scaleXA = patternratio / posA.width / properties.dash_line_width / properties.dash_array.fromScale;
|
||||
float scaleYA = -posA.height / 2.0;
|
||||
float scaleXB = patternratio / posB.width / properties.dash_line_width / properties.dash_array.highScale;
|
||||
float scaleXB = patternratio / posB.width / properties.dash_line_width / properties.dash_array.toScale;
|
||||
float scaleYB = -posB.height / 2.0;
|
||||
|
||||
linesdfShader->u_patternscale_a = {{ scaleXA, scaleYA }};
|
||||
@@ -101,9 +101,9 @@ void Painter::renderLine(LineBucket& bucket, util::ptr<StyleLayer> layer_desc, c
|
||||
|
||||
bucket.drawLineSDF(*linesdfShader);
|
||||
|
||||
} else if (properties.image.low.size()) {
|
||||
SpriteAtlasPosition imagePosA = spriteAtlas.getPosition(properties.image.low, true);
|
||||
SpriteAtlasPosition imagePosB = spriteAtlas.getPosition(properties.image.high, true);
|
||||
} else if (properties.image.from.size()) {
|
||||
SpriteAtlasPosition imagePosA = spriteAtlas.getPosition(properties.image.from, true);
|
||||
SpriteAtlasPosition imagePosB = spriteAtlas.getPosition(properties.image.to, true);
|
||||
|
||||
float factor = 8.0 / std::pow(2, state.getIntegerZoom() - id.z);
|
||||
|
||||
@@ -115,10 +115,10 @@ void Painter::renderLine(LineBucket& bucket, util::ptr<StyleLayer> layer_desc, c
|
||||
linepatternShader->u_ratio = ratio;
|
||||
linepatternShader->u_blur = blur;
|
||||
|
||||
linepatternShader->u_pattern_size_a = {{imagePosA.size[0] * factor * properties.image.lowScale, imagePosA.size[1]}};
|
||||
linepatternShader->u_pattern_size_a = {{imagePosA.size[0] * factor * properties.image.fromScale, imagePosA.size[1]}};
|
||||
linepatternShader->u_pattern_tl_a = imagePosA.tl;
|
||||
linepatternShader->u_pattern_br_a = imagePosA.br;
|
||||
linepatternShader->u_pattern_size_b = {{imagePosB.size[0] * factor * properties.image.highScale, imagePosB.size[1]}};
|
||||
linepatternShader->u_pattern_size_b = {{imagePosB.size[0] * factor * properties.image.toScale, imagePosB.size[1]}};
|
||||
linepatternShader->u_pattern_tl_b = imagePosB.tl;
|
||||
linepatternShader->u_pattern_br_b = imagePosB.br;
|
||||
linepatternShader->u_fade = properties.image.t;
|
||||
|
||||
@@ -21,26 +21,28 @@ T PiecewiseConstantFunction<T>::evaluate(float z, const ZoomHistory &zh) const {
|
||||
|
||||
float fraction = std::fmod(z, 1.0f);
|
||||
float t = std::min((std::chrono::steady_clock::now() - zh.lastIntegerZoomTime) / duration, 1.0f);
|
||||
float scale = 1.0f;
|
||||
uint32_t low, high;
|
||||
float fromScale = 1.0f;
|
||||
float toScale = 1.0f;
|
||||
uint32_t from, to;
|
||||
|
||||
if (z > zh.lastIntegerZoom) {
|
||||
result.t = fraction + (1.0f - fraction) * t;
|
||||
scale *= 2.0f;
|
||||
low = getBiggestStopLessThan(values, z - 1.0f);
|
||||
high = getBiggestStopLessThan(values, z);
|
||||
from = getBiggestStopLessThan(values, z - 1.0f);
|
||||
to = getBiggestStopLessThan(values, z);
|
||||
fromScale *= 2.0f;
|
||||
|
||||
} else {
|
||||
result.t = fraction - fraction * t;
|
||||
low = getBiggestStopLessThan(values, z);
|
||||
high = getBiggestStopLessThan(values, z + 1.0f);
|
||||
result.t = 1 - (1 - t) * fraction;
|
||||
to = getBiggestStopLessThan(values, z);
|
||||
from = getBiggestStopLessThan(values, z + 1.0f);
|
||||
fromScale /= 2.0f;
|
||||
}
|
||||
|
||||
|
||||
result.low = values[low].second.low;
|
||||
result.high = values[high].second.low;
|
||||
result.lowScale = scale;
|
||||
result.highScale = scale / 2;
|
||||
result.from = values[from].second.to;
|
||||
result.to = values[to].second.to;
|
||||
result.fromScale = fromScale;
|
||||
result.toScale = toScale;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ template <>
|
||||
Faded<std::vector<float>> StyleParser::parseFunctionArgument(JSVal value) {
|
||||
Faded<std::vector<float>> parsed;
|
||||
JSVal rvalue = replaceConstant(value);
|
||||
parsed.low = std::get<1>(parseFloatArray(rvalue));
|
||||
parsed.to = std::get<1>(parseFloatArray(rvalue));
|
||||
return parsed;
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ Faded<std::string> StyleParser::parseFunctionArgument(JSVal value) {
|
||||
JSVal rvalue = replaceConstant(value);
|
||||
if (rvalue.IsString()) {
|
||||
Faded<std::string> parsed;
|
||||
parsed.low = { value.GetString(), value.GetStringLength() };
|
||||
parsed.to = { value.GetString(), value.GetStringLength() };
|
||||
return parsed;
|
||||
} else {
|
||||
Log::Warning(Event::ParseStyle, "function argument must be a string");
|
||||
@@ -560,7 +560,7 @@ template<> std::tuple<bool, PiecewiseConstantFunction<Faded<std::vector<float>>>
|
||||
} else if (value.IsArray()) {
|
||||
Faded<std::vector<float>> parsed;
|
||||
std::tuple<bool, std::vector<float>> floatarray = parseFloatArray(value);
|
||||
parsed.low = std::get<1>(floatarray);
|
||||
parsed.to = std::get<1>(floatarray);
|
||||
return std::tuple<bool, PiecewiseConstantFunction<Faded<std::vector<float>>>> { std::get<0>(floatarray), parsed };
|
||||
} else {
|
||||
Log::Warning(Event::ParseStyle, "value of '%s' must be an array of numbers, or a number array function", property_name);
|
||||
@@ -573,7 +573,7 @@ template<> std::tuple<bool, PiecewiseConstantFunction<Faded<std::string>>> Style
|
||||
return parsePiecewiseConstantFunction<Faded<std::string>>(value);
|
||||
} else if (value.IsString()) {
|
||||
Faded<std::string> parsed;
|
||||
parsed.low = { value.GetString(), value.GetStringLength() };
|
||||
parsed.to = { value.GetString(), value.GetStringLength() };
|
||||
return std::tuple<bool, PiecewiseConstantFunction<Faded<std::string>>> { true, parsed };
|
||||
} else {
|
||||
Log::Warning(Event::ParseStyle, "value of '%s' must be string or a string function", property_name);
|
||||
|
||||
@@ -14,10 +14,10 @@ typedef std::array<float, 4> Color;
|
||||
|
||||
template <typename T>
|
||||
struct Faded {
|
||||
T low;
|
||||
float lowScale;
|
||||
T high;
|
||||
float highScale;
|
||||
T from;
|
||||
float fromScale;
|
||||
T to;
|
||||
float toScale;
|
||||
float t;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user