summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/renderer')
-rw-r--r--src/mbgl/renderer/circle_bucket.cpp4
-rw-r--r--src/mbgl/renderer/painter.cpp3
-rw-r--r--src/mbgl/renderer/painter.hpp21
-rw-r--r--src/mbgl/renderer/painter_fill.cpp2
-rw-r--r--src/mbgl/renderer/painter_line.cpp6
-rw-r--r--src/mbgl/renderer/painter_symbol.cpp4
-rw-r--r--src/mbgl/renderer/symbol_bucket.cpp10
-rw-r--r--src/mbgl/renderer/symbol_bucket.hpp1
8 files changed, 26 insertions, 25 deletions
diff --git a/src/mbgl/renderer/circle_bucket.cpp b/src/mbgl/renderer/circle_bucket.cpp
index 13a3cebafe..1ebe8ffaf3 100644
--- a/src/mbgl/renderer/circle_bucket.cpp
+++ b/src/mbgl/renderer/circle_bucket.cpp
@@ -3,6 +3,7 @@
#include <mbgl/shader/circle_shader.hpp>
#include <mbgl/layer/circle_layer.hpp>
+#include <mbgl/util/constants.hpp>
using namespace mbgl;
@@ -31,14 +32,13 @@ bool CircleBucket::hasData() const {
}
void CircleBucket::addGeometry(const GeometryCollection& geometryCollection) {
- const int extent = 4096;
for (auto& circle : geometryCollection) {
for(auto & geometry : circle) {
auto x = geometry.x;
auto y = geometry.y;
// Do not include points that are outside the tile boundaries.
- if (x < 0 || x >= extent || y < 0 || y >= extent) continue;
+ if (x < 0 || x >= util::EXTENT || y < 0 || y >= util::EXTENT) continue;
// this geometry will be of the Point type, and we'll derive
// two triangles from it.
diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp
index 19b597a77b..0fd76314dc 100644
--- a/src/mbgl/renderer/painter.cpp
+++ b/src/mbgl/renderer/painter.cpp
@@ -344,8 +344,7 @@ mat4 Painter::translatedMatrix(const mat4& matrix, const std::array<float, 2> &t
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)) / state.getScale() * (4096.0 / util::tileSize / id.overscaling);
+ const double factor = ((double)(1 << id.z)) / state.getScale() * (util::EXTENT / util::tileSize / id.overscaling);
mat4 vtxMatrix;
if (anchor == TranslateAnchorType::Viewport) {
diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp
index 7189bcc19b..092c164033 100644
--- a/src/mbgl/renderer/painter.hpp
+++ b/src/mbgl/renderer/painter.hpp
@@ -18,6 +18,7 @@
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/chrono.hpp>
+#include <mbgl/util/constants.hpp>
#include <array>
#include <vector>
@@ -129,8 +130,8 @@ private:
// used to composite images and flips the geometry upside down
const mat4 flipMatrix = []{
mat4 flip;
- matrix::ortho(flip, 0, 4096, -4096, 0, 0, 1);
- matrix::translate(flip, flip, 0, -4096, 0);
+ matrix::ortho(flip, 0, util::EXTENT, -util::EXTENT, 0, 0, 1);
+ matrix::translate(flip, flip, 0, -util::EXTENT, 0);
return flip;
}();
@@ -186,13 +187,13 @@ private:
StaticVertexBuffer tileStencilBuffer = {
// top left triangle
{ 0, 0 },
- { 4096, 0 },
- { 0, 4096 },
+ { util::EXTENT, 0 },
+ { 0, util::EXTENT },
// bottom right triangle
- { 4096, 0 },
- { 0, 4096 },
- { 4096, 4096 },
+ { util::EXTENT, 0 },
+ { 0, util::EXTENT },
+ { util::EXTENT, util::EXTENT },
};
VertexArrayObject coveringPlainArray;
@@ -201,9 +202,9 @@ private:
// Set up the tile boundary lines we're using to draw the tile outlines.
StaticVertexBuffer tileBorderBuffer = {
{ 0, 0 },
- { 4096, 0 },
- { 4096, 4096 },
- { 0, 4096 },
+ { util::EXTENT, 0 },
+ { util::EXTENT, util::EXTENT },
+ { 0, util::EXTENT },
{ 0, 0 },
};
diff --git a/src/mbgl/renderer/painter_fill.cpp b/src/mbgl/renderer/painter_fill.cpp
index 0217cb1a5d..44ae1919a0 100644
--- a/src/mbgl/renderer/painter_fill.cpp
+++ b/src/mbgl/renderer/painter_fill.cpp
@@ -65,7 +65,7 @@ void Painter::renderFill(FillBucket& bucket, const FillLayer& layer, const TileI
// Image fill.
if (pass == RenderPass::Translucent && posA && posB) {
- float factor = (8.0 / std::pow(2, state.getIntegerZoom() - id.z)) / id.overscaling;
+ float factor = (util::EXTENT / util::tileSize / std::pow(2, state.getIntegerZoom() - id.z)) / id.overscaling;
mat3 patternMatrixA;
matrix::identity(patternMatrixA);
diff --git a/src/mbgl/renderer/painter_line.cpp b/src/mbgl/renderer/painter_line.cpp
index b849073cc1..b507c8c865 100644
--- a/src/mbgl/renderer/painter_line.cpp
+++ b/src/mbgl/renderer/painter_line.cpp
@@ -51,7 +51,7 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI
color[2] *= properties.opacity;
color[3] *= properties.opacity;
- float ratio = state.getScale() / std::pow(2, id.z) / (4096.0 / (512.0 * id.overscaling));
+ float ratio = state.getScale() / std::pow(2, id.z) / (util::EXTENT / (512.0 * id.overscaling));
mat2 antialiasingMatrix;
matrix::identity(antialiasingMatrix);
@@ -83,7 +83,7 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI
LinePatternPos posB = lineAtlas->getDashPosition(properties.dasharray.value.to, layout.cap == CapType::Round);
lineAtlas->bind();
- float patternratio = std::pow(2.0, std::floor(::log2(state.getScale())) - id.z) / 8.0 * id.overscaling;
+ float patternratio = std::pow(2.0, std::floor(::log2(state.getScale())) - id.z) / (util::EXTENT / util::tileSize) * id.overscaling;
float scaleXA = patternratio / posA.width / properties.dashLineWidth / properties.dasharray.value.fromScale;
float scaleYA = -posA.height / 2.0;
float scaleXB = patternratio / posB.width / properties.dashLineWidth / properties.dasharray.value.toScale;
@@ -109,7 +109,7 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI
if (!imagePosA || !imagePosB)
return;
- float factor = 4096.0 / (512 * id.overscaling) / std::pow(2, state.getIntegerZoom() - id.z);
+ float factor = util::EXTENT / (512 * id.overscaling) / std::pow(2, state.getIntegerZoom() - id.z);
config.program = linepatternShader->program;
diff --git a/src/mbgl/renderer/painter_symbol.cpp b/src/mbgl/renderer/painter_symbol.cpp
index e45cc822dc..0538485824 100644
--- a/src/mbgl/renderer/painter_symbol.cpp
+++ b/src/mbgl/renderer/painter_symbol.cpp
@@ -34,7 +34,7 @@ void Painter::renderSDF(SymbolBucket &bucket,
if (skewed) {
matrix::identity(exMatrix);
- s = 4096.0f / util::tileSize / id.overscaling / std::pow(2, state.getZoom() - id.z);
+ s = util::EXTENT / util::tileSize / id.overscaling / std::pow(2, state.getZoom() - id.z);
gammaScale = 1.0f / std::cos(state.getPitch());
} else {
exMatrix = extrudeMatrix;
@@ -211,7 +211,7 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const
if (skewed) {
matrix::identity(exMatrix);
- s = 4096.0f / util::tileSize / id.overscaling / std::pow(2, state.getZoom() - id.z);
+ s = util::EXTENT / util::tileSize / id.overscaling / std::pow(2, state.getZoom() - id.z);
} else {
exMatrix = extrudeMatrix;
matrix::rotate_z(exMatrix, exMatrix, state.getNorthOrientationAngle());
diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp
index 75cf496d15..36d285909b 100644
--- a/src/mbgl/renderer/symbol_bucket.cpp
+++ b/src/mbgl/renderer/symbol_bucket.cpp
@@ -24,6 +24,8 @@
#include <mbgl/util/merge_lines.hpp>
#include <mbgl/util/clip_lines.hpp>
#include <mbgl/util/std.hpp>
+#include <mbgl/util/get_geometries.hpp>
+#include <mbgl/util/constants.hpp>
namespace mbgl {
@@ -54,7 +56,7 @@ SymbolInstance::SymbolInstance(Anchor& anchor, const std::vector<Coordinate>& li
SymbolBucket::SymbolBucket(float overscaling_, float zoom_, const MapMode mode_)
- : overscaling(overscaling_), zoom(zoom_), tileSize(512 * overscaling_), tilePixelRatio(tileExtent / tileSize), mode(mode_) {
+ : overscaling(overscaling_), zoom(zoom_), tileSize(512 * overscaling_), tilePixelRatio(util::EXTENT / tileSize), mode(mode_) {
}
SymbolBucket::~SymbolBucket() {
@@ -141,7 +143,7 @@ void SymbolBucket::parseFeatures(const GeometryTileLayer& layer,
auto &multiline = ft.geometry;
- GeometryCollection geometryCollection = feature->getGeometries();
+ GeometryCollection geometryCollection = getGeometries(*feature);
for (auto& line : geometryCollection) {
multiline.emplace_back();
for (auto& point : line) {
@@ -295,7 +297,7 @@ void SymbolBucket::addFeature(const std::vector<std::vector<Coordinate>> &lines,
const float textRepeatDistance = symbolSpacing / 2;
auto& clippedLines = isLine ?
- util::clipLines(lines, 0, 0, 4096, 4096) :
+ util::clipLines(lines, 0, 0, util::EXTENT, util::EXTENT) :
lines;
for (const auto& line : clippedLines) {
@@ -314,7 +316,7 @@ void SymbolBucket::addFeature(const std::vector<std::vector<Coordinate>> &lines,
}
}
- const bool inside = !(anchor.x < 0 || anchor.x > 4096 || anchor.y < 0 || anchor.y > 4096);
+ const bool inside = !(anchor.x < 0 || anchor.x > util::EXTENT || anchor.y < 0 || anchor.y > util::EXTENT);
if (avoidEdges && !inside) continue;
diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp
index 68a622bb8a..7ea5fa05d7 100644
--- a/src/mbgl/renderer/symbol_bucket.hpp
+++ b/src/mbgl/renderer/symbol_bucket.hpp
@@ -117,7 +117,6 @@ private:
const float overscaling;
const float zoom;
const float tileSize;
- const float tileExtent = 4096.0f;
const float tilePixelRatio;
const MapMode mode;