[core] Fix background-pattern origin

Regressed in 6e41664cb0. This restores it
to the same behavior as gl-js, backed by test-suite tests.
This commit is contained in:
John Firebaugh
2015-12-17 18:03:25 -08:00
parent b8aee77299
commit e2ad0e008a
2 changed files with 7 additions and 6 deletions

View File

@@ -34,6 +34,7 @@
#include <mbgl/util/constants.hpp>
#include <mbgl/util/mat3.hpp>
#include <mbgl/util/tile_coordinate.hpp>
#if defined(DEBUG)
#include <mbgl/util/stopwatch.hpp>
@@ -279,7 +280,7 @@ void Painter::renderBackground(const BackgroundLayer& layer) {
patternShader->u_opacity = properties.opacity;
LatLng latLng = state.getLatLng();
PrecisionPoint center = state.latLngToPoint(latLng);
TileCoordinate center = state.latLngToCoordinate(latLng);
float scale = 1 / std::pow(2, zoomFraction);
std::array<float, 2> sizeA = (*imagePosA).size;
@@ -289,8 +290,8 @@ void Painter::renderBackground(const BackgroundLayer& layer) {
1.0f / (sizeA[0] * properties.pattern.value.fromScale),
1.0f / (sizeA[1] * properties.pattern.value.fromScale));
matrix::translate(matrixA, matrixA,
std::fmod(center.x * 512, sizeA[0] * properties.pattern.value.fromScale),
std::fmod(center.y * 512, sizeA[1] * properties.pattern.value.fromScale));
std::fmod(center.column * util::tileSize, sizeA[0] * properties.pattern.value.fromScale),
std::fmod(center.row * util::tileSize, sizeA[1] * properties.pattern.value.fromScale));
matrix::rotate(matrixA, matrixA, -state.getAngle());
matrix::scale(matrixA, matrixA,
scale * state.getWidth() / 2,
@@ -303,8 +304,8 @@ void Painter::renderBackground(const BackgroundLayer& layer) {
1.0f / (sizeB[0] * properties.pattern.value.toScale),
1.0f / (sizeB[1] * properties.pattern.value.toScale));
matrix::translate(matrixB, matrixB,
std::fmod(center.x * 512, sizeB[0] * properties.pattern.value.toScale),
std::fmod(center.y * 512, sizeB[1] * properties.pattern.value.toScale));
std::fmod(center.column * util::tileSize, sizeB[0] * properties.pattern.value.toScale),
std::fmod(center.row * util::tileSize, sizeB[1] * properties.pattern.value.toScale));
matrix::rotate(matrixB, matrixB, -state.getAngle());
matrix::scale(matrixB, matrixB,
scale * state.getWidth() / 2,