[core] Move translatedMatrix to RenderTile
This commit is contained in:
@@ -274,32 +274,6 @@ void Painter::renderPass(PaintParameters& parameters,
|
||||
}
|
||||
}
|
||||
|
||||
mat4 Painter::translatedMatrix(const mat4& matrix,
|
||||
const std::array<float, 2>& translation,
|
||||
const UnwrappedTileID& id,
|
||||
TranslateAnchorType anchor) {
|
||||
if (translation[0] == 0 && translation[1] == 0) {
|
||||
return matrix;
|
||||
} else {
|
||||
mat4 vtxMatrix;
|
||||
if (anchor == TranslateAnchorType::Viewport) {
|
||||
const double sin_a = std::sin(-state.getAngle());
|
||||
const double cos_a = std::cos(-state.getAngle());
|
||||
matrix::translate(vtxMatrix, matrix,
|
||||
id.pixelsToTileUnits(translation[0] * cos_a - translation[1] * sin_a, state.getZoom()),
|
||||
id.pixelsToTileUnits(translation[0] * sin_a + translation[1] * cos_a, state.getZoom()),
|
||||
0);
|
||||
} else {
|
||||
matrix::translate(vtxMatrix, matrix,
|
||||
id.pixelsToTileUnits(translation[0], state.getZoom()),
|
||||
id.pixelsToTileUnits(translation[1], state.getZoom()),
|
||||
0);
|
||||
}
|
||||
|
||||
return vtxMatrix;
|
||||
}
|
||||
}
|
||||
|
||||
void Painter::setDepthSublayer(int n) {
|
||||
float nearDepth = ((1 + currentLayer) * numSublayers + n) * depthEpsilon;
|
||||
float farDepth = nearDepth + depthRangeSize;
|
||||
|
||||
@@ -105,11 +105,6 @@ public:
|
||||
bool needsAnimation() const;
|
||||
|
||||
private:
|
||||
mat4 translatedMatrix(const mat4& matrix,
|
||||
const std::array<float, 2>& translation,
|
||||
const UnwrappedTileID& id,
|
||||
style::TranslateAnchorType anchor);
|
||||
|
||||
std::vector<RenderItem> determineRenderOrder(const style::Style&);
|
||||
|
||||
template <class Iterator>
|
||||
|
||||
@@ -26,14 +26,13 @@ void Painter::renderCircle(PaintParameters& parameters,
|
||||
setDepthSublayer(0);
|
||||
|
||||
const CirclePaintProperties& properties = layer.impl->paint;
|
||||
mat4 vtxMatrix = translatedMatrix(tile.matrix, properties.circleTranslate, tile.id,
|
||||
properties.circleTranslateAnchor);
|
||||
|
||||
auto& circleShader = parameters.shaders.circle;
|
||||
|
||||
config.program = circleShader.getID();
|
||||
|
||||
circleShader.u_matrix = vtxMatrix;
|
||||
circleShader.u_matrix = tile.translatedMatrix(properties.circleTranslate,
|
||||
properties.circleTranslateAnchor,
|
||||
state);
|
||||
|
||||
if (properties.circlePitchScale == CirclePitchScaleType::Map) {
|
||||
circleShader.u_extrude_scale = {{
|
||||
|
||||
@@ -17,8 +17,9 @@ void Painter::renderFill(PaintParameters& parameters,
|
||||
const FillLayer& layer,
|
||||
const RenderTile& tile) {
|
||||
const FillPaintProperties& properties = layer.impl->paint;
|
||||
mat4 vertexMatrix =
|
||||
translatedMatrix(tile.matrix, properties.fillTranslate, tile.id, properties.fillTranslateAnchor);
|
||||
mat4 vertexMatrix = tile.translatedMatrix(properties.fillTranslate,
|
||||
properties.fillTranslateAnchor,
|
||||
state);
|
||||
|
||||
Color fillColor = properties.fillColor;
|
||||
float opacity = properties.fillOpacity;
|
||||
|
||||
@@ -50,8 +50,9 @@ void Painter::renderLine(PaintParameters& parameters,
|
||||
float x = state.getHeight() / 2.0f * std::tan(state.getPitch());
|
||||
float extra = (topedgelength + x) / topedgelength - 1.0f;
|
||||
|
||||
mat4 vtxMatrix =
|
||||
translatedMatrix(tile.matrix, properties.lineTranslate, tile.id, properties.lineTranslateAnchor);
|
||||
mat4 vtxMatrix = tile.translatedMatrix(properties.lineTranslate,
|
||||
properties.lineTranslateAnchor,
|
||||
state);
|
||||
|
||||
setDepthSublayer(0);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
void Painter::renderSDF(SymbolBucket &bucket,
|
||||
void Painter::renderSDF(SymbolBucket& bucket,
|
||||
const RenderTile& tile,
|
||||
float sdfFontSize,
|
||||
std::array<float, 2> texsize,
|
||||
@@ -37,7 +37,7 @@ void Painter::renderSDF(SymbolBucket &bucket,
|
||||
TranslateAnchorType translateAnchor,
|
||||
float paintSize)
|
||||
{
|
||||
mat4 vtxMatrix = translatedMatrix(tile.matrix, translate, tile.id, translateAnchor);
|
||||
mat4 vtxMatrix = tile.translatedMatrix(translate, translateAnchor, state);
|
||||
|
||||
// If layerStyle.size > bucket.info.fontSize then labels may collide
|
||||
float fontSize = paintSize;
|
||||
@@ -185,8 +185,9 @@ void Painter::renderSymbol(PaintParameters& parameters,
|
||||
paint.iconTranslateAnchor,
|
||||
layer.impl->iconSize);
|
||||
} else {
|
||||
mat4 vtxMatrix =
|
||||
translatedMatrix(tile.matrix, paint.iconTranslate, tile.id, paint.iconTranslateAnchor);
|
||||
mat4 vtxMatrix = tile.translatedMatrix(paint.iconTranslate,
|
||||
paint.iconTranslateAnchor,
|
||||
state);
|
||||
|
||||
std::array<float, 2> extrudeScale;
|
||||
|
||||
|
||||
@@ -1,5 +1,34 @@
|
||||
#include <mbgl/renderer/render_tile.hpp>
|
||||
#include <mbgl/map/transform_state.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
mat4 RenderTile::translatedMatrix(const std::array<float, 2>& translation,
|
||||
TranslateAnchorType anchor,
|
||||
const TransformState& state) const {
|
||||
if (translation[0] == 0 && translation[1] == 0) {
|
||||
return matrix;
|
||||
}
|
||||
|
||||
mat4 vtxMatrix;
|
||||
|
||||
if (anchor == TranslateAnchorType::Viewport) {
|
||||
const double sin_a = std::sin(-state.getAngle());
|
||||
const double cos_a = std::cos(-state.getAngle());
|
||||
matrix::translate(vtxMatrix, matrix,
|
||||
id.pixelsToTileUnits(translation[0] * cos_a - translation[1] * sin_a, state.getZoom()),
|
||||
id.pixelsToTileUnits(translation[0] * sin_a + translation[1] * cos_a, state.getZoom()),
|
||||
0);
|
||||
} else {
|
||||
matrix::translate(vtxMatrix, matrix,
|
||||
id.pixelsToTileUnits(translation[0], state.getZoom()),
|
||||
id.pixelsToTileUnits(translation[1], state.getZoom()),
|
||||
0);
|
||||
}
|
||||
|
||||
return vtxMatrix;
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -4,10 +4,14 @@
|
||||
#include <mbgl/util/mat4.hpp>
|
||||
#include <mbgl/util/ptr.hpp>
|
||||
#include <mbgl/util/clip_id.hpp>
|
||||
#include <mbgl/style/types.hpp>
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class Tile;
|
||||
class TransformState;
|
||||
|
||||
class RenderTile {
|
||||
public:
|
||||
@@ -21,6 +25,10 @@ public:
|
||||
Tile& tile;
|
||||
ClipID clip;
|
||||
mat4 matrix;
|
||||
|
||||
mat4 translatedMatrix(const std::array<float, 2>& translate,
|
||||
style::TranslateAnchorType anchor,
|
||||
const TransformState&) const;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
Reference in New Issue
Block a user