From 8cafb555dc9c31c5c4a53779bb25d9b3944114ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 2 Dec 2013 15:17:27 +0100 Subject: [PATCH 1/3] MeshTools: code cleanup. No need to repeat size computation, this way it's also safer (we won't read memory after the end). --- src/MeshTools/Interleave.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MeshTools/Interleave.h b/src/MeshTools/Interleave.h index e5dae48cc..dc663456a 100644 --- a/src/MeshTools/Interleave.h +++ b/src/MeshTools/Interleave.h @@ -66,7 +66,7 @@ class Interleave { std::tie(std::ignore, std::ignore, data) = operator()(attributes...); mesh.setVertexCount(_attributeCount); - buffer.setData({data, _attributeCount*_stride}, usage); + buffer.setData(data, usage); } /* Specialization for only one attribute array */ From fd987c9e4e7dbcf00d92422905cd21009342f6fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 2 Dec 2013 15:21:29 +0100 Subject: [PATCH 2/3] Text: clean up GlyphCache::insert(). Const is good is good. --- src/Text/GlyphCache.cpp | 10 ++++------ src/Text/GlyphCache.h | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Text/GlyphCache.cpp b/src/Text/GlyphCache.cpp index ec43b95d0..75e82b236 100644 --- a/src/Text/GlyphCache.cpp +++ b/src/Text/GlyphCache.cpp @@ -85,16 +85,14 @@ std::vector GlyphCache::reserve(const std::vector& sizes) { return TextureTools::atlas(_size, sizes, _padding); } -void GlyphCache::insert(const UnsignedInt glyph, Vector2i position, Range2Di rectangle) { - position -= _padding; - rectangle.bottomLeft() -= _padding; - rectangle.topRight() += _padding; +void GlyphCache::insert(const UnsignedInt glyph, const Vector2i& position, const Range2Di& rectangle) { + const std::pair glyphData = {position-_padding, rectangle.padded(_padding)}; /* Overwriting "Not Found" glyph */ - if(glyph == 0) glyphs[0] = {position, rectangle}; + if(glyph == 0) glyphs[0] = glyphData; /* Inserting new glyph */ - else CORRADE_INTERNAL_ASSERT_OUTPUT(glyphs.insert({glyph, {position, rectangle}}).second); + else CORRADE_INTERNAL_ASSERT_OUTPUT(glyphs.insert({glyph, glyphData}).second); } void GlyphCache::setImage(const Vector2i& offset, const ImageReference2D& image) { diff --git a/src/Text/GlyphCache.h b/src/Text/GlyphCache.h index 8e45ab68a..5fa5ede88 100644 --- a/src/Text/GlyphCache.h +++ b/src/Text/GlyphCache.h @@ -176,7 +176,7 @@ class MAGNUM_TEXT_EXPORT GlyphCache { * See also @ref setImage() to upload glyph image. * @see @ref padding() */ - void insert(UnsignedInt glyph, Vector2i position, Range2Di rectangle); + void insert(UnsignedInt glyph, const Vector2i& position, const Range2Di& rectangle); /** * @brief Set cache image From fff5950253945daef7e465c09cc2cd6c9d6ee0d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 2 Dec 2013 15:22:52 +0100 Subject: [PATCH 3/3] MagnumFontConverter: use Range::padded(). --- src/Plugins/MagnumFontConverter/MagnumFontConverter.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Plugins/MagnumFontConverter/MagnumFontConverter.cpp b/src/Plugins/MagnumFontConverter/MagnumFontConverter.cpp index e21ce5f43..bd6d0e732 100644 --- a/src/Plugins/MagnumFontConverter/MagnumFontConverter.cpp +++ b/src/Plugins/MagnumFontConverter/MagnumFontConverter.cpp @@ -101,8 +101,7 @@ std::vector>> MagnumFont Utility::ConfigurationGroup* group = configuration.addGroup("glyph"); group->setValue("advance", font.glyphAdvance(oldGlyphId)); group->setValue("position", glyph.first+cache.padding()); - group->setValue("rectangle", Range2Di(glyph.second.bottomLeft()+cache.padding(), - glyph.second.topRight()-cache.padding())); + group->setValue("rectangle", glyph.second.padded(-cache.padding())); } std::ostringstream confOut;