Browse Source

Using CORRADE_INTERNAL_ASSERT_OUTPUT() where appropriate.

pull/7/head
Vladimír Vondruš 13 years ago
parent
commit
a45454ca73
  1. 4
      src/Buffer.h
  2. 14
      src/Text/Font.cpp
  3. 2
      src/Text/FontRenderer.cpp

4
src/Buffer.h

@ -75,7 +75,7 @@ buffer again.
Vector3* data = static_cast<Vector3*>(buffer.map(0, 200*sizeof(Vector3), Buffer::MapFlag::Write|Buffer::MapFlag::InvalidateBuffer)); Vector3* data = static_cast<Vector3*>(buffer.map(0, 200*sizeof(Vector3), Buffer::MapFlag::Write|Buffer::MapFlag::InvalidateBuffer));
for(std::size_t i = 0; i != 200; ++i) for(std::size_t i = 0; i != 200; ++i)
data[i] = ...; data[i] = ...;
CORRADE_INTERNAL_ASSERT(buffer.unmap()); CORRADE_INTERNAL_ASSERT_OUTPUT(buffer.unmap());
@endcode @endcode
If you are updating only a few discrete portions of the buffer, you can use If you are updating only a few discrete portions of the buffer, you can use
@ref MapFlag "MapFlag::FlushExplicit" and flushMappedRange() to reduce number @ref MapFlag "MapFlag::FlushExplicit" and flushMappedRange() to reduce number
@ -86,7 +86,7 @@ for(std::size_t i: {7, 27, 56, 128}) {
data[i] = ...; data[i] = ...;
buffer.flushMappedRange(i*sizeof(Vector3), sizeof(Vector3)); buffer.flushMappedRange(i*sizeof(Vector3), sizeof(Vector3));
} }
CORRADE_INTERNAL_ASSERT(buffer.unmap()); CORRADE_INTERNAL_ASSERT_OUTPUT(buffer.unmap());
@endcode @endcode
@section Buffer-performance-optimization Performance optimizations @section Buffer-performance-optimization Performance optimizations

14
src/Text/Font.cpp

@ -34,8 +34,8 @@ Font::Font(FontRenderer& renderer, const std::string& fontFile, GLfloat size): _
#endif #endif
/* Create FreeType font */ /* Create FreeType font */
CORRADE_INTERNAL_ASSERT(FT_New_Face(renderer.library(), fontFile.c_str(), 0, &_ftFont) == 0); CORRADE_INTERNAL_ASSERT_OUTPUT(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_Set_Char_Size(_ftFont, 0, _size*64, 100, 100) == 0);
/* Create Harfbuzz font */ /* Create Harfbuzz font */
_hbFont = hb_ft_font_create(_ftFont, nullptr); _hbFont = hb_ft_font_create(_ftFont, nullptr);
@ -69,7 +69,7 @@ void Font::prerender(const std::string& characters, const Vector2i& atlasSize) {
std::vector<Vector2i> charSizes; std::vector<Vector2i> charSizes;
charSizes.reserve(charIndices.size()); charSizes.reserve(charIndices.size());
for(FT_UInt c: charIndices) { 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); 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 */ /* Load and render glyph */
/** @todo B&W only */ /** @todo B&W only */
FT_GlyphSlot glyph = _ftFont->glyph; FT_GlyphSlot glyph = _ftFont->glyph;
CORRADE_INTERNAL_ASSERT(FT_Load_Glyph(_ftFont, charIndices[i], FT_LOAD_DEFAULT) == 0); CORRADE_INTERNAL_ASSERT_OUTPUT(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_Render_Glyph(glyph, FT_RENDER_MODE_NORMAL) == 0);
/* Copy rendered bitmap to texture image */ /* Copy rendered bitmap to texture image */
const FT_Bitmap& bitmap = glyph->bitmap; 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]; 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 */ /* 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, Rectangle::fromSize(Vector2(glyph->bitmap_left, glyph->bitmap_top-charPositions[i].height())/_size,
Vector2(charPositions[i].size())/_size), Vector2(charPositions[i].size())/_size),
Rectangle(Vector2(charPositions[i].bottomLeft())/atlasSize, Rectangle(Vector2(charPositions[i].bottomLeft())/atlasSize,
Vector2(charPositions[i].topRight())/atlasSize) Vector2(charPositions[i].topRight())/atlasSize)
)}); )}).second);
} }
/* Set texture data */ /* Set texture data */

2
src/Text/FontRenderer.cpp

@ -22,7 +22,7 @@
namespace Magnum { namespace Text { namespace Magnum { namespace Text {
FontRenderer::FontRenderer() { FontRenderer::FontRenderer() {
CORRADE_INTERNAL_ASSERT(FT_Init_FreeType(&_library) == 0); CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Init_FreeType(&_library) == 0);
} }
FontRenderer::~FontRenderer() { FontRenderer::~FontRenderer() {

Loading…
Cancel
Save