[core] Implement CrossFadedDataDrivenProperty to add support for feature expressions in *-pattern properties
This commit is contained in:
@@ -20,13 +20,13 @@ Values makeValues(const RenderLinePaintProperties::PossiblyEvaluated& properties
|
||||
Args&&... args) {
|
||||
|
||||
return Values {
|
||||
uniforms::u_matrix::Value{
|
||||
uniforms::u_matrix::Value(
|
||||
tile.translatedMatrix(properties.get<LineTranslate>(),
|
||||
properties.get<LineTranslateAnchor>(),
|
||||
state)
|
||||
},
|
||||
uniforms::u_ratio::Value{ 1.0f / tile.id.pixelsToTileUnits(1.0, state.getZoom()) },
|
||||
uniforms::u_gl_units_to_pixels::Value{{{ 1.0f / pixelsToGLUnits[0], 1.0f / pixelsToGLUnits[1] }}},
|
||||
),
|
||||
uniforms::u_ratio::Value( 1.0f / tile.id.pixelsToTileUnits(1.0, state.getZoom()) ),
|
||||
uniforms::u_gl_units_to_pixels::Value({ {1.0f / pixelsToGLUnits[0], 1.0f / pixelsToGLUnits[1]} }),
|
||||
std::forward<Args>(args)...
|
||||
};
|
||||
}
|
||||
@@ -52,9 +52,10 @@ LineSDFProgram::uniformValues(const RenderLinePaintProperties::PossiblyEvaluated
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
const LinePatternPos& posA,
|
||||
const LinePatternPos& posB,
|
||||
const CrossfadeParameters& crossfade,
|
||||
float atlasWidth) {
|
||||
const float widthA = posA.width * properties.get<LineDasharray>().fromScale;
|
||||
const float widthB = posB.width * properties.get<LineDasharray>().toScale;
|
||||
const float widthA = posA.width * crossfade.fromScale;
|
||||
const float widthB = posB.width * crossfade.toScale;
|
||||
|
||||
std::array<float, 2> scaleA {{
|
||||
1.0f / tile.id.pixelsToTileUnits(widthA, state.getIntegerZoom()),
|
||||
@@ -71,13 +72,13 @@ LineSDFProgram::uniformValues(const RenderLinePaintProperties::PossiblyEvaluated
|
||||
tile,
|
||||
state,
|
||||
pixelsToGLUnits,
|
||||
uniforms::u_patternscale_a::Value{ scaleA },
|
||||
uniforms::u_patternscale_b::Value{ scaleB },
|
||||
uniforms::u_tex_y_a::Value{ posA.y },
|
||||
uniforms::u_tex_y_b::Value{ posB.y },
|
||||
uniforms::u_mix::Value{ properties.get<LineDasharray>().t },
|
||||
uniforms::u_sdfgamma::Value{ atlasWidth / (std::min(widthA, widthB) * 256.0f * pixelRatio) / 2.0f },
|
||||
uniforms::u_image::Value{ 0 }
|
||||
uniforms::u_patternscale_a::Value( scaleA ),
|
||||
uniforms::u_patternscale_b::Value( scaleB ),
|
||||
uniforms::u_tex_y_a::Value( posA.y ),
|
||||
uniforms::u_tex_y_b::Value( posB.y ),
|
||||
uniforms::u_mix::Value( crossfade.t ),
|
||||
uniforms::u_sdfgamma::Value( atlasWidth / (std::min(widthA, widthB) * 256.0f * pixelRatio) / 2.0f ),
|
||||
uniforms::u_image::Value( 0 )
|
||||
);
|
||||
}
|
||||
|
||||
@@ -87,32 +88,20 @@ LinePatternProgram::uniformValues(const RenderLinePaintProperties::PossiblyEvalu
|
||||
const TransformState& state,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
const Size atlasSize,
|
||||
const ImagePosition& posA,
|
||||
const ImagePosition& posB) {
|
||||
std::array<float, 2> sizeA {{
|
||||
tile.id.pixelsToTileUnits(posA.displaySize()[0] * properties.get<LinePattern>().fromScale, state.getIntegerZoom()),
|
||||
posA.displaySize()[1]
|
||||
}};
|
||||
|
||||
std::array<float, 2> sizeB {{
|
||||
tile.id.pixelsToTileUnits(posB.displaySize()[0] * properties.get<LinePattern>().toScale, state.getIntegerZoom()),
|
||||
posB.displaySize()[1]
|
||||
}};
|
||||
const CrossfadeParameters& crossfade,
|
||||
const float pixelRatio) {
|
||||
|
||||
const auto tileRatio = 1 / tile.id.pixelsToTileUnits(1, state.getIntegerZoom());
|
||||
|
||||
return makeValues<LinePatternProgram::UniformValues>(
|
||||
properties,
|
||||
tile,
|
||||
state,
|
||||
pixelsToGLUnits,
|
||||
uniforms::u_pattern_tl_a::Value{ posA.tl() },
|
||||
uniforms::u_pattern_br_a::Value{ posA.br() },
|
||||
uniforms::u_pattern_tl_b::Value{ posB.tl() },
|
||||
uniforms::u_pattern_br_b::Value{ posB.br() },
|
||||
uniforms::u_pattern_size_a::Value{ sizeA },
|
||||
uniforms::u_pattern_size_b::Value{ sizeB },
|
||||
uniforms::u_texsize::Value{ atlasSize },
|
||||
uniforms::u_fade::Value{ properties.get<LinePattern>().t },
|
||||
uniforms::u_image::Value{ 0 }
|
||||
uniforms::u_scale::Value ({ {pixelRatio, tileRatio, crossfade.fromScale, crossfade.toScale} }),
|
||||
uniforms::u_texsize::Value( atlasSize ),
|
||||
uniforms::u_fade::Value( crossfade.t ),
|
||||
uniforms::u_image::Value( 0 )
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user