[core] Simplify and fix sprite atlas coordinate calculations
* Always return image metrics exclusive of padding * Work with integer coordinates whenever possible * Eliminate redundant SpriteAtlasElement members * Fix asymmetric re-padding in getIconQuad when pixelRatio != 1 * Add explanatory comments
This commit is contained in:
@@ -92,13 +92,13 @@ LinePatternProgram::uniformValues(const LinePaintProperties::PossiblyEvaluated&
|
||||
const SpriteAtlasElement& posA,
|
||||
const SpriteAtlasElement& posB) {
|
||||
std::array<float, 2> sizeA {{
|
||||
tile.id.pixelsToTileUnits(posA.size[0] * properties.get<LinePattern>().fromScale, state.getIntegerZoom()),
|
||||
posA.size[1]
|
||||
tile.id.pixelsToTileUnits(posA.displaySize()[0] * properties.get<LinePattern>().fromScale, state.getIntegerZoom()),
|
||||
posA.displaySize()[1]
|
||||
}};
|
||||
|
||||
std::array<float, 2> sizeB {{
|
||||
tile.id.pixelsToTileUnits(posB.size[0] * properties.get<LinePattern>().toScale, state.getIntegerZoom()),
|
||||
posB.size[1]
|
||||
tile.id.pixelsToTileUnits(posB.displaySize()[0] * properties.get<LinePattern>().toScale, state.getIntegerZoom()),
|
||||
posB.displaySize()[1]
|
||||
}};
|
||||
|
||||
return makeValues<LinePatternProgram::UniformValues>(
|
||||
@@ -106,10 +106,10 @@ LinePatternProgram::uniformValues(const LinePaintProperties::PossiblyEvaluated&
|
||||
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_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 },
|
||||
|
||||
Reference in New Issue
Block a user