From a45454ca73cb95f615bf28632b4419a268ceaafb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 27 Jan 2013 15:04:25 +0100 Subject: [PATCH] Using CORRADE_INTERNAL_ASSERT_OUTPUT() where appropriate. --- src/Buffer.h | 4 ++-- src/Text/Font.cpp | 14 +++++++------- src/Text/FontRenderer.cpp | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Buffer.h b/src/Buffer.h index a02d20088..0f2b30b08 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -75,7 +75,7 @@ buffer again. Vector3* data = static_cast(buffer.map(0, 200*sizeof(Vector3), Buffer::MapFlag::Write|Buffer::MapFlag::InvalidateBuffer)); for(std::size_t i = 0; i != 200; ++i) data[i] = ...; -CORRADE_INTERNAL_ASSERT(buffer.unmap()); +CORRADE_INTERNAL_ASSERT_OUTPUT(buffer.unmap()); @endcode If you are updating only a few discrete portions of the buffer, you can use @ref MapFlag "MapFlag::FlushExplicit" and flushMappedRange() to reduce number @@ -86,7 +86,7 @@ for(std::size_t i: {7, 27, 56, 128}) { data[i] = ...; buffer.flushMappedRange(i*sizeof(Vector3), sizeof(Vector3)); } -CORRADE_INTERNAL_ASSERT(buffer.unmap()); +CORRADE_INTERNAL_ASSERT_OUTPUT(buffer.unmap()); @endcode @section Buffer-performance-optimization Performance optimizations diff --git a/src/Text/Font.cpp b/src/Text/Font.cpp index 2bdfce706..249ac0b22 100644 --- a/src/Text/Font.cpp +++ b/src/Text/Font.cpp @@ -34,8 +34,8 @@ Font::Font(FontRenderer& renderer, const std::string& fontFile, GLfloat size): _ #endif /* Create FreeType font */ - CORRADE_INTERNAL_ASSERT(FT_New_Face(renderer.library(), fontFile.c_str(), 0, &_ftFont) == 0); - CORRADE_INTERNAL_ASSERT(FT_Set_Char_Size(_ftFont, 0, _size*64, 100, 100) == 0); + CORRADE_INTERNAL_ASSERT_OUTPUT(FT_New_Face(renderer.library(), fontFile.c_str(), 0, &_ftFont) == 0); + CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Set_Char_Size(_ftFont, 0, _size*64, 100, 100) == 0); /* Create Harfbuzz font */ _hbFont = hb_ft_font_create(_ftFont, nullptr); @@ -69,7 +69,7 @@ void Font::prerender(const std::string& characters, const Vector2i& atlasSize) { std::vector charSizes; charSizes.reserve(charIndices.size()); for(FT_UInt c: charIndices) { - CORRADE_INTERNAL_ASSERT(FT_Load_Glyph(_ftFont, c, FT_LOAD_DEFAULT) == 0); + CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Load_Glyph(_ftFont, c, FT_LOAD_DEFAULT) == 0); charSizes.push_back((Vector2i(_ftFont->glyph->metrics.width, _ftFont->glyph->metrics.height))/64); } @@ -84,8 +84,8 @@ void Font::prerender(const std::string& characters, const Vector2i& atlasSize) { /* Load and render glyph */ /** @todo B&W only */ FT_GlyphSlot glyph = _ftFont->glyph; - CORRADE_INTERNAL_ASSERT(FT_Load_Glyph(_ftFont, charIndices[i], FT_LOAD_DEFAULT) == 0); - CORRADE_INTERNAL_ASSERT(FT_Render_Glyph(glyph, FT_RENDER_MODE_NORMAL) == 0); + CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Load_Glyph(_ftFont, charIndices[i], FT_LOAD_DEFAULT) == 0); + CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Render_Glyph(glyph, FT_RENDER_MODE_NORMAL) == 0); /* Copy rendered bitmap to texture image */ const FT_Bitmap& bitmap = glyph->bitmap; @@ -96,12 +96,12 @@ void Font::prerender(const std::string& characters, const Vector2i& atlasSize) { pixmap[yout*atlasSize.x() + xout] = bitmap.buffer[(bitmap.rows-yin-1)*bitmap.width + xin]; /* Save character texture position and texture coordinates for given character index */ - glyphs.insert({charIndices[i], std::make_tuple( + CORRADE_INTERNAL_ASSERT_OUTPUT(glyphs.insert({charIndices[i], std::make_tuple( Rectangle::fromSize(Vector2(glyph->bitmap_left, glyph->bitmap_top-charPositions[i].height())/_size, Vector2(charPositions[i].size())/_size), Rectangle(Vector2(charPositions[i].bottomLeft())/atlasSize, Vector2(charPositions[i].topRight())/atlasSize) - )}); + )}).second); } /* Set texture data */ diff --git a/src/Text/FontRenderer.cpp b/src/Text/FontRenderer.cpp index 94c5fde25..8b1f540f9 100644 --- a/src/Text/FontRenderer.cpp +++ b/src/Text/FontRenderer.cpp @@ -22,7 +22,7 @@ namespace Magnum { namespace Text { FontRenderer::FontRenderer() { - CORRADE_INTERNAL_ASSERT(FT_Init_FreeType(&_library) == 0); + CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Init_FreeType(&_library) == 0); } FontRenderer::~FontRenderer() {