From 00d6cc6bddef8e8ddb60b6f3ee125dc9008212e2 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Tue, 27 May 2014 19:33:26 +0300 Subject: [PATCH] simplify glyph boxes handling --- src/text/placement.cpp | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/text/placement.cpp b/src/text/placement.cpp index dbf7286e5..e1d7b55bc 100644 --- a/src/text/placement.cpp +++ b/src/text/placement.cpp @@ -72,14 +72,6 @@ struct GlyphInstance { const float angle = 0.0f; }; -struct GlyphsAndBoxes { - explicit GlyphsAndBoxes(const PlacedGlyphs &glyphs, const GlyphBoxes &boxes) - : glyphs(glyphs), boxes(boxes) {} - - const PlacedGlyphs glyphs; - const GlyphBoxes boxes; -}; - typedef std::vector GlyphInstances; void getSegmentGlyphs(std::back_insert_iterator glyphs, @@ -153,7 +145,8 @@ void getSegmentGlyphs(std::back_insert_iterator glyphs, } } -GlyphsAndBoxes getGlyphs(Anchor &anchor, float advance, const Shaping &shaping, +void getGlyphs(PlacedGlyphs &glyphs, GlyphBoxes &boxes, + Anchor &anchor, float advance, const Shaping &shaping, const IndexedFaces &faces, float fontScale, bool horizontal, const std::vector &line, float maxAngleDelta, float rotate) { @@ -170,9 +163,6 @@ GlyphsAndBoxes getGlyphs(Anchor &anchor, float advance, const Shaping &shaping, // origin.x -= advance; // } - PlacedGlyphs glyphs; - GlyphBoxes boxes; - const uint32_t buffer = 3; for (const GlyphPlacement &placed : shaping) { @@ -264,8 +254,6 @@ GlyphsAndBoxes getGlyphs(Anchor &anchor, float advance, const Shaping &shaping, } } } - - return GlyphsAndBoxes{glyphs, boxes}; } void Placement::addFeature(TextBucket& bucket, @@ -303,15 +291,16 @@ void Placement::addFeature(TextBucket& bucket, } for (Anchor anchor : anchors) { - GlyphsAndBoxes glyphsAndBoxes = - getGlyphs(anchor, advance, shaping, faces, fontScale, horizontal, + PlacedGlyphs glyphs; + GlyphBoxes boxes; + + getGlyphs(glyphs, boxes, anchor, advance, shaping, faces, fontScale, horizontal, line, maxAngleDelta, rotate); PlacementProperty place = - collision.place(glyphsAndBoxes.boxes, anchor, anchor.scale, maxPlacementScale, + collision.place(boxes, anchor, anchor.scale, maxPlacementScale, padding, horizontal, info.alwaysVisible); if (place) { - bucket.addGlyphs(glyphsAndBoxes.glyphs, place.zoom, place.rotationRange, - zoom - zOffset); + bucket.addGlyphs(glyphs, place.zoom, place.rotationRange, zoom - zOffset); } } }