Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Label legibility improvements: pitch-scaling and pitched line-following #9009

Merged
merged 15 commits into from
Jul 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmake/core-files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ set(MBGL_CORE_FILES
src/mbgl/layout/symbol_instance.hpp
src/mbgl/layout/symbol_layout.cpp
src/mbgl/layout/symbol_layout.hpp
src/mbgl/layout/symbol_projection.cpp
src/mbgl/layout/symbol_projection.hpp

# map
include/mbgl/map/backend.hpp
Expand Down
2 changes: 1 addition & 1 deletion mapbox-gl-js
Submodule mapbox-gl-js updated 44 files
+4 −0 CHANGELOG.md
+1 −1 docs/_posts/examples/3400-01-24-custom-marker-icons.html
+0 −1 src/data/array_group.js
+7 −7 src/data/bucket/circle_bucket.js
+3 −3 src/data/bucket/fill_bucket.js
+3 −3 src/data/bucket/fill_extrusion_bucket.js
+7 −7 src/data/bucket/line_bucket.js
+19 −10 src/data/bucket/symbol_bucket.js
+217 −275 src/data/program_configuration.js
+7 −7 src/render/painter.js
+2 −21 src/shaders/_prelude.vertex.glsl
+72 −0 src/shaders/index.js
+2 −1 src/style/style.js
+1 −7 src/symbol/glyph_source.js
+1 −3 src/ui/control/geolocate_control.js
+8 −11 src/ui/control/logo_control.js
+6 −2 src/ui/marker.js
+1 −1 src/util/is_char_in_unicode_block.js
+1 −4 test/integration/query-tests/edge-cases/box-cutting-antimeridian-z0/style.json
+1 −1 test/integration/query-tests/symbol-features-in/pitched-screen/style.json
+6 −2 test/integration/query-tests/symbol-features-in/tilted-outside/style.json
+3 −0 test/integration/render-tests/circle-pitch-alignment/map-scale-map/style.json
+3 −0 test/integration/render-tests/circle-pitch-alignment/map-scale-viewport/style.json
+3 −0 test/integration/render-tests/circle-pitch-alignment/viewport-scale-map/style.json
+3 −0 test/integration/render-tests/circle-pitch-alignment/viewport-scale-viewport/style.json
+2 −2 test/integration/render-tests/debug/collision-pitched-wrapped/style.json
+2 −2 test/integration/render-tests/debug/collision-pitched/style.json
+0 −3 test/integration/render-tests/icon-pitch-scaling/rotation-alignment-map/style.json
+0 −3 test/integration/render-tests/icon-pitch-scaling/rotation-alignment-viewport/style.json
+1 −1 test/integration/render-tests/regressions/mapbox-gl-js#4860/style.json
+0 −3 test/integration/render-tests/text-pitch-alignment/auto-text-rotation-alignment-map/style.json
+0 −3 test/integration/render-tests/text-pitch-alignment/auto-text-rotation-alignment-viewport/style.json
+0 −3 test/integration/render-tests/text-pitch-alignment/map-text-depthtest/style.json
+0 −3 test/integration/render-tests/text-pitch-alignment/map-text-rotation-alignment-map/style.json
+0 −3 test/integration/render-tests/text-pitch-alignment/map-text-rotation-alignment-viewport/style.json
+0 −3 test/integration/render-tests/text-pitch-alignment/viewport-text-depthtest/style.json
+0 −3 test/integration/render-tests/text-pitch-alignment/viewport-text-rotation-alignment-map/style.json
+0 −3 test/integration/render-tests/text-pitch-alignment/viewport-text-rotation-alignment-viewport/style.json
+1 −4 test/integration/render-tests/text-pitch-scaling/line-half/style.json
+3 −8 test/unit/data/bucket.test.js
+0 −11 test/unit/data/fill_bucket.test.js
+3 −6 test/unit/data/symbol_bucket.test.js
+2 −2 test/unit/ui/control/logo.test.js
+15 −0 test/unit/ui/marker.test.js
9 changes: 4 additions & 5 deletions src/mbgl/algorithm/update_renderables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void updateRenderables(GetTileFn getTile,
assert(idealRenderTileID.canonical.z <= zoomRange.max);
assert(dataTileZoom >= idealRenderTileID.canonical.z);

const OverscaledTileID idealDataTileID(dataTileZoom, idealRenderTileID.canonical);
const OverscaledTileID idealDataTileID(dataTileZoom, idealRenderTileID.wrap, idealRenderTileID.canonical);
auto tile = getTile(idealDataTileID);
if (!tile) {
tile = createTile(idealDataTileID);
Expand Down Expand Up @@ -64,11 +64,11 @@ void updateRenderables(GetTileFn getTile,
} else {
// Check all four actual child tiles.
for (const auto& childTileID : idealDataTileID.canonical.children()) {
const OverscaledTileID childDataTileID(overscaledZ, childTileID);
const OverscaledTileID childDataTileID(overscaledZ, idealRenderTileID.wrap, childTileID);
tile = getTile(childDataTileID);
if (tile && tile->isRenderable()) {
retainTile(*tile, Resource::Necessity::Optional);
renderTile(childDataTileID.unwrapTo(idealRenderTileID.wrap), *tile);
renderTile(childDataTileID.toUnwrapped(), *tile);
} else {
// At least one child tile doesn't exist, so we are going to look for
// parents as well.
Expand All @@ -81,8 +81,7 @@ void updateRenderables(GetTileFn getTile,
// We couldn't find child tiles that entirely cover the ideal tile.
for (overscaledZ = dataTileZoom - 1; overscaledZ >= zoomRange.min; --overscaledZ) {
const auto parentDataTileID = idealDataTileID.scaledTo(overscaledZ);
const auto parentRenderTileID =
parentDataTileID.unwrapTo(idealRenderTileID.wrap);
const auto parentRenderTileID = parentDataTileID.toUnwrapped();

if (checked.find(parentRenderTileID) != checked.end()) {
// Break parent tile ascent, this route has been checked by another child
Expand Down
56 changes: 54 additions & 2 deletions src/mbgl/gl/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@ namespace gl {
static_assert(underlying_type(ShaderType::Vertex) == GL_VERTEX_SHADER, "OpenGL type mismatch");
static_assert(underlying_type(ShaderType::Fragment) == GL_FRAGMENT_SHADER, "OpenGL type mismatch");

static_assert(underlying_type(DataType::Byte) == GL_BYTE, "OpenGL type mismatch");
static_assert(underlying_type(DataType::UnsignedByte) == GL_UNSIGNED_BYTE, "OpenGL type mismatch");
static_assert(underlying_type(DataType::Short) == GL_SHORT, "OpenGL type mismatch");
static_assert(underlying_type(DataType::UnsignedShort) == GL_UNSIGNED_SHORT, "OpenGL type mismatch");
static_assert(underlying_type(DataType::Integer) == GL_INT, "OpenGL type mismatch");
static_assert(underlying_type(DataType::UnsignedInteger) == GL_UNSIGNED_INT, "OpenGL type mismatch");
static_assert(underlying_type(DataType::Float) == GL_FLOAT, "OpenGL type mismatch");

#if not MBGL_USE_GLES2
static_assert(underlying_type(RenderbufferType::RGBA) == GL_RGBA8, "OpenGL type mismatch");
#else
static_assert(underlying_type(RenderbufferType::RGBA) == GL_RGBA8_OES, "OpenGL type mismatch");
#endif // MBGL_USE_GLES2
#if not MBGL_USE_GLES2
static_assert(underlying_type(RenderbufferType::DepthStencil) == GL_DEPTH24_STENCIL8, "OpenGL type mismatch");
#else
static_assert(underlying_type(RenderbufferType::DepthStencil) == GL_DEPTH24_STENCIL8_OES, "OpenGL type mismatch");
#endif // MBGL_USE_GLES2
#if not MBGL_USE_GLES2
static_assert(underlying_type(RenderbufferType::DepthComponent) == GL_DEPTH_COMPONENT, "OpenGL type mismatch");
#else
static_assert(underlying_type(RenderbufferType::DepthComponent) == GL_DEPTH_COMPONENT16, "OpenGL type mismatch");
#endif // MBGL_USE_GLES2


static_assert(underlying_type(PrimitiveType::Points) == GL_POINTS, "OpenGL type mismatch");
static_assert(underlying_type(PrimitiveType::Lines) == GL_LINES, "OpenGL type mismatch");
static_assert(underlying_type(PrimitiveType::LineLoop) == GL_LINE_LOOP, "OpenGL type mismatch");
Expand All @@ -36,6 +61,28 @@ static_assert(std::is_same<std::underlying_type_t<TextureFormat>, GLenum>::value
static_assert(underlying_type(TextureFormat::RGBA) == GL_RGBA, "OpenGL type mismatch");
static_assert(underlying_type(TextureFormat::Alpha) == GL_ALPHA, "OpenGL type mismatch");

static_assert(underlying_type(UniformDataType::Float) == GL_FLOAT, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::FloatVec2) == GL_FLOAT_VEC2, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::FloatVec3) == GL_FLOAT_VEC3, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::FloatVec4) == GL_FLOAT_VEC4, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::Int) == GL_INT, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::IntVec2) == GL_INT_VEC2, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::IntVec3) == GL_INT_VEC3, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::IntVec4) == GL_INT_VEC4, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::Bool) == GL_BOOL, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::BoolVec2) == GL_BOOL_VEC2, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::BoolVec3) == GL_BOOL_VEC3, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::BoolVec4) == GL_BOOL_VEC4, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::FloatMat2) == GL_FLOAT_MAT2, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::FloatMat3) == GL_FLOAT_MAT3, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::FloatMat4) == GL_FLOAT_MAT4, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::Sampler2D) == GL_SAMPLER_2D, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::SamplerCube) == GL_SAMPLER_CUBE, "OpenGL type mismatch");

static_assert(underlying_type(BufferUsage::StreamDraw) == GL_STREAM_DRAW, "OpenGL type mismatch");
static_assert(underlying_type(BufferUsage::StaticDraw) == GL_STATIC_DRAW, "OpenGL type mismatch");
static_assert(underlying_type(BufferUsage::DynamicDraw) == GL_DYNAMIC_DRAW, "OpenGL type mismatch");

static_assert(std::is_same<BinaryProgramFormat, GLenum>::value, "OpenGL type mismatch");

Context::Context() = default;
Expand Down Expand Up @@ -164,15 +211,20 @@ void Context::verifyProgramLinkage(ProgramID program_) {
throw std::runtime_error("program failed to link");
}

UniqueBuffer Context::createVertexBuffer(const void* data, std::size_t size) {
UniqueBuffer Context::createVertexBuffer(const void* data, std::size_t size, const BufferUsage usage) {
BufferID id = 0;
MBGL_CHECK_ERROR(glGenBuffers(1, &id));
UniqueBuffer result { std::move(id), { this } };
vertexBuffer = result;
MBGL_CHECK_ERROR(glBufferData(GL_ARRAY_BUFFER, size, data, GL_STATIC_DRAW));
MBGL_CHECK_ERROR(glBufferData(GL_ARRAY_BUFFER, size, data, static_cast<GLenum>(usage)));
return result;
}

void Context::updateVertexBuffer(UniqueBuffer& buffer, const void* data, std::size_t size) {
vertexBuffer = buffer;
MBGL_CHECK_ERROR(glBufferSubData(GL_ARRAY_BUFFER, 0, size, data));
}

UniqueBuffer Context::createIndexBuffer(const void* data, std::size_t size) {
BufferID id = 0;
MBGL_CHECK_ERROR(glGenBuffers(1, &id));
Expand Down
13 changes: 10 additions & 3 deletions src/mbgl/gl/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,19 @@ class Context : private util::noncopyable {
optional<std::pair<BinaryProgramFormat, std::string>> getBinaryProgram(ProgramID) const;

template <class Vertex, class DrawMode>
VertexBuffer<Vertex, DrawMode> createVertexBuffer(VertexVector<Vertex, DrawMode>&& v) {
VertexBuffer<Vertex, DrawMode> createVertexBuffer(VertexVector<Vertex, DrawMode>&& v, const BufferUsage usage=BufferUsage::StaticDraw) {
return VertexBuffer<Vertex, DrawMode> {
v.vertexSize(),
createVertexBuffer(v.data(), v.byteSize())
createVertexBuffer(v.data(), v.byteSize(), usage)
};
}

template <class Vertex, class DrawMode>
void updateVertexBuffer(VertexBuffer<Vertex, DrawMode>& buffer, VertexVector<Vertex, DrawMode>&& v) {
assert(v.vertexSize() == buffer.vertexCount);
updateVertexBuffer(buffer.buffer, v.data(), v.byteSize());
}

template <class DrawMode>
IndexBuffer<DrawMode> createIndexBuffer(IndexVector<DrawMode>&& v) {
return IndexBuffer<DrawMode> {
Expand Down Expand Up @@ -239,7 +245,8 @@ class Context : private util::noncopyable {
State<value::PointSize> pointSize;
#endif // MBGL_USE_GLES2

UniqueBuffer createVertexBuffer(const void* data, std::size_t size);
UniqueBuffer createVertexBuffer(const void* data, std::size_t size, const BufferUsage usage);
void updateVertexBuffer(UniqueBuffer& buffer, const void* data, std::size_t size);
UniqueBuffer createIndexBuffer(const void* data, std::size_t size);
UniqueTexture createTexture(Size size, const void* data, TextureFormat, TextureUnit);
void updateTexture(TextureID, Size size, const void* data, TextureFormat, TextureUnit);
Expand Down
6 changes: 6 additions & 0 deletions src/mbgl/gl/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,11 @@ enum class UniformDataType : uint32_t {
SamplerCube = 0x8B60,
};

enum class BufferUsage : uint32_t {
StreamDraw = 0x88E0,
StaticDraw = 0x88E4,
DynamicDraw = 0x88E8,
};

} // namespace gl
} // namespace mbgl
23 changes: 14 additions & 9 deletions src/mbgl/layout/symbol_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace mbgl {

using namespace style;

SymbolInstance::SymbolInstance(Anchor& anchor,
const GeometryCoordinates& line,
SymbolInstance::SymbolInstance(Anchor& anchor_,
GeometryCoordinates line_,
const std::pair<Shaping, Shaping>& shapedTextOrientations,
optional<PositionedIcon> shapedIcon,
const SymbolLayoutProperties::Evaluated& layout,
Expand All @@ -16,33 +16,38 @@ SymbolInstance::SymbolInstance(Anchor& anchor,
const float textBoxScale,
const float textPadding,
const SymbolPlacementType textPlacement,
const std::array<float, 2> textOffset_,
const float iconBoxScale,
const float iconPadding,
const SymbolPlacementType iconPlacement,
const std::array<float, 2> iconOffset_,
const GlyphPositionMap& positions,
const IndexedSubfeature& indexedFeature,
const std::size_t featureIndex_) :
point(anchor.point),
anchor(anchor_),
line(line_),
index(index_),
hasText(shapedTextOrientations.first || shapedTextOrientations.second),
hasIcon(shapedIcon),

// Create the collision features that will be used to check whether this symbol instance can be placed
textCollisionFeature(line, anchor, shapedTextOrientations.second ?: shapedTextOrientations.first, textBoxScale, textPadding, textPlacement, indexedFeature),
iconCollisionFeature(line, anchor, shapedIcon, iconBoxScale, iconPadding, iconPlacement, indexedFeature),
featureIndex(featureIndex_) {
textCollisionFeature(line_, anchor, shapedTextOrientations.second ?: shapedTextOrientations.first, textBoxScale, textPadding, textPlacement, indexedFeature),
iconCollisionFeature(line_, anchor, shapedIcon, iconBoxScale, iconPadding, iconPlacement, indexedFeature),
featureIndex(featureIndex_),
textOffset(textOffset_),
iconOffset(iconOffset_) {

// Create the quads used for rendering the icon and glyphs.
if (addToBuffers) {
if (shapedIcon) {
iconQuad = getIconQuad(anchor, *shapedIcon, line, layout, layoutTextSize, iconPlacement, shapedTextOrientations.first);
iconQuad = getIconQuad(*shapedIcon, layout, layoutTextSize, shapedTextOrientations.first);
}
if (shapedTextOrientations.first) {
auto quads = getGlyphQuads(anchor, shapedTextOrientations.first, textBoxScale, line, layout, textPlacement, positions);
auto quads = getGlyphQuads(shapedTextOrientations.first, layout, textPlacement, positions);
glyphQuads.insert(glyphQuads.end(), quads.begin(), quads.end());
}
if (shapedTextOrientations.second) {
auto quads = getGlyphQuads(anchor, shapedTextOrientations.second, textBoxScale, line, layout, textPlacement, positions);
auto quads = getGlyphQuads(shapedTextOrientations.second, layout, textPlacement, positions);
glyphQuads.insert(glyphQuads.end(), quads.begin(), quads.end());
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/mbgl/layout/symbol_instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class IndexedSubfeature;
class SymbolInstance {
public:
SymbolInstance(Anchor& anchor,
const GeometryCoordinates& line,
GeometryCoordinates line,
const std::pair<Shaping, Shaping>& shapedTextOrientations,
optional<PositionedIcon> shapedIcon,
const style::SymbolLayoutProperties::Evaluated&,
Expand All @@ -23,14 +23,17 @@ class SymbolInstance {
const float textBoxScale,
const float textPadding,
style::SymbolPlacementType textPlacement,
const std::array<float, 2> textOffset,
const float iconBoxScale,
const float iconPadding,
style::SymbolPlacementType iconPlacement,
const std::array<float, 2> iconOffset,
const GlyphPositionMap&,
const IndexedSubfeature&,
const std::size_t featureIndex);

Point<float> point;
Anchor anchor;
GeometryCoordinates line;
uint32_t index;
bool hasText;
bool hasIcon;
Expand All @@ -40,6 +43,8 @@ class SymbolInstance {
CollisionFeature iconCollisionFeature;
WritingModeType writingModes;
std::size_t featureIndex;
std::array<float, 2> textOffset;
std::array<float, 2> iconOffset;
};

} // namespace mbgl
Loading