diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index dbaa177fc..03de3d8a2 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -236,7 +236,7 @@ void SymbolBucket::addFeatures(const GeometryTileLayer& layer, } // if either shaping or icon position is present, add the feature - if (shaping.size() || image) { + if (shaping.size() || image.hasArea()) { for (const auto& line : feature.geometry) { if (line.size()) { addFeature(line, shaping, face, image); @@ -265,7 +265,7 @@ void SymbolBucket::addFeature(const std::vector &line, const Shaping const float textBoxScale = collision.tilePixelRatio * fontScale; const float iconBoxScale = collision.tilePixelRatio * layout.icon.max_size; const bool iconWithoutText = layout.text.optional || !shaping.size(); - const bool textWithoutIcon = layout.icon.optional || !image; + const bool textWithoutIcon = layout.icon.optional || !image.hasArea(); const bool avoidEdges = layout.avoid_edges && layout.placement != PlacementType::Line; Anchors anchors; @@ -322,7 +322,7 @@ void SymbolBucket::addFeature(const std::vector &line, const Shaping continue; } - if (image) { + if (image.hasArea()) { iconPlacement = Placement::getIcon(anchor, image, iconBoxScale, line, layout); iconScale = layout.icon.allow_overlap diff --git a/src/mbgl/text/glyph.hpp b/src/mbgl/text/glyph.hpp index 4fbb75fc1..b0af261cc 100644 --- a/src/mbgl/text/glyph.hpp +++ b/src/mbgl/text/glyph.hpp @@ -35,7 +35,7 @@ struct Glyph { : rect(rect_), metrics(metrics_) {} operator bool() const { - return metrics || rect; + return metrics || rect.hasArea(); } const Rect rect; diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp index addab5873..bee3a073e 100644 --- a/src/mbgl/text/placement.cpp +++ b/src/mbgl/text/placement.cpp @@ -224,7 +224,7 @@ Placement Placement::getGlyphs(Anchor &anchor, const vec2 &origin, const if (!glyph) continue; - if (!rect) + if (!rect.hasArea()) continue; const float x = (origin.x + shape.x + glyph.metrics.left - buffer + rect.w / 2) * boxScale; diff --git a/src/mbgl/util/rect.hpp b/src/mbgl/util/rect.hpp index 5cc398d82..b5f07eb23 100644 --- a/src/mbgl/util/rect.hpp +++ b/src/mbgl/util/rect.hpp @@ -16,7 +16,7 @@ struct Rect { return Rect(x * value, y * value, w * value, h * value); } - operator bool() const { return w != 0 && h != 0; } + inline bool hasArea() const { return w != 0 && h != 0; } }; }