From bfa0b7f009c2460f81f5e4cbfdf251a2589a618a Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 28 Aug 2014 17:13:55 -0700 Subject: [PATCH] Remove vtxMatrix state --- include/mbgl/renderer/painter.hpp | 3 +-- src/renderer/painter.cpp | 3 ++- src/renderer/painter_fill.cpp | 2 +- src/renderer/painter_line.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/mbgl/renderer/painter.hpp b/include/mbgl/renderer/painter.hpp index 957660a52..6801ad1cf 100644 --- a/include/mbgl/renderer/painter.hpp +++ b/include/mbgl/renderer/painter.hpp @@ -120,7 +120,7 @@ public: bool needsAnimation() const; private: void setupShaders(); - const mat4 &translatedMatrix(const mat4& matrix, const std::array &translation, const Tile::ID &id, TranslateAnchorType anchor = TranslateAnchorType::Map); + mat4 translatedMatrix(const mat4& matrix, const std::array &translation, const Tile::ID &id, TranslateAnchorType anchor = TranslateAnchorType::Map); void prepareTile(const Tile& tile); @@ -131,7 +131,6 @@ public: void depthRange(float near, float far); public: - mat4 vtxMatrix; mat4 projMatrix; mat4 nativeMatrix; mat4 extrudeMatrix; diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index 4822ba731..2a3d45c9e 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -204,13 +204,14 @@ void Painter::renderBackground(std::shared_ptr layer_desc) { } } -const mat4 &Painter::translatedMatrix(const mat4& matrix, const std::array &translation, const Tile::ID &id, TranslateAnchorType anchor) { +mat4 Painter::translatedMatrix(const mat4& matrix, const std::array &translation, const Tile::ID &id, TranslateAnchorType anchor) { if (translation[0] == 0 && translation[1] == 0) { return matrix; } else { // TODO: Get rid of the 8 (scaling from 4096 to tile size) const double factor = ((double)(1 << id.z)) / map.getState().getScale() * (4096.0 / util::tileSize); + mat4 vtxMatrix; if (anchor == TranslateAnchorType::Viewport) { const double sin_a = std::sin(-map.getState().getAngle()); const double cos_a = std::cos(-map.getState().getAngle()); diff --git a/src/renderer/painter_fill.cpp b/src/renderer/painter_fill.cpp index fe08d4c2f..141b60d3a 100644 --- a/src/renderer/painter_fill.cpp +++ b/src/renderer/painter_fill.cpp @@ -141,6 +141,6 @@ void Painter::renderFill(FillBucket& bucket, std::shared_ptr layer_d // Abort early. if (!bucket.hasData()) return; const FillProperties &properties = layer_desc->getProperties(); - const mat4 &vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor); + mat4 vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor); renderFill(bucket, properties, id, vtxMatrix); } diff --git a/src/renderer/painter_line.cpp b/src/renderer/painter_line.cpp index 24358c51d..ad0778fc0 100644 --- a/src/renderer/painter_line.cpp +++ b/src/renderer/painter_line.cpp @@ -31,7 +31,7 @@ void Painter::renderLine(LineBucket& bucket, std::shared_ptr layer_d float dash_length = properties.dash_array[0]; float dash_gap = properties.dash_array[1]; - const mat4 &vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor); + mat4 vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor); depthRange(strata, 1.0f);